diff options
author | commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2014-04-15 15:48:36 +0000 |
---|---|---|
committer | commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2014-04-15 15:48:36 +0000 |
commit | 73cb15351f33459e0c861a96135c634dec77ef9d (patch) | |
tree | cf521a48286c5cd88354056e65a933cc63f8fbe1 | |
parent | beb8b3a4da83ce30e313e72ae0e444870acecb7e (diff) |
Make sure SkDrawLooper objects can only be allocated on the heap.
Make constructors of SkLayerDrawLooper and SkBlurDrawLooper non-public.
Remove addLayer* methods from SkLayerDrawLooper. SkLayerDrawLooper::Builder is
used to create new objects.
Provide factory method for creating SkBlurDrawLooper.
BUG=2141
R=scroggo@google.com, reed@google.com, djsollen@google.com
Author: dominikg@chromium.org
Review URL: https://codereview.chromium.org/232913003
git-svn-id: http://skia.googlecode.com/svn/trunk@14200 2bbb7eff-a529-9590-31e7-b0007b416f81
-rw-r--r-- | bench/BlurRoundRectBench.cpp | 8 | ||||
-rw-r--r-- | bench/RectoriBench.cpp | 8 | ||||
-rw-r--r-- | gm/blurroundrect.cpp | 8 | ||||
-rw-r--r-- | gm/circles.cpp | 12 | ||||
-rw-r--r-- | gm/drawlooper.cpp | 5 | ||||
-rw-r--r-- | gm/megalooper.cpp | 12 | ||||
-rw-r--r-- | gm/rects.cpp | 12 | ||||
-rw-r--r-- | gm/shadows.cpp | 56 | ||||
-rw-r--r-- | gm/tilemodes_scaled.cpp | 11 | ||||
-rw-r--r-- | include/effects/SkBlurDrawLooper.h | 13 | ||||
-rw-r--r-- | include/effects/SkLayerDrawLooper.h | 23 | ||||
-rw-r--r-- | samplecode/SampleTextOnPath.cpp | 8 | ||||
-rw-r--r-- | samplecode/SampleTiling.cpp | 14 | ||||
-rw-r--r-- | samplecode/SampleUnpremul.cpp | 8 | ||||
-rw-r--r-- | src/effects/SkBlurDrawLooper.cpp | 2 | ||||
-rw-r--r-- | src/effects/SkLayerDrawLooper.cpp | 38 | ||||
-rw-r--r-- | tests/PaintTest.cpp | 3 |
17 files changed, 99 insertions, 142 deletions
diff --git a/bench/BlurRoundRectBench.cpp b/bench/BlurRoundRectBench.cpp index 29c0080594..a3d0ba9fd9 100644 --- a/bench/BlurRoundRectBench.cpp +++ b/bench/BlurRoundRectBench.cpp @@ -40,7 +40,7 @@ public: } virtual void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE { - SkLayerDrawLooper* looper = new SkLayerDrawLooper; + SkLayerDrawLooper::Builder looperBuilder; { SkLayerDrawLooper::LayerInfo info; info.fPaintBits = SkLayerDrawLooper::kMaskFilter_Bit @@ -48,7 +48,7 @@ public: info.fColorMode = SkXfermode::kSrc_Mode; info.fOffset = SkPoint::Make(SkIntToScalar(-1), SkIntToScalar(0)); info.fPostTranslate = false; - SkPaint* paint = looper->addLayerOnTop(info); + SkPaint* paint = looperBuilder.addLayerOnTop(info); SkMaskFilter* maskFilter = SkBlurMaskFilter::Create( SkBlurMaskFilter::kNormal_BlurStyle, SkBlurMask::ConvertRadiusToSigma(SK_ScalarHalf), @@ -61,13 +61,13 @@ public: } { SkLayerDrawLooper::LayerInfo info; - looper->addLayerOnTop(info); + looperBuilder.addLayerOnTop(info); } SkPaint dullPaint; dullPaint.setAntiAlias(true); SkPaint loopedPaint; - loopedPaint.setLooper(looper)->unref(); + loopedPaint.setLooper(looperBuilder.detachLooper())->unref(); loopedPaint.setAntiAlias(true); loopedPaint.setColor(SK_ColorCYAN); diff --git a/bench/RectoriBench.cpp b/bench/RectoriBench.cpp index ee79ca9964..87f5feef89 100644 --- a/bench/RectoriBench.cpp +++ b/bench/RectoriBench.cpp @@ -71,7 +71,7 @@ private: }; SkLayerDrawLooper* createLooper(SkScalar xOff, SkScalar sigma) { - SkLayerDrawLooper* looper = new SkLayerDrawLooper; + SkLayerDrawLooper::Builder looperBuilder; //----------------------------------------------- SkLayerDrawLooper::LayerInfo info; @@ -83,7 +83,7 @@ private: info.fOffset.set(xOff, 0); info.fPostTranslate = false; - SkPaint* paint = looper->addLayer(info); + SkPaint* paint = looperBuilder.addLayer(info); SkMaskFilter* mf = SkBlurMaskFilter::Create(SkBlurMaskFilter::kNormal_BlurStyle, sigma, @@ -94,8 +94,8 @@ private: info.fPaintBits = 0; info.fOffset.set(0, 0); - paint = looper->addLayer(info); - return looper; + paint = looperBuilder.addLayer(info); + return looperBuilder.detachLooper(); } typedef SkBenchmark INHERITED; diff --git a/gm/blurroundrect.cpp b/gm/blurroundrect.cpp index 6c3903fd40..f688380f0e 100644 --- a/gm/blurroundrect.cpp +++ b/gm/blurroundrect.cpp @@ -53,7 +53,7 @@ public: } virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { - SkLayerDrawLooper* looper = new SkLayerDrawLooper; + SkLayerDrawLooper::Builder looperBuilder; { SkLayerDrawLooper::LayerInfo info; info.fPaintBits = SkLayerDrawLooper::kMaskFilter_Bit @@ -61,7 +61,7 @@ public: info.fColorMode = SkXfermode::kSrc_Mode; info.fOffset = SkPoint::Make(SkIntToScalar(-1), SkIntToScalar(0)); info.fPostTranslate = false; - SkPaint* paint = looper->addLayerOnTop(info); + SkPaint* paint = looperBuilder.addLayerOnTop(info); SkMaskFilter* maskFilter = SkBlurMaskFilter::Create( SkBlurMaskFilter::kNormal_BlurStyle, SkBlurMask::ConvertRadiusToSigma(SK_ScalarHalf), @@ -74,12 +74,12 @@ public: } { SkLayerDrawLooper::LayerInfo info; - looper->addLayerOnTop(info); + looperBuilder.addLayerOnTop(info); } SkPaint paint; canvas->drawRect(fRRect.rect(), paint); - paint.setLooper(looper)->unref(); + paint.setLooper(looperBuilder.detachLooper())->unref(); paint.setColor(SK_ColorCYAN); paint.setAntiAlias(true); diff --git a/gm/circles.cpp b/gm/circles.cpp index b4cfef28c1..ce833db6fd 100644 --- a/gm/circles.cpp +++ b/gm/circles.cpp @@ -81,12 +81,12 @@ protected: SkPaint p; p.setAntiAlias(true); SkBlurDrawLooper* shadowLooper = - new SkBlurDrawLooper (SK_ColorBLUE, - SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(10)), - SkIntToScalar(5), SkIntToScalar(10), - SkBlurDrawLooper::kIgnoreTransform_BlurFlag | - SkBlurDrawLooper::kOverrideColor_BlurFlag | - SkBlurDrawLooper::kHighQuality_BlurFlag); + SkBlurDrawLooper::Create(SK_ColorBLUE, + SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(10)), + SkIntToScalar(5), SkIntToScalar(10), + SkBlurDrawLooper::kIgnoreTransform_BlurFlag | + SkBlurDrawLooper::kOverrideColor_BlurFlag | + SkBlurDrawLooper::kHighQuality_BlurFlag); SkAutoUnref aurL0(shadowLooper); p.setLooper(shadowLooper); fPaints.push_back(p); diff --git a/gm/drawlooper.cpp b/gm/drawlooper.cpp index 678d2ad35f..d3a4475442 100644 --- a/gm/drawlooper.cpp +++ b/gm/drawlooper.cpp @@ -72,7 +72,7 @@ private: { 0x88000000, SkPaint::kFill_Style, 0, SkIntToScalar(10), SkIntToScalar(3) } }; - fLooper = new SkLayerDrawLooper; + SkLayerDrawLooper::Builder looperBuilder; SkLayerDrawLooper::LayerInfo info; info.fPaintBits = SkLayerDrawLooper::kStyle_Bit | SkLayerDrawLooper::kMaskFilter_Bit; @@ -80,7 +80,7 @@ private: for (size_t i = 0; i < SK_ARRAY_COUNT(gParams); i++) { info.fOffset.set(gParams[i].fOffset, gParams[i].fOffset); - SkPaint* paint = fLooper->addLayer(info); + SkPaint* paint = looperBuilder.addLayer(info); paint->setColor(gParams[i].fColor); paint->setStyle(gParams[i].fStyle); paint->setStrokeWidth(gParams[i].fWidth); @@ -90,6 +90,7 @@ private: paint->setMaskFilter(mf)->unref(); } } + fLooper = looperBuilder.detachLooper(); } typedef GM INHERITED; diff --git a/gm/megalooper.cpp b/gm/megalooper.cpp index 12ccf2db5f..e8255502a1 100644 --- a/gm/megalooper.cpp +++ b/gm/megalooper.cpp @@ -163,7 +163,7 @@ private: // Create a 1-tier drawlooper SkLayerDrawLooper* create1Looper(SkScalar xOff, SkScalar yOff, SkColor color) { - SkLayerDrawLooper* looper = new SkLayerDrawLooper; + SkLayerDrawLooper::Builder looperBuilder; SkLayerDrawLooper::LayerInfo info; info.fPaintBits = SkLayerDrawLooper::kColorFilter_Bit | @@ -172,14 +172,14 @@ private: info.fOffset.set(xOff, yOff); info.fPostTranslate = false; - SkPaint* paint = looper->addLayer(info); + SkPaint* paint = looperBuilder.addLayer(info); paint->setMaskFilter(this->createBlur())->unref(); SkColorFilter* cf = SkColorFilter::CreateModeFilter(color, SkXfermode::kSrcIn_Mode); paint->setColorFilter(cf)->unref(); - return looper; + return looperBuilder.detachLooper(); } void draw1x4(SkCanvas* canvas, SkScalar x, SkScalar y) { @@ -207,7 +207,7 @@ private: // Create a 4-tier draw looper SkLayerDrawLooper* create4Looper(SkScalar xOff, SkScalar yOff) { - SkLayerDrawLooper* looper = new SkLayerDrawLooper; + SkLayerDrawLooper::Builder looperBuilder; SkLayerDrawLooper::LayerInfo info; info.fPaintBits = SkLayerDrawLooper::kColorFilter_Bit | @@ -219,7 +219,7 @@ private: for (int i = 3; i >= 0; --i) { info.fOffset.set(xOff+gBlurOffsets[i].fX, yOff+gBlurOffsets[i].fY); - paint = looper->addLayer(info); + paint = looperBuilder.addLayer(info); paint->setMaskFilter(this->createBlur())->unref(); @@ -227,7 +227,7 @@ private: paint->setColorFilter(cf)->unref(); } - return looper; + return looperBuilder.detachLooper(); } typedef GM INHERITED; diff --git a/gm/rects.cpp b/gm/rects.cpp index febf553aa1..9600dd5ed5 100644 --- a/gm/rects.cpp +++ b/gm/rects.cpp @@ -95,12 +95,12 @@ protected: p.setColor(SK_ColorWHITE); p.setAntiAlias(true); SkBlurDrawLooper* shadowLooper = - new SkBlurDrawLooper (SK_ColorWHITE, - SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(10)), - SkIntToScalar(5), SkIntToScalar(10), - SkBlurDrawLooper::kIgnoreTransform_BlurFlag | - SkBlurDrawLooper::kOverrideColor_BlurFlag | - SkBlurDrawLooper::kHighQuality_BlurFlag); + SkBlurDrawLooper::Create(SK_ColorWHITE, + SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(10)), + SkIntToScalar(5), SkIntToScalar(10), + SkBlurDrawLooper::kIgnoreTransform_BlurFlag | + SkBlurDrawLooper::kOverrideColor_BlurFlag | + SkBlurDrawLooper::kHighQuality_BlurFlag); SkAutoUnref aurL0(shadowLooper); p.setLooper(shadowLooper); fPaints.push_back(p); diff --git a/gm/shadows.cpp b/gm/shadows.cpp index d0d23a8047..44fa8e22bf 100644 --- a/gm/shadows.cpp +++ b/gm/shadows.cpp @@ -47,42 +47,42 @@ protected: virtual void onDraw(SkCanvas* canvas) { SkBlurDrawLooper* shadowLoopers[5]; shadowLoopers[0] = - new SkBlurDrawLooper (SK_ColorBLUE, - SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(10)), - SkIntToScalar(5), SkIntToScalar(10), - SkBlurDrawLooper::kIgnoreTransform_BlurFlag | - SkBlurDrawLooper::kOverrideColor_BlurFlag | - SkBlurDrawLooper::kHighQuality_BlurFlag); + SkBlurDrawLooper::Create(SK_ColorBLUE, + SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(10)), + SkIntToScalar(5), SkIntToScalar(10), + SkBlurDrawLooper::kIgnoreTransform_BlurFlag | + SkBlurDrawLooper::kOverrideColor_BlurFlag | + SkBlurDrawLooper::kHighQuality_BlurFlag); SkAutoUnref aurL0(shadowLoopers[0]); shadowLoopers[1] = - new SkBlurDrawLooper (SK_ColorBLUE, - SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(10)), - SkIntToScalar(5), SkIntToScalar(10), - SkBlurDrawLooper::kIgnoreTransform_BlurFlag | - SkBlurDrawLooper::kOverrideColor_BlurFlag); + SkBlurDrawLooper::Create(SK_ColorBLUE, + SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(10)), + SkIntToScalar(5), SkIntToScalar(10), + SkBlurDrawLooper::kIgnoreTransform_BlurFlag | + SkBlurDrawLooper::kOverrideColor_BlurFlag); SkAutoUnref aurL1(shadowLoopers[1]); shadowLoopers[2] = - new SkBlurDrawLooper (SK_ColorBLACK, - SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(5)), - SkIntToScalar(5), - SkIntToScalar(10), - SkBlurDrawLooper::kIgnoreTransform_BlurFlag | - SkBlurDrawLooper::kHighQuality_BlurFlag); + SkBlurDrawLooper::Create(SK_ColorBLACK, + SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(5)), + SkIntToScalar(5), + SkIntToScalar(10), + SkBlurDrawLooper::kIgnoreTransform_BlurFlag | + SkBlurDrawLooper::kHighQuality_BlurFlag); SkAutoUnref aurL2(shadowLoopers[2]); shadowLoopers[3] = - new SkBlurDrawLooper (0x7FFF0000, - SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(5)), - SkIntToScalar(-5), SkIntToScalar(-10), - SkBlurDrawLooper::kIgnoreTransform_BlurFlag | - SkBlurDrawLooper::kOverrideColor_BlurFlag | - SkBlurDrawLooper::kHighQuality_BlurFlag); + SkBlurDrawLooper::Create(0x7FFF0000, + SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(5)), + SkIntToScalar(-5), SkIntToScalar(-10), + SkBlurDrawLooper::kIgnoreTransform_BlurFlag | + SkBlurDrawLooper::kOverrideColor_BlurFlag | + SkBlurDrawLooper::kHighQuality_BlurFlag); SkAutoUnref aurL3(shadowLoopers[3]); shadowLoopers[4] = - new SkBlurDrawLooper (SK_ColorBLACK, SkIntToScalar(0), - SkIntToScalar(5), SkIntToScalar(5), - SkBlurDrawLooper::kIgnoreTransform_BlurFlag | - SkBlurDrawLooper::kOverrideColor_BlurFlag | - SkBlurDrawLooper::kHighQuality_BlurFlag); + SkBlurDrawLooper::Create(SK_ColorBLACK, SkIntToScalar(0), + SkIntToScalar(5), SkIntToScalar(5), + SkBlurDrawLooper::kIgnoreTransform_BlurFlag | + SkBlurDrawLooper::kOverrideColor_BlurFlag | + SkBlurDrawLooper::kHighQuality_BlurFlag); SkAutoUnref aurL4(shadowLoopers[4]); static const struct { diff --git a/gm/tilemodes_scaled.cpp b/gm/tilemodes_scaled.cpp index bbb86a70fd..e9c6c9950a 100644 --- a/gm/tilemodes_scaled.cpp +++ b/gm/tilemodes_scaled.cpp @@ -13,6 +13,7 @@ #include "SkColorPriv.h" #include "SkColorFilter.h" #include "SkTypeface.h" +#include "SkBlurMask.h" // effects #include "SkGradientShader.h" @@ -55,10 +56,12 @@ static const SkColorType gColorTypes[] = { }; class ScaledTilingGM : public skiagm::GM { - SkBlurDrawLooper fLooper; + SkAutoTUnref<SkBlurDrawLooper> fLooper; public: ScaledTilingGM(bool powerOfTwoSize) - : fLooper(SkIntToScalar(1), SkIntToScalar(2), SkIntToScalar(2), 0x88000000) + : fLooper(SkBlurDrawLooper::Create(0x88000000, + SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(1)), + SkIntToScalar(2), SkIntToScalar(2))) , fPowerOfTwoSize(powerOfTwoSize) { } @@ -117,7 +120,7 @@ protected: SkString str; p.setAntiAlias(true); p.setDither(true); - p.setLooper(&fLooper); + p.setLooper(fLooper); str.printf("[%s,%s]", gModeNames[kx], gModeNames[ky]); p.setTextAlign(SkPaint::kCenter_Align); @@ -157,7 +160,7 @@ protected: SkPaint p; SkString str; p.setAntiAlias(true); - p.setLooper(&fLooper); + p.setLooper(fLooper); str.printf("%s, %s", gColorTypeNames[i], gFilterNames[j]); canvas->drawText(str.c_str(), str.size(), scale*x, scale*(y + r.height() * 2 / 3), p); } diff --git a/include/effects/SkBlurDrawLooper.h b/include/effects/SkBlurDrawLooper.h index 5469e2cf02..fe945c3801 100644 --- a/include/effects/SkBlurDrawLooper.h +++ b/include/effects/SkBlurDrawLooper.h @@ -35,12 +35,16 @@ public: kAll_BlurFlag = 0x07 }; - SkBlurDrawLooper(SkColor color, SkScalar sigma, SkScalar dx, SkScalar dy, - uint32_t flags = kNone_BlurFlag); + static SkBlurDrawLooper* Create(SkColor color, SkScalar sigma, SkScalar dx, SkScalar dy, + uint32_t flags = kNone_BlurFlag) { + return SkNEW_ARGS(SkBlurDrawLooper, (color, sigma, dx, dy, flags)); + } -// SK_ATTR_DEPRECATED("use sigma version") +#ifdef SK_SUPPORT_LEGACY_BLURDRAWLOOPERCONSTRUCTORS SkBlurDrawLooper(SkScalar radius, SkScalar dx, SkScalar dy, SkColor color, uint32_t flags = kNone_BlurFlag); +#endif + virtual ~SkBlurDrawLooper(); virtual SkDrawLooper::Context* createContext(SkCanvas*, void* storage) const SK_OVERRIDE; @@ -51,6 +55,9 @@ public: SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkBlurDrawLooper) protected: + SkBlurDrawLooper(SkColor color, SkScalar sigma, SkScalar dx, SkScalar dy, + uint32_t flags); + SkBlurDrawLooper(SkReadBuffer&); virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; diff --git a/include/effects/SkLayerDrawLooper.h b/include/effects/SkLayerDrawLooper.h index 1e76ce21e5..fe660a8aae 100644 --- a/include/effects/SkLayerDrawLooper.h +++ b/include/effects/SkLayerDrawLooper.h @@ -17,7 +17,6 @@ class SK_API SkLayerDrawLooper : public SkDrawLooper { public: SK_DECLARE_INST_COUNT(SkLayerDrawLooper) - SkLayerDrawLooper(); virtual ~SkLayerDrawLooper(); /** @@ -74,26 +73,6 @@ public: LayerInfo(); }; - /** - * Call for each layer you want to add (from top to bottom). - * This returns a paint you can modify, but that ptr is only valid until - * the next call made to addLayer(). - */ - SkPaint* addLayer(const LayerInfo&); - - /** - * This layer will draw with the original paint, at the specified offset - */ - void addLayer(SkScalar dx, SkScalar dy); - - /** - * This layer will with the original paint and no offset. - */ - void addLayer() { this->addLayer(0, 0); } - - /// Similar to addLayer, but adds a layer to the top. - SkPaint* addLayerOnTop(const LayerInfo&); - virtual SkDrawLooper::Context* createContext(SkCanvas*, void* storage) const SK_OVERRIDE; virtual size_t contextSize() const SK_OVERRIDE { return sizeof(LayerDrawLooperContext); } @@ -105,6 +84,8 @@ public: static SkFlattenable* CreateProc(SkReadBuffer& buffer); protected: + SkLayerDrawLooper(); + virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; private: diff --git a/samplecode/SampleTextOnPath.cpp b/samplecode/SampleTextOnPath.cpp index f2b9af6732..6d79e20755 100644 --- a/samplecode/SampleTextOnPath.cpp +++ b/samplecode/SampleTextOnPath.cpp @@ -35,10 +35,10 @@ static void textStrokePath(SkCanvas* canvas) { canvas->drawPath(path, paint); - paint.setLooper(new SkBlurDrawLooper(SK_ColorBLACK, - SkBlurMask::ConvertRadiusToSigma(0.002f), - 0.0f, - 0.0f))->unref(); + paint.setLooper(SkBlurDrawLooper::Create(SK_ColorBLACK, + SkBlurMask::ConvertRadiusToSigma(0.002f), + 0.0f, + 0.0f))->unref(); const char* text = "DRAWING STROKED TEXT WITH A BLUR ON A PATH"; size_t len = strlen(text); diff --git a/samplecode/SampleTiling.cpp b/samplecode/SampleTiling.cpp index faa8d80144..7d109fd50f 100644 --- a/samplecode/SampleTiling.cpp +++ b/samplecode/SampleTiling.cpp @@ -62,13 +62,13 @@ static const int gWidth = 32; static const int gHeight = 32; class TilingView : public SampleView { - SkAutoTUnref<SkPicture> fTextPicture; - SkBlurDrawLooper fLooper; + SkAutoTUnref<SkPicture> fTextPicture; + SkAutoTUnref<SkBlurDrawLooper> fLooper; public: TilingView() - : fLooper(0x88000000, - SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(1)), - SkIntToScalar(2), SkIntToScalar(2)) { + : fLooper(SkBlurDrawLooper::Create(0x88000000, + SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(1)), + SkIntToScalar(2), SkIntToScalar(2))) { for (size_t i = 0; i < SK_ARRAY_COUNT(gColorTypes); i++) { makebm(&fTexture[i], gColorTypes[i], gWidth, gHeight); } @@ -116,7 +116,7 @@ protected: SkString str; p.setAntiAlias(true); p.setDither(true); - p.setLooper(&fLooper); + p.setLooper(fLooper); str.printf("[%s,%s]", gModeNames[kx], gModeNames[ky]); p.setTextAlign(SkPaint::kCenter_Align); @@ -150,7 +150,7 @@ protected: SkPaint p; SkString str; p.setAntiAlias(true); - p.setLooper(&fLooper); + p.setLooper(fLooper); str.printf("%s, %s", gConfigNames[i], gFilterNames[j]); textCanvas->drawText(str.c_str(), str.size(), x, y + r.height() * 2 / 3, p); } diff --git a/samplecode/SampleUnpremul.cpp b/samplecode/SampleUnpremul.cpp index f2f60cc312..0b1848df95 100644 --- a/samplecode/SampleUnpremul.cpp +++ b/samplecode/SampleUnpremul.cpp @@ -85,10 +85,10 @@ protected: SkPaint paint; paint.setAntiAlias(true); paint.setTextSize(SkIntToScalar(24)); - SkAutoTUnref<SkBlurDrawLooper> looper(SkNEW_ARGS(SkBlurDrawLooper, - (SK_ColorBLUE, - SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(2)), - 0, 0))); + SkAutoTUnref<SkBlurDrawLooper> looper( + SkBlurDrawLooper::Create(SK_ColorBLUE, + SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(2)), + 0, 0)); paint.setLooper(looper); SkScalar height = paint.getFontMetrics(NULL); if (!fDecodeSucceeded) { diff --git a/src/effects/SkBlurDrawLooper.cpp b/src/effects/SkBlurDrawLooper.cpp index 2caa62e5ad..5cfb8d884d 100644 --- a/src/effects/SkBlurDrawLooper.cpp +++ b/src/effects/SkBlurDrawLooper.cpp @@ -17,10 +17,12 @@ #include "SkString.h" #include "SkStringUtils.h" +#ifdef SK_SUPPORT_LEGACY_BLURDRAWLOOPERCONSTRUCTORS SkBlurDrawLooper::SkBlurDrawLooper(SkScalar radius, SkScalar dx, SkScalar dy, SkColor color, uint32_t flags) { this->init(SkBlurMask::ConvertRadiusToSigma(radius), dx, dy, color, flags); } +#endif SkBlurDrawLooper::SkBlurDrawLooper(SkColor color, SkScalar sigma, SkScalar dx, SkScalar dy, uint32_t flags) { diff --git a/src/effects/SkLayerDrawLooper.cpp b/src/effects/SkLayerDrawLooper.cpp index 962ca293d8..5fbb550f75 100644 --- a/src/effects/SkLayerDrawLooper.cpp +++ b/src/effects/SkLayerDrawLooper.cpp @@ -36,44 +36,6 @@ SkLayerDrawLooper::~SkLayerDrawLooper() { } } -SkPaint* SkLayerDrawLooper::addLayer(const LayerInfo& info) { - fCount += 1; - - Rec* rec = SkNEW(Rec); - rec->fNext = fRecs; - rec->fInfo = info; - fRecs = rec; - if (NULL == fTopRec) { - fTopRec = rec; - } - - return &rec->fPaint; -} - -void SkLayerDrawLooper::addLayer(SkScalar dx, SkScalar dy) { - LayerInfo info; - - info.fOffset.set(dx, dy); - (void)this->addLayer(info); -} - -SkPaint* SkLayerDrawLooper::addLayerOnTop(const LayerInfo& info) { - fCount += 1; - - Rec* rec = SkNEW(Rec); - rec->fNext = NULL; - rec->fInfo = info; - if (NULL == fRecs) { - fRecs = rec; - } else { - SkASSERT(NULL != fTopRec); - fTopRec->fNext = rec; - } - fTopRec = rec; - - return &rec->fPaint; -} - SkLayerDrawLooper::Context* SkLayerDrawLooper::createContext(SkCanvas* canvas, void* storage) const { canvas->save(SkCanvas::kMatrix_SaveFlag); return SkNEW_PLACEMENT_ARGS(storage, LayerDrawLooperContext, (this)); diff --git a/tests/PaintTest.cpp b/tests/PaintTest.cpp index c41e23ac54..cfbe23aa6f 100644 --- a/tests/PaintTest.cpp +++ b/tests/PaintTest.cpp @@ -147,7 +147,8 @@ DEF_TEST(Paint_copy, reporter) { paint.setTextAlign(SkPaint::kLeft_Align); paint.setStrokeWidth(SkIntToScalar(2)); // set a few pointers - SkLayerDrawLooper* looper = new SkLayerDrawLooper(); + SkLayerDrawLooper::Builder looperBuilder; + SkLayerDrawLooper* looper = looperBuilder.detachLooper(); paint.setLooper(looper)->unref(); SkMaskFilter* mask = SkBlurMaskFilter::Create(SkBlurMaskFilter::kNormal_BlurStyle, SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(1))); |