change back to method for localmatrix imagefilter

This method is different from MatrixFilter, in that MatrixFilter does not require a pre-existing
filter, but LocalM does. Also change the comment to be more general, as there is no promise that
we return a different subclass, and certainly not a specific subclass.

This pattern of obj->newWithModifiers() also more closely matches the pattern in SkImage (newSubset).

BUG=skia:

Review URL: https://codereview.chromium.org/1402133002
diff --git a/gm/localmatriximagefilter.cpp b/gm/localmatriximagefilter.cpp
index 1bdc940..64ed6d7 100644
--- a/gm/localmatriximagefilter.cpp
+++ b/gm/localmatriximagefilter.cpp
@@ -86,8 +86,7 @@
             canvas->save();
             show_image(canvas, image0, filter);
             for (const auto& matrix : matrices) {
-                SkAutoTUnref<SkImageFilter> localFilter(
-                    SkImageFilter::CreateLocalMatrixFilter(matrix, filter));
+                SkAutoTUnref<SkImageFilter> localFilter(filter->newWithLocalMatrix(matrix));
                 canvas->translate(spacer, 0);
                 show_image(canvas, image0, localFilter);
             }
diff --git a/include/core/SkImageFilter.h b/include/core/SkImageFilter.h
index 0a3f7b8..3a7cb23 100644
--- a/include/core/SkImageFilter.h
+++ b/include/core/SkImageFilter.h
@@ -230,19 +230,18 @@
     bool canComputeFastBounds() const;
 
     /**
+     *  If this filter can be represented by another filter + a localMatrix, return that filter,
+     *  else return null.
+     */
+    SkImageFilter* newWithLocalMatrix(const SkMatrix& matrix) const;
+
+    /**
      * Create an SkMatrixImageFilter, which transforms its input by the given matrix.
      */
     static SkImageFilter* CreateMatrixFilter(const SkMatrix& matrix,
                                              SkFilterQuality,
                                              SkImageFilter* input = NULL);
 
-    /**
-     * Create an SkLocalMatrixImageFilter, which transform the filter parameters
-     * of its inputs by the given matrix.
-     */
-    static SkImageFilter* CreateLocalMatrixFilter(const SkMatrix& matrix,
-                                                  SkImageFilter* input);
-
 #if SK_SUPPORT_GPU
     /**
      * Wrap the given texture in a texture-backed SkBitmap.
diff --git a/src/core/SkImageFilter.cpp b/src/core/SkImageFilter.cpp
index 43adc2f..3f6ea9a 100644
--- a/src/core/SkImageFilter.cpp
+++ b/src/core/SkImageFilter.cpp
@@ -440,9 +440,11 @@
     return SkMatrixImageFilter::Create(matrix, filterQuality, input);
 }
 
-SkImageFilter* SkImageFilter::CreateLocalMatrixFilter(const SkMatrix& matrix,
-                                                      SkImageFilter* input) {
-    return SkLocalMatrixImageFilter::Create(matrix, input);
+SkImageFilter* SkImageFilter::newWithLocalMatrix(const SkMatrix& matrix) const {
+    // SkLocalMatrixImageFilter takes SkImage* in its factory, but logically that parameter
+    // is *always* treated as a const ptr. Hence the const-cast here.
+    //
+    return SkLocalMatrixImageFilter::Create(matrix, const_cast<SkImageFilter*>(this));
 }
 
 #if SK_SUPPORT_GPU