Move SkMatrixImageFilter into core, and add a factory fn for it.

BUG=skia:

Review URL: https://codereview.chromium.org/1011273003
diff --git a/gm/filterfastbounds.cpp b/gm/filterfastbounds.cpp
index 0ae7068..d0fed52 100644
--- a/gm/filterfastbounds.cpp
+++ b/gm/filterfastbounds.cpp
@@ -9,7 +9,6 @@
 #include "SkBitmapSource.h"
 #include "SkBlurImageFilter.h"
 #include "SkDropShadowImageFilter.h"
-#include "SkMatrixImageFilter.h"
 #include "SkOffsetImageFilter.h"
 #include "SkPictureImageFilter.h"
 #include "SkPictureRecorder.h"
@@ -93,8 +92,8 @@
         SkMatrix scale;
         scale.setScale(2.0f, 2.0f);
 
-        SkAutoTUnref<SkMatrixImageFilter> scaleMIF(
-            SkMatrixImageFilter::Create(scale, kLow_SkFilterQuality, source));
+        SkAutoTUnref<SkImageFilter> scaleMIF(
+            SkImageFilter::CreateMatrixFilter(scale, kLow_SkFilterQuality, source));
 
         add_paint(scaleMIF, paints);
     }
@@ -103,8 +102,8 @@
         SkMatrix rot;
         rot.setRotate(-33.3f);
 
-        SkAutoTUnref<SkMatrixImageFilter> rotMIF(
-            SkMatrixImageFilter::Create(rot, kLow_SkFilterQuality, source));
+        SkAutoTUnref<SkImageFilter> rotMIF(
+            SkImageFilter::CreateMatrixFilter(rot, kLow_SkFilterQuality, source));
 
         add_paint(rotMIF, paints);
     }
diff --git a/gm/imagefiltersclipped.cpp b/gm/imagefiltersclipped.cpp
index 5608414..9b91929 100644
--- a/gm/imagefiltersclipped.cpp
+++ b/gm/imagefiltersclipped.cpp
@@ -12,7 +12,6 @@
 #include "SkDisplacementMapEffect.h"
 #include "SkDropShadowImageFilter.h"
 #include "SkGradientShader.h"
-#include "SkMatrixImageFilter.h"
 #include "SkMorphologyImageFilter.h"
 #include "SkOffsetImageFilter.h"
 #include "SkPerlinNoiseShader.h"
@@ -91,7 +90,7 @@
             SkDilateImageFilter::Create(2, 2, checkerboard.get()),
             SkErodeImageFilter::Create(2, 2, checkerboard.get()),
             SkOffsetImageFilter::Create(SkIntToScalar(-16), SkIntToScalar(32)),
-            SkMatrixImageFilter::Create(resizeMatrix, kNone_SkFilterQuality),
+            SkImageFilter::CreateMatrixFilter(resizeMatrix, kNone_SkFilterQuality),
             SkRectShaderImageFilter::Create(noise),
         };
 
diff --git a/gm/imagefiltersscaled.cpp b/gm/imagefiltersscaled.cpp
index 1cb1e5c..9c9ec15 100644
--- a/gm/imagefiltersscaled.cpp
+++ b/gm/imagefiltersscaled.cpp
@@ -13,7 +13,6 @@
 #include "SkDropShadowImageFilter.h"
 #include "SkGradientShader.h"
 #include "SkLightingImageFilter.h"
-#include "SkMatrixImageFilter.h"
 #include "SkMorphologyImageFilter.h"
 #include "SkOffsetImageFilter.h"
 #include "SkPerlinNoiseShader.h"
@@ -100,7 +99,7 @@
             SkDilateImageFilter::Create(1, 1, checkerboard.get()),
             SkErodeImageFilter::Create(1, 1, checkerboard.get()),
             SkOffsetImageFilter::Create(SkIntToScalar(32), 0),
