aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-03-10 10:51:58 +0000
committerGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-03-10 10:51:58 +0000
commitcac5fd597f6e2495f50aaa6bcbe3dadc56f0b977 (patch)
treeaeeee764feb84da585a469d005bfaf0e4a69bc13
parentb471a32460a44043e1f00d28cbefc87579dc30c5 (diff)
Factory methods for heap-allocated SkImageFilter objects.
This is part of an effort to ensure that all SkPaint effects can only be allocated on the heap. This patch makes the constructors of SkImageFilter and its subclasses non-public and instead provides factory methods for creating these objects on the heap. We temporarily keep constructor of publicly visible classes public behind a flag. BUG=skia:2187 R=scroggo@google.com, mtklein@chromium.org, reed@google.com, senorblanco@google.com, senorblanco@chromium.org, bsalomon@google.com, sugoi@chromium.org, zork@chromium.org Author: dominikg@chromium.org Review URL: https://codereview.chromium.org/182983003 git-svn-id: http://skia.googlecode.com/svn/trunk@13718 2bbb7eff-a529-9590-31e7-b0007b416f81
-rw-r--r--bench/BlurImageFilterBench.cpp2
-rw-r--r--bench/DisplacementBench.cpp24
-rw-r--r--bench/MagnifierBench.cpp2
-rw-r--r--bench/MatrixConvolutionBench.cpp2
-rw-r--r--bench/MergeBench.cpp6
-rw-r--r--bench/MorphologyBench.cpp8
-rw-r--r--gm/bitmapsource.cpp8
-rw-r--r--gm/colorfilterimagefilter.cpp2
-rw-r--r--gm/displacement.cpp190
-rw-r--r--gm/dropshadowimagefilter.cpp12
-rw-r--r--gm/imageblur.cpp2
-rw-r--r--gm/imageblurtiled.cpp2
-rw-r--r--gm/imagefiltersbase.cpp18
-rw-r--r--gm/imagefiltersclipped.cpp28
-rw-r--r--gm/imagefilterscropped.cpp14
-rw-r--r--gm/imagefiltersgraph.cpp22
-rw-r--r--gm/imagefiltersscaled.cpp28
-rw-r--r--gm/imagemagnifier.cpp2
-rw-r--r--gm/imageresizetiled.cpp2
-rw-r--r--gm/matrixconvolution.cpp18
-rw-r--r--gm/morphology.cpp4
-rw-r--r--gm/offsetimagefilter.cpp10
-rw-r--r--gm/pictureimagefilter.cpp6
-rw-r--r--gm/resizeimagefilter.cpp6
-rw-r--r--gm/spritebitmap.cpp2
-rw-r--r--gm/testimagefilters.cpp32
-rw-r--r--gm/tileimagefilter.cpp6
-rw-r--r--gm/xfermodeimagefilter.cpp28
-rw-r--r--include/effects/SkBicubicImageFilter.h14
-rw-r--r--include/effects/SkBitmapSource.h15
-rw-r--r--include/effects/SkBlurImageFilter.h19
-rw-r--r--include/effects/SkComposeImageFilter.h10
-rw-r--r--include/effects/SkDisplacementMapEffect.h27
-rw-r--r--include/effects/SkDropShadowImageFilter.h21
-rw-r--r--include/effects/SkMagnifierImageFilter.h9
-rw-r--r--include/effects/SkMatrixConvolutionImageFilter.h77
-rwxr-xr-xinclude/effects/SkMergeImageFilter.h27
-rw-r--r--include/effects/SkMorphologyImageFilter.h37
-rw-r--r--include/effects/SkOffsetImageFilter.h12
-rw-r--r--include/effects/SkPictureImageFilter.h18
-rw-r--r--include/effects/SkResizeImageFilter.h15
-rwxr-xr-xinclude/effects/SkTestImageFilters.h5
-rw-r--r--include/effects/SkTileImageFilter.h14
-rw-r--r--include/effects/SkXfermodeImageFilter.h15
-rw-r--r--samplecode/SampleFilterFuzz.cpp32
-rw-r--r--src/effects/SkDisplacementMapEffect.cpp4
-rw-r--r--src/effects/SkDropShadowImageFilter.cpp2
-rw-r--r--src/effects/SkMagnifierImageFilter.cpp2
-rw-r--r--src/effects/SkMatrixConvolutionImageFilter.cpp56
-rw-r--r--src/effects/SkPictureImageFilter.cpp14
-rw-r--r--tests/GLProgramsTest.cpp3
-rw-r--r--tests/ImageFilterTest.cpp30
-rw-r--r--tests/SerializationTest.cpp9
53 files changed, 572 insertions, 401 deletions
diff --git a/bench/BlurImageFilterBench.cpp b/bench/BlurImageFilterBench.cpp
index 1cc205a70c..bd36b5b3c4 100644
--- a/bench/BlurImageFilterBench.cpp
+++ b/bench/BlurImageFilterBench.cpp
@@ -44,7 +44,7 @@ protected:
virtual void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE {
SkPaint paint;
- paint.setImageFilter(new SkBlurImageFilter(fSigmaX, fSigmaY))->unref();
+ paint.setImageFilter(SkBlurImageFilter::Create(fSigmaX, fSigmaY))->unref();
for (int i = 0; i < loops; i++) {
canvas->drawBitmap(fCheckerboard, 0, 0, &paint);
diff --git a/bench/DisplacementBench.cpp b/bench/DisplacementBench.cpp
index 77ac305852..08da9b19af 100644
--- a/bench/DisplacementBench.cpp
+++ b/bench/DisplacementBench.cpp
@@ -101,11 +101,11 @@ protected:
virtual void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE {
SkPaint paint;
- SkAutoTUnref<SkImageFilter> displ(SkNEW_ARGS(SkBitmapSource, (fCheckerboard)));
+ SkAutoTUnref<SkImageFilter> displ(SkBitmapSource::Create(fCheckerboard));
// No displacement effect
- paint.setImageFilter(SkNEW_ARGS(SkDisplacementMapEffect,
- (SkDisplacementMapEffect::kR_ChannelSelectorType,
- SkDisplacementMapEffect::kG_ChannelSelectorType, 0.0f, displ)))->unref();
+ paint.setImageFilter(SkDisplacementMapEffect::Create(
+ SkDisplacementMapEffect::kR_ChannelSelectorType,
+ SkDisplacementMapEffect::kG_ChannelSelectorType, 0.0f, displ))->unref();
for (int i = 0; i < loops; i++) {
this->drawClippedBitmap(canvas, 0, 0, paint);
@@ -128,11 +128,11 @@ protected:
virtual void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE {
SkPaint paint;
- SkAutoTUnref<SkImageFilter> displ(SkNEW_ARGS(SkBitmapSource, (fCheckerboard)));
+ SkAutoTUnref<SkImageFilter> displ(SkBitmapSource::Create(fCheckerboard));
// Displacement, with 1 alpha component (which isn't pre-multiplied)
- paint.setImageFilter(SkNEW_ARGS(SkDisplacementMapEffect,
- (SkDisplacementMapEffect::kB_ChannelSelectorType,
- SkDisplacementMapEffect::kA_ChannelSelectorType, 16.0f, displ)))->unref();
+ paint.setImageFilter(SkDisplacementMapEffect::Create(
+ SkDisplacementMapEffect::kB_ChannelSelectorType,
+ SkDisplacementMapEffect::kA_ChannelSelectorType, 16.0f, displ))->unref();
for (int i = 0; i < loops; i++) {
drawClippedBitmap(canvas, 100, 0, paint);
}
@@ -154,11 +154,11 @@ protected:
virtual void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE {
SkPaint paint;
- SkAutoTUnref<SkImageFilter> displ(SkNEW_ARGS(SkBitmapSource, (fCheckerboard)));
+ SkAutoTUnref<SkImageFilter> displ(SkBitmapSource::Create(fCheckerboard));
// Displacement, with 2 non-alpha components
- paint.setImageFilter(SkNEW_ARGS(SkDisplacementMapEffect,
- (SkDisplacementMapEffect::kR_ChannelSelectorType,
- SkDisplacementMapEffect::kB_ChannelSelectorType, 32.0f, displ)))->unref();
+ paint.setImageFilter(SkDisplacementMapEffect::Create(
+ SkDisplacementMapEffect::kR_ChannelSelectorType,
+ SkDisplacementMapEffect::kB_ChannelSelectorType, 32.0f, displ))->unref();
for (int i = 0; i < loops; ++i) {
this->drawClippedBitmap(canvas, 200, 0, paint);
}
diff --git a/bench/MagnifierBench.cpp b/bench/MagnifierBench.cpp
index 5c53244275..3ef2062c4e 100644
--- a/bench/MagnifierBench.cpp
+++ b/bench/MagnifierBench.cpp
@@ -38,7 +38,7 @@ protected:
const int h = fIsSmall ? FILTER_HEIGHT_SMALL : FILTER_HEIGHT_LARGE;
SkPaint paint;
paint.setImageFilter(
- new SkMagnifierImageFilter(
+ SkMagnifierImageFilter::Create(
SkRect::MakeXYWH(SkIntToScalar(w / 4),
SkIntToScalar(h / 4),
SkIntToScalar(w / 2),
diff --git a/bench/MatrixConvolutionBench.cpp b/bench/MatrixConvolutionBench.cpp
index 1acc0cb01a..82529737c1 100644
--- a/bench/MatrixConvolutionBench.cpp
+++ b/bench/MatrixConvolutionBench.cpp
@@ -23,7 +23,7 @@ public:
};
SkScalar gain = 0.3f, bias = SkIntToScalar(100);
SkIPoint target = SkIPoint::Make(1, 1);
- fFilter = new SkMatrixConvolutionImageFilter(kernelSize, kernel, gain, bias, target, tileMode, convolveAlpha);
+ fFilter = SkMatrixConvolutionImageFilter::Create(kernelSize, kernel, gain, bias, target, tileMode, convolveAlpha);
}
~MatrixConvolutionBench() {
diff --git a/bench/MergeBench.cpp b/bench/MergeBench.cpp
index 1723cbfc21..cec0ea93e4 100644
--- a/bench/MergeBench.cpp
+++ b/bench/MergeBench.cpp
@@ -44,11 +44,11 @@ protected:
private:
SkImageFilter* mergeBitmaps() {
- SkImageFilter* first = new SkBitmapSource(fCheckerboard);
- SkImageFilter* second = new SkBitmapSource(fBitmap);
+ SkImageFilter* first = SkBitmapSource::Create(fCheckerboard);
+ SkImageFilter* second = SkBitmapSource::Create(fBitmap);
SkAutoUnref aur0(first);
SkAutoUnref aur1(second);
- return new SkMergeImageFilter(first, second);
+ return SkMergeImageFilter::Create(first, second);
}
void make_bitmap() {
diff --git a/bench/MorphologyBench.cpp b/bench/MorphologyBench.cpp
index 0bf689eff6..a32bca620a 100644
--- a/bench/MorphologyBench.cpp
+++ b/bench/MorphologyBench.cpp
@@ -66,12 +66,12 @@ protected:
SkMorphologyImageFilter* mf = NULL;
switch (fStyle) {
case kDilate_MT:
- mf = new SkDilateImageFilter(SkScalarFloorToInt(fRadius),
- SkScalarFloorToInt(fRadius));
+ mf = SkDilateImageFilter::Create(SkScalarFloorToInt(fRadius),
+ SkScalarFloorToInt(fRadius));
break;
case kErode_MT:
- mf = new SkErodeImageFilter(SkScalarFloorToInt(fRadius),
- SkScalarFloorToInt(fRadius));
+ mf = SkErodeImageFilter::Create(SkScalarFloorToInt(fRadius),
+ SkScalarFloorToInt(fRadius));
break;
}
paint.setImageFilter(mf)->unref();
diff --git a/gm/bitmapsource.cpp b/gm/bitmapsource.cpp
index f40cc15e90..9cf5a75cae 100644
--- a/gm/bitmapsource.cpp
+++ b/gm/bitmapsource.cpp
@@ -56,10 +56,10 @@ protected:
SkRect clipRect = SkRect::MakeXYWH(0, 0, 100, 100);
SkRect bounds;
fBitmap.getBounds(&bounds);
- SkAutoTUnref<SkImageFilter> bitmapSource(new SkBitmapSource(fBitmap));
- SkAutoTUnref<SkImageFilter> bitmapSourceSrcRect(new SkBitmapSource(fBitmap, srcRect, srcRect));
- SkAutoTUnref<SkImageFilter> bitmapSourceSrcRectDstRect(new SkBitmapSource(fBitmap, srcRect, dstRect));
- SkAutoTUnref<SkImageFilter> bitmapSourceDstRectOnly(new SkBitmapSource(fBitmap, bounds, dstRect));
+ SkAutoTUnref<SkImageFilter> bitmapSource(SkBitmapSource::Create(fBitmap));
+ SkAutoTUnref<SkImageFilter> bitmapSourceSrcRect(SkBitmapSource::Create(fBitmap, srcRect, srcRect));
+ SkAutoTUnref<SkImageFilter> bitmapSourceSrcRectDstRect(SkBitmapSource::Create(fBitmap, srcRect, dstRect));
+ SkAutoTUnref<SkImageFilter> bitmapSourceDstRectOnly(SkBitmapSource::Create(fBitmap, bounds, dstRect));
// Draw an unscaled bitmap.
fillRectFiltered(canvas, clipRect, bitmapSource);
diff --git a/gm/colorfilterimagefilter.cpp b/gm/colorfilterimagefilter.cpp
index f2f46fd888..b34058f9d7 100644
--- a/gm/colorfilterimagefilter.cpp
+++ b/gm/colorfilterimagefilter.cpp
@@ -19,7 +19,7 @@
#define MARGIN SkIntToScalar(10)
static SkImageFilter* make_blur(float amount, SkImageFilter* input = NULL) {
- return new SkBlurImageFilter(amount, amount, input);
+ return SkBlurImageFilter::Create(amount, amount, input);
}
static SkImageFilter* make_brightness(float amount, SkImageFilter* input = NULL) {
diff --git a/gm/displacement.cpp b/gm/displacement.cpp
index b1f097b8bf..af7c772532 100644
--- a/gm/displacement.cpp
+++ b/gm/displacement.cpp
@@ -83,135 +83,135 @@ protected:
}
canvas->clear(0x00000000);
SkPaint paint;
- SkAutoTUnref<SkImageFilter> displ(SkNEW_ARGS(SkBitmapSource, (fCheckerboard)));
- paint.setImageFilter(SkNEW_ARGS(SkDisplacementMapEffect,
- (SkDisplacementMapEffect::kR_ChannelSelectorType,
- SkDisplacementMapEffect::kG_ChannelSelectorType, 0.0f, displ)))->unref();
+ SkAutoTUnref<SkImageFilter> displ(SkBitmapSource::Create(fCheckerboard));
+ paint.setImageFilter(SkDisplacementMapEffect::Create(
+ SkDisplacementMapEffect::kR_ChannelSelectorType,
+ SkDisplacementMapEffect::kG_ChannelSelectorType, 0.0f, displ))->unref();
drawClippedBitmap(canvas, 0, 0, paint);
- paint.setImageFilter(SkNEW_ARGS(SkDisplacementMapEffect,
- (SkDisplacementMapEffect::kB_ChannelSelectorType,
- SkDisplacementMapEffect::kA_ChannelSelectorType, 16.0f, displ)))->unref();
+ paint.setImageFilter(SkDisplacementMapEffect::Create(
+ SkDisplacementMapEffect::kB_ChannelSelectorType,
+ SkDisplacementMapEffect::kA_ChannelSelectorType, 16.0f, displ))->unref();
drawClippedBitmap(canvas, 100, 0, paint);
- paint.setImageFilter(SkNEW_ARGS(SkDisplacementMapEffect,
- (SkDisplacementMapEffect::kR_ChannelSelectorType,
- SkDisplacementMapEffect::kB_ChannelSelectorType, 32.0f, displ)))->unref();
+ paint.setImageFilter(SkDisplacementMapEffect::Create(
+ SkDisplacementMapEffect::kR_ChannelSelectorType,
+ SkDisplacementMapEffect::kB_ChannelSelectorType, 32.0f, displ))->unref();
drawClippedBitmap(canvas, 200, 0, paint);
- paint.setImageFilter(SkNEW_ARGS(SkDisplacementMapEffect,
- (SkDisplacementMapEffect::kG_ChannelSelectorType,
- SkDisplacementMapEffect::kA_ChannelSelectorType, 48.0f, displ)))->unref();
+ paint.setImageFilter(SkDisplacementMapEffect::Create(
+ SkDisplacementMapEffect::kG_ChannelSelectorType,
+ SkDisplacementMapEffect::kA_ChannelSelectorType, 48.0f, displ))->unref();
drawClippedBitmap(canvas, 300, 0, paint);
- paint.setImageFilter(SkNEW_ARGS(SkDisplacementMapEffect,
- (SkDisplacementMapEffect::kR_ChannelSelectorType,
- SkDisplacementMapEffect::kA_ChannelSelectorType, 64.0f, displ)))->unref();
+ paint.setImageFilter(SkDisplacementMapEffect::Create(
+ SkDisplacementMapEffect::kR_ChannelSelectorType,
+ SkDisplacementMapEffect::kA_ChannelSelectorType, 64.0f, displ))->unref();
drawClippedBitmap(canvas, 400, 0, paint);
- paint.setImageFilter(SkNEW_ARGS(SkDisplacementMapEffect,
- (SkDisplacementMapEffect::kR_ChannelSelectorType,
- SkDisplacementMapEffect::kG_ChannelSelectorType, 40.0f, displ)))->unref();
+ paint.setImageFilter(SkDisplacementMapEffect::Create(
+ SkDisplacementMapEffect::kR_ChannelSelectorType,
+ SkDisplacementMapEffect::kG_ChannelSelectorType, 40.0f, displ))->unref();
drawClippedBitmap(canvas, 0, 100, paint);
- paint.setImageFilter(SkNEW_ARGS(SkDisplacementMapEffect,
- (SkDisplacementMapEffect::kB_ChannelSelectorType,
- SkDisplacementMapEffect::kA_ChannelSelectorType, 40.0f, displ)))->unref();
+ paint.setImageFilter(SkDisplacementMapEffect::Create(
+ SkDisplacementMapEffect::kB_ChannelSelectorType,
+ SkDisplacementMapEffect::kA_ChannelSelectorType, 40.0f, displ))->unref();
drawClippedBitmap(canvas, 100, 100, paint);
- paint.setImageFilter(SkNEW_ARGS(SkDisplacementMapEffect,
- (SkDisplacementMapEffect::kR_ChannelSelectorType,
- SkDisplacementMapEffect::kB_ChannelSelectorType, 40.0f, displ)))->unref();
+ paint.setImageFilter(SkDisplacementMapEffect::Create(
+ SkDisplacementMapEffect::kR_ChannelSelectorType,
+ SkDisplacementMapEffect::kB_ChannelSelectorType, 40.0f, displ))->unref();
drawClippedBitmap(canvas, 200, 100, paint);
- paint.setImageFilter(SkNEW_ARGS(SkDisplacementMapEffect,
- (SkDisplacementMapEffect::kG_ChannelSelectorType,
- SkDisplacementMapEffect::kA_ChannelSelectorType, 40.0f, displ)))->unref();
+ paint.setImageFilter(SkDisplacementMapEffect::Create(
+ SkDisplacementMapEffect::kG_ChannelSelectorType,
+ SkDisplacementMapEffect::kA_ChannelSelectorType, 40.0f, displ))->unref();
drawClippedBitmap(canvas, 300, 100, paint);
- paint.setImageFilter(SkNEW_ARGS(SkDisplacementMapEffect,
- (SkDisplacementMapEffect::kR_ChannelSelectorType,
- SkDisplacementMapEffect::kA_ChannelSelectorType, 40.0f, displ)))->unref();
+ paint.setImageFilter(SkDisplacementMapEffect::Create(
+ SkDisplacementMapEffect::kR_ChannelSelectorType,
+ SkDisplacementMapEffect::kA_ChannelSelectorType, 40.0f, displ))->unref();
drawClippedBitmap(canvas, 400, 100, paint);
SkImageFilter::CropRect cropRect(SkRect::MakeXYWH(30, 30, 40, 40));
- paint.setImageFilter(SkNEW_ARGS(SkDisplacementMapEffect,
- (SkDisplacementMapEffect::kR_ChannelSelectorType,
- SkDisplacementMapEffect::kG_ChannelSelectorType,
- 0.0f, displ, NULL, &cropRect)))->unref();
+ paint.setImageFilter(SkDisplacementMapEffect::Create(
+ SkDisplacementMapEffect::kR_ChannelSelectorType,
+ SkDisplacementMapEffect::kG_ChannelSelectorType,
+ 0.0f, displ, NULL, &cropRect))->unref();
drawClippedBitmap(canvas, 0, 200, paint);
- paint.setImageFilter(SkNEW_ARGS(SkDisplacementMapEffect,
- (SkDisplacementMapEffect::kB_ChannelSelectorType,
- SkDisplacementMapEffect::kA_ChannelSelectorType,
- 16.0f, displ, NULL, &cropRect)))->unref();
+ paint.setImageFilter(SkDisplacementMapEffect::Create(
+ SkDisplacementMapEffect::kB_ChannelSelectorType,
+ SkDisplacementMapEffect::kA_ChannelSelectorType,
+ 16.0f, displ, NULL, &cropRect))->unref();
drawClippedBitmap(canvas, 100, 200, paint);
- paint.setImageFilter(SkNEW_ARGS(SkDisplacementMapEffect,
- (SkDisplacementMapEffect::kR_ChannelSelectorType,
- SkDisplacementMapEffect::kB_ChannelSelectorType,
- 32.0f, displ, NULL, &cropRect)))->unref();
+ paint.setImageFilter(SkDisplacementMapEffect::Create(
+ SkDisplacementMapEffect::kR_ChannelSelectorType,
+ SkDisplacementMapEffect::kB_ChannelSelectorType,
+ 32.0f, displ, NULL, &cropRect))->unref();
drawClippedBitmap(canvas, 200, 200, paint);
- paint.setImageFilter(SkNEW_ARGS(SkDisplacementMapEffect,
- (SkDisplacementMapEffect::kG_ChannelSelectorType,
- SkDisplacementMapEffect::kA_ChannelSelectorType,
- 48.0f, displ, NULL, &cropRect)))->unref();
+ paint.setImageFilter(SkDisplacementMapEffect::Create(
+ SkDisplacementMapEffect::kG_ChannelSelectorType,
+ SkDisplacementMapEffect::kA_ChannelSelectorType,
+ 48.0f, displ, NULL, &cropRect))->unref();
drawClippedBitmap(canvas, 300, 200, paint);
- paint.setImageFilter(SkNEW_ARGS(SkDisplacementMapEffect,
- (SkDisplacementMapEffect::kR_ChannelSelectorType,
- SkDisplacementMapEffect::kA_ChannelSelectorType,
- 64.0f, displ, NULL, &cropRect)))->unref();
+ paint.setImageFilter(SkDisplacementMapEffect::Create(
+ SkDisplacementMapEffect::kR_ChannelSelectorType,
+ SkDisplacementMapEffect::kA_ChannelSelectorType,
+ 64.0f, displ, NULL, &cropRect))->unref();
drawClippedBitmap(canvas, 400, 200, paint);
- paint.setImageFilter(SkNEW_ARGS(SkDisplacementMapEffect,
- (SkDisplacementMapEffect::kR_ChannelSelectorType,
- SkDisplacementMapEffect::kG_ChannelSelectorType,
- 40.0f, displ, NULL, &cropRect)))->unref();
+ paint.setImageFilter(SkDisplacementMapEffect::Create(
+ SkDisplacementMapEffect::kR_ChannelSelectorType,
+ SkDisplacementMapEffect::kG_ChannelSelectorType,
+ 40.0f, displ, NULL, &cropRect))->unref();
drawClippedBitmap(canvas, 0, 300, paint);
- paint.setImageFilter(SkNEW_ARGS(SkDisplacementMapEffect,
- (SkDisplacementMapEffect::kB_ChannelSelectorType,
- SkDisplacementMapEffect::kA_ChannelSelectorType,
- 40.0f, displ, NULL, &cropRect)))->unref();
+ paint.setImageFilter(SkDisplacementMapEffect::Create(
+ SkDisplacementMapEffect::kB_ChannelSelectorType,
+ SkDisplacementMapEffect::kA_ChannelSelectorType,
+ 40.0f, displ, NULL, &cropRect))->unref();
drawClippedBitmap(canvas, 100, 300, paint);
- paint.setImageFilter(SkNEW_ARGS(SkDisplacementMapEffect,
- (SkDisplacementMapEffect::kR_ChannelSelectorType,
- SkDisplacementMapEffect::kB_ChannelSelectorType,
- 40.0f, displ, NULL, &cropRect)))->unref();
+ paint.setImageFilter(SkDisplacementMapEffect::Create(
+ SkDisplacementMapEffect::kR_ChannelSelectorType,
+ SkDisplacementMapEffect::kB_ChannelSelectorType,
+ 40.0f, displ, NULL, &cropRect))->unref();
drawClippedBitmap(canvas, 200, 300, paint);
- paint.setImageFilter(SkNEW_ARGS(SkDisplacementMapEffect,
- (SkDisplacementMapEffect::kG_ChannelSelectorType,
- SkDisplacementMapEffect::kA_ChannelSelectorType,
- 40.0f, displ, NULL, &cropRect)))->unref();
+ paint.setImageFilter(SkDisplacementMapEffect::Create(
+ SkDisplacementMapEffect::kG_ChannelSelectorType,
+ SkDisplacementMapEffect::kA_ChannelSelectorType,
+ 40.0f, displ, NULL, &cropRect))->unref();
drawClippedBitmap(canvas, 300, 300, paint);
- paint.setImageFilter(SkNEW_ARGS(SkDisplacementMapEffect,
- (SkDisplacementMapEffect::kR_ChannelSelectorType,
- SkDisplacementMapEffect::kA_ChannelSelectorType,
- 40.0f, displ, NULL, &cropRect)))->unref();
+ paint.setImageFilter(SkDisplacementMapEffect::Create(
+ SkDisplacementMapEffect::kR_ChannelSelectorType,
+ SkDisplacementMapEffect::kA_ChannelSelectorType,
+ 40.0f, displ, NULL, &cropRect))->unref();
drawClippedBitmap(canvas, 400, 300, paint);
// Tests for images of different sizes
- displ.reset(SkNEW_ARGS(SkBitmapSource, (fSmall)));
- paint.setImageFilter(SkNEW_ARGS(SkDisplacementMapEffect,
- (SkDisplacementMapEffect::kR_ChannelSelectorType,
- SkDisplacementMapEffect::kG_ChannelSelectorType,
- 40.0f, displ)))->unref();
+ displ.reset(SkBitmapSource::Create(fSmall));
+ paint.setImageFilter(SkDisplacementMapEffect::Create(
+ SkDisplacementMapEffect::kR_ChannelSelectorType,
+ SkDisplacementMapEffect::kG_ChannelSelectorType,
+ 40.0f, displ))->unref();
drawClippedBitmap(canvas, 0, 400, paint);
- displ.reset(SkNEW_ARGS(SkBitmapSource, (fLarge)));
- paint.setImageFilter(SkNEW_ARGS(SkDisplacementMapEffect,
- (SkDisplacementMapEffect::kB_ChannelSelectorType,
- SkDisplacementMapEffect::kA_ChannelSelectorType,
- 40.0f, displ)))->unref();
+ displ.reset(SkBitmapSource::Create(fLarge));
+ paint.setImageFilter(SkDisplacementMapEffect::Create(
+ SkDisplacementMapEffect::kB_ChannelSelectorType,
+ SkDisplacementMapEffect::kA_ChannelSelectorType,
+ 40.0f, displ))->unref();
drawClippedBitmap(canvas, 100, 400, paint);
- displ.reset(SkNEW_ARGS(SkBitmapSource, (fLargeW)));
- paint.setImageFilter(SkNEW_ARGS(SkDisplacementMapEffect,
- (SkDisplacementMapEffect::kR_ChannelSelectorType,
- SkDisplacementMapEffect::kB_ChannelSelectorType,
- 40.0f, displ)))->unref();
+ displ.reset(SkBitmapSource::Create(fLargeW));
+ paint.setImageFilter(SkDisplacementMapEffect::Create(
+ SkDisplacementMapEffect::kR_ChannelSelectorType,
+ SkDisplacementMapEffect::kB_ChannelSelectorType,
+ 40.0f, displ))->unref();
drawClippedBitmap(canvas, 200, 400, paint);
- displ.reset(SkNEW_ARGS(SkBitmapSource, (fLargeH)));
- paint.setImageFilter(SkNEW_ARGS(SkDisplacementMapEffect,
- (SkDisplacementMapEffect::kG_ChannelSelectorType,
- SkDisplacementMapEffect::kA_ChannelSelectorType,
- 40.0f, displ)))->unref();
+ displ.reset(SkBitmapSource::Create(fLargeH));
+ paint.setImageFilter(SkDisplacementMapEffect::Create(
+ SkDisplacementMapEffect::kG_ChannelSelectorType,
+ SkDisplacementMapEffect::kA_ChannelSelectorType,
+ 40.0f, displ))->unref();
drawClippedBitmap(canvas, 300, 400, paint);
// Test for no given displacement input. In this case, both displacement
// and color should use the same bitmap, given to SkCanvas::drawBitmap()
// as an input argument.
- paint.setImageFilter(SkNEW_ARGS(SkDisplacementMapEffect,
- (SkDisplacementMapEffect::kG_ChannelSelectorType,
- SkDisplacementMapEffect::kA_ChannelSelectorType,
- 40.0f, NULL)))->unref();
+ paint.setImageFilter(SkDisplacementMapEffect::Create(
+ SkDisplacementMapEffect::kG_ChannelSelectorType,
+ SkDisplacementMapEffect::kA_ChannelSelectorType,
+ 40.0f, NULL))->unref();
drawClippedBitmap(canvas, 400, 400, paint);
}
diff --git a/gm/dropshadowimagefilter.cpp b/gm/dropshadowimagefilter.cpp
index e9ed583a39..93768412a6 100644
--- a/gm/dropshadowimagefilter.cpp
+++ b/gm/dropshadowimagefilter.cpp
@@ -133,12 +133,12 @@ protected:
SkImageFilter* filters[] = {
NULL,
- new SkDropShadowImageFilter(7.0f, 0.0f, 0.0f, 3.0f, SK_ColorBLUE),
- new SkDropShadowImageFilter(0.0f, 7.0f, 3.0f, 0.0f, SK_ColorBLUE),
- new SkDropShadowImageFilter(7.0f, 7.0f, 3.0f, 3.0f, SK_ColorBLUE),
- new SkDropShadowImageFilter(7.0f, 7.0f, 3.0f, 3.0f, SK_ColorBLUE, cfif),
- new SkDropShadowImageFilter(7.0f, 7.0f, 3.0f, 3.0f, SK_ColorBLUE, NULL, &cropRect),
- new SkDropShadowImageFilter(7.0f, 7.0f, 3.0f, 3.0f, SK_ColorBLUE, NULL, &bogusRect),
+ SkDropShadowImageFilter::Create(7.0f, 0.0f, 0.0f, 3.0f, SK_ColorBLUE),
+ SkDropShadowImageFilter::Create(0.0f, 7.0f, 3.0f, 0.0f, SK_ColorBLUE),
+ SkDropShadowImageFilter::Create(7.0f, 7.0f, 3.0f, 3.0f, SK_ColorBLUE),
+ SkDropShadowImageFilter::Create(7.0f, 7.0f, 3.0f, 3.0f, SK_ColorBLUE, cfif),
+ SkDropShadowImageFilter::Create(7.0f, 7.0f, 3.0f, 3.0f, SK_ColorBLUE, NULL, &cropRect),
+ SkDropShadowImageFilter::Create(7.0f, 7.0f, 3.0f, 3.0f, SK_ColorBLUE, NULL, &bogusRect),
};
SkRect r = SkRect::MakeWH(SkIntToScalar(64), SkIntToScalar(64));
diff --git a/gm/imageblur.cpp b/gm/imageblur.cpp
index 4c3f42d825..ff8a4812cf 100644
--- a/gm/imageblur.cpp
+++ b/gm/imageblur.cpp
@@ -33,7 +33,7 @@ protected:
virtual void onDraw(SkCanvas* canvas) {
SkPaint paint;
- paint.setImageFilter(new SkBlurImageFilter(fSigmaX, fSigmaY))->unref();
+ paint.setImageFilter(SkBlurImageFilter::Create(fSigmaX, fSigmaY))->unref();
canvas->saveLayer(NULL, &paint);
const char* str = "The quick brown fox jumped over the lazy dog.";
diff --git a/gm/imageblurtiled.cpp b/gm/imageblurtiled.cpp
index 96df4367b4..c3bcab998b 100644
--- a/gm/imageblurtiled.cpp
+++ b/gm/imageblurtiled.cpp
@@ -31,7 +31,7 @@ protected:
virtual void onDraw(SkCanvas* canvas) {
SkPaint paint;
- paint.setImageFilter(new SkBlurImageFilter(fSigmaX, fSigmaY))->unref();
+ paint.setImageFilter(SkBlurImageFilter::Create(fSigmaX, fSigmaY))->unref();
const SkScalar tile_size = SkIntToScalar(128);
SkRect bounds;
canvas->getClipBounds(&bounds);
diff --git a/gm/imagefiltersbase.cpp b/gm/imagefiltersbase.cpp
index 4794b02699..86a7f81b47 100644
--- a/gm/imagefiltersbase.cpp
+++ b/gm/imagefiltersbase.cpp
@@ -18,10 +18,13 @@
class FailImageFilter : public SkImageFilter {
public:
- FailImageFilter() : INHERITED(0) {}
+ static FailImageFilter* Create() {
+ return SkNEW(FailImageFilter);
+ }
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(FailImageFilter)
protected:
+ FailImageFilter() : INHERITED(0) {}
virtual bool onFilterImage(Proxy*, const SkBitmap& src, const SkMatrix&,
SkBitmap* result, SkIPoint* offset) const {
return false;
@@ -41,10 +44,13 @@ static SkFlattenable::Registrar gFailImageFilterReg("FailImageFilter",
class IdentityImageFilter : public SkImageFilter {
public:
- IdentityImageFilter() : INHERITED(0) {}
+ static IdentityImageFilter* Create() {
+ return SkNEW(IdentityImageFilter);
+ }
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(IdentityImageFilter)
protected:
+ IdentityImageFilter() : INHERITED(0) {}
virtual bool onFilterImage(Proxy*, const SkBitmap& src, const SkMatrix&,
SkBitmap* result, SkIPoint* offset) const {
*result = src;
@@ -188,11 +194,11 @@ protected:
SkXfermode::kSrcIn_Mode);
SkImageFilter* filters[] = {
NULL,
- new IdentityImageFilter,
- new FailImageFilter,
+ IdentityImageFilter::Create(),
+ FailImageFilter::Create(),
SkColorFilterImageFilter::Create(cf),
- new SkBlurImageFilter(12.0f, 0.0f),
- new SkDropShadowImageFilter(10.0f, 5.0f, 3.0f, SK_ColorBLUE),
+ SkBlurImageFilter::Create(12.0f, 0.0f),
+ SkDropShadowImageFilter::Create(10.0f, 5.0f, 3.0f, SK_ColorBLUE),
};
cf->unref();
diff --git a/gm/imagefiltersclipped.cpp b/gm/imagefiltersclipped.cpp
index bb6cd0471f..84e63b8f0d 100644
--- a/gm/imagefiltersclipped.cpp
+++ b/gm/imagefiltersclipped.cpp
@@ -87,24 +87,24 @@ protected:
}
canvas->clear(0x00000000);
- SkAutoTUnref<SkImageFilter> gradient(new SkBitmapSource(fGradientCircle));
- SkAutoTUnref<SkImageFilter> checkerboard(new SkBitmapSource(fCheckerboard));
+ SkAutoTUnref<SkImageFilter> gradient(SkBitmapSource::Create(fGradientCircle));
+ SkAutoTUnref<SkImageFilter> checkerboard(SkBitmapSource::Create(fCheckerboard));
SkAutoTUnref<SkShader> noise(SkPerlinNoiseShader::CreateFractalNoise(
SkDoubleToScalar(0.1), SkDoubleToScalar(0.05), 1, 0));
SkImageFilter* filters[] = {
- new SkBlurImageFilter(SkIntToScalar(12), SkIntToScalar(12)),
- new SkDropShadowImageFilter(SkIntToScalar(10), SkIntToScalar(10), SkIntToScalar(3),
- SK_ColorGREEN),
- new SkDisplacementMapEffect(SkDisplacementMapEffect::kR_ChannelSelectorType,
- SkDisplacementMapEffect::kR_ChannelSelectorType,
- SkIntToScalar(12),
- gradient.get(),
- checkerboard.get()),
- new SkDilateImageFilter(2, 2, checkerboard.get()),
- new SkErodeImageFilter(2, 2, checkerboard.get()),
- new SkOffsetImageFilter(SkIntToScalar(-16), SkIntToScalar(32)),
- new SkResizeImageFilter(RESIZE_FACTOR_X, RESIZE_FACTOR_Y, SkPaint::kNone_FilterLevel),
+ SkBlurImageFilter::Create(SkIntToScalar(12), SkIntToScalar(12)),
+ SkDropShadowImageFilter::Create(SkIntToScalar(10), SkIntToScalar(10), SkIntToScalar(3),
+ SK_ColorGREEN),
+ SkDisplacementMapEffect::Create(SkDisplacementMapEffect::kR_ChannelSelectorType,
+ SkDisplacementMapEffect::kR_ChannelSelectorType,
+ SkIntToScalar(12),
+ gradient.get(),
+ checkerboard.get()),
+ SkDilateImageFilter::Create(2, 2, checkerboard.get()),
+ SkErodeImageFilter::Create(2, 2, checkerboard.get()),
+ SkOffsetImageFilter::Create(SkIntToScalar(-16), SkIntToScalar(32)),
+ SkResizeImageFilter::Create(RESIZE_FACTOR_X, RESIZE_FACTOR_Y, SkPaint::kNone_FilterLevel),
SkRectShaderImageFilter::Create(noise),
};
diff --git a/gm/imagefilterscropped.cpp b/gm/imagefilterscropped.cpp
index 9f2d70025b..fa834d51c0 100644
--- a/gm/imagefilterscropped.cpp
+++ b/gm/imagefilterscropped.cpp
@@ -134,7 +134,7 @@ protected:
SkImageFilter::CropRect cropRect(SkRect::Make(SkIRect::MakeXYWH(10, 10, 44, 44)), SkImageFilter::CropRect::kHasAll_CropEdge);
SkImageFilter::CropRect bogusRect(SkRect::Make(SkIRect::MakeXYWH(-100, -100, 10, 10)), SkImageFilter::CropRect::kHasAll_CropEdge);
- SkAutoTUnref<SkImageFilter> offset(new SkOffsetImageFilter(
+ SkAutoTUnref<SkImageFilter> offset(SkOffsetImageFilter::Create(
SkIntToScalar(-10), SkIntToScalar(-10)));
SkAutoTUnref<SkImageFilter> cfOffset(SkColorFilterImageFilter::Create(cf.get(), offset.get()));
@@ -142,12 +142,12 @@ protected:
SkImageFilter* filters[] = {
NULL,
SkColorFilterImageFilter::Create(cf.get(), NULL, &cropRect),
- new SkBlurImageFilter(1.0f, 1.0f, NULL, &cropRect),
- new SkBlurImageFilter(8.0f, 0.0f, NULL, &cropRect),
- new SkBlurImageFilter(0.0f, 8.0f, NULL, &cropRect),
- new SkBlurImageFilter(8.0f, 8.0f, NULL, &cropRect),
- new SkMergeImageFilter(NULL, cfOffset.get(), SkXfermode::kSrcOver_Mode, &cropRect),
- new SkBlurImageFilter(8.0f, 8.0f, NULL, &bogusRect),
+ SkBlurImageFilter::Create(1.0f, 1.0f, NULL, &cropRect),
+ SkBlurImageFilter::Create(8.0f, 0.0f, NULL, &cropRect),
+ SkBlurImageFilter::Create(0.0f, 8.0f, NULL, &cropRect),
+ SkBlurImageFilter::Create(8.0f, 8.0f, NULL, &cropRect),
+ SkMergeImageFilter::Create(NULL, cfOffset.get(), SkXfermode::kSrcOver_Mode, &cropRect),
+ SkBlurImageFilter::Create(8.0f, 8.0f, NULL, &bogusRect),
SkColorFilterImageFilter::Create(cf.get(), NULL, &bogusRect),
};
diff --git a/gm/imagefiltersgraph.cpp b/gm/imagefiltersgraph.cpp
index f97072e443..fb957e72f2 100644
--- a/gm/imagefiltersgraph.cpp
+++ b/gm/imagefiltersgraph.cpp
@@ -121,13 +121,13 @@ protected:
}
canvas->clear(0x00000000);
{
- SkAutoTUnref<SkImageFilter> bitmapSource(new SkBitmapSource(fBitmap));
+ SkAutoTUnref<SkImageFilter> bitmapSource(SkBitmapSource::Create(fBitmap));
SkAutoTUnref<SkColorFilter> cf(SkColorFilter::CreateModeFilter(SK_ColorRED,
SkXfermode::kSrcIn_Mode));
- SkAutoTUnref<SkImageFilter> blur(new SkBlurImageFilter(4.0f, 4.0f, bitmapSource));
- SkAutoTUnref<SkImageFilter> erode(new SkErodeImageFilter(4, 4, blur));
+ SkAutoTUnref<SkImageFilter> blur(SkBlurImageFilter::Create(4.0f, 4.0f, bitmapSource));
+ SkAutoTUnref<SkImageFilter> erode(SkErodeImageFilter::Create(4, 4, blur));
SkAutoTUnref<SkImageFilter> color(SkColorFilterImageFilter::Create(cf, erode));
- SkAutoTUnref<SkImageFilter> merge(new SkMergeImageFilter(blur, color));
+ SkAutoTUnref<SkImageFilter> merge(SkMergeImageFilter::Create(blur, color));
SkPaint paint;
paint.setImageFilter(merge);
@@ -135,7 +135,7 @@ protected:
canvas->translate(SkIntToScalar(100), 0);
}
{
- SkAutoTUnref<SkImageFilter> morph(new SkDilateImageFilter(5, 5));
+ SkAutoTUnref<SkImageFilter> morph(SkDilateImageFilter::Create(5, 5));
SkScalar matrix[20] = { SK_Scalar1, 0, 0, 0, 0,
0, SK_Scalar1, 0, 0, 0,
@@ -145,7 +145,7 @@ protected:
SkAutoTUnref<SkColorFilter> matrixFilter(SkColorMatrixFilter::Create(matrix));
SkAutoTUnref<SkImageFilter> colorMorph(SkColorFilterImageFilter::Create(matrixFilter, morph));
SkAutoTUnref<SkXfermode> mode(SkXfermode::Create(SkXfermode::kSrcOver_Mode));
- SkAutoTUnref<SkImageFilter> blendColor(new SkXfermodeImageFilter(mode, colorMorph));
+ SkAutoTUnref<SkImageFilter> blendColor(SkXfermodeImageFilter::Create(mode, colorMorph));
SkPaint paint;
paint.setImageFilter(blendColor);
@@ -162,20 +162,22 @@ protected:
SimpleOffsetFilter offsetFilter(SkIntToScalar(10), SkIntToScalar(10), matrixFilter);
SkAutoTUnref<SkXfermode> arith(SkArithmeticMode::Create(0, SK_Scalar1, SK_Scalar1, 0));
- SkXfermodeImageFilter arithFilter(arith, matrixFilter, &offsetFilter);
+ SkAutoTUnref<SkXfermodeImageFilter> arithFilter(
+ SkXfermodeImageFilter::Create(arith, matrixFilter, &offsetFilter));
SkPaint paint;
- paint.setImageFilter(&arithFilter);
+ paint.setImageFilter(arithFilter);
drawClippedBitmap(canvas, fBitmap, paint);
canvas->translate(SkIntToScalar(100), 0);
}
{
- SkAutoTUnref<SkImageFilter> blur(new SkBlurImageFilter(
+ SkAutoTUnref<SkImageFilter> blur(SkBlurImageFilter::Create(
SkIntToScalar(10), SkIntToScalar(10)));
SkAutoTUnref<SkXfermode> mode(SkXfermode::Create(SkXfermode::kSrcIn_Mode));
SkImageFilter::CropRect cropRect(SkRect::MakeWH(SkIntToScalar(95), SkIntToScalar(100)));
- SkAutoTUnref<SkImageFilter> blend(new SkXfermodeImageFilter(mode, blur, NULL, &cropRect));
+ SkAutoTUnref<SkImageFilter> blend(
+ SkXfermodeImageFilter::Create(mode, blur, NULL, &cropRect));
SkPaint paint;
paint.setImageFilter(blend);
diff --git a/gm/imagefiltersscaled.cpp b/gm/imagefiltersscaled.cpp
index ab24a3025f..809e7ea344 100644
--- a/gm/imagefiltersscaled.cpp
+++ b/gm/imagefiltersscaled.cpp
@@ -86,24 +86,24 @@ protected:
}
canvas->clear(0x00000000);
- SkAutoTUnref<SkImageFilter> gradient(new SkBitmapSource(fGradientCircle));
- SkAutoTUnref<SkImageFilter> checkerboard(new SkBitmapSource(fCheckerboard));
+ SkAutoTUnref<SkImageFilter> gradient(SkBitmapSource::Create(fGradientCircle));
+ SkAutoTUnref<SkImageFilter> checkerboard(SkBitmapSource::Create(fCheckerboard));
SkAutoTUnref<SkShader> noise(SkPerlinNoiseShader::CreateFractalNoise(
SkDoubleToScalar(0.1), SkDoubleToScalar(0.05), 1, 0));
SkImageFilter* filters[] = {
- new SkBlurImageFilter(SkIntToScalar(4), SkIntToScalar(4)),
- new SkDropShadowImageFilter(SkIntToScalar(5), SkIntToScalar(10), SkIntToScalar(3),
- SK_ColorYELLOW),
- new SkDisplacementMapEffect(SkDisplacementMapEffect::kR_ChannelSelectorType,
- SkDisplacementMapEffect::kR_ChannelSelectorType,
- SkIntToScalar(12),
- gradient.get(),
- checkerboard.get()),
- new SkDilateImageFilter(1, 1, checkerboard.get()),
- new SkErodeImageFilter(1, 1, checkerboard.get()),
- new SkOffsetImageFilter(SkIntToScalar(32), 0),
- new SkResizeImageFilter(RESIZE_FACTOR, RESIZE_FACTOR, SkPaint::kNone_FilterLevel),
+ SkBlurImageFilter::Create(SkIntToScalar(4), SkIntToScalar(4)),
+ SkDropShadowImageFilter::Create(SkIntToScalar(5), SkIntToScalar(10), SkIntToScalar(3),
+ SK_ColorYELLOW),
+ SkDisplacementMapEffect::Create(SkDisplacementMapEffect::kR_ChannelSelectorType,
+ SkDisplacementMapEffect::kR_ChannelSelectorType,
+ SkIntToScalar(12),
+ gradient.get(),
+ checkerboard.get()),
+ SkDilateImageFilter::Create(1, 1, checkerboard.get()),
+ SkErodeImageFilter::Create(1, 1, checkerboard.get()),
+ SkOffsetImageFilter::Create(SkIntToScalar(32), 0),
+ SkResizeImageFilter::Create(RESIZE_FACTOR, RESIZE_FACTOR, SkPaint::kNone_FilterLevel),
SkRectShaderImageFilter::Create(noise),
};
diff --git a/gm/imagemagnifier.cpp b/gm/imagemagnifier.cpp
index ae639d3b53..66961c915e 100644
--- a/gm/imagemagnifier.cpp
+++ b/gm/imagemagnifier.cpp
@@ -37,7 +37,7 @@ protected:
virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
SkPaint paint;
paint.setImageFilter(
- new SkMagnifierImageFilter(
+ SkMagnifierImageFilter::Create(
SkRect::MakeXYWH(SkIntToScalar(100), SkIntToScalar(100),
SkIntToScalar(WIDTH / 2),
SkIntToScalar(HEIGHT / 2)),
diff --git a/gm/imageresizetiled.cpp b/gm/imageresizetiled.cpp
index ba154d14f4..eba87c5f1f 100644
--- a/gm/imageresizetiled.cpp
+++ b/gm/imageresizetiled.cpp
@@ -37,7 +37,7 @@ protected:
virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
SkPaint paint;
SkAutoTUnref<SkImageFilter> imageFilter(
- new SkResizeImageFilter(RESIZE_FACTOR, RESIZE_FACTOR, SkPaint::kNone_FilterLevel));
+ SkResizeImageFilter::Create(RESIZE_FACTOR, RESIZE_FACTOR, SkPaint::kNone_FilterLevel));
paint.setImageFilter(imageFilter.get());
const SkScalar tile_size = SkIntToScalar(100);
SkRect bounds;
diff --git a/gm/matrixconvolution.cpp b/gm/matrixconvolution.cpp
index b986cc1fc0..5976a40ce6 100644
--- a/gm/matrixconvolution.cpp
+++ b/gm/matrixconvolution.cpp
@@ -57,15 +57,15 @@ protected:
SkScalar gain = 0.3f, bias = SkIntToScalar(100);
SkPaint paint;
SkAutoTUnref<SkImageFilter> filter(
- SkNEW_ARGS(SkMatrixConvolutionImageFilter, (kernelSize,
- kernel,
- gain,
- bias,
- target,
- tileMode,
- convolveAlpha,
- NULL,
- cropRect)));
+ SkMatrixConvolutionImageFilter::Create(kernelSize,
+ kernel,
+ gain,
+ bias,
+ target,
+ tileMode,
+ convolveAlpha,
+ NULL,
+ cropRect));
paint.setImageFilter(filter);
canvas->save();
canvas->translate(SkIntToScalar(x), SkIntToScalar(y));
diff --git a/gm/morphology.cpp b/gm/morphology.cpp
index a2206b8f52..0b4d3af224 100644
--- a/gm/morphology.cpp
+++ b/gm/morphology.cpp
@@ -74,13 +74,13 @@ protected:
for (unsigned i = 0; i < SK_ARRAY_COUNT(samples); ++i) {
const SkImageFilter::CropRect* cr = j & 0x02 ? &cropRect : NULL;
if (j & 0x01) {
- paint.setImageFilter(new SkErodeImageFilter(
+ paint.setImageFilter(SkErodeImageFilter::Create(
samples[i].fRadiusX,
samples[i].fRadiusY,
NULL,
cr))->unref();
} else {
- paint.setImageFilter(new SkDilateImageFilter(
+ paint.setImageFilter(SkDilateImageFilter::Create(
samples[i].fRadiusX,
samples[i].fRadiusY,
NULL,
diff --git a/gm/offsetimagefilter.cpp b/gm/offsetimagefilter.cpp
index 52d6de9503..54597310ab 100644
--- a/gm/offsetimagefilter.cpp
+++ b/gm/offsetimagefilter.cpp
@@ -101,11 +101,11 @@ protected:
bitmap->width() - i * 8,
bitmap->height() - i * 12);
SkImageFilter::CropRect rect(SkRect::Make(cropRect));
- SkAutoTUnref<SkImageFilter> tileInput(SkNEW_ARGS(SkBitmapSource, (*bitmap)));
+ SkAutoTUnref<SkImageFilter> tileInput(SkBitmapSource::Create(*bitmap));
SkScalar dx = SkIntToScalar(i*5);
SkScalar dy = SkIntToScalar(i*10);
- SkAutoTUnref<SkImageFilter> filter(SkNEW_ARGS(
- SkOffsetImageFilter, (dx, dy, tileInput, &rect)));
+ SkAutoTUnref<SkImageFilter> filter(
+ SkOffsetImageFilter::Create(dx, dy, tileInput, &rect));
paint.setImageFilter(filter);
drawClippedBitmap(canvas, *bitmap, paint, SK_Scalar1, cropRect);
canvas->translate(SkIntToScalar(bitmap->width() + MARGIN), 0);
@@ -113,8 +113,8 @@ protected:
SkIRect cropRect = SkIRect::MakeXYWH(0, 0, 100, 100);
SkImageFilter::CropRect rect(SkRect::Make(cropRect));
- SkAutoTUnref<SkImageFilter> filter(SkNEW_ARGS(
- SkOffsetImageFilter, (SkIntToScalar(-5), SkIntToScalar(-10), NULL, &rect)));
+ SkAutoTUnref<SkImageFilter> filter(
+ SkOffsetImageFilter::Create(SkIntToScalar(-5), SkIntToScalar(-10), NULL, &rect));
paint.setImageFilter(filter);
drawClippedBitmap(canvas, fBitmap, paint, SkIntToScalar(2), cropRect);
}
diff --git a/gm/pictureimagefilter.cpp b/gm/pictureimagefilter.cpp
index 5547e87b19..2b3cd14ea2 100644
--- a/gm/pictureimagefilter.cpp
+++ b/gm/pictureimagefilter.cpp
@@ -54,9 +54,9 @@ protected:
SkRect srcRect = SkRect::MakeXYWH(20, 20, 30, 30);
SkRect emptyRect = SkRect::MakeXYWH(20, 20, 0, 0);
SkRect bounds = SkRect::MakeXYWH(0, 0, 100, 100);
- SkAutoTUnref<SkImageFilter> pictureSource(new SkPictureImageFilter(&fPicture));
- SkAutoTUnref<SkImageFilter> pictureSourceSrcRect(new SkPictureImageFilter(&fPicture, srcRect));
- SkAutoTUnref<SkImageFilter> pictureSourceEmptyRect(new SkPictureImageFilter(&fPicture, emptyRect));
+ SkAutoTUnref<SkImageFilter> pictureSource(SkPictureImageFilter::Create(&fPicture));
+ SkAutoTUnref<SkImageFilter> pictureSourceSrcRect(SkPictureImageFilter::Create(&fPicture, srcRect));
+ SkAutoTUnref<SkImageFilter> pictureSourceEmptyRect(SkPictureImageFilter::Create(&fPicture, emptyRect));
// Draw the picture unscaled.
fillRectFiltered(canvas, bounds, pictureSource);
diff --git a/gm/resizeimagefilter.cpp b/gm/resizeimagefilter.cpp
index fa407c4bfa..8f5c0152c5 100644
--- a/gm/resizeimagefilter.cpp
+++ b/gm/resizeimagefilter.cpp
@@ -35,9 +35,9 @@ protected:
canvas->scale(deviceScaleX, deviceScaleY);
canvas->translate(-rect.x(), -rect.y());
SkAutoTUnref<SkImageFilter> imageFilter(
- new SkResizeImageFilter(SkScalarInvert(deviceScaleX),
- SkScalarInvert(deviceScaleY),
- filterLevel));
+ SkResizeImageFilter::Create(SkScalarInvert(deviceScaleX),
+ SkScalarInvert(deviceScaleY),
+ filterLevel));
SkPaint filteredPaint;
filteredPaint.setImageFilter(imageFilter.get());
canvas->saveLayer(&rect, &filteredPaint);
diff --git a/gm/spritebitmap.cpp b/gm/spritebitmap.cpp
index 5884efeca0..f7997eeaba 100644
--- a/gm/spritebitmap.cpp
+++ b/gm/spritebitmap.cpp
@@ -78,7 +78,7 @@ protected:
int dy = 10;
SkScalar sigma = 8;
- SkAutoTUnref<SkImageFilter> filter(new SkBlurImageFilter(sigma, sigma));
+ SkAutoTUnref<SkImageFilter> filter(SkBlurImageFilter::Create(sigma, sigma));
draw_2_bitmaps(canvas, bm, false, dx, dy);
dy += bm.height() + 20;
diff --git a/gm/testimagefilters.cpp b/gm/testimagefilters.cpp
index 6d27c3a21a..2b937ecf47 100644
--- a/gm/testimagefilters.cpp
+++ b/gm/testimagefilters.cpp
@@ -21,8 +21,8 @@
#define FILTER_WIDTH SkIntToScalar(150)
#define FILTER_HEIGHT SkIntToScalar(200)
-static SkImageFilter* make0() { return new SkDownSampleImageFilter(SK_Scalar1 / 5); }
-static SkImageFilter* make1() { return new SkOffsetImageFilter(SkIntToScalar(16), SkIntToScalar(16)); }
+static SkImageFilter* make0() { return SkDownSampleImageFilter::Create(SK_Scalar1 / 5); }
+static SkImageFilter* make1() { return SkOffsetImageFilter::Create(SkIntToScalar(16), SkIntToScalar(16)); }
static SkImageFilter* make2() {
SkColorFilter* cf = SkColorFilter::CreateModeFilter(SK_ColorBLUE,
SkXfermode::kSrcIn_Mode);
@@ -30,30 +30,30 @@ static SkImageFilter* make2() {
return SkColorFilterImageFilter::Create(cf);
}
static SkImageFilter* make3() {
- return new SkBlurImageFilter(8, 0);
+ return SkBlurImageFilter::Create(8, 0);
}
static SkImageFilter* make4() {
- SkImageFilter* outer = new SkOffsetImageFilter(SkIntToScalar(16), SkIntToScalar(16));
- SkImageFilter* inner = new SkDownSampleImageFilter(SK_Scalar1 / 5);
+ SkImageFilter* outer = SkOffsetImageFilter::Create(SkIntToScalar(16), SkIntToScalar(16));
+ SkImageFilter* inner = SkDownSampleImageFilter::Create(SK_Scalar1 / 5);
SkAutoUnref aur0(outer);
SkAutoUnref aur1(inner);
- return new SkComposeImageFilter(outer, inner);
+ return SkComposeImageFilter::Create(outer, inner);
}
static SkImageFilter* make5() {
- SkImageFilter* first = new SkOffsetImageFilter(SkIntToScalar(16), SkIntToScalar(16));
- SkImageFilter* second = new SkDownSampleImageFilter(SK_Scalar1 / 5);
+ SkImageFilter* first = SkOffsetImageFilter::Create(SkIntToScalar(16), SkIntToScalar(16));
+ SkImageFilter* second = SkDownSampleImageFilter::Create(SK_Scalar1 / 5);
SkAutoUnref aur0(first);
SkAutoUnref aur1(second);
- return new SkMergeImageFilter(first, second);
+ return SkMergeImageFilter::Create(first, second);
}
static SkImageFilter* make6() {
- SkImageFilter* outer = new SkOffsetImageFilter(SkIntToScalar(16), SkIntToScalar(16));
- SkImageFilter* inner = new SkDownSampleImageFilter(SK_Scalar1 / 5);
+ SkImageFilter* outer = SkOffsetImageFilter::Create(SkIntToScalar(16), SkIntToScalar(16));
+ SkImageFilter* inner = SkDownSampleImageFilter::Create(SK_Scalar1 / 5);
SkAutoUnref aur0(outer);
SkAutoUnref aur1(inner);
- SkImageFilter* compose = new SkComposeImageFilter(outer, inner);
+ SkImageFilter* compose = SkComposeImageFilter::Create(outer, inner);
SkAutoUnref aur2(compose);
SkColorFilter* cf = SkColorFilter::CreateModeFilter(0x880000FF,
@@ -62,15 +62,15 @@ static SkImageFilter* make6() {
SkImageFilter* blue = SkColorFilterImageFilter::Create(cf);
SkAutoUnref aur4(blue);
- return new SkMergeImageFilter(compose, blue);
+ return SkMergeImageFilter::Create(compose, blue);
}
static SkImageFilter* make7() {
- SkImageFilter* outer = new SkOffsetImageFilter(SkIntToScalar(16), SkIntToScalar(16));
+ SkImageFilter* outer = SkOffsetImageFilter::Create(SkIntToScalar(16), SkIntToScalar(16));
SkImageFilter* inner = make3();
SkAutoUnref aur0(outer);
SkAutoUnref aur1(inner);
- SkImageFilter* compose = new SkComposeImageFilter(outer, inner);
+ SkImageFilter* compose = SkComposeImageFilter::Create(outer, inner);
SkAutoUnref aur2(compose);
SkColorFilter* cf = SkColorFilter::CreateModeFilter(0x880000FF,
@@ -79,7 +79,7 @@ static SkImageFilter* make7() {
SkImageFilter* blue = SkColorFilterImageFilter::Create(cf);
SkAutoUnref aur4(blue);
- return new SkMergeImageFilter(compose, blue);
+ return SkMergeImageFilter::Create(compose, blue);
}
static void draw0(SkCanvas* canvas) {
diff --git a/gm/tileimagefilter.cpp b/gm/tileimagefilter.cpp
index 319aa3c9fa..d6c8d4cbfc 100644
--- a/gm/tileimagefilter.cpp
+++ b/gm/tileimagefilter.cpp
@@ -83,9 +83,9 @@ protected:
SkIntToScalar(i * 4),
SkIntToScalar(bitmap->width() - i * 12),
SkIntToScalar(bitmap->height()) - i * 12);
- SkAutoTUnref<SkImageFilter> tileInput(SkNEW_ARGS(SkBitmapSource, (*bitmap)));
- SkAutoTUnref<SkImageFilter> filter(SkNEW_ARGS(
- SkTileImageFilter, (srcRect, dstRect, tileInput)));
+ SkAutoTUnref<SkImageFilter> tileInput(SkBitmapSource::Create(*bitmap));
+ SkAutoTUnref<SkImageFilter> filter(
+ SkTileImageFilter::Create(srcRect, dstRect, tileInput));
canvas->save();
canvas->translate(SkIntToScalar(x), SkIntToScalar(y));
paint.setImageFilter(filter);
diff --git a/gm/xfermodeimagefilter.cpp b/gm/xfermodeimagefilter.cpp
index 4469618717..2b14f4dfaa 100644
--- a/gm/xfermodeimagefilter.cpp
+++ b/gm/xfermodeimagefilter.cpp
@@ -130,11 +130,10 @@ protected:
};
int x = 0, y = 0;
- SkAutoTUnref<SkImageFilter> background(SkNEW_ARGS(SkBitmapSource, (fCheckerboard)));
+ SkAutoTUnref<SkImageFilter> background(SkBitmapSource::Create(fCheckerboard));
for (size_t i = 0; i < SK_ARRAY_COUNT(gModes); i++) {
SkAutoTUnref<SkXfermode> mode(SkXfermode::Create(gModes[i].fMode));
- SkAutoTUnref<SkImageFilter> filter(SkNEW_ARGS(
- SkXfermodeImageFilter, (mode, background)));
+ SkAutoTUnref<SkImageFilter> filter(SkXfermodeImageFilter::Create(mode, background));
paint.setImageFilter(filter);
drawClippedBitmap(canvas, fBitmap, paint, x, y);
x += fBitmap.width() + MARGIN;
@@ -145,7 +144,7 @@ protected:
}
// Test arithmetic mode as image filter
SkAutoTUnref<SkXfermode> mode(SkArithmeticMode::Create(0, SK_Scalar1, SK_Scalar1, 0));
- SkAutoTUnref<SkImageFilter> filter(SkNEW_ARGS(SkXfermodeImageFilter, (mode, background)));
+ SkAutoTUnref<SkImageFilter> filter(SkXfermodeImageFilter::Create(mode, background));
paint.setImageFilter(filter);
drawClippedBitmap(canvas, fBitmap, paint, x, y);
x += fBitmap.width() + MARGIN;
@@ -154,7 +153,7 @@ protected:
y += fBitmap.height() + MARGIN;
}
// Test NULL mode
- filter.reset(SkNEW_ARGS(SkXfermodeImageFilter, (NULL, background)));
+ filter.reset(SkXfermodeImageFilter::Create(NULL, background));
paint.setImageFilter(filter);
drawClippedBitmap(canvas, fBitmap, paint, x, y);
x += fBitmap.width() + MARGIN;
@@ -165,14 +164,13 @@ protected:
SkRect clipRect = SkRect::MakeWH(SkIntToScalar(fBitmap.width() + 4),
SkIntToScalar(fBitmap.height() + 4));
// Test offsets on SrcMode (uses fixed-function blend)
- SkAutoTUnref<SkImageFilter> foreground(SkNEW_ARGS(SkBitmapSource, (fBitmap)));
- SkAutoTUnref<SkImageFilter> offsetForeground(SkNEW_ARGS(SkOffsetImageFilter,
- (SkIntToScalar(4), SkIntToScalar(-4), foreground)));
- SkAutoTUnref<SkImageFilter> offsetBackground(SkNEW_ARGS(SkOffsetImageFilter,
- (SkIntToScalar(4), SkIntToScalar(4), background)));
+ SkAutoTUnref<SkImageFilter> foreground(SkBitmapSource::Create(fBitmap));
+ SkAutoTUnref<SkImageFilter> offsetForeground(SkOffsetImageFilter::Create(
+ SkIntToScalar(4), SkIntToScalar(-4), foreground));
+ SkAutoTUnref<SkImageFilter> offsetBackground(SkOffsetImageFilter::Create(
+ SkIntToScalar(4), SkIntToScalar(4), background));
mode.reset(SkXfermode::Create(SkXfermode::kSrcOver_Mode));
- filter.reset(SkNEW_ARGS(SkXfermodeImageFilter,
- (mode, offsetBackground, offsetForeground)));
+ filter.reset(SkXfermodeImageFilter::Create(mode, offsetBackground, offsetForeground));
paint.setImageFilter(filter);
drawClippedPaint(canvas, clipRect, paint, x, y);
x += fBitmap.width() + MARGIN;
@@ -182,7 +180,7 @@ protected:
}
// Test offsets on Darken (uses shader blend)
mode.reset(SkXfermode::Create(SkXfermode::kDarken_Mode));
- filter.reset(SkNEW_ARGS(SkXfermodeImageFilter, (mode, offsetBackground, offsetForeground)));
+ filter.reset(SkXfermodeImageFilter::Create(mode, offsetBackground, offsetForeground));
paint.setImageFilter(filter);
drawClippedPaint(canvas, clipRect, paint, x, y);
x += fBitmap.width() + MARGIN;
@@ -205,8 +203,8 @@ protected:
fBitmap.height() + offsets[i][3]);
SkImageFilter::CropRect rect(SkRect::Make(cropRect));
mode.reset(SkXfermode::Create(sampledModes[i]));
- filter.reset(SkNEW_ARGS(SkXfermodeImageFilter,
- (mode, offsetBackground, offsetForeground, &rect)));
+ filter.reset(SkXfermodeImageFilter::Create(
+ mode, offsetBackground, offsetForeground, &rect));
paint.setImageFilter(filter);
drawClippedPaint(canvas, clipRect, paint, x, y);
x += fBitmap.width() + MARGIN;
diff --git a/include/effects/SkBicubicImageFilter.h b/include/effects/SkBicubicImageFilter.h
index 48105b1c5b..9b65975863 100644
--- a/include/effects/SkBicubicImageFilter.h
+++ b/include/effects/SkBicubicImageFilter.h
@@ -20,21 +20,21 @@
class SK_API SkBicubicImageFilter : public SkImageFilter {
public:
+ virtual ~SkBicubicImageFilter();
+
+ static SkBicubicImageFilter* CreateMitchell(const SkSize& scale, SkImageFilter* input = NULL);
+
+ SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkBicubicImageFilter)
+
+protected:
/** Construct a (scaling-only) bicubic resampling image filter.
@param scale How much to scale the image.
@param coefficients The 16 coefficients of the bicubic matrix.
@param input The input image filter. If NULL, the src bitmap
passed to filterImage() is used instead.
*/
-
SkBicubicImageFilter(const SkSize& scale, const SkScalar coefficients[16],
SkImageFilter* input = NULL);
- static SkBicubicImageFilter* CreateMitchell(const SkSize& scale, SkImageFilter* input = NULL);
- virtual ~SkBicubicImageFilter();
-
- SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkBicubicImageFilter)
-
-protected:
SkBicubicImageFilter(SkReadBuffer& buffer);
virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
diff --git a/include/effects/SkBitmapSource.h b/include/effects/SkBitmapSource.h
index fcc1db97bc..9740e0e6c6 100644
--- a/include/effects/SkBitmapSource.h
+++ b/include/effects/SkBitmapSource.h
@@ -13,8 +13,13 @@
class SK_API SkBitmapSource : public SkImageFilter {
public:
- explicit SkBitmapSource(const SkBitmap& bitmap);
- SkBitmapSource(const SkBitmap& bitmap, const SkRect& srcRect, const SkRect& dstRect);
+ static SkBitmapSource* Create(const SkBitmap& bitmap) {
+ return SkNEW_ARGS(SkBitmapSource, (bitmap));
+ }
+ static SkBitmapSource* Create(const SkBitmap& bitmap, const SkRect& srcRect,
+ const SkRect& dstRect) {
+ return SkNEW_ARGS(SkBitmapSource, (bitmap, srcRect, dstRect));
+ }
virtual void computeFastBounds(const SkRect& src, SkRect* dst) const SK_OVERRIDE;
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkBitmapSource)
@@ -26,6 +31,12 @@ protected:
SkBitmap* result, SkIPoint* offset) const SK_OVERRIDE;
virtual bool onFilterBounds(const SkIRect& src, const SkMatrix& ctm, SkIRect* dst) const SK_OVERRIDE;
+#ifdef SK_SUPPORT_LEGACY_PUBLICEFFECTCONSTRUCTORS
+public:
+#endif
+ explicit SkBitmapSource(const SkBitmap& bitmap);
+ SkBitmapSource(const SkBitmap& bitmap, const SkRect& srcRect, const SkRect& dstRect);
+
private:
SkBitmap fBitmap;
SkRect fSrcRect, fDstRect;
diff --git a/include/effects/SkBlurImageFilter.h b/include/effects/SkBlurImageFilter.h
index 60dab729b4..44bf3935cc 100644
--- a/include/effects/SkBlurImageFilter.h
+++ b/include/effects/SkBlurImageFilter.h
@@ -13,10 +13,13 @@
class SK_API SkBlurImageFilter : public SkImageFilter {
public:
- SkBlurImageFilter(SkScalar sigmaX,
- SkScalar sigmaY,
- SkImageFilter* input = NULL,
- const CropRect* cropRect = NULL);
+ static SkBlurImageFilter* Create(SkScalar sigmaX,
+ SkScalar sigmaY,
+ SkImageFilter* input = NULL,
+ const CropRect* cropRect = NULL) {
+ return SkNEW_ARGS(SkBlurImageFilter, (sigmaX, sigmaY, input, cropRect));
+ }
+
virtual void computeFastBounds(const SkRect&, SkRect*) const SK_OVERRIDE;
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkBlurImageFilter)
@@ -34,6 +37,14 @@ protected:
virtual bool filterImageGPU(Proxy* proxy, const SkBitmap& src, const SkMatrix& ctm,
SkBitmap* result, SkIPoint* offset) const SK_OVERRIDE;
+#ifdef SK_SUPPORT_LEGACY_PUBLICEFFECTCONSTRUCTORS
+public:
+#endif
+ SkBlurImageFilter(SkScalar sigmaX,
+ SkScalar sigmaY,
+ SkImageFilter* input = NULL,
+ const CropRect* cropRect = NULL);
+
private:
SkSize fSigma;
typedef SkImageFilter INHERITED;
diff --git a/include/effects/SkComposeImageFilter.h b/include/effects/SkComposeImageFilter.h
index 9e024ef84e..7a982d8090 100644
--- a/include/effects/SkComposeImageFilter.h
+++ b/include/effects/SkComposeImageFilter.h
@@ -12,9 +12,12 @@
class SK_API SkComposeImageFilter : public SkImageFilter {
public:
- SkComposeImageFilter(SkImageFilter* outer, SkImageFilter* inner) : INHERITED(outer, inner) {}
virtual ~SkComposeImageFilter();
+ static SkComposeImageFilter* Create(SkImageFilter* outer, SkImageFilter* inner) {
+ return SkNEW_ARGS(SkComposeImageFilter, (outer, inner));
+ }
+
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkComposeImageFilter)
protected:
@@ -24,6 +27,11 @@ protected:
SkBitmap* result, SkIPoint* loc) const SK_OVERRIDE;
virtual bool onFilterBounds(const SkIRect&, const SkMatrix&, SkIRect*) const SK_OVERRIDE;
+#ifdef SK_SUPPORT_LEGACY_PUBLICEFFECTCONSTRUCTORS
+public:
+#endif
+ SkComposeImageFilter(SkImageFilter* outer, SkImageFilter* inner) : INHERITED(outer, inner) {}
+
private:
typedef SkImageFilter INHERITED;
};
diff --git a/include/effects/SkDisplacementMapEffect.h b/include/effects/SkDisplacementMapEffect.h
index 5de4814951..59549dc718 100644
--- a/include/effects/SkDisplacementMapEffect.h
+++ b/include/effects/SkDisplacementMapEffect.h
@@ -18,18 +18,20 @@ public:
kR_ChannelSelectorType,
kG_ChannelSelectorType,
kB_ChannelSelectorType,
- kA_ChannelSelectorType,
- kKeyBits = 3 // Max value is 4, so 3 bits are required at most
+ kA_ChannelSelectorType
};
- SkDisplacementMapEffect(ChannelSelectorType xChannelSelector,
- ChannelSelectorType yChannelSelector,
- SkScalar scale, SkImageFilter* displacement,
- SkImageFilter* color = NULL,
- const CropRect* cropRect = NULL);
-
~SkDisplacementMapEffect();
+ static SkDisplacementMapEffect* Create(ChannelSelectorType xChannelSelector,
+ ChannelSelectorType yChannelSelector,
+ SkScalar scale, SkImageFilter* displacement,
+ SkImageFilter* color = NULL,
+ const CropRect* cropRect = NULL) {
+ return SkNEW_ARGS(SkDisplacementMapEffect, (xChannelSelector, yChannelSelector, scale,
+ displacement, color, cropRect));
+ }
+
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkDisplacementMapEffect)
virtual bool onFilterImage(Proxy* proxy,
@@ -52,6 +54,15 @@ protected:
explicit SkDisplacementMapEffect(SkReadBuffer& buffer);
virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
+#ifdef SK_SUPPORT_LEGACY_PUBLICEFFECTCONSTRUCTORS
+public:
+#endif
+ SkDisplacementMapEffect(ChannelSelectorType xChannelSelector,
+ ChannelSelectorType yChannelSelector,
+ SkScalar scale, SkImageFilter* displacement,
+ SkImageFilter* color = NULL,
+ const CropRect* cropRect = NULL);
+
private:
ChannelSelectorType fXChannelSelector;
ChannelSelectorType fYChannelSelector;
diff --git a/include/effects/SkDropShadowImageFilter.h b/include/effects/SkDropShadowImageFilter.h
index aba2017eef..5804386294 100644
--- a/include/effects/SkDropShadowImageFilter.h
+++ b/include/effects/SkDropShadowImageFilter.h
@@ -11,8 +11,17 @@
class SK_API SkDropShadowImageFilter : public SkImageFilter {
public:
- SkDropShadowImageFilter(SkScalar dx, SkScalar dy, SkScalar sigma, SkColor, SkImageFilter* input = NULL);
- SkDropShadowImageFilter(SkScalar dx, SkScalar dy, SkScalar sigmaX, SkScalar sigmaY, SkColor, SkImageFilter* input = NULL, const CropRect* cropRect = NULL);
+ static SkDropShadowImageFilter* Create(SkScalar dx, SkScalar dy, SkScalar sigma,
+ SkColor color, SkImageFilter* input = NULL) {
+ return SkNEW_ARGS(SkDropShadowImageFilter, (dx, dy, sigma, color, input));
+ }
+ static SkDropShadowImageFilter* Create(SkScalar dx, SkScalar dy,
+ SkScalar sigmaX, SkScalar sigmaY, SkColor color,
+ SkImageFilter* input = NULL,
+ const CropRect* cropRect = NULL) {
+ return SkNEW_ARGS(SkDropShadowImageFilter, (dx, dy, sigmaX, sigmaY,
+ color, input, cropRect));
+ }
virtual void computeFastBounds(const SkRect&, SkRect*) const SK_OVERRIDE;
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkDropShadowImageFilter)
@@ -23,7 +32,13 @@ protected:
virtual bool onFilterBounds(const SkIRect& src, const SkMatrix&,
SkIRect* dst) const SK_OVERRIDE;
-
+#ifdef SK_SUPPORT_LEGACY_PUBLICEFFECTCONSTRUCTORS
+public:
+#endif
+ SkDropShadowImageFilter(SkScalar dx, SkScalar dy, SkScalar sigma, SkColor,
+ SkImageFilter* input = NULL);
+ SkDropShadowImageFilter(SkScalar dx, SkScalar dy, SkScalar sigmaX, SkScalar sigmaY, SkColor,
+ SkImageFilter* input = NULL, const CropRect* cropRect = NULL);
private:
SkScalar fDx, fDy, fSigmaX, fSigmaY;
diff --git a/include/effects/SkMagnifierImageFilter.h b/include/effects/SkMagnifierImageFilter.h
index 44f0d0d689..cfe1f09b41 100644
--- a/include/effects/SkMagnifierImageFilter.h
+++ b/include/effects/SkMagnifierImageFilter.h
@@ -14,7 +14,9 @@
class SK_API SkMagnifierImageFilter : public SkImageFilter {
public:
- SkMagnifierImageFilter(SkRect srcRect, SkScalar inset);
+ static SkMagnifierImageFilter* Create(const SkRect& srcRect, SkScalar inset) {
+ return SkNEW_ARGS(SkMagnifierImageFilter, (srcRect, inset));
+ }
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkMagnifierImageFilter)
@@ -28,6 +30,11 @@ protected:
virtual bool asNewEffect(GrEffectRef** effect, GrTexture* texture, const SkMatrix& matrix, const SkIRect& bounds) const SK_OVERRIDE;
#endif
+#ifdef SK_SUPPORT_LEGACY_PUBLICEFFECTCONSTRUCTORS
+public:
+#endif
+ SkMagnifierImageFilter(const SkRect& srcRect, SkScalar inset);
+
private:
SkRect fSrcRect;
SkScalar fInset;
diff --git a/include/effects/SkMatrixConvolutionImageFilter.h b/include/effects/SkMatrixConvolutionImageFilter.h
index 59af83e025..524d05d9ca 100644
--- a/include/effects/SkMatrixConvolutionImageFilter.h
+++ b/include/effects/SkMatrixConvolutionImageFilter.h
@@ -28,38 +28,42 @@ public:
kClampToBlack_TileMode, /*!< Fill with transparent black. */
};
+ virtual ~SkMatrixConvolutionImageFilter();
+
/** Construct a matrix convolution image filter.
- @param kernelSize The kernel size in pixels, in each dimension (N by M).
- @param kernel The image processing kernel. Must contain N * M
- elements, in row order.
- @param gain A scale factor applied to each pixel after
- convolution. This can be used to normalize the
- kernel, if it does not sum to 1.
- @param bias A bias factor added to each pixel after convolution.
- @param target An offset applied to each pixel coordinate before
- convolution. This can be used to center the kernel
- over the image (e.g., a 3x3 kernel should have a
- target of {1, 1}).
- @param tileMode How accesses outside the image are treated. (@see
- TileMode).
+ @param kernelSize The kernel size in pixels, in each dimension (N by M).
+ @param kernel The image processing kernel. Must contain N * M
+ elements, in row order.
+ @param gain A scale factor applied to each pixel after
+ convolution. This can be used to normalize the
+ kernel, if it does not sum to 1.
+ @param bias A bias factor added to each pixel after convolution.
+ @param kernelOffset An offset applied to each pixel coordinate before
+ convolution. This can be used to center the kernel
+ over the image (e.g., a 3x3 kernel should have an
+ offset of {1, 1}).
+ @param tileMode How accesses outside the image are treated. (@see
+ TileMode).
@param convolveAlpha If true, all channels are convolved. If false,
- only the RGB channels are convolved, and
- alpha is copied from the source image.
- @param input The input image filter. If NULL, the src bitmap
- passed to filterImage() is used instead.
- @param cropRect The rectangle to which the output processing will be limited.
+ only the RGB channels are convolved, and
+ alpha is copied from the source image.
+ @param input The input image filter. If NULL, the src bitmap
+ passed to filterImage() is used instead.
+ @param cropRect The rectangle to which the output processing will be limited.
*/
-
- SkMatrixConvolutionImageFilter(const SkISize& kernelSize,
- const SkScalar* kernel,
- SkScalar gain,
- SkScalar bias,
- const SkIPoint& target,
- TileMode tileMode,
- bool convolveAlpha,
- SkImageFilter* input = NULL,
- const CropRect* cropRect = NULL);
- virtual ~SkMatrixConvolutionImageFilter();
+ static SkMatrixConvolutionImageFilter* Create(const SkISize& kernelSize,
+ const SkScalar* kernel,
+ SkScalar gain,
+ SkScalar bias,
+ const SkIPoint& kernelOffset,
+ TileMode tileMode,
+ bool convolveAlpha,
+ SkImageFilter* input = NULL,
+ const CropRect* cropRect = NULL) {
+ return SkNEW_ARGS(SkMatrixConvolutionImageFilter, (kernelSize, kernel, gain, bias,
+ kernelOffset, tileMode, convolveAlpha,
+ input, cropRect));
+ }
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkMatrixConvolutionImageFilter)
@@ -77,12 +81,25 @@ protected:
const SkIRect& bounds) const SK_OVERRIDE;
#endif
+#ifdef SK_SUPPORT_LEGACY_PUBLICEFFECTCONSTRUCTORS
+public:
+#endif
+ SkMatrixConvolutionImageFilter(const SkISize& kernelSize,
+ const SkScalar* kernel,
+ SkScalar gain,
+ SkScalar bias,
+ const SkIPoint& kernelOffset,
+ TileMode tileMode,
+ bool convolveAlpha,
+ SkImageFilter* input = NULL,
+ const CropRect* cropRect = NULL);
+
private:
SkISize fKernelSize;
SkScalar* fKernel;
SkScalar fGain;
SkScalar fBias;
- SkIPoint fTarget;
+ SkIPoint fKernelOffset;
TileMode fTileMode;
bool fConvolveAlpha;
typedef SkImageFilter INHERITED;
diff --git a/include/effects/SkMergeImageFilter.h b/include/effects/SkMergeImageFilter.h
index 36eaaf3df1..54170a3ec9 100755
--- a/include/effects/SkMergeImageFilter.h
+++ b/include/effects/SkMergeImageFilter.h
@@ -14,14 +14,19 @@
class SK_API SkMergeImageFilter : public SkImageFilter {
public:
- SkMergeImageFilter(SkImageFilter* first, SkImageFilter* second,
- SkXfermode::Mode = SkXfermode::kSrcOver_Mode,
- const CropRect* cropRect = NULL);
- SkMergeImageFilter(SkImageFilter* filters[], int count,
- const SkXfermode::Mode modes[] = NULL,
- const CropRect* cropRect = NULL);
virtual ~SkMergeImageFilter();
+ static SkMergeImageFilter* Create(SkImageFilter* first, SkImageFilter* second,
+ SkXfermode::Mode mode = SkXfermode::kSrcOver_Mode,
+ const CropRect* cropRect = NULL) {
+ return SkNEW_ARGS(SkMergeImageFilter, (first, second, mode, cropRect));
+ }
+ static SkMergeImageFilter* Create(SkImageFilter* filters[], int count,
+ const SkXfermode::Mode modes[] = NULL,
+ const CropRect* cropRect = NULL) {
+ return SkNEW_ARGS(SkMergeImageFilter, (filters, count, modes, cropRect));
+ }
+
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkMergeImageFilter)
protected:
@@ -30,6 +35,16 @@ protected:
virtual bool onFilterImage(Proxy*, const SkBitmap& src, const SkMatrix&,
SkBitmap* result, SkIPoint* loc) const SK_OVERRIDE;
+
+#ifdef SK_SUPPORT_LEGACY_PUBLICEFFECTCONSTRUCTORS
+public:
+#endif
+ SkMergeImageFilter(SkImageFilter* first, SkImageFilter* second,
+ SkXfermode::Mode = SkXfermode::kSrcOver_Mode,
+ const CropRect* cropRect = NULL);
+ SkMergeImageFilter(SkImageFilter* filters[], int count,
+ const SkXfermode::Mode modes[] = NULL,
+ const CropRect* cropRect = NULL);
private:
uint8_t* fModes; // SkXfermode::Mode
diff --git a/include/effects/SkMorphologyImageFilter.h b/include/effects/SkMorphologyImageFilter.h
index 4d60180aeb..edf1040fd3 100644
--- a/include/effects/SkMorphologyImageFilter.h
+++ b/include/effects/SkMorphologyImageFilter.h
@@ -15,7 +15,6 @@
class SK_API SkMorphologyImageFilter : public SkImageFilter {
public:
- SkMorphologyImageFilter(int radiusX, int radiusY, SkImageFilter* input, const CropRect* cropRect);
virtual void computeFastBounds(const SkRect& src, SkRect* dst) const SK_OVERRIDE;
virtual bool onFilterBounds(const SkIRect& src, const SkMatrix& ctm, SkIRect* dst) const SK_OVERRIDE;
@@ -30,6 +29,8 @@ public:
int width, int height, int srcStride, int dstStride);
protected:
+ SkMorphologyImageFilter(int radiusX, int radiusY, SkImageFilter* input,
+ const CropRect* cropRect);
bool filterImageGeneric(Proc procX, Proc procY,
Proxy*, const SkBitmap& src, const SkMatrix&,
SkBitmap* result, SkIPoint* offset) const;
@@ -51,10 +52,11 @@ private:
class SK_API SkDilateImageFilter : public SkMorphologyImageFilter {
public:
- SkDilateImageFilter(int radiusX, int radiusY,
- SkImageFilter* input = NULL,
- const CropRect* cropRect = NULL)
- : INHERITED(radiusX, radiusY, input, cropRect) {}
+ static SkDilateImageFilter* Create(int radiusX, int radiusY,
+ SkImageFilter* input = NULL,
+ const CropRect* cropRect = NULL) {
+ return SkNEW_ARGS(SkDilateImageFilter, (radiusX, radiusY, input, cropRect));
+ }
virtual bool onFilterImage(Proxy*, const SkBitmap& src, const SkMatrix&,
SkBitmap* result, SkIPoint* offset) const SK_OVERRIDE;
@@ -68,16 +70,25 @@ public:
protected:
SkDilateImageFilter(SkReadBuffer& buffer) : INHERITED(buffer) {}
+#ifdef SK_SUPPORT_LEGACY_PUBLICEFFECTCONSTRUCTORS
+public:
+#endif
+ SkDilateImageFilter(int radiusX, int radiusY,
+ SkImageFilter* input = NULL,
+ const CropRect* cropRect = NULL)
+ : INHERITED(radiusX, radiusY, input, cropRect) {}
+
private:
typedef SkMorphologyImageFilter INHERITED;
};
class SK_API SkErodeImageFilter : public SkMorphologyImageFilter {
public:
- SkErodeImageFilter(int radiusX, int radiusY,
- SkImageFilter* input = NULL,
- const CropRect* cropRect = NULL)
- : INHERITED(radiusX, radiusY, input, cropRect) {}
+ static SkErodeImageFilter* Create(int radiusX, int radiusY,
+ SkImageFilter* input = NULL,
+ const CropRect* cropRect = NULL) {
+ return SkNEW_ARGS(SkErodeImageFilter, (radiusX, radiusY, input, cropRect));
+ }
virtual bool onFilterImage(Proxy*, const SkBitmap& src, const SkMatrix&,
SkBitmap* result, SkIPoint* offset) const SK_OVERRIDE;
@@ -91,6 +102,14 @@ public:
protected:
SkErodeImageFilter(SkReadBuffer& buffer) : INHERITED(buffer) {}
+#ifdef SK_SUPPORT_LEGACY_PUBLICEFFECTCONSTRUCTORS
+public:
+#endif
+ SkErodeImageFilter(int radiusX, int radiusY,
+ SkImageFilter* input = NULL,
+ const CropRect* cropRect = NULL)
+ : INHERITED(radiusX, radiusY, input, cropRect) {}
+
private:
typedef SkMorphologyImageFilter INHERITED;
};
diff --git a/include/effects/SkOffsetImageFilter.h b/include/effects/SkOffsetImageFilter.h
index 31eead3ded..93fc273cd6 100644
--- a/include/effects/SkOffsetImageFilter.h
+++ b/include/effects/SkOffsetImageFilter.h
@@ -15,8 +15,10 @@ class SK_API SkOffsetImageFilter : public SkImageFilter {
typedef SkImageFilter INHERITED;
public:
- SkOffsetImageFilter(SkScalar dx, SkScalar dy, SkImageFilter* input = NULL,
- const CropRect* cropRect = NULL);
+ static SkOffsetImageFilter* Create(SkScalar dx, SkScalar dy, SkImageFilter* input = NULL,
+ const CropRect* cropRect = NULL) {
+ return SkNEW_ARGS(SkOffsetImageFilter, (dx, dy, input, cropRect));
+ }
virtual void computeFastBounds(const SkRect& src, SkRect* dst) const SK_OVERRIDE;
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkOffsetImageFilter)
@@ -28,6 +30,12 @@ protected:
SkBitmap* result, SkIPoint* loc) const SK_OVERRIDE;
virtual bool onFilterBounds(const SkIRect&, const SkMatrix&, SkIRect*) const SK_OVERRIDE;
+#ifdef SK_SUPPORT_LEGACY_PUBLICEFFECTCONSTRUCTORS
+public:
+#endif
+ SkOffsetImageFilter(SkScalar dx, SkScalar dy, SkImageFilter* input = NULL,
+ const CropRect* cropRect = NULL);
+
private:
SkVector fOffset;
};
diff --git a/include/effects/SkPictureImageFilter.h b/include/effects/SkPictureImageFilter.h
index a10d23eebb..1eda5dcceb 100644
--- a/include/effects/SkPictureImageFilter.h
+++ b/include/effects/SkPictureImageFilter.h
@@ -16,13 +16,17 @@ public:
/**
* Refs the passed-in picture.
*/
- explicit SkPictureImageFilter(SkPicture* picture);
+ static SkPictureImageFilter* Create(SkPicture* picture) {
+ return SkNEW_ARGS(SkPictureImageFilter, (picture));
+ }
/**
- * Refs the passed-in picture. rect can be used to crop or expand the destination rect when
+ * Refs the passed-in picture. cropRect can be used to crop or expand the destination rect when
* the picture is drawn. (No scaling is implied by the dest rect; only the CTM is applied.)
*/
- SkPictureImageFilter(SkPicture* picture, const SkRect& rect);
+ static SkPictureImageFilter* Create(SkPicture* picture, const SkRect& cropRect) {
+ return SkNEW_ARGS(SkPictureImageFilter, (picture, cropRect));
+ }
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkPictureImageFilter)
@@ -39,9 +43,15 @@ protected:
virtual bool onFilterImage(Proxy*, const SkBitmap& src, const SkMatrix&,
SkBitmap* result, SkIPoint* offset) const SK_OVERRIDE;
+#ifdef SK_SUPPORT_LEGACY_PUBLICEFFECTCONSTRUCTORS
+public:
+#endif
+ explicit SkPictureImageFilter(SkPicture* picture);
+ SkPictureImageFilter(SkPicture* picture, const SkRect& cropRect);
+
private:
SkPicture* fPicture;
- SkRect fRect;
+ SkRect fCropRect;
typedef SkImageFilter INHERITED;
};
diff --git a/include/effects/SkResizeImageFilter.h b/include/effects/SkResizeImageFilter.h
index 0a8fb14647..9cb7bf3bb0 100644
--- a/include/effects/SkResizeImageFilter.h
+++ b/include/effects/SkResizeImageFilter.h
@@ -21,6 +21,8 @@
class SK_API SkResizeImageFilter : public SkImageFilter {
public:
+ virtual ~SkResizeImageFilter();
+
/** Construct a (scaling-only) resampling image filter.
* @param sx The x scale parameter to apply when resizing.
* @param sy The y scale parameter to apply when resizing.
@@ -28,10 +30,11 @@ public:
* @param input The input image filter. If NULL, the src bitmap
* passed to filterImage() is used instead.
*/
+ static SkResizeImageFilter* Create(SkScalar sx, SkScalar sy, SkPaint::FilterLevel filterLevel,
+ SkImageFilter* input = NULL) {
+ return SkNEW_ARGS(SkResizeImageFilter, (sx, sy, filterLevel, input));
+ }
- SkResizeImageFilter(SkScalar sx, SkScalar sy, SkPaint::FilterLevel filterLevel,
- SkImageFilter* input = NULL);
- virtual ~SkResizeImageFilter();
virtual void computeFastBounds(const SkRect&, SkRect*) const SK_OVERRIDE;
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkResizeImageFilter)
@@ -45,6 +48,12 @@ protected:
virtual bool onFilterBounds(const SkIRect& src, const SkMatrix&,
SkIRect* dst) const SK_OVERRIDE;
+#ifdef SK_SUPPORT_LEGACY_PUBLICEFFECTCONSTRUCTORS
+public:
+#endif
+ SkResizeImageFilter(SkScalar sx, SkScalar sy, SkPaint::FilterLevel filterLevel,
+ SkImageFilter* input = NULL);
+
private:
SkScalar fSx, fSy;
SkPaint::FilterLevel fFilterLevel;
diff --git a/include/effects/SkTestImageFilters.h b/include/effects/SkTestImageFilters.h
index abbaa92593..24f6349cd0 100755
--- a/include/effects/SkTestImageFilters.h
+++ b/include/effects/SkTestImageFilters.h
@@ -7,11 +7,14 @@
// Fun mode that scales down (only) and then scales back up to look pixelated
class SK_API SkDownSampleImageFilter : public SkImageFilter {
public:
- SkDownSampleImageFilter(SkScalar scale) : INHERITED(0), fScale(scale) {}
+ static SkDownSampleImageFilter* Create(SkScalar scale) {
+ return SkNEW_ARGS(SkDownSampleImageFilter, (scale));
+ }
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkDownSampleImageFilter)
protected:
+ SkDownSampleImageFilter(SkScalar scale) : INHERITED(0), fScale(scale) {}
SkDownSampleImageFilter(SkReadBuffer& buffer);
virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
diff --git a/include/effects/SkTileImageFilter.h b/include/effects/SkTileImageFilter.h
index 390e00c9a4..4bc2a20091 100644
--- a/include/effects/SkTileImageFilter.h
+++ b/include/effects/SkTileImageFilter.h
@@ -14,13 +14,15 @@ class SK_API SkTileImageFilter : public SkImageFilter {
typedef SkImageFilter INHERITED;
public:
- /** Tile image filter constructor
+ /** Create a tile image filter
@param srcRect Defines the pixels to tile
@param dstRect Defines the pixels where tiles are drawn
@param input Input from which the subregion defined by srcRect will be tiled
*/
- SkTileImageFilter(const SkRect& srcRect, const SkRect& dstRect, SkImageFilter* input)
- : INHERITED(input), fSrcRect(srcRect), fDstRect(dstRect) {}
+ static SkTileImageFilter* Create(const SkRect& srcRect, const SkRect& dstRect,
+ SkImageFilter* input) {
+ return SkNEW_ARGS(SkTileImageFilter, (srcRect, dstRect, input));
+ }
virtual bool onFilterImage(Proxy* proxy, const SkBitmap& src, const SkMatrix& ctm,
SkBitmap* dst, SkIPoint* offset) const SK_OVERRIDE;
@@ -32,6 +34,12 @@ protected:
virtual void flatten(SkWriteBuffer& buffer) const SK_OVERRIDE;
+#ifdef SK_SUPPORT_LEGACY_PUBLICEFFECTCONSTRUCTORS
+public:
+#endif
+ SkTileImageFilter(const SkRect& srcRect, const SkRect& dstRect, SkImageFilter* input)
+ : INHERITED(input), fSrcRect(srcRect), fDstRect(dstRect) {}
+
private:
SkRect fSrcRect;
SkRect fDstRect;
diff --git a/include/effects/SkXfermodeImageFilter.h b/include/effects/SkXfermodeImageFilter.h
index 602dc48404..b3872a058c 100644
--- a/include/effects/SkXfermodeImageFilter.h
+++ b/include/effects/SkXfermodeImageFilter.h
@@ -21,11 +21,14 @@ class SK_API SkXfermodeImageFilter : public SkImageFilter {
*/
public:
- SkXfermodeImageFilter(SkXfermode* mode, SkImageFilter* background,
- SkImageFilter* foreground = NULL, const CropRect* cropRect = NULL);
-
virtual ~SkXfermodeImageFilter();
+ static SkXfermodeImageFilter* Create(SkXfermode* mode, SkImageFilter* background,
+ SkImageFilter* foreground = NULL,
+ const CropRect* cropRect = NULL) {
+ return SkNEW_ARGS(SkXfermodeImageFilter, (mode, background, foreground, cropRect));
+ }
+
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkXfermodeImageFilter)
virtual bool onFilterImage(Proxy* proxy,
@@ -43,6 +46,12 @@ protected:
explicit SkXfermodeImageFilter(SkReadBuffer& buffer);
virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
+#ifdef SK_SUPPORT_LEGACY_PUBLICEFFECTCONSTRUCTORS
+public:
+#endif
+ SkXfermodeImageFilter(SkXfermode* mode, SkImageFilter* background,
+ SkImageFilter* foreground = NULL, const CropRect* cropRect = NULL);
+
private:
SkXfermode* fMode;
typedef SkImageFilter INHERITED;
diff --git a/samplecode/SampleFilterFuzz.cpp b/samplecode/SampleFilterFuzz.cpp
index f753b50304..074452fb3a 100644
--- a/samplecode/SampleFilterFuzz.cpp
+++ b/samplecode/SampleFilterFuzz.cpp
@@ -226,7 +226,7 @@ static SkImageFilter* make_image_filter(bool canBeNull = true) {
filter = SkBicubicImageFilter::CreateMitchell(SkSize::Make(1, 1), make_image_filter());
break;
case MERGE:
- filter = new SkMergeImageFilter(make_image_filter(), make_image_filter(), make_xfermode());
+ filter = SkMergeImageFilter::Create(make_image_filter(), make_image_filter(), make_xfermode());
break;
case COLOR:
{
@@ -237,22 +237,22 @@ static SkImageFilter* make_image_filter(bool canBeNull = true) {
}
break;
case BLUR:
- filter = new SkBlurImageFilter(make_scalar(true), make_scalar(true), make_image_filter());
+ filter = SkBlurImageFilter::Create(make_scalar(true), make_scalar(true), make_image_filter());
break;
case MAGNIFIER:
- filter = new SkMagnifierImageFilter(make_rect(), make_scalar(true));
+ filter = SkMagnifierImageFilter::Create(make_rect(), make_scalar(true));
break;
case XFERMODE:
{
SkAutoTUnref<SkXfermode> mode(SkXfermode::Create(make_xfermode()));
- filter = new SkXfermodeImageFilter(mode, make_image_filter(), make_image_filter());
+ filter = SkXfermodeImageFilter::Create(mode, make_image_filter(), make_image_filter());
}
break;
case OFFSET:
- filter = new SkOffsetImageFilter(make_scalar(), make_scalar(), make_image_filter());
+ filter = SkOffsetImageFilter::Create(make_scalar(), make_scalar(), make_image_filter());
break;
case COMPOSE:
- filter = new SkComposeImageFilter(make_image_filter(), make_image_filter());
+ filter = SkComposeImageFilter::Create(make_image_filter(), make_image_filter());
break;
case DISTANT_LIGHT:
filter = (R(2) == 1) ?
@@ -292,32 +292,32 @@ static SkImageFilter* make_image_filter(bool canBeNull = true) {
}
break;
case DROP_SHADOW:
- filter = new SkDropShadowImageFilter(make_scalar(), make_scalar(),
+ filter = SkDropShadowImageFilter::Create(make_scalar(), make_scalar(),
make_scalar(true), make_color(), make_image_filter());
break;
case MORPHOLOGY:
if (R(2) == 1) {
- filter = new SkDilateImageFilter(R(static_cast<float>(kBitmapSize)),
+ filter = SkDilateImageFilter::Create(R(static_cast<float>(kBitmapSize)),
R(static_cast<float>(kBitmapSize)), make_image_filter());
} else {
- filter = new SkErodeImageFilter(R(static_cast<float>(kBitmapSize)),
+ filter = SkErodeImageFilter::Create(R(static_cast<float>(kBitmapSize)),
R(static_cast<float>(kBitmapSize)), make_image_filter());
}
break;
case BITMAP:
if (R(2) == 1) {
- filter = new SkBitmapSource(make_bitmap(), make_rect(), make_rect());
+ filter = SkBitmapSource::Create(make_bitmap(), make_rect(), make_rect());
} else {
- filter = new SkBitmapSource(make_bitmap());
+ filter = SkBitmapSource::Create(make_bitmap());
}
break;
case DISPLACE:
- filter = new SkDisplacementMapEffect(make_channel_selector_type(),
- make_channel_selector_type(), make_scalar(),
- make_image_filter(false), make_image_filter());
+ filter = SkDisplacementMapEffect::Create(make_channel_selector_type(),
+ make_channel_selector_type(), make_scalar(),
+ make_image_filter(false), make_image_filter());
break;
case TILE:
- filter = new SkTileImageFilter(make_rect(), make_rect(), make_image_filter(false));
+ filter = SkTileImageFilter::Create(make_rect(), make_rect(), make_image_filter(false));
break;
case PICTURE:
{
@@ -328,7 +328,7 @@ static SkImageFilter* make_image_filter(bool canBeNull = true) {
drawSomething(pict->beginRecording(kBitmapSize, kBitmapSize));
pict->endRecording();
#endif
- filter = new SkPictureImageFilter(pict, make_rect());
+ filter = SkPictureImageFilter::Create(pict, make_rect());
}
break;
default:
diff --git a/src/effects/SkDisplacementMapEffect.cpp b/src/effects/SkDisplacementMapEffect.cpp
index 62fba1ac48..15e93c11cd 100644
--- a/src/effects/SkDisplacementMapEffect.cpp
+++ b/src/effects/SkDisplacementMapEffect.cpp
@@ -19,6 +19,8 @@
namespace {
+#define kChannelSelectorKeyBits 3; // Max value is 4, so 3 bits are required at most
+
template<SkDisplacementMapEffect::ChannelSelectorType type>
uint32_t getValue(SkColor, const SkUnPreMultiply::Scale*) {
SkDEBUGFAIL("Unknown channel selector");
@@ -602,7 +604,7 @@ GrGLEffect::EffectKey GrGLDisplacementMapEffect::GenKey(const GrDrawEffect& draw
drawEffect.castEffect<GrDisplacementMapEffect>();
EffectKey xKey = displacementMap.xChannelSelector();
- EffectKey yKey = displacementMap.yChannelSelector() << SkDisplacementMapEffect::kKeyBits;
+ EffectKey yKey = displacementMap.yChannelSelector() << kChannelSelectorKeyBits;
return xKey | yKey;
}
diff --git a/src/effects/SkDropShadowImageFilter.cpp b/src/effects/SkDropShadowImageFilter.cpp
index 6d68a24d43..7c9631c393 100644
--- a/src/effects/SkDropShadowImageFilter.cpp
+++ b/src/effects/SkDropShadowImageFilter.cpp
@@ -82,7 +82,7 @@ bool SkDropShadowImageFilter::onFilterImage(Proxy* proxy, const SkBitmap& source
matrix.mapVectors(&sigma, &localSigma, 1);
sigma.fX = SkMaxScalar(0, sigma.fX);
sigma.fY = SkMaxScalar(0, sigma.fY);
- SkAutoTUnref<SkImageFilter> blurFilter(new SkBlurImageFilter(sigma.fX, sigma.fY));
+ SkAutoTUnref<SkImageFilter> blurFilter(SkBlurImageFilter::Create(sigma.fX, sigma.fY));
SkAutoTUnref<SkColorFilter> colorFilter(SkColorFilter::CreateModeFilter(fColor, SkXfermode::kSrcIn_Mode));
SkPaint paint;
paint.setImageFilter(blurFilter.get());
diff --git a/src/effects/SkMagnifierImageFilter.cpp b/src/effects/SkMagnifierImageFilter.cpp
index 4ab3fa1749..931ed7ec6b 100644
--- a/src/effects/SkMagnifierImageFilter.cpp
+++ b/src/effects/SkMagnifierImageFilter.cpp
@@ -247,7 +247,7 @@ SkMagnifierImageFilter::SkMagnifierImageFilter(SkReadBuffer& buffer)
}
// FIXME: implement single-input semantics
-SkMagnifierImageFilter::SkMagnifierImageFilter(SkRect srcRect, SkScalar inset)
+SkMagnifierImageFilter::SkMagnifierImageFilter(const SkRect& srcRect, SkScalar inset)
: INHERITED(0), fSrcRect(srcRect), fInset(inset) {
SkASSERT(srcRect.x() >= 0 && srcRect.y() >= 0 && inset >= 0);
}
diff --git a/src/effects/SkMatrixConvolutionImageFilter.cpp b/src/effects/SkMatrixConvolutionImageFilter.cpp
index 79b8e2781b..9e4ad63e08 100644
--- a/src/effects/SkMatrixConvolutionImageFilter.cpp
+++ b/src/effects/SkMatrixConvolutionImageFilter.cpp
@@ -38,7 +38,7 @@ SkMatrixConvolutionImageFilter::SkMatrixConvolutionImageFilter(
const SkScalar* kernel,
SkScalar gain,
SkScalar bias,
- const SkIPoint& target,
+ const SkIPoint& kernelOffset,
TileMode tileMode,
bool convolveAlpha,
SkImageFilter* input,
@@ -47,15 +47,15 @@ SkMatrixConvolutionImageFilter::SkMatrixConvolutionImageFilter(
fKernelSize(kernelSize),
fGain(gain),
fBias(bias),
- fTarget(target),
+ fKernelOffset(kernelOffset),
fTileMode(tileMode),
fConvolveAlpha(convolveAlpha) {
uint32_t size = fKernelSize.fWidth * fKernelSize.fHeight;
fKernel = SkNEW_ARRAY(SkScalar, size);
memcpy(fKernel, kernel, size * sizeof(SkScalar));
SkASSERT(kernelSize.fWidth >= 1 && kernelSize.fHeight >= 1);
- SkASSERT(target.fX >= 0 && target.fX < kernelSize.fWidth);
- SkASSERT(target.fY >= 0 && target.fY < kernelSize.fHeight);
+ SkASSERT(kernelOffset.fX >= 0 && kernelOffset.fX < kernelSize.fWidth);
+ SkASSERT(kernelOffset.fY >= 0 && kernelOffset.fY < kernelSize.fHeight);
}
SkMatrixConvolutionImageFilter::SkMatrixConvolutionImageFilter(SkReadBuffer& buffer)
@@ -79,8 +79,8 @@ SkMatrixConvolutionImageFilter::SkMatrixConvolutionImageFilter(SkReadBuffer& buf
}
fGain = buffer.readScalar();
fBias = buffer.readScalar();
- fTarget.fX = buffer.readInt();
- fTarget.fY = buffer.readInt();
+ fKernelOffset.fX = buffer.readInt();
+ fKernelOffset.fY = buffer.readInt();
fTileMode = (TileMode) buffer.readInt();
fConvolveAlpha = buffer.readBool();
buffer.validate((fKernel != 0) &&
@@ -96,8 +96,8 @@ void SkMatrixConvolutionImageFilter::flatten(SkWriteBuffer& buffer) const {
buffer.writeScalarArray(fKernel, fKernelSize.fWidth * fKernelSize.fHeight);
buffer.writeScalar(fGain);
buffer.writeScalar(fBias);
- buffer.writeInt(fTarget.fX);
- buffer.writeInt(fTarget.fY);
+ buffer.writeInt(fKernelOffset.fX);
+ buffer.writeInt(fKernelOffset.fY);
buffer.writeInt((int) fTileMode);
buffer.writeBool(fConvolveAlpha);
}
@@ -160,8 +160,8 @@ void SkMatrixConvolutionImageFilter::filterPixels(const SkBitmap& src,
for (int cy = 0; cy < fKernelSize.fHeight; cy++) {
for (int cx = 0; cx < fKernelSize.fWidth; cx++) {
SkPMColor s = PixelFetcher::fetch(src,
- x + cx - fTarget.fX,
- y + cy - fTarget.fY,
+ x + cx - fKernelOffset.fX,
+ y + cy - fKernelOffset.fY,
bounds);
SkScalar k = fKernel[cy * fKernelSize.fWidth + cx];
if (convolveAlpha) {
@@ -289,8 +289,8 @@ bool SkMatrixConvolutionImageFilter::onFilterImage(Proxy* proxy,
offset->fX = bounds.fLeft;
offset->fY = bounds.fTop;
bounds.offset(-srcOffset);
- SkIRect interior = SkIRect::MakeXYWH(bounds.left() + fTarget.fX,
- bounds.top() + fTarget.fY,
+ SkIRect interior = SkIRect::MakeXYWH(bounds.left() + fKernelOffset.fX,
+ bounds.top() + fKernelOffset.fY,
bounds.width() - fKernelSize.fWidth + 1,
bounds.height() - fKernelSize.fHeight + 1);
SkIRect top = SkIRect::MakeLTRB(bounds.left(), bounds.top(), bounds.right(), interior.top());
@@ -323,7 +323,7 @@ public:
const SkScalar* kernel,
SkScalar gain,
SkScalar bias,
- const SkIPoint& target,
+ const SkIPoint& kernelOffset,
TileMode tileMode,
bool convolveAlpha) {
AutoEffectUnref effect(SkNEW_ARGS(GrMatrixConvolutionEffect, (texture,
@@ -332,7 +332,7 @@ public:
kernel,
gain,
bias,
- target,
+ kernelOffset,
tileMode,
convolveAlpha)));
return CreateEffectRef(effect);
@@ -348,7 +348,7 @@ public:
static const char* Name() { return "MatrixConvolution"; }
const SkIRect& bounds() const { return fBounds; }
const SkISize& kernelSize() const { return fKernelSize; }
- const float* target() const { return fTarget; }
+ const float* kernelOffset() const { return fKernelOffset; }
const float* kernel() const { return fKernel; }
float gain() const { return fGain; }
float bias() const { return fBias; }
@@ -366,7 +366,7 @@ private:
const SkScalar* kernel,
SkScalar gain,
SkScalar bias,
- const SkIPoint& target,
+ const SkIPoint& kernelOffset,
TileMode tileMode,
bool convolveAlpha);
@@ -377,7 +377,7 @@ private:
float *fKernel;
float fGain;
float fBias;
- float fTarget[2];
+ float fKernelOffset[2];
TileMode fTileMode;
bool fConvolveAlpha;
@@ -475,7 +475,7 @@ void GrGLMatrixConvolutionEffect::emitCode(GrGLShaderBuilder* builder,
kFloat_GrSLType, "Bias");
const char* bounds = builder->getUniformCStr(fBoundsUni);
- const char* target = builder->getUniformCStr(fTargetUni);
+ const char* kernelOffset = builder->getUniformCStr(fTargetUni);
const char* imgInc = builder->getUniformCStr(fImageIncrementUni);
const char* kernel = builder->getUniformCStr(fKernelUni);
const char* gain = builder->getUniformCStr(fGainUni);
@@ -484,7 +484,7 @@ void GrGLMatrixConvolutionEffect::emitCode(GrGLShaderBuilder* builder,
int kHeight = fKernelSize.height();
builder->fsCodeAppend("\t\tvec4 sum = vec4(0, 0, 0, 0);\n");
- builder->fsCodeAppendf("\t\tvec2 coord = %s - %s * %s;\n", coords2D.c_str(), target, imgInc);
+ builder->fsCodeAppendf("\t\tvec2 coord = %s - %s * %s;\n", coords2D.c_str(), kernelOffset, imgInc);
builder->fsCodeAppendf("\t\tfor (int y = 0; y < %d; y++) {\n", kHeight);
builder->fsCodeAppendf("\t\t\tfor (int x = 0; x < %d; x++) {\n", kWidth);
builder->fsCodeAppendf("\t\t\t\tfloat k = %s[y * %d + x];\n", kernel, kWidth);
@@ -545,7 +545,7 @@ void GrGLMatrixConvolutionEffect::setData(const GrGLUniformManager& uman,
imageIncrement[0] = 1.0f / texture.width();
imageIncrement[1] = ySign / texture.height();
uman.set2fv(fImageIncrementUni, 1, imageIncrement);
- uman.set2fv(fTargetUni, 1, conv.target());
+ uman.set2fv(fTargetUni, 1, conv.kernelOffset());
uman.set1fv(fKernelUni, fKernelSize.width() * fKernelSize.height(), conv.kernel());
uman.set1f(fGainUni, conv.gain());
uman.set1f(fBiasUni, conv.bias());
@@ -567,7 +567,7 @@ GrMatrixConvolutionEffect::GrMatrixConvolutionEffect(GrTexture* texture,
const SkScalar* kernel,
SkScalar gain,
SkScalar bias,
- const SkIPoint& target,
+ const SkIPoint& kernelOffset,
TileMode tileMode,
bool convolveAlpha)
: INHERITED(texture, MakeDivByTextureWHMatrix(texture)),
@@ -581,8 +581,8 @@ GrMatrixConvolutionEffect::GrMatrixConvolutionEffect(GrTexture* texture,
for (int i = 0; i < kernelSize.width() * kernelSize.height(); i++) {
fKernel[i] = SkScalarToFloat(kernel[i]);
}
- fTarget[0] = static_cast<float>(target.x());
- fTarget[1] = static_cast<float>(target.y());
+ fKernelOffset[0] = static_cast<float>(kernelOffset.x());
+ fKernelOffset[1] = static_cast<float>(kernelOffset.y());
this->setWillNotUseInputColor();
}
@@ -602,7 +602,7 @@ bool GrMatrixConvolutionEffect::onIsEqual(const GrEffect& sBase) const {
fKernelSize.width() * fKernelSize.height() * sizeof(float)) &&
fGain == s.gain() &&
fBias == s.bias() &&
- fTarget == s.target() &&
+ fKernelOffset == s.kernelOffset() &&
fTileMode == s.tileMode() &&
fConvolveAlpha == s.convolveAlpha();
}
@@ -628,8 +628,8 @@ GrEffectRef* GrMatrixConvolutionEffect::TestCreate(SkRandom* random,
}
SkScalar gain = random->nextSScalar1();
SkScalar bias = random->nextSScalar1();
- SkIPoint target = SkIPoint::Make(random->nextRangeU(0, kernelSize.width()),
- random->nextRangeU(0, kernelSize.height()));
+ SkIPoint kernelOffset = SkIPoint::Make(random->nextRangeU(0, kernelSize.width()),
+ random->nextRangeU(0, kernelSize.height()));
SkIRect bounds = SkIRect::MakeXYWH(random->nextRangeU(0, textures[texIdx]->width()),
random->nextRangeU(0, textures[texIdx]->height()),
random->nextRangeU(0, textures[texIdx]->width()),
@@ -642,7 +642,7 @@ GrEffectRef* GrMatrixConvolutionEffect::TestCreate(SkRandom* random,
kernel.get(),
gain,
bias,
- target,
+ kernelOffset,
tileMode,
convolveAlpha);
}
@@ -662,7 +662,7 @@ bool SkMatrixConvolutionImageFilter::asNewEffect(GrEffectRef** effect,
fKernel,
fGain,
fBias,
- fTarget,
+ fKernelOffset,
fTileMode,
fConvolveAlpha);
return true;
diff --git a/src/effects/SkPictureImageFilter.cpp b/src/effects/SkPictureImageFilter.cpp
index 6e76231867..8db9914930 100644
--- a/src/effects/SkPictureImageFilter.cpp
+++ b/src/effects/SkPictureImageFilter.cpp
@@ -15,15 +15,15 @@
SkPictureImageFilter::SkPictureImageFilter(SkPicture* picture)
: INHERITED(0, 0),
fPicture(picture),
- fRect(SkRect::MakeWH(picture ? SkIntToScalar(picture->width()) : 0,
- picture ? SkIntToScalar(picture->height()) : 0)) {
+ fCropRect(SkRect::MakeWH(picture ? SkIntToScalar(picture->width()) : 0,
+ picture ? SkIntToScalar(picture->height()) : 0)) {
SkSafeRef(fPicture);
}
-SkPictureImageFilter::SkPictureImageFilter(SkPicture* picture, const SkRect& rect)
+SkPictureImageFilter::SkPictureImageFilter(SkPicture* picture, const SkRect& cropRect)
: INHERITED(0, 0),
fPicture(picture),
- fRect(rect) {
+ fCropRect(cropRect) {
SkSafeRef(fPicture);
}
@@ -41,7 +41,7 @@ SkPictureImageFilter::SkPictureImageFilter(SkReadBuffer& buffer)
#else
buffer.readBool();
#endif
- buffer.readRect(&fRect);
+ buffer.readRect(&fCropRect);
}
void SkPictureImageFilter::flatten(SkWriteBuffer& buffer) const {
@@ -55,7 +55,7 @@ void SkPictureImageFilter::flatten(SkWriteBuffer& buffer) const {
#else
buffer.writeBool(false);
#endif
- buffer.writeRect(fRect);
+ buffer.writeRect(fCropRect);
}
bool SkPictureImageFilter::onFilterImage(Proxy* proxy, const SkBitmap&, const SkMatrix& matrix,
@@ -67,7 +67,7 @@ bool SkPictureImageFilter::onFilterImage(Proxy* proxy, const SkBitmap&, const Sk
SkRect floatBounds;
SkIRect bounds;
- matrix.mapRect(&floatBounds, fRect);
+ matrix.mapRect(&floatBounds, fCropRect);
floatBounds.roundOut(&bounds);
if (bounds.isEmpty()) {
diff --git a/tests/GLProgramsTest.cpp b/tests/GLProgramsTest.cpp
index e63342c936..3df08a7f5b 100644
--- a/tests/GLProgramsTest.cpp
+++ b/tests/GLProgramsTest.cpp
@@ -257,7 +257,8 @@ void forceLinking();
void forceLinking() {
SkLightingImageFilter::CreateDistantLitDiffuse(SkPoint3(0,0,0), 0, 0, 0);
SkAlphaThresholdFilter::Create(SkRegion(), .5f, .5f);
- SkMagnifierImageFilter mag(SkRect::MakeWH(SK_Scalar1, SK_Scalar1), SK_Scalar1);
+ SkAutoTUnref<SkMagnifierImageFilter> mag(SkMagnifierImageFilter::Create(
+ SkRect::MakeWH(SK_Scalar1, SK_Scalar1), SK_Scalar1));
GrConfigConversionEffect::Create(NULL,
false,
GrConfigConversionEffect::kNone_PMConversion,
diff --git a/tests/ImageFilterTest.cpp b/tests/ImageFilterTest.cpp
index 96dc959950..36c9a87c39 100644
--- a/tests/ImageFilterTest.cpp
+++ b/tests/ImageFilterTest.cpp
@@ -168,7 +168,7 @@ DEF_TEST(ImageFilter, reporter) {
// 3 ) large negative specular exponent value
SkScalar specularExponent = -1000;
- SkAutoTUnref<SkImageFilter> bmSrc(new SkBitmapSource(bitmap));
+ SkAutoTUnref<SkImageFilter> bmSrc(SkBitmapSource::Create(bitmap));
SkPaint paint;
paint.setImageFilter(SkLightingImageFilter::CreateSpotLitSpecular(
location, target, specularExponent, 180,
@@ -183,7 +183,7 @@ DEF_TEST(ImageFilter, reporter) {
{
// This tests for scale bringing width to 0
SkSize scale = SkSize::Make(-0.001f, SK_Scalar1);
- SkAutoTUnref<SkImageFilter> bmSrc(new SkBitmapSource(bitmap));
+ SkAutoTUnref<SkImageFilter> bmSrc(SkBitmapSource::Create(bitmap));
SkAutoTUnref<SkBicubicImageFilter> bicubic(
SkBicubicImageFilter::CreateMitchell(scale, bmSrc));
SkBitmapDevice device(bitmap);
@@ -222,21 +222,21 @@ static void test_crop_rects(SkBaseDevice* device, skiatest::Reporter* reporter)
SkImageFilter* filters[] = {
SkColorFilterImageFilter::Create(cf.get(), input.get(), &cropRect),
- new SkDisplacementMapEffect(SkDisplacementMapEffect::kR_ChannelSelectorType,
- SkDisplacementMapEffect::kB_ChannelSelectorType,
- 40.0f, input.get(), input.get(), &cropRect),
- new SkBlurImageFilter(SK_Scalar1, SK_Scalar1, input.get(), &cropRect),
- new SkDropShadowImageFilter(SK_Scalar1, SK_Scalar1, SK_Scalar1, SK_Scalar1, SK_ColorGREEN, input.get(), &cropRect),
+ SkDisplacementMapEffect::Create(SkDisplacementMapEffect::kR_ChannelSelectorType,
+ SkDisplacementMapEffect::kB_ChannelSelectorType,
+ 40.0f, input.get(), input.get(), &cropRect),
+ SkBlurImageFilter::Create(SK_Scalar1, SK_Scalar1, input.get(), &cropRect),
+ SkDropShadowImageFilter::Create(SK_Scalar1, SK_Scalar1, SK_Scalar1, SK_Scalar1, SK_ColorGREEN, input.get(), &cropRect),
SkLightingImageFilter::CreatePointLitDiffuse(location, SK_ColorGREEN, 0, 0, input.get(), &cropRect),
SkLightingImageFilter::CreatePointLitSpecular(location, SK_ColorGREEN, 0, 0, 0, input.get(), &cropRect),
- new SkMatrixConvolutionImageFilter(kernelSize, kernel, gain, bias, SkIPoint::Make(1, 1), SkMatrixConvolutionImageFilter::kRepeat_TileMode, false, input.get(), &cropRect),
- new SkMergeImageFilter(input.get(), input.get(), SkXfermode::kSrcOver_Mode, &cropRect),
- new SkOffsetImageFilter(SK_Scalar1, SK_Scalar1, input.get(), &cropRect),
- new SkOffsetImageFilter(SK_Scalar1, SK_Scalar1, input.get(), &cropRect),
- new SkDilateImageFilter(3, 2, input.get(), &cropRect),
- new SkErodeImageFilter(2, 3, input.get(), &cropRect),
- new SkTileImageFilter(inputCropRect.rect(), cropRect.rect(), input.get()),
- new SkXfermodeImageFilter(SkXfermode::Create(SkXfermode::kSrcOver_Mode), input.get(), input.get(), &cropRect),
+ SkMatrixConvolutionImageFilter::Create(kernelSize, kernel, gain, bias, SkIPoint::Make(1, 1), SkMatrixConvolutionImageFilter::kRepeat_TileMode, false, input.get(), &cropRect),
+ SkMergeImageFilter::Create(input.get(), input.get(), SkXfermode::kSrcOver_Mode, &cropRect),
+ SkOffsetImageFilter::Create(SK_Scalar1, SK_Scalar1, input.get(), &cropRect),
+ SkOffsetImageFilter::Create(SK_Scalar1, SK_Scalar1, input.get(), &cropRect),
+ SkDilateImageFilter::Create(3, 2, input.get(), &cropRect),
+ SkErodeImageFilter::Create(2, 3, input.get(), &cropRect),
+ SkTileImageFilter::Create(inputCropRect.rect(), cropRect.rect(), input.get()),
+ SkXfermodeImageFilter::Create(SkXfermode::Create(SkXfermode::kSrcOver_Mode), input.get(), input.get(), &cropRect),
};
for (size_t i = 0; i < SK_ARRAY_COUNT(filters); ++i) {
diff --git a/tests/SerializationTest.cpp b/tests/SerializationTest.cpp
index 95067298d0..7b2914a1cb 100644
--- a/tests/SerializationTest.cpp
+++ b/tests/SerializationTest.cpp
@@ -205,14 +205,15 @@ static void TestBitmapSerialization(const SkBitmap& validBitmap,
const SkBitmap& invalidBitmap,
bool shouldSucceed,
skiatest::Reporter* reporter) {
- SkBitmapSource validBitmapSource(validBitmap);
- SkBitmapSource invalidBitmapSource(invalidBitmap);
+ SkAutoTUnref<SkBitmapSource> validBitmapSource(SkBitmapSource::Create(validBitmap));
+ SkAutoTUnref<SkBitmapSource> invalidBitmapSource(SkBitmapSource::Create(invalidBitmap));
SkAutoTUnref<SkXfermode> mode(SkXfermode::Create(SkXfermode::kSrcOver_Mode));
- SkXfermodeImageFilter xfermodeImageFilter(mode, &invalidBitmapSource, &validBitmapSource);
+ SkAutoTUnref<SkXfermodeImageFilter> xfermodeImageFilter(
+ SkXfermodeImageFilter::Create(mode, invalidBitmapSource, validBitmapSource));
SkAutoTUnref<SkImageFilter> deserializedFilter(
TestFlattenableSerialization<SkImageFilter>(
- &xfermodeImageFilter, shouldSucceed, reporter));
+ xfermodeImageFilter, shouldSucceed, reporter));
// Try to render a small bitmap using the invalid deserialized filter
// to make sure we don't crash while trying to render it