OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 #include "SkColorPriv.h" | 8 #include "SkColorPriv.h" |
9 #include "SkReadBuffer.h" | 9 #include "SkReadBuffer.h" |
10 #include "SkWriteBuffer.h" | 10 #include "SkWriteBuffer.h" |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 | 176 |
177 fFlags = flags; | 177 fFlags = flags; |
178 } | 178 } |
179 | 179 |
180 SkBitmapProcShader::BitmapProcShaderContext::~BitmapProcShaderContext() { | 180 SkBitmapProcShader::BitmapProcShaderContext::~BitmapProcShaderContext() { |
181 // The bitmap proc state has been created outside of the context on memory t
hat will be freed | 181 // The bitmap proc state has been created outside of the context on memory t
hat will be freed |
182 // elsewhere. Only call the destructor but leave the freeing of the memory t
o the caller. | 182 // elsewhere. Only call the destructor but leave the freeing of the memory t
o the caller. |
183 fState->~SkBitmapProcState(); | 183 fState->~SkBitmapProcState(); |
184 } | 184 } |
185 | 185 |
186 #define BUF_MAX 128 | 186 /* Defines the buffer size for sample pixel indexes, used in the sample proc fun
ction calls. |
| 187 * If the operation is bigger than the buffer, it's split into multiple calls. T
his split is bad |
| 188 * for the performance of SIMD optimizations. |
| 189 * A display in portrait mode, with a width of 720 pixels, requires a buffer siz
e of at least 721 |
| 190 * to run uninterrupted in the more basic operations. |
| 191 * (Formula: Width + 1 for 'scale/translate with filter' procs. |
| 192 * See description of SkBitmapProcState::maxCountForBufferSize for more informa
tion.) |
| 193 */ |
| 194 #define BUF_MAX 1081 |
187 | 195 |
188 #define TEST_BUFFER_OVERRITEx | 196 #define TEST_BUFFER_OVERRITEx |
189 | 197 |
190 #ifdef TEST_BUFFER_OVERRITE | 198 #ifdef TEST_BUFFER_OVERRITE |
191 #define TEST_BUFFER_EXTRA 32 | 199 #define TEST_BUFFER_EXTRA 32 |
192 #define TEST_PATTERN 0x88888888 | 200 #define TEST_PATTERN 0x88888888 |
193 #else | 201 #else |
194 #define TEST_BUFFER_EXTRA 0 | 202 #define TEST_BUFFER_EXTRA 0 |
195 #endif | 203 #endif |
196 | 204 |
197 void SkBitmapProcShader::BitmapProcShaderContext::shadeSpan(int x, int y, SkPMCo
lor dstC[], | 205 void SkBitmapProcShader::BitmapProcShaderContext::shadeSpan(int x, int y, SkPMCo
lor dstC[], |
198 int count) { | 206 int count) { |
199 const SkBitmapProcState& state = *fState; | 207 const SkBitmapProcState& state = *fState; |
200 if (state.getShaderProc32()) { | 208 if (state.getShaderProc32()) { |
201 state.getShaderProc32()(state, x, y, dstC, count); | 209 state.getShaderProc32()(state, x, y, dstC, count); |
202 return; | 210 return; |
203 } | 211 } |
204 | 212 |
205 uint32_t buffer[BUF_MAX + TEST_BUFFER_EXTRA]; | 213 // Align buffer to 16 bytes to enable more efficient SIMD optimizations. |
| 214 uint32_t SK_ALIGN(16) buffer[BUF_MAX + TEST_BUFFER_EXTRA]; |
| 215 |
206 SkBitmapProcState::MatrixProc mproc = state.getMatrixProc(); | 216 SkBitmapProcState::MatrixProc mproc = state.getMatrixProc(); |
207 SkBitmapProcState::SampleProc32 sproc = state.getSampleProc32(); | 217 SkBitmapProcState::SampleProc32 sproc = state.getSampleProc32(); |
208 int max = state.maxCountForBufferSize(sizeof(buffer[0]) * BUF_MAX); | 218 int max = state.maxCountForBufferSize(sizeof(buffer[0]) * BUF_MAX); |
209 | 219 |
210 SkASSERT(state.fBitmap->getPixels()); | 220 SkASSERT(state.fBitmap->getPixels()); |
211 SkASSERT(state.fBitmap->pixelRef() == NULL || | 221 SkASSERT(state.fBitmap->pixelRef() == NULL || |
212 state.fBitmap->pixelRef()->isLocked()); | 222 state.fBitmap->pixelRef()->isLocked()); |
213 | 223 |
214 for (;;) { | 224 for (;;) { |
215 int n = count; | 225 int n = count; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 } | 258 } |
249 | 259 |
250 void SkBitmapProcShader::BitmapProcShaderContext::shadeSpan16(int x, int y, uint
16_t dstC[], | 260 void SkBitmapProcShader::BitmapProcShaderContext::shadeSpan16(int x, int y, uint
16_t dstC[], |
251 int count) { | 261 int count) { |
252 const SkBitmapProcState& state = *fState; | 262 const SkBitmapProcState& state = *fState; |
253 if (state.getShaderProc16()) { | 263 if (state.getShaderProc16()) { |
254 state.getShaderProc16()(state, x, y, dstC, count); | 264 state.getShaderProc16()(state, x, y, dstC, count); |
255 return; | 265 return; |
256 } | 266 } |
257 | 267 |
258 uint32_t buffer[BUF_MAX]; | 268 // Align buffer to 16 bytes to enable more efficient SIMD optimizations. |
| 269 uint32_t SK_ALIGN(16) buffer[BUF_MAX]; |
| 270 |
259 SkBitmapProcState::MatrixProc mproc = state.getMatrixProc(); | 271 SkBitmapProcState::MatrixProc mproc = state.getMatrixProc(); |
260 SkBitmapProcState::SampleProc16 sproc = state.getSampleProc16(); | 272 SkBitmapProcState::SampleProc16 sproc = state.getSampleProc16(); |
261 int max = state.maxCountForBufferSize(sizeof(buffer)); | 273 int max = state.maxCountForBufferSize(sizeof(buffer)); |
262 | 274 |
263 SkASSERT(state.fBitmap->getPixels()); | 275 SkASSERT(state.fBitmap->getPixels()); |
264 SkASSERT(state.fBitmap->pixelRef() == NULL || | 276 SkASSERT(state.fBitmap->pixelRef() == NULL || |
265 state.fBitmap->pixelRef()->isLocked()); | 277 state.fBitmap->pixelRef()->isLocked()); |
266 | 278 |
267 for (;;) { | 279 for (;;) { |
268 int n = count; | 280 int n = count; |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
456 GrEffectRef* effect = NULL; | 468 GrEffectRef* effect = NULL; |
457 if (useBicubic) { | 469 if (useBicubic) { |
458 effect = GrBicubicEffect::Create(texture, matrix, tm); | 470 effect = GrBicubicEffect::Create(texture, matrix, tm); |
459 } else { | 471 } else { |
460 effect = GrSimpleTextureEffect::Create(texture, matrix, params); | 472 effect = GrSimpleTextureEffect::Create(texture, matrix, params); |
461 } | 473 } |
462 GrUnlockAndUnrefCachedBitmapTexture(texture); | 474 GrUnlockAndUnrefCachedBitmapTexture(texture); |
463 return effect; | 475 return effect; |
464 } | 476 } |
465 #endif | 477 #endif |
OLD | NEW |