Sampler bias for all nofilter flavors
authorfmalita <fmalita@chromium.org>
Tue, 2 Feb 2016 18:17:24 +0000 (10:17 -0800)
committerCommit bot <commit-bot@chromium.org>
Tue, 2 Feb 2016 18:17:25 +0000 (10:17 -0800)
Instead of a piecemeal approach to sampler bias (http://crrev.com/1642273002,
http://crrev.com/1539083002), audit all nofilter procs (grep "fInvProc(")
and convert them to SkBitmapProcStateAutoMapper.

GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1656833002
CQ_EXTRA_TRYBOTS=client.skia:Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-SKNX_NO_SIMD-Trybot
R=reed@google.com

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

src/core/SkBitmapProcState.cpp
src/core/SkBitmapProcState_matrixProcs.cpp
src/opts/SkBitmapProcState_matrix_neon.h
src/opts/SkBitmapProcState_opts_SSE2.cpp

index 163bc88..f62f4f0 100644 (file)
@@ -492,21 +492,17 @@ static void S32_D32_constX_shaderproc(const void* sIn,
         int yTemp;
 
         if (s.fInvType > SkMatrix::kTranslate_Mask) {
-            // TODO(fmalita): looks like another SkBitmapProcStateAutoMapper customer
-            SkPoint pt;
-            s.fInvProc(s.fInvMatrix,
-                       SkIntToScalar(x) + SK_ScalarHalf,
-                       SkIntToScalar(y) + SK_ScalarHalf,
-                       &pt);
+            const SkBitmapProcStateAutoMapper mapper(s, x, y);
+
             // When the matrix has a scale component the setup code in
             // chooseProcs multiples the inverse matrix by the inverse of the
             // bitmap's width and height. Since this method is going to do
             // its own tiling and sampling we need to undo that here.
             if (SkShader::kClamp_TileMode != s.fTileModeX ||
                 SkShader::kClamp_TileMode != s.fTileModeY) {
-                yTemp = SkScalarFloorToInt(pt.fY * s.fPixmap.height());
+                yTemp = SkFractionalIntToInt(mapper.y() * s.fPixmap.height());
             } else {
-                yTemp = SkScalarFloorToInt(pt.fY);
+                yTemp = SkFractionalIntToInt(mapper.y());
             }
         } else {
             yTemp = s.fFilterOneY + y;
@@ -528,20 +524,14 @@ static void S32_D32_constX_shaderproc(const void* sIn,
 
 #ifdef SK_DEBUG
         {
+            const SkBitmapProcStateAutoMapper mapper(s, x, y);
             int iY2;
-            if (s.fInvType > SkMatrix::kTranslate_Mask) {
-                SkPoint pt;
-                s.fInvProc(s.fInvMatrix,
-                           SkIntToScalar(x) + SK_ScalarHalf,
-                           SkIntToScalar(y) + SK_ScalarHalf,
-                           &pt);
-                if (SkShader::kClamp_TileMode != s.fTileModeX ||
-                    SkShader::kClamp_TileMode != s.fTileModeY) {
-                    pt.fY *= s.fPixmap.height();
-                }
-                iY2 = SkScalarFloorToInt(pt.fY);
+
+            if (s.fInvType > SkMatrix::kTranslate_Mask &&
+                (SkShader::kClamp_TileMode != s.fTileModeX ||
+                 SkShader::kClamp_TileMode != s.fTileModeY)) {
+                iY2 = SkFractionalIntToInt(mapper.y() * s.fPixmap.height());
             } else {
-                const SkBitmapProcStateAutoMapper mapper(s, x, y);
                 iY2 = SkFractionalIntToInt(mapper.y());
             }
 
index 1c4b7b6..d7457ec 100644 (file)
@@ -328,14 +328,11 @@ static void fill_sequential(uint16_t xptr[], int start, int count) {
 
 static int nofilter_trans_preamble(const SkBitmapProcState& s, uint32_t** xy,
                                    int x, int y) {
-    SkPoint pt;
-    s.fInvProc(s.fInvMatrix, SkIntToScalar(x) + SK_ScalarHalf,
-               SkIntToScalar(y) + SK_ScalarHalf, &pt);
-    **xy = s.fIntTileProcY(SkScalarToFixed(pt.fY) >> 16,
-                           s.fPixmap.height());
+    const SkBitmapProcStateAutoMapper mapper(s, x, y);
+    **xy = s.fIntTileProcY(SkFractionalIntToInt(mapper.y()), s.fPixmap.height());
     *xy += 1;   // bump the ptr
     // return our starting X position
-    return SkScalarToFixed(pt.fX) >> 16;
+    return SkFractionalIntToInt(mapper.x());
 }
 
 static void clampx_nofilter_trans(const SkBitmapProcState& s,
index fbb2a1e..4546f70 100644 (file)
@@ -38,13 +38,10 @@ static void SCALE_NOFILTER_NAME(const SkBitmapProcState& s,
     const unsigned maxX = s.fPixmap.width() - 1;
     SkFractionalInt fx;
     {
-        SkPoint pt;
-        s.fInvProc(s.fInvMatrix, SkIntToScalar(x) + SK_ScalarHalf,
-                                 SkIntToScalar(y) + SK_ScalarHalf, &pt);
-        fx = SkScalarToFractionalInt(pt.fY);
+        const SkBitmapProcStateAutoMapper mapper(s, x, y);
         const unsigned maxY = s.fPixmap.height() - 1;
-        *xy++ = TILEY_PROCF(SkFractionalIntToFixed(fx), maxY);
-        fx = SkScalarToFractionalInt(pt.fX);
+        *xy++ = TILEY_PROCF(SkFractionalIntToFixed(mapper.y()), maxY);
+        fx = mapper.x();
     }
 
     if (0 == maxX) {
@@ -118,13 +115,10 @@ static void AFFINE_NOFILTER_NAME(const SkBitmapProcState& s,
                              SkMatrix::kAffine_Mask)) == 0);
 
     PREAMBLE(s);
-    SkPoint srcPt;
-    s.fInvProc(s.fInvMatrix,
-               SkIntToScalar(x) + SK_ScalarHalf,
-               SkIntToScalar(y) + SK_ScalarHalf, &srcPt);
+    const SkBitmapProcStateAutoMapper mapper(s, x, y);
 
-    SkFractionalInt fx = SkScalarToFractionalInt(srcPt.fX);
-    SkFractionalInt fy = SkScalarToFractionalInt(srcPt.fY);
+    SkFractionalInt fx = mapper.x();
+    SkFractionalInt fy = mapper.y();
     SkFractionalInt dx = s.fInvSxFractionalInt;
     SkFractionalInt dy = s.fInvKyFractionalInt;
     int maxX = s.fPixmap.width() - 1;
index cffe962..b5da8e2 100644 (file)
@@ -374,14 +374,10 @@ void ClampX_ClampY_nofilter_scale_SSE2(const SkBitmapProcState& s,
 
     // we store y, x, x, x, x, x
     const unsigned maxX = s.fPixmap.width() - 1;
-    SkFixed fx;
-    SkPoint pt;
-    s.fInvProc(s.fInvMatrix, SkIntToScalar(x) + SK_ScalarHalf,
-                             SkIntToScalar(y) + SK_ScalarHalf, &pt);
-    fx = SkScalarToFixed(pt.fY);
+    const SkBitmapProcStateAutoMapper mapper(s, x, y);
     const unsigned maxY = s.fPixmap.height() - 1;
-    *xy++ = SkClampMax(fx >> 16, maxY);
-    fx = SkScalarToFixed(pt.fX);
+    *xy++ = SkClampMax(SkFractionalIntToInt(mapper.y()), maxY);
+    SkFixed fx = SkFractionalIntToFixed(mapper.x());
 
     if (0 == maxX) {
         // all of the following X values must be 0
@@ -565,13 +561,10 @@ void ClampX_ClampY_nofilter_affine_SSE2(const SkBitmapProcState& s,
                              SkMatrix::kScale_Mask |
                              SkMatrix::kAffine_Mask)) == 0);
 
-    SkPoint srcPt;
-    s.fInvProc(s.fInvMatrix,
-               SkIntToScalar(x) + SK_ScalarHalf,
-               SkIntToScalar(y) + SK_ScalarHalf, &srcPt);
+    const SkBitmapProcStateAutoMapper mapper(s, x, y);
 
-    SkFixed fx = SkScalarToFixed(srcPt.fX);
-    SkFixed fy = SkScalarToFixed(srcPt.fY);
+    SkFixed fx = SkFractionalIntToFixed(mapper.x());
+    SkFixed fy = SkFractionalIntToFixed(mapper.y());
     SkFixed dx = s.fInvSx;
     SkFixed dy = s.fInvKy;
     int maxX = s.fPixmap.width() - 1;