diff --git a/bench/BlurBench.cpp b/bench/BlurBench.cpp index 5b94d66ff6..ce801a0ddc 100644 --- a/bench/BlurBench.cpp +++ b/bench/BlurBench.cpp @@ -6,8 +6,8 @@ */ #include "Benchmark.h" #include "SkBlurMask.h" -#include "SkBlurMaskFilter.h" #include "SkCanvas.h" +#include "SkMaskFilter.h" #include "SkPaint.h" #include "SkRandom.h" #include "SkShader.h" @@ -31,17 +31,14 @@ static const char* gStyleName[] = { class BlurBench : public Benchmark { SkScalar fRadius; SkBlurStyle fStyle; - uint32_t fFlags; SkString fName; public: - BlurBench(SkScalar rad, SkBlurStyle bs, uint32_t flags = 0) { + BlurBench(SkScalar rad, SkBlurStyle bs) { fRadius = rad; fStyle = bs; - fFlags = flags; const char* name = rad > 0 ? gStyleName[bs] : "none"; - const char* quality = flags & SkBlurMaskFilter::kHighQuality_BlurFlag ? "high_quality" - : "low_quality"; + const char* quality = "high_quality"; if (SkScalarFraction(rad) != 0) { fName.printf("blur_%.2f_%s_%s", SkScalarToFloat(rad), name, quality); } else { @@ -67,9 +64,8 @@ protected: r.offset(fRadius, fRadius); if (fRadius > 0) { - paint.setMaskFilter(SkBlurMaskFilter::Make(fStyle, - SkBlurMask::ConvertRadiusToSigma(fRadius), - fFlags)); + paint.setMaskFilter(SkMaskFilter::MakeBlur(fStyle, + SkBlurMask::ConvertRadiusToSigma(fRadius))); } canvas->drawOval(r, paint); } @@ -104,15 +100,4 @@ DEF_BENCH(return new BlurBench(REAL, kSolid_SkBlurStyle);) DEF_BENCH(return new BlurBench(REAL, kOuter_SkBlurStyle);) DEF_BENCH(return new BlurBench(REAL, kInner_SkBlurStyle);) -DEF_BENCH(return new BlurBench(MINI, kNormal_SkBlurStyle, SkBlurMaskFilter::kHighQuality_BlurFlag);) - -DEF_BENCH(return new BlurBench(SMALL, kNormal_SkBlurStyle, SkBlurMaskFilter::kHighQuality_BlurFlag);) - -DEF_BENCH(return new BlurBench(BIG, kNormal_SkBlurStyle, SkBlurMaskFilter::kHighQuality_BlurFlag);) - -DEF_BENCH(return new BlurBench(REALBIG, kNormal_SkBlurStyle, SkBlurMaskFilter::kHighQuality_BlurFlag);) - -DEF_BENCH(return new BlurBench(REAL, kNormal_SkBlurStyle, SkBlurMaskFilter::kHighQuality_BlurFlag);) -DEF_BENCH(return new BlurBench(CUTOVER, kNormal_SkBlurStyle, SkBlurMaskFilter::kHighQuality_BlurFlag);) - DEF_BENCH(return new BlurBench(0, kNormal_SkBlurStyle);) diff --git a/bench/BlurOccludedRRectBench.cpp b/bench/BlurOccludedRRectBench.cpp index 2de50c509a..b5635c5ad8 100644 --- a/bench/BlurOccludedRRectBench.cpp +++ b/bench/BlurOccludedRRectBench.cpp @@ -6,8 +6,8 @@ */ #include "Benchmark.h" -#include "SkBlurMaskFilter.h" #include "SkCanvas.h" +#include "SkMaskFilter.h" #include "SkPaint.h" #include "SkRRect.h" #include "SkRect.h" @@ -48,7 +48,7 @@ public: SkPaint firstBlur; firstBlur.setAntiAlias(true); firstBlur.setColor(0x09000000); - firstBlur.setMaskFilter(SkBlurMaskFilter::Make(kNormal_SkBlurStyle, + firstBlur.setMaskFilter(SkMaskFilter::MakeBlur(kNormal_SkBlurStyle, 2.5f, occRect)); @@ -60,7 +60,7 @@ public: SkPaint secondBlur; secondBlur.setAntiAlias(true); secondBlur.setColor(0x30000000); - secondBlur.setMaskFilter(SkBlurMaskFilter::Make(kNormal_SkBlurStyle, + secondBlur.setMaskFilter(SkMaskFilter::MakeBlur(kNormal_SkBlurStyle, 6.0f, occRect)); diff --git a/bench/BlurRectBench.cpp b/bench/BlurRectBench.cpp index 163130201e..3449ffabed 100644 --- a/bench/BlurRectBench.cpp +++ b/bench/BlurRectBench.cpp @@ -145,7 +145,7 @@ protected: void makeBlurryRect(const SkRect&) override { SkMask mask; if (!SkBlurMask::BoxBlur(&mask, fSrcMask, SkBlurMask::ConvertRadiusToSigma(this->radius()), - kNormal_SkBlurStyle, kHigh_SkBlurQuality)) { + kNormal_SkBlurStyle)) { return; } SkMask::FreeImage(mask.fImage); diff --git a/bench/BlurRectsBench.cpp b/bench/BlurRectsBench.cpp index fc04d0294e..d41ee1aafa 100644 --- a/bench/BlurRectsBench.cpp +++ b/bench/BlurRectsBench.cpp @@ -6,8 +6,8 @@ */ #include "Benchmark.h" -#include "SkBlurMaskFilter.h" #include "SkCanvas.h" +#include "SkMaskFilter.h" #include "SkPaint.h" #include "SkPath.h" #include "SkRect.h" @@ -31,7 +31,7 @@ public: void onDraw(int loops, SkCanvas* canvas) override { SkPaint paint; - paint.setMaskFilter(SkBlurMaskFilter::Make(kNormal_SkBlurStyle, fRadius)); + paint.setMaskFilter(SkMaskFilter::MakeBlur(kNormal_SkBlurStyle, fRadius)); SkPath path; path.addRect(fOuter, SkPath::kCW_Direction); diff --git a/bench/BlurRoundRectBench.cpp b/bench/BlurRoundRectBench.cpp index 6ebc641fd9..085a8eb0e6 100644 --- a/bench/BlurRoundRectBench.cpp +++ b/bench/BlurRoundRectBench.cpp @@ -7,10 +7,10 @@ #include "Benchmark.h" #include "SkBlurMask.h" -#include "SkBlurMaskFilter.h" #include "SkCanvas.h" #include "SkColorFilter.h" #include "SkLayerDrawLooper.h" +#include "SkMaskFilter.h" #include "SkPaint.h" #include "SkPath.h" #include "SkPoint.h" @@ -48,9 +48,8 @@ public: info.fOffset = SkPoint::Make(SkIntToScalar(-1), SkIntToScalar(0)); info.fPostTranslate = false; SkPaint* paint = looperBuilder.addLayerOnTop(info); - paint->setMaskFilter(SkBlurMaskFilter::Make(kNormal_SkBlurStyle, - SkBlurMask::ConvertRadiusToSigma(0.5), - SkBlurMaskFilter::kHighQuality_BlurFlag)); + paint->setMaskFilter(SkMaskFilter::MakeBlur(kNormal_SkBlurStyle, + SkBlurMask::ConvertRadiusToSigma(0.5))); paint->setColorFilter(SkColorFilter::MakeModeFilter(SK_ColorLTGRAY, SkBlendMode::kSrcIn)); paint->setColor(SK_ColorGRAY); diff --git a/bench/RectoriBench.cpp b/bench/RectoriBench.cpp index 416f9ea2ba..c0d21552f9 100644 --- a/bench/RectoriBench.cpp +++ b/bench/RectoriBench.cpp @@ -6,9 +6,9 @@ */ #include "Benchmark.h" -#include "SkBlurMaskFilter.h" #include "SkCanvas.h" #include "SkLayerDrawLooper.h" +#include "SkMaskFilter.h" #include "SkPaint.h" #include "SkPath.h" #include "SkRandom.h" @@ -86,8 +86,7 @@ private: SkPaint* paint = looperBuilder.addLayer(info); - paint->setMaskFilter(SkBlurMaskFilter::Make(kNormal_SkBlurStyle, sigma, - SkBlurMaskFilter::kHighQuality_BlurFlag)); + paint->setMaskFilter(SkMaskFilter::MakeBlur(kNormal_SkBlurStyle, sigma)); //----------------------------------------------- info.fPaintBits = 0; diff --git a/fuzz/FuzzCanvas.cpp b/fuzz/FuzzCanvas.cpp index 783306b22f..0180809a70 100644 --- a/fuzz/FuzzCanvas.cpp +++ b/fuzz/FuzzCanvas.cpp @@ -509,8 +509,9 @@ static sk_sp make_fuzz_maskfilter(Fuzz* fuzz) { fuzz->next(&occluder); } uint32_t flags; - fuzz->nextRange(&flags, 0, 3); - return SkBlurMaskFilter::Make(blurStyle, sigma, occluder, flags); + fuzz->nextRange(&flags, 0, 1); + bool respectCTM = flags != 0; + return SkMaskFilter::MakeBlur(blurStyle, sigma, occluder, respectCTM); } case 2: { SkRRect first, second; diff --git a/gm/alpha_image.cpp b/gm/alpha_image.cpp index 0a0da03a3b..06fb3f6549 100644 --- a/gm/alpha_image.cpp +++ b/gm/alpha_image.cpp @@ -7,9 +7,9 @@ #include "gm.h" -#include "SkBlurMaskFilter.h" #include "SkColorFilter.h" #include "SkImage.h" +#include "SkMaskFilter.h" #include "SkShader.h" static SkBitmap make_alpha_image(int w, int h) { @@ -39,7 +39,7 @@ DEF_SIMPLE_GM(alpha_image, canvas, 256, 256) { SkPaint paint; paint.setColorFilter(make_color_filter()); - paint.setMaskFilter(SkBlurMaskFilter::Make(kNormal_SkBlurStyle, 10.0f, 0)); + paint.setMaskFilter(SkMaskFilter::MakeBlur(kNormal_SkBlurStyle, 10.0f)); canvas->drawImage(image.get(), 16, 16, &paint); paint.setColorFilter(nullptr); diff --git a/gm/bigblurs.cpp b/gm/bigblurs.cpp index be5a6b8f9f..83f6bd4a44 100644 --- a/gm/bigblurs.cpp +++ b/gm/bigblurs.cpp @@ -8,7 +8,7 @@ #include "gm.h" #include "sk_tool_utils.h" #include "SkBlurMask.h" -#include "SkBlurMaskFilter.h" +#include "SkMaskFilter.h" #include "SkPath.h" namespace skiagm { @@ -71,7 +71,7 @@ protected: for (int i = 0; i < 2; ++i) { for (int j = 0; j <= kLastEnum_SkBlurStyle; ++j) { - blurPaint.setMaskFilter(SkBlurMaskFilter::Make((SkBlurStyle)j, kSigma)); + blurPaint.setMaskFilter(SkMaskFilter::MakeBlur((SkBlurStyle)j, kSigma)); for (int k = 0; k < (int)SK_ARRAY_COUNT(origins); ++k) { canvas->save(); diff --git a/gm/bleed.cpp b/gm/bleed.cpp index b6ee10b555..85d3328428 100644 --- a/gm/bleed.cpp +++ b/gm/bleed.cpp @@ -7,10 +7,10 @@ #include "gm.h" #include "SkBlurMask.h" -#include "SkBlurMaskFilter.h" #include "SkCanvas.h" #include "SkGradientShader.h" #include "SkImage.h" +#include "SkMaskFilter.h" #include "SkTDArray.h" #include "SkUtils.h" #include "sk_tool_utils.h" @@ -281,7 +281,7 @@ protected: SkPaint paint; paint.setFilterQuality(filter); - paint.setMaskFilter(SkBlurMaskFilter::Make(kNormal_SkBlurStyle, + paint.setMaskFilter(SkMaskFilter::MakeBlur(kNormal_SkBlurStyle, SkBlurMask::ConvertRadiusToSigma(3))); paint.setShader(fShader); paint.setColor(SK_ColorBLUE); @@ -299,7 +299,7 @@ protected: SkPaint paint; paint.setFilterQuality(filter); - paint.setMaskFilter(SkBlurMaskFilter::Make(kOuter_SkBlurStyle, + paint.setMaskFilter(SkMaskFilter::MakeBlur(kOuter_SkBlurStyle, SkBlurMask::ConvertRadiusToSigma(7))); paint.setShader(fShader); paint.setColor(SK_ColorBLUE); diff --git a/gm/blurcircles.cpp b/gm/blurcircles.cpp index 13cbeb864d..e0978c0caf 100644 --- a/gm/blurcircles.cpp +++ b/gm/blurcircles.cpp @@ -7,8 +7,8 @@ #include "gm.h" #include "SkBlurMask.h" -#include "SkBlurMaskFilter.h" #include "SkCanvas.h" +#include "SkMaskFilter.h" #include "SkPaint.h" #include "SkString.h" @@ -31,10 +31,9 @@ protected: const float blurRadii[kNumBlurs] = { 1,5,10,20 }; for (int i = 0; i < kNumBlurs; ++i) { - fBlurFilters[i] = SkBlurMaskFilter::Make( + fBlurFilters[i] = SkMaskFilter::MakeBlur( kNormal_SkBlurStyle, - SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(blurRadii[i])), - SkBlurMaskFilter::kHighQuality_BlurFlag); + SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(blurRadii[i]))); } } diff --git a/gm/blurcircles2.cpp b/gm/blurcircles2.cpp index a65763e540..c2739a948c 100644 --- a/gm/blurcircles2.cpp +++ b/gm/blurcircles2.cpp @@ -55,9 +55,8 @@ protected: }; auto blurMaker = [] (SkScalar radius) ->sk_sp { - return SkBlurMaskFilter::Make(kNormal_SkBlurStyle, - SkBlurMask::ConvertRadiusToSigma(radius), - SkBlurMaskFilter::kHighQuality_BlurFlag); + return SkMaskFilter::MakeBlur(kNormal_SkBlurStyle, + SkBlurMask::ConvertRadiusToSigma(radius)); }; SkPaint paint; diff --git a/gm/blurignorexform.cpp b/gm/blurignorexform.cpp index 8db56ab8d7..1e89dec681 100644 --- a/gm/blurignorexform.cpp +++ b/gm/blurignorexform.cpp @@ -9,8 +9,8 @@ #include "sk_tool_utils.h" #include "SkBlurMask.h" -#include "SkBlurMaskFilter.h" #include "SkCanvas.h" +#include "SkMaskFilter.h" #include "SkPaint.h" // This GM tests out the SkBlurMaskFilter's kIgnoreTransform flag. That flag causes the blur mask @@ -42,10 +42,10 @@ protected: void onOnceBeforeDraw() override { for (int i = 0; i < kNumBlurs; ++i) { - fBlurFilters[i] = SkBlurMaskFilter::Make( + fBlurFilters[i] = SkMaskFilter::MakeBlur( kNormal_SkBlurStyle, SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(20)), - SkBlurMaskFilter::kHighQuality_BlurFlag | kBlurFlags[i].fFlags); + kBlurFlags[i].fRespectCTM); } } @@ -114,7 +114,7 @@ private: static constexpr int kNumBlurs = 2; static const struct BlurFlags { - uint32_t fFlags; + bool fRespectCTM; const char* fName; } kBlurFlags[kNumBlurs]; @@ -130,8 +130,8 @@ private: }; const BlurIgnoreXformGM::BlurFlags BlurIgnoreXformGM::kBlurFlags[] = { - {0, "none"}, - {SkBlurMaskFilter::kIgnoreTransform_BlurFlag, "IgnoreTransform"} + {true, "none"}, + {false, "IgnoreTransform"} }; const BlurIgnoreXformGM::MatrixScale BlurIgnoreXformGM::kMatrixScales[] = { diff --git a/gm/blurimagevmask.cpp b/gm/blurimagevmask.cpp index c1f9b3e1ec..22e49c5f00 100644 --- a/gm/blurimagevmask.cpp +++ b/gm/blurimagevmask.cpp @@ -5,8 +5,8 @@ * found in the LICENSE file. */ -#include "SkBlurMaskFilter.h" #include "SkBlurImageFilter.h" +#include "SkMaskFilter.h" #include "gm.h" #include "sk_tool_utils.h" @@ -38,9 +38,7 @@ DEF_SIMPLE_GM(blurimagevmask, canvas, 700, 1200) { r.offset(250, 0); - paint.setMaskFilter( - SkBlurMaskFilter::Make(kNormal_SkBlurStyle, sigma, - SkBlurMaskFilter::kHighQuality_BlurFlag)); + paint.setMaskFilter(SkMaskFilter::MakeBlur(kNormal_SkBlurStyle, sigma)); canvas->drawRect(r, paint); paint.setMaskFilter(nullptr); @@ -61,7 +59,7 @@ DEF_SIMPLE_GM(blur_image, canvas, 500, 500) { auto image = GetResourceAsImage("images/mandrill_128.png"); SkPaint paint; - paint.setMaskFilter(SkBlurMaskFilter::Make(kNormal_SkBlurStyle, 4)); + paint.setMaskFilter(SkMaskFilter::MakeBlur(kNormal_SkBlurStyle, 4)); // both of these should draw with the blur, but (formerally) we had a bug where the unscaled // version (taking the spriteblitter code path) ignore the maskfilter. diff --git a/gm/blurquickreject.cpp b/gm/blurquickreject.cpp index 452cdf7e91..237c678f4d 100644 --- a/gm/blurquickreject.cpp +++ b/gm/blurquickreject.cpp @@ -7,8 +7,8 @@ #include "gm.h" #include "SkBlurMask.h" -#include "SkBlurMaskFilter.h" #include "SkCanvas.h" +#include "SkMaskFilter.h" // This GM tests out the quick reject bounds of the blur mask filter. It draws // four blurred rects around a central clip. The blurred rect geometry outset @@ -56,7 +56,7 @@ protected: SkPaint blurPaint; blurPaint.setFilterQuality(kLow_SkFilterQuality); - blurPaint.setMaskFilter(SkBlurMaskFilter::Make(kNormal_SkBlurStyle, + blurPaint.setMaskFilter(SkMaskFilter::MakeBlur(kNormal_SkBlurStyle, SkBlurMask::ConvertRadiusToSigma(kBlurRadius))); canvas->clear(SK_ColorBLACK); diff --git a/gm/blurrect.cpp b/gm/blurrect.cpp index 54f3c216c0..a718cdeac6 100644 --- a/gm/blurrect.cpp +++ b/gm/blurrect.cpp @@ -7,8 +7,8 @@ #include "gm.h" #include "SkBlurMask.h" -#include "SkBlurMaskFilter.h" #include "SkCanvas.h" +#include "SkMaskFilter.h" #include "SkPath.h" #define STROKE_WIDTH SkIntToScalar(10) @@ -95,9 +95,8 @@ public: protected: void onOnceBeforeDraw() override { for (int i = 0; i <= kLastEnum_SkBlurStyle; ++i) { - fMaskFilters[i] = SkBlurMaskFilter::Make((SkBlurStyle)i, - SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(STROKE_WIDTH/2)), - SkBlurMaskFilter::kHighQuality_BlurFlag); + fMaskFilters[i] = SkMaskFilter::MakeBlur((SkBlurStyle)i, + SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(STROKE_WIDTH/2))); } } diff --git a/gm/blurredclippedcircle.cpp b/gm/blurredclippedcircle.cpp index f62cb1270e..533555d015 100644 --- a/gm/blurredclippedcircle.cpp +++ b/gm/blurredclippedcircle.cpp @@ -7,9 +7,9 @@ #include "gm.h" #include "sk_tool_utils.h" -#include "SkBlurMaskFilter.h" #include "SkClipOpPriv.h" #include "SkColorFilter.h" +#include "SkMaskFilter.h" #include "SkPaint.h" #include "SkRRect.h" @@ -65,10 +65,9 @@ protected: SkPaint paint; - paint.setMaskFilter(SkBlurMaskFilter::Make( + paint.setMaskFilter(SkMaskFilter::MakeBlur( kNormal_SkBlurStyle, - 1.366025f, - SkBlurMaskFilter::kHighQuality_BlurFlag)); + 1.366025f)); paint.setColorFilter(SkColorFilter::MakeModeFilter( SK_ColorRED, SkBlendMode::kSrcIn)); diff --git a/gm/blurroundrect.cpp b/gm/blurroundrect.cpp index 32a5bc4e49..289e156345 100644 --- a/gm/blurroundrect.cpp +++ b/gm/blurroundrect.cpp @@ -8,10 +8,10 @@ #include "gm.h" #include "sk_tool_utils.h" #include "SkBlurMask.h" -#include "SkBlurMaskFilter.h" #include "SkCanvas.h" #include "SkColorFilter.h" #include "SkLayerDrawLooper.h" +#include "SkMaskFilter.h" #include "SkPaint.h" #include "SkPath.h" #include "SkPoint.h" @@ -55,10 +55,9 @@ public: info.fOffset = SkPoint::Make(SkIntToScalar(-1), SkIntToScalar(0)); info.fPostTranslate = false; SkPaint* paint = looperBuilder.addLayerOnTop(info); - paint->setMaskFilter(SkBlurMaskFilter::Make( + paint->setMaskFilter(SkMaskFilter::MakeBlur( kNormal_SkBlurStyle, - SkBlurMask::ConvertRadiusToSigma(SK_ScalarHalf), - SkBlurMaskFilter::kHighQuality_BlurFlag)); + SkBlurMask::ConvertRadiusToSigma(SK_ScalarHalf))); paint->setColorFilter(SkColorFilter::MakeModeFilter( sk_tool_utils::color_to_565(SK_ColorLTGRAY), SkBlendMode::kSrcIn)); @@ -143,9 +142,8 @@ protected: for (int k = 0; k <= 1; k++) { SkPaint paint; paint.setColor(SK_ColorBLACK); - paint.setMaskFilter(SkBlurMaskFilter::Make(kNormal_SkBlurStyle, - SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(blurRadii[i])), - SkBlurMaskFilter::kHighQuality_BlurFlag)); + paint.setMaskFilter(SkMaskFilter::MakeBlur(kNormal_SkBlurStyle, + SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(blurRadii[i])))); bool useRadial = SkToBool(k); if (useRadial) { diff --git a/gm/blurs.cpp b/gm/blurs.cpp index 0e0374e0a5..1ba13691e2 100644 --- a/gm/blurs.cpp +++ b/gm/blurs.cpp @@ -9,8 +9,8 @@ #include "sk_tool_utils.h" #include "Resources.h" #include "SkBlurMask.h" -#include "SkBlurMaskFilter.h" #include "SkImage.h" +#include "SkMaskFilter.h" #include "SkPath.h" DEF_SIMPLE_GM_BG(blurs, canvas, 700, 500, sk_tool_utils::color_to_565(0xFFDDDDDD)) { @@ -32,43 +32,34 @@ DEF_SIMPLE_GM_BG(blurs, canvas, 700, 500, sk_tool_utils::color_to_565(0xFFDDDDDD paint.setTextSize(SkIntToScalar(25)); canvas->translate(SkIntToScalar(-40), SkIntToScalar(0)); - SkBlurMaskFilter::BlurFlags flags = SkBlurMaskFilter::kNone_BlurFlag; - for (int j = 0; j < 2; j++) { - canvas->save(); - paint.setColor(SK_ColorBLUE); - for (size_t i = 0; i < SK_ARRAY_COUNT(gRecs); i++) { - if (gRecs[i].fStyle != NONE) { - paint.setMaskFilter(SkBlurMaskFilter::Make(gRecs[i].fStyle, - SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(20)), - flags)); - } else { - paint.setMaskFilter(nullptr); - } - canvas->drawCircle(SkIntToScalar(200 + gRecs[i].fCx*100), - SkIntToScalar(200 + gRecs[i].fCy*100), - SkIntToScalar(50), - paint); - } - // draw text - { - paint.setMaskFilter(SkBlurMaskFilter::Make(kNormal_SkBlurStyle, - SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(4)), - flags)); - SkScalar x = SkIntToScalar(70); - SkScalar y = SkIntToScalar(400); - paint.setColor(SK_ColorBLACK); - canvas->drawString("Hamburgefons Style", x, y, paint); - canvas->drawString("Hamburgefons Style", - x, y + SkIntToScalar(50), paint); + paint.setColor(SK_ColorBLUE); + for (size_t i = 0; i < SK_ARRAY_COUNT(gRecs); i++) { + if (gRecs[i].fStyle != NONE) { + paint.setMaskFilter(SkMaskFilter::MakeBlur(gRecs[i].fStyle, + SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(20)))); + } else { paint.setMaskFilter(nullptr); - paint.setColor(SK_ColorWHITE); - x -= SkIntToScalar(2); - y -= SkIntToScalar(2); - canvas->drawString("Hamburgefons Style", x, y, paint); } - canvas->restore(); - flags = SkBlurMaskFilter::kHighQuality_BlurFlag; - canvas->translate(SkIntToScalar(350), SkIntToScalar(0)); + canvas->drawCircle(SkIntToScalar(200 + gRecs[i].fCx*100), + SkIntToScalar(200 + gRecs[i].fCy*100), + SkIntToScalar(50), + paint); + } + // draw text + { + paint.setMaskFilter(SkMaskFilter::MakeBlur(kNormal_SkBlurStyle, + SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(4)))); + SkScalar x = SkIntToScalar(70); + SkScalar y = SkIntToScalar(400); + paint.setColor(SK_ColorBLACK); + canvas->drawString("Hamburgefons Style", x, y, paint); + canvas->drawString("Hamburgefons Style", + x, y + SkIntToScalar(50), paint); + paint.setMaskFilter(nullptr); + paint.setColor(SK_ColorWHITE); + x -= SkIntToScalar(2); + y -= SkIntToScalar(2); + canvas->drawString("Hamburgefons Style", x, y, paint); } } @@ -83,7 +74,7 @@ DEF_SIMPLE_GM_BG(blurs, canvas, 700, 500, sk_tool_utils::color_to_565(0xFFDDDDDD DEF_SIMPLE_GM(blur2rects, canvas, 700, 500) { SkPaint paint; - paint.setMaskFilter(SkBlurMaskFilter::Make(kNormal_SkBlurStyle, 2.3f)); + paint.setMaskFilter(SkMaskFilter::MakeBlur(kNormal_SkBlurStyle, 2.3f)); SkRect outer = SkRect::MakeXYWH(10.125f, 10.125f, 100.125f, 100); SkRect inner = SkRect::MakeXYWH(20.25f, 20.125f, 80, 80); @@ -101,7 +92,7 @@ DEF_SIMPLE_GM(blur2rects, canvas, 700, 500) { DEF_SIMPLE_GM(blur2rectsnonninepatch, canvas, 700, 500) { SkPaint paint; - paint.setMaskFilter(SkBlurMaskFilter::Make(kNormal_SkBlurStyle, 4.3f)); + paint.setMaskFilter(SkMaskFilter::MakeBlur(kNormal_SkBlurStyle, 4.3f)); SkRect outer = SkRect::MakeXYWH(10, 110, 100, 100); SkRect inner = SkRect::MakeXYWH(50, 150, 10, 10); @@ -122,7 +113,7 @@ DEF_SIMPLE_GM(blur2rectsnonninepatch, canvas, 700, 500) { DEF_SIMPLE_GM(BlurDrawImage, canvas, 256, 256) { SkPaint paint; - paint.setMaskFilter(SkBlurMaskFilter::Make(kNormal_SkBlurStyle, 10, 0)); + paint.setMaskFilter(SkMaskFilter::MakeBlur(kNormal_SkBlurStyle, 10)); canvas->clear(0xFF88FF88); if (auto image = GetResourceAsImage("images/mandrill_512_q075.jpg")) { canvas->scale(0.25, 0.25); diff --git a/gm/blurtextsmallradii.cpp b/gm/blurtextsmallradii.cpp index 610338144c..62572ce49d 100644 --- a/gm/blurtextsmallradii.cpp +++ b/gm/blurtextsmallradii.cpp @@ -6,8 +6,8 @@ */ #include "gm.h" -#include "SkBlurMaskFilter.h" #include "SkColor.h" +#include "SkMaskFilter.h" // GM to check the behavior from chrome bug:745290 DEF_SIMPLE_GM(blurSmallRadii, canvas, 100, 100) { @@ -17,7 +17,7 @@ DEF_SIMPLE_GM(blurSmallRadii, canvas, 100, 100) { for (auto sigma : sigmas) { paint.setColor(SK_ColorBLACK); paint.setAntiAlias(true); - paint.setMaskFilter(SkBlurMaskFilter::Make(kNormal_SkBlurStyle, sigma)); + paint.setMaskFilter(SkMaskFilter::MakeBlur(kNormal_SkBlurStyle, sigma)); canvas->drawString("Guest", 20, 10, paint); paint.setMaskFilter(nullptr); diff --git a/gm/circles.cpp b/gm/circles.cpp index 9d2eca5ba7..4c4a3a5263 100644 --- a/gm/circles.cpp +++ b/gm/circles.cpp @@ -7,9 +7,9 @@ #include "gm.h" #include "SkBlurDrawLooper.h" #include "SkBlurMask.h" -#include "SkBlurMaskFilter.h" #include "SkColorFilter.h" #include "SkGradientShader.h" +#include "SkMaskFilter.h" #include "SkMatrix.h" #include "SkRandom.h" #include "SkTArray.h" @@ -52,10 +52,9 @@ protected: // AA with mask filter SkPaint p; p.setAntiAlias(true); - p.setMaskFilter(SkBlurMaskFilter::Make( + p.setMaskFilter(SkMaskFilter::MakeBlur( kNormal_SkBlurStyle, - SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(5)), - SkBlurMaskFilter::kHighQuality_BlurFlag)); + SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(5)))); fPaints.push_back(p); } diff --git a/gm/clip_error.cpp b/gm/clip_error.cpp index 0a3eceb66a..49c51a7457 100644 --- a/gm/clip_error.cpp +++ b/gm/clip_error.cpp @@ -8,8 +8,8 @@ #include "gm.h" #include "sk_tool_utils.h" #include "SkBlurMask.h" -#include "SkBlurMaskFilter.h" #include "SkCanvas.h" +#include "SkMaskFilter.h" #include "SkTextBlob.h" #define WIDTH 800 @@ -53,7 +53,7 @@ protected: const SkScalar kSigma = SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(50)); SkPaint blurPaint(paint); - blurPaint.setMaskFilter(SkBlurMaskFilter::Make(kNormal_SkBlurStyle, kSigma)); + blurPaint.setMaskFilter(SkMaskFilter::MakeBlur(kNormal_SkBlurStyle, kSigma)); SkTextBlobBuilder builder; diff --git a/gm/drawbitmaprect.cpp b/gm/drawbitmaprect.cpp index 6b5f6d9920..e90f52df76 100644 --- a/gm/drawbitmaprect.cpp +++ b/gm/drawbitmaprect.cpp @@ -224,10 +224,9 @@ protected: paint.setFilterQuality(kLow_SkFilterQuality); srcRect.setXYWH(1, 1, 3, 3); - paint.setMaskFilter(SkBlurMaskFilter::Make( + paint.setMaskFilter(SkMaskFilter::MakeBlur( kNormal_SkBlurStyle, - SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(5)), - SkBlurMaskFilter::kHighQuality_BlurFlag)); + SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(5)))); sk_sp image(SkImage::MakeFromBitmap(bm)); fProc(canvas, image.get(), bm, srcRect, dstRect, &paint); diff --git a/gm/drawfilter.cpp b/gm/drawfilter.cpp index b283c1308b..f054cc5226 100644 --- a/gm/drawfilter.cpp +++ b/gm/drawfilter.cpp @@ -7,9 +7,9 @@ #include "gm.h" #include "SkBlurMask.h" -#include "SkBlurMaskFilter.h" #include "SkCanvas.h" #include "SkDrawFilter.h" +#include "SkMaskFilter.h" #include "SkPaint.h" #ifdef SK_SUPPORT_LEGACY_DRAWFILTER @@ -45,9 +45,8 @@ protected: } void onOnceBeforeDraw() override { - fBlur = SkBlurMaskFilter::Make(kNormal_SkBlurStyle, - SkBlurMask::ConvertRadiusToSigma(10.0f), - kLow_SkBlurQuality); + fBlur = SkMaskFilter::MakeBlur(kNormal_SkBlurStyle, + SkBlurMask::ConvertRadiusToSigma(10.0f)); } void onDraw(SkCanvas* canvas) override { diff --git a/gm/drawlooper.cpp b/gm/drawlooper.cpp index 07ec8d8c3f..49f1f1279d 100644 --- a/gm/drawlooper.cpp +++ b/gm/drawlooper.cpp @@ -8,10 +8,10 @@ #include "gm.h" #include "sk_tool_utils.h" #include "SkBlurMask.h" -#include "SkBlurMaskFilter.h" #include "SkCanvas.h" #include "SkGraphics.h" #include "SkLayerDrawLooper.h" +#include "SkMaskFilter.h" #include "SkRandom.h" #define WIDTH 200 @@ -78,7 +78,7 @@ private: paint->setStyle(gParams[i].fStyle); paint->setStrokeWidth(gParams[i].fWidth); if (gParams[i].fBlur > 0) { - paint->setMaskFilter(SkBlurMaskFilter::Make(kNormal_SkBlurStyle, + paint->setMaskFilter(SkMaskFilter::MakeBlur(kNormal_SkBlurStyle, SkBlurMask::ConvertRadiusToSigma(gParams[i].fBlur))); } } diff --git a/gm/drawregionmodes.cpp b/gm/drawregionmodes.cpp index 88e320085a..7e4765aaec 100644 --- a/gm/drawregionmodes.cpp +++ b/gm/drawregionmodes.cpp @@ -7,10 +7,10 @@ #include "gm.h" #include "SkBlurImageFilter.h" -#include "SkBlurMaskFilter.h" #include "SkCanvas.h" #include "SkDashPathEffect.h" #include "SkGradientShader.h" +#include "SkMaskFilter.h" #include "SkRegion.h" class DrawRegionModesGM : public skiagm::GM { @@ -50,7 +50,7 @@ protected: canvas->translate(-125.0f, 125.0f); paint.setImageFilter(nullptr); SkRect occluder = SkRect::MakeEmpty(); - paint.setMaskFilter(SkBlurMaskFilter::Make(kNormal_SkBlurStyle, 5.0f, occluder, 0)); + paint.setMaskFilter(SkMaskFilter::MakeBlur(kNormal_SkBlurStyle, 5.0f, occluder)); canvas->drawRegion(fRegion, paint); canvas->translate(-125.0f, -125.0f); diff --git a/gm/largeglyphblur.cpp b/gm/largeglyphblur.cpp index fe82b5ed8c..40390cf79a 100644 --- a/gm/largeglyphblur.cpp +++ b/gm/largeglyphblur.cpp @@ -9,8 +9,8 @@ #include "sk_tool_utils.h" #include "SkBlurMask.h" -#include "SkBlurMaskFilter.h" #include "SkCanvas.h" +#include "SkMaskFilter.h" #include "SkTextBlob.h" // This test ensures that glyphs whose point size is less than the SkGlyphCache's maxmium, but @@ -27,7 +27,7 @@ DEF_SIMPLE_GM(largeglyphblur, canvas, 1920, 600) { const SkScalar kSigma = SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(40)); SkPaint blurPaint(paint); - blurPaint.setMaskFilter(SkBlurMaskFilter::Make(kNormal_SkBlurStyle, kSigma)); + blurPaint.setMaskFilter(SkMaskFilter::MakeBlur(kNormal_SkBlurStyle, kSigma)); SkTextBlobBuilder builder; diff --git a/gm/megalooper.cpp b/gm/megalooper.cpp index 57df53aebd..e2e53e75fa 100644 --- a/gm/megalooper.cpp +++ b/gm/megalooper.cpp @@ -7,10 +7,10 @@ #include "gm.h" #include "SkBlurMask.h" -#include "SkBlurMaskFilter.h" #include "SkCanvas.h" #include "SkColorFilter.h" #include "SkLayerDrawLooper.h" +#include "SkMaskFilter.h" // This GM tests 3 different ways of drawing four shadows around a square: // just using 4 blurred rects @@ -113,8 +113,7 @@ private: static sk_sp MakeBlur() { const SkScalar kBlurSigma = SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(25)); - return SkBlurMaskFilter::Make(kNormal_SkBlurStyle, kBlurSigma, - SkBlurMaskFilter::kHighQuality_BlurFlag); + return SkMaskFilter::MakeBlur(kNormal_SkBlurStyle, kBlurSigma); } // This draws 4 blurred shadows around a single square (centered at x, y). diff --git a/gm/occludedrrectblur.cpp b/gm/occludedrrectblur.cpp index b43f451490..e72d2920c3 100644 --- a/gm/occludedrrectblur.cpp +++ b/gm/occludedrrectblur.cpp @@ -7,7 +7,7 @@ #include "gm.h" #include "sk_tool_utils.h" -#include "SkBlurMaskFilter.h" +#include "SkMaskFilter.h" #include "SkRRect.h" static SkRect offset_center_to(const SkIRect& src, SkScalar x, SkScalar y) { @@ -46,7 +46,7 @@ static void draw_rrect(SkCanvas* canvas, const SkRRect& rr, const SkRRect& occRR // draw the blur SkPaint paint; - paint.setMaskFilter(SkBlurMaskFilter::Make(kNormal_SkBlurStyle, kBlurSigma, occRect)); + paint.setMaskFilter(SkMaskFilter::MakeBlur(kNormal_SkBlurStyle, kBlurSigma, occRect)); canvas->drawRRect(rr, paint); // draw the stroked geometry of the full occluder diff --git a/gm/rects.cpp b/gm/rects.cpp index d8c2fd9a42..9d7ac6dbb8 100644 --- a/gm/rects.cpp +++ b/gm/rects.cpp @@ -65,10 +65,9 @@ protected: SkPaint p; p.setColor(SK_ColorWHITE); p.setAntiAlias(true); - p.setMaskFilter(SkBlurMaskFilter::Make( + p.setMaskFilter(SkMaskFilter::MakeBlur( kNormal_SkBlurStyle, - SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(5)), - SkBlurMaskFilter::kHighQuality_BlurFlag)); + SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(5)))); fPaints.push_back(p); } diff --git a/gm/reveal.cpp b/gm/reveal.cpp index e58807c090..93c64ae2c2 100644 --- a/gm/reveal.cpp +++ b/gm/reveal.cpp @@ -8,7 +8,7 @@ #include "gm.h" #include "sk_tool_utils.h" #include "SkAnimTimer.h" -#include "SkBlurMaskFilter.h" +#include "SkMaskFilter.h" #include "SkRRectsGaussianEdgeMaskFilter.h" #include "SkPath.h" #include "SkPathOps.h" @@ -400,7 +400,7 @@ protected: SkPaint blurPaint; blurPaint.setAntiAlias(true); - blurPaint.setMaskFilter(SkBlurMaskFilter::Make(kNormal_SkBlurStyle, sigma)); + blurPaint.setMaskFilter(SkMaskFilter::MakeBlur(kNormal_SkBlurStyle, sigma)); canvas->drawPath(clippedPath, blurPaint); } else { SkASSERT(kRRectsGaussianEdge_Mode == fMode); diff --git a/gm/samplerstress.cpp b/gm/samplerstress.cpp index f3287437ee..25ef76c07b 100644 --- a/gm/samplerstress.cpp +++ b/gm/samplerstress.cpp @@ -7,8 +7,8 @@ #include "gm.h" #include "sk_tool_utils.h" -#include "SkBlurMaskFilter.h" #include "SkCanvas.h" +#include "SkMaskFilter.h" #include "SkPath.h" #include "SkShader.h" @@ -82,7 +82,7 @@ protected: } const SkScalar sigma = 1; - fMaskFilter = SkBlurMaskFilter::Make(kNormal_SkBlurStyle, sigma); + fMaskFilter = SkMaskFilter::MakeBlur(kNormal_SkBlurStyle, sigma); } void onDraw(SkCanvas* canvas) override { diff --git a/gm/shadermaskfilter.cpp b/gm/shadermaskfilter.cpp index d561967cd8..c1bee02e6d 100644 --- a/gm/shadermaskfilter.cpp +++ b/gm/shadermaskfilter.cpp @@ -8,9 +8,9 @@ #include "gm.h" #include "sk_tool_utils.h" #include "SkBlendModePriv.h" -#include "SkBlurMaskFilter.h" #include "SkCanvas.h" #include "SkImage.h" +#include "SkMaskFilter.h" #include "SkShaderMaskFilter.h" static void draw_masked_image(SkCanvas* canvas, const SkImage* image, SkScalar x, SkScalar y, @@ -58,7 +58,7 @@ DEF_SIMPLE_GM(shadermaskfilter_image, canvas, 560, 370) { auto image = GetResourceAsImage("images/mandrill_128.png"); auto mask = GetResourceAsImage("images/color_wheel.png"); - auto blurmf = SkBlurMaskFilter::Make(kNormal_SkBlurStyle, 5); + auto blurmf = SkMaskFilter::MakeBlur(kNormal_SkBlurStyle, 5); auto gradmf = SkShaderMaskFilter::Make(make_shader(SkRect::MakeIWH(mask->width(), mask->height()))); @@ -166,7 +166,7 @@ DEF_SIMPLE_GM(combinemaskfilter, canvas, 560, 510) { #include "SkSurface.h" #include "SkBlurImageFilter.h" -#include "SkBlurMaskFilter.h" +#include "SkMaskFilter.h" static sk_sp make_circle_image(SkCanvas* canvas, SkScalar radius, int margin) { const int n = SkScalarCeilToInt(radius) * 2 + margin * 2; auto surf = sk_tool_utils::makeSurface(canvas, SkImageInfo::MakeN32Premul(n, n)); @@ -190,7 +190,7 @@ DEF_SIMPLE_GM(savelayer_maskfilter, canvas, 450, 675) { sk_sp mfs[] = { SkShaderMaskFilter::Make(maskImage->makeShader()), - SkBlurMaskFilter::Make(kNormal_SkBlurStyle, 3.5f), + SkMaskFilter::MakeBlur(kNormal_SkBlurStyle, 3.5f), nullptr, }; mfs[2] = SkMaskFilter::MakeCompose(mfs[1], mfs[0]); diff --git a/gm/skbug1719.cpp b/gm/skbug1719.cpp index f632852860..8f16926fc8 100644 --- a/gm/skbug1719.cpp +++ b/gm/skbug1719.cpp @@ -7,8 +7,8 @@ #include "gm.h" #include "sk_tool_utils.h" -#include "SkBlurMaskFilter.h" #include "SkColorFilter.h" +#include "SkMaskFilter.h" #include "SkPath.h" /** @@ -62,8 +62,7 @@ DEF_SIMPLE_GM_BG(skbug1719, canvas, 300, 100, paint.setAntiAlias(true); paint.setColor(0xFF000000); paint.setMaskFilter( - SkBlurMaskFilter::Make(kNormal_SkBlurStyle, 0.78867501f, - SkBlurMaskFilter::kHighQuality_BlurFlag)); + SkMaskFilter::MakeBlur(kNormal_SkBlurStyle, 0.78867501f)); paint.setColorFilter(SkColorFilter::MakeModeFilter(0xBFFFFFFF, SkBlendMode::kSrcIn)); canvas->clipPath(clipPath, true); diff --git a/gm/strokedlines.cpp b/gm/strokedlines.cpp index 402fa9b497..6e9eed7f9a 100644 --- a/gm/strokedlines.cpp +++ b/gm/strokedlines.cpp @@ -7,9 +7,9 @@ #include "gm.h" #include "sk_tool_utils.h" -#include "SkBlurMaskFilter.h" #include "SkDashPathEffect.h" #include "SkGradientShader.h" +#include "SkMaskFilter.h" #include "SkPaint.h" #include "SkPath.h" #include "SkPoint3.h" @@ -163,8 +163,7 @@ protected: // blur SkPaint p; p.setColor(SK_ColorWHITE); - p.setMaskFilter(SkBlurMaskFilter::Make(kOuter_SkBlurStyle, 3.0f, - SkBlurMaskFilter::kHighQuality_BlurFlag)); + p.setMaskFilter(SkMaskFilter::MakeBlur(kOuter_SkBlurStyle, 3.0f)); fPaints.push_back(p); } diff --git a/gm/textbloblooper.cpp b/gm/textbloblooper.cpp index 60ad4860d4..a6a77254b9 100644 --- a/gm/textbloblooper.cpp +++ b/gm/textbloblooper.cpp @@ -10,12 +10,12 @@ #include "Sk2DPathEffect.h" #include "SkBlurMask.h" -#include "SkBlurMaskFilter.h" #include "SkColorMatrixFilter.h" #include "SkCanvas.h" #include "SkGradientShader.h" #include "SkGraphics.h" #include "SkLayerDrawLooper.h" +#include "SkMaskFilter.h" #include "SkRandom.h" #include "SkTextBlob.h" @@ -62,7 +62,7 @@ struct LooperSettings { }; static void mask_filter(SkPaint* paint) { - paint->setMaskFilter(SkBlurMaskFilter::Make(kNormal_SkBlurStyle, + paint->setMaskFilter(SkMaskFilter::MakeBlur(kNormal_SkBlurStyle, SkBlurMask::ConvertRadiusToSigma(3.f))); } diff --git a/gm/textblobmixedsizes.cpp b/gm/textblobmixedsizes.cpp index d5c87eeb34..7ada13a3c5 100644 --- a/gm/textblobmixedsizes.cpp +++ b/gm/textblobmixedsizes.cpp @@ -10,10 +10,10 @@ #include "Resources.h" #include "SkBlurMask.h" -#include "SkBlurMaskFilter.h" #include "SkCanvas.h" #include "SkGradientShader.h" #include "SkImage.h" +#include "SkMaskFilter.h" #include "SkRandom.h" #include "SkStream.h" #include "SkSurface.h" @@ -136,7 +136,7 @@ protected: // setup blur paint SkPaint blurPaint(paint); blurPaint.setColor(sk_tool_utils::color_to_565(SK_ColorBLACK)); - blurPaint.setMaskFilter(SkBlurMaskFilter::Make(kNormal_SkBlurStyle, kSigma)); + blurPaint.setMaskFilter(SkMaskFilter::MakeBlur(kNormal_SkBlurStyle, kSigma)); for (int i = 0; i < 4; i++) { canvas->save(); diff --git a/gn/flutter_defines.gni b/gn/flutter_defines.gni index 0907b1036c..7df2360e6f 100644 --- a/gn/flutter_defines.gni +++ b/gn/flutter_defines.gni @@ -7,4 +7,5 @@ flutter_defines = [ "SK_DISABLE_EXPLICIT_GPU_RESOURCE_ALLOCATION", "SK_DISABLE_RENDER_TARGET_SORTING", "SK_SUPPORT_LEGACY_RECTMAKELARGEST", + "SK_SUPPORT_LEGACY_BLURMASKFILTER", ] diff --git a/gn/gn_to_bp_utils.py b/gn/gn_to_bp_utils.py index 65456408cd..3cc91483b0 100644 --- a/gn/gn_to_bp_utils.py +++ b/gn/gn_to_bp_utils.py @@ -52,6 +52,7 @@ def CleanupCFlags(cflags): "-DSKIA_DLL", "-DSKIA_IMPLEMENTATION=1", "-DATRACE_TAG=ATRACE_TAG_VIEW", + "-DSK_SUPPORT_LEGACY_BLURMASKFILTER", "-DSK_PRINT_CODEC_MESSAGES", ]) diff --git a/include/core/SkBlurTypes.h b/include/core/SkBlurTypes.h index b87ad0823e..49a4e1914e 100644 --- a/include/core/SkBlurTypes.h +++ b/include/core/SkBlurTypes.h @@ -19,12 +19,13 @@ enum SkBlurStyle { kLastEnum_SkBlurStyle = kInner_SkBlurStyle }; -// DEPRECATED +#ifdef SK_SUPPORT_LEGACY_BLURMASKFILTER enum SkBlurQuality { kLow_SkBlurQuality, //!< e.g. box filter kHigh_SkBlurQuality, //!< e.g. 3-pass similar to gaussian kLastEnum_SkBlurQuality }; +#endif #endif diff --git a/include/core/SkDrawLooper.h b/include/core/SkDrawLooper.h index 6d9a871ca3..9012802344 100644 --- a/include/core/SkDrawLooper.h +++ b/include/core/SkDrawLooper.h @@ -84,7 +84,9 @@ public: SkVector fOffset; SkColor fColor; SkBlurStyle fStyle; +#ifdef SK_SUPPORT_LEGACY_BLURMASKFILTER SkBlurQuality fQuality; +#endif }; /** * If this looper can be interpreted as having two layers, such that diff --git a/include/effects/SkBlurMaskFilter.h b/include/effects/SkBlurMaskFilter.h index bc4ee8049f..5a0f7adaad 100644 --- a/include/effects/SkBlurMaskFilter.h +++ b/include/effects/SkBlurMaskFilter.h @@ -18,6 +18,7 @@ class SkRRect; class SK_API SkBlurMaskFilter { public: +#ifdef SK_SUPPORT_LEGACY_BLURMASKFILTER enum BlurFlags { kNone_BlurFlag = 0x00, /** The blur layer's radius is not affected by transforms */ @@ -44,6 +45,7 @@ public: uint32_t flags = kNone_BlurFlag) { return Make(style, sigma, SkRect::MakeEmpty(), flags); } +#endif #ifdef SK_SUPPORT_LEGACY_EMBOSSMASKFILTER /** Create an emboss maskfilter @@ -58,8 +60,10 @@ public: SkScalar ambient, SkScalar specular); #endif +#ifdef SK_SUPPORT_LEGACY_BLURMASKFILTER private: SkBlurMaskFilter(); // can't be instantiated +#endif }; #endif diff --git a/public.bzl b/public.bzl index fbd005bf0f..d60cf89ce6 100644 --- a/public.bzl +++ b/public.bzl @@ -585,6 +585,7 @@ def base_defines(os_conditions): # Required for building dm. "GR_TEST_UTILS", # Staging flags for API changes + "SK_SUPPORT_LEGACY_BLURMASKFILTER", # Should remove after we update golden images "SK_WEBP_ENCODER_USE_DEFAULT_METHOD", # Experiment to diagnose image diffs in Google3 diff --git a/samplecode/SampleAnimBlur.cpp b/samplecode/SampleAnimBlur.cpp index 5330fdfa71..bf5005dc18 100644 --- a/samplecode/SampleAnimBlur.cpp +++ b/samplecode/SampleAnimBlur.cpp @@ -7,9 +7,9 @@ #include "SampleCode.h" #include "SkAnimTimer.h" -#include "SkBlurMaskFilter.h" #include "SkColorPriv.h" #include "SkCanvas.h" +#include "SkMaskFilter.h" #include "SkRandom.h" SkScalar get_anim_sin(double secs, SkScalar amplitude, SkScalar periodInSec, SkScalar phaseInSec) { @@ -47,9 +47,8 @@ protected: for (size_t i = 0; i < SK_ARRAY_COUNT(gStyles); ++i) { SkPaint paint; - paint.setMaskFilter(SkBlurMaskFilter::Make(gStyles[i], - fBlurSigma, - SkBlurMaskFilter::kHighQuality_BlurFlag)); + paint.setMaskFilter(SkMaskFilter::MakeBlur(gStyles[i], + fBlurSigma)); paint.setColor(random.nextU() | 0xff000000); canvas->drawCircle(200 * SK_Scalar1 + 400 * (i % 2) * SK_Scalar1, 200 * SK_Scalar1 + i / 2 * 400 * SK_Scalar1, diff --git a/samplecode/SampleBigBlur.cpp b/samplecode/SampleBigBlur.cpp index cb7a419a80..03349833f9 100644 --- a/samplecode/SampleBigBlur.cpp +++ b/samplecode/SampleBigBlur.cpp @@ -6,8 +6,8 @@ */ #include "SampleCode.h" #include "SkBlurMask.h" -#include "SkBlurMaskFilter.h" #include "SkCanvas.h" +#include "SkMaskFilter.h" #include "SkView.h" class BigBlurView : public SampleView { @@ -29,10 +29,9 @@ protected: SkPaint paint; canvas->save(); paint.setColor(SK_ColorBLUE); - paint.setMaskFilter(SkBlurMaskFilter::Make( + paint.setMaskFilter(SkMaskFilter::MakeBlur( kNormal_SkBlurStyle, - SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(128)), - SkBlurMaskFilter::kHighQuality_BlurFlag)); + SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(128)))); canvas->translate(200, 200); canvas->drawCircle(100, 100, 200, paint); canvas->restore(); diff --git a/samplecode/SampleBlur.cpp b/samplecode/SampleBlur.cpp index a5e5a18cb9..5890ce62e8 100644 --- a/samplecode/SampleBlur.cpp +++ b/samplecode/SampleBlur.cpp @@ -8,10 +8,10 @@ #include "SampleCode.h" #include "SkBitmap.h" #include "SkBlurMask.h" -#include "SkBlurMaskFilter.h" #include "SkCanvas.h" #include "SkColorPriv.h" #include "SkGradientShader.h" +#include "SkMaskFilter.h" #include "SkUtils.h" #include "SkView.h" @@ -54,40 +54,31 @@ protected: paint.setTextSize(25); canvas->translate(-40, 0); - SkBlurMaskFilter::BlurFlags flags = SkBlurMaskFilter::kNone_BlurFlag; - for (int j = 0; j < 2; j++) { - canvas->save(); - paint.setColor(SK_ColorBLUE); - for (size_t i = 0; i < SK_ARRAY_COUNT(gRecs); i++) { - if (gRecs[i].fStyle != NONE) { - paint.setMaskFilter(SkBlurMaskFilter::Make(gRecs[i].fStyle, - SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(20)), - flags)); - } else { - paint.setMaskFilter(nullptr); - } - canvas->drawCircle(200 + gRecs[i].fCx*100.f, - 200 + gRecs[i].fCy*100.f, 50, paint); - } - // draw text - { - paint.setMaskFilter(SkBlurMaskFilter::Make(kNormal_SkBlurStyle, - SkBlurMask::ConvertRadiusToSigma(4), - flags)); - SkScalar x = SkIntToScalar(70); - SkScalar y = SkIntToScalar(400); - paint.setColor(SK_ColorBLACK); - canvas->drawString("Hamburgefons Style", x, y, paint); - canvas->drawString("Hamburgefons Style", x, y + SkIntToScalar(50), paint); + paint.setColor(SK_ColorBLUE); + for (size_t i = 0; i < SK_ARRAY_COUNT(gRecs); i++) { + if (gRecs[i].fStyle != NONE) { + paint.setMaskFilter(SkMaskFilter::MakeBlur(gRecs[i].fStyle, + SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(20)))); + } else { paint.setMaskFilter(nullptr); - paint.setColor(SK_ColorWHITE); - x -= SkIntToScalar(2); - y -= SkIntToScalar(2); - canvas->drawString("Hamburgefons Style", x, y, paint); } - canvas->restore(); - flags = SkBlurMaskFilter::kHighQuality_BlurFlag; - canvas->translate(350, 0); + canvas->drawCircle(200 + gRecs[i].fCx*100.f, + 200 + gRecs[i].fCy*100.f, 50, paint); + } + // draw text + { + paint.setMaskFilter(SkMaskFilter::MakeBlur(kNormal_SkBlurStyle, + SkBlurMask::ConvertRadiusToSigma(4))); + SkScalar x = SkIntToScalar(70); + SkScalar y = SkIntToScalar(400); + paint.setColor(SK_ColorBLACK); + canvas->drawString("Hamburgefons Style", x, y, paint); + canvas->drawString("Hamburgefons Style", x, y + SkIntToScalar(50), paint); + paint.setMaskFilter(nullptr); + paint.setColor(SK_ColorWHITE); + x -= SkIntToScalar(2); + y -= SkIntToScalar(2); + canvas->drawString("Hamburgefons Style", x, y, paint); } } diff --git a/samplecode/SampleEffects.cpp b/samplecode/SampleEffects.cpp index 49654983da..d890232aaf 100644 --- a/samplecode/SampleEffects.cpp +++ b/samplecode/SampleEffects.cpp @@ -6,7 +6,6 @@ */ #include "SampleCode.h" #include "SkBlurMask.h" -#include "SkBlurMaskFilter.h" #include "SkCanvas.h" #include "SkColorMatrixFilter.h" #include "SkDiscretePathEffect.h" @@ -23,7 +22,7 @@ static void paint_proc0(SkPaint*) { } static void paint_proc1(SkPaint* paint) { - paint->setMaskFilter(SkBlurMaskFilter::Make( + paint->setMaskFilter(SkMaskFilter::MakeBlur( kNormal_SkBlurStyle, SkBlurMask::ConvertRadiusToSigma(2))); } diff --git a/samplecode/SampleFilterFuzz.cpp b/samplecode/SampleFilterFuzz.cpp index 28ba1e69d6..f3710984ec 100644 --- a/samplecode/SampleFilterFuzz.cpp +++ b/samplecode/SampleFilterFuzz.cpp @@ -9,7 +9,6 @@ #include "Sk2DPathEffect.h" #include "SkAlphaThresholdFilter.h" #include "SkBlurImageFilter.h" -#include "SkBlurMaskFilter.h" #include "SkCanvas.h" #include "SkColorFilter.h" #include "SkColorFilterImageFilter.h" @@ -186,8 +185,8 @@ static SkBlurStyle make_blur_style() { return static_cast(R(kLastEnum_SkBlurStyle+1)); } -static SkBlurMaskFilter::BlurFlags make_blur_mask_filter_flag() { - return static_cast(R(SkBlurMaskFilter::kAll_BlurFlag+1)); +static bool make_blur_mask_filter_respectctm() { + return static_cast(R(2)); } static SkFilterQuality make_filter_quality() { @@ -458,8 +457,8 @@ static sk_sp make_mask_filter() { sk_sp maskFilter; switch (R(3)) { case 0: - maskFilter = SkBlurMaskFilter::Make(make_blur_style(), make_scalar(), - make_blur_mask_filter_flag()); + maskFilter = SkMaskFilter::MakeBlur(make_blur_style(), make_scalar(), + make_blur_mask_filter_respectctm()); case 1: { SkEmbossMaskFilter::Light light; for (int i = 0; i < 3; ++i) { diff --git a/samplecode/SampleFuzz.cpp b/samplecode/SampleFuzz.cpp index 63504cd77a..1379e73d13 100644 --- a/samplecode/SampleFuzz.cpp +++ b/samplecode/SampleFuzz.cpp @@ -4,10 +4,11 @@ * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ + #include "SampleCode.h" #include "SkView.h" #include "SkCanvas.h" -#include "SkBlurMaskFilter.h" +#include "SkMaskFilter.h" #include "SkPaint.h" #include "SkPath.h" #include "SkMatrix.h" @@ -188,7 +189,7 @@ static void do_fuzz(SkCanvas* canvas) { case 7: if (quick == true) break; - paint.setMaskFilter(SkBlurMaskFilter::Make(kNormal_SkBlurStyle, make_number())); + paint.setMaskFilter(SkMaskFilter::MakeBlur(kNormal_SkBlurStyle, make_number())); break; case 8: diff --git a/samplecode/SampleStrokePath.cpp b/samplecode/SampleStrokePath.cpp index ce64155504..d51f24f6fa 100644 --- a/samplecode/SampleStrokePath.cpp +++ b/samplecode/SampleStrokePath.cpp @@ -6,8 +6,8 @@ */ #include "SampleCode.h" #include "SkBlurMask.h" -#include "SkBlurMaskFilter.h" #include "SkCanvas.h" +#include "SkMaskFilter.h" #include "SkParsePath.h" #include "SkPath.h" #include "SkRandom.h" @@ -168,7 +168,7 @@ protected: SkScalar sigma = SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(4)); for (int y = 0; y < 10; y++) { if (x) { - paint.setMaskFilter(SkBlurMaskFilter::Make(gStyle[x - 1], sigma)); + paint.setMaskFilter(SkMaskFilter::MakeBlur(gStyle[x - 1], sigma)); } canvas->drawString("Title Bar", x*SkIntToScalar(100), y*SkIntToScalar(30), paint); sigma *= 0.75f; diff --git a/samplecode/SampleTextAlpha.cpp b/samplecode/SampleTextAlpha.cpp index 097af8fb4d..c6ef3d7124 100644 --- a/samplecode/SampleTextAlpha.cpp +++ b/samplecode/SampleTextAlpha.cpp @@ -4,12 +4,13 @@ * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ + #include "SampleCode.h" #include "SkBlurMask.h" -#include "SkBlurMaskFilter.h" #include "SkCanvas.h" #include "SkGradientShader.h" #include "SkGraphics.h" +#include "SkMaskFilter.h" #include "SkPath.h" #include "SkRandom.h" #include "SkRegion.h" @@ -50,7 +51,7 @@ protected: paint.setARGB(fByte, 0xFF, 0xFF, 0xFF); - paint.setMaskFilter(SkBlurMaskFilter::Make(kNormal_SkBlurStyle, + paint.setMaskFilter(SkMaskFilter::MakeBlur(kNormal_SkBlurStyle, SkBlurMask::ConvertRadiusToSigma(3))); SkRandom rand; diff --git a/samplecode/SampleTextureDomain.cpp b/samplecode/SampleTextureDomain.cpp index 9c7f3de7a3..7b429cbe16 100644 --- a/samplecode/SampleTextureDomain.cpp +++ b/samplecode/SampleTextureDomain.cpp @@ -76,11 +76,8 @@ protected: // renders correctly srcRect.setXYWH(1, 1, 3, 3); dstRect.setXYWH(5, 405, 305, 305); - paint.setMaskFilter(SkBlurMaskFilter::Make( - kNormal_SkBlurStyle, - SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(5)), - SkBlurMaskFilter::kHighQuality_BlurFlag | - SkBlurMaskFilter::kIgnoreTransform_BlurFlag)); + paint.setMaskFilter(SkMaskFilter::MakeBlur( + kNormal_SkBlurStyle, SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(5)), false)); canvas->drawImageRect(image, srcRect, dstRect, &paint); // Blur and a rotation + nullptr src rect @@ -88,9 +85,8 @@ protected: // but it will test a code path in SkGpuDevice::drawBitmap // that handles blurs with rects transformed to non- // orthogonal rects. It also tests the nullptr src rect handling - paint.setMaskFilter(SkBlurMaskFilter::Make(kNormal_SkBlurStyle, - SkBlurMask::ConvertRadiusToSigma(5), - SkBlurMaskFilter::kHighQuality_BlurFlag)); + paint.setMaskFilter(SkMaskFilter::MakeBlur(kNormal_SkBlurStyle, + SkBlurMask::ConvertRadiusToSigma(5))); dstRect.setXYWH(-150, -150, 300, 300); canvas->translate(550, 550); diff --git a/samplecode/SampleXfermodesBlur.cpp b/samplecode/SampleXfermodesBlur.cpp index ec478dbcac..37b859288b 100644 --- a/samplecode/SampleXfermodesBlur.cpp +++ b/samplecode/SampleXfermodesBlur.cpp @@ -39,9 +39,8 @@ class XfermodesBlurView : public SampleView { void draw_mode(SkCanvas* canvas, SkBlendMode mode, int alpha, SkScalar x, SkScalar y) { SkPaint p; - p.setMaskFilter(SkBlurMaskFilter::Make(kNormal_SkBlurStyle, - SkBlurMask::ConvertRadiusToSigma(5), - SkBlurMaskFilter::kNone_BlurFlag)); + p.setMaskFilter(SkMaskFilter::MakeBlur(kNormal_SkBlurStyle, + SkBlurMask::ConvertRadiusToSigma(5))); SkScalar ww = SkIntToScalar(W); SkScalar hh = SkIntToScalar(H); diff --git a/src/core/SkBlurMF.cpp b/src/core/SkBlurMF.cpp index c9599cc494..10b10a4086 100644 --- a/src/core/SkBlurMF.cpp +++ b/src/core/SkBlurMF.cpp @@ -106,8 +106,6 @@ private: SkRect fOccluder; bool fRespectCTM; - SkBlurQuality getQuality() const { return kHigh_SkBlurQuality; } - SkBlurMaskFilterImpl(SkReadBuffer&); void flatten(SkWriteBuffer&) const override; @@ -291,7 +289,9 @@ bool SkBlurMaskFilterImpl::asABlur(BlurRec* rec) const { if (rec) { rec->fSigma = fSigma; rec->fStyle = fBlurStyle; - rec->fQuality = this->getQuality(); +#ifdef SK_SUPPORT_LEGACY_BLURMASKFILTER + rec->fQuality = kHigh_SkBlurQuality; +#endif } return true; } @@ -300,7 +300,7 @@ bool SkBlurMaskFilterImpl::filterMask(SkMask* dst, const SkMask& src, const SkMatrix& matrix, SkIPoint* margin) const { SkScalar sigma = this->computeXformedSigma(matrix); - return SkBlurMask::BoxBlur(dst, src, sigma, fBlurStyle, this->getQuality(), margin); + return SkBlurMask::BoxBlur(dst, src, sigma, fBlurStyle, margin); } bool SkBlurMaskFilterImpl::filterRectMask(SkMask* dst, const SkRect& r, @@ -406,29 +406,29 @@ static SkCachedData* copy_mask_to_cacheddata(SkMask* mask) { } static SkCachedData* find_cached_rrect(SkMask* mask, SkScalar sigma, SkBlurStyle style, - SkBlurQuality quality, const SkRRect& rrect) { - return SkMaskCache::FindAndRef(sigma, style, quality, rrect, mask); + const SkRRect& rrect) { + return SkMaskCache::FindAndRef(sigma, style, rrect, mask); } static SkCachedData* add_cached_rrect(SkMask* mask, SkScalar sigma, SkBlurStyle style, - SkBlurQuality quality, const SkRRect& rrect) { + const SkRRect& rrect) { SkCachedData* cache = copy_mask_to_cacheddata(mask); if (cache) { - SkMaskCache::Add(sigma, style, quality, rrect, *mask, cache); + SkMaskCache::Add(sigma, style, rrect, *mask, cache); } return cache; } static SkCachedData* find_cached_rects(SkMask* mask, SkScalar sigma, SkBlurStyle style, - SkBlurQuality quality, const SkRect rects[], int count) { - return SkMaskCache::FindAndRef(sigma, style, quality, rects, count, mask); + const SkRect rects[], int count) { + return SkMaskCache::FindAndRef(sigma, style, rects, count, mask); } static SkCachedData* add_cached_rects(SkMask* mask, SkScalar sigma, SkBlurStyle style, - SkBlurQuality quality, const SkRect rects[], int count) { + const SkRect rects[], int count) { SkCachedData* cache = copy_mask_to_cacheddata(mask); if (cache) { - SkMaskCache::Add(sigma, style, quality, rects, count, *mask, cache); + SkMaskCache::Add(sigma, style, rects, count, *mask, cache); } return cache; } @@ -541,8 +541,7 @@ SkBlurMaskFilterImpl::filterRRectToNine(const SkRRect& rrect, const SkMatrix& ma smallRR.setRectRadii(smallR, radii); const SkScalar sigma = this->computeXformedSigma(matrix); - SkCachedData* cache = find_cached_rrect(&patch->fMask, sigma, fBlurStyle, - this->getQuality(), smallRR); + SkCachedData* cache = find_cached_rrect(&patch->fMask, sigma, fBlurStyle, smallRR); if (!cache) { bool analyticBlurWorked = false; if (c_analyticBlurRRect) { @@ -562,7 +561,7 @@ SkBlurMaskFilterImpl::filterRRectToNine(const SkRRect& rrect, const SkMatrix& ma return kFalse_FilterReturn; } } - cache = add_cached_rrect(&patch->fMask, sigma, fBlurStyle, this->getQuality(), smallRR); + cache = add_cached_rrect(&patch->fMask, sigma, fBlurStyle, smallRR); } patch->fMask.fBounds.offsetTo(0, 0); @@ -675,8 +674,7 @@ SkBlurMaskFilterImpl::filterRectsToNine(const SkRect rects[], int count, } const SkScalar sigma = this->computeXformedSigma(matrix); - SkCachedData* cache = find_cached_rects(&patch->fMask, sigma, fBlurStyle, - this->getQuality(), smallR, count); + SkCachedData* cache = find_cached_rects(&patch->fMask, sigma, fBlurStyle, smallR, count); if (!cache) { if (count > 1 || !c_analyticBlurNinepatch) { if (!draw_rects_into_mask(smallR, count, &srcM)) { @@ -694,7 +692,7 @@ SkBlurMaskFilterImpl::filterRectsToNine(const SkRect rects[], int count, return kFalse_FilterReturn; } } - cache = add_cached_rects(&patch->fMask, sigma, fBlurStyle, this->getQuality(), smallR, count); + cache = add_cached_rects(&patch->fMask, sigma, fBlurStyle, smallR, count); } patch->fMask.fBounds.offsetTo(0, 0); patch->fOuterRect = dstM.fBounds; diff --git a/src/core/SkBlurMask.cpp b/src/core/SkBlurMask.cpp index 086977528b..ccdea57208 100644 --- a/src/core/SkBlurMask.cpp +++ b/src/core/SkBlurMask.cpp @@ -95,9 +95,8 @@ void SkMask_FreeImage(uint8_t* image) { SkMask::FreeImage(image); } -bool SkBlurMask::BoxBlur(SkMask* dst, const SkMask& src, - SkScalar sigma, SkBlurStyle style, SkBlurQuality quality, - SkIPoint* margin, bool force_quality) { +bool SkBlurMask::BoxBlur(SkMask* dst, const SkMask& src, SkScalar sigma, SkBlurStyle style, + SkIPoint* margin) { if (src.fFormat != SkMask::kA8_Format) { return false; diff --git a/src/core/SkBlurMask.h b/src/core/SkBlurMask.h index 67009b0bb5..cd81e60a6c 100644 --- a/src/core/SkBlurMask.h +++ b/src/core/SkBlurMask.h @@ -36,9 +36,8 @@ public: // null. static bool SK_WARN_UNUSED_RESULT BoxBlur(SkMask* dst, const SkMask& src, - SkScalar sigma, SkBlurStyle style, SkBlurQuality, - SkIPoint* margin = nullptr, - bool forceQuality = false); + SkScalar sigma, SkBlurStyle style, + SkIPoint* margin = nullptr); // the "ground truth" blur does a gaussian convolution; it's slow // but useful for comparison purposes. diff --git a/src/core/SkMaskCache.cpp b/src/core/SkMaskCache.cpp index f998a928cc..c4b964418f 100644 --- a/src/core/SkMaskCache.cpp +++ b/src/core/SkMaskCache.cpp @@ -20,19 +20,17 @@ static unsigned gRRectBlurKeyNamespaceLabel; struct RRectBlurKey : public SkResourceCache::Key { public: - RRectBlurKey(SkScalar sigma, const SkRRect& rrect, SkBlurStyle style, SkBlurQuality quality) + RRectBlurKey(SkScalar sigma, const SkRRect& rrect, SkBlurStyle style) : fSigma(sigma) , fStyle(style) - , fQuality(quality) , fRRect(rrect) { this->init(&gRRectBlurKeyNamespaceLabel, 0, - sizeof(fSigma) + sizeof(fStyle) + sizeof(fQuality) + sizeof(fRRect)); + sizeof(fSigma) + sizeof(fStyle) + sizeof(fRRect)); } SkScalar fSigma; int32_t fStyle; - int32_t fQuality; SkRRect fRRect; }; @@ -74,10 +72,10 @@ struct RRectBlurRec : public SkResourceCache::Rec { }; } // namespace -SkCachedData* SkMaskCache::FindAndRef(SkScalar sigma, SkBlurStyle style, SkBlurQuality quality, +SkCachedData* SkMaskCache::FindAndRef(SkScalar sigma, SkBlurStyle style, const SkRRect& rrect, SkMask* mask, SkResourceCache* localCache) { MaskValue result; - RRectBlurKey key(sigma, rrect, style, quality); + RRectBlurKey key(sigma, rrect, style); if (!CHECK_LOCAL(localCache, find, Find, key, RRectBlurRec::Visitor, &result)) { return nullptr; } @@ -87,10 +85,10 @@ SkCachedData* SkMaskCache::FindAndRef(SkScalar sigma, SkBlurStyle style, SkBlurQ return result.fData; } -void SkMaskCache::Add(SkScalar sigma, SkBlurStyle style, SkBlurQuality quality, +void SkMaskCache::Add(SkScalar sigma, SkBlurStyle style, const SkRRect& rrect, const SkMask& mask, SkCachedData* data, SkResourceCache* localCache) { - RRectBlurKey key(sigma, rrect, style, quality); + RRectBlurKey key(sigma, rrect, style); return CHECK_LOCAL(localCache, add, Add, new RRectBlurRec(key, mask, data)); } @@ -101,11 +99,9 @@ static unsigned gRectsBlurKeyNamespaceLabel; struct RectsBlurKey : public SkResourceCache::Key { public: - RectsBlurKey(SkScalar sigma, SkBlurStyle style, SkBlurQuality quality, - const SkRect rects[], int count) + RectsBlurKey(SkScalar sigma, SkBlurStyle style, const SkRect rects[], int count) : fSigma(sigma) , fStyle(style) - , fQuality(quality) { SkASSERT(1 == count || 2 == count); SkIRect ir; @@ -121,12 +117,11 @@ public: fSizes[3] = SkSize{rects[0].x() - ir.x(), rects[0].y() - ir.y()}; this->init(&gRectsBlurKeyNamespaceLabel, 0, - sizeof(fSigma) + sizeof(fStyle) + sizeof(fQuality) + sizeof(fSizes)); + sizeof(fSigma) + sizeof(fStyle) + sizeof(fSizes)); } SkScalar fSigma; int32_t fStyle; - int32_t fQuality; SkSize fSizes[4]; }; @@ -168,11 +163,11 @@ struct RectsBlurRec : public SkResourceCache::Rec { }; } // namespace -SkCachedData* SkMaskCache::FindAndRef(SkScalar sigma, SkBlurStyle style, SkBlurQuality quality, +SkCachedData* SkMaskCache::FindAndRef(SkScalar sigma, SkBlurStyle style, const SkRect rects[], int count, SkMask* mask, SkResourceCache* localCache) { MaskValue result; - RectsBlurKey key(sigma, style, quality, rects, count); + RectsBlurKey key(sigma, style, rects, count); if (!CHECK_LOCAL(localCache, find, Find, key, RectsBlurRec::Visitor, &result)) { return nullptr; } @@ -182,9 +177,9 @@ SkCachedData* SkMaskCache::FindAndRef(SkScalar sigma, SkBlurStyle style, SkBlurQ return result.fData; } -void SkMaskCache::Add(SkScalar sigma, SkBlurStyle style, SkBlurQuality quality, +void SkMaskCache::Add(SkScalar sigma, SkBlurStyle style, const SkRect rects[], int count, const SkMask& mask, SkCachedData* data, SkResourceCache* localCache) { - RectsBlurKey key(sigma, style, quality, rects, count); + RectsBlurKey key(sigma, style, rects, count); return CHECK_LOCAL(localCache, add, Add, new RectsBlurRec(key, mask, data)); } diff --git a/src/core/SkMaskCache.h b/src/core/SkMaskCache.h index 9df1bf8601..88a989b2ec 100644 --- a/src/core/SkMaskCache.h +++ b/src/core/SkMaskCache.h @@ -23,20 +23,20 @@ public: * * On failure, return nullptr. */ - static SkCachedData* FindAndRef(SkScalar sigma, SkBlurStyle style, SkBlurQuality quality, + static SkCachedData* FindAndRef(SkScalar sigma, SkBlurStyle style, const SkRRect& rrect, SkMask* mask, SkResourceCache* localCache = nullptr); - static SkCachedData* FindAndRef(SkScalar sigma, SkBlurStyle style, SkBlurQuality quality, + static SkCachedData* FindAndRef(SkScalar sigma, SkBlurStyle style, const SkRect rects[], int count, SkMask* mask, SkResourceCache* localCache = nullptr); /** * Add a mask and its pixel-data to the cache. */ - static void Add(SkScalar sigma, SkBlurStyle style, SkBlurQuality quality, + static void Add(SkScalar sigma, SkBlurStyle style, const SkRRect& rrect, const SkMask& mask, SkCachedData* data, SkResourceCache* localCache = nullptr); - static void Add(SkScalar sigma, SkBlurStyle style, SkBlurQuality quality, + static void Add(SkScalar sigma, SkBlurStyle style, const SkRect rects[], int count, const SkMask& mask, SkCachedData* data, SkResourceCache* localCache = nullptr); }; diff --git a/src/core/SkMaskFilterBase.h b/src/core/SkMaskFilterBase.h index 4b4b4258d6..4fa6ae08f4 100644 --- a/src/core/SkMaskFilterBase.h +++ b/src/core/SkMaskFilterBase.h @@ -155,7 +155,9 @@ public: struct BlurRec { SkScalar fSigma; SkBlurStyle fStyle; +#ifdef SK_SUPPORT_LEGACY_BLURMASKFILTER SkBlurQuality fQuality; +#endif }; /** * If this filter can be represented by a BlurRec, return true and (if not null) fill in the diff --git a/src/effects/SkBlurMaskFilter.cpp b/src/effects/SkBlurMaskFilter.cpp index 64a880cc8f..57e6eedd08 100644 --- a/src/effects/SkBlurMaskFilter.cpp +++ b/src/effects/SkBlurMaskFilter.cpp @@ -7,8 +7,11 @@ #include "SkBlurMaskFilter.h" +#ifdef SK_SUPPORT_LEGACY_BLURMASKFILTER sk_sp SkBlurMaskFilter::Make(SkBlurStyle style, SkScalar sigma, const SkRect& occluder, uint32_t flags) { bool respectCTM = !(flags & kIgnoreTransform_BlurFlag); return SkMaskFilter::MakeBlur(style, sigma, occluder, respectCTM); } +#endif + diff --git a/src/effects/SkEmbossMaskFilter.cpp b/src/effects/SkEmbossMaskFilter.cpp index 671025006e..cbc470eb6d 100644 --- a/src/effects/SkEmbossMaskFilter.cpp +++ b/src/effects/SkEmbossMaskFilter.cpp @@ -74,7 +74,7 @@ bool SkEmbossMaskFilter::filterMask(SkMask* dst, const SkMask& src, const SkMatrix& matrix, SkIPoint* margin) const { SkScalar sigma = matrix.mapRadius(fBlurSigma); - if (!SkBlurMask::BoxBlur(dst, src, sigma, kInner_SkBlurStyle, kLow_SkBlurQuality)) { + if (!SkBlurMask::BoxBlur(dst, src, sigma, kInner_SkBlurStyle)) { return false; } diff --git a/src/effects/SkLayerDrawLooper.cpp b/src/effects/SkLayerDrawLooper.cpp index 3cd661c640..48954a8938 100644 --- a/src/effects/SkLayerDrawLooper.cpp +++ b/src/effects/SkLayerDrawLooper.cpp @@ -204,7 +204,9 @@ bool SkLayerDrawLooper::asABlurShadow(BlurShadowRec* bsRec) const { bsRec->fOffset = fRecs->fInfo.fOffset; bsRec->fColor = fRecs->fPaint.getColor(); bsRec->fStyle = maskBlur.fStyle; +#ifdef SK_SUPPORT_LEGACY_BLURMASKFILTER bsRec->fQuality = maskBlur.fQuality; +#endif } return true; } diff --git a/src/gpu/text/GrAtlasTextBlob.cpp b/src/gpu/text/GrAtlasTextBlob.cpp index 72ddac3167..7acf617299 100644 --- a/src/gpu/text/GrAtlasTextBlob.cpp +++ b/src/gpu/text/GrAtlasTextBlob.cpp @@ -184,9 +184,7 @@ bool GrAtlasTextBlob::mustRegenerate(const GrTextUtils::Paint& paint, // We only cache one masked version if (fKey.fHasBlur && - (fBlurRec.fSigma != blurRec.fSigma || - fBlurRec.fStyle != blurRec.fStyle || - fBlurRec.fQuality != blurRec.fQuality)) { + (fBlurRec.fSigma != blurRec.fSigma || fBlurRec.fStyle != blurRec.fStyle)) { return true; } @@ -409,7 +407,6 @@ void GrAtlasTextBlob::AssertEqual(const GrAtlasTextBlob& l, const GrAtlasTextBlo SkASSERT_RELEASE(l.fBlurRec.fSigma == r.fBlurRec.fSigma); SkASSERT_RELEASE(l.fBlurRec.fStyle == r.fBlurRec.fStyle); - SkASSERT_RELEASE(l.fBlurRec.fQuality == r.fBlurRec.fQuality); SkASSERT_RELEASE(l.fStrokeInfo.fFrameWidth == r.fStrokeInfo.fFrameWidth); SkASSERT_RELEASE(l.fStrokeInfo.fMiterLimit == r.fStrokeInfo.fMiterLimit); diff --git a/tests/BlurTest.cpp b/tests/BlurTest.cpp index 75c6d819cf..50bc4d799e 100644 --- a/tests/BlurTest.cpp +++ b/tests/BlurTest.cpp @@ -383,7 +383,9 @@ static void test_blurDrawLooper(skiatest::Reporter* reporter, SkScalar sigma, Sk REPORTER_ASSERT(reporter, rec.fOffset.y() == dy); REPORTER_ASSERT(reporter, rec.fColor == color); REPORTER_ASSERT(reporter, rec.fStyle == style); +#ifdef SK_SUPPORT_LEGACY_BLURMASKFILTER REPORTER_ASSERT(reporter, rec.fQuality == kHigh_SkBlurQuality); +#endif } } } @@ -399,7 +401,9 @@ static void test_looper(skiatest::Reporter* reporter, sk_sp lp, Sk if (success) { REPORTER_ASSERT(reporter, rec.fSigma == sigma); REPORTER_ASSERT(reporter, rec.fStyle == style); +#ifdef SK_SUPPORT_LEGACY_BLURMASKFILTER REPORTER_ASSERT(reporter, rec.fQuality == kHigh_SkBlurQuality); +#endif } } @@ -474,7 +478,9 @@ DEF_TEST(BlurAsABlur, reporter) { REPORTER_ASSERT(reporter, success); REPORTER_ASSERT(reporter, rec.fSigma == sigma); REPORTER_ASSERT(reporter, rec.fStyle == style); +#ifdef SK_SUPPORT_LEGACY_BLURMASKFILTER REPORTER_ASSERT(reporter, rec.fQuality == kHigh_SkBlurQuality); +#endif } else { REPORTER_ASSERT(reporter, !success); } diff --git a/tests/MaskCacheTest.cpp b/tests/MaskCacheTest.cpp index 13cd354c91..34e3edf251 100644 --- a/tests/MaskCacheTest.cpp +++ b/tests/MaskCacheTest.cpp @@ -36,10 +36,9 @@ DEF_TEST(RRectMaskCache, reporter) { SkRRect rrect; rrect.setRectXY(rect, 30, 30); SkBlurStyle style = kNormal_SkBlurStyle; - SkBlurQuality quality = kLow_SkBlurQuality; SkMask mask; - SkCachedData* data = SkMaskCache::FindAndRef(sigma, style, quality, rrect, &mask, &cache); + SkCachedData* data = SkMaskCache::FindAndRef(sigma, style, rrect, &mask, &cache); REPORTER_ASSERT(reporter, nullptr == data); size_t size = 256; @@ -48,14 +47,14 @@ DEF_TEST(RRectMaskCache, reporter) { mask.fBounds.setXYWH(0, 0, 100, 100); mask.fRowBytes = 100; mask.fFormat = SkMask::kBW_Format; - SkMaskCache::Add(sigma, style, quality, rrect, mask, data, &cache); + SkMaskCache::Add(sigma, style, rrect, mask, data, &cache); check_data(reporter, data, 2, kInCache, kLocked); data->unref(); check_data(reporter, data, 1, kInCache, kUnlocked); sk_bzero(&mask, sizeof(mask)); - data = SkMaskCache::FindAndRef(sigma, style, quality, rrect, &mask, &cache); + data = SkMaskCache::FindAndRef(sigma, style, rrect, &mask, &cache); REPORTER_ASSERT(reporter, data); REPORTER_ASSERT(reporter, data->size() == size); REPORTER_ASSERT(reporter, mask.fBounds.top() == 0 && mask.fBounds.bottom() == 100); @@ -74,10 +73,9 @@ DEF_TEST(RectsMaskCache, reporter) { SkRect rect = SkRect::MakeWH(100, 100); SkRect rects[2] = {rect}; SkBlurStyle style = kNormal_SkBlurStyle; - SkBlurQuality quality = kLow_SkBlurQuality; SkMask mask; - SkCachedData* data = SkMaskCache::FindAndRef(sigma, style, quality, rects, 1, &mask, &cache); + SkCachedData* data = SkMaskCache::FindAndRef(sigma, style, rects, 1, &mask, &cache); REPORTER_ASSERT(reporter, nullptr == data); size_t size = 256; @@ -86,14 +84,14 @@ DEF_TEST(RectsMaskCache, reporter) { mask.fBounds.setXYWH(0, 0, 100, 100); mask.fRowBytes = 100; mask.fFormat = SkMask::kBW_Format; - SkMaskCache::Add(sigma, style, quality, rects, 1, mask, data, &cache); + SkMaskCache::Add(sigma, style, rects, 1, mask, data, &cache); check_data(reporter, data, 2, kInCache, kLocked); data->unref(); check_data(reporter, data, 1, kInCache, kUnlocked); sk_bzero(&mask, sizeof(mask)); - data = SkMaskCache::FindAndRef(sigma, style, quality, rects, 1, &mask, &cache); + data = SkMaskCache::FindAndRef(sigma, style, rects, 1, &mask, &cache); REPORTER_ASSERT(reporter, data); REPORTER_ASSERT(reporter, data->size() == size); REPORTER_ASSERT(reporter, mask.fBounds.top() == 0 && mask.fBounds.bottom() == 100); diff --git a/tests/PaintTest.cpp b/tests/PaintTest.cpp index dd1885e652..e52308c159 100644 --- a/tests/PaintTest.cpp +++ b/tests/PaintTest.cpp @@ -7,8 +7,8 @@ #include "SkAutoMalloc.h" #include "SkBlurMask.h" -#include "SkBlurMaskFilter.h" #include "SkLayerDrawLooper.h" +#include "SkMaskFilter.h" #include "SkPaintPriv.h" #include "SkPath.h" #include "SkRandom.h" @@ -147,7 +147,7 @@ DEF_TEST(Paint_copy, reporter) { // set a few pointers SkLayerDrawLooper::Builder looperBuilder; paint.setLooper(looperBuilder.detach()); - paint.setMaskFilter(SkBlurMaskFilter::Make(kNormal_SkBlurStyle, + paint.setMaskFilter(SkMaskFilter::MakeBlur(kNormal_SkBlurStyle, SkBlurMask::ConvertRadiusToSigma(1))); // copy the paint using the copy constructor and check they are the same diff --git a/tests/skbug6389.cpp b/tests/skbug6389.cpp index 42112a7a0f..d82a1462fb 100644 --- a/tests/skbug6389.cpp +++ b/tests/skbug6389.cpp @@ -6,17 +6,16 @@ */ #include "Resources.h" -#include "SkBlurMaskFilter.h" #include "SkCanvas.h" #include "SkImageSource.h" +#include "SkMaskFilter.h" #include "SkSurface.h" #include "Test.h" DEF_TEST(skbug_6389, r) { auto s = SkSurface::MakeRasterN32Premul(100, 100); SkPaint p; - p.setMaskFilter(SkBlurMaskFilter::Make(SkBlurStyle::kNormal_SkBlurStyle, 5, - SkBlurMaskFilter::kHighQuality_BlurFlag)); + p.setMaskFilter(SkMaskFilter::MakeBlur(SkBlurStyle::kNormal_SkBlurStyle, 5)); p.setImageFilter(SkImageSource::Make(GetResourceAsImage("images/mandrill_512.png"), {0, 0, 0, 0}, {0, 0, 0, 0}, (SkFilterQuality)0)); s->getCanvas()->drawPaint(p); diff --git a/tools/debugger/SkDrawCommand.cpp b/tools/debugger/SkDrawCommand.cpp index a99ff6d2b1..076dac57a5 100644 --- a/tools/debugger/SkDrawCommand.cpp +++ b/tools/debugger/SkDrawCommand.cpp @@ -10,7 +10,6 @@ #include "png.h" #include "SkAutoMalloc.h" -#include "SkBlurMaskFilter.h" #include "SkColorFilter.h" #include "SkDashPathEffect.h" #include "SkImageFilter.h" @@ -1124,18 +1123,6 @@ static void apply_paint_maskfilter(const SkPaint& paint, Json::Value* target, default: SkASSERT(false); } - switch (blurRec.fQuality) { - case SkBlurQuality::kLow_SkBlurQuality: - blur[SKDEBUGCANVAS_ATTRIBUTE_QUALITY] = Json::Value( - SKDEBUGCANVAS_BLURQUALITY_LOW); - break; - case SkBlurQuality::kHigh_SkBlurQuality: - blur[SKDEBUGCANVAS_ATTRIBUTE_QUALITY] = Json::Value( - SKDEBUGCANVAS_BLURQUALITY_HIGH); - break; - default: - SkASSERT(false); - } (*target)[SKDEBUGCANVAS_ATTRIBUTE_BLUR] = blur; } else { Json::Value jsonMaskFilter; @@ -1590,19 +1577,7 @@ static void extract_json_paint_blur(Json::Value& jsonPaint, SkPaint* target) { SkASSERT(false); style = SkBlurStyle::kNormal_SkBlurStyle; } - SkBlurMaskFilter::BlurFlags flags; - const char* jsonQuality = blur[SKDEBUGCANVAS_ATTRIBUTE_QUALITY].asCString(); - if (!strcmp(jsonQuality, SKDEBUGCANVAS_BLURQUALITY_LOW)) { - flags = SkBlurMaskFilter::BlurFlags::kNone_BlurFlag; - } - else if (!strcmp(jsonQuality, SKDEBUGCANVAS_BLURQUALITY_HIGH)) { - flags = SkBlurMaskFilter::BlurFlags::kHighQuality_BlurFlag; - } - else { - SkASSERT(false); - flags = SkBlurMaskFilter::BlurFlags::kNone_BlurFlag; - } - target->setMaskFilter(SkBlurMaskFilter::Make(style, sigma, flags)); + target->setMaskFilter(SkMaskFilter::MakeBlur(style, sigma)); } }