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
diff --git a/include/effects/SkMatrixConvolutionImageFilter.h b/include/effects/SkMatrixConvolutionImageFilter.h
index 59af83e..524d05d 100644
--- a/include/effects/SkMatrixConvolutionImageFilter.h
+++ b/include/effects/SkMatrixConvolutionImageFilter.h
@@ -28,39 +28,43 @@
       kClampToBlack_TileMode,  /*!< Fill with transparent black. */
     };
 
-    /** Construct a matrix convolution image filter.
-        @param kernelSize  The kernel size in pixels, in each dimension (N by M).
-        @param kernel      The image processing kernel.  Must contain N * M
-                           elements, in row order.
-        @param gain        A scale factor applied to each pixel after
-                           convolution.  This can be used to normalize the
-                           kernel, if it does not sum to 1.
-        @param bias        A bias factor added to each pixel after convolution.
-        @param target      An offset applied to each pixel coordinate before
-                           convolution.  This can be used to center the kernel
-                           over the image (e.g., a 3x3 kernel should have a
-                           target of {1, 1}).
-        @param tileMode    How accesses outside the image are treated.  (@see
-                           TileMode).
-        @param convolveAlpha  If true, all channels are convolved.  If false,
-                           only the RGB channels are convolved, and
-                           alpha is copied from the source image.
-        @param input       The input image filter.  If NULL, the src bitmap
-                           passed to filterImage() is used instead.
-        @param cropRect    The rectangle to which the output processing will be limited.
-    */
-
-    SkMatrixConvolutionImageFilter(const SkISize& kernelSize,
-                                   const SkScalar* kernel,
-                                   SkScalar gain,
-                                   SkScalar bias,
-                                   const SkIPoint& target,
-                                   TileMode tileMode,
-                                   bool convolveAlpha,
-                                   SkImageFilter* input = NULL,
-                                   const CropRect* cropRect = NULL);
     virtual ~SkMatrixConvolutionImageFilter();
 
+    /** Construct a matrix convolution image filter.
+        @param kernelSize     The kernel size in pixels, in each dimension (N by M).
+        @param kernel         The image processing kernel.  Must contain N * M
+                              elements, in row order.
+        @param gain           A scale factor applied to each pixel after
+                              convolution.  This can be used to normalize the
+                              kernel, if it does not sum to 1.
+        @param bias           A bias factor added to each pixel after convolution.
+        @param kernelOffset   An offset applied to each pixel coordinate before
+                              convolution.  This can be used to center the kernel
+                              over the image (e.g., a 3x3 kernel should have an
+                              offset of {1, 1}).
+        @param tileMode       How accesses outside the image are treated.  (@see
+                              TileMode).
+        @param convolveAlpha  If true, all channels are convolved.  If false,
+                              only the RGB channels are convolved, and
+                              alpha is copied from the source image.
+        @param input          The input image filter.  If NULL, the src bitmap
+                              passed to filterImage() is used instead.
+        @param cropRect       The rectangle to which the output processing will be limited.
+    */
+    static SkMatrixConvolutionImageFilter* Create(const SkISize& kernelSize,
+                                                  const SkScalar* kernel,
+                                                  SkScalar gain,
+                                                  SkScalar bias,
+                                                  const SkIPoint& kernelOffset,
+                                                  TileMode tileMode,
+                                                  bool convolveAlpha,
+                                                  SkImageFilter* input = NULL,
+                                                  const CropRect* cropRect = NULL) {
+        return SkNEW_ARGS(SkMatrixConvolutionImageFilter, (kernelSize, kernel, gain, bias,
+                                                           kernelOffset, tileMode, convolveAlpha,
+                                                           input, cropRect));
+    }
+
     SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkMatrixConvolutionImageFilter)
 
 protected:
@@ -77,12 +81,25 @@
                              const SkIRect& bounds) const SK_OVERRIDE;
 #endif
 
+#ifdef SK_SUPPORT_LEGACY_PUBLICEFFECTCONSTRUCTORS
+public:
+#endif
+    SkMatrixConvolutionImageFilter(const SkISize& kernelSize,
+                                   const SkScalar* kernel,
+                                   SkScalar gain,
+                                   SkScalar bias,
+                                   const SkIPoint& kernelOffset,
+                                   TileMode tileMode,
+                                   bool convolveAlpha,
+                                   SkImageFilter* input = NULL,
+                                   const CropRect* cropRect = NULL);
+
 private:
     SkISize   fKernelSize;
     SkScalar* fKernel;
     SkScalar  fGain;
     SkScalar  fBias;
-    SkIPoint  fTarget;
+    SkIPoint  fKernelOffset;
     TileMode  fTileMode;
     bool      fConvolveAlpha;
     typedef SkImageFilter INHERITED;