Push sigma-based blur interface into our GMs/benches/tests/samplecode

https://codereview.chromium.org/23701006/



git-svn-id: http://skia.googlecode.com/svn/trunk@11129 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
robertphillips@google.com 2013-09-06 14:16:12 +00:00
parent b27eba7c28
commit b7061176c7
34 changed files with 298 additions and 222 deletions

View File

@ -6,6 +6,7 @@
* found in the LICENSE file.
*/
#include "SkBenchmark.h"
#include "SkBlurMask.h"
#include "SkCanvas.h"
#include "SkPaint.h"
#include "SkRandom.h"
@ -32,12 +33,14 @@ class BlurBench : public SkBenchmark {
SkString fName;
public:
BlurBench(void* param, SkScalar rad, SkBlurMaskFilter::BlurStyle bs, uint32_t flags = 0) : INHERITED(param) {
BlurBench(void* param, SkScalar rad, SkBlurMaskFilter::BlurStyle bs, uint32_t flags = 0)
: INHERITED(param) {
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 = flags & SkBlurMaskFilter::kHighQuality_BlurFlag ? "high_quality"
: "low_quality";
if (SkScalarFraction(rad) != 0) {
fName.printf("blur_%.2f_%s_%s", SkScalarToFloat(rad), name, quality);
} else {
@ -63,7 +66,9 @@ protected:
r.offset(fRadius, fRadius);
if (fRadius > 0) {
SkMaskFilter* mf = SkBlurMaskFilter::Create(fRadius, fStyle, fFlags);
SkMaskFilter* mf = SkBlurMaskFilter::Create(fStyle,
SkBlurMask::ConvertRadiusToSigma(fRadius),
fFlags);
paint.setMaskFilter(mf)->unref();
}
canvas->drawOval(r, paint);

View File

@ -15,7 +15,9 @@
#define SMALL SkIntToScalar(2)
#define REAL SkFloatToScalar(1.5f)
static const SkScalar kMedium = SkIntToScalar(5);
#define BIG SkIntToScalar(10)
static const SkScalar kMedBig = SkIntToScalar(20);
#define REALBIG SkFloatToScalar(30.5f)
class BlurRectBench: public SkBenchmark {
@ -83,12 +85,13 @@ class BlurRectDirectBench: public BlurRectBench {
name.printf("blurrect_direct_%d", SkScalarRoundToInt(rad));
}
setName(name);
this->setName(name);
}
protected:
virtual void makeBlurryRect(const SkRect& r) SK_OVERRIDE {
SkMask mask;
SkBlurMask::BlurRect(&mask, r, this->radius(), SkBlurMask::kNormal_Style);
SkBlurMask::BlurRect(SkBlurMask::ConvertRadiusToSigma(this->radius()),
&mask, r, SkBlurMask::kNormal_Style);
SkMask::FreeImage(mask.fImage);
}
private:
@ -127,12 +130,14 @@ class BlurRectBoxFilterBench: public BlurRectSeparableBench {
public:
BlurRectBoxFilterBench(void *param, SkScalar rad) : INHERITED(param, rad) {
SkString name;
if (SkScalarFraction(rad) != 0) {
name.printf("blurrect_boxfilter_%.2f", SkScalarToFloat(rad));
} else {
name.printf("blurrect_boxfilter_%d", SkScalarRoundToInt(rad));
}
setName(name);
this->setName(name);
}
protected:
@ -140,9 +145,9 @@ protected:
virtual void makeBlurryRect(const SkRect&) SK_OVERRIDE {
SkMask mask;
mask.fImage = NULL;
SkBlurMask::Blur(&mask, fSrcMask, this->radius(),
SkBlurMask::kNormal_Style,
SkBlurMask::kHigh_Quality);
SkBlurMask::BoxBlur(&mask, fSrcMask, SkBlurMask::ConvertRadiusToSigma(this->radius()),
SkBlurMask::kNormal_Style,
SkBlurMask::kHigh_Quality);
SkMask::FreeImage(mask.fImage);
}
private:
@ -153,12 +158,14 @@ class BlurRectGaussianBench: public BlurRectSeparableBench {
public:
BlurRectGaussianBench(void *param, SkScalar rad) : INHERITED(param, rad) {
SkString name;
if (SkScalarFraction(rad) != 0) {
name.printf("blurrect_gaussian_%.2f", SkScalarToFloat(rad));
} else {
name.printf("blurrect_gaussian_%d", SkScalarRoundToInt(rad));
}
setName(name);
this->setName(name);
}
protected:
@ -166,8 +173,8 @@ protected:
virtual void makeBlurryRect(const SkRect&) SK_OVERRIDE {
SkMask mask;
mask.fImage = NULL;
SkBlurMask::BlurGroundTruth(&mask, fSrcMask, this->radius(),
SkBlurMask::kNormal_Style);
SkBlurMask::BlurGroundTruth(SkBlurMask::ConvertRadiusToSigma(this->radius()),
&mask, fSrcMask, SkBlurMask::kNormal_Style);
SkMask::FreeImage(mask.fImage);
}
private:
@ -187,11 +194,11 @@ DEF_BENCH(return new BlurRectDirectBench(p, BIG);)
DEF_BENCH(return new BlurRectDirectBench(p, REALBIG);)
DEF_BENCH(return new BlurRectDirectBench(p, REAL);)
DEF_BENCH(return new BlurRectDirectBench(p, SkIntToScalar(5));)
DEF_BENCH(return new BlurRectDirectBench(p, SkIntToScalar(20));)
DEF_BENCH(return new BlurRectDirectBench(p, kMedium);)
DEF_BENCH(return new BlurRectDirectBench(p, kMedBig);)
DEF_BENCH(return new BlurRectBoxFilterBench(p, SkIntToScalar(5));)
DEF_BENCH(return new BlurRectBoxFilterBench(p, SkIntToScalar(20));)
DEF_BENCH(return new BlurRectBoxFilterBench(p, kMedium);)
DEF_BENCH(return new BlurRectBoxFilterBench(p, kMedBig);)
#if 0
// disable Gaussian benchmarks; the algorithm works well enough

View File

@ -28,8 +28,8 @@ protected:
SkMWCRandom Random;
for (int i = 0; i < N; i++) {
SkScalar blurRad = Random.nextRangeScalar(1.5f, 25.0f);
SkScalar size = Random.nextRangeScalar(20*blurRad, 50*blurRad);
SkScalar blurSigma = Random.nextRangeScalar(1.5f, 25.0f);
SkScalar size = Random.nextRangeScalar(20*blurSigma, 50*blurSigma);
SkScalar x = Random.nextRangeScalar(0.0f, W - size);
SkScalar y = Random.nextRangeScalar(0.0f, H - size);
@ -38,7 +38,7 @@ protected:
SkRect outer(inner);
// outer is always outset either 2x or 4x the blur radius (we go with 2x)
outer.outset(2*blurRad, 2*blurRad);
outer.outset(2*blurSigma, 2*blurSigma);
SkPath p;
@ -51,7 +51,7 @@ protected:
SkScalar translate = 2.0f * size;
SkPaint paint;
paint.setLooper(this->createLooper(-translate, blurRad))->unref();
paint.setLooper(this->createLooper(-translate, blurSigma))->unref();
paint.setColor(0xff000000 | Random.nextU());
paint.setAntiAlias(true);
@ -72,7 +72,7 @@ private:
enum { N = SkBENCHLOOP(100) };
SkLayerDrawLooper* createLooper(SkScalar xOff, SkScalar radius) {
SkLayerDrawLooper* createLooper(SkScalar xOff, SkScalar sigma) {
SkLayerDrawLooper* looper = new SkLayerDrawLooper;
//-----------------------------------------------
@ -88,8 +88,8 @@ private:
SkPaint* paint = looper->addLayer(info);
SkMaskFilter* mf = SkBlurMaskFilter::Create(radius,
SkBlurMaskFilter::kNormal_BlurStyle,
SkMaskFilter* mf = SkBlurMaskFilter::Create(SkBlurMaskFilter::kNormal_BlurStyle,
sigma,
SkBlurMaskFilter::kHighQuality_BlurFlag);
paint->setMaskFilter(mf)->unref();

View File

@ -7,6 +7,7 @@
*/
#include "gm.h"
#include "SkBitmap.h"
#include "SkBlurMask.h"
#include "SkBlurMaskFilter.h"
#include "SkCanvas.h"
#include "SkColor.h"
@ -83,8 +84,8 @@ protected:
paint.setFilterBitmap(true);
SkMaskFilter* mf = SkBlurMaskFilter::Create(
5,
SkBlurMaskFilter::kNormal_BlurStyle,
SkBlurMask::ConvertRadiusToSigma(5),
SkBlurMaskFilter::kHighQuality_BlurFlag |
SkBlurMaskFilter::kIgnoreTransform_BlurFlag);
paint.setMaskFilter(mf)->unref();

View File

@ -6,8 +6,9 @@
*/
#include "gm.h"
#include "SkCanvas.h"
#include "SkBlurMask.h"
#include "SkBlurMaskFilter.h"
#include "SkCanvas.h"
#if SK_SUPPORT_GPU
#include "GrContext.h"
@ -146,8 +147,8 @@ protected:
SkPaint paint;
paint.setFilterBitmap(filter);
SkMaskFilter* mf = SkBlurMaskFilter::Create(SkIntToScalar(3),
SkBlurMaskFilter::kNormal_BlurStyle);
SkMaskFilter* mf = SkBlurMaskFilter::Create(SkBlurMaskFilter::kNormal_BlurStyle,
SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(3)));
paint.setMaskFilter(mf)->unref();
canvas->save();

View File

@ -6,8 +6,9 @@
*/
#include "gm.h"
#include "SkCanvas.h"
#include "SkBlurMask.h"
#include "SkBlurMaskFilter.h"
#include "SkCanvas.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
@ -55,8 +56,8 @@ protected:
SkPaint blurPaint;
blurPaint.setFilterBitmap(true);
SkMaskFilter* mf = SkBlurMaskFilter::Create(kBlurRadius,
SkBlurMaskFilter::kNormal_BlurStyle);
SkMaskFilter* mf = SkBlurMaskFilter::Create(SkBlurMaskFilter::kNormal_BlurStyle,
SkBlurMask::ConvertRadiusToSigma(kBlurRadius));
blurPaint.setMaskFilter(mf)->unref();
canvas->clear(SK_ColorBLACK);

View File

@ -6,8 +6,8 @@
*/
#include "gm.h"
#include "SkBlurMaskFilter.h"
#include "SkBlurMask.h"
#include "SkBlurMaskFilter.h"
#include "SkCanvas.h"
#include "SkPath.h"
@ -72,7 +72,8 @@ class BlurRectGM : public skiagm::GM {
public:
BlurRectGM(const char name[], PaintProc pproc, U8CPU alpha,
SkBlurMaskFilter::BlurStyle bs)
: fMaskFilter(SkBlurMaskFilter::Create(STROKE_WIDTH/2, bs,
: fMaskFilter(SkBlurMaskFilter::Create(bs,
SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(STROKE_WIDTH/2)),
SkBlurMaskFilter::kHighQuality_BlurFlag))
, fName(name)
, fPProc(pproc)
@ -140,14 +141,15 @@ class BlurRectCompareGM : public skiagm::GM {
SkScalar fRadius;
SkBlurMask::Style fStyle;
public:
BlurRectCompareGM(const char name[], unsigned int rectWidth, unsigned int rectHeight, float radius, SkBlurMask::Style style)
BlurRectCompareGM(const char name[], unsigned int rectWidth,
unsigned int rectHeight, float radius,
SkBlurMask::Style style)
: fName(name)
, fRectWidth(rectWidth)
, fRectHeight(rectHeight)
, fRadius(radius)
, fStyle(style)
{}
, fStyle(style) {
}
int width() const {
return fRectWidth;
}
@ -216,7 +218,8 @@ public:
protected:
virtual bool makeMask(SkMask *m, const SkRect& r) SK_OVERRIDE {
return SkBlurMask::BlurRect(m, r, this->radius(), this->style());
return SkBlurMask::BlurRect(SkBlurMask::ConvertRadiusToSigma(this->radius()),
m, r, this->style());
}
private:
typedef BlurRectCompareGM INHERITED;
@ -224,12 +227,11 @@ private:
class BlurRectSlowGM: public BlurRectCompareGM {
public:
BlurRectSlowGM(const char name[], unsigned int rect_width, unsigned int rect_height,
float blur_radius, SkBlurMask::Style style) :
INHERITED(name, rect_width, rect_height, blur_radius, style)
{
BlurRectSlowGM(const char name[], unsigned int rectWidth, unsigned int rectHeight,
float blurRadius, SkBlurMask::Style style)
: INHERITED(name, rectWidth, rectHeight, blurRadius, style) {
}
protected:
virtual bool makeMask(SkMask *m, const SkRect& r) SK_OVERRIDE {
SkMask src;
@ -242,7 +244,9 @@ protected:
memset(src.fImage, 0xff, src.computeTotalImageSize());
return SkBlurMask::Blur(m, src, this->radius(), this->style(), this->getQuality());
return SkBlurMask::BoxBlur(m, src,
SkBlurMask::ConvertRadiusToSigma(this->radius()),
this->style(), this->getQuality());
}
virtual SkBlurMask::Quality getQuality() {
@ -255,11 +259,10 @@ private:
class BlurRectSlowLowGM: public BlurRectSlowGM {
public:
BlurRectSlowLowGM(const char name[], unsigned int rectWidth, unsigned int rectHeight,
float blurRadius, SkBlurMask::Style style) :
INHERITED(name, rectWidth, rectHeight, blurRadius, style)
{
float blurRadius, SkBlurMask::Style style)
: INHERITED(name, rectWidth, rectHeight, blurRadius, style) {
}
protected:
virtual SkBlurMask::Quality getQuality() SK_OVERRIDE {
return SkBlurMask::kLow_Quality;
@ -271,11 +274,10 @@ private:
class BlurRectGroundTruthGM: public BlurRectCompareGM {
public:
BlurRectGroundTruthGM(const char name[], unsigned int rectWidth, unsigned int rectHeight,
float blurRadius, SkBlurMask::Style style) :
INHERITED(name, rectWidth, rectHeight, blurRadius, style)
{
float blurRadius, SkBlurMask::Style style)
: INHERITED(name, rectWidth, rectHeight, blurRadius, style) {
}
protected:
virtual bool makeMask(SkMask *m, const SkRect& r) SK_OVERRIDE {
SkMask src;
@ -288,7 +290,8 @@ protected:
memset(src.fImage, 0xff, src.computeTotalImageSize());
return SkBlurMask::BlurGroundTruth(m, src, this->radius(), this->style());
return SkBlurMask::BlurGroundTruth(SkBlurMask::ConvertRadiusToSigma(this->radius()),
m, src, this->style());
}
virtual SkBlurMask::Quality getQuality() {
@ -306,50 +309,53 @@ DEF_GM(return new BlurRectGM("blurrect", NULL, 0xFF, SkBlurMaskFilter::kSolid_Bl
DEF_GM(return new BlurRectGM("blurrect", NULL, 0xFF, SkBlurMaskFilter::kOuter_BlurStyle);)
DEF_GM(return new BlurRectGM("blurrect", NULL, 0xFF, SkBlurMaskFilter::kInner_BlurStyle);)
static const SkScalar kBig = SkFloatToScalar(20);
static const SkScalar kSmall = SkFloatToScalar(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, 2, SkBlurMask::kNormal_Style);)
DEF_GM(return new BlurRectFastGM("blurrect_25_100_20_normal_fast", 25, 100, 20, SkBlurMask::kNormal_Style);)
DEF_GM(return new BlurRectSlowGM( "blurrect_25_100_2_normal_slow", 25, 100, 2, SkBlurMask::kNormal_Style);)
DEF_GM(return new BlurRectSlowGM("blurrect_25_100_20_normal_slow", 25, 100, 20, SkBlurMask::kNormal_Style);)
DEF_GM(return new BlurRectFastGM( "blurrect_25_100_2_inner_fast", 25, 100, 2, SkBlurMask::kInner_Style);)
DEF_GM(return new BlurRectFastGM("blurrect_25_100_20_inner_fast", 25, 100, 20, SkBlurMask::kInner_Style);)
DEF_GM(return new BlurRectSlowGM( "blurrect_25_100_2_inner_slow", 25, 100, 2, SkBlurMask::kInner_Style);)
DEF_GM(return new BlurRectSlowGM("blurrect_25_100_20_inner_slow", 25, 100, 20, SkBlurMask::kInner_Style);)
DEF_GM(return new BlurRectFastGM( "blurrect_25_100_2_outer_fast", 25, 100, 2, SkBlurMask::kOuter_Style);)
DEF_GM(return new BlurRectFastGM("blurrect_25_100_20_outer_fast", 25, 100, 20, SkBlurMask::kOuter_Style);)
DEF_GM(return new BlurRectSlowGM( "blurrect_25_100_2_outer_slow", 25, 100, 2, SkBlurMask::kOuter_Style);)
DEF_GM(return new BlurRectSlowGM("blurrect_25_100_20_outer_slow", 25, 100, 20, SkBlurMask::kOuter_Style);)
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);)
// skinny tall rects, blurs overlap in X but not y
DEF_GM(return new BlurRectFastGM( "blurrect_5_100_2_normal_fast", 5, 100, 2 , SkBlurMask::kNormal_Style);)
DEF_GM(return new BlurRectFastGM("blurrect_5_100_20_normal_fast", 5, 100, 20, SkBlurMask::kNormal_Style);)
DEF_GM(return new BlurRectSlowGM( "blurrect_5_100_2_normal_slow", 5, 100, 2 , SkBlurMask::kNormal_Style);)
DEF_GM(return new BlurRectSlowGM("blurrect_5_100_20_normal_slow", 5, 100, 20, SkBlurMask::kNormal_Style);)
DEF_GM(return new BlurRectFastGM( "blurrect_5_100_2_inner_fast", 5, 100, 2 , SkBlurMask::kInner_Style);)
DEF_GM(return new BlurRectFastGM("blurrect_5_100_20_inner_fast", 5, 100, 20, SkBlurMask::kInner_Style);)
DEF_GM(return new BlurRectSlowGM( "blurrect_5_100_2_inner_slow", 5, 100, 2 , SkBlurMask::kInner_Style);)
DEF_GM(return new BlurRectSlowGM("blurrect_5_100_20_inner_slow", 5, 100, 20, SkBlurMask::kInner_Style);)
DEF_GM(return new BlurRectFastGM( "blurrect_5_100_2_outer_fast", 5, 100, 2 , SkBlurMask::kOuter_Style);)
DEF_GM(return new BlurRectFastGM("blurrect_5_100_20_outer_fast", 5, 100, 20, SkBlurMask::kOuter_Style);)
DEF_GM(return new BlurRectSlowGM( "blurrect_5_100_2_outer_slow", 5, 100, 2 , SkBlurMask::kOuter_Style);)
DEF_GM(return new BlurRectSlowGM("blurrect_5_100_20_outer_slow", 5, 100, 20, SkBlurMask::kOuter_Style);)
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);)
// tiny rects, blurs overlap in X and Y
DEF_GM(return new BlurRectFastGM( "blurrect_5_5_2_normal_fast", 5, 5, 2 , SkBlurMask::kNormal_Style);)
DEF_GM(return new BlurRectFastGM("blurrect_5_5_20_normal_fast", 5, 5, 20, SkBlurMask::kNormal_Style);)
DEF_GM(return new BlurRectSlowGM( "blurrect_5_5_2_normal_slow", 5, 5, 2 , SkBlurMask::kNormal_Style);)
DEF_GM(return new BlurRectSlowGM("blurrect_5_5_20_normal_slow", 5, 5, 20, SkBlurMask::kNormal_Style);)
DEF_GM(return new BlurRectFastGM( "blurrect_5_5_2_inner_fast", 5, 5, 2 , SkBlurMask::kInner_Style);)
DEF_GM(return new BlurRectFastGM("blurrect_5_5_20_inner_fast", 5, 5, 20, SkBlurMask::kInner_Style);)
DEF_GM(return new BlurRectSlowGM( "blurrect_5_5_2_inner_slow", 5, 5, 2 , SkBlurMask::kInner_Style);)
DEF_GM(return new BlurRectSlowGM("blurrect_5_5_20_inner_slow", 5, 5, 20, SkBlurMask::kInner_Style);)
DEF_GM(return new BlurRectFastGM( "blurrect_5_5_2_outer_fast", 5, 5, 2 , SkBlurMask::kOuter_Style);)
DEF_GM(return new BlurRectFastGM("blurrect_5_5_20_outer_fast", 5, 5, 20, SkBlurMask::kOuter_Style);)
DEF_GM(return new BlurRectSlowGM( "blurrect_5_5_2_outer_slow", 5, 5, 2 , SkBlurMask::kOuter_Style);)
DEF_GM(return new BlurRectSlowGM("blurrect_5_5_20_outer_slow", 5, 5, 20, SkBlurMask::kOuter_Style);)
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);)
#if 0

View File

@ -6,6 +6,7 @@
* found in the LICENSE file.
*/
#include "gm.h"
#include "SkBlurMask.h"
#include "SkBlurMaskFilter.h"
namespace skiagm {
@ -59,8 +60,9 @@ protected:
paint.setColor(SK_ColorBLUE);
for (size_t i = 0; i < SK_ARRAY_COUNT(gRecs); i++) {
if (gRecs[i].fStyle != NONE) {
SkMaskFilter* mf = SkBlurMaskFilter::Create(
SkIntToScalar(20), gRecs[i].fStyle, flags);
SkMaskFilter* mf = SkBlurMaskFilter::Create(gRecs[i].fStyle,
SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(20)),
flags);
paint.setMaskFilter(mf)->unref();
} else {
paint.setMaskFilter(NULL);
@ -72,10 +74,9 @@ protected:
}
// draw text
{
SkMaskFilter* mf = SkBlurMaskFilter::Create(
SkIntToScalar(4),
SkBlurMaskFilter::kNormal_BlurStyle,
flags);
SkMaskFilter* mf = SkBlurMaskFilter::Create(SkBlurMaskFilter::kNormal_BlurStyle,
SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(4)),
flags);
paint.setMaskFilter(mf)->unref();
SkScalar x = SkIntToScalar(70);
SkScalar y = SkIntToScalar(400);

View File

@ -6,12 +6,13 @@
* found in the LICENSE file.
*/
#include "gm.h"
#include "SkTArray.h"
#include "SkRandom.h"
#include "SkMatrix.h"
#include "SkBlurDrawLooper.h"
#include "SkBlurMask.h"
#include "SkBlurMaskFilter.h"
#include "SkGradientShader.h"
#include "SkBlurDrawLooper.h"
#include "SkMatrix.h"
#include "SkRandom.h"
#include "SkTArray.h"
namespace skiagm {
@ -50,8 +51,9 @@ protected:
// AA with mask filter
SkPaint p;
p.setAntiAlias(true);
SkMaskFilter* mf = SkBlurMaskFilter::Create(SkIntToScalar(5),
SkMaskFilter* mf = SkBlurMaskFilter::Create(
SkBlurMaskFilter::kNormal_BlurStyle,
SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(5)),
SkBlurMaskFilter::kHighQuality_BlurFlag);
p.setMaskFilter(mf)->unref();
fPaints.push_back(p);
@ -79,8 +81,9 @@ protected:
SkPaint p;
p.setAntiAlias(true);
SkBlurDrawLooper* shadowLooper =
new SkBlurDrawLooper (SkIntToScalar(10), SkIntToScalar(5),
SkIntToScalar(10), 0xFF0000FF,
new SkBlurDrawLooper (SK_ColorBLUE,
SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(10)),
SkIntToScalar(5), SkIntToScalar(10),
SkBlurDrawLooper::kIgnoreTransform_BlurFlag |
SkBlurDrawLooper::kOverrideColor_BlurFlag |
SkBlurDrawLooper::kHighQuality_BlurFlag);

View File

@ -6,13 +6,11 @@
* found in the LICENSE file.
*/
#include "gm.h"
#include "SkShader.h"
#include "SkColorPriv.h"
#include "SkBlurMask.h"
#include "SkBlurMaskFilter.h"
// effects
#include "SkColorPriv.h"
#include "SkGradientShader.h"
#include "SkShader.h"
namespace skiagm {
@ -169,8 +167,8 @@ protected:
srcRect.setXYWH(1, 1, 3, 3);
SkMaskFilter* mf = SkBlurMaskFilter::Create(
5,
SkBlurMaskFilter::kNormal_BlurStyle,
SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(5)),
SkBlurMaskFilter::kHighQuality_BlurFlag |
SkBlurMaskFilter::kIgnoreTransform_BlurFlag);
paint.setMaskFilter(mf)->unref();

View File

@ -6,11 +6,12 @@
*/
#include "gm.h"
#include "SkBlurMask.h"
#include "SkBlurMaskFilter.h"
#include "SkCanvas.h"
#include "SkGraphics.h"
#include "SkRandom.h"
#include "SkLayerDrawLooper.h"
#include "SkBlurMaskFilter.h"
#include "SkRandom.h"
#define WIDTH 200
#define HEIGHT 200
@ -62,12 +63,12 @@ private:
SkPaint::Style fStyle;
SkScalar fWidth;
SkScalar fOffset;
int fBlur;
SkScalar fBlur;
} gParams[] = {
{ SK_ColorWHITE, SkPaint::kStroke_Style, SkIntToScalar(1)*3/4, 0, 0 },
{ SK_ColorRED, SkPaint::kStroke_Style, SkIntToScalar(4), 0, 0 },
{ SK_ColorBLUE, SkPaint::kFill_Style, 0, 0, 0 },
{ 0x88000000, SkPaint::kFill_Style, 0, SkIntToScalar(10), 3 }
{ 0x88000000, SkPaint::kFill_Style, 0, SkIntToScalar(10), SkIntToScalar(3) }
};
fLooper = new SkLayerDrawLooper;
@ -85,8 +86,8 @@ private:
paint->setStyle(gParams[i].fStyle);
paint->setStrokeWidth(gParams[i].fWidth);
if (gParams[i].fBlur > 0) {
SkMaskFilter* mf = SkBlurMaskFilter::Create(SkIntToScalar(gParams[i].fBlur),
SkBlurMaskFilter::kNormal_BlurStyle);
SkMaskFilter* mf = SkBlurMaskFilter::Create(SkBlurMaskFilter::kNormal_BlurStyle,
SkBlurMask::ConvertRadiusToSigma(gParams[i].fBlur));
paint->setMaskFilter(mf)->unref();
}
}

View File

@ -6,10 +6,11 @@
*/
#include "gm.h"
#include "SkCanvas.h"
#include "SkBlurMask.h"
#include "SkBlurMaskFilter.h"
#include "SkLayerDrawLooper.h"
#include "SkCanvas.h"
#include "SkColorFilter.h"
#include "SkLayerDrawLooper.h"
// This GM tests 3 different ways of drawing four shadows around a square:
// just using 4 blurred rects
@ -110,10 +111,10 @@ private:
}
SkMaskFilter* createBlur() {
static const SkScalar kBlurRadius = 25.0f;
static const SkScalar kBlurSigma = SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(25));
return SkBlurMaskFilter::Create(kBlurRadius,
SkBlurMaskFilter::kNormal_BlurStyle,
return SkBlurMaskFilter::Create(SkBlurMaskFilter::kNormal_BlurStyle,
kBlurSigma,
SkBlurMaskFilter::kHighQuality_BlurFlag);
}

View File

@ -6,11 +6,12 @@
*/
#include "gm.h"
#include "SkTArray.h"
#include "SkMatrix.h"
#include "SkBlurDrawLooper.h"
#include "SkBlurMask.h"
#include "SkBlurMaskFilter.h"
#include "SkGradientShader.h"
#include "SkBlurDrawLooper.h"
#include "SkMatrix.h"
#include "SkTArray.h"
namespace skiagm {
@ -53,8 +54,9 @@ protected:
SkPaint p;
p.setColor(SK_ColorWHITE);
p.setAntiAlias(true);
SkMaskFilter* mf = SkBlurMaskFilter::Create(SkIntToScalar(5),
SkMaskFilter* mf = SkBlurMaskFilter::Create(
SkBlurMaskFilter::kNormal_BlurStyle,
SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(5)),
SkBlurMaskFilter::kHighQuality_BlurFlag);
p.setMaskFilter(mf)->unref();
fPaints.push_back(p);
@ -84,8 +86,9 @@ protected:
p.setColor(SK_ColorWHITE);
p.setAntiAlias(true);
SkBlurDrawLooper* shadowLooper =
new SkBlurDrawLooper (SkIntToScalar(10), SkIntToScalar(5),
SkIntToScalar(10), SK_ColorWHITE,
new SkBlurDrawLooper (SK_ColorWHITE,
SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(10)),
SkIntToScalar(5), SkIntToScalar(10),
SkBlurDrawLooper::kIgnoreTransform_BlurFlag |
SkBlurDrawLooper::kOverrideColor_BlurFlag |
SkBlurDrawLooper::kHighQuality_BlurFlag);

View File

@ -6,6 +6,7 @@
* found in the LICENSE file.
*/
#include "gm.h"
#include "SkBlurMask.h"
#include "SkBlurDrawLooper.h"
namespace skiagm {
@ -46,34 +47,39 @@ protected:
virtual void onDraw(SkCanvas* canvas) {
SkBlurDrawLooper* shadowLoopers[5];
shadowLoopers[0] =
new SkBlurDrawLooper (SkIntToScalar(10), SkIntToScalar(5),
SkIntToScalar(10), 0xFF0000FF,
new SkBlurDrawLooper (SK_ColorBLUE,
SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(10)),
SkIntToScalar(5), SkIntToScalar(10),
SkBlurDrawLooper::kIgnoreTransform_BlurFlag |
SkBlurDrawLooper::kOverrideColor_BlurFlag |
SkBlurDrawLooper::kHighQuality_BlurFlag);
SkAutoUnref aurL0(shadowLoopers[0]);
shadowLoopers[1] =
new SkBlurDrawLooper (SkIntToScalar(10), SkIntToScalar(5),
SkIntToScalar(10), 0xFF0000FF,
new SkBlurDrawLooper (SK_ColorBLUE,
SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(10)),
SkIntToScalar(5), SkIntToScalar(10),
SkBlurDrawLooper::kIgnoreTransform_BlurFlag |
SkBlurDrawLooper::kOverrideColor_BlurFlag);
SkAutoUnref aurL1(shadowLoopers[1]);
shadowLoopers[2] =
new SkBlurDrawLooper (SkIntToScalar(5), SkIntToScalar(5),
SkIntToScalar(10), 0xFF000000,
new SkBlurDrawLooper (SK_ColorBLACK,
SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(5)),
SkIntToScalar(5),
SkIntToScalar(10),
SkBlurDrawLooper::kIgnoreTransform_BlurFlag |
SkBlurDrawLooper::kHighQuality_BlurFlag);
SkAutoUnref aurL2(shadowLoopers[2]);
shadowLoopers[3] =
new SkBlurDrawLooper (SkIntToScalar(5), SkIntToScalar(-5),
SkIntToScalar(-10), 0x7FFF0000,
new SkBlurDrawLooper (0x7FFF0000,
SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(5)),
SkIntToScalar(-5), SkIntToScalar(-10),
SkBlurDrawLooper::kIgnoreTransform_BlurFlag |
SkBlurDrawLooper::kOverrideColor_BlurFlag |
SkBlurDrawLooper::kHighQuality_BlurFlag);
SkAutoUnref aurL3(shadowLoopers[3]);
shadowLoopers[4] =
new SkBlurDrawLooper (SkIntToScalar(0), SkIntToScalar(5),
SkIntToScalar(5), 0xFF000000,
new SkBlurDrawLooper (SK_ColorBLACK, SkIntToScalar(0),
SkIntToScalar(5), SkIntToScalar(5),
SkBlurDrawLooper::kIgnoreTransform_BlurFlag |
SkBlurDrawLooper::kOverrideColor_BlurFlag |
SkBlurDrawLooper::kHighQuality_BlurFlag);

View File

@ -6,13 +6,14 @@
*/
#include "gm.h"
#include "SkBlurMask.h"
#include "SkBlurMaskFilter.h"
#include "SkFlattenableBuffers.h"
#include "SkLayerRasterizer.h"
#include "SkBlurMaskFilter.h"
static void r0(SkLayerRasterizer* rast, SkPaint& p) {
p.setMaskFilter(SkBlurMaskFilter::Create(SkIntToScalar(3),
SkBlurMaskFilter::kNormal_BlurStyle))->unref();
p.setMaskFilter(SkBlurMaskFilter::Create(SkBlurMaskFilter::kNormal_BlurStyle,
SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(3))))->unref();
rast->addLayer(p, SkIntToScalar(3), SkIntToScalar(3));
p.setMaskFilter(NULL);

View File

@ -6,6 +6,7 @@
* found in the LICENSE file.
*/
#include "SampleCode.h"
#include "SkBlurMask.h"
#include "SkCanvas.h"
#include "SkView.h"
#include "Sk1DPathEffect.h"
@ -79,8 +80,8 @@ private:
///////////////////////////////////////////////////////////
static void r0(SkLayerRasterizer* rast, SkPaint& p) {
p.setMaskFilter(SkBlurMaskFilter::Create(SkIntToScalar(3),
SkBlurMaskFilter::kNormal_BlurStyle,
p.setMaskFilter(SkBlurMaskFilter::Create(SkBlurMaskFilter::kNormal_BlurStyle,
SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(3)),
SkBlurMaskFilter::kNone_BlurFlag))->unref();
rast->addLayer(p, SkIntToScalar(3), SkIntToScalar(3));
@ -255,10 +256,9 @@ static void apply_shader(SkPaint* paint, int index) {
#if 1
SkScalar dir[] = { SK_Scalar1, SK_Scalar1, SK_Scalar1 };
paint->setMaskFilter(SkBlurMaskFilter::CreateEmboss(dir,
SK_Scalar1/4,
SkIntToScalar(4),
SkIntToScalar(3)))->unref();
paint->setMaskFilter(SkBlurMaskFilter::CreateEmboss(
SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(3)), dir,
SK_Scalar1/4, SkIntToScalar(4)))->unref();
paint->setColor(SK_ColorBLUE);
#endif
}
@ -386,8 +386,8 @@ protected:
light.fDirection[2] = SK_Scalar1/3;
light.fAmbient = 0x48;
light.fSpecular = 0x80;
SkScalar radius = SkIntToScalar(12)/5;
SkEmbossMaskFilter* embossFilter = new SkEmbossMaskFilter(light, radius);
SkScalar sigma = SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(12)/5);
SkEmbossMaskFilter* embossFilter = new SkEmbossMaskFilter(sigma, light);
SkXfermode* xfermode = SkXfermode::Create(SkXfermode::kXor_Mode);
SkColorFilter* lightingFilter = SkColorFilter::CreateLightingFilter(

View File

@ -28,9 +28,9 @@ protected:
virtual void onDrawContent(SkCanvas* canvas) {
SkScalar blurRadius = SampleCode::GetAnimSinScalar(100 * SK_Scalar1,
4 * SK_Scalar1,
5 * SK_Scalar1);
SkScalar blurSigma = SampleCode::GetAnimSinScalar(100 * SK_Scalar1,
4 * SK_Scalar1,
5 * SK_Scalar1);
SkScalar circleRadius = 3 * SK_Scalar1 +
SampleCode::GetAnimSinScalar(150 * SK_Scalar1,
@ -46,8 +46,9 @@ protected:
SkRandom random;
for (size_t i = 0; i < SK_ARRAY_COUNT(gStyles); ++i) {
SkMaskFilter* mf = SkBlurMaskFilter::Create(blurRadius,
SkMaskFilter* mf = SkBlurMaskFilter::Create(
gStyles[i],
blurSigma,
SkBlurMaskFilter::kHighQuality_BlurFlag);
SkPaint paint;
SkSafeUnref(paint.setMaskFilter(mf));

View File

@ -6,9 +6,10 @@
* found in the LICENSE file.
*/
#include "SampleCode.h"
#include "SkBlurMask.h"
#include "SkBlurMaskFilter.h"
#include "SkView.h"
#include "SkCanvas.h"
#include "SkView.h"
class BigBlurView : public SampleView {
public:
@ -30,8 +31,8 @@ protected:
canvas->save();
paint.setColor(SK_ColorBLUE);
SkMaskFilter* mf = SkBlurMaskFilter::Create(
128,
SkBlurMaskFilter::kNormal_BlurStyle,
SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(128)),
SkBlurMaskFilter::kHighQuality_BlurFlag);
paint.setMaskFilter(mf)->unref();
canvas->translate(200, 200);

View File

@ -6,12 +6,13 @@
* found in the LICENSE file.
*/
#include "SampleCode.h"
#include "SkBlurMask.h"
#include "SkBlurMaskFilter.h"
#include "SkCanvas.h"
#include "SkColorPriv.h"
#include "SkGradientShader.h"
#include "SkView.h"
#include "SkCanvas.h"
#include "SkUtils.h"
#include "SkView.h"
static SkBitmap make_bitmap() {
SkBitmap bm;
@ -97,9 +98,9 @@ protected:
paint.setColor(SK_ColorBLUE);
for (size_t i = 0; i < SK_ARRAY_COUNT(gRecs); i++) {
if (gRecs[i].fStyle != NONE) {
SkMaskFilter* mf = SkBlurMaskFilter::Create(20,
gRecs[i].fStyle,
flags);
SkMaskFilter* mf = SkBlurMaskFilter::Create(gRecs[i].fStyle,
SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(20)),
flags);
paint.setMaskFilter(mf)->unref();
} else {
paint.setMaskFilter(NULL);
@ -109,9 +110,9 @@ protected:
}
// draw text
{
SkMaskFilter* mf = SkBlurMaskFilter::Create(4,
SkBlurMaskFilter::kNormal_BlurStyle,
flags);
SkMaskFilter* mf = SkBlurMaskFilter::Create(SkBlurMaskFilter::kNormal_BlurStyle,
SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(4)),
flags);
paint.setMaskFilter(mf)->unref();
SkScalar x = SkIntToScalar(70);
SkScalar y = SkIntToScalar(400);

View File

@ -6,14 +6,15 @@
* found in the LICENSE file.
*/
#include "SampleCode.h"
#include "SkCanvas.h"
#include "SkPaint.h"
#include "SkView.h"
#include "SkBlurMask.h"
#include "SkBlurMaskFilter.h"
#include "SkCanvas.h"
#include "SkColorMatrixFilter.h"
#include "SkDiscretePathEffect.h"
#include "SkGradientShader.h"
#include "SkPaint.h"
#include "SkView.h"
//#define COLOR 0xFFFF8844
#define COLOR 0xFF888888
@ -22,14 +23,18 @@ static void paint_proc0(SkPaint*) {
}
static void paint_proc1(SkPaint* paint) {
paint->setMaskFilter(SkBlurMaskFilter::Create(2,
SkBlurMaskFilter::kNormal_BlurStyle))->unref();
paint->setMaskFilter(SkBlurMaskFilter::Create(
SkBlurMaskFilter::kNormal_BlurStyle,
SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(2))))->unref();
}
static void paint_proc2(SkPaint* paint) {
SkScalar dir[3] = { 1, 1, 1};
paint->setMaskFilter(
SkBlurMaskFilter::CreateEmboss(dir, 0.1f, 0.05f, 1))->unref();
SkBlurMaskFilter::CreateEmboss(SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(1)),
dir,
SkFloatToScalar(0.1f),
SkFloatToScalar(0.05f)))->unref();
}
static void paint_proc3(SkPaint* paint) {

View File

@ -6,6 +6,7 @@
* found in the LICENSE file.
*/
#include "SampleCode.h"
#include "SkBlurMask.h"
#include "SkView.h"
#include "SkCanvas.h"
#include "Sk64.h"
@ -53,7 +54,8 @@ protected:
paint.setAntiAlias(true);
paint.setStyle(SkPaint::kStroke_Style);
paint.setStrokeWidth(SkIntToScalar(10));
paint.setMaskFilter(new SkEmbossMaskFilter(fLight, SkIntToScalar(4)))->unref();
paint.setMaskFilter(new SkEmbossMaskFilter(
SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(4)), fLight))->unref();
paint.setShader(new SkColorShader(SK_ColorBLUE))->unref();
paint.setDither(true);

View File

@ -59,21 +59,35 @@ static float make_number() {
float v = 0;
int sel;
if (return_large == true && R(3) == 1) sel = R(6); else sel = R(4);
if (return_undef == false && sel == 0) sel = 1;
if (R(2) == 1) v = (float)R(100); else
switch (sel) {
case 0: break;
case 1: v = 0; break;
case 2: v = 0.000001f; break;
case 3: v = 10000; break;
case 4: v = 2000000000; break;
case 5: v = huge(); break;
if (return_large == true && R(3) == 1) {
sel = R(6);
} else {
sel = R(4);
}
if (return_undef == false && sel == 0) {
sel = 1;
}
if (R(2) == 1) {
v = (float)R(100);
} else {
switch (sel) {
case 0: break;
case 1: v = 0; break;
case 2: v = 0.000001f; break;
case 3: v = 10000; break;
case 4: v = 2000000000; break;
case 5: v = huge(); break;
}
}
if (R(4) == 1) {
v = -v;
}
if (R(4) == 1) v = -v;
return v;
}
@ -176,7 +190,9 @@ static void do_fuzz(SkCanvas* canvas) {
case 7:
if (quick == true) break;
SkSafeUnref(paint.setMaskFilter(SkBlurMaskFilter::Create(make_number(), SkBlurMaskFilter::kNormal_BlurStyle)));
SkSafeUnref(paint.setMaskFilter(SkBlurMaskFilter::Create(
SkBlurMaskFilter::kNormal_BlurStyle,
make_number())));
break;
case 8:

View File

@ -6,11 +6,15 @@
* found in the LICENSE file.
*/
#include "SampleCode.h"
#include "SkView.h"
#include "SkBlurMask.h"
#include "SkBlurMaskFilter.h"
#include "SkCanvas.h"
#include "SkDevice.h"
#include "SkFlattenableBuffers.h"
#include "SkGradientShader.h"
#include "SkLayerRasterizer.h"
#include "SkPaint.h"
#include "SkView.h"
#define BG_COLOR 0xFFDDDDDD
@ -471,14 +475,10 @@ static void mesh_slide(SkCanvas* canvas) {
///////////////////////////////////////////////////////////////////////////////
#include "SkGradientShader.h"
#include "SkLayerRasterizer.h"
#include "SkBlurMaskFilter.h"
static void r0(SkLayerRasterizer* rast, SkPaint& p)
{
p.setMaskFilter(SkBlurMaskFilter::Create(SkIntToScalar(3),
SkBlurMaskFilter::kNormal_BlurStyle))->unref();
p.setMaskFilter(SkBlurMaskFilter::Create(SkBlurMaskFilter::kNormal_BlurStyle,
SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(3))))->unref();
rast->addLayer(p, SkIntToScalar(3), SkIntToScalar(3));
p.setMaskFilter(NULL);

View File

@ -6,13 +6,14 @@
* found in the LICENSE file.
*/
#include "SampleCode.h"
#include "SkBlurMask.h"
#include "SkBlurMaskFilter.h"
#include "SkCanvas.h"
#include "SkParsePath.h"
#include "SkPath.h"
#include "SkRandom.h"
#include "SkView.h"
#include "SkBlurMaskFilter.h"
static void test_huge_stroke(SkCanvas* canvas) {
SkRect srcR = { 0, 0, 72000, 54000 };
@ -41,7 +42,6 @@ static void test_huge_stroke(SkCanvas* canvas) {
}
#if 0
#include "SkBlurMask.h"
static void test_blur() {
uint8_t cell[9];
memset(cell, 0xFF, sizeof(cell));
@ -168,14 +168,14 @@ protected:
};
for (int x = 0; x < 5; x++) {
SkMaskFilter* mf;
SkScalar radius = 4;
SkScalar sigma = SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(4));
for (int y = 0; y < 10; y++) {
if (x) {
mf = SkBlurMaskFilter::Create(radius, gStyle[x - 1]);
mf = SkBlurMaskFilter::Create(gStyle[x - 1], sigma);
paint.setMaskFilter(mf)->unref();
}
canvas->drawText("Title Bar", 9, x*SkIntToScalar(100), y*SkIntToScalar(30), paint);
radius *= 0.75f;
sigma *= 0.75f;
}
}

View File

@ -6,7 +6,7 @@
* found in the LICENSE file.
*/
#include "SampleCode.h"
#include "SkView.h"
#include "SkBlurMask.h"
#include "SkBlurMaskFilter.h"
#include "SkCanvas.h"
#include "SkDevice.h"
@ -23,6 +23,7 @@
#include "SkColorFilter.h"
#include "SkTime.h"
#include "SkTypeface.h"
#include "SkView.h"
#include "SkOSFile.h"
#include "SkStream.h"
@ -69,8 +70,8 @@ protected:
paint.setARGB(fByte, 0xFF, 0xFF, 0xFF);
paint.setMaskFilter(SkBlurMaskFilter::Create(SkIntToScalar(3),
SkBlurMaskFilter::kNormal_BlurStyle));
paint.setMaskFilter(SkBlurMaskFilter::Create(SkBlurMaskFilter::kNormal_BlurStyle,
SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(3))));
paint.getMaskFilter()->unref();
SkRandom rand;

View File

@ -6,6 +6,7 @@
* found in the LICENSE file.
*/
#include "SampleCode.h"
#include "SkBlurMask.h"
#include "SkBlurDrawLooper.h"
#include "SkCanvas.h"
#include "SkPath.h"
@ -34,10 +35,10 @@ static void textStrokePath(SkCanvas* canvas) {
canvas->drawPath(path, paint);
paint.setLooper(new SkBlurDrawLooper(SkFloatToScalar(0.002f),
SkFloatToScalar(0.0f),
SkFloatToScalar(0.0f),
(SkColor)0xFF000000))->unref();
paint.setLooper(new SkBlurDrawLooper(SK_ColorBLACK,
SkBlurMask::ConvertRadiusToSigma(SkFloatToScalar(0.002f)),
SkFloatToScalar(0.0f),
SkFloatToScalar(0.0f)))->unref();
const char* text = "DRAWING STROKED TEXT WITH A BLUR ON A PATH";
size_t len = strlen(text);

View File

@ -6,9 +6,10 @@
* found in the LICENSE file.
*/
#include "SampleCode.h"
#include "SkBlurMask.h"
#include "SkBlurMaskFilter.h"
#include "SkCanvas.h"
#include "SkDevice.h"
#include "SkBlurMaskFilter.h"
namespace {
SkBitmap make_bitmap() {
@ -80,8 +81,8 @@ protected:
srcRect.setXYWH(1, 1, 3, 3);
dstRect.setXYWH(5.0f, 405.0f, 305.0f, 305.0f);
SkMaskFilter* mf = SkBlurMaskFilter::Create(
5,
SkBlurMaskFilter::kNormal_BlurStyle,
SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(5)),
SkBlurMaskFilter::kHighQuality_BlurFlag |
SkBlurMaskFilter::kIgnoreTransform_BlurFlag);
paint.setMaskFilter(mf)->unref();
@ -93,8 +94,8 @@ protected:
// that handles blurs with rects transformed to non-
// orthogonal rects. It also tests the NULL src rect handling
mf = SkBlurMaskFilter::Create(
5,
SkBlurMaskFilter::kNormal_BlurStyle,
SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(5)),
SkBlurMaskFilter::kHighQuality_BlurFlag);
paint.setMaskFilter(mf)->unref();

View File

@ -21,6 +21,7 @@
// effects
#include "SkGradientShader.h"
#include "SkUnitMappers.h"
#include "SkBlurMask.h"
#include "SkBlurDrawLooper.h"
static void makebm(SkBitmap* bm, SkBitmap::Config config, int w, int h) {
@ -66,8 +67,9 @@ class TilingView : public SampleView {
SkBlurDrawLooper fLooper;
public:
TilingView()
: fLooper(SkIntToScalar(1), SkIntToScalar(2), SkIntToScalar(2),
0x88000000) {
: fLooper(0x88000000,
SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(1)),
SkIntToScalar(2), SkIntToScalar(2)) {
fTextPicture = new SkPicture();
for (size_t i = 0; i < SK_ARRAY_COUNT(gConfigs); i++) {
makebm(&fTexture[i], gConfigs[i], gWidth, gHeight);

View File

@ -6,6 +6,7 @@
*/
#include "gm.h"
#include "SampleCode.h"
#include "SkBlurMask.h"
#include "SkBlurDrawLooper.h"
#include "SkCanvas.h"
#include "SkColorPriv.h"
@ -85,7 +86,9 @@ protected:
paint.setAntiAlias(true);
paint.setTextSize(SkIntToScalar(24));
SkAutoTUnref<SkBlurDrawLooper> looper(SkNEW_ARGS(SkBlurDrawLooper,
(SkIntToScalar(2), 0, 0, SK_ColorBLUE)));
(SK_ColorBLUE,
SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(2)),
0, 0)));
paint.setLooper(looper);
SkScalar height = paint.getFontMetrics(NULL);
if (!fDecodeSucceeded) {

View File

@ -7,6 +7,7 @@
*/
#include "SampleCode.h"
#include "SkView.h"
#include "SkBlurMask.h"
#include "SkCanvas.h"
#include "Sk64.h"
#include "SkCornerPathEffect.h"
@ -46,8 +47,9 @@ class XfermodesBlurView : public SampleView {
void draw_mode(SkCanvas* canvas, SkXfermode* mode, int alpha,
SkScalar x, SkScalar y) {
SkPaint p;
SkMaskFilter* mf = SkBlurMaskFilter::Create(5, SkBlurMaskFilter::kNormal_BlurStyle,
SkBlurMaskFilter::kNone_BlurFlag);
SkMaskFilter* mf = SkBlurMaskFilter::Create(SkBlurMaskFilter::kNormal_BlurStyle,
SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(5)),
SkBlurMaskFilter::kNone_BlurFlag);
p.setMaskFilter(mf)->unref();
SkScalar ww = SkIntToScalar(W);

View File

@ -12,20 +12,21 @@
#if SK_USE_CONDENSED_INFO == 0
const SkMemberInfo SkDrawBlur::fInfo[] = {
SK_MEMBER(blurStyle, MaskFilterBlurStyle),
SK_MEMBER(radius, Float)
SK_MEMBER(fBlurStyle, MaskFilterBlurStyle),
SK_MEMBER(fSigma, Float)
};
#endif
DEFINE_GET_MEMBER(SkDrawBlur);
SkDrawBlur::SkDrawBlur() : radius(-1),
blurStyle(SkBlurMaskFilter::kNormal_BlurStyle) {
SkDrawBlur::SkDrawBlur()
: fSigma(-1)
, fBlurStyle(SkBlurMaskFilter::kNormal_BlurStyle) {
}
SkMaskFilter* SkDrawBlur::getMaskFilter() {
if (radius < 0)
if (fSigma < 0)
return NULL;
return SkBlurMaskFilter::Create(radius, (SkBlurMaskFilter::BlurStyle) blurStyle);
return SkBlurMaskFilter::Create((SkBlurMaskFilter::BlurStyle) fBlurStyle, fSigma);
}

View File

@ -16,10 +16,12 @@
class SkDrawBlur : public SkDrawMaskFilter {
DECLARE_DRAW_MEMBER_INFO(Blur);
SkDrawBlur();
virtual SkMaskFilter* getMaskFilter();
virtual SkMaskFilter* getMaskFilter() SK_OVERRIDE;
protected:
SkScalar radius;
int /*SkBlurMaskFilter::BlurStyle*/ blurStyle;
SkScalar fSigma;
int /*SkBlurMaskFilter::BlurStyle*/ fBlurStyle;
typedef SkDrawMaskFilter INHERITED;
};
#endif // SkDrawBlur_DEFINED

View File

@ -102,7 +102,7 @@ static void test_blur_drawing(skiatest::Reporter* reporter) {
paint.setStyle(SkPaint::kStroke_Style);
paint.setStrokeWidth(SkIntToScalar(strokeWidth));
SkScalar radius = SkIntToScalar(5);
SkScalar sigma = SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(5));
for (int style = 0; style < SkBlurMaskFilter::kBlurStyleCount; ++style) {
SkBlurMaskFilter::BlurStyle blurStyle =
static_cast<SkBlurMaskFilter::BlurStyle>(style);
@ -110,7 +110,7 @@ static void test_blur_drawing(skiatest::Reporter* reporter) {
const uint32_t flagPermutations = SkBlurMaskFilter::kAll_BlurFlag;
for (uint32_t flags = 0; flags < flagPermutations; ++flags) {
SkMaskFilter* filter;
filter = SkBlurMaskFilter::Create(radius, blurStyle, flags);
filter = SkBlurMaskFilter::Create(blurStyle, sigma, flags);
paint.setMaskFilter(filter);
filter->unref();

View File

@ -6,10 +6,11 @@
*/
#include "Test.h"
#include "SkBlurMask.h"
#include "SkBlurMaskFilter.h"
#include "SkLayerDrawLooper.h"
#include "SkPath.h"
#include "SkPaint.h"
#include "SkLayerDrawLooper.h"
#include "SkBlurMaskFilter.h"
#include "SkRandom.h"
#include "SkTypeface.h"
#include "SkUtils.h"
@ -142,7 +143,8 @@ static void test_copy(skiatest::Reporter* reporter) {
// set a few pointers
SkLayerDrawLooper* looper = new SkLayerDrawLooper();
paint.setLooper(looper)->unref();
SkMaskFilter* mask = SkBlurMaskFilter::Create(1, SkBlurMaskFilter::kNormal_BlurStyle);
SkMaskFilter* mask = SkBlurMaskFilter::Create(SkBlurMaskFilter::kNormal_BlurStyle,
SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(1)));
paint.setMaskFilter(mask)->unref();
// copy the paint using the copy constructor and check they are the same