move common blur types into central header
BUG=skia: R=scroggo@google.com, djsollen@google.com Author: reed@google.com Review URL: https://codereview.chromium.org/253833002 git-svn-id: http://skia.googlecode.com/svn/trunk@14411 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
parent
2e0c32af05
commit
e396455d2d
@ -28,12 +28,12 @@ static const char* gStyleName[] = {
|
||||
|
||||
class BlurBench : public SkBenchmark {
|
||||
SkScalar fRadius;
|
||||
SkBlurMaskFilter::BlurStyle fStyle;
|
||||
uint32_t fFlags;
|
||||
SkBlurStyle fStyle;
|
||||
uint32_t fFlags;
|
||||
SkString fName;
|
||||
|
||||
public:
|
||||
BlurBench(SkScalar rad, SkBlurMaskFilter::BlurStyle bs, uint32_t flags = 0) {
|
||||
BlurBench(SkScalar rad, SkBlurStyle bs, uint32_t flags = 0) {
|
||||
fRadius = rad;
|
||||
fStyle = bs;
|
||||
fFlags = flags;
|
||||
@ -78,32 +78,32 @@ private:
|
||||
typedef SkBenchmark INHERITED;
|
||||
};
|
||||
|
||||
DEF_BENCH(return new BlurBench(SMALL, SkBlurMaskFilter::kNormal_BlurStyle);)
|
||||
DEF_BENCH(return new BlurBench(SMALL, SkBlurMaskFilter::kSolid_BlurStyle);)
|
||||
DEF_BENCH(return new BlurBench(SMALL, SkBlurMaskFilter::kOuter_BlurStyle);)
|
||||
DEF_BENCH(return new BlurBench(SMALL, SkBlurMaskFilter::kInner_BlurStyle);)
|
||||
DEF_BENCH(return new BlurBench(SMALL, kNormal_SkBlurStyle);)
|
||||
DEF_BENCH(return new BlurBench(SMALL, kSolid_SkBlurStyle);)
|
||||
DEF_BENCH(return new BlurBench(SMALL, kOuter_SkBlurStyle);)
|
||||
DEF_BENCH(return new BlurBench(SMALL, kInner_SkBlurStyle);)
|
||||
|
||||
DEF_BENCH(return new BlurBench(BIG, SkBlurMaskFilter::kNormal_BlurStyle);)
|
||||
DEF_BENCH(return new BlurBench(BIG, SkBlurMaskFilter::kSolid_BlurStyle);)
|
||||
DEF_BENCH(return new BlurBench(BIG, SkBlurMaskFilter::kOuter_BlurStyle);)
|
||||
DEF_BENCH(return new BlurBench(BIG, SkBlurMaskFilter::kInner_BlurStyle);)
|
||||
DEF_BENCH(return new BlurBench(BIG, kNormal_SkBlurStyle);)
|
||||
DEF_BENCH(return new BlurBench(BIG, kSolid_SkBlurStyle);)
|
||||
DEF_BENCH(return new BlurBench(BIG, kOuter_SkBlurStyle);)
|
||||
DEF_BENCH(return new BlurBench(BIG, kInner_SkBlurStyle);)
|
||||
|
||||
DEF_BENCH(return new BlurBench(REALBIG, SkBlurMaskFilter::kNormal_BlurStyle);)
|
||||
DEF_BENCH(return new BlurBench(REALBIG, SkBlurMaskFilter::kSolid_BlurStyle);)
|
||||
DEF_BENCH(return new BlurBench(REALBIG, SkBlurMaskFilter::kOuter_BlurStyle);)
|
||||
DEF_BENCH(return new BlurBench(REALBIG, SkBlurMaskFilter::kInner_BlurStyle);)
|
||||
DEF_BENCH(return new BlurBench(REALBIG, kNormal_SkBlurStyle);)
|
||||
DEF_BENCH(return new BlurBench(REALBIG, kSolid_SkBlurStyle);)
|
||||
DEF_BENCH(return new BlurBench(REALBIG, kOuter_SkBlurStyle);)
|
||||
DEF_BENCH(return new BlurBench(REALBIG, kInner_SkBlurStyle);)
|
||||
|
||||
DEF_BENCH(return new BlurBench(REAL, SkBlurMaskFilter::kNormal_BlurStyle);)
|
||||
DEF_BENCH(return new BlurBench(REAL, SkBlurMaskFilter::kSolid_BlurStyle);)
|
||||
DEF_BENCH(return new BlurBench(REAL, SkBlurMaskFilter::kOuter_BlurStyle);)
|
||||
DEF_BENCH(return new BlurBench(REAL, SkBlurMaskFilter::kInner_BlurStyle);)
|
||||
DEF_BENCH(return new BlurBench(REAL, kNormal_SkBlurStyle);)
|
||||
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(SMALL, SkBlurMaskFilter::kNormal_BlurStyle, SkBlurMaskFilter::kHighQuality_BlurFlag);)
|
||||
DEF_BENCH(return new BlurBench(SMALL, kNormal_SkBlurStyle, SkBlurMaskFilter::kHighQuality_BlurFlag);)
|
||||
|
||||
DEF_BENCH(return new BlurBench(BIG, SkBlurMaskFilter::kNormal_BlurStyle, SkBlurMaskFilter::kHighQuality_BlurFlag);)
|
||||
DEF_BENCH(return new BlurBench(BIG, kNormal_SkBlurStyle, SkBlurMaskFilter::kHighQuality_BlurFlag);)
|
||||
|
||||
DEF_BENCH(return new BlurBench(REALBIG, SkBlurMaskFilter::kNormal_BlurStyle, SkBlurMaskFilter::kHighQuality_BlurFlag);)
|
||||
DEF_BENCH(return new BlurBench(REALBIG, kNormal_SkBlurStyle, SkBlurMaskFilter::kHighQuality_BlurFlag);)
|
||||
|
||||
DEF_BENCH(return new BlurBench(REAL, SkBlurMaskFilter::kNormal_BlurStyle, SkBlurMaskFilter::kHighQuality_BlurFlag);)
|
||||
DEF_BENCH(return new BlurBench(REAL, kNormal_SkBlurStyle, SkBlurMaskFilter::kHighQuality_BlurFlag);)
|
||||
|
||||
DEF_BENCH(return new BlurBench(0, SkBlurMaskFilter::kNormal_BlurStyle);)
|
||||
DEF_BENCH(return new BlurBench(0, kNormal_SkBlurStyle);)
|
||||
|
@ -91,7 +91,7 @@ protected:
|
||||
virtual void makeBlurryRect(const SkRect& r) SK_OVERRIDE {
|
||||
SkMask mask;
|
||||
SkBlurMask::BlurRect(SkBlurMask::ConvertRadiusToSigma(this->radius()),
|
||||
&mask, r, SkBlurMask::kNormal_Style);
|
||||
&mask, r, kNormal_SkBlurStyle);
|
||||
SkMask::FreeImage(mask.fImage);
|
||||
}
|
||||
private:
|
||||
@ -146,8 +146,7 @@ protected:
|
||||
SkMask mask;
|
||||
mask.fImage = NULL;
|
||||
SkBlurMask::BoxBlur(&mask, fSrcMask, SkBlurMask::ConvertRadiusToSigma(this->radius()),
|
||||
SkBlurMask::kNormal_Style,
|
||||
SkBlurMask::kHigh_Quality);
|
||||
kNormal_SkBlurStyle, kHigh_SkBlurQuality);
|
||||
SkMask::FreeImage(mask.fImage);
|
||||
}
|
||||
private:
|
||||
@ -174,7 +173,7 @@ protected:
|
||||
SkMask mask;
|
||||
mask.fImage = NULL;
|
||||
SkBlurMask::BlurGroundTruth(SkBlurMask::ConvertRadiusToSigma(this->radius()),
|
||||
&mask, fSrcMask, SkBlurMask::kNormal_Style);
|
||||
&mask, fSrcMask, kNormal_SkBlurStyle);
|
||||
SkMask::FreeImage(mask.fImage);
|
||||
}
|
||||
private:
|
||||
|
@ -50,7 +50,7 @@ public:
|
||||
info.fPostTranslate = false;
|
||||
SkPaint* paint = looperBuilder.addLayerOnTop(info);
|
||||
SkMaskFilter* maskFilter = SkBlurMaskFilter::Create(
|
||||
SkBlurMaskFilter::kNormal_BlurStyle,
|
||||
kNormal_SkBlurStyle,
|
||||
SkBlurMask::ConvertRadiusToSigma(SK_ScalarHalf),
|
||||
SkBlurMaskFilter::kHighQuality_BlurFlag);
|
||||
paint->setMaskFilter(maskFilter)->unref();
|
||||
|
@ -85,7 +85,7 @@ private:
|
||||
|
||||
SkPaint* paint = looperBuilder.addLayer(info);
|
||||
|
||||
SkMaskFilter* mf = SkBlurMaskFilter::Create(SkBlurMaskFilter::kNormal_BlurStyle,
|
||||
SkMaskFilter* mf = SkBlurMaskFilter::Create(kNormal_SkBlurStyle,
|
||||
sigma,
|
||||
SkBlurMaskFilter::kHighQuality_BlurFlag);
|
||||
paint->setMaskFilter(mf)->unref();
|
||||
|
@ -69,9 +69,8 @@ protected:
|
||||
int desiredX = 0, desiredY = 0;
|
||||
|
||||
for (int i = 0; i < 2; ++i) {
|
||||
for (int j = 0; j < SkBlurMaskFilter::kBlurStyleCount; ++j) {
|
||||
SkMaskFilter* mf = SkBlurMaskFilter::Create((SkBlurMaskFilter::BlurStyle)j,
|
||||
kSigma);
|
||||
for (int j = 0; j <= kLastEnum_SkBlurStyle; ++j) {
|
||||
SkMaskFilter* mf = SkBlurMaskFilter::Create((SkBlurStyle)j, kSigma);
|
||||
blurPaint.setMaskFilter(mf)->unref();
|
||||
|
||||
for (int k = 0; k < (int)SK_ARRAY_COUNT(origins); ++k) {
|
||||
@ -107,7 +106,7 @@ protected:
|
||||
private:
|
||||
static const int kCloseUpSize = 64;
|
||||
static const int kWidth = 5 * kCloseUpSize;
|
||||
static const int kHeight = 2 * SkBlurMaskFilter::kBlurStyleCount * kCloseUpSize;
|
||||
static const int kHeight = 2 * (kLastEnum_SkBlurStyle + 1) * kCloseUpSize;
|
||||
|
||||
typedef GM INHERITED;
|
||||
};
|
||||
|
@ -84,7 +84,7 @@ protected:
|
||||
paint.setFilterLevel(SkPaint::kLow_FilterLevel);
|
||||
|
||||
SkMaskFilter* mf = SkBlurMaskFilter::Create(
|
||||
SkBlurMaskFilter::kNormal_BlurStyle,
|
||||
kNormal_SkBlurStyle,
|
||||
SkBlurMask::ConvertRadiusToSigma(5),
|
||||
SkBlurMaskFilter::kHighQuality_BlurFlag |
|
||||
SkBlurMaskFilter::kIgnoreTransform_BlurFlag);
|
||||
|
@ -162,7 +162,7 @@ protected:
|
||||
|
||||
SkPaint paint;
|
||||
paint.setFilterLevel(filter);
|
||||
SkMaskFilter* mf = SkBlurMaskFilter::Create(SkBlurMaskFilter::kNormal_BlurStyle,
|
||||
SkMaskFilter* mf = SkBlurMaskFilter::Create(kNormal_SkBlurStyle,
|
||||
SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(3)));
|
||||
paint.setMaskFilter(mf)->unref();
|
||||
|
||||
|
@ -56,7 +56,7 @@ protected:
|
||||
|
||||
SkPaint blurPaint;
|
||||
blurPaint.setFilterLevel(SkPaint::kLow_FilterLevel);
|
||||
SkMaskFilter* mf = SkBlurMaskFilter::Create(SkBlurMaskFilter::kNormal_BlurStyle,
|
||||
SkMaskFilter* mf = SkBlurMaskFilter::Create(kNormal_SkBlurStyle,
|
||||
SkBlurMask::ConvertRadiusToSigma(kBlurRadius));
|
||||
blurPaint.setMaskFilter(mf)->unref();
|
||||
|
||||
|
104
gm/blurrect.cpp
104
gm/blurrect.cpp
@ -58,7 +58,7 @@ static void draw_donut_skewed(SkCanvas* canvas, const SkRect& r, const SkPaint&
|
||||
typedef void (*PaintProc)(SkPaint*, SkScalar width);
|
||||
|
||||
class BlurRectGM : public skiagm::GM {
|
||||
SkAutoTUnref<SkMaskFilter> fMaskFilters[SkBlurMaskFilter::kBlurStyleCount];
|
||||
SkAutoTUnref<SkMaskFilter> fMaskFilters[kLastEnum_SkBlurStyle + 1];
|
||||
SkString fName;
|
||||
SkAlpha fAlpha;
|
||||
public:
|
||||
@ -69,8 +69,8 @@ public:
|
||||
|
||||
protected:
|
||||
virtual void onOnceBeforeDraw() SK_OVERRIDE {
|
||||
for (int i = 0; i < SkBlurMaskFilter::kBlurStyleCount; ++i) {
|
||||
fMaskFilters[i].reset(SkBlurMaskFilter::Create((SkBlurMaskFilter::BlurStyle) i,
|
||||
for (int i = 0; i <= kLastEnum_SkBlurStyle; ++i) {
|
||||
fMaskFilters[i].reset(SkBlurMaskFilter::Create((SkBlurStyle)i,
|
||||
SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(STROKE_WIDTH/2)),
|
||||
SkBlurMaskFilter::kHighQuality_BlurFlag));
|
||||
}
|
||||
@ -143,11 +143,11 @@ class BlurRectCompareGM : public skiagm::GM {
|
||||
SkString fName;
|
||||
unsigned int fRectWidth, fRectHeight;
|
||||
SkScalar fRadius;
|
||||
SkBlurMask::Style fStyle;
|
||||
SkBlurStyle fStyle;
|
||||
public:
|
||||
BlurRectCompareGM(const char name[], unsigned int rectWidth,
|
||||
unsigned int rectHeight, float radius,
|
||||
SkBlurMask::Style style)
|
||||
SkBlurStyle style)
|
||||
: fName(name)
|
||||
, fRectWidth(rectWidth)
|
||||
, fRectHeight(rectHeight)
|
||||
@ -163,7 +163,7 @@ public:
|
||||
SkScalar radius() const {
|
||||
return fRadius;
|
||||
}
|
||||
SkBlurMask::Style style() const {
|
||||
SkBlurStyle style() const {
|
||||
return fStyle;
|
||||
}
|
||||
|
||||
@ -215,7 +215,7 @@ class BlurRectFastGM: public BlurRectCompareGM {
|
||||
public:
|
||||
BlurRectFastGM(const char name[], unsigned int rectWidth,
|
||||
unsigned int rectHeight, float blurRadius,
|
||||
SkBlurMask::Style style) :
|
||||
SkBlurStyle style) :
|
||||
INHERITED(name, rectWidth, rectHeight, blurRadius, style) {
|
||||
}
|
||||
|
||||
@ -231,7 +231,7 @@ private:
|
||||
class BlurRectSlowGM: public BlurRectCompareGM {
|
||||
public:
|
||||
BlurRectSlowGM(const char name[], unsigned int rectWidth, unsigned int rectHeight,
|
||||
float blurRadius, SkBlurMask::Style style)
|
||||
float blurRadius, SkBlurStyle style)
|
||||
: INHERITED(name, rectWidth, rectHeight, blurRadius, style) {
|
||||
}
|
||||
|
||||
@ -252,8 +252,8 @@ protected:
|
||||
this->style(), this->getQuality());
|
||||
}
|
||||
|
||||
virtual SkBlurMask::Quality getQuality() {
|
||||
return SkBlurMask::kHigh_Quality;
|
||||
virtual SkBlurQuality getQuality() {
|
||||
return kHigh_SkBlurQuality;
|
||||
}
|
||||
private:
|
||||
typedef BlurRectCompareGM INHERITED;
|
||||
@ -262,13 +262,13 @@ private:
|
||||
class BlurRectSlowLowGM: public BlurRectSlowGM {
|
||||
public:
|
||||
BlurRectSlowLowGM(const char name[], unsigned int rectWidth, unsigned int rectHeight,
|
||||
float blurRadius, SkBlurMask::Style style)
|
||||
float blurRadius, SkBlurStyle style)
|
||||
: INHERITED(name, rectWidth, rectHeight, blurRadius, style) {
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual SkBlurMask::Quality getQuality() SK_OVERRIDE {
|
||||
return SkBlurMask::kLow_Quality;
|
||||
virtual SkBlurQuality getQuality() SK_OVERRIDE {
|
||||
return kLow_SkBlurQuality;
|
||||
}
|
||||
private:
|
||||
typedef BlurRectSlowGM INHERITED;
|
||||
@ -277,7 +277,7 @@ private:
|
||||
class BlurRectGroundTruthGM: public BlurRectCompareGM {
|
||||
public:
|
||||
BlurRectGroundTruthGM(const char name[], unsigned int rectWidth, unsigned int rectHeight,
|
||||
float blurRadius, SkBlurMask::Style style)
|
||||
float blurRadius, SkBlurStyle style)
|
||||
: INHERITED(name, rectWidth, rectHeight, blurRadius, style) {
|
||||
}
|
||||
|
||||
@ -297,8 +297,8 @@ protected:
|
||||
m, src, this->style());
|
||||
}
|
||||
|
||||
virtual SkBlurMask::Quality getQuality() {
|
||||
return SkBlurMask::kHigh_Quality;
|
||||
virtual SkBlurQuality getQuality() {
|
||||
return kHigh_SkBlurQuality;
|
||||
}
|
||||
private:
|
||||
typedef BlurRectCompareGM INHERITED;
|
||||
@ -314,48 +314,48 @@ static const SkScalar kSmall = 2;
|
||||
|
||||
// regular size rects, blurs should be small enough not to completely overlap.
|
||||
|
||||
DEF_GM(return new BlurRectFastGM( "blurrect_25_100_2_normal_fast", 25, 100, kSmall, SkBlurMask::kNormal_Style);)
|
||||
DEF_GM(return new BlurRectFastGM("blurrect_25_100_20_normal_fast", 25, 100, kBig, SkBlurMask::kNormal_Style);)
|
||||
DEF_GM(return new BlurRectSlowGM( "blurrect_25_100_2_normal_slow", 25, 100, kSmall, SkBlurMask::kNormal_Style);)
|
||||
DEF_GM(return new BlurRectSlowGM("blurrect_25_100_20_normal_slow", 25, 100, kBig, SkBlurMask::kNormal_Style);)
|
||||
DEF_GM(return new BlurRectFastGM( "blurrect_25_100_2_inner_fast", 25, 100, kSmall, SkBlurMask::kInner_Style);)
|
||||
DEF_GM(return new BlurRectFastGM("blurrect_25_100_20_inner_fast", 25, 100, kBig, SkBlurMask::kInner_Style);)
|
||||
DEF_GM(return new BlurRectSlowGM( "blurrect_25_100_2_inner_slow", 25, 100, kSmall, SkBlurMask::kInner_Style);)
|
||||
DEF_GM(return new BlurRectSlowGM("blurrect_25_100_20_inner_slow", 25, 100, kBig, SkBlurMask::kInner_Style);)
|
||||
DEF_GM(return new BlurRectFastGM( "blurrect_25_100_2_outer_fast", 25, 100, kSmall, SkBlurMask::kOuter_Style);)
|
||||
DEF_GM(return new BlurRectFastGM("blurrect_25_100_20_outer_fast", 25, 100, kBig, SkBlurMask::kOuter_Style);)
|
||||
DEF_GM(return new BlurRectSlowGM( "blurrect_25_100_2_outer_slow", 25, 100, kSmall, SkBlurMask::kOuter_Style);)
|
||||
DEF_GM(return new BlurRectSlowGM("blurrect_25_100_20_outer_slow", 25, 100, kBig, SkBlurMask::kOuter_Style);)
|
||||
DEF_GM(return new BlurRectFastGM( "blurrect_25_100_2_normal_fast", 25, 100, kSmall, kNormal_SkBlurStyle);)
|
||||
DEF_GM(return new BlurRectFastGM("blurrect_25_100_20_normal_fast", 25, 100, kBig, kNormal_SkBlurStyle);)
|
||||
DEF_GM(return new BlurRectSlowGM( "blurrect_25_100_2_normal_slow", 25, 100, kSmall, kNormal_SkBlurStyle);)
|
||||
DEF_GM(return new BlurRectSlowGM("blurrect_25_100_20_normal_slow", 25, 100, kBig, kNormal_SkBlurStyle);)
|
||||
DEF_GM(return new BlurRectFastGM( "blurrect_25_100_2_inner_fast", 25, 100, kSmall, kInner_SkBlurStyle);)
|
||||
DEF_GM(return new BlurRectFastGM("blurrect_25_100_20_inner_fast", 25, 100, kBig, kInner_SkBlurStyle);)
|
||||
DEF_GM(return new BlurRectSlowGM( "blurrect_25_100_2_inner_slow", 25, 100, kSmall, kInner_SkBlurStyle);)
|
||||
DEF_GM(return new BlurRectSlowGM("blurrect_25_100_20_inner_slow", 25, 100, kBig, kInner_SkBlurStyle);)
|
||||
DEF_GM(return new BlurRectFastGM( "blurrect_25_100_2_outer_fast", 25, 100, kSmall, kOuter_SkBlurStyle);)
|
||||
DEF_GM(return new BlurRectFastGM("blurrect_25_100_20_outer_fast", 25, 100, kBig, kOuter_SkBlurStyle);)
|
||||
DEF_GM(return new BlurRectSlowGM( "blurrect_25_100_2_outer_slow", 25, 100, kSmall, kOuter_SkBlurStyle);)
|
||||
DEF_GM(return new BlurRectSlowGM("blurrect_25_100_20_outer_slow", 25, 100, kBig, kOuter_SkBlurStyle);)
|
||||
|
||||
// skinny tall rects, blurs overlap in X but not y
|
||||
|
||||
DEF_GM(return new BlurRectFastGM( "blurrect_5_100_2_normal_fast", 5, 100, kSmall, SkBlurMask::kNormal_Style);)
|
||||
DEF_GM(return new BlurRectFastGM("blurrect_5_100_20_normal_fast", 5, 100, kBig, SkBlurMask::kNormal_Style);)
|
||||
DEF_GM(return new BlurRectSlowGM( "blurrect_5_100_2_normal_slow", 5, 100, kSmall, SkBlurMask::kNormal_Style);)
|
||||
DEF_GM(return new BlurRectSlowGM("blurrect_5_100_20_normal_slow", 5, 100, kBig, SkBlurMask::kNormal_Style);)
|
||||
DEF_GM(return new BlurRectFastGM( "blurrect_5_100_2_inner_fast", 5, 100, kSmall, SkBlurMask::kInner_Style);)
|
||||
DEF_GM(return new BlurRectFastGM("blurrect_5_100_20_inner_fast", 5, 100, kBig, SkBlurMask::kInner_Style);)
|
||||
DEF_GM(return new BlurRectSlowGM( "blurrect_5_100_2_inner_slow", 5, 100, kSmall, SkBlurMask::kInner_Style);)
|
||||
DEF_GM(return new BlurRectSlowGM("blurrect_5_100_20_inner_slow", 5, 100, kBig, SkBlurMask::kInner_Style);)
|
||||
DEF_GM(return new BlurRectFastGM( "blurrect_5_100_2_outer_fast", 5, 100, kSmall, SkBlurMask::kOuter_Style);)
|
||||
DEF_GM(return new BlurRectFastGM("blurrect_5_100_20_outer_fast", 5, 100, kBig, SkBlurMask::kOuter_Style);)
|
||||
DEF_GM(return new BlurRectSlowGM( "blurrect_5_100_2_outer_slow", 5, 100, kSmall, SkBlurMask::kOuter_Style);)
|
||||
DEF_GM(return new BlurRectSlowGM("blurrect_5_100_20_outer_slow", 5, 100, kBig, SkBlurMask::kOuter_Style);)
|
||||
DEF_GM(return new BlurRectFastGM( "blurrect_5_100_2_normal_fast", 5, 100, kSmall, kNormal_SkBlurStyle);)
|
||||
DEF_GM(return new BlurRectFastGM("blurrect_5_100_20_normal_fast", 5, 100, kBig, kNormal_SkBlurStyle);)
|
||||
DEF_GM(return new BlurRectSlowGM( "blurrect_5_100_2_normal_slow", 5, 100, kSmall, kNormal_SkBlurStyle);)
|
||||
DEF_GM(return new BlurRectSlowGM("blurrect_5_100_20_normal_slow", 5, 100, kBig, kNormal_SkBlurStyle);)
|
||||
DEF_GM(return new BlurRectFastGM( "blurrect_5_100_2_inner_fast", 5, 100, kSmall, kInner_SkBlurStyle);)
|
||||
DEF_GM(return new BlurRectFastGM("blurrect_5_100_20_inner_fast", 5, 100, kBig, kInner_SkBlurStyle);)
|
||||
DEF_GM(return new BlurRectSlowGM( "blurrect_5_100_2_inner_slow", 5, 100, kSmall, kInner_SkBlurStyle);)
|
||||
DEF_GM(return new BlurRectSlowGM("blurrect_5_100_20_inner_slow", 5, 100, kBig, kInner_SkBlurStyle);)
|
||||
DEF_GM(return new BlurRectFastGM( "blurrect_5_100_2_outer_fast", 5, 100, kSmall, kOuter_SkBlurStyle);)
|
||||
DEF_GM(return new BlurRectFastGM("blurrect_5_100_20_outer_fast", 5, 100, kBig, kOuter_SkBlurStyle);)
|
||||
DEF_GM(return new BlurRectSlowGM( "blurrect_5_100_2_outer_slow", 5, 100, kSmall, kOuter_SkBlurStyle);)
|
||||
DEF_GM(return new BlurRectSlowGM("blurrect_5_100_20_outer_slow", 5, 100, kBig, kOuter_SkBlurStyle);)
|
||||
|
||||
// tiny rects, blurs overlap in X and Y
|
||||
|
||||
DEF_GM(return new BlurRectFastGM( "blurrect_5_5_2_normal_fast", 5, 5, kSmall, SkBlurMask::kNormal_Style);)
|
||||
DEF_GM(return new BlurRectFastGM("blurrect_5_5_20_normal_fast", 5, 5, kBig, SkBlurMask::kNormal_Style);)
|
||||
DEF_GM(return new BlurRectSlowGM( "blurrect_5_5_2_normal_slow", 5, 5, kSmall, SkBlurMask::kNormal_Style);)
|
||||
DEF_GM(return new BlurRectSlowGM("blurrect_5_5_20_normal_slow", 5, 5, kBig, SkBlurMask::kNormal_Style);)
|
||||
DEF_GM(return new BlurRectFastGM( "blurrect_5_5_2_inner_fast", 5, 5, kSmall, SkBlurMask::kInner_Style);)
|
||||
DEF_GM(return new BlurRectFastGM("blurrect_5_5_20_inner_fast", 5, 5, kBig, SkBlurMask::kInner_Style);)
|
||||
DEF_GM(return new BlurRectSlowGM( "blurrect_5_5_2_inner_slow", 5, 5, kSmall, SkBlurMask::kInner_Style);)
|
||||
DEF_GM(return new BlurRectSlowGM("blurrect_5_5_20_inner_slow", 5, 5, kBig, SkBlurMask::kInner_Style);)
|
||||
DEF_GM(return new BlurRectFastGM( "blurrect_5_5_2_outer_fast", 5, 5, kSmall, SkBlurMask::kOuter_Style);)
|
||||
DEF_GM(return new BlurRectFastGM("blurrect_5_5_20_outer_fast", 5, 5, kBig, SkBlurMask::kOuter_Style);)
|
||||
DEF_GM(return new BlurRectSlowGM( "blurrect_5_5_2_outer_slow", 5, 5, kSmall, SkBlurMask::kOuter_Style);)
|
||||
DEF_GM(return new BlurRectSlowGM("blurrect_5_5_20_outer_slow", 5, 5, kBig, SkBlurMask::kOuter_Style);)
|
||||
DEF_GM(return new BlurRectFastGM( "blurrect_5_5_2_normal_fast", 5, 5, kSmall, kNormal_SkBlurStyle);)
|
||||
DEF_GM(return new BlurRectFastGM("blurrect_5_5_20_normal_fast", 5, 5, kBig, kNormal_SkBlurStyle);)
|
||||
DEF_GM(return new BlurRectSlowGM( "blurrect_5_5_2_normal_slow", 5, 5, kSmall, kNormal_SkBlurStyle);)
|
||||
DEF_GM(return new BlurRectSlowGM("blurrect_5_5_20_normal_slow", 5, 5, kBig, kNormal_SkBlurStyle);)
|
||||
DEF_GM(return new BlurRectFastGM( "blurrect_5_5_2_inner_fast", 5, 5, kSmall, kInner_SkBlurStyle);)
|
||||
DEF_GM(return new BlurRectFastGM("blurrect_5_5_20_inner_fast", 5, 5, kBig, kInner_SkBlurStyle);)
|
||||
DEF_GM(return new BlurRectSlowGM( "blurrect_5_5_2_inner_slow", 5, 5, kSmall, kInner_SkBlurStyle);)
|
||||
DEF_GM(return new BlurRectSlowGM("blurrect_5_5_20_inner_slow", 5, 5, kBig, kInner_SkBlurStyle);)
|
||||
DEF_GM(return new BlurRectFastGM( "blurrect_5_5_2_outer_fast", 5, 5, kSmall, kOuter_SkBlurStyle);)
|
||||
DEF_GM(return new BlurRectFastGM("blurrect_5_5_20_outer_fast", 5, 5, kBig, kOuter_SkBlurStyle);)
|
||||
DEF_GM(return new BlurRectSlowGM( "blurrect_5_5_2_outer_slow", 5, 5, kSmall, kOuter_SkBlurStyle);)
|
||||
DEF_GM(return new BlurRectSlowGM("blurrect_5_5_20_outer_slow", 5, 5, kBig, kOuter_SkBlurStyle);)
|
||||
|
||||
|
||||
#if 0
|
||||
|
@ -63,7 +63,7 @@ public:
|
||||
info.fPostTranslate = false;
|
||||
SkPaint* paint = looperBuilder.addLayerOnTop(info);
|
||||
SkMaskFilter* maskFilter = SkBlurMaskFilter::Create(
|
||||
SkBlurMaskFilter::kNormal_BlurStyle,
|
||||
kNormal_SkBlurStyle,
|
||||
SkBlurMask::ConvertRadiusToSigma(SK_ScalarHalf),
|
||||
SkBlurMaskFilter::kHighQuality_BlurFlag);
|
||||
paint->setMaskFilter(maskFilter)->unref();
|
||||
@ -121,7 +121,7 @@ protected:
|
||||
canvas->translate(0, (r.height() + SkIntToScalar(50)) * i);
|
||||
for (size_t j = 0; j < SK_ARRAY_COUNT(cornerRadii); ++j) {
|
||||
SkMaskFilter* filter = SkBlurMaskFilter::Create(
|
||||
SkBlurMaskFilter::kNormal_BlurStyle,
|
||||
kNormal_SkBlurStyle,
|
||||
SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(blurRadii[i])),
|
||||
SkBlurMaskFilter::kHighQuality_BlurFlag);
|
||||
SkPaint paint;
|
||||
|
18
gm/blurs.cpp
18
gm/blurs.cpp
@ -27,16 +27,16 @@ protected:
|
||||
}
|
||||
|
||||
virtual void onDraw(SkCanvas* canvas) {
|
||||
SkBlurMaskFilter::BlurStyle NONE = SkBlurMaskFilter::BlurStyle(-999);
|
||||
SkBlurStyle NONE = SkBlurStyle(-999);
|
||||
static const struct {
|
||||
SkBlurMaskFilter::BlurStyle fStyle;
|
||||
int fCx, fCy;
|
||||
SkBlurStyle fStyle;
|
||||
int fCx, fCy;
|
||||
} gRecs[] = {
|
||||
{ NONE, 0, 0 },
|
||||
{ SkBlurMaskFilter::kInner_BlurStyle, -1, 0 },
|
||||
{ SkBlurMaskFilter::kNormal_BlurStyle, 0, 1 },
|
||||
{ SkBlurMaskFilter::kSolid_BlurStyle, 0, -1 },
|
||||
{ SkBlurMaskFilter::kOuter_BlurStyle, 1, 0 },
|
||||
{ NONE, 0, 0 },
|
||||
{ kInner_SkBlurStyle, -1, 0 },
|
||||
{ kNormal_SkBlurStyle, 0, 1 },
|
||||
{ kSolid_SkBlurStyle, 0, -1 },
|
||||
{ kOuter_SkBlurStyle, 1, 0 },
|
||||
};
|
||||
|
||||
SkPaint paint;
|
||||
@ -64,7 +64,7 @@ protected:
|
||||
}
|
||||
// draw text
|
||||
{
|
||||
SkMaskFilter* mf = SkBlurMaskFilter::Create(SkBlurMaskFilter::kNormal_BlurStyle,
|
||||
SkMaskFilter* mf = SkBlurMaskFilter::Create(kNormal_SkBlurStyle,
|
||||
SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(4)),
|
||||
flags);
|
||||
paint.setMaskFilter(mf)->unref();
|
||||
|
@ -52,7 +52,7 @@ protected:
|
||||
SkPaint p;
|
||||
p.setAntiAlias(true);
|
||||
SkMaskFilter* mf = SkBlurMaskFilter::Create(
|
||||
SkBlurMaskFilter::kNormal_BlurStyle,
|
||||
kNormal_SkBlurStyle,
|
||||
SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(5)),
|
||||
SkBlurMaskFilter::kHighQuality_BlurFlag);
|
||||
p.setMaskFilter(mf)->unref();
|
||||
|
@ -163,7 +163,7 @@ protected:
|
||||
|
||||
srcRect.setXYWH(1, 1, 3, 3);
|
||||
SkMaskFilter* mf = SkBlurMaskFilter::Create(
|
||||
SkBlurMaskFilter::kNormal_BlurStyle,
|
||||
kNormal_SkBlurStyle,
|
||||
SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(5)),
|
||||
SkBlurMaskFilter::kHighQuality_BlurFlag |
|
||||
SkBlurMaskFilter::kIgnoreTransform_BlurFlag);
|
||||
|
@ -85,7 +85,7 @@ private:
|
||||
paint->setStyle(gParams[i].fStyle);
|
||||
paint->setStrokeWidth(gParams[i].fWidth);
|
||||
if (gParams[i].fBlur > 0) {
|
||||
SkMaskFilter* mf = SkBlurMaskFilter::Create(SkBlurMaskFilter::kNormal_BlurStyle,
|
||||
SkMaskFilter* mf = SkBlurMaskFilter::Create(kNormal_SkBlurStyle,
|
||||
SkBlurMask::ConvertRadiusToSigma(gParams[i].fBlur));
|
||||
paint->setMaskFilter(mf)->unref();
|
||||
}
|
||||
|
@ -113,8 +113,7 @@ private:
|
||||
SkMaskFilter* createBlur() {
|
||||
static const SkScalar kBlurSigma = SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(25));
|
||||
|
||||
return SkBlurMaskFilter::Create(SkBlurMaskFilter::kNormal_BlurStyle,
|
||||
kBlurSigma,
|
||||
return SkBlurMaskFilter::Create(kNormal_SkBlurStyle, kBlurSigma,
|
||||
SkBlurMaskFilter::kHighQuality_BlurFlag);
|
||||
}
|
||||
|
||||
|
@ -64,7 +64,7 @@ protected:
|
||||
p.setColor(SK_ColorWHITE);
|
||||
p.setAntiAlias(true);
|
||||
SkMaskFilter* mf = SkBlurMaskFilter::Create(
|
||||
SkBlurMaskFilter::kNormal_BlurStyle,
|
||||
kNormal_SkBlurStyle,
|
||||
SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(5)),
|
||||
SkBlurMaskFilter::kHighQuality_BlurFlag);
|
||||
p.setMaskFilter(mf)->unref();
|
||||
|
@ -80,7 +80,7 @@ protected:
|
||||
paint.setAntiAlias(true);
|
||||
paint.setColor(0xFF000000);
|
||||
paint.setMaskFilter(
|
||||
SkBlurMaskFilter::Create(SkBlurMaskFilter::kNormal_BlurStyle,
|
||||
SkBlurMaskFilter::Create(kNormal_SkBlurStyle,
|
||||
0.78867501f,
|
||||
SkBlurMaskFilter::kHighQuality_BlurFlag))->unref();
|
||||
paint.setColorFilter(
|
||||
|
@ -13,7 +13,7 @@
|
||||
#include "SkLayerRasterizer.h"
|
||||
|
||||
static void r0(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p) {
|
||||
p.setMaskFilter(SkBlurMaskFilter::Create(SkBlurMaskFilter::kNormal_BlurStyle,
|
||||
p.setMaskFilter(SkBlurMaskFilter::Create(kNormal_SkBlurStyle,
|
||||
SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(3))))->unref();
|
||||
rastBuilder->addLayer(p, SkIntToScalar(3), SkIntToScalar(3));
|
||||
|
||||
|
@ -307,6 +307,7 @@
|
||||
'SK_SUPPORT_LEGACY_DERIVED_PICTURE_CLASSES',
|
||||
'SK_SUPPORT_LEGACY_PICTURE_HEADERS',
|
||||
'SK_SUPPORT_LEGACY_BLURDRAWLOOPERCONSTRUCTORS',
|
||||
'SK_SUPPORT_LEGACY_BLURMASKFILTER_STYLE',
|
||||
# Needed until we fix skbug.com/2440.
|
||||
'SK_SUPPORT_LEGACY_CLIPTOLAYERFLAG',
|
||||
# Transitional, for deprecated SkCanvas::SaveFlags methods.
|
||||
|
@ -21,6 +21,7 @@
|
||||
'SK_SUPPORT_LEGACY_PICTURE_HEADERS',
|
||||
'SK_SUPPORT_LEGACY_PICTURE_CAN_RECORD',
|
||||
'SK_SUPPORT_DEPRECATED_RECORD_FLAGS',
|
||||
'SK_SUPPORT_LEGACY_BLURMASKFILTER_STYLE',
|
||||
],
|
||||
},
|
||||
}
|
||||
|
29
include/core/SkBlurTypes.h
Normal file
29
include/core/SkBlurTypes.h
Normal file
@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright 2014 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef SkBlurTypes_DEFINED
|
||||
#define SkBlurTypes_DEFINED
|
||||
|
||||
#include "SkTypes.h"
|
||||
|
||||
enum SkBlurStyle {
|
||||
kNormal_SkBlurStyle, //!< fuzzy inside and outside
|
||||
kSolid_SkBlurStyle, //!< solid inside, fuzzy outside
|
||||
kOuter_SkBlurStyle, //!< nothing inside, fuzzy outside
|
||||
kInner_SkBlurStyle, //!< fuzzy inside, nothing outside
|
||||
|
||||
kLastEnum_SkBlurStyle = kInner_SkBlurStyle
|
||||
};
|
||||
|
||||
enum SkBlurQuality {
|
||||
kLow_SkBlurQuality, //!< e.g. box filter
|
||||
kHigh_SkBlurQuality, //!< e.g. 3-pass similar to gaussian
|
||||
|
||||
kLastEnum_SkBlurQuality
|
||||
};
|
||||
|
||||
#endif
|
@ -11,17 +11,20 @@
|
||||
// we include this since our callers will need to at least be able to ref/unref
|
||||
#include "SkMaskFilter.h"
|
||||
#include "SkScalar.h"
|
||||
#include "SkBlurTypes.h"
|
||||
|
||||
class SK_API SkBlurMaskFilter {
|
||||
public:
|
||||
#ifdef SK_SUPPORT_LEGACY_BLURMASKFILTER_STYLE
|
||||
enum BlurStyle {
|
||||
kNormal_BlurStyle, //!< fuzzy inside and outside
|
||||
kSolid_BlurStyle, //!< solid inside, fuzzy outside
|
||||
kOuter_BlurStyle, //!< nothing inside, fuzzy outside
|
||||
kInner_BlurStyle, //!< fuzzy inside, nothing outside
|
||||
kNormal_BlurStyle = kNormal_SkBlurStyle, //!< fuzzy inside and outside
|
||||
kSolid_BlurStyle = kSolid_SkBlurStyle, //!< solid inside, fuzzy outside
|
||||
kOuter_BlurStyle = kOuter_SkBlurStyle, //!< nothing inside, fuzzy outside
|
||||
kInner_BlurStyle = kInner_SkBlurStyle, //!< fuzzy inside, nothing outside
|
||||
|
||||
kBlurStyleCount
|
||||
};
|
||||
#endif
|
||||
|
||||
enum BlurFlags {
|
||||
kNone_BlurFlag = 0x00,
|
||||
@ -33,6 +36,7 @@ public:
|
||||
kAll_BlurFlag = 0x03
|
||||
};
|
||||
|
||||
#ifdef SK_SUPPORT_LEGACY_BLURMASKFILTER_STYLE
|
||||
SK_ATTR_DEPRECATED("use sigma version")
|
||||
static SkMaskFilter* Create(SkScalar radius, BlurStyle style,
|
||||
uint32_t flags = kNone_BlurFlag);
|
||||
@ -45,6 +49,15 @@ public:
|
||||
*/
|
||||
static SkMaskFilter* Create(BlurStyle style, SkScalar sigma,
|
||||
uint32_t flags = kNone_BlurFlag);
|
||||
#endif
|
||||
|
||||
/** Create a blur maskfilter.
|
||||
* @param style The SkBlurStyle to use
|
||||
* @param sigma Standard deviation of the Gaussian blur to apply. Must be > 0.
|
||||
* @param flags Flags to use - defaults to none
|
||||
* @return The new blur maskfilter
|
||||
*/
|
||||
static SkMaskFilter* Create(SkBlurStyle style, SkScalar sigma, uint32_t flags = kNone_BlurFlag);
|
||||
|
||||
/** Create an emboss maskfilter
|
||||
@param blurSigma standard deviation of the Gaussian blur to apply
|
||||
|
@ -82,7 +82,7 @@ private:
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
static void r0(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p) {
|
||||
p.setMaskFilter(SkBlurMaskFilter::Create(SkBlurMaskFilter::kNormal_BlurStyle,
|
||||
p.setMaskFilter(SkBlurMaskFilter::Create(kNormal_SkBlurStyle,
|
||||
SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(3)),
|
||||
SkBlurMaskFilter::kNone_BlurFlag))->unref();
|
||||
rastBuilder->addLayer(p, SkIntToScalar(3), SkIntToScalar(3));
|
||||
|
@ -37,11 +37,11 @@ protected:
|
||||
25 * SK_Scalar1,
|
||||
3 * SK_Scalar1);
|
||||
|
||||
static const SkBlurMaskFilter::BlurStyle gStyles[] = {
|
||||
SkBlurMaskFilter::kNormal_BlurStyle,
|
||||
SkBlurMaskFilter::kInner_BlurStyle,
|
||||
SkBlurMaskFilter::kSolid_BlurStyle,
|
||||
SkBlurMaskFilter::kOuter_BlurStyle,
|
||||
static const SkBlurStyle gStyles[] = {
|
||||
kNormal_SkBlurStyle,
|
||||
kInner_SkBlurStyle,
|
||||
kSolid_SkBlurStyle,
|
||||
kOuter_SkBlurStyle,
|
||||
};
|
||||
SkRandom random;
|
||||
|
||||
|
@ -31,7 +31,7 @@ protected:
|
||||
canvas->save();
|
||||
paint.setColor(SK_ColorBLUE);
|
||||
SkMaskFilter* mf = SkBlurMaskFilter::Create(
|
||||
SkBlurMaskFilter::kNormal_BlurStyle,
|
||||
kNormal_SkBlurStyle,
|
||||
SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(128)),
|
||||
SkBlurMaskFilter::kHighQuality_BlurFlag);
|
||||
paint.setMaskFilter(mf)->unref();
|
||||
|
@ -76,16 +76,16 @@ protected:
|
||||
virtual void onDrawContent(SkCanvas* canvas) {
|
||||
drawBG(canvas);
|
||||
|
||||
SkBlurMaskFilter::BlurStyle NONE = SkBlurMaskFilter::BlurStyle(-999);
|
||||
SkBlurStyle NONE = SkBlurStyle(-999);
|
||||
static const struct {
|
||||
SkBlurMaskFilter::BlurStyle fStyle;
|
||||
int fCx, fCy;
|
||||
SkBlurStyle fStyle;
|
||||
int fCx, fCy;
|
||||
} gRecs[] = {
|
||||
{ NONE, 0, 0 },
|
||||
{ SkBlurMaskFilter::kInner_BlurStyle, -1, 0 },
|
||||
{ SkBlurMaskFilter::kNormal_BlurStyle, 0, 1 },
|
||||
{ SkBlurMaskFilter::kSolid_BlurStyle, 0, -1 },
|
||||
{ SkBlurMaskFilter::kOuter_BlurStyle, 1, 0 },
|
||||
{ kInner_SkBlurStyle, -1, 0 },
|
||||
{ kNormal_SkBlurStyle, 0, 1 },
|
||||
{ kSolid_SkBlurStyle, 0, -1 },
|
||||
{ kOuter_SkBlurStyle, 1, 0 },
|
||||
};
|
||||
|
||||
SkPaint paint;
|
||||
@ -111,7 +111,7 @@ protected:
|
||||
}
|
||||
// draw text
|
||||
{
|
||||
SkMaskFilter* mf = SkBlurMaskFilter::Create(SkBlurMaskFilter::kNormal_BlurStyle,
|
||||
SkMaskFilter* mf = SkBlurMaskFilter::Create(kNormal_SkBlurStyle,
|
||||
SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(4)),
|
||||
flags);
|
||||
paint.setMaskFilter(mf)->unref();
|
||||
|
@ -24,7 +24,7 @@ static void paint_proc0(SkPaint*) {
|
||||
|
||||
static void paint_proc1(SkPaint* paint) {
|
||||
paint->setMaskFilter(SkBlurMaskFilter::Create(
|
||||
SkBlurMaskFilter::kNormal_BlurStyle,
|
||||
kNormal_SkBlurStyle,
|
||||
SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(2))))->unref();
|
||||
}
|
||||
|
||||
|
@ -190,9 +190,8 @@ static void do_fuzz(SkCanvas* canvas) {
|
||||
|
||||
case 7:
|
||||
if (quick == true) break;
|
||||
SkSafeUnref(paint.setMaskFilter(SkBlurMaskFilter::Create(
|
||||
SkBlurMaskFilter::kNormal_BlurStyle,
|
||||
make_number())));
|
||||
SkSafeUnref(paint.setMaskFilter(SkBlurMaskFilter::Create(kNormal_SkBlurStyle,
|
||||
make_number())));
|
||||
break;
|
||||
|
||||
case 8:
|
||||
|
@ -478,7 +478,7 @@ static void mesh_slide(SkCanvas* canvas) {
|
||||
|
||||
static void r0(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p)
|
||||
{
|
||||
p.setMaskFilter(SkBlurMaskFilter::Create(SkBlurMaskFilter::kNormal_BlurStyle,
|
||||
p.setMaskFilter(SkBlurMaskFilter::Create(kNormal_SkBlurStyle,
|
||||
SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(3))))->unref();
|
||||
rastBuilder->addLayer(p, SkIntToScalar(3), SkIntToScalar(3));
|
||||
|
||||
|
@ -160,11 +160,11 @@ protected:
|
||||
paint.setColor(SK_ColorWHITE);
|
||||
canvas->translate(10, 30);
|
||||
|
||||
static const SkBlurMaskFilter::BlurStyle gStyle[] = {
|
||||
SkBlurMaskFilter::kNormal_BlurStyle,
|
||||
SkBlurMaskFilter::kInner_BlurStyle,
|
||||
SkBlurMaskFilter::kOuter_BlurStyle,
|
||||
SkBlurMaskFilter::kSolid_BlurStyle,
|
||||
static const SkBlurStyle gStyle[] = {
|
||||
kNormal_SkBlurStyle,
|
||||
kInner_SkBlurStyle,
|
||||
kOuter_SkBlurStyle,
|
||||
kSolid_SkBlurStyle,
|
||||
};
|
||||
for (int x = 0; x < 5; x++) {
|
||||
SkMaskFilter* mf;
|
||||
|
@ -70,7 +70,7 @@ protected:
|
||||
|
||||
paint.setARGB(fByte, 0xFF, 0xFF, 0xFF);
|
||||
|
||||
paint.setMaskFilter(SkBlurMaskFilter::Create(SkBlurMaskFilter::kNormal_BlurStyle,
|
||||
paint.setMaskFilter(SkBlurMaskFilter::Create(kNormal_SkBlurStyle,
|
||||
SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(3))));
|
||||
paint.getMaskFilter()->unref();
|
||||
|
||||
|
@ -78,7 +78,7 @@ protected:
|
||||
srcRect.setXYWH(1, 1, 3, 3);
|
||||
dstRect.setXYWH(5, 405, 305, 305);
|
||||
SkMaskFilter* mf = SkBlurMaskFilter::Create(
|
||||
SkBlurMaskFilter::kNormal_BlurStyle,
|
||||
kNormal_SkBlurStyle,
|
||||
SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(5)),
|
||||
SkBlurMaskFilter::kHighQuality_BlurFlag |
|
||||
SkBlurMaskFilter::kIgnoreTransform_BlurFlag);
|
||||
@ -90,7 +90,7 @@ 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 NULL src rect handling
|
||||
mf = SkBlurMaskFilter::Create(SkBlurMaskFilter::kNormal_BlurStyle,
|
||||
mf = SkBlurMaskFilter::Create(kNormal_SkBlurStyle,
|
||||
SkBlurMask::ConvertRadiusToSigma(5),
|
||||
SkBlurMaskFilter::kHighQuality_BlurFlag);
|
||||
paint.setMaskFilter(mf)->unref();
|
||||
|
@ -46,7 +46,7 @@ class XfermodesBlurView : public SampleView {
|
||||
void draw_mode(SkCanvas* canvas, SkXfermode* mode, int alpha,
|
||||
SkScalar x, SkScalar y) {
|
||||
SkPaint p;
|
||||
SkMaskFilter* mf = SkBlurMaskFilter::Create(SkBlurMaskFilter::kNormal_BlurStyle,
|
||||
SkMaskFilter* mf = SkBlurMaskFilter::Create(kNormal_SkBlurStyle,
|
||||
SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(5)),
|
||||
SkBlurMaskFilter::kNone_BlurFlag);
|
||||
p.setMaskFilter(mf)->unref();
|
||||
|
@ -22,11 +22,12 @@ DEFINE_GET_MEMBER(SkDrawBlur);
|
||||
|
||||
SkDrawBlur::SkDrawBlur()
|
||||
: fSigma(-1)
|
||||
, fBlurStyle(SkBlurMaskFilter::kNormal_BlurStyle) {
|
||||
, fBlurStyle(kNormal_SkBlurStyle) {
|
||||
}
|
||||
|
||||
SkMaskFilter* SkDrawBlur::getMaskFilter() {
|
||||
if (fSigma < 0)
|
||||
if (fSigma <= 0) {
|
||||
return NULL;
|
||||
return SkBlurMaskFilter::Create((SkBlurMaskFilter::BlurStyle) fBlurStyle, fSigma);
|
||||
}
|
||||
return SkBlurMaskFilter::Create((SkBlurStyle)fBlurStyle, fSigma);
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ class SkDrawBlur : public SkDrawMaskFilter {
|
||||
virtual SkMaskFilter* getMaskFilter() SK_OVERRIDE;
|
||||
protected:
|
||||
SkScalar fSigma;
|
||||
int /*SkBlurMaskFilter::BlurStyle*/ fBlurStyle;
|
||||
int /*SkBlurStyle*/ fBlurStyle;
|
||||
|
||||
typedef SkDrawMaskFilter INHERITED;
|
||||
};
|
||||
|
@ -46,9 +46,7 @@ void SkBlurDrawLooper::init(SkScalar sigma, SkScalar dx, SkScalar dy,
|
||||
SkBlurMaskFilter::kHighQuality_BlurFlag :
|
||||
SkBlurMaskFilter::kNone_BlurFlag;
|
||||
|
||||
fBlur = SkBlurMaskFilter::Create(SkBlurMaskFilter::kNormal_BlurStyle,
|
||||
sigma,
|
||||
blurFlags);
|
||||
fBlur = SkBlurMaskFilter::Create(kNormal_SkBlurStyle, sigma, blurFlags);
|
||||
} else {
|
||||
fBlur = NULL;
|
||||
}
|
||||
|
@ -435,11 +435,11 @@ static void merge_src_with_blur(uint8_t dst[], int dstRB,
|
||||
static void clamp_with_orig(uint8_t dst[], int dstRowBytes,
|
||||
const uint8_t src[], int srcRowBytes,
|
||||
int sw, int sh,
|
||||
SkBlurMask::Style style) {
|
||||
SkBlurStyle style) {
|
||||
int x;
|
||||
while (--sh >= 0) {
|
||||
switch (style) {
|
||||
case SkBlurMask::kSolid_Style:
|
||||
case kSolid_SkBlurStyle:
|
||||
for (x = sw - 1; x >= 0; --x) {
|
||||
int s = *src;
|
||||
int d = *dst;
|
||||
@ -448,7 +448,7 @@ static void clamp_with_orig(uint8_t dst[], int dstRowBytes,
|
||||
src += 1;
|
||||
}
|
||||
break;
|
||||
case SkBlurMask::kOuter_Style:
|
||||
case kOuter_SkBlurStyle:
|
||||
for (x = sw - 1; x >= 0; --x) {
|
||||
if (*src) {
|
||||
*dst = SkToU8(SkAlphaMul(*dst, SkAlpha255To256(255 - *src)));
|
||||
@ -475,21 +475,19 @@ void SkMask_FreeImage(uint8_t* image) {
|
||||
SkMask::FreeImage(image);
|
||||
}
|
||||
|
||||
bool SkBlurMask::BoxBlur(SkMask* dst, const SkMask& src,
|
||||
SkScalar sigma, Style style, Quality quality,
|
||||
SkIPoint* margin, bool force_quality) {
|
||||
|
||||
bool SkBlurMask::BoxBlur(SkMask* dst, const SkMask& src, SkScalar sigma, SkBlurStyle style,
|
||||
SkBlurQuality quality, SkIPoint* margin, bool force_quality) {
|
||||
if (src.fFormat != SkMask::kA8_Format) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Force high quality off for small radii (performance)
|
||||
if (!force_quality && sigma <= SkIntToScalar(2)) {
|
||||
quality = kLow_Quality;
|
||||
quality = kLow_SkBlurQuality;
|
||||
}
|
||||
|
||||
SkScalar passRadius;
|
||||
if (kHigh_Quality == quality) {
|
||||
if (kHigh_SkBlurQuality == quality) {
|
||||
// For the high quality path the 3 pass box blur kernel width is
|
||||
// 6*rad+1 while the full Gaussian width is 6*sigma.
|
||||
passRadius = sigma - (1/6.0f);
|
||||
@ -502,7 +500,7 @@ bool SkBlurMask::BoxBlur(SkMask* dst, const SkMask& src,
|
||||
|
||||
// highQuality: use three box blur passes as a cheap way
|
||||
// to approximate a Gaussian blur
|
||||
int passCount = (kHigh_Quality == quality) ? 3 : 1;
|
||||
int passCount = (kHigh_SkBlurQuality == quality) ? 3 : 1;
|
||||
|
||||
int rx = SkScalarCeilToInt(passRadius);
|
||||
int outerWeight = 255 - SkScalarRoundToInt((SkIntToScalar(rx) - passRadius) * 255);
|
||||
@ -548,7 +546,7 @@ bool SkBlurMask::BoxBlur(SkMask* dst, const SkMask& src,
|
||||
if (outerWeight == 255) {
|
||||
int loRadius, hiRadius;
|
||||
get_adjusted_radii(passRadius, &loRadius, &hiRadius);
|
||||
if (kHigh_Quality == quality) {
|
||||
if (kHigh_SkBlurQuality == quality) {
|
||||
// Do three X blurs, with a transpose on the final one.
|
||||
w = boxBlur(sp, src.fRowBytes, tp, loRadius, hiRadius, w, h, false);
|
||||
w = boxBlur(tp, w, dp, hiRadius, loRadius, w, h, false);
|
||||
@ -562,7 +560,7 @@ bool SkBlurMask::BoxBlur(SkMask* dst, const SkMask& src,
|
||||
h = boxBlur(tp, h, dp, ry, ry, h, w, true);
|
||||
}
|
||||
} else {
|
||||
if (kHigh_Quality == quality) {
|
||||
if (kHigh_SkBlurQuality == quality) {
|
||||
// Do three X blurs, with a transpose on the final one.
|
||||
w = boxBlurInterp(sp, src.fRowBytes, tp, rx, w, h, false, outerWeight);
|
||||
w = boxBlurInterp(tp, w, dp, rx, w, h, false, outerWeight);
|
||||
@ -580,7 +578,7 @@ bool SkBlurMask::BoxBlur(SkMask* dst, const SkMask& src,
|
||||
dst->fImage = dp;
|
||||
// if need be, alloc the "real" dst (same size as src) and copy/merge
|
||||
// the blur into it (applying the src)
|
||||
if (style == kInner_Style) {
|
||||
if (style == kInner_SkBlurStyle) {
|
||||
// now we allocate the "real" dst, mirror the size of src
|
||||
size_t srcSize = src.computeImageSize();
|
||||
if (0 == srcSize) {
|
||||
@ -592,14 +590,14 @@ bool SkBlurMask::BoxBlur(SkMask* dst, const SkMask& src,
|
||||
dp + passCount * (rx + ry * dst->fRowBytes),
|
||||
dst->fRowBytes, sw, sh);
|
||||
SkMask::FreeImage(dp);
|
||||
} else if (style != kNormal_Style) {
|
||||
} else if (style != kNormal_SkBlurStyle) {
|
||||
clamp_with_orig(dp + passCount * (rx + ry * dst->fRowBytes),
|
||||
dst->fRowBytes, sp, src.fRowBytes, sw, sh, style);
|
||||
}
|
||||
(void)autoCall.detach();
|
||||
}
|
||||
|
||||
if (style == kInner_Style) {
|
||||
if (style == kInner_SkBlurStyle) {
|
||||
dst->fBounds = src.fBounds; // restore trimmed bounds
|
||||
dst->fRowBytes = src.fRowBytes;
|
||||
}
|
||||
@ -734,7 +732,7 @@ void SkBlurMask::ComputeBlurredScanline(uint8_t *pixels, const uint8_t *profile,
|
||||
}
|
||||
|
||||
bool SkBlurMask::BlurRect(SkScalar sigma, SkMask *dst,
|
||||
const SkRect &src, Style style,
|
||||
const SkRect &src, SkBlurStyle style,
|
||||
SkIPoint *margin, SkMask::CreateMode createMode) {
|
||||
int profile_size = SkScalarCeilToInt(6*sigma);
|
||||
|
||||
@ -756,7 +754,7 @@ bool SkBlurMask::BlurRect(SkScalar sigma, SkMask *dst,
|
||||
int sh = SkScalarFloorToInt(src.height());
|
||||
|
||||
if (createMode == SkMask::kJustComputeBounds_CreateMode) {
|
||||
if (style == kInner_Style) {
|
||||
if (style == kInner_SkBlurStyle) {
|
||||
dst->fBounds.set(SkScalarRoundToInt(src.fLeft),
|
||||
SkScalarRoundToInt(src.fTop),
|
||||
SkScalarRoundToInt(src.fRight),
|
||||
@ -797,7 +795,7 @@ bool SkBlurMask::BlurRect(SkScalar sigma, SkMask *dst,
|
||||
}
|
||||
}
|
||||
|
||||
if (style == kInner_Style) {
|
||||
if (style == kInner_SkBlurStyle) {
|
||||
// now we allocate the "real" dst, mirror the size of src
|
||||
size_t srcSize = (size_t)(src.width() * src.height());
|
||||
if (0 == srcSize) {
|
||||
@ -817,12 +815,12 @@ bool SkBlurMask::BlurRect(SkScalar sigma, SkMask *dst,
|
||||
SkScalarRoundToInt(src.fBottom)); // restore trimmed bounds
|
||||
dst->fRowBytes = sw;
|
||||
|
||||
} else if (style == kOuter_Style) {
|
||||
} else if (style == kOuter_SkBlurStyle) {
|
||||
for (int y = pad ; y < dstHeight-pad ; y++) {
|
||||
uint8_t *dst_scanline = dp + y*dstWidth + pad;
|
||||
memset(dst_scanline, 0, sw);
|
||||
}
|
||||
} else if (style == kSolid_Style) {
|
||||
} else if (style == kSolid_SkBlurStyle) {
|
||||
for (int y = pad ; y < dstHeight-pad ; y++) {
|
||||
uint8_t *dst_scanline = dp + y*dstWidth + pad;
|
||||
memset(dst_scanline, 0xff, sw);
|
||||
@ -835,7 +833,7 @@ bool SkBlurMask::BlurRect(SkScalar sigma, SkMask *dst,
|
||||
}
|
||||
|
||||
bool SkBlurMask::BlurRRect(SkScalar sigma, SkMask *dst,
|
||||
const SkRRect &src, Style style,
|
||||
const SkRRect &src, SkBlurStyle style,
|
||||
SkIPoint *margin, SkMask::CreateMode createMode) {
|
||||
// Temporary for now -- always fail, should cause caller to fall back
|
||||
// to old path. Plumbing just to land API and parallelize effort.
|
||||
@ -848,7 +846,7 @@ bool SkBlurMask::BlurRRect(SkScalar sigma, SkMask *dst,
|
||||
// useful for correctness comparisons.
|
||||
|
||||
bool SkBlurMask::BlurGroundTruth(SkScalar sigma, SkMask* dst, const SkMask& src,
|
||||
Style style, SkIPoint* margin) {
|
||||
SkBlurStyle style, SkIPoint* margin) {
|
||||
|
||||
if (src.fFormat != SkMask::kA8_Format) {
|
||||
return false;
|
||||
@ -964,7 +962,7 @@ bool SkBlurMask::BlurGroundTruth(SkScalar sigma, SkMask* dst, const SkMask& src,
|
||||
dst->fImage = dstPixels;
|
||||
// if need be, alloc the "real" dst (same size as src) and copy/merge
|
||||
// the blur into it (applying the src)
|
||||
if (style == kInner_Style) {
|
||||
if (style == kInner_SkBlurStyle) {
|
||||
// now we allocate the "real" dst, mirror the size of src
|
||||
size_t srcSize = src.computeImageSize();
|
||||
if (0 == srcSize) {
|
||||
@ -976,14 +974,14 @@ bool SkBlurMask::BlurGroundTruth(SkScalar sigma, SkMask* dst, const SkMask& src,
|
||||
dstPixels + pad*dst->fRowBytes + pad,
|
||||
dst->fRowBytes, srcWidth, srcHeight);
|
||||
SkMask::FreeImage(dstPixels);
|
||||
} else if (style != kNormal_Style) {
|
||||
} else if (style != kNormal_SkBlurStyle) {
|
||||
clamp_with_orig(dstPixels + pad*dst->fRowBytes + pad,
|
||||
dst->fRowBytes, srcPixels, src.fRowBytes, srcWidth, srcHeight, style);
|
||||
}
|
||||
(void)autoCall.detach();
|
||||
}
|
||||
|
||||
if (style == kInner_Style) {
|
||||
if (style == kInner_SkBlurStyle) {
|
||||
dst->fBounds = src.fBounds; // restore trimmed bounds
|
||||
dst->fRowBytes = src.fRowBytes;
|
||||
}
|
||||
|
@ -1,4 +1,3 @@
|
||||
|
||||
/*
|
||||
* Copyright 2006 The Android Open Source Project
|
||||
*
|
||||
@ -6,37 +5,21 @@
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef SkBlurMask_DEFINED
|
||||
#define SkBlurMask_DEFINED
|
||||
|
||||
#include "SkBlurTypes.h"
|
||||
#include "SkShader.h"
|
||||
#include "SkMask.h"
|
||||
#include "SkRRect.h"
|
||||
|
||||
class SkBlurMask {
|
||||
public:
|
||||
enum Style {
|
||||
kNormal_Style, //!< fuzzy inside and outside
|
||||
kSolid_Style, //!< solid inside, fuzzy outside
|
||||
kOuter_Style, //!< nothing inside, fuzzy outside
|
||||
kInner_Style, //!< fuzzy inside, nothing outside
|
||||
|
||||
kStyleCount
|
||||
};
|
||||
|
||||
enum Quality {
|
||||
kLow_Quality, //!< box blur
|
||||
kHigh_Quality //!< three pass box blur (similar to gaussian)
|
||||
};
|
||||
|
||||
static bool BlurRect(SkScalar sigma, SkMask *dst, const SkRect &src,
|
||||
Style style,
|
||||
static bool BlurRect(SkScalar sigma, SkMask *dst, const SkRect &src, SkBlurStyle,
|
||||
SkIPoint *margin = NULL,
|
||||
SkMask::CreateMode createMode =
|
||||
SkMask::kComputeBoundsAndRenderImage_CreateMode);
|
||||
static bool BlurRRect(SkScalar sigma, SkMask *dst, const SkRRect &src,
|
||||
Style style,
|
||||
static bool BlurRRect(SkScalar sigma, SkMask *dst, const SkRRect &src, SkBlurStyle,
|
||||
SkIPoint *margin = NULL,
|
||||
SkMask::CreateMode createMode =
|
||||
SkMask::kComputeBoundsAndRenderImage_CreateMode);
|
||||
@ -48,13 +31,12 @@ public:
|
||||
// rectangle will lie.
|
||||
|
||||
static bool BoxBlur(SkMask* dst, const SkMask& src,
|
||||
SkScalar sigma, Style style, Quality quality,
|
||||
SkScalar sigma, SkBlurStyle style, SkBlurQuality quality,
|
||||
SkIPoint* margin = NULL, bool forceQuality = false);
|
||||
|
||||
// the "ground truth" blur does a gaussian convolution; it's slow
|
||||
// but useful for comparison purposes.
|
||||
static bool BlurGroundTruth(SkScalar sigma, SkMask* dst, const SkMask& src,
|
||||
Style style,
|
||||
static bool BlurGroundTruth(SkScalar sigma, SkMask* dst, const SkMask& src, SkBlurStyle,
|
||||
SkIPoint* margin = NULL);
|
||||
|
||||
static SkScalar ConvertRadiusToSigma(SkScalar radius);
|
||||
|
@ -30,7 +30,7 @@
|
||||
|
||||
class SkBlurMaskFilterImpl : public SkMaskFilter {
|
||||
public:
|
||||
SkBlurMaskFilterImpl(SkScalar sigma, SkBlurMaskFilter::BlurStyle, uint32_t flags);
|
||||
SkBlurMaskFilterImpl(SkScalar sigma, SkBlurStyle, uint32_t flags);
|
||||
|
||||
// overrides from SkMaskFilter
|
||||
virtual SkMask::Format getFormat() const SK_OVERRIDE;
|
||||
@ -83,9 +83,9 @@ private:
|
||||
// a request like 10,000)
|
||||
static const SkScalar kMAX_BLUR_SIGMA;
|
||||
|
||||
SkScalar fSigma;
|
||||
SkBlurMaskFilter::BlurStyle fBlurStyle;
|
||||
uint32_t fBlurFlags;
|
||||
SkScalar fSigma;
|
||||
SkBlurStyle fBlurStyle;
|
||||
uint32_t fBlurFlags;
|
||||
|
||||
SkBlurMaskFilterImpl(SkReadBuffer&);
|
||||
virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
|
||||
@ -102,50 +102,42 @@ private:
|
||||
|
||||
const SkScalar SkBlurMaskFilterImpl::kMAX_BLUR_SIGMA = SkIntToScalar(128);
|
||||
|
||||
SkMaskFilter* SkBlurMaskFilter::Create(SkBlurStyle style, SkScalar sigma, uint32_t flags) {
|
||||
if (!SkScalarIsFinite(sigma) || sigma <= 0) {
|
||||
return NULL;
|
||||
}
|
||||
if ((unsigned)style > (unsigned)kLastEnum_SkBlurStyle) {
|
||||
return NULL;
|
||||
}
|
||||
if (flags > SkBlurMaskFilter::kAll_BlurFlag) {
|
||||
return NULL;
|
||||
}
|
||||
return SkNEW_ARGS(SkBlurMaskFilterImpl, (sigma, style, flags));
|
||||
}
|
||||
|
||||
#ifdef SK_SUPPORT_LEGACY_BLURMASKFILTER_STYLE
|
||||
SkMaskFilter* SkBlurMaskFilter::Create(SkScalar radius,
|
||||
SkBlurMaskFilter::BlurStyle style,
|
||||
uint32_t flags) {
|
||||
// use !(radius > 0) instead of radius <= 0 to reject NaN values
|
||||
if (!(radius > 0) || (unsigned)style >= SkBlurMaskFilter::kBlurStyleCount
|
||||
|| flags > SkBlurMaskFilter::kAll_BlurFlag) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
SkScalar sigma = SkBlurMask::ConvertRadiusToSigma(radius);
|
||||
|
||||
return SkNEW_ARGS(SkBlurMaskFilterImpl, (sigma, style, flags));
|
||||
return Create((SkBlurStyle)style, sigma, flags);
|
||||
}
|
||||
|
||||
SkMaskFilter* SkBlurMaskFilter::Create(SkBlurMaskFilter::BlurStyle style,
|
||||
SkScalar sigma,
|
||||
uint32_t flags) {
|
||||
// use !(sigma > 0) instead of sigma <= 0 to reject NaN values
|
||||
if (!(sigma > 0) || (unsigned)style >= SkBlurMaskFilter::kBlurStyleCount
|
||||
|| flags > SkBlurMaskFilter::kAll_BlurFlag) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return SkNEW_ARGS(SkBlurMaskFilterImpl, (sigma, style, flags));
|
||||
return Create((SkBlurStyle)style, sigma, flags);
|
||||
}
|
||||
#endif
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
SkBlurMaskFilterImpl::SkBlurMaskFilterImpl(SkScalar sigma,
|
||||
SkBlurMaskFilter::BlurStyle style,
|
||||
uint32_t flags)
|
||||
: fSigma(sigma), fBlurStyle(style), fBlurFlags(flags) {
|
||||
#if 0
|
||||
fGamma = NULL;
|
||||
if (gammaScale) {
|
||||
fGamma = new U8[256];
|
||||
if (gammaScale > 0)
|
||||
SkBlurMask::BuildSqrGamma(fGamma, gammaScale);
|
||||
else
|
||||
SkBlurMask::BuildSqrtGamma(fGamma, -gammaScale);
|
||||
}
|
||||
#endif
|
||||
SkASSERT(fSigma >= 0);
|
||||
SkASSERT((unsigned)style < SkBlurMaskFilter::kBlurStyleCount);
|
||||
SkBlurMaskFilterImpl::SkBlurMaskFilterImpl(SkScalar sigma, SkBlurStyle style, uint32_t flags)
|
||||
: fSigma(sigma)
|
||||
, fBlurStyle(style)
|
||||
, fBlurFlags(flags) {
|
||||
SkASSERT(fSigma > 0);
|
||||
SkASSERT((unsigned)style <= kLastEnum_SkBlurStyle);
|
||||
SkASSERT(flags <= SkBlurMaskFilter::kAll_BlurFlag);
|
||||
}
|
||||
|
||||
@ -158,12 +150,11 @@ bool SkBlurMaskFilterImpl::filterMask(SkMask* dst, const SkMask& src,
|
||||
SkIPoint* margin) const{
|
||||
SkScalar sigma = this->computeXformedSigma(matrix);
|
||||
|
||||
SkBlurMask::Quality blurQuality =
|
||||
SkBlurQuality blurQuality =
|
||||
(fBlurFlags & SkBlurMaskFilter::kHighQuality_BlurFlag) ?
|
||||
SkBlurMask::kHigh_Quality : SkBlurMask::kLow_Quality;
|
||||
kHigh_SkBlurQuality : kLow_SkBlurQuality;
|
||||
|
||||
return SkBlurMask::BoxBlur(dst, src, sigma, (SkBlurMask::Style)fBlurStyle,
|
||||
blurQuality, margin);
|
||||
return SkBlurMask::BoxBlur(dst, src, sigma, fBlurStyle, blurQuality, margin);
|
||||
}
|
||||
|
||||
bool SkBlurMaskFilterImpl::filterRectMask(SkMask* dst, const SkRect& r,
|
||||
@ -171,7 +162,7 @@ bool SkBlurMaskFilterImpl::filterRectMask(SkMask* dst, const SkRect& r,
|
||||
SkIPoint* margin, SkMask::CreateMode createMode) const{
|
||||
SkScalar sigma = computeXformedSigma(matrix);
|
||||
|
||||
return SkBlurMask::BlurRect(sigma, dst, r, (SkBlurMask::Style)fBlurStyle,
|
||||
return SkBlurMask::BlurRect(sigma, dst, r, fBlurStyle,
|
||||
margin, createMode);
|
||||
}
|
||||
|
||||
@ -180,7 +171,7 @@ bool SkBlurMaskFilterImpl::filterRRectMask(SkMask* dst, const SkRRect& r,
|
||||
SkIPoint* margin, SkMask::CreateMode createMode) const{
|
||||
SkScalar sigma = computeXformedSigma(matrix);
|
||||
|
||||
return SkBlurMask::BlurRRect(sigma, dst, r, (SkBlurMask::Style)fBlurStyle,
|
||||
return SkBlurMask::BlurRRect(sigma, dst, r, fBlurStyle,
|
||||
margin, createMode);
|
||||
}
|
||||
|
||||
@ -298,7 +289,7 @@ SkBlurMaskFilterImpl::filterRRectToNine(const SkRRect& rrect, const SkMatrix& ma
|
||||
|
||||
// TODO: report correct metrics for innerstyle, where we do not grow the
|
||||
// total bounds, but we do need an inset the size of our blur-radius
|
||||
if (SkBlurMaskFilter::kInner_BlurStyle == fBlurStyle) {
|
||||
if (kInner_SkBlurStyle == fBlurStyle) {
|
||||
return kUnimplemented_FilterReturn;
|
||||
}
|
||||
|
||||
@ -410,8 +401,7 @@ SkBlurMaskFilterImpl::filterRectsToNine(const SkRect rects[], int count,
|
||||
|
||||
// TODO: report correct metrics for innerstyle, where we do not grow the
|
||||
// total bounds, but we do need an inset the size of our blur-radius
|
||||
if (SkBlurMaskFilter::kInner_BlurStyle == fBlurStyle ||
|
||||
SkBlurMaskFilter::kOuter_BlurStyle == fBlurStyle) {
|
||||
if (kInner_SkBlurStyle == fBlurStyle || kOuter_SkBlurStyle == fBlurStyle) {
|
||||
return kUnimplemented_FilterReturn;
|
||||
}
|
||||
|
||||
@ -531,10 +521,10 @@ void SkBlurMaskFilterImpl::computeFastBounds(const SkRect& src,
|
||||
SkBlurMaskFilterImpl::SkBlurMaskFilterImpl(SkReadBuffer& buffer)
|
||||
: SkMaskFilter(buffer) {
|
||||
fSigma = buffer.readScalar();
|
||||
fBlurStyle = (SkBlurMaskFilter::BlurStyle)buffer.readInt();
|
||||
fBlurStyle = (SkBlurStyle)buffer.readInt();
|
||||
fBlurFlags = buffer.readUInt() & SkBlurMaskFilter::kAll_BlurFlag;
|
||||
SkASSERT(fSigma >= 0);
|
||||
SkASSERT((unsigned)fBlurStyle < SkBlurMaskFilter::kBlurStyleCount);
|
||||
SkASSERT(fSigma > 0);
|
||||
SkASSERT((unsigned)fBlurStyle <= kLastEnum_SkBlurStyle);
|
||||
}
|
||||
|
||||
void SkBlurMaskFilterImpl::flatten(SkWriteBuffer& buffer) const {
|
||||
@ -785,7 +775,7 @@ bool SkBlurMaskFilterImpl::directFilterMaskGPU(GrContext* context,
|
||||
GrPaint* grp,
|
||||
const SkStrokeRec& strokeRec,
|
||||
const SkPath& path) const {
|
||||
if (fBlurStyle != SkBlurMaskFilter::kNormal_BlurStyle) {
|
||||
if (fBlurStyle != kNormal_SkBlurStyle) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -888,7 +878,8 @@ GrEffectRef* GrRRectBlurEffect::Create(GrContext* context, float sigma, const Sk
|
||||
texDesc.fHeight = texSide;
|
||||
texDesc.fConfig = kAlpha_8_GrPixelConfig;
|
||||
|
||||
GrTexture *blurNinePatchTexture = context->findAndRefTexture(texDesc, blurRRectNinePatchID, ¶ms);
|
||||
GrTexture *blurNinePatchTexture = context->findAndRefTexture(texDesc, blurRRectNinePatchID,
|
||||
¶ms);
|
||||
|
||||
if (NULL == blurNinePatchTexture) {
|
||||
SkMask mask;
|
||||
@ -910,12 +901,15 @@ GrEffectRef* GrRRectBlurEffect::Create(GrContext* context, float sigma, const Sk
|
||||
SkPath path;
|
||||
path.addRRect( smallRRect );
|
||||
|
||||
SkDraw::DrawToMask(path, &mask.fBounds, NULL, NULL, &mask, SkMask::kJustRenderImage_CreateMode, SkPaint::kFill_Style);
|
||||
SkDraw::DrawToMask(path, &mask.fBounds, NULL, NULL, &mask,
|
||||
SkMask::kJustRenderImage_CreateMode, SkPaint::kFill_Style);
|
||||
|
||||
SkMask blurred_mask;
|
||||
SkBlurMask::BoxBlur(&blurred_mask, mask, sigma, SkBlurMask::kNormal_Style, SkBlurMask::kHigh_Quality, NULL, true );
|
||||
SkBlurMask::BoxBlur(&blurred_mask, mask, sigma, kNormal_SkBlurStyle,
|
||||
kHigh_SkBlurQuality, NULL, true );
|
||||
|
||||
blurNinePatchTexture = context->createTexture(¶ms, texDesc, blurRRectNinePatchID, blurred_mask.fImage, 0);
|
||||
blurNinePatchTexture = context->createTexture(¶ms, texDesc, blurRRectNinePatchID,
|
||||
blurred_mask.fImage, 0);
|
||||
}
|
||||
|
||||
if (NULL == blurNinePatchTexture) {
|
||||
@ -935,9 +929,10 @@ const GrBackendEffectFactory& GrRRectBlurEffect::getFactory() const {
|
||||
}
|
||||
|
||||
GrRRectBlurEffect::GrRRectBlurEffect(float sigma, const SkRRect& rrect, GrTexture *ninePatchTexture)
|
||||
: fRRect(rrect),
|
||||
fSigma(sigma),
|
||||
fNinePatchAccess(ninePatchTexture) {
|
||||
: fRRect(rrect)
|
||||
, fSigma(sigma)
|
||||
, fNinePatchAccess(ninePatchTexture)
|
||||
{
|
||||
this->addTextureAccess(&fNinePatchAccess);
|
||||
this->setWillReadFragmentPosition();
|
||||
}
|
||||
@ -1070,7 +1065,7 @@ bool SkBlurMaskFilterImpl::directFilterRRectMaskGPU(GrContext* context,
|
||||
GrPaint* grp,
|
||||
const SkStrokeRec& strokeRec,
|
||||
const SkRRect& rrect) const {
|
||||
if (fBlurStyle != SkBlurMaskFilter::kNormal_BlurStyle) {
|
||||
if (fBlurStyle != kNormal_SkBlurStyle) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -1154,7 +1149,7 @@ bool SkBlurMaskFilterImpl::filterMaskGPU(GrTexture* src,
|
||||
|
||||
// If we're doing a normal blur, we can clobber the pathTexture in the
|
||||
// gaussianBlur. Otherwise, we need to save it for later compositing.
|
||||
bool isNormalBlur = (SkBlurMaskFilter::kNormal_BlurStyle == fBlurStyle);
|
||||
bool isNormalBlur = (kNormal_SkBlurStyle == fBlurStyle);
|
||||
*result = SkGpuBlurUtils::GaussianBlur(context, src, isNormalBlur && canOverwriteSrc,
|
||||
clipRect, false, xformedSigma, xformedSigma);
|
||||
if (NULL == *result) {
|
||||
@ -1169,14 +1164,14 @@ bool SkBlurMaskFilterImpl::filterMaskGPU(GrTexture* src,
|
||||
// Blend pathTexture over blurTexture.
|
||||
GrContext::AutoRenderTarget art(context, (*result)->asRenderTarget());
|
||||
paint.addColorEffect(GrSimpleTextureEffect::Create(src, matrix))->unref();
|
||||
if (SkBlurMaskFilter::kInner_BlurStyle == fBlurStyle) {
|
||||
if (kInner_SkBlurStyle == fBlurStyle) {
|
||||
// inner: dst = dst * src
|
||||
paint.setBlendFunc(kDC_GrBlendCoeff, kZero_GrBlendCoeff);
|
||||
} else if (SkBlurMaskFilter::kSolid_BlurStyle == fBlurStyle) {
|
||||
} else if (kSolid_SkBlurStyle == fBlurStyle) {
|
||||
// solid: dst = src + dst - src * dst
|
||||
// = (1 - dst) * src + 1 * dst
|
||||
paint.setBlendFunc(kIDC_GrBlendCoeff, kOne_GrBlendCoeff);
|
||||
} else if (SkBlurMaskFilter::kOuter_BlurStyle == fBlurStyle) {
|
||||
} else if (kOuter_SkBlurStyle == fBlurStyle) {
|
||||
// outer: dst = dst * (1 - src)
|
||||
// = 0 * src + (1 - src) * dst
|
||||
paint.setBlendFunc(kZero_GrBlendCoeff, kISC_GrBlendCoeff);
|
||||
@ -1198,7 +1193,7 @@ void SkBlurMaskFilterImpl::toString(SkString* str) const {
|
||||
str->appendScalar(fSigma);
|
||||
str->append(" ");
|
||||
|
||||
static const char* gStyleName[SkBlurMaskFilter::kBlurStyleCount] = {
|
||||
static const char* gStyleName[kLastEnum_SkBlurStyle + 1] = {
|
||||
"normal", "solid", "outer", "inner"
|
||||
};
|
||||
|
||||
|
@ -76,8 +76,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, SkBlurMask::kInner_Style,
|
||||
SkBlurMask::kLow_Quality)) {
|
||||
if (!SkBlurMask::BoxBlur(dst, src, sigma, kInner_SkBlurStyle, kLow_SkBlurQuality)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -103,9 +103,8 @@ static void test_blur_drawing(skiatest::Reporter* reporter) {
|
||||
paint.setStrokeWidth(SkIntToScalar(strokeWidth));
|
||||
|
||||
SkScalar sigma = SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(5));
|
||||
for (int style = 0; style < SkBlurMaskFilter::kBlurStyleCount; ++style) {
|
||||
SkBlurMaskFilter::BlurStyle blurStyle =
|
||||
static_cast<SkBlurMaskFilter::BlurStyle>(style);
|
||||
for (int style = 0; style <= kLastEnum_SkBlurStyle; ++style) {
|
||||
SkBlurStyle blurStyle = static_cast<SkBlurStyle>(style);
|
||||
|
||||
const uint32_t flagPermutations = SkBlurMaskFilter::kAll_BlurFlag;
|
||||
for (uint32_t flags = 0; flags < flagPermutations; ++flags) {
|
||||
@ -169,7 +168,7 @@ static void ground_truth_2d(int width, int height,
|
||||
memset(src.fImage, 0xff, src.computeTotalImageSize());
|
||||
|
||||
dst.fImage = NULL;
|
||||
SkBlurMask::BlurGroundTruth(sigma, &dst, src, SkBlurMask::kNormal_Style);
|
||||
SkBlurMask::BlurGroundTruth(sigma, &dst, src, kNormal_SkBlurStyle);
|
||||
|
||||
int midX = dst.fBounds.centerX();
|
||||
int midY = dst.fBounds.centerY();
|
||||
@ -231,7 +230,7 @@ static void blur_path(SkCanvas* canvas, const SkPath& path,
|
||||
|
||||
SkPaint blurPaint;
|
||||
blurPaint.setColor(SK_ColorWHITE);
|
||||
SkMaskFilter* filter = SkBlurMaskFilter::Create(SkBlurMaskFilter::kNormal_BlurStyle,
|
||||
SkMaskFilter* filter = SkBlurMaskFilter::Create(kNormal_SkBlurStyle,
|
||||
gaussianSigma,
|
||||
SkBlurMaskFilter::kHighQuality_BlurFlag);
|
||||
blurPaint.setMaskFilter(filter)->unref();
|
||||
|
@ -150,7 +150,7 @@ DEF_TEST(Paint_copy, reporter) {
|
||||
SkLayerDrawLooper::Builder looperBuilder;
|
||||
SkLayerDrawLooper* looper = looperBuilder.detachLooper();
|
||||
paint.setLooper(looper)->unref();
|
||||
SkMaskFilter* mask = SkBlurMaskFilter::Create(SkBlurMaskFilter::kNormal_BlurStyle,
|
||||
SkMaskFilter* mask = SkBlurMaskFilter::Create(kNormal_SkBlurStyle,
|
||||
SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(1)));
|
||||
paint.setMaskFilter(mask)->unref();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user