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
diff --git a/bench/BlurRoundRectBench.cpp b/bench/BlurRoundRectBench.cpp
index 29c0080..a3d0ba9 100644
--- a/bench/BlurRoundRectBench.cpp
+++ b/bench/BlurRoundRectBench.cpp
@@ -40,7 +40,7 @@
     }
 
     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 @@
             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 @@
         }
         {
             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 ee79ca9..87f5fee 100644
--- a/bench/RectoriBench.cpp
+++ b/bench/RectoriBench.cpp
@@ -71,7 +71,7 @@
     };
 
     SkLayerDrawLooper* createLooper(SkScalar xOff, SkScalar sigma) {
-        SkLayerDrawLooper* looper = new SkLayerDrawLooper;
+        SkLayerDrawLooper::Builder looperBuilder;
 
         //-----------------------------------------------
         SkLayerDrawLooper::LayerInfo info;
@@ -83,7 +83,7 @@
         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 @@
         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 6c3903f..f688380 100644
--- a/gm/blurroundrect.cpp
+++ b/gm/blurroundrect.cpp
@@ -53,7 +53,7 @@
     }
 
     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 @@
             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 @@
         }
         {
             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 b4cfef2..ce833db 100644
--- a/gm/circles.cpp
+++ b/gm/circles.cpp
@@ -81,12 +81,12 @@
         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 678d2ad..d3a4475 100644
--- a/gm/drawlooper.cpp
+++ b/gm/drawlooper.cpp
@@ -72,7 +72,7 @@
             { 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 @@
 
         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 @@
                 paint->setMaskFilter(mf)->unref();
             }
         }
+        fLooper = looperBuilder.detachLooper();
     }
 
     typedef GM INHERITED;
diff --git a/gm/megalooper.cpp b/gm/megalooper.cpp
index 12ccf2d..e825550 100644
--- a/gm/megalooper.cpp
+++ b/gm/megalooper.cpp
@@ -163,7 +163,7 @@
 
     // 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 @@
         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 @@
 
     // 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 @@
 
         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 @@
             paint->setColorFilter(cf)->unref();
         }
 
-        return looper;
+        return looperBuilder.detachLooper();
     }
 
     typedef GM INHERITED;
diff --git a/gm/rects.cpp b/gm/rects.cpp
index febf553..9600dd5 100644
--- a/gm/rects.cpp
+++ b/gm/rects.cpp
@@ -95,12 +95,12 @@
             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 d0d23a8..44fa8e2 100644
--- a/gm/shadows.cpp
+++ b/gm/shadows.cpp
@@ -47,42 +47,42 @@
     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 bbb86a7..e9c6c99 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 @@
 };
 
 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 @@
                 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 @@
                     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 5469e2c..fe945c3 100644
--- a/include/effects/SkBlurDrawLooper.h
+++ b/include/effects/SkBlurDrawLooper.h
@@ -35,12 +35,16 @@
         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 @@
     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 1e76ce2..fe660a8 100644
--- a/include/effects/SkLayerDrawLooper.h
+++ b/include/effects/SkLayerDrawLooper.h
@@ -17,7 +17,6 @@
 public:
     SK_DECLARE_INST_COUNT(SkLayerDrawLooper)
 
-            SkLayerDrawLooper();
     virtual ~SkLayerDrawLooper();
 
     /**
@@ -74,26 +73,6 @@
         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 @@
     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 f2b9af6..6d79e20 100644
--- a/samplecode/SampleTextOnPath.cpp
+++ b/samplecode/SampleTextOnPath.cpp
@@ -35,10 +35,10 @@
 
     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 faa8d80..7d109fd 100644
--- a/samplecode/SampleTiling.cpp
+++ b/samplecode/SampleTiling.cpp
@@ -62,13 +62,13 @@
 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 @@
                     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 @@
                     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 f2f60cc..0b1848d 100644
--- a/samplecode/SampleUnpremul.cpp
+++ b/samplecode/SampleUnpremul.cpp
@@ -85,10 +85,10 @@
         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 2caa62e..5cfb8d8 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 962ca29..5fbb550 100644
--- a/src/effects/SkLayerDrawLooper.cpp
+++ b/src/effects/SkLayerDrawLooper.cpp
@@ -36,44 +36,6 @@
     }
 }
 
-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 c41e23a..cfbe23a 100644
--- a/tests/PaintTest.cpp
+++ b/tests/PaintTest.cpp
@@ -147,7 +147,8 @@
     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)));