Index: skia/sgl/SkBitmapProcState_matrixProcs.cpp |
=================================================================== |
--- skia/sgl/SkBitmapProcState_matrixProcs.cpp (revision 9831) |
+++ skia/sgl/SkBitmapProcState_matrixProcs.cpp (working copy) |
@@ -28,6 +28,8 @@ |
#define TILEX_LOW_BITS(fx, max) (((fx) >> 12) & 0xF) |
#define TILEY_LOW_BITS(fy, max) (((fy) >> 12) & 0xF) |
#define CHECK_FOR_DECAL |
+#define TILEX_TRANS(x, max) SkClampMax(x, max) |
+#define TILEY_TRANS(y, max) SkClampMax(y, max) |
#include "SkBitmapProcState_matrix.h" |
#define MAKENAME(suffix) RepeatX_RepeatY ## suffix |
@@ -35,6 +37,8 @@ |
#define TILEY_PROCF(fy, max) (((fy) & 0xFFFF) * ((max) + 1) >> 16) |
#define TILEX_LOW_BITS(fx, max) ((((fx) & 0xFFFF) * ((max) + 1) >> 12) & 0xF) |
#define TILEY_LOW_BITS(fy, max) ((((fy) & 0xFFFF) * ((max) + 1) >> 12) & 0xF) |
+#define TILEX_TRANS(x, max) ((x) % ((max) + 1)) |
+#define TILEY_TRANS(y, max) ((y) % ((max) + 1)) |
#include "SkBitmapProcState_matrix.h" |
#define MAKENAME(suffix) GeneralXY ## suffix |
@@ -44,13 +48,19 @@ |
#define PREAMBLE_PARAM_Y , SkBitmapProcState::FixedTileProc tileProcY |
#define PREAMBLE_ARG_X , tileProcX |
#define PREAMBLE_ARG_Y , tileProcY |
-#define TILEX_PROCF(fx, max) (tileProcX(fx) * ((max) + 1) >> 16) |
-#define TILEY_PROCF(fy, max) (tileProcY(fy) * ((max) + 1) >> 16) |
-#define TILEX_LOW_BITS(fx, max) ((tileProcX(fx) * ((max) + 1) >> 12) & 0xF) |
-#define TILEY_LOW_BITS(fy, max) ((tileProcY(fy) * ((max) + 1) >> 12) & 0xF) |
+#define TILEX_PROCF(fx, max) (tileProcX(fx, max) >> 16) |
+#define TILEY_PROCF(fy, max) (tileProcY(fy, max) >> 16) |
+#define TILEX_LOW_BITS(fx, max) ((tileProcX(fx, max) >> 14) & 0x3) |
+#define TILEY_LOW_BITS(fy, max) ((tileProcY(fy, max) >> 14) & 0x3) |
+#define PREAMBLE_TRANS(state) SkBitmapProcState::IntTileProc tileProcX = (state).iTileProcX; \ |
+ SkBitmapProcState::IntTileProc tileProcY = (state).iTileProcY |
+#define TILEX_TRANS(x, max) tileProcX(x, max) |
+#define TILEY_TRANS(y, max) tileProcY(y, max) |
#include "SkBitmapProcState_matrix.h" |
-static inline U16CPU fixed_clamp(SkFixed x) |
+ |
+ |
+static inline SkFixed fixed_clamp(SkFixed x, int max) |
{ |
#ifdef SK_CPU_HAS_CONDITIONAL_INSTR |
if (x >> 16) |
@@ -66,19 +76,20 @@ |
x = 0xFFFF; |
} |
#endif |
- return x; |
+ return x * (max + 1); |
} |
-static inline U16CPU fixed_repeat(SkFixed x) |
+static inline SkFixed fixed_repeat(SkFixed x, int max) |
{ |
- return x & 0xFFFF; |
+ return (x & 0xFFFF) * (max + 1); |
} |
-static inline U16CPU fixed_mirror(SkFixed x) |
+static inline SkFixed fixed_mirror(SkFixed x, int max) |
{ |
SkFixed s = x << 15 >> 31; |
// s is FFFFFFFF if we're on an odd interval, or 0 if an even interval |
- return (x ^ s) & 0xFFFF; |
+ x = ((x ^ s) & 0xFFFF) * (max + 1); |
+ return s ? (x ^ 0xFFFF) : x; |
} |
static SkBitmapProcState::FixedTileProc choose_tile_proc(unsigned m) |
@@ -91,14 +102,51 @@ |
return fixed_mirror; |
} |
+static inline int int_clamp(int x, int max) |
+{ |
+ SkASSERT(max >= 0); |
+ |
+ return SkClampMax(x, max); |
+} |
+ |
+static inline int int_repeat(int x, int max) |
+{ |
+ SkASSERT(max >= 0); |
+ |
+ return x % (max + 1); |
+} |
+ |
+static inline int int_mirror(int x, int max) |
+{ |
+ SkASSERT(max >= 0); |
+ |
+ int dx = x % (max + 1); |
+ if (dx < 0) |
+ dx = -dx - 1; |
+ |
+ return (x / (max + 1) % 2) ? max - dx : dx; |
+} |
+ |
+static SkBitmapProcState::IntTileProc choose_int_tile_proc(unsigned m) |
+{ |
+ if (SkShader::kClamp_TileMode == m) |
+ return int_clamp; |
+ if (SkShader::kRepeat_TileMode == m) |
+ return int_repeat; |
+ SkASSERT(SkShader::kMirror_TileMode == m); |
+ return int_mirror; |
+} |
+ |
SkBitmapProcState::MatrixProc SkBitmapProcState::chooseMatrixProc() |
{ |
int index = 0; |
if (fDoFilter) |
index = 1; |
if (fInvType & SkMatrix::kPerspective_Mask) |
+ index |= 6; |
+ else if (fInvType & SkMatrix::kAffine_Mask) |
index |= 4; |
- else if (fInvType & SkMatrix::kAffine_Mask) |
+ else if (fInvType & SkMatrix::kScale_Mask) |
index |= 2; |
if (SkShader::kClamp_TileMode == fTileModeX && |
@@ -123,6 +171,8 @@ |
// only general needs these procs |
fTileProcX = choose_tile_proc(fTileModeX); |
fTileProcY = choose_tile_proc(fTileModeY); |
+ iTileProcX = choose_int_tile_proc(fTileModeX); |
+ iTileProcY = choose_int_tile_proc(fTileModeY); |
return GeneralXY_Procs[index]; |
} |