diff options
Diffstat (limited to 'skia/sgl/SkBitmapProcState_matrixProcs.cpp')
-rw-r--r-- | skia/sgl/SkBitmapProcState_matrixProcs.cpp | 72 |
1 files changed, 61 insertions, 11 deletions
diff --git a/skia/sgl/SkBitmapProcState_matrixProcs.cpp b/skia/sgl/SkBitmapProcState_matrixProcs.cpp index beb21c8..a16c8b3 100644 --- a/skia/sgl/SkBitmapProcState_matrixProcs.cpp +++ b/skia/sgl/SkBitmapProcState_matrixProcs.cpp @@ -28,6 +28,8 @@ void decal_filter_scale(uint32_t dst[], SkFixed fx, SkFixed dx, int count); #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 @@ void decal_filter_scale(uint32_t dst[], SkFixed fx, SkFixed dx, int count); #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 @@ void decal_filter_scale(uint32_t dst[], SkFixed fx, SkFixed dx, int count); #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 @@ static inline U16CPU fixed_clamp(SkFixed x) 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 @@ static SkBitmapProcState::FixedTileProc choose_tile_proc(unsigned m) 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 |= 4; + index |= 6; else if (fInvType & SkMatrix::kAffine_Mask) + index |= 4; + else if (fInvType & SkMatrix::kScale_Mask) index |= 2; if (SkShader::kClamp_TileMode == fTileModeX && @@ -123,6 +171,8 @@ SkBitmapProcState::MatrixProc SkBitmapProcState::chooseMatrixProc() // 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]; } |