Refactor bitmap scaler to make it easier to migrate rest of chrome to use it

Previously, the set of platform-specific function pointers to do fast convolution (e.g., neon, SSE) were passed in a structure to the scaler.

I refactored this so that the scaler fills in these function pointers after it's called, so the caller doesn't have to worry about it.

R=mtklein@google.com
TBR=mtklein
NOTRY=True

Author: humper@google.com

Review URL: https://codereview.chromium.org/354193002
diff --git a/src/core/SkBitmapProcState.cpp b/src/core/SkBitmapProcState.cpp
index f6f9f3f..48962cf 100644
--- a/src/core/SkBitmapProcState.cpp
+++ b/src/core/SkBitmapProcState.cpp
@@ -172,16 +172,11 @@
 
             // All the criteria are met; let's make a new bitmap.
 
-            SkConvolutionProcs simd;
-            sk_bzero(&simd, sizeof(simd));
-            this->platformConvolutionProcs(&simd);
-
             if (!SkBitmapScaler::Resize(&fScaledBitmap,
                                         fOrigBitmap,
                                         SkBitmapScaler::RESIZE_BEST,
                                         dest_width,
                                         dest_height,
-                                        simd,
                                         SkScaledImageCache::GetAllocator())) {
                 // we failed to create fScaledBitmap, so just return and let
                 // the scanline proc handle it.
diff --git a/src/core/SkBitmapProcState.h b/src/core/SkBitmapProcState.h
index 663bcb8..73d7e90 100644
--- a/src/core/SkBitmapProcState.h
+++ b/src/core/SkBitmapProcState.h
@@ -33,7 +33,6 @@
 #endif
 
 class SkPaint;
-struct SkConvolutionProcs;
 
 struct SkBitmapProcState {
 
@@ -104,12 +103,6 @@
      */
     void platformProcs();
 
-    /** Platforms can also optionally overwrite the convolution functions
-        if we have SIMD versions of them.
-      */
-
-    void platformConvolutionProcs(SkConvolutionProcs*);
-
     /** Given the byte size of the index buffer to be passed to the matrix proc,
         return the maximum number of resulting pixels that can be computed
         (i.e. the number of SkPMColor values to be written by the sample proc).
diff --git a/src/core/SkBitmapScaler.cpp b/src/core/SkBitmapScaler.cpp
index be32a89..35e101e 100644
--- a/src/core/SkBitmapScaler.cpp
+++ b/src/core/SkBitmapScaler.cpp
@@ -246,9 +246,11 @@
                             const SkBitmap& source,
                             ResizeMethod method,
                             float destWidth, float destHeight,
-                            const SkConvolutionProcs& convolveProcs,
                             SkBitmap::Allocator* allocator) {
 
+  SkConvolutionProcs convolveProcs= { 0, NULL, NULL, NULL, NULL };
+  PlatformConvolutionProcs(&convolveProcs);
+
   SkRect destSubset = { 0, 0, destWidth, destHeight };
 
   // Ensure that the ResizeMethod enumeration is sound.
diff --git a/src/core/SkBitmapScaler.h b/src/core/SkBitmapScaler.h
index d6636cf..ef559df 100644
--- a/src/core/SkBitmapScaler.h
+++ b/src/core/SkBitmapScaler.h
@@ -83,8 +83,13 @@
                        const SkBitmap& source,
                        ResizeMethod method,
                        float dest_width, float dest_height,
-                       const SkConvolutionProcs&,
                        SkBitmap::Allocator* allocator = NULL);
+
+     /** Platforms can also optionally overwrite the convolution functions
+        if we have SIMD versions of them.
+      */
+
+    static void PlatformConvolutionProcs(SkConvolutionProcs*);
 };
 
 #endif
diff --git a/src/opts/SkBitmapProcState_opts_arm.cpp b/src/opts/SkBitmapProcState_opts_arm.cpp
index ffa0ccf..8f24c39 100644
--- a/src/opts/SkBitmapProcState_opts_arm.cpp
+++ b/src/opts/SkBitmapProcState_opts_arm.cpp
@@ -6,6 +6,7 @@
  */
 
 
+#include "SkBitmapScaler.h"
 #include "SkBitmapProcState.h"
 #include "SkColorPriv.h"
 #include "SkPaint.h"
@@ -229,6 +230,6 @@
 void platformConvolutionProcs_arm(SkConvolutionProcs* procs) {
 }
 
-void SkBitmapProcState::platformConvolutionProcs(SkConvolutionProcs* procs) {
+void SkBitmapScaler::PlatformConvolutionProcs(SkConvolutionProcs* procs) {
     SK_ARM_NEON_WRAP(platformConvolutionProcs_arm)(procs);
 }
diff --git a/src/opts/SkBitmapProcState_opts_none.cpp b/src/opts/SkBitmapProcState_opts_none.cpp
index 96e711b..88aaa93 100644
--- a/src/opts/SkBitmapProcState_opts_none.cpp
+++ b/src/opts/SkBitmapProcState_opts_none.cpp
@@ -5,6 +5,8 @@
  * Use of this source code is governed by a BSD-style license that can be
  * found in the LICENSE file.
  */
+
+#include "SkBitmapScaler.h"
 #include "SkBitmapProcState.h"
 
 /*  A platform may optionally overwrite any of these with accelerated
@@ -23,4 +25,4 @@
 void SkBitmapProcState::platformProcs() {}
 
 // empty implementation just uses default supplied function pointers
-void SkBitmapProcState::platformConvolutionProcs(SkConvolutionProcs*) {}
+void SkBitmapScaler::PlatformConvolutionProcs(SkConvolutionProcs*) {}
diff --git a/src/opts/opts_check_x86.cpp b/src/opts/opts_check_x86.cpp
index b949698..603458b 100644
--- a/src/opts/opts_check_x86.cpp
+++ b/src/opts/opts_check_x86.cpp
@@ -8,6 +8,7 @@
 #include "SkBitmapFilter_opts_SSE2.h"
 #include "SkBitmapProcState_opts_SSE2.h"
 #include "SkBitmapProcState_opts_SSSE3.h"
+#include "SkBitmapScaler.h"
 #include "SkBlitMask.h"
 #include "SkBlitRect_opts_SSE2.h"
 #include "SkBlitRow.h"
@@ -123,7 +124,7 @@
 
 SK_CONF_DECLARE( bool, c_hqfilter_sse, "bitmap.filter.highQualitySSE", false, "Use SSE optimized version of high quality image filters");
 
-void SkBitmapProcState::platformConvolutionProcs(SkConvolutionProcs* procs) {
+void SkBitmapScaler::PlatformConvolutionProcs(SkConvolutionProcs* procs) {
     if (supports_simd(SK_CPU_SSE_LEVEL_SSE2)) {
         procs->fExtraHorizontalReads = 3;
         procs->fConvolveVertically = &convolveVertically_SSE2;