-            SkMatrixImageFilter::Create(resizeMatrix, kNone_SkFilterQuality),
+            SkImageFilter::CreateMatrixFilter(resizeMatrix, kNone_SkFilterQuality),
             SkRectShaderImageFilter::Create(noise),
             SkLightingImageFilter::CreatePointLitDiffuse(pointLocation, white, surfaceScale, kd),
             SkLightingImageFilter::CreateSpotLitDiffuse(spotLocation, spotTarget, spotExponent,
diff --git a/gm/imageresizetiled.cpp b/gm/imageresizetiled.cpp
index d06c1fb..4899d35 100644
--- a/gm/imageresizetiled.cpp
+++ b/gm/imageresizetiled.cpp
@@ -6,7 +6,7 @@
  */
 
 #include "gm.h"
-#include "SkMatrixImageFilter.h"
+#include "SkImageFilter.h"
 #include "SkRandom.h"
 
 #define WIDTH 640
@@ -36,7 +36,7 @@
         SkMatrix matrix;
         matrix.setScale(RESIZE_FACTOR, RESIZE_FACTOR);
         SkAutoTUnref<SkImageFilter> imageFilter(
-            SkMatrixImageFilter::Create(matrix, kNone_SkFilterQuality));
+            SkImageFilter::CreateMatrixFilter(matrix, kNone_SkFilterQuality));
         paint.setImageFilter(imageFilter.get());
         const SkScalar tile_size = SkIntToScalar(100);
         SkRect bounds;
diff --git a/gm/matriximagefilter.cpp b/gm/matriximagefilter.cpp
index eef2b45..a42870b 100644
--- a/gm/matriximagefilter.cpp
+++ b/gm/matriximagefilter.cpp
@@ -7,7 +7,7 @@
 
 #include "gm.h"
 #include "SkColor.h"
