diff options
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/SkBitmapProcState.cpp | 1 | ||||
-rw-r--r-- | src/core/SkBitmapProcState.h | 16 | ||||
-rw-r--r-- | src/core/SkBitmapProcState_matrix.h | 42 |
3 files changed, 39 insertions, 20 deletions
diff --git a/src/core/SkBitmapProcState.cpp b/src/core/SkBitmapProcState.cpp index 3d34b2007a..744a9e4076 100644 --- a/src/core/SkBitmapProcState.cpp +++ b/src/core/SkBitmapProcState.cpp @@ -390,6 +390,7 @@ bool SkBitmapProcState::chooseProcs(const SkMatrix& inv, const SkPaint& paint) { fInvProc = m->getMapXYProc(); fInvType = m->getType(); fInvSx = SkScalarToFixed(m->getScaleX()); + fInvSxFractionalInt = SkScalarToFractionalInt(m->getScaleX()); fInvKy = SkScalarToFixed(m->getSkewY()); fAlphaScale = SkAlpha255To256(paint.getAlpha()); diff --git a/src/core/SkBitmapProcState.h b/src/core/SkBitmapProcState.h index f80671ab4c..97705becf9 100644 --- a/src/core/SkBitmapProcState.h +++ b/src/core/SkBitmapProcState.h @@ -13,6 +13,20 @@ #include "SkBitmap.h" #include "SkMatrix.h" +#define FractionalInt_IS_64BIT + +#ifdef FractionalInt_IS_64BIT + typedef SkFixed48 SkFractionalInt; + #define SkScalarToFractionalInt(x) SkScalarToFixed48(x) + #define SkFractionalIntToFixed(x) SkFixed48ToFixed(x) + #define SkFractionalIntToInt(x) SkFixed48ToInt(x) +#else + typedef SkFixed SkFractionalInt; + #define SkScalarToFractionalInt(x) SkScalarToFixed(x) + #define SkFractionalIntToFixed(x) (x) + #define SkFractionalIntToInt(x) ((x) >> 16) +#endif + class SkPaint; struct SkBitmapProcState { @@ -54,6 +68,8 @@ struct SkBitmapProcState { const SkMatrix* fInvMatrix; // chooseProcs SkMatrix::MapXYProc fInvProc; // chooseProcs + SkFractionalInt fInvSxFractionalInt; + FixedTileProc fTileProcX; // chooseProcs FixedTileProc fTileProcY; // chooseProcs IntTileProc fIntTileProcY; // chooseProcs diff --git a/src/core/SkBitmapProcState_matrix.h b/src/core/SkBitmapProcState_matrix.h index f427e9681c..3d959dd379 100644 --- a/src/core/SkBitmapProcState_matrix.h +++ b/src/core/SkBitmapProcState_matrix.h @@ -8,7 +8,6 @@ #include "SkMath.h" - #define SCALE_NOFILTER_NAME MAKENAME(_nofilter_scale) #define SCALE_FILTER_NAME MAKENAME(_filter_scale) #define AFFINE_NOFILTER_NAME MAKENAME(_nofilter_affine) @@ -36,15 +35,15 @@ void SCALE_NOFILTER_NAME(const SkBitmapProcState& s, // we store y, x, x, x, x, x const unsigned maxX = s.fBitmap->width() - 1; - SkFixed fx; + SkFractionalInt fx; { SkPoint pt; s.fInvProc(*s.fInvMatrix, SkIntToScalar(x) + SK_ScalarHalf, SkIntToScalar(y) + SK_ScalarHalf, &pt); - fx = SkScalarToFixed(pt.fY); + fx = SkScalarToFractionalInt(pt.fY); const unsigned maxY = s.fBitmap->height() - 1; - *xy++ = TILEY_PROCF(fx, maxY); - fx = SkScalarToFixed(pt.fX); + *xy++ = TILEY_PROCF(SkFractionalIntToFixed(fx), maxY); + fx = SkScalarToFractionalInt(pt.fX); } if (0 == maxX) { @@ -53,28 +52,30 @@ void SCALE_NOFILTER_NAME(const SkBitmapProcState& s, return; } - const SkFixed dx = s.fInvSx; + const SkFractionalInt dx = s.fInvSxFractionalInt; #ifdef CHECK_FOR_DECAL // test if we don't need to apply the tile proc - if ((unsigned)(fx >> 16) <= maxX && - (unsigned)((fx + dx * (count - 1)) >> 16) <= maxX) { - decal_nofilter_scale(xy, fx, dx, count); + SkFixed tmpFx = SkFractionalIntToFixed(fx); + SkFixed tmpDx = SkFractionalIntToFixed(dx); + if ((unsigned)(tmpFx >> 16) <= maxX && + (unsigned)((tmpFx + tmpDx * (count - 1)) >> 16) <= maxX) { + decal_nofilter_scale(xy, tmpFx, tmpDx, count); } else #endif { int i; for (i = (count >> 2); i > 0; --i) { unsigned a, b; - a = TILEX_PROCF(fx, maxX); fx += dx; - b = TILEX_PROCF(fx, maxX); fx += dx; + a = TILEX_PROCF(SkFractionalIntToFixed(fx), maxX); fx += dx; + b = TILEX_PROCF(SkFractionalIntToFixed(fx), maxX); fx += dx; #ifdef SK_CPU_BENDIAN *xy++ = (a << 16) | b; #else *xy++ = (b << 16) | a; #endif - a = TILEX_PROCF(fx, maxX); fx += dx; - b = TILEX_PROCF(fx, maxX); fx += dx; + a = TILEX_PROCF(SkFractionalIntToFixed(fx), maxX); fx += dx; + b = TILEX_PROCF(SkFractionalIntToFixed(fx), maxX); fx += dx; #ifdef SK_CPU_BENDIAN *xy++ = (a << 16) | b; #else @@ -83,7 +84,7 @@ void SCALE_NOFILTER_NAME(const SkBitmapProcState& s, } uint16_t* xx = (uint16_t*)xy; for (i = (count & 3); i > 0; --i) { - *xx++ = TILEX_PROCF(fx, maxX); fx += dx; + *xx++ = TILEX_PROCF(SkFractionalIntToFixed(fx), maxX); fx += dx; } } } @@ -104,16 +105,17 @@ void AFFINE_NOFILTER_NAME(const SkBitmapProcState& s, s.fInvProc(*s.fInvMatrix, SkIntToScalar(x) + SK_ScalarHalf, SkIntToScalar(y) + SK_ScalarHalf, &srcPt); - - SkFixed fx = SkScalarToFixed(srcPt.fX); - SkFixed fy = SkScalarToFixed(srcPt.fY); - SkFixed dx = s.fInvSx; - SkFixed dy = s.fInvKy; + + SkFractionalInt fx = SkScalarToFractionalInt(srcPt.fX); + SkFractionalInt fy = SkScalarToFractionalInt(srcPt.fY); + SkFractionalInt dx = s.fInvSx; + SkFractionalInt dy = s.fInvKy; int maxX = s.fBitmap->width() - 1; int maxY = s.fBitmap->height() - 1; for (int i = count; i > 0; --i) { - *xy++ = (TILEY_PROCF(fy, maxY) << 16) | TILEX_PROCF(fx, maxX); + *xy++ = (TILEY_PROCF(SkFractionalIntToFixed(fx), maxY) << 16) | + TILEX_PROCF(SkFractionalIntToFixed(fx), maxX); fx += dx; fy += dy; } } |