OLD | NEW |
1 /* NEON optimized code (C) COPYRIGHT 2009 Motorola | 1 /* NEON optimized code (C) COPYRIGHT 2009 Motorola |
2 * | 2 * |
3 * Use of this source code is governed by a BSD-style license that can be | 3 * Use of this source code is governed by a BSD-style license that can be |
4 * found in the LICENSE file. | 4 * found in the LICENSE file. |
5 */ | 5 */ |
6 | 6 |
7 #include "SkBitmapProcState.h" | 7 #include "SkBitmapProcState.h" |
8 #include "SkPerspIter.h" | 8 #include "SkPerspIter.h" |
9 #include "SkShader.h" | 9 #include "SkShader.h" |
10 #include "SkUtils.h" | 10 #include "SkUtils.h" |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 #define PREAMBLE_ARG_X , tileProcX, tileLowBitsProcX | 105 #define PREAMBLE_ARG_X , tileProcX, tileLowBitsProcX |
106 #define PREAMBLE_ARG_Y , tileProcY, tileLowBitsProcY | 106 #define PREAMBLE_ARG_Y , tileProcY, tileLowBitsProcY |
107 #define TILEX_PROCF(fx, max) SK_USHIFT16(tileProcX(fx) * ((max) + 1)) | 107 #define TILEX_PROCF(fx, max) SK_USHIFT16(tileProcX(fx) * ((max) + 1)) |
108 #define TILEY_PROCF(fy, max) SK_USHIFT16(tileProcY(fy) * ((max) + 1)) | 108 #define TILEY_PROCF(fy, max) SK_USHIFT16(tileProcY(fy) * ((max) + 1)) |
109 #define TILEX_LOW_BITS(fx, max) tileLowBitsProcX(fx, (max) + 1) | 109 #define TILEX_LOW_BITS(fx, max) tileLowBitsProcX(fx, (max) + 1) |
110 #define TILEY_LOW_BITS(fy, max) tileLowBitsProcY(fy, (max) + 1) | 110 #define TILEY_LOW_BITS(fy, max) tileLowBitsProcY(fy, (max) + 1) |
111 #include "SkBitmapProcState_matrix.h" | 111 #include "SkBitmapProcState_matrix.h" |
112 | 112 |
113 static inline U16CPU fixed_clamp(SkFixed x) | 113 static inline U16CPU fixed_clamp(SkFixed x) |
114 { | 114 { |
115 #ifdef SK_CPU_HAS_CONDITIONAL_INSTR | 115 if (x < 0) { |
116 if (x < 0) | |
117 x = 0; | 116 x = 0; |
118 if (x >> 16) | 117 } |
| 118 if (x >> 16) { |
119 x = 0xFFFF; | 119 x = 0xFFFF; |
120 #else | |
121 if (x >> 16) | |
122 { | |
123 #if 0 // is this faster? | |
124 x = (~x >> 31) & 0xFFFF; | |
125 #else | |
126 if (x < 0) | |
127 x = 0; | |
128 else | |
129 x = 0xFFFF; | |
130 #endif | |
131 } | 120 } |
132 #endif | |
133 return x; | 121 return x; |
134 } | 122 } |
135 | 123 |
136 static inline U16CPU fixed_repeat(SkFixed x) | 124 static inline U16CPU fixed_repeat(SkFixed x) |
137 { | 125 { |
138 return x & 0xFFFF; | 126 return x & 0xFFFF; |
139 } | 127 } |
140 | 128 |
141 // Visual Studio 2010 (MSC_VER=1600) optimizes bit-shift code incorrectly. | 129 // Visual Studio 2010 (MSC_VER=1600) optimizes bit-shift code incorrectly. |
142 // See http://code.google.com/p/skia/issues/detail?id=472 | 130 // See http://code.google.com/p/skia/issues/detail?id=472 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 return fixed_clamp_lowbits; | 166 return fixed_clamp_lowbits; |
179 } else { | 167 } else { |
180 SkASSERT(SkShader::kMirror_TileMode == m || | 168 SkASSERT(SkShader::kMirror_TileMode == m || |
181 SkShader::kRepeat_TileMode == m); | 169 SkShader::kRepeat_TileMode == m); |
182 // mirror and repeat have the same behavior for the low bits. | 170 // mirror and repeat have the same behavior for the low bits. |
183 return fixed_repeat_or_mirrow_lowbits; | 171 return fixed_repeat_or_mirrow_lowbits; |
184 } | 172 } |
185 } | 173 } |
186 | 174 |
187 static inline U16CPU int_clamp(int x, int n) { | 175 static inline U16CPU int_clamp(int x, int n) { |
188 #ifdef SK_CPU_HAS_CONDITIONAL_INSTR | 176 if (x >= n) { |
189 if (x >= n) | |
190 x = n - 1; | 177 x = n - 1; |
191 if (x < 0) | 178 } |
| 179 if (x < 0) { |
192 x = 0; | 180 x = 0; |
193 #else | |
194 if ((unsigned)x >= (unsigned)n) { | |
195 if (x < 0) { | |
196 x = 0; | |
197 } else { | |
198 x = n - 1; | |
199 } | |
200 } | 181 } |
201 #endif | |
202 return x; | 182 return x; |
203 } | 183 } |
204 | 184 |
205 static inline U16CPU int_repeat(int x, int n) { | 185 static inline U16CPU int_repeat(int x, int n) { |
206 return sk_int_mod(x, n); | 186 return sk_int_mod(x, n); |
207 } | 187 } |
208 | 188 |
209 static inline U16CPU int_mirror(int x, int n) { | 189 static inline U16CPU int_mirror(int x, int n) { |
210 x = sk_int_mod(x, 2 * n); | 190 x = sk_int_mod(x, 2 * n); |
211 if (x >= n) { | 191 if (x >= n) { |
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
512 { | 492 { |
513 return SK_ARM_NEON_WRAP(RepeatX_RepeatY_Procs)[index]; | 493 return SK_ARM_NEON_WRAP(RepeatX_RepeatY_Procs)[index]; |
514 } | 494 } |
515 | 495 |
516 fTileProcX = choose_tile_proc(fTileModeX); | 496 fTileProcX = choose_tile_proc(fTileModeX); |
517 fTileProcY = choose_tile_proc(fTileModeY); | 497 fTileProcY = choose_tile_proc(fTileModeY); |
518 fTileLowBitsProcX = choose_tile_lowbits_proc(fTileModeX); | 498 fTileLowBitsProcX = choose_tile_lowbits_proc(fTileModeX); |
519 fTileLowBitsProcY = choose_tile_lowbits_proc(fTileModeY); | 499 fTileLowBitsProcY = choose_tile_lowbits_proc(fTileModeY); |
520 return GeneralXY_Procs[index]; | 500 return GeneralXY_Procs[index]; |
521 } | 501 } |
OLD | NEW |