| OLD | NEW |
| 1 #include "SkBitmapProcState.h" | 1 #include "SkBitmapProcState.h" |
| 2 #include "SkPerspIter.h" | 2 #include "SkPerspIter.h" |
| 3 #include "SkShader.h" | 3 #include "SkShader.h" |
| 4 | 4 |
| 5 void decal_nofilter_scale(uint32_t dst[], SkFixed fx, SkFixed dx, int count); | 5 void decal_nofilter_scale(uint32_t dst[], SkFixed fx, SkFixed dx, int count); |
| 6 void decal_filter_scale(uint32_t dst[], SkFixed fx, SkFixed dx, int count); | 6 void decal_filter_scale(uint32_t dst[], SkFixed fx, SkFixed dx, int count); |
| 7 | 7 |
| 8 #ifdef SK_CPU_BENDIAN | 8 #ifdef SK_CPU_BENDIAN |
| 9 #define PACK_TWO_SHORTS(pri, sec) ((pri) << 16 | (sec)) | 9 #define PACK_TWO_SHORTS(pri, sec) ((pri) << 16 | (sec)) |
| 10 #else | 10 #else |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 #else | 21 #else |
| 22 #define pack_two_shorts(pri, sec) PACK_TWO_SHORTS(pri, sec) | 22 #define pack_two_shorts(pri, sec) PACK_TWO_SHORTS(pri, sec) |
| 23 #endif | 23 #endif |
| 24 | 24 |
| 25 #define MAKENAME(suffix) ClampX_ClampY ## suffix | 25 #define MAKENAME(suffix) ClampX_ClampY ## suffix |
| 26 #define TILEX_PROCF(fx, max) SkClampMax((fx) >> 16, max) | 26 #define TILEX_PROCF(fx, max) SkClampMax((fx) >> 16, max) |
| 27 #define TILEY_PROCF(fy, max) SkClampMax((fy) >> 16, max) | 27 #define TILEY_PROCF(fy, max) SkClampMax((fy) >> 16, max) |
| 28 #define TILEX_LOW_BITS(fx, max) (((fx) >> 12) & 0xF) | 28 #define TILEX_LOW_BITS(fx, max) (((fx) >> 12) & 0xF) |
| 29 #define TILEY_LOW_BITS(fy, max) (((fy) >> 12) & 0xF) | 29 #define TILEY_LOW_BITS(fy, max) (((fy) >> 12) & 0xF) |
| 30 #define CHECK_FOR_DECAL | 30 #define CHECK_FOR_DECAL |
| 31 #define TILEX_TRANS(x, max) SkClampMax(x, max) |
| 32 #define TILEY_TRANS(y, max) SkClampMax(y, max) |
| 31 #include "SkBitmapProcState_matrix.h" | 33 #include "SkBitmapProcState_matrix.h" |
| 32 | 34 |
| 33 #define MAKENAME(suffix) RepeatX_RepeatY ## suffix | 35 #define MAKENAME(suffix) RepeatX_RepeatY ## suffix |
| 34 #define TILEX_PROCF(fx, max) (((fx) & 0xFFFF) * ((max) + 1) >> 16) | 36 #define TILEX_PROCF(fx, max) (((fx) & 0xFFFF) * ((max) + 1) >> 16) |
| 35 #define TILEY_PROCF(fy, max) (((fy) & 0xFFFF) * ((max) + 1) >> 16) | 37 #define TILEY_PROCF(fy, max) (((fy) & 0xFFFF) * ((max) + 1) >> 16) |
| 36 #define TILEX_LOW_BITS(fx, max) ((((fx) & 0xFFFF) * ((max) + 1) >> 12) & 0xF) | 38 #define TILEX_LOW_BITS(fx, max) ((((fx) & 0xFFFF) * ((max) + 1) >> 12) & 0xF) |
| 37 #define TILEY_LOW_BITS(fy, max) ((((fy) & 0xFFFF) * ((max) + 1) >> 12) & 0xF) | 39 #define TILEY_LOW_BITS(fy, max) ((((fy) & 0xFFFF) * ((max) + 1) >> 12) & 0xF) |
| 40 #define TILEX_TRANS(x, max) ((x) % ((max) + 1)) |
| 41 #define TILEY_TRANS(y, max) ((y) % ((max) + 1)) |
| 38 #include "SkBitmapProcState_matrix.h" | 42 #include "SkBitmapProcState_matrix.h" |
| 39 | 43 |
| 40 #define MAKENAME(suffix) GeneralXY ## suffix | 44 #define MAKENAME(suffix) GeneralXY ## suffix |
| 41 #define PREAMBLE(state) SkBitmapProcState::FixedTileProc tileProcX = (st
ate).fTileProcX; \ | 45 #define PREAMBLE(state) SkBitmapProcState::FixedTileProc tileProcX = (st
ate).fTileProcX; \ |
| 42 SkBitmapProcState::FixedTileProc tileProcY = (st
ate).fTileProcY | 46 SkBitmapProcState::FixedTileProc tileProcY = (st
ate).fTileProcY |
| 43 #define PREAMBLE_PARAM_X , SkBitmapProcState::FixedTileProc tileProcX | 47 #define PREAMBLE_PARAM_X , SkBitmapProcState::FixedTileProc tileProcX |
| 44 #define PREAMBLE_PARAM_Y , SkBitmapProcState::FixedTileProc tileProcY | 48 #define PREAMBLE_PARAM_Y , SkBitmapProcState::FixedTileProc tileProcY |
| 45 #define PREAMBLE_ARG_X , tileProcX | 49 #define PREAMBLE_ARG_X , tileProcX |
| 46 #define PREAMBLE_ARG_Y , tileProcY | 50 #define PREAMBLE_ARG_Y , tileProcY |
| 47 #define TILEX_PROCF(fx, max) (tileProcX(fx) * ((max) + 1) >> 16) | 51 #define TILEX_PROCF(fx, max) (tileProcX(fx, max) >> 16) |
| 48 #define TILEY_PROCF(fy, max) (tileProcY(fy) * ((max) + 1) >> 16) | 52 #define TILEY_PROCF(fy, max) (tileProcY(fy, max) >> 16) |
| 49 #define TILEX_LOW_BITS(fx, max) ((tileProcX(fx) * ((max) + 1) >> 12) & 0xF) | 53 #define TILEX_LOW_BITS(fx, max) ((tileProcX(fx, max) >> 14) & 0x3) |
| 50 #define TILEY_LOW_BITS(fy, max) ((tileProcY(fy) * ((max) + 1) >> 12) & 0xF) | 54 #define TILEY_LOW_BITS(fy, max) ((tileProcY(fy, max) >> 14) & 0x3) |
| 55 #define PREAMBLE_TRANS(state) SkBitmapProcState::IntTileProc tileProcX = (stat
e).iTileProcX; \ |
| 56 SkBitmapProcState::IntTileProc tileProcY = (stat
e).iTileProcY |
| 57 #define TILEX_TRANS(x, max) tileProcX(x, max) |
| 58 #define TILEY_TRANS(y, max) tileProcY(y, max) |
| 51 #include "SkBitmapProcState_matrix.h" | 59 #include "SkBitmapProcState_matrix.h" |
| 52 | 60 |
| 53 static inline U16CPU fixed_clamp(SkFixed x) | 61 |
| 62 |
| 63 static inline SkFixed fixed_clamp(SkFixed x, int max) |
| 54 { | 64 { |
| 55 #ifdef SK_CPU_HAS_CONDITIONAL_INSTR | 65 #ifdef SK_CPU_HAS_CONDITIONAL_INSTR |
| 56 if (x >> 16) | 66 if (x >> 16) |
| 57 x = 0xFFFF; | 67 x = 0xFFFF; |
| 58 if (x < 0) | 68 if (x < 0) |
| 59 x = 0; | 69 x = 0; |
| 60 #else | 70 #else |
| 61 if (x >> 16) | 71 if (x >> 16) |
| 62 { | 72 { |
| 63 if (x < 0) | 73 if (x < 0) |
| 64 x = 0; | 74 x = 0; |
| 65 else | 75 else |
| 66 x = 0xFFFF; | 76 x = 0xFFFF; |
| 67 } | 77 } |
| 68 #endif | 78 #endif |
| 69 return x; | 79 return x * (max + 1); |
| 70 } | 80 } |
| 71 | 81 |
| 72 static inline U16CPU fixed_repeat(SkFixed x) | 82 static inline SkFixed fixed_repeat(SkFixed x, int max) |
| 73 { | 83 { |
| 74 return x & 0xFFFF; | 84 return (x & 0xFFFF) * (max + 1); |
| 75 } | 85 } |
| 76 | 86 |
| 77 static inline U16CPU fixed_mirror(SkFixed x) | 87 static inline SkFixed fixed_mirror(SkFixed x, int max) |
| 78 { | 88 { |
| 79 SkFixed s = x << 15 >> 31; | 89 SkFixed s = x << 15 >> 31; |
| 80 // s is FFFFFFFF if we're on an odd interval, or 0 if an even interval | 90 // s is FFFFFFFF if we're on an odd interval, or 0 if an even interval |
| 81 return (x ^ s) & 0xFFFF; | 91 x = ((x ^ s) & 0xFFFF) * (max + 1); |
| 92 return s ? (x ^ 0xFFFF) : x; |
| 82 } | 93 } |
| 83 | 94 |
| 84 static SkBitmapProcState::FixedTileProc choose_tile_proc(unsigned m) | 95 static SkBitmapProcState::FixedTileProc choose_tile_proc(unsigned m) |
| 85 { | 96 { |
| 86 if (SkShader::kClamp_TileMode == m) | 97 if (SkShader::kClamp_TileMode == m) |
| 87 return fixed_clamp; | 98 return fixed_clamp; |
| 88 if (SkShader::kRepeat_TileMode == m) | 99 if (SkShader::kRepeat_TileMode == m) |
| 89 return fixed_repeat; | 100 return fixed_repeat; |
| 90 SkASSERT(SkShader::kMirror_TileMode == m); | 101 SkASSERT(SkShader::kMirror_TileMode == m); |
| 91 return fixed_mirror; | 102 return fixed_mirror; |
| 92 } | 103 } |
| 93 | 104 |
| 105 static inline int int_clamp(int x, int max) |
| 106 { |
| 107 SkASSERT(max >= 0); |
| 108 |
| 109 return SkClampMax(x, max); |
| 110 } |
| 111 |
| 112 static inline int int_repeat(int x, int max) |
| 113 { |
| 114 SkASSERT(max >= 0); |
| 115 |
| 116 return x % (max + 1); |
| 117 } |
| 118 |
| 119 static inline int int_mirror(int x, int max) |
| 120 { |
| 121 SkASSERT(max >= 0); |
| 122 |
| 123 int dx = x % (max + 1); |
| 124 if (dx < 0) |
| 125 dx = -dx - 1; |
| 126 |
| 127 return (x / (max + 1) % 2) ? max - dx : dx; |
| 128 } |
| 129 |
| 130 static SkBitmapProcState::IntTileProc choose_int_tile_proc(unsigned m) |
| 131 { |
| 132 if (SkShader::kClamp_TileMode == m) |
| 133 return int_clamp; |
| 134 if (SkShader::kRepeat_TileMode == m) |
| 135 return int_repeat; |
| 136 SkASSERT(SkShader::kMirror_TileMode == m); |
| 137 return int_mirror; |
| 138 } |
| 139 |
| 94 SkBitmapProcState::MatrixProc SkBitmapProcState::chooseMatrixProc() | 140 SkBitmapProcState::MatrixProc SkBitmapProcState::chooseMatrixProc() |
| 95 { | 141 { |
| 96 int index = 0; | 142 int index = 0; |
| 97 if (fDoFilter) | 143 if (fDoFilter) |
| 98 index = 1; | 144 index = 1; |
| 99 if (fInvType & SkMatrix::kPerspective_Mask) | 145 if (fInvType & SkMatrix::kPerspective_Mask) |
| 146 index |= 6; |
| 147 else if (fInvType & SkMatrix::kAffine_Mask) |
| 100 index |= 4; | 148 index |= 4; |
| 101 else if (fInvType & SkMatrix::kAffine_Mask) | 149 else if (fInvType & SkMatrix::kScale_Mask) |
| 102 index |= 2; | 150 index |= 2; |
| 103 | 151 |
| 104 if (SkShader::kClamp_TileMode == fTileModeX && | 152 if (SkShader::kClamp_TileMode == fTileModeX && |
| 105 SkShader::kClamp_TileMode == fTileModeY) | 153 SkShader::kClamp_TileMode == fTileModeY) |
| 106 { | 154 { |
| 107 // clamp gets special version of filterOne | 155 // clamp gets special version of filterOne |
| 108 fFilterOneX = SK_Fixed1; | 156 fFilterOneX = SK_Fixed1; |
| 109 fFilterOneY = SK_Fixed1; | 157 fFilterOneY = SK_Fixed1; |
| 110 return ClampX_ClampY_Procs[index]; | 158 return ClampX_ClampY_Procs[index]; |
| 111 } | 159 } |
| 112 | 160 |
| 113 // all remaining procs use this form for filterOne | 161 // all remaining procs use this form for filterOne |
| 114 fFilterOneX = SK_Fixed1 / fBitmap->width(); | 162 fFilterOneX = SK_Fixed1 / fBitmap->width(); |
| 115 fFilterOneY = SK_Fixed1 / fBitmap->height(); | 163 fFilterOneY = SK_Fixed1 / fBitmap->height(); |
| 116 | 164 |
| 117 if (SkShader::kRepeat_TileMode == fTileModeX && | 165 if (SkShader::kRepeat_TileMode == fTileModeX && |
| 118 SkShader::kRepeat_TileMode == fTileModeY) | 166 SkShader::kRepeat_TileMode == fTileModeY) |
| 119 { | 167 { |
| 120 return RepeatX_RepeatY_Procs[index]; | 168 return RepeatX_RepeatY_Procs[index]; |
| 121 } | 169 } |
| 122 | 170 |
| 123 // only general needs these procs | 171 // only general needs these procs |
| 124 fTileProcX = choose_tile_proc(fTileModeX); | 172 fTileProcX = choose_tile_proc(fTileModeX); |
| 125 fTileProcY = choose_tile_proc(fTileModeY); | 173 fTileProcY = choose_tile_proc(fTileModeY); |
| 174 iTileProcX = choose_int_tile_proc(fTileModeX); |
| 175 iTileProcY = choose_int_tile_proc(fTileModeY); |
| 126 return GeneralXY_Procs[index]; | 176 return GeneralXY_Procs[index]; |
| 127 } | 177 } |
| 128 | 178 |
| 129 ////////////////////////////////////////////////////////////////////////////// | 179 ////////////////////////////////////////////////////////////////////////////// |
| 130 | 180 |
| 131 void decal_nofilter_scale(uint32_t dst[], SkFixed fx, SkFixed dx, int count) | 181 void decal_nofilter_scale(uint32_t dst[], SkFixed fx, SkFixed dx, int count) |
| 132 { | 182 { |
| 133 int i; | 183 int i; |
| 134 | 184 |
| 135 for (i = (count >> 2); i > 0; --i) | 185 for (i = (count >> 2); i > 0; --i) |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 while ((count -= width) >= 0) | 240 while ((count -= width) >= 0) |
| 191 for (i = 0; i < width; i++) | 241 for (i = 0; i < width; i++) |
| 192 *xx++ = SkToU16(i); | 242 *xx++ = SkToU16(i); |
| 193 | 243 |
| 194 // final cleanup run | 244 // final cleanup run |
| 195 count += width; | 245 count += width; |
| 196 for (i = 0; i < count; i++) | 246 for (i = 0; i < count; i++) |
| 197 *xx++ = SkToU16(i); | 247 *xx++ = SkToU16(i); |
| 198 } | 248 } |
| 199 | 249 |
| OLD | NEW |