Factory methods for heap-allocated SkPathEffect and SkXfermode 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 SkPathEffect, SkXfermode and
their subclasses non-public and instead provides factory methods for
creating these objects on the heap. We temporarily keep the constructors
of the following classes public to not break Chrome/Blink:

SkXfermode
SkCornerPathEffect
SkDashPathEffect

BUG=skia:2187
R=scroggo@google.com, reed@google.com, mtklein@google.com, bungeman@google.com

Author: dominikg@chromium.org

Review URL: https://codereview.chromium.org/166583002

git-svn-id: http://skia.googlecode.com/svn/trunk@13519 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/bench/DashBench.cpp b/bench/DashBench.cpp
index 2e4bc37..365eee9 100644
--- a/bench/DashBench.cpp
+++ b/bench/DashBench.cpp
@@ -71,8 +71,8 @@
         SkPath path;
         this->makePath(&path);
 
-        paint.setPathEffect(new SkDashPathEffect(fIntervals.begin(),
-                                                 fIntervals.count(), 0))->unref();
+        paint.setPathEffect(SkDashPathEffect::Create(fIntervals.begin(),
+                                                     fIntervals.count(), 0))->unref();
 
         if (fDoClip) {
             SkRect r = path.getBounds();
@@ -186,7 +186,7 @@
         proc(&fPath);
 
         SkScalar vals[] = { SkIntToScalar(4), SkIntToScalar(4) };
-        fPE.reset(new SkDashPathEffect(vals, 2, 0));
+        fPE.reset(SkDashPathEffect::Create(vals, 2, 0));
     }
 
 protected:
@@ -224,7 +224,7 @@
         fIsRound = isRound;
 
         SkScalar vals[] = { SK_Scalar1, SK_Scalar1 };
-        fPE.reset(new SkDashPathEffect(vals, 2, 0));
+        fPE.reset(SkDashPathEffect::Create(vals, 2, 0));
     }
 
 protected:
@@ -263,7 +263,7 @@
         fDoAA = doAA;
 
         SkScalar vals[] = { SkIntToScalar(dashLength), SkIntToScalar(dashLength) };
-        fPathEffect.reset(new SkDashPathEffect(vals, 2, SK_Scalar1, false));
+        fPathEffect.reset(SkDashPathEffect::Create(vals, 2, SK_Scalar1, false));
     }
 
 protected:
@@ -323,8 +323,8 @@
         // deliberately pick intervals that won't be caught by asPoints(), so
         // we can test the filterPath code-path.
         const SkScalar intervals[] = { 2, 1, 1, 1 };
-        fPathEffect.reset(new SkDashPathEffect(intervals,
-                                               SK_ARRAY_COUNT(intervals), 0));
+        fPathEffect.reset(SkDashPathEffect::Create(intervals,
+                                                   SK_ARRAY_COUNT(intervals), 0));
 
         SkScalar cx = 640 / 2;  // center X
         SkScalar cy = 480 / 2;  // center Y
diff --git a/experimental/PdfViewer/SkPdfGraphicsState.cpp b/experimental/PdfViewer/SkPdfGraphicsState.cpp
index b52f22c..76c4120 100644
--- a/experimental/PdfViewer/SkPdfGraphicsState.cpp
+++ b/experimental/PdfViewer/SkPdfGraphicsState.cpp
@@ -25,9 +25,9 @@
         paint->setStrokeWidth(SkDoubleToScalar(fLineWidth));
         // TODO(edisonn): perf, avoid allocs of the intervals
         if (fDashArrayLength > 0) {
-            paint->setPathEffect(new SkDashPathEffect(fDashArray,
-                                                      fDashArrayLength,
-                                                      fDashPhase))->unref();
+            paint->setPathEffect(SkDashPathEffect::Create(fDashArray,
+                                                          fDashArrayLength,
+                                                          fDashPhase))->unref();
         }
     }
 
diff --git a/gm/dashcubics.cpp b/gm/dashcubics.cpp
index 5d874d4..f99c0c3 100644
--- a/gm/dashcubics.cpp
+++ b/gm/dashcubics.cpp
@@ -43,7 +43,7 @@
         SkParsePath::FromSVGString(d, &path);
 
         SkScalar intervals[] = { 5, 10 };
-        SkPathEffect* pe = new SkDashPathEffect(intervals, 2, 0);
+        SkPathEffect* pe = SkDashPathEffect::Create(intervals, 2, 0);
 
         SkPaint paint;
         paint.setAntiAlias(true);
diff --git a/gm/dashing.cpp b/gm/dashing.cpp
index fa88e9e..f690852 100644
--- a/gm/dashing.cpp
+++ b/gm/dashing.cpp
@@ -19,7 +19,7 @@
         SkIntToScalar(off),
     };
 
-    p.setPathEffect(new SkDashPathEffect(intervals, 2, 0))->unref();
+    p.setPathEffect(SkDashPathEffect::Create(intervals, 2, 0))->unref();
     canvas->drawLine(0, 0, finalX, 0, p);
 }
 
@@ -155,7 +155,7 @@
                 vals[i] = SkIntToScalar(*intervals++);
             }
             SkScalar phase = vals[0] / 2;
