apply FractionalInt improvement to rotated
authorreed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Thu, 8 Mar 2012 20:13:46 +0000 (20:13 +0000)
committerreed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Thu, 8 Mar 2012 20:13:46 +0000 (20:13 +0000)
git-svn-id: http://skia.googlecode.com/svn/trunk@3348 2bbb7eff-a529-9590-31e7-b0007b416f81

src/core/SkBitmapProcState.cpp
src/core/SkBitmapProcState.h
src/core/SkBitmapProcState_matrix.h

index 744a9e4..75d2791 100644 (file)
@@ -392,6 +392,7 @@ bool SkBitmapProcState::chooseProcs(const SkMatrix& inv, const SkPaint& paint) {
     fInvSx          = SkScalarToFixed(m->getScaleX());
     fInvSxFractionalInt = SkScalarToFractionalInt(m->getScaleX());
     fInvKy          = SkScalarToFixed(m->getSkewY());
+    fInvKyFractionalInt = SkScalarToFractionalInt(m->getSkewY());
 
     fAlphaScale = SkAlpha255To256(paint.getAlpha());
 
index 97705be..ccbe060 100644 (file)
     typedef SkFixed48    SkFractionalInt;
     #define SkScalarToFractionalInt(x)  SkScalarToFixed48(x)
     #define SkFractionalIntToFixed(x)   SkFixed48ToFixed(x)
+    #define SkFixedToFractionalInt(x)   SkFixedToFixed48(x)
     #define SkFractionalIntToInt(x)     SkFixed48ToInt(x)
 #else
     typedef SkFixed    SkFractionalInt;
     #define SkScalarToFractionalInt(x)  SkScalarToFixed(x)
     #define SkFractionalIntToFixed(x)   (x)
+    #define SkFixedToFractionalInt(x)   (x)
     #define SkFractionalIntToInt(x)     ((x) >> 16)
 #endif
 
@@ -69,6 +71,7 @@ struct SkBitmapProcState {
     SkMatrix::MapXYProc fInvProc;           // chooseProcs
 
     SkFractionalInt     fInvSxFractionalInt;
+    SkFractionalInt     fInvKyFractionalInt;
     
     FixedTileProc       fTileProcX;         // chooseProcs
     FixedTileProc       fTileProcY;         // chooseProcs
index 3d959dd..0fe0c19 100644 (file)
@@ -108,13 +108,13 @@ void AFFINE_NOFILTER_NAME(const SkBitmapProcState& s,
 
     SkFractionalInt fx = SkScalarToFractionalInt(srcPt.fX);
     SkFractionalInt fy = SkScalarToFractionalInt(srcPt.fY);
-    SkFractionalInt dx = s.fInvSx;
-    SkFractionalInt dy = s.fInvKy;
+    SkFractionalInt dx = s.fInvSxFractionalInt;
+    SkFractionalInt dy = s.fInvKyFractionalInt;
     int maxX = s.fBitmap->width() - 1;
     int maxY = s.fBitmap->height() - 1;
     
     for (int i = count; i > 0; --i) {
-        *xy++ = (TILEY_PROCF(SkFractionalIntToFixed(fx), maxY) << 16) |
+        *xy++ = (TILEY_PROCF(SkFractionalIntToFixed(fy), maxY) << 16) |
                  TILEX_PROCF(SkFractionalIntToFixed(fx), maxX);
         fx += dx; fy += dy;
     }
@@ -169,8 +169,8 @@ void SCALE_FILTER_NAME(const SkBitmapProcState& s,
     
     const unsigned maxX = s.fBitmap->width() - 1;
     const SkFixed one = s.fFilterOneX;
-    const SkFixed dx = s.fInvSx;
-    SkFixed fx;
+    const SkFractionalInt dx = s.fInvSxFractionalInt;
+    SkFractionalInt fx;
 
     {
         SkPoint pt;
@@ -181,7 +181,7 @@ void SCALE_FILTER_NAME(const SkBitmapProcState& s,
         // compute our two Y values up front
         *xy++ = PACK_FILTER_Y_NAME(fy, maxY, s.fFilterOneY PREAMBLE_ARG_Y);
         // now initialize fx
-        fx = SkScalarToFixed(pt.fX) - (one >> 1);
+        fx = SkScalarToFractionalInt(pt.fX) - (SkFixedToFractionalInt(one) >> 1);
     }
 
 #ifdef CHECK_FOR_DECAL
@@ -194,7 +194,8 @@ void SCALE_FILTER_NAME(const SkBitmapProcState& s,
 #endif
     {
         do {
-            *xy++ = PACK_FILTER_X_NAME(fx, maxX, one PREAMBLE_ARG_X);
+            SkFixed fixedFx = SkFractionalIntToFixed(fx);
+            *xy++ = PACK_FILTER_X_NAME(fixedFx, maxX, one PREAMBLE_ARG_X);
             fx += dx;
         } while (--count != 0);
     }