remove fConvolutionProcs from State, and just use it locally
authorreed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Thu, 5 Sep 2013 20:31:17 +0000 (20:31 +0000)
committerreed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Thu, 5 Sep 2013 20:31:17 +0000 (20:31 +0000)
BUG=
R=humper@google.com

Review URL: https://codereview.chromium.org/23796005

git-svn-id: http://skia.googlecode.com/svn/trunk@11118 2bbb7eff-a529-9590-31e7-b0007b416f81

src/core/SkBitmapProcState.cpp
src/core/SkBitmapProcState.h
src/core/SkBitmapScaler.cpp
src/core/SkBitmapScaler.h
src/core/SkConvolver.cpp
src/core/SkConvolver.h
src/opts/SkBitmapProcState_opts_arm.cpp
src/opts/opts_check_SSE2.cpp

index 821d383e15a33774ed989eaeaebc775b5dfc7d4c..353248f62738a1f6ea35a4ecae1d799e1634ff6d 100644 (file)
@@ -124,15 +124,9 @@ void SkBitmapProcState::possiblyScaleImage() {
     // recompiles a lot less painful.
 
     SkConvolutionProcs simd;
-    fConvolutionProcs = &simd;
+    sk_bzero(&simd, sizeof(simd));
 
-    fConvolutionProcs->fExtraHorizontalReads = 0;
-    fConvolutionProcs->fConvolveVertically = NULL;
-    fConvolutionProcs->fConvolve4RowsHorizontally = NULL;
-    fConvolutionProcs->fConvolveHorizontally = NULL;
-    fConvolutionProcs->fApplySIMDPadding = NULL;
-
-    this->platformConvolutionProcs();
+    this->platformConvolutionProcs(&simd);
 
     // STEP 1: Highest quality direct scale?
 
@@ -162,7 +156,7 @@ void SkBitmapProcState::possiblyScaleImage() {
                                         SkBitmapScaler::RESIZE_BEST,
                                         dest_width,
                                         dest_height,
-                                        fConvolutionProcs)) {
+                                        simd)) {
                 // we failed to create fScaledBitmap, so just return and let
                 // the scanline proc handle it.
                 return;
index 3a1d7bad620c4b9f241ad42d801b32c1b56d6a64..2522a69e7f0e59c776be86663b0f85abcd658f2e 100644 (file)
@@ -79,8 +79,6 @@ struct SkBitmapProcState {
     SkFixed             fFilterOneX;
     SkFixed             fFilterOneY;
 
-    SkConvolutionProcs* fConvolutionProcs;         // possiblyScaleImage
-
     SkPMColor           fPaintPMColor;      // chooseProcs - A8 config
     SkFixed             fInvSx;             // chooseProcs
     SkFixed             fInvKy;             // chooseProcs
@@ -115,7 +113,7 @@ struct SkBitmapProcState {
         if we have SIMD versions of them.
       */
 
-    void platformConvolutionProcs();
+    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
index 807696277ee52adf32badf92fe19135b27330d50..114836dd7967c72419c4ad92253648467cdf3413 100644 (file)
@@ -15,7 +15,7 @@ public:
                    int srcFullWidth, int srcFullHeight,
                    int destWidth, int destHeight,
                    const SkIRect& destSubset,
-                   SkConvolutionProcs* convolveProcs);
+                   const SkConvolutionProcs& convolveProcs);
     ~SkResizeFilter() {
         SkDELETE( fBitmapFilter );
     }
@@ -43,7 +43,7 @@ private:
                         int destSubsetLo, int destSubsetSize,
                         float scale,
                         SkConvolutionFilter1D* output,
-                        SkConvolutionProcs* convolveProcs);
+                        const SkConvolutionProcs& convolveProcs);
 
     SkConvolutionFilter1D fXFilter;
     SkConvolutionFilter1D fYFilter;