-#include "SkMatrixImageFilter.h"
+#include "SkImageFilter.h"
 
 namespace skiagm {
 
@@ -25,7 +25,7 @@
     void draw(SkCanvas* canvas, const SkRect& rect, const SkBitmap& bitmap,
               const SkMatrix& matrix, SkFilterQuality filter) {
         SkAutoTUnref<SkImageFilter> imageFilter(
-            SkMatrixImageFilter::Create(matrix, filter));
+            SkImageFilter::CreateMatrixFilter(matrix, filter));
         SkPaint paint;
         paint.setImageFilter(imageFilter.get());
         canvas->saveLayer(&rect, &paint);
diff --git a/gm/resizeimagefilter.cpp b/gm/resizeimagefilter.cpp
index 6916f611..b88c388 100644
--- a/gm/resizeimagefilter.cpp
+++ b/gm/resizeimagefilter.cpp
@@ -9,7 +9,6 @@
 #include "SkBitmapDevice.h"
 #include "SkBitmapSource.h"
 #include "SkColor.h"
-#include "SkMatrixImageFilter.h"
 #include "SkRefCnt.h"
 
 namespace skiagm {
@@ -42,7 +41,7 @@
         matrix.setScale(SkScalarInvert(deviceScaleX),
                         SkScalarInvert(deviceScaleY));
         SkAutoTUnref<SkImageFilter> imageFilter(
-            SkMatrixImageFilter::Create(matrix, filterQuality, input));
+            SkImageFilter::CreateMatrixFilter(matrix, filterQuality, input));
         SkPaint filteredPaint;
         filteredPaint.setImageFilter(imageFilter.get());
         canvas->saveLayer(&rect, &filteredPaint);
diff --git a/gyp/core.gypi b/gyp/core.gypi
index 2e9fb1b..f02c585 100644
--- a/gyp/core.gypi
+++ b/gyp/core.gypi
@@ -123,6 +123,7 @@
         '<(skia_src_path)/core/SkMaskGamma.h',
         '<(skia_src_path)/core/SkMath.cpp',
         '<(skia_src_path)/core/SkMatrix.cpp',
+        '<(skia_src_path)/core/SkMatrixImageFilter.cpp',
         '<(skia_src_path)/core/SkMessageBus.h',
         '<(skia_src_path)/core/SkMetaData.cpp',
         '<(skia_src_path)/core/SkMipMap.cpp',
@@ -275,6 +276,7 @@
         '<(skia_include_path)/core/SkMaskFilter.h',
         '<(skia_include_path)/core/SkMath.h',
         '<(skia_include_path)/core/SkMatrix.h',
+        '<(skia_include_path)/core/SkMatrixImageFilter.h',
         '<(skia_include_path)/core/SkMetaData.h',
         '<(skia_include_path)/core/SkMultiPictureDraw.h',
         '<(skia_include_path)/core/SkOnce.h',
diff --git a/gyp/effects.gypi b/gyp/effects.gypi
index 24a79be..54165c0 100644
--- a/gyp/effects.gypi
+++ b/gyp/effects.gypi
@@ -56,7 +56,6 @@
     '<(skia_src_path)/effects/SkTableMaskFilter.cpp',
     '<(skia_src_path)/effects/SkTestImageFilters.cpp',
     '<(skia_src_path)/effects/SkTileImageFilter.cpp',
-    '<(skia_src_path)/effects/SkMatrixImageFilter.cpp',
     '<(skia_src_path)/effects/SkTransparentShader.cpp',
     '<(skia_src_path)/effects/SkXfermodeImageFilter.cpp',
 
diff --git a/include/core/SkImageFilter.h b/include/core/SkImageFilter.h
index b64a295..40bd38a 100644
--- a/include/core/SkImageFilter.h
+++ b/include/core/SkImageFilter.h
@@ -8,6 +8,7 @@
 #ifndef SkImageFilter_DEFINED
 #define SkImageFilter_DEFINED
 
+#include "SkFilterQuality.h"
 #include "SkFlattenable.h"
 #include "SkMatrix.h"
 #include "SkRect.h"
@@ -192,6 +193,13 @@
     // Default impl returns union of all input bounds.
     virtual void computeFastBounds(const SkRect&, SkRect*) const;
 
+    /**
+     * Create an SkMatrixImageFilter, which transforms its input by the given matrix.
+     */
+    static SkImageFilter* CreateMatrixFilter(const SkMatrix& matrix,
+                                             SkFilterQuality,
+                                             SkImageFilter* input = NULL);
+
 #if SK_SUPPORT_GPU
     /**
      * Wrap the given texture in a texture-backed SkBitmap.
diff --git a/include/effects/SkMatrixImageFilter.h b/include/core/SkMatrixImageFilter.h
similarity index 100%
rename from include/effects/SkMatrixImageFilter.h
rename to include/core/SkMatrixImageFilter.h
diff --git a/samplecode/SampleFilterFuzz.cpp b/samplecode/SampleFilterFuzz.cpp
index 77ae0d8..30389b6 100644
--- a/samplecode/SampleFilterFuzz.cpp
+++ b/samplecode/SampleFilterFuzz.cpp
@@ -19,7 +19,6 @@
 #include "SkFlattenableSerialization.h"
 #include "SkLightingImageFilter.h"
 #include "SkMagnifierImageFilter.h"
-#include "SkMatrixImageFilter.h"
 #include "SkMatrixConvolutionImageFilter.h"
 #include "SkMergeImageFilter.h"
 #include "SkMorphologyImageFilter.h"
@@ -310,9 +309,9 @@
         filter = SkOffsetImageFilter::Create(make_scalar(), make_scalar(), make_image_filter());
         break;
     case MATRIX:
-        filter = SkMatrixImageFilter::Create(make_matrix(),
-                                             (SkFilterQuality)R(4),
-                                             make_image_filter());
+        filter = SkImageFilter::CreateMatrixFilter(make_matrix(),
+                                                   (SkFilterQuality)R(4),
+                                                   make_image_filter());
         break;
     case MATRIX_CONVOLUTION:
     {
diff --git a/src/core/SkImageFilter.cpp b/src/core/SkImageFilter.cpp
index f1553e2..fd98911 100644
--- a/src/core/SkImageFilter.cpp
+++ b/src/core/SkImageFilter.cpp
@@ -11,6 +11,7 @@
 #include "SkChecksum.h"
 #include "SkDevice.h"
 #include "SkLazyPtr.h"
+#include "SkMatrixImageFilter.h"
 #include "SkReadBuffer.h"
 #include "SkWriteBuffer.h"
 #include "SkRect.h"
@@ -368,6 +369,12 @@
     return false;
 }
 
+SkImageFilter* SkImageFilter::CreateMatrixFilter(const SkMatrix& matrix,
+                                                 SkFilterQuality filterQuality,
+                                                 SkImageFilter* input) {
+    return SkMatrixImageFilter::Create(matrix, filterQuality, input);
+}
+
 #if SK_SUPPORT_GPU
 
 void SkImageFilter::WrapTexture(GrTexture* texture, int width, int height, SkBitmap* result) {
diff --git a/src/effects/SkMatrixImageFilter.cpp b/src/core/SkMatrixImageFilter.cpp
similarity index 100%
rename from src/effects/SkMatrixImageFilter.cpp
rename to src/core/SkMatrixImageFilter.cpp
diff --git a/tests/ImageFilterTest.cpp b/tests/ImageFilterTest.cpp
index e9792e4..87aabd1 100644
--- a/tests/ImageFilterTest.cpp
+++ b/tests/ImageFilterTest.cpp
@@ -20,7 +20,6 @@
 #include "SkGradientShader.h"
 #include "SkLightingImageFilter.h"
 #include "SkMatrixConvolutionImageFilter.h"
-#include "SkMatrixImageFilter.h"
 #include "SkMergeImageFilter.h"
 #include "SkMorphologyImageFilter.h"
 #include "SkOffsetImageFilter.h"
@@ -470,7 +469,7 @@
         { "erode", SkErodeImageFilter::Create(2, 3) },
         { "tile", SkTileImageFilter::Create(SkRect::MakeXYWH(0, 0, 50, 50),
                                             SkRect::MakeXYWH(0, 0, 100, 100), NULL) },
-        { "matrix", SkMatrixImageFilter::Create(matrix, kLow_SkFilterQuality) },
+        { "matrix", SkImageFilter::CreateMatrixFilter(matrix, kLow_SkFilterQuality) },
         { "blur and offset", SkOffsetImageFilter::Create(five, five, blur.get()) },
         { "picture and blur", SkBlurImageFilter::Create(five, five, pictureFilter.get()) },
         { "rect shader and blur", SkBlurImageFilter::Create(five, five, rectShaderFilter.get()) },
@@ -533,7 +532,7 @@
 
     SkAutoTUnref<SkColorFilter> cf(SkColorFilter::CreateModeFilter(SK_ColorWHITE, SkXfermode::kSrc_Mode));
     SkAutoTUnref<SkImageFilter> cfif(SkColorFilterImageFilter::Create(cf.get()));
-    SkAutoTUnref<SkImageFilter> imageFilter(SkMatrixImageFilter::Create(matrix, kNone_SkFilterQuality, cfif.get()));
+    SkAutoTUnref<SkImageFilter> imageFilter(SkImageFilter::CreateMatrixFilter(matrix, kNone_SkFilterQuality, cfif.get()));
 
     SkPaint paint;
     paint.setImageFilter(imageFilter.get());
@@ -1076,7 +1075,7 @@
     matrix.setScale(SkIntToScalar(2), SkIntToScalar(2));
     matrix.postTranslate(SkIntToScalar(-20), SkIntToScalar(-20));
     SkAutoTUnref<SkImageFilter> matrixFilter(
-        SkMatrixImageFilter::Create(matrix, kLow_SkFilterQuality));
+        SkImageFilter::CreateMatrixFilter(matrix, kLow_SkFilterQuality));
 
     // Test that saveLayer() with a filter nested inside another saveLayer() applies the
     // correct offset to the filter matrix.