-            paint.setPathEffect(new SkDashPathEffect(vals, count, phase))->unref();
+            paint.setPathEffect(SkDashPathEffect::Create(vals, count, phase))->unref();
 
             for (size_t x = 0; x < SK_ARRAY_COUNT(gProc); ++x) {
                 SkPath path;
@@ -202,7 +202,7 @@
 
         SkScalar intervals[2] = { dashLength, dashLength };
 
-        p.setPathEffect(new SkDashPathEffect(intervals, 2, phase, false))->unref();
+        p.setPathEffect(SkDashPathEffect::Create(intervals, 2, phase, false))->unref();
 
         SkPoint pts[2];
 
diff --git a/gm/patheffects.cpp b/gm/patheffects.cpp
index a1fb675..4c5cd45 100644
--- a/gm/patheffects.cpp
+++ b/gm/patheffects.cpp
@@ -17,10 +17,10 @@
 
 static void compose_pe(SkPaint* paint) {
     SkPathEffect* pe = paint->getPathEffect();
-    SkPathEffect* corner = new SkCornerPathEffect(25);
+    SkPathEffect* corner = SkCornerPathEffect::Create(25);
     SkPathEffect* compose;
     if (pe) {
-        compose = new SkComposePathEffect(pe, corner);
+        compose = SkComposePathEffect::Create(pe, corner);
         corner->unref();
     } else {
         compose = corner;
@@ -45,8 +45,8 @@
 static void dash_pe(SkPaint* paint) {
     SkScalar inter[] = { 20, 10, 10, 10 };
     paint->setStrokeWidth(12);
-    paint->setPathEffect(new SkDashPathEffect(inter, SK_ARRAY_COUNT(inter),
-                                              0))->unref();
+    paint->setPathEffect(SkDashPathEffect::Create(inter, SK_ARRAY_COUNT(inter),
+                                                  0))->unref();
     compose_pe(paint);
 }
 
@@ -69,7 +69,7 @@
     path.offset(SkIntToScalar(-6), 0);
     scale(&path, 1.5f);
 
-    paint->setPathEffect(new SkPath1DPathEffect(path, SkIntToScalar(21), 0,
+    paint->setPathEffect(SkPath1DPathEffect::Create(path, SkIntToScalar(21), 0,
                                 SkPath1DPathEffect::kRotate_Style))->unref();
     compose_pe(paint);
 }
@@ -83,7 +83,7 @@
 }
 
 static void discrete_pe(SkPaint* paint) {
-    paint->setPathEffect(new SkDiscretePathEffect(10, 4))->unref();
+    paint->setPathEffect(SkDiscretePathEffect::Create(10, 4))->unref();
 }
 
 static SkPathEffect* MakeTileEffect() {
@@ -93,7 +93,7 @@
     SkPath path;
     path.addCircle(0, 0, SkIntToScalar(5));
 
-    return new SkPath2DPathEffect(m, path);
+    return SkPath2DPathEffect::Create(m, path);
 }
 
 static void tile_pe(SkPaint* paint) {
diff --git a/gm/texteffects.cpp b/gm/texteffects.cpp
index 094fe7b..cf9ec5a 100644
--- a/gm/texteffects.cpp
+++ b/gm/texteffects.cpp
@@ -77,7 +77,7 @@
 static void r5(SkLayerRasterizer* rast, SkPaint& p) {
     rast->addLayer(p);
 
-    p.setPathEffect(new SkDiscretePathEffect(SK_Scalar1*4, SK_Scalar1*3))->unref();
+    p.setPathEffect(SkDiscretePathEffect::Create(SK_Scalar1*4, SK_Scalar1*3))->unref();
     p.setXfermodeMode(SkXfermode::kSrcOut_Mode);
     rast->addLayer(p);
 }
@@ -98,7 +98,7 @@
 static SkPathEffect* MakeDotEffect(SkScalar radius, const SkMatrix& matrix) {
     SkPath path;
     path.addCircle(0, 0, radius);
-    return new SkPath2DPathEffect(matrix, path);
+    return SkPath2DPathEffect::Create(matrix, path);
 }
 
 static void r7(SkLayerRasterizer* rast, SkPaint& p) {
@@ -132,7 +132,7 @@
     SkMatrix    lattice;
     lattice.setScale(SK_Scalar1, SK_Scalar1*6, 0, 0);
     lattice.postRotate(SkIntToScalar(30), 0, 0);
-    p.setPathEffect(new SkLine2DPathEffect(SK_Scalar1*2, lattice))->unref();
+    p.setPathEffect(SkLine2DPathEffect::Create(SK_Scalar1*2, lattice))->unref();
     p.setXfermodeMode(SkXfermode::kClear_Mode);
     rast->addLayer(p);
 
diff --git a/include/core/SkPathEffect.h b/include/core/SkPathEffect.h
index 3f38f3a..86ccf86 100644
--- a/include/core/SkPathEffect.h
+++ b/include/core/SkPathEffect.h
@@ -31,8 +31,6 @@
 public:
     SK_DECLARE_INST_COUNT(SkPathEffect)
 
-    SkPathEffect() {}
-
     /**
      *  Given a src path (input) and a stroke-rec (input and output), apply
      *  this effect to the src path, returning the new path in dst, and return
@@ -109,6 +107,7 @@
     SK_DEFINE_FLATTENABLE_TYPE(SkPathEffect)
 
 protected:
+    SkPathEffect() {}
     SkPathEffect(SkReadBuffer& buffer) : INHERITED(buffer) {}
 
 private:
@@ -127,10 +126,10 @@
 */
 class SkPairPathEffect : public SkPathEffect {
 public:
-    SkPairPathEffect(SkPathEffect* pe0, SkPathEffect* pe1);
     virtual ~SkPairPathEffect();
 
 protected:
+    SkPairPathEffect(SkPathEffect* pe0, SkPathEffect* pe1);
     SkPairPathEffect(SkReadBuffer&);
     virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
 
@@ -153,8 +152,9 @@
         The reference counts for outer and inner are both incremented in the constructor,
         and decremented in the destructor.
     */
-    SkComposePathEffect(SkPathEffect* outer, SkPathEffect* inner)
-        : INHERITED(outer, inner) {}
+    static SkComposePathEffect* Create(SkPathEffect* outer, SkPathEffect* inner) {
+        return SkNEW_ARGS(SkComposePathEffect, (outer, inner));
+    }
 
     virtual bool filterPath(SkPath* dst, const SkPath& src,
                             SkStrokeRec*, const SkRect*) const SK_OVERRIDE;
@@ -164,6 +164,12 @@
 protected:
     SkComposePathEffect(SkReadBuffer& buffer) : INHERITED(buffer) {}
 
+#ifdef SK_SUPPORT_LEGACY_PUBLICEFFECTCONSTRUCTORS
+public:
+#endif
+    SkComposePathEffect(SkPathEffect* outer, SkPathEffect* inner)
+        : INHERITED(outer, inner) {}
+
 private:
     // illegal
     SkComposePathEffect(const SkComposePathEffect&);
@@ -184,8 +190,9 @@
         The reference counts for first and second are both incremented in the constructor,
         and decremented in the destructor.
     */
-    SkSumPathEffect(SkPathEffect* first, SkPathEffect* second)
-        : INHERITED(first, second) {}
+    static SkSumPathEffect* Create(SkPathEffect* first, SkPathEffect* second) {
+        return SkNEW_ARGS(SkSumPathEffect, (first, second));
+    }
 
     virtual bool filterPath(SkPath* dst, const SkPath& src,
                             SkStrokeRec*, const SkRect*) const SK_OVERRIDE;
@@ -195,6 +202,12 @@
 protected:
     SkSumPathEffect(SkReadBuffer& buffer) : INHERITED(buffer) {}
 
+#ifdef SK_SUPPORT_LEGACY_PUBLICEFFECTCONSTRUCTORS
+public:
+#endif
+    SkSumPathEffect(SkPathEffect* first, SkPathEffect* second)
+        : INHERITED(first, second) {}
+
 private:
     // illegal
     SkSumPathEffect(const SkSumPathEffect&);
diff --git a/include/core/SkXfermode.h b/include/core/SkXfermode.h
index 31b8081..86c08dd 100644
--- a/include/core/SkXfermode.h
+++ b/include/core/SkXfermode.h
@@ -32,8 +32,6 @@
 public:
     SK_DECLARE_INST_COUNT(SkXfermode)
 
-    SkXfermode() {}
-
     virtual void xfer32(SkPMColor dst[], const SkPMColor src[], int count,
                         const SkAlpha aa[]) const;
     virtual void xfer16(uint16_t dst[], const SkPMColor src[], int count,
@@ -230,6 +228,11 @@
     */
     virtual SkPMColor xferColor(SkPMColor src, SkPMColor dst) const;
 
+#ifdef SK_SUPPORT_LEGACY_PUBLICEFFECTCONSTRUCTORS
+public:
+#endif
+    SkXfermode() {}
+
 private:
     enum {
         kModeCount = kLastMode + 1
@@ -250,7 +253,9 @@
 */
 class SkProcXfermode : public SkXfermode {
 public:
-    SkProcXfermode(SkXfermodeProc proc) : fProc(proc) {}
+    static SkProcXfermode* Create(SkXfermodeProc proc) {
+        return SkNEW_ARGS(SkProcXfermode, (proc));
+    }
 
     // overrides from SkXfermode
     virtual void xfer32(SkPMColor dst[], const SkPMColor src[], int count,
@@ -276,6 +281,11 @@
         return fProc;
     }
 
+#ifdef SK_SUPPORT_LEGACY_PUBLICEFFECTCONSTRUCTORS
+public:
+#endif
+    SkProcXfermode(SkXfermodeProc proc) : fProc(proc) {}
+
 private:
     SkXfermodeProc  fProc;
 
diff --git a/include/effects/Sk1DPathEffect.h b/include/effects/Sk1DPathEffect.h
index 4ac8f73..ce49460 100644
--- a/include/effects/Sk1DPathEffect.h
+++ b/include/effects/Sk1DPathEffect.h
@@ -52,7 +52,10 @@
         @param style how to transform path at each point (based on the current
                      position and tangent)
     */
-    SkPath1DPathEffect(const SkPath& path, SkScalar advance, SkScalar phase, Style);
+    static SkPath1DPathEffect* Create(const SkPath& path, SkScalar advance, SkScalar phase,
+                                      Style style) {
+        return SkNEW_ARGS(SkPath1DPathEffect, (path, advance, phase, style));
+    }
 
     virtual bool filterPath(SkPath*, const SkPath&,
                             SkStrokeRec*, const SkRect*) const SK_OVERRIDE;
@@ -67,6 +70,11 @@
     virtual SkScalar begin(SkScalar contourLength) const SK_OVERRIDE;
     virtual SkScalar next(SkPath*, SkScalar, SkPathMeasure&) const SK_OVERRIDE;
 
+#ifdef SK_SUPPORT_LEGACY_PUBLICEFFECTCONSTRUCTORS
+public:
+#endif
+    SkPath1DPathEffect(const SkPath& path, SkScalar advance, SkScalar phase, Style);
+
 private:
     SkPath      fPath;          // copied from constructor
     SkScalar    fAdvance;       // copied from constructor
diff --git a/include/effects/Sk2DPathEffect.h b/include/effects/Sk2DPathEffect.h
index 859b5cd..f037e33 100644
--- a/include/effects/Sk2DPathEffect.h
+++ b/include/effects/Sk2DPathEffect.h
@@ -14,7 +14,9 @@
 
 class SK_API Sk2DPathEffect : public SkPathEffect {
 public:
-    Sk2DPathEffect(const SkMatrix& mat);
+    static Sk2DPathEffect* Create(const SkMatrix& mat) {
+        return SkNEW_ARGS(Sk2DPathEffect, (mat));
+    }
 
     virtual bool filterPath(SkPath*, const SkPath&,
                             SkStrokeRec*, const SkRect*) const SK_OVERRIDE;
@@ -44,6 +46,11 @@
     Sk2DPathEffect(SkReadBuffer&);
     virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
 
+#ifdef SK_SUPPORT_LEGACY_PUBLICEFFECTCONSTRUCTORS
+public:
+#endif
+    Sk2DPathEffect(const SkMatrix& mat);
+
 private:
     SkMatrix    fMatrix, fInverse;
     bool        fMatrixIsInvertible;
@@ -58,8 +65,9 @@
 
 class SK_API SkLine2DPathEffect : public Sk2DPathEffect {
 public:
-    SkLine2DPathEffect(SkScalar width, const SkMatrix& matrix)
-    : Sk2DPathEffect(matrix), fWidth(width) {}
+    static SkLine2DPathEffect* Create(SkScalar width, const SkMatrix& matrix) {
+        return SkNEW_ARGS(SkLine2DPathEffect, (width, matrix));
+    }
 
     virtual bool filterPath(SkPath* dst, const SkPath& src,
                             SkStrokeRec*, const SkRect*) const SK_OVERRIDE;
@@ -73,6 +81,12 @@
 
     virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
 
+#ifdef SK_SUPPORT_LEGACY_PUBLICEFFECTCONSTRUCTORS
+public:
+#endif
+    SkLine2DPathEffect(SkScalar width, const SkMatrix& matrix)
+    : Sk2DPathEffect(matrix), fWidth(width) {}
+
 private:
     SkScalar fWidth;
 
@@ -85,7 +99,9 @@
      *  Stamp the specified path to fill the shape, using the matrix to define
      *  the latice.
      */
-    SkPath2DPathEffect(const SkMatrix&, const SkPath&);
+    static SkPath2DPathEffect* Create(const SkMatrix& matrix, const SkPath& path) {
+        return SkNEW_ARGS(SkPath2DPathEffect, (matrix, path));
+    }
 
     SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkPath2DPathEffect)
 
@@ -95,6 +111,11 @@
 
     virtual void next(const SkPoint&, int u, int v, SkPath*) const SK_OVERRIDE;
 
+#ifdef SK_SUPPORT_LEGACY_PUBLICEFFECTCONSTRUCTORS
+public:
+#endif
+    SkPath2DPathEffect(const SkMatrix&, const SkPath&);
+
 private:
     SkPath  fPath;
 
diff --git a/include/effects/SkAvoidXfermode.h b/include/effects/SkAvoidXfermode.h
index afc3fc9..2fa20b9 100644
--- a/include/effects/SkAvoidXfermode.h
+++ b/include/effects/SkAvoidXfermode.h
@@ -37,7 +37,9 @@
                 Tolerance near 0: draw only on colors that are nearly identical to the op-color
                 Tolerance near 255: draw on any colors even remotely similar to the op-color
      */
-    SkAvoidXfermode(SkColor opColor, U8CPU tolerance, Mode mode);
+    static SkAvoidXfermode* Create(SkColor opColor, U8CPU tolerance, Mode mode) {
+        return SkNEW_ARGS(SkAvoidXfermode, (opColor, tolerance, mode));
+    }
 
     // overrides from SkXfermode
     virtual void xfer32(SkPMColor dst[], const SkPMColor src[], int count,
@@ -54,6 +56,11 @@
     SkAvoidXfermode(SkReadBuffer&);
     virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
 
+#ifdef SK_SUPPORT_LEGACY_PUBLICEFFECTCONSTRUCTORS
+public:
+#endif
+    SkAvoidXfermode(SkColor opColor, U8CPU tolerance, Mode mode);
+
 private:
     SkColor     fOpColor;
     uint32_t    fDistMul;   // x.14
diff --git a/include/effects/SkCornerPathEffect.h b/include/effects/SkCornerPathEffect.h
index dcb7c9f..c77505b 100644
--- a/include/effects/SkCornerPathEffect.h
+++ b/include/effects/SkCornerPathEffect.h
@@ -20,7 +20,9 @@
     /** radius must be > 0 to have an effect. It specifies the distance from each corner
         that should be "rounded".
     */
-    SkCornerPathEffect(SkScalar radius);
+    static SkCornerPathEffect* Create(SkScalar radius) {
+        return SkNEW_ARGS(SkCornerPathEffect, (radius));
+    }
     virtual ~SkCornerPathEffect();
 
     virtual bool filterPath(SkPath* dst, const SkPath& src,
@@ -32,6 +34,11 @@
     SkCornerPathEffect(SkReadBuffer&);
     virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
 
+#ifdef SK_SUPPORT_LEGACY_PUBLICEFFECTCONSTRUCTORS
+public:
+#endif
+    SkCornerPathEffect(SkScalar radius);
+
 private:
     SkScalar    fRadius;
 
diff --git a/include/effects/SkDashPathEffect.h b/include/effects/SkDashPathEffect.h
index 818e073..a1c5482 100644
--- a/include/effects/SkDashPathEffect.h
+++ b/include/effects/SkDashPathEffect.h
@@ -36,8 +36,10 @@
 
         Note: only affects stroked paths.
     */
-    SkDashPathEffect(const SkScalar intervals[], int count, SkScalar phase,
-                     bool scaleToFit = false);
+    static SkDashPathEffect* Create(const SkScalar intervals[], int count,
+                                    SkScalar phase, bool scaleToFit = false) {
+        return SkNEW_ARGS(SkDashPathEffect, (intervals, count, phase, scaleToFit));
+    }
     virtual ~SkDashPathEffect();
 
     virtual bool filterPath(SkPath* dst, const SkPath& src,
@@ -55,6 +57,12 @@
     SkDashPathEffect(SkReadBuffer&);
     virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
 
+#ifdef SK_SUPPORT_LEGACY_PUBLICEFFECTCONSTRUCTORS
+public:
+#endif
+    SkDashPathEffect(const SkScalar intervals[], int count, SkScalar phase,
+                     bool scaleToFit = false);
+
 private:
     SkScalar*   fIntervals;
     int32_t     fCount;
diff --git a/include/effects/SkDiscretePathEffect.h b/include/effects/SkDiscretePathEffect.h
index 60eb852..126b408 100644
--- a/include/effects/SkDiscretePathEffect.h
+++ b/include/effects/SkDiscretePathEffect.h
@@ -20,7 +20,9 @@
         away from the original path by a maximum of deviation.
         Note: works on filled or framed paths
     */
-    SkDiscretePathEffect(SkScalar segLength, SkScalar deviation);
+    static SkDiscretePathEffect* Create(SkScalar segLength, SkScalar deviation) {
+        return SkNEW_ARGS(SkDiscretePathEffect, (segLength, deviation));
+    }
 
     virtual bool filterPath(SkPath* dst, const SkPath& src,
                             SkStrokeRec*, const SkRect*) const SK_OVERRIDE;
@@ -31,6 +33,11 @@
     SkDiscretePathEffect(SkReadBuffer&);
     virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
 
+#ifdef SK_SUPPORT_LEGACY_PUBLICEFFECTCONSTRUCTORS
+public:
+#endif
+    SkDiscretePathEffect(SkScalar segLength, SkScalar deviation);
+
 private:
     SkScalar fSegLength, fPerterb;
 
diff --git a/include/effects/SkPixelXorXfermode.h b/include/effects/SkPixelXorXfermode.h
index 9472d94..cfd59ec 100644
--- a/include/effects/SkPixelXorXfermode.h
+++ b/include/effects/SkPixelXorXfermode.h
@@ -17,7 +17,9 @@
 */
 class SK_API SkPixelXorXfermode : public SkXfermode {
 public:
-    SkPixelXorXfermode(SkColor opColor) : fOpColor(opColor) {}
+    static SkPixelXorXfermode* Create(SkColor opColor) {
+        return SkNEW_ARGS(SkPixelXorXfermode, (opColor));
+    }
 
     SK_DEVELOPER_TO_STRING()
     SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkPixelXorXfermode)
@@ -29,6 +31,11 @@
     // override from SkXfermode
     virtual SkPMColor xferColor(SkPMColor src, SkPMColor dst) const;
 
+#ifdef SK_SUPPORT_LEGACY_PUBLICEFFECTCONSTRUCTORS
+public:
+#endif
+    SkPixelXorXfermode(SkColor opColor) : fOpColor(opColor) {}
+
 private:
     SkColor fOpColor;
 
diff --git a/samplecode/SampleAll.cpp b/samplecode/SampleAll.cpp
index 6410670..bb5aadd 100644
--- a/samplecode/SampleAll.cpp
+++ b/samplecode/SampleAll.cpp
@@ -144,7 +144,7 @@
 static void r5(SkLayerRasterizer* rast, SkPaint& p) {
     rast->addLayer(p);
 
-    p.setPathEffect(new SkDiscretePathEffect(SK_Scalar1*4, SK_Scalar1*3))->unref();
+    p.setPathEffect(SkDiscretePathEffect::Create(SK_Scalar1*4, SK_Scalar1*3))->unref();
     p.setXfermodeMode(SkXfermode::kSrcOut_Mode);
     rast->addLayer(p);
 }
@@ -217,7 +217,7 @@
     SkMatrix    lattice;
     lattice.setScale(SK_Scalar1, SK_Scalar1*6, 0, 0);
     lattice.postRotate(SkIntToScalar(30), 0, 0);
-    p.setPathEffect(new SkLine2DPathEffect(SK_Scalar1*2, lattice))->unref();
+    p.setPathEffect(SkLine2DPathEffect::Create(SK_Scalar1*2, lattice))->unref();
     p.setXfermodeMode(SkXfermode::kClear_Mode);
     rast->addLayer(p);
 
@@ -550,11 +550,11 @@
             path.lineTo(SkIntToScalar(gXY[i]), SkIntToScalar(gXY[i+1]));
         path.close();
         path.offset(SkIntToScalar(-6), 0);
-        SkPathEffect* outer = new SkPath1DPathEffect(path, SkIntToScalar(12),
+        SkPathEffect* outer = SkPath1DPathEffect::Create(path, SkIntToScalar(12),
             gPhase, SkPath1DPathEffect::kRotate_Style);
-        SkPathEffect* inner = new SkDiscretePathEffect(SkIntToScalar(2),
+        SkPathEffect* inner = SkDiscretePathEffect::Create(SkIntToScalar(2),
             SkIntToScalar(1)/10); // SkCornerPathEffect(SkIntToScalar(2));
-        SkPathEffect* result = new SkComposePathEffect(outer, inner);
+        SkPathEffect* result = SkComposePathEffect::Create(outer, inner);
         outer->unref();
         inner->unref();
         return result;
@@ -627,12 +627,12 @@
         canvas->restore();
 
         if (1) {
-            SkAvoidXfermode   mode(SK_ColorWHITE, 0xFF,
-                                   SkAvoidXfermode::kTargetColor_Mode);
+            SkAutoTUnref<SkAvoidXfermode> mode(SkAvoidXfermode::Create(SK_ColorWHITE, 0xFF,
+                                   SkAvoidXfermode::kTargetColor_Mode));
             SkPaint paint;
             x += SkIntToScalar(20);
             SkRect  r = { x, 0, x + SkIntToScalar(360), SkIntToScalar(700) };
-            paint.setXfermode(&mode);
+            paint.setXfermode(mode);
             paint.setColor(SK_ColorGREEN);
             paint.setAntiAlias(true);
             canvas->drawOval(r, paint);
diff --git a/samplecode/SampleAvoid.cpp b/samplecode/SampleAvoid.cpp
index 879481b..aa7ca0e 100644
--- a/samplecode/SampleAvoid.cpp
+++ b/samplecode/SampleAvoid.cpp
@@ -78,9 +78,9 @@
         frameP.setStyle(SkPaint::kStroke_Style);
 
         for (size_t i = 0; i < SK_ARRAY_COUNT(gData); i++) {
-            SkAvoidXfermode mode(SK_ColorGREEN, gData[i].fTolerance,
-                                 gData[i].fMode);
-            paint.setXfermode(&mode);
+            SkAutoTUnref<SkAvoidXfermode> mode(SkAvoidXfermode::Create(
+                SK_ColorGREEN, gData[i].fTolerance, gData[i].fMode));
+            paint.setXfermode(mode);
             int div = 3;
             SkRect rr = { 0, 0, r.width()/div, r.height()/div };
             rr.offset(r.width()/4 - rr.width()/2, r.height()/4 - rr.height()/2);
diff --git a/samplecode/SamplePathEffects.cpp b/samplecode/SamplePathEffects.cpp
index ac77f21..2a1a49b 100644
--- a/samplecode/SamplePathEffects.cpp
+++ b/samplecode/SamplePathEffects.cpp
@@ -29,7 +29,7 @@
 
 static SkPathEffect* make_pe(int flags) {
     if (flags == 1)
-        return new SkCornerPathEffect(SkIntToScalar(CORNER_RADIUS));
+        return SkCornerPathEffect::Create(SkIntToScalar(CORNER_RADIUS));
 
     SkPath  path;
     path.moveTo(SkIntToScalar(gXY[0]), SkIntToScalar(gXY[1]));
@@ -38,14 +38,14 @@
     path.close();
     path.offset(SkIntToScalar(-6), 0);
 
-    SkPathEffect* outer = new SkPath1DPathEffect(path, SkIntToScalar(12), gPhase, SkPath1DPathEffect::kRotate_Style);
+    SkPathEffect* outer = SkPath1DPathEffect::Create(path, SkIntToScalar(12), gPhase, SkPath1DPathEffect::kRotate_Style);
 
     if (flags == 2)
         return outer;
 
-    SkPathEffect* inner = new SkCornerPathEffect(SkIntToScalar(CORNER_RADIUS));
+    SkPathEffect* inner = SkCornerPathEffect::Create(SkIntToScalar(CORNER_RADIUS));
 
-    SkPathEffect* pe = new SkComposePathEffect(outer, inner);
+    SkPathEffect* pe = SkComposePathEffect::Create(outer, inner);
     outer->unref();
     inner->unref();
     return pe;
@@ -59,10 +59,11 @@
     path.close();
     path.offset(SkIntToScalar(-6), 0);
 
-    SkPathEffect* outer = new SkPath1DPathEffect(path, SkIntToScalar(12), gPhase, SkPath1DPathEffect::kMorph_Style);
-    SkPathEffect* inner = new SkCornerPathEffect(SkIntToScalar(CORNER_RADIUS));
+    SkPathEffect* outer = SkPath1DPathEffect::Create(
+        path, SkIntToScalar(12), gPhase, SkPath1DPathEffect::kMorph_Style);
+    SkPathEffect* inner = SkCornerPathEffect::Create(SkIntToScalar(CORNER_RADIUS));
 
-    SkPathEffect* pe = new SkComposePathEffect(outer, inner);
+    SkPathEffect* pe = SkComposePathEffect::Create(outer, inner);
     outer->unref();
     inner->unref();
     return pe;
diff --git a/samplecode/SamplePathUtils.cpp b/samplecode/SamplePathUtils.cpp
index 09ab773..503a6ea 100644
--- a/samplecode/SamplePathUtils.cpp
+++ b/samplecode/SamplePathUtils.cpp
@@ -65,14 +65,14 @@
 
     virtual void onDrawContent(SkCanvas* canvas) {
         SkScalar intervals[8] = { .5f, .3f, .5f, .3f, .5f, .3f, .5f, .3f };
-        SkDashPathEffect dash(intervals, 2, fPhase);
-        SkCornerPathEffect corner(.25f);
-        SkComposePathEffect compose(&dash, &corner);
+        SkAutoTUnref<SkDashPathEffect> dash(SkDashPathEffect::Create(intervals, 2, fPhase));
+        SkAutoTUnref<SkCornerPathEffect> corner(SkCornerPathEffect::Create(.25f));
+        SkAutoTUnref<SkComposePathEffect> compose(SkComposePathEffect::Create(dash, corner));
 
         SkPaint outlinePaint;
         outlinePaint.setAntiAlias(true);  // dashed paint for bitmap
         outlinePaint.setStyle(SkPaint::kStroke_Style);
-        outlinePaint.setPathEffect(&compose);
+        outlinePaint.setPathEffect(compose);
 
         canvas->scale(10.0f, 10.0f);  // scales up
 
diff --git a/samplecode/SampleSlides.cpp b/samplecode/SampleSlides.cpp
index 26cfc7d..914283a 100644
--- a/samplecode/SampleSlides.cpp
+++ b/samplecode/SampleSlides.cpp
@@ -31,10 +31,10 @@
 
 static void compose_pe(SkPaint* paint) {
     SkPathEffect* pe = paint->getPathEffect();
-    SkPathEffect* corner = new SkCornerPathEffect(25);
+    SkPathEffect* corner = SkCornerPathEffect::Create(25);
     SkPathEffect* compose;
     if (pe) {
-        compose = new SkComposePathEffect(pe, corner);
+        compose = SkComposePathEffect::Create(pe, corner);
         corner->unref();
     } else {
         compose = corner;
@@ -59,8 +59,8 @@
 static void dash_pe(SkPaint* paint) {
     SkScalar inter[] = { 20, 10, 10, 10 };
     paint->setStrokeWidth(12);
-    paint->setPathEffect(new SkDashPathEffect(inter, SK_ARRAY_COUNT(inter),
-                                              0))->unref();
+    paint->setPathEffect(SkDashPathEffect::Create(inter, SK_ARRAY_COUNT(inter),
+                                                  0))->unref();
     compose_pe(paint);
 }
 
@@ -83,8 +83,8 @@
     path.offset(SkIntToScalar(-6), 0);
     scale(&path, 1.5f);
 
-    paint->setPathEffect(new SkPath1DPathEffect(path, SkIntToScalar(21), 0,
-                                SkPath1DPathEffect::kRotate_Style))->unref();
+    paint->setPathEffect(SkPath1DPathEffect::Create(path, SkIntToScalar(21), 0,
+                                                    SkPath1DPathEffect::kRotate_Style))->unref();
     compose_pe(paint);
 }
 
@@ -97,7 +97,7 @@
 }
 
 static void discrete_pe(SkPaint* paint) {
-    paint->setPathEffect(new SkDiscretePathEffect(10, 4))->unref();
+    paint->setPathEffect(SkDiscretePathEffect::Create(10, 4))->unref();
 }
 
 static SkPathEffect* MakeTileEffect() {
@@ -107,7 +107,7 @@
     SkPath path;
     path.addCircle(0, 0, SkIntToScalar(5));
 
-    return new SkPath2DPathEffect(m, path);
+    return SkPath2DPathEffect::Create(m, path);
 }
 
 static void tile_pe(SkPaint* paint) {
@@ -547,7 +547,7 @@
 {
     rast->addLayer(p);
 
-    p.setPathEffect(new SkDiscretePathEffect(SK_Scalar1*4, SK_Scalar1*3))->unref();
+    p.setPathEffect(SkDiscretePathEffect::Create(SK_Scalar1*4, SK_Scalar1*3))->unref();
     p.setXfermodeMode(SkXfermode::kSrcOut_Mode);
     rast->addLayer(p);
 }
@@ -569,7 +569,7 @@
 static SkPathEffect* MakeDotEffect(SkScalar radius, const SkMatrix& matrix) {
     SkPath path;
     path.addCircle(0, 0, radius);
-    return new SkPath2DPathEffect(matrix, path);
+    return SkPath2DPathEffect::Create(matrix, path);
 }
 
 static void r7(SkLayerRasterizer* rast, SkPaint& p)
@@ -606,7 +606,7 @@
     SkMatrix    lattice;
     lattice.setScale(SK_Scalar1, SK_Scalar1*6, 0, 0);
     lattice.postRotate(SkIntToScalar(30), 0, 0);
-    p.setPathEffect(new SkLine2DPathEffect(SK_Scalar1*2, lattice))->unref();
+    p.setPathEffect(SkLine2DPathEffect::Create(SK_Scalar1*2, lattice))->unref();
     p.setXfermodeMode(SkXfermode::kClear_Mode);
     rast->addLayer(p);
 
diff --git a/src/animator/SkDrawDash.cpp b/src/animator/SkDrawDash.cpp
index 8e73aa1..cfef303 100644
--- a/src/animator/SkDrawDash.cpp
+++ b/src/animator/SkDrawDash.cpp
@@ -31,5 +31,5 @@
     int count = intervals.count();
     if (count == 0)
         return NULL;
-    return new SkDashPathEffect(intervals.begin(), count, phase);
+    return SkDashPathEffect::Create(intervals.begin(), count, phase);
 }
diff --git a/src/animator/SkDrawDiscrete.cpp b/src/animator/SkDrawDiscrete.cpp
index 18c3ee0..9376435 100644
--- a/src/animator/SkDrawDiscrete.cpp
+++ b/src/animator/SkDrawDiscrete.cpp
@@ -30,5 +30,5 @@
     if (deviation <= 0 || segLength <= 0)
         return NULL;
     else
-        return new SkDiscretePathEffect(segLength, deviation);
+        return SkDiscretePathEffect::Create(segLength, deviation);
 }
diff --git a/src/animator/SkDrawExtraPathEffect.cpp b/src/animator/SkDrawExtraPathEffect.cpp
index 7b991d2..4b911d1 100644
--- a/src/animator/SkDrawExtraPathEffect.cpp
+++ b/src/animator/SkDrawExtraPathEffect.cpp
@@ -371,7 +371,7 @@
 SkPathEffect* SkDrawComposePathEffect::getPathEffect() {
     SkPathEffect* e1 = effect1->getPathEffect();
     SkPathEffect* e2 = effect2->getPathEffect();
-    SkPathEffect* composite = new SkComposePathEffect(e1, e2);
+    SkPathEffect* composite = SkComposePathEffect::Create(e1, e2);
     e1->unref();
     e2->unref();
     return composite;
@@ -401,7 +401,7 @@
 }
 
 SkPathEffect* SkDrawCornerPathEffect::getPathEffect() {
-    return new SkCornerPathEffect(radius);
+    return SkCornerPathEffect::Create(radius);
 }
 
 /////////
diff --git a/src/core/SkXfermode.cpp b/src/core/SkXfermode.cpp
index 66e0dea..f5ac20b 100644
--- a/src/core/SkXfermode.cpp
+++ b/src/core/SkXfermode.cpp
@@ -1444,7 +1444,9 @@
 
 class SkClearXfermode : public SkProcCoeffXfermode {
 public:
-    SkClearXfermode(const ProcCoeff& rec) : SkProcCoeffXfermode(rec, kClear_Mode) {}
+    static SkClearXfermode* Create(const ProcCoeff& rec) {
+        return SkNEW_ARGS(SkClearXfermode, (rec));
+    }
 
     virtual void xfer32(SkPMColor*, const SkPMColor*, int, const SkAlpha*) const SK_OVERRIDE;
     virtual void xferA8(SkAlpha*, const SkPMColor*, int, const SkAlpha*) const SK_OVERRIDE;
@@ -1453,6 +1455,7 @@
     SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkClearXfermode)
 
 private:
+    SkClearXfermode(const ProcCoeff& rec) : SkProcCoeffXfermode(rec, kClear_Mode) {}
     SkClearXfermode(SkReadBuffer& buffer)
         : SkProcCoeffXfermode(buffer) {}
 
@@ -1506,7 +1509,9 @@
 
 class SkSrcXfermode : public SkProcCoeffXfermode {
 public:
-    SkSrcXfermode(const ProcCoeff& rec) : SkProcCoeffXfermode(rec, kSrc_Mode) {}
+    static SkSrcXfermode* Create(const ProcCoeff& rec) {
+        return SkNEW_ARGS(SkSrcXfermode, (rec));
+    }
 
     virtual void xfer32(SkPMColor*, const SkPMColor*, int, const SkAlpha*) const SK_OVERRIDE;
     virtual void xferA8(SkAlpha*, const SkPMColor*, int, const SkAlpha*) const SK_OVERRIDE;
@@ -1515,6 +1520,7 @@
     SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkSrcXfermode)
 
 private:
+    SkSrcXfermode(const ProcCoeff& rec) : SkProcCoeffXfermode(rec, kSrc_Mode) {}
     SkSrcXfermode(SkReadBuffer& buffer)
         : SkProcCoeffXfermode(buffer) {}
 
@@ -1573,7 +1579,9 @@
 
 class SkDstInXfermode : public SkProcCoeffXfermode {
 public:
-    SkDstInXfermode(const ProcCoeff& rec) : SkProcCoeffXfermode(rec, kDstIn_Mode) {}
+    static SkDstInXfermode* Create(const ProcCoeff& rec) {
+        return SkNEW_ARGS(SkDstInXfermode, (rec));
+    }
 
     virtual void xfer32(SkPMColor*, const SkPMColor*, int, const SkAlpha*) const SK_OVERRIDE;
 
@@ -1581,6 +1589,7 @@
     SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkDstInXfermode)
 
 private:
+    SkDstInXfermode(const ProcCoeff& rec) : SkProcCoeffXfermode(rec, kDstIn_Mode) {}
     SkDstInXfermode(SkReadBuffer& buffer) : INHERITED(buffer) {}
 
     typedef SkProcCoeffXfermode INHERITED;
@@ -1616,7 +1625,9 @@
 
 class SkDstOutXfermode : public SkProcCoeffXfermode {
 public:
-    SkDstOutXfermode(const ProcCoeff& rec) : SkProcCoeffXfermode(rec, kDstOut_Mode) {}
+    static SkDstOutXfermode* Create(const ProcCoeff& rec) {
+        return SkNEW_ARGS(SkDstOutXfermode, (rec));
+    }
 
     virtual void xfer32(SkPMColor*, const SkPMColor*, int, const SkAlpha*) const SK_OVERRIDE;
 
@@ -1624,6 +1635,7 @@
     SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkDstOutXfermode)
 
 private:
+    SkDstOutXfermode(const ProcCoeff& rec) : SkProcCoeffXfermode(rec, kDstOut_Mode) {}
     SkDstOutXfermode(SkReadBuffer& buffer)
         : INHERITED(buffer) {}
 
@@ -1712,23 +1724,23 @@
             // commonly used, so we call those out for their own subclasses here.
             switch (mode) {
                 case kClear_Mode:
-                    xfer = SkNEW_ARGS(SkClearXfermode, (rec));
+                    xfer = SkClearXfermode::Create(rec);
                     break;
                 case kSrc_Mode:
-                    xfer = SkNEW_ARGS(SkSrcXfermode, (rec));
+                    xfer = SkSrcXfermode::Create(rec);
                     break;
                 case kSrcOver_Mode:
                     SkASSERT(false);    // should not land here
                     break;
                 case kDstIn_Mode:
-                    xfer = SkNEW_ARGS(SkDstInXfermode, (rec));
+                    xfer = SkDstInXfermode::Create(rec);
                     break;
                 case kDstOut_Mode:
-                    xfer = SkNEW_ARGS(SkDstOutXfermode, (rec));
+                    xfer = SkDstOutXfermode::Create(rec);
                     break;
                 default:
                     // no special-case, just rely in the rec and its function-ptrs
-                    xfer = SkNEW_ARGS(SkProcCoeffXfermode, (rec, mode));
+                    xfer = SkProcCoeffXfermode::Create(rec, mode);
                     break;
             }
         }
diff --git a/src/core/SkXfermode_proccoeff.h b/src/core/SkXfermode_proccoeff.h
index 1a2f7fc..1112111 100644
--- a/src/core/SkXfermode_proccoeff.h
+++ b/src/core/SkXfermode_proccoeff.h
@@ -15,12 +15,8 @@
 
 class SkProcCoeffXfermode : public SkProcXfermode {
 public:
-    SkProcCoeffXfermode(const ProcCoeff& rec, Mode mode)
-            : INHERITED(rec.fProc) {
-        fMode = mode;
-        // these may be valid, or may be CANNOT_USE_COEFF
-        fSrcCoeff = rec.fSC;
-        fDstCoeff = rec.fDC;
+    static SkProcCoeffXfermode* Create(const ProcCoeff& rec, Mode mode) {
+        return SkNEW_ARGS(SkProcCoeffXfermode, (rec, mode));
     }
 
     virtual bool asMode(Mode* mode) const SK_OVERRIDE;
@@ -36,6 +32,14 @@
     SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkProcCoeffXfermode)
 
 protected:
+    SkProcCoeffXfermode(const ProcCoeff& rec, Mode mode)
+            : INHERITED(rec.fProc) {
+        fMode = mode;
+        // these may be valid, or may be CANNOT_USE_COEFF
+        fSrcCoeff = rec.fSC;
+        fDstCoeff = rec.fDC;
+    }
+
     SkProcCoeffXfermode(SkReadBuffer& buffer);
 
     virtual void flatten(SkWriteBuffer& buffer) const SK_OVERRIDE;
diff --git a/src/effects/SkArithmeticMode.cpp b/src/effects/SkArithmeticMode.cpp
index 052b065..2121e3a 100644
--- a/src/effects/SkArithmeticMode.cpp
+++ b/src/effects/SkArithmeticMode.cpp
@@ -23,11 +23,8 @@
 
 class SkArithmeticMode_scalar : public SkXfermode {
 public:
-    SkArithmeticMode_scalar(SkScalar k1, SkScalar k2, SkScalar k3, SkScalar k4) {
-        fK[0] = k1;
-        fK[1] = k2;
-        fK[2] = k3;
-        fK[3] = k4;
+    static SkArithmeticMode_scalar* Create(SkScalar k1, SkScalar k2, SkScalar k3, SkScalar k4) {
+        return SkNEW_ARGS(SkArithmeticMode_scalar, (k1, k2, k3, k4));
     }
 
     virtual void xfer32(SkPMColor dst[], const SkPMColor src[], int count,
@@ -41,6 +38,13 @@
 #endif
 
 private:
+    SkArithmeticMode_scalar(SkScalar k1, SkScalar k2, SkScalar k3, SkScalar k4) {
+        fK[0] = k1;
+        fK[1] = k2;
+        fK[2] = k3;
+        fK[3] = k4;
+    }
+
     SkArithmeticMode_scalar(SkReadBuffer& buffer) : INHERITED(buffer) {
         fK[0] = buffer.readScalar();
         fK[1] = buffer.readScalar();
@@ -216,7 +220,7 @@
         return SkNEW_ARGS(SkArithmeticMode_linear, (i2, i3, i4));
 #endif
     }
-    return SkNEW_ARGS(SkArithmeticMode_scalar, (k1, k2, k3, k4));
+    return SkArithmeticMode_scalar::Create(k1, k2, k3, k4);
 }
 
 
diff --git a/src/utils/debugger/SkDebugCanvas.cpp b/src/utils/debugger/SkDebugCanvas.cpp
index 32a6570..07cb09f 100644
--- a/src/utils/debugger/SkDebugCanvas.cpp
+++ b/src/utils/debugger/SkDebugCanvas.cpp
@@ -118,7 +118,7 @@
 class SkOverdrawFilter : public SkDrawFilter {
 public:
     SkOverdrawFilter() {
-        fXferMode = new SkProcXfermode(OverdrawXferModeProc);
+        fXferMode = SkProcXfermode::Create(OverdrawXferModeProc);
     }
 
     virtual ~SkOverdrawFilter() {
diff --git a/tests/DrawPathTest.cpp b/tests/DrawPathTest.cpp
index e7f7005..f7f7367 100644
--- a/tests/DrawPathTest.cpp
+++ b/tests/DrawPathTest.cpp
@@ -202,7 +202,7 @@
      */
 
     const SkScalar vals[] = { 27734, 35660, 2157846850.0f, 247 };
-    SkDashPathEffect dontAssert(vals, 4, -248.135982067f);
+    SkAutoTUnref<SkDashPathEffect> dontAssert(SkDashPathEffect::Create(vals, 4, -248.135982067f));
 }
 
 static void test_crbug_124652() {
@@ -212,8 +212,7 @@
         large values can "swamp" small ones.
      */
     SkScalar intervals[2] = {837099584, 33450};
-    SkAutoTUnref<SkDashPathEffect> dash(
-        new SkDashPathEffect(intervals, 2, -10, false));
+    SkAutoTUnref<SkDashPathEffect> dash(SkDashPathEffect::Create(intervals, 2, -10, false));
 }
 
 static void test_bigcubic() {
@@ -254,12 +253,12 @@
     path.lineTo(5000000, 0);
 
     SkScalar intervals[] = { 0.2f, 0.2f };
-    SkDashPathEffect dash(intervals, 2, 0);
+    SkAutoTUnref<SkDashPathEffect> dash(SkDashPathEffect::Create(intervals, 2, 0));
 
     SkPath filteredPath;
     SkPaint paint;
     paint.setStyle(SkPaint::kStroke_Style);
-    paint.setPathEffect(&dash);
+    paint.setPathEffect(dash);
 
     paint.getFillPath(path, &filteredPath);
     // If we reach this, we passed.
@@ -274,15 +273,15 @@
     path.lineTo(10000000, 0);
 
     SkScalar intervals[] = { 0.5f, 0.5f };
-    SkDashPathEffect dash(intervals, 2, 0);
+    SkAutoTUnref<SkDashPathEffect> dash(SkDashPathEffect::Create(intervals, 2, 0));
 
     SkPaint paint;
     paint.setStyle(SkPaint::kStroke_Style);
-    paint.setPathEffect(&dash);
+    paint.setPathEffect(dash);
 
     SkPath filteredPath;
     SkStrokeRec rec(paint);
-    REPORTER_ASSERT(reporter, !dash.filterPath(&filteredPath, path, &rec, NULL));
+    REPORTER_ASSERT(reporter, !dash->filterPath(&filteredPath, path, &rec, NULL));
     REPORTER_ASSERT(reporter, filteredPath.isEmpty());
 }
 
diff --git a/tests/XfermodeTest.cpp b/tests/XfermodeTest.cpp
index 7ac12fb..4afa522 100644
--- a/tests/XfermodeTest.cpp
+++ b/tests/XfermodeTest.cpp
@@ -37,7 +37,7 @@
         }
     }
 
-    SkXfermode* bogusXfer = new SkProcXfermode(bogusXfermodeProc);
+    SkXfermode* bogusXfer = SkProcXfermode::Create(bogusXfermodeProc);
     SkXfermode::Mode reportedMode = ILLEGAL_MODE;
     REPORTER_ASSERT(reporter, !bogusXfer->asMode(&reportedMode));
     REPORTER_ASSERT(reporter, reportedMode == ILLEGAL_MODE);