Refactor bitmap scaler to make it easier to migrate rest of chrome to use it
authorhumper <humper@google.com>
Fri, 27 Jun 2014 18:27:03 +0000 (11:27 -0700)
committerCommit bot <commit-bot@chromium.org>
Fri, 27 Jun 2014 18:27:03 +0000 (11:27 -0700)
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

src/core/SkBitmapProcState.cpp
src/core/SkBitmapProcState.h
src/core/SkBitmapScaler.cpp
src/core/SkBitmapScaler.h
src/opts/SkBitmapProcState_opts_arm.cpp
src/opts/SkBitmapProcState_opts_none.cpp
src/opts/opts_check_x86.cpp

index f6f9f3fa06c20c025993f47ab2d071843ea7fb2f..48962cffa46c173b98f3c48fe0ffbf26720c9aab 100644 (file)
@@ -172,16 +172,11 @@ bool SkBitmapProcState::possiblyScaleImage() {
 
             // 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.
index 663bcb8be91b03722b314cd9c1e0bb5f3900404d..73d7e904b30b99d1f6f456e3aa4c90c934f1f95b 100644 (file)
@@ -33,7 +33,6 @@
 #endif
 
 class SkPaint;
-struct SkConvolutionProcs;
 
 struct SkBitmapProcState {
 
@@ -104,12 +103,6 @@ struct SkBitmapProcState {
      */
     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).
index be32a891fcd8c4a9226514ecc4806179a889ddd4..35e101efa964238f7f05a13de849d396a636d759 100644 (file)
@@ -246,9 +246,11 @@ bool SkBitmapScaler::Resize(SkBitmap* resultPtr,
                             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.
index d6636cf34ea9a44a794308c6f6a78303cdbf1e09..ef559df606c727c2342d6948098cc37d5295e5b8 100644 (file)
@@ -83,8 +83,13 @@ public:
                        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
index ffa0ccfa8aabe612d2dbc74f7892e3a6174c9c0b..8f24c39a2e178bfc301457a8e1fcc76e4c7c2c58 100644 (file)
@@ -6,6 +6,7 @@
  */
 
 
+#include "SkBitmapScaler.h"
 #include "SkBitmapProcState.h"
 #include "SkColorPriv.h"
 #include "SkPaint.h"
@@ -229,6 +230,6 @@ extern void platformConvolutionProcs_arm_neon(SkConvolutionProcs* procs);
 void platformConvolutionProcs_arm(SkConvolutionProcs* procs) {
 }
 
-void SkBitmapProcState::platformConvolutionProcs(SkConvolutionProcs* procs) {
+void SkBitmapScaler::PlatformConvolutionProcs(SkConvolutionProcs* procs) {
     SK_ARM_NEON_WRAP(platformConvolutionProcs_arm)(procs);
 }
index 96e711b47240a2406ee280a56a31fdd921914508..88aaa93e21a005b9a1af8c7abc68465cf9109111 100644 (file)
@@ -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*) {}
index b94969890d1f540e982d696452fc772286d3c84f..603458ba26abcddb7e6370454971572fef142a0a 100644 (file)
@@ -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 @@ static inline bool supports_simd(int minLevel) {
 
 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;