@@ -53,7 +53,7 @@ SkResizeFilter::SkResizeFilter(SkBitmapScaler::ResizeMethod method,
                                int srcFullWidth, int srcFullHeight,
                                int destWidth, int destHeight,
                                const SkIRect& destSubset,
-                               SkConvolutionProcs* convolveProcs) {
+                               const SkConvolutionProcs& convolveProcs) {
 
     // method will only ever refer to an "algorithm method".
     SkASSERT((SkBitmapScaler::RESIZE_FIRST_ALGORITHM_METHOD <= method) &&
@@ -108,7 +108,7 @@ void SkResizeFilter::computeFilters(int srcSize,
                                   int destSubsetLo, int destSubsetSize,
                                   float scale,
                                   SkConvolutionFilter1D* output,
-                                  SkConvolutionProcs* convolveProcs) {
+                                  const SkConvolutionProcs& convolveProcs) {
   int destSubsetHi = destSubsetLo + destSubsetSize;  // [lo, hi)
 
   // When we're doing a magnification, the scale will be larger than one. This
@@ -197,8 +197,8 @@ void SkResizeFilter::computeFilters(int srcSize,
                       static_cast<int>(fixedFilterValues.count()));
   }
 
-  if (convolveProcs->fApplySIMDPadding) {
-      convolveProcs->fApplySIMDPadding( output );
+  if (convolveProcs.fApplySIMDPadding) {
+      convolveProcs.fApplySIMDPadding( output );
   }
 }
 
@@ -238,7 +238,7 @@ bool SkBitmapScaler::Resize(SkBitmap* resultPtr,
                             ResizeMethod method,
                             int destWidth, int destHeight,
                             const SkIRect& destSubset,
-                            SkConvolutionProcs* convolveProcs,
+                            const SkConvolutionProcs& convolveProcs,
                             SkBitmap::Allocator* allocator) {
   // Ensure that the ResizeMethod enumeration is sound.
     SkASSERT(((RESIZE_FIRST_QUALITY_METHOD <= method) &&
@@ -310,7 +310,7 @@ bool SkBitmapScaler::Resize(SkBitmap* resultPtr,
                             const SkBitmap& source,
                             ResizeMethod method,
                             int destWidth, int destHeight,
-                            SkConvolutionProcs* convolveProcs,
+                            const SkConvolutionProcs& convolveProcs,
                             SkBitmap::Allocator* allocator) {
     SkIRect destSubset = { 0, 0, destWidth, destHeight };
     return Resize(resultPtr, source, method, destWidth, destHeight, destSubset,
index b88fb9e7757c2f83d25a421754b670f44d8ed8af..c8d8a84185e3601ef028ec56b44e3bcd5895d79a 100644 (file)
@@ -92,7 +92,7 @@ public:
                        ResizeMethod method,
                        int dest_width, int dest_height,
                        const SkIRect& dest_subset,
-                       SkConvolutionProcs *convolveProcs = NULL,
+                       const SkConvolutionProcs&,
                        SkBitmap::Allocator* allocator = NULL);
 
     // Alternate version for resizing and returning the entire bitmap rather than
@@ -101,7 +101,7 @@ public:
                        const SkBitmap& source,
                        ResizeMethod method,
                        int dest_width, int dest_height,
-                       SkConvolutionProcs *convolveProcs = NULL,
+                       const SkConvolutionProcs&,
                        SkBitmap::Allocator* allocator = NULL);
 };
 
index f426ef00d111277e55d209005198e52364b58a1b..7666e6fadc99ac3b161403c91bee35fa0fdbe529 100644 (file)
@@ -337,7 +337,7 @@ void BGRAConvolve2D(const unsigned char* sourceData,
                     const SkConvolutionFilter1D& filterY,
                     int outputByteRowStride,
                     unsigned char* output,
-                    SkConvolutionProcs* convolveProcs,
+                    const SkConvolutionProcs& convolveProcs,
                     bool useSimdIfPossible) {
 
     int maxYFilterSize = filterY.maxFilter();
@@ -364,7 +364,7 @@ void BGRAConvolve2D(const unsigned char* sourceData,
     // convolution pass yet. Somehow Windows does not like it.
     int rowBufferWidth = (filterX.numValues() + 15) & ~0xF;
     int rowBufferHeight = maxYFilterSize +
-                          (convolveProcs->fConvolve4RowsHorizontally ? 4 : 0);
+                          (convolveProcs.fConvolve4RowsHorizontally ? 4 : 0);
     CircularRowBuffer rowBuffer(rowBufferWidth,
                                 rowBufferHeight,
                                 filterOffset);
@@ -387,7 +387,7 @@ void BGRAConvolve2D(const unsigned char* sourceData,
     // rows we need to avoid the SSE implementation for here.
     filterX.FilterForValue(filterX.numValues() - 1, &lastFilterOffset,
                            &lastFilterLength);
-    int avoidSimdRows = 1 + convolveProcs->fExtraHorizontalReads /
+    int avoidSimdRows = 1 + convolveProcs.fExtraHorizontalReads /
         (lastFilterOffset + lastFilterLength);
 
     filterY.FilterForValue(numOutputRows - 1, &lastFilterOffset,
@@ -399,7 +399,7 @@ void BGRAConvolve2D(const unsigned char* sourceData,
 
         // Generate output rows until we have enough to run the current filter.
         while (nextXRow < filterOffset + filterLength) {
-            if (convolveProcs->fConvolve4RowsHorizontally &&
+            if (convolveProcs.fConvolve4RowsHorizontally &&
                 nextXRow + 3 < lastFilterOffset + lastFilterLength -
                 avoidSimdRows) {
                 const unsigned char* src[4];
@@ -408,14 +408,14 @@ void BGRAConvolve2D(const unsigned char* sourceData,
                     src[i] = &sourceData[(nextXRow + i) * sourceByteRowStride];
                     outRow[i] = rowBuffer.advanceRow();
                 }
-                convolveProcs->fConvolve4RowsHorizontally(src, filterX, outRow);
+                convolveProcs.fConvolve4RowsHorizontally(src, filterX, outRow);
                 nextXRow += 4;
             } else {
                 // Check if we need to avoid SSE2 for this row.
-                if (convolveProcs->fConvolveHorizontally &&
+                if (convolveProcs.fConvolveHorizontally &&
                     nextXRow < lastFilterOffset + lastFilterLength -
                     avoidSimdRows) {
-                    convolveProcs->fConvolveHorizontally(
+                    convolveProcs.fConvolveHorizontally(
                         &sourceData[nextXRow * sourceByteRowStride],
                         filterX, rowBuffer.advanceRow(), sourceHasAlpha);
                 } else {
@@ -446,8 +446,8 @@ void BGRAConvolve2D(const unsigned char* sourceData,
         unsigned char* const* firstRowForFilter =
             &rowsToConvolve[filterOffset - firstRowInCircularBuffer];
 
-        if (convolveProcs->fConvolveVertically) {
-            convolveProcs->fConvolveVertically(filterValues, filterLength,
+        if (convolveProcs.fConvolveVertically) {
+            convolveProcs.fConvolveVertically(filterValues, filterLength,
                                                firstRowForFilter,
                                                filterX.numValues(), curOutputRow,
                                                sourceHasAlpha);
index 4327afaf1809d1d3f33d684eef47eee683a668cc..94a5e91598782c413d0640379d3afa0eec636257 100644 (file)
@@ -197,7 +197,7 @@ SK_API void BGRAConvolve2D(const unsigned char* sourceData,
     const SkConvolutionFilter1D& yfilter,
     int outputByteRowStride,
     unsigned char* output,
-    SkConvolutionProcs* convolveProcs,
+    const SkConvolutionProcs&,
     bool useSimdIfPossible);
 
 #endif  // SK_CONVOLVER_H
index a9b44daa890489d319355619d169294b54297157..3a3cb8567c9525a0719fdfa99493a63bcfad6ff6 100644 (file)
@@ -401,10 +401,10 @@ void applySIMDPadding_arm(SkConvolutionFilter1D *filter) {
     }
 }
 
-void SkBitmapProcState::platformConvolutionProcs() {
+void SkBitmapProcState::platformConvolutionProcs(SkConvolutionProcs* procs) {
     if (sk_cpu_arm_has_neon()) {
-        fConvolutionProcs->fExtraHorizontalReads = 3;
-        fConvolutionProcs->fConvolveVertically = &convolveVertically_arm;
+        procs->fExtraHorizontalReads = 3;
+        procs->fConvolveVertically = &convolveVertically_arm;
 
         // next line is commented out because the four-row convolution function above is
         // just a no-op.  Please see the comment above its definition, and the SSE implementation
@@ -412,11 +412,11 @@ void SkBitmapProcState::platformConvolutionProcs() {
         // leaving it as NULL will just cause the convolution system to not attempt
         // to operate on four rows at once, which is correct but not performance-optimal.
 
-        // fConvolutionProcs->fConvolve4RowsHorizontally = &convolve4RowsHorizontally_arm;
+        // procs->fConvolve4RowsHorizontally = &convolve4RowsHorizontally_arm;
 
-        fConvolutionProcs->fConvolve4RowsHorizontally = NULL;
+        procs->fConvolve4RowsHorizontally = NULL;
 
-        fConvolutionProcs->fConvolveHorizontally = &convolveHorizontally_arm;
-        fConvolutionProcs->fApplySIMDPadding = &applySIMDPadding_arm;
+        procs->fConvolveHorizontally = &convolveHorizontally_arm;
+        procs->fApplySIMDPadding = &applySIMDPadding_arm;
     }
 }
index 8d43390a22642badb0a0be60e148d33b70688752..8f0bdac8fd88b647bb88b3c1fca6f640526914b1 100644 (file)
@@ -107,13 +107,13 @@ static bool cachedHasSSSE3() {
 
 SK_CONF_DECLARE( bool, c_hqfilter_sse, "bitmap.filter.highQualitySSE", false, "Use SSE optimized version of high quality image filters");
 
-void SkBitmapProcState::platformConvolutionProcs() {
+void SkBitmapProcState::platformConvolutionProcs(SkConvolutionProcs* procs) {
     if (cachedHasSSE2()) {
-        fConvolutionProcs->fExtraHorizontalReads = 3;
-        fConvolutionProcs->fConvolveVertically = &convolveVertically_SSE2;
-        fConvolutionProcs->fConvolve4RowsHorizontally = &convolve4RowsHorizontally_SSE2;
-        fConvolutionProcs->fConvolveHorizontally = &convolveHorizontally_SSE2;
-        fConvolutionProcs->fApplySIMDPadding = &applySIMDPadding_SSE2;
+        procs->fExtraHorizontalReads = 3;
+        procs->fConvolveVertically = &convolveVertically_SSE2;
+        procs->fConvolve4RowsHorizontally = &convolve4RowsHorizontally_SSE2;
+        procs->fConvolveHorizontally = &convolveHorizontally_SSE2;
+        procs->fApplySIMDPadding = &applySIMDPadding_SSE2;
     }
 }