uint16_t colors[]);
typedef U16CPU (*FixedTileProc)(SkFixed); // returns 0..0xFFFF
+ typedef U16CPU (*FixedTileLowBitsProc)(SkFixed, int); // returns 0..0xF
typedef U16CPU (*IntTileProc)(int value, int count); // returns 0..count-1
// If a shader proc is present, then the corresponding matrix/sample procs
FixedTileProc fTileProcX; // chooseProcs
FixedTileProc fTileProcY; // chooseProcs
+ FixedTileLowBitsProc fTileLowBitsProcX; // chooseProcs
+ FixedTileLowBitsProc fTileLowBitsProcY; // chooseProcs
IntTileProc fIntTileProcY; // chooseProcs
SkFixed fFilterOneX;
SkFixed fFilterOneY;
#define MAKENAME(suffix) GeneralXY ## suffix
#define PREAMBLE(state) SkBitmapProcState::FixedTileProc tileProcX = (state).fTileProcX; \
- SkBitmapProcState::FixedTileProc tileProcY = (state).fTileProcY
-#define PREAMBLE_PARAM_X , SkBitmapProcState::FixedTileProc tileProcX
-#define PREAMBLE_PARAM_Y , SkBitmapProcState::FixedTileProc tileProcY
-#define PREAMBLE_ARG_X , tileProcX
-#define PREAMBLE_ARG_Y , tileProcY
+ SkBitmapProcState::FixedTileProc tileProcY = (state).fTileProcY; \
+ SkBitmapProcState::FixedTileLowBitsProc tileLowBitsProcX = (state).fTileLowBitsProcX; \
+ SkBitmapProcState::FixedTileLowBitsProc tileLowBitsProcY = (state).fTileLowBitsProcY
+#define PREAMBLE_PARAM_X , SkBitmapProcState::FixedTileProc tileProcX, SkBitmapProcState::FixedTileLowBitsProc tileLowBitsProcX
+#define PREAMBLE_PARAM_Y , SkBitmapProcState::FixedTileProc tileProcY, SkBitmapProcState::FixedTileLowBitsProc tileLowBitsProcY
+#define PREAMBLE_ARG_X , tileProcX, tileLowBitsProcX
+#define PREAMBLE_ARG_Y , tileProcY, tileLowBitsProcY
#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_LOW_BITS(fx, max) tileLowBitsProcX(fx, (max) + 1)
+#define TILEY_LOW_BITS(fy, max) tileLowBitsProcY(fy, (max) + 1)
#include "SkBitmapProcState_matrix.h"
static inline U16CPU fixed_clamp(SkFixed x)
return fixed_mirror;
}
+static inline U16CPU fixed_clamp_lowbits(SkFixed x, int) {
+ return (x >> 12) & 0xF;
+}
+
+static inline U16CPU fixed_repeat_or_mirrow_lowbits(SkFixed x, int scale) {
+ return ((x * scale) >> 12) & 0xF;
+}
+
+static SkBitmapProcState::FixedTileLowBitsProc choose_tile_lowbits_proc(unsigned m) {
+ if (SkShader::kClamp_TileMode == m) {
+ return fixed_clamp_lowbits;
+ } else {
+ SkASSERT(SkShader::kMirror_TileMode == m ||
+ SkShader::kRepeat_TileMode == m);
+ // mirror and repeat have the same behavior for the low bits.
+ return fixed_repeat_or_mirrow_lowbits;
+ }
+}
+
static inline U16CPU int_clamp(int x, int n) {
#ifdef SK_CPU_HAS_CONDITIONAL_INSTR
if (x >= n)
fTileProcX = choose_tile_proc(fTileModeX);
fTileProcY = choose_tile_proc(fTileModeY);
+ fTileLowBitsProcX = choose_tile_lowbits_proc(fTileModeX);
+ fTileLowBitsProcY = choose_tile_lowbits_proc(fTileModeY);
return GeneralXY_Procs[index];
}