Skip to content

Commit

Permalink
hide SkBlurMaskFilter and SkBlurQuality
Browse files Browse the repository at this point in the history
SK_SUPPORT_LEGACY_BLURMASKFILTER

Bug: skia:
Change-Id: Ic3e27e08e6e3cd2ffc1cd13b044e197bebc96236
Reviewed-on: https://skia-review.googlesource.com/113940
Commit-Queue: Mike Reed <reed@google.com>
Reviewed-by: Florin Malita <fmalita@chromium.org>
  • Loading branch information
reed-at-google authored and Skia Commit-Bot committed Mar 14, 2018
1 parent c29c76a commit 1be1f8d
Show file tree
Hide file tree
Showing 68 changed files with 245 additions and 318 deletions.
25 changes: 5 additions & 20 deletions bench/BlurBench.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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 {
Expand All @@ -67,9 +64,8 @@ class BlurBench : public Benchmark {
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);
}
Expand Down Expand Up @@ -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);)
6 changes: 3 additions & 3 deletions bench/BlurOccludedRRectBench.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -48,7 +48,7 @@ class BlurOccludedRRectBench : public Benchmark {
SkPaint firstBlur;
firstBlur.setAntiAlias(true);
firstBlur.setColor(0x09000000);
firstBlur.setMaskFilter(SkBlurMaskFilter::Make(kNormal_SkBlurStyle,
firstBlur.setMaskFilter(SkMaskFilter::MakeBlur(kNormal_SkBlurStyle,
2.5f,
occRect));

Expand All @@ -60,7 +60,7 @@ class BlurOccludedRRectBench : public Benchmark {
SkPaint secondBlur;
secondBlur.setAntiAlias(true);
secondBlur.setColor(0x30000000);
secondBlur.setMaskFilter(SkBlurMaskFilter::Make(kNormal_SkBlurStyle,
secondBlur.setMaskFilter(SkMaskFilter::MakeBlur(kNormal_SkBlurStyle,
6.0f,
occRect));

Expand Down
2 changes: 1 addition & 1 deletion bench/BlurRectBench.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ class BlurRectBoxFilterBench: public BlurRectSeparableBench {
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);
Expand Down
4 changes: 2 additions & 2 deletions bench/BlurRectsBench.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -31,7 +31,7 @@ class BlurRectsBench : public Benchmark {

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);
Expand Down
7 changes: 3 additions & 4 deletions bench/BlurRoundRectBench.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -48,9 +48,8 @@ class BlurRoundRectBench : public Benchmark {
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);
Expand Down
5 changes: 2 additions & 3 deletions bench/RectoriBench.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -86,8 +86,7 @@ class RectoriBench : public Benchmark {

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;
Expand Down
5 changes: 3 additions & 2 deletions fuzz/FuzzCanvas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -509,8 +509,9 @@ static sk_sp<SkMaskFilter> 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;
Expand Down
4 changes: 2 additions & 2 deletions gm/alpha_image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions gm/bigblurs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -71,7 +71,7 @@ class BigBlursGM : public GM {

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();
Expand Down
6 changes: 3 additions & 3 deletions gm/bleed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -281,7 +281,7 @@ class BleedGM : public skiagm::GM {

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);
Expand All @@ -299,7 +299,7 @@ class BleedGM : public skiagm::GM {

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);
Expand Down
7 changes: 3 additions & 4 deletions gm/blurcircles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -31,10 +31,9 @@ class BlurCirclesGM : public skiagm::GM {
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])));
}
}

Expand Down
5 changes: 2 additions & 3 deletions gm/blurcircles2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,8 @@ class BlurCircles2GM : public skiagm::GM {
};

auto blurMaker = [] (SkScalar radius) ->sk_sp<SkMaskFilter> {
return SkBlurMaskFilter::Make(kNormal_SkBlurStyle,
SkBlurMask::ConvertRadiusToSigma(radius),
SkBlurMaskFilter::kHighQuality_BlurFlag);
return SkMaskFilter::MakeBlur(kNormal_SkBlurStyle,
SkBlurMask::ConvertRadiusToSigma(radius));
};

SkPaint paint;
Expand Down
12 changes: 6 additions & 6 deletions gm/blurignorexform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -42,10 +42,10 @@ class BlurIgnoreXformGM : public skiagm::GM {

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);
}
}

Expand Down Expand Up @@ -114,7 +114,7 @@ class BlurIgnoreXformGM : public skiagm::GM {
static constexpr int kNumBlurs = 2;

static const struct BlurFlags {
uint32_t fFlags;
bool fRespectCTM;
const char* fName;
} kBlurFlags[kNumBlurs];

Expand All @@ -130,8 +130,8 @@ class BlurIgnoreXformGM : public skiagm::GM {
};

const BlurIgnoreXformGM::BlurFlags BlurIgnoreXformGM::kBlurFlags[] = {
{0, "none"},
{SkBlurMaskFilter::kIgnoreTransform_BlurFlag, "IgnoreTransform"}
{true, "none"},
{false, "IgnoreTransform"}
};

const BlurIgnoreXformGM::MatrixScale BlurIgnoreXformGM::kMatrixScales[] = {
Expand Down
8 changes: 3 additions & 5 deletions gm/blurimagevmask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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);

Expand All @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions gm/blurquickreject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -56,7 +56,7 @@ class BlurQuickRejectGM : public skiagm::GM {

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);
Expand Down
7 changes: 3 additions & 4 deletions gm/blurrect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -95,9 +95,8 @@ class BlurRectGM : public skiagm::GM {
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)));
}
}

Expand Down
Loading

0 comments on commit 1be1f8d

Please sign in to comment.