From cac5fd597f6e2495f50aaa6bcbe3dadc56f0b977 Mon Sep 17 00:00:00 2001 From: "commit-bot@chromium.org" Date: Mon, 10 Mar 2014 10:51:58 +0000 Subject: 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 --- gm/xfermodeimagefilter.cpp | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) (limited to 'gm/xfermodeimagefilter.cpp') 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 background(SkNEW_ARGS(SkBitmapSource, (fCheckerboard))); + SkAutoTUnref background(SkBitmapSource::Create(fCheckerboard)); for (size_t i = 0; i < SK_ARRAY_COUNT(gModes); i++) { SkAutoTUnref mode(SkXfermode::Create(gModes[i].fMode)); - SkAutoTUnref filter(SkNEW_ARGS( - SkXfermodeImageFilter, (mode, background))); + SkAutoTUnref 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 mode(SkArithmeticMode::Create(0, SK_Scalar1, SK_Scalar1, 0)); - SkAutoTUnref filter(SkNEW_ARGS(SkXfermodeImageFilter, (mode, background))); + SkAutoTUnref 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 foreground(SkNEW_ARGS(SkBitmapSource, (fBitmap))); - SkAutoTUnref offsetForeground(SkNEW_ARGS(SkOffsetImageFilter, - (SkIntToScalar(4), SkIntToScalar(-4), foreground))); - SkAutoTUnref offsetBackground(SkNEW_ARGS(SkOffsetImageFilter, - (SkIntToScalar(4), SkIntToScalar(4), background))); + SkAutoTUnref foreground(SkBitmapSource::Create(fBitmap)); + SkAutoTUnref offsetForeground(SkOffsetImageFilter::Create( + SkIntToScalar(4), SkIntToScalar(-4), foreground)); + SkAutoTUnref 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; -- cgit v1.2.3