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 /* Defines the buffer size for sample pixel indexes, used in the sample proc fun
ction calls. | 186 #define BUF_MAX 128 |
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 | |
195 | 187 |
196 #define TEST_BUFFER_OVERRITEx | 188 #define TEST_BUFFER_OVERRITEx |
197 | 189 |
198 #ifdef TEST_BUFFER_OVERRITE | 190 #ifdef TEST_BUFFER_OVERRITE |
199 #define TEST_BUFFER_EXTRA 32 | 191 #define TEST_BUFFER_EXTRA 32 |
200 #define TEST_PATTERN 0x88888888 | 192 #define TEST_PATTERN 0x88888888 |
201 #else | 193 #else |
202 #define TEST_BUFFER_EXTRA 0 | 194 #define TEST_BUFFER_EXTRA 0 |
203 #endif | 195 #endif |
204 | 196 |
205 void SkBitmapProcShader::BitmapProcShaderContext::shadeSpan(int x, int y, SkPMCo
lor dstC[], | 197 void SkBitmapProcShader::BitmapProcShaderContext::shadeSpan(int x, int y, SkPMCo
lor dstC[], |
206 int count) { | 198 int count) { |
207 const SkBitmapProcState& state = *fState; | 199 const SkBitmapProcState& state = *fState; |
208 if (state.getShaderProc32()) { | 200 if (state.getShaderProc32()) { |
209 state.getShaderProc32()(state, x, y, dstC, count); | 201 state.getShaderProc32()(state, x, y, dstC, count); |
210 return; | 202 return; |
211 } | 203 } |
212 | 204 |
213 // Align buffer to 16 bytes to enable more efficient SIMD optimizations. | 205 uint32_t buffer[BUF_MAX + TEST_BUFFER_EXTRA]; |
214 uint32_t SK_ALIGN(16) buffer[BUF_MAX + TEST_BUFFER_EXTRA]; | |
215 | |
216 SkBitmapProcState::MatrixProc mproc = state.getMatrixProc(); | 206 SkBitmapProcState::MatrixProc mproc = state.getMatrixProc(); |
217 SkBitmapProcState::SampleProc32 sproc = state.getSampleProc32(); | 207 SkBitmapProcState::SampleProc32 sproc = state.getSampleProc32(); |
218 int max = state.maxCountForBufferSize(sizeof(buffer[0]) * BUF_MAX); | 208 int max = state.maxCountForBufferSize(sizeof(buffer[0]) * BUF_MAX); |
219 | 209 |
220 SkASSERT(state.fBitmap->getPixels()); | 210 SkASSERT(state.fBitmap->getPixels()); |
221 SkASSERT(state.fBitmap->pixelRef() == NULL || | 211 SkASSERT(state.fBitmap->pixelRef() == NULL || |
222 state.fBitmap->pixelRef()->isLocked()); | 212 state.fBitmap->pixelRef()->isLocked()); |
223 | 213 |
224 for (;;) { | 214 for (;;) { |
225 int n = count; | 215 int n = count; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 } | 248 } |
259 | 249 |
260 void SkBitmapProcShader::BitmapProcShaderContext::shadeSpan16(int x, int y, uint
16_t dstC[], | 250 void SkBitmapProcShader::BitmapProcShaderContext::shadeSpan16(int x, int y, uint
16_t dstC[], |
261 int count) { | 251 int count) { |
262 const SkBitmapProcState& state = *fState; | 252 const SkBitmapProcState& state = *fState; |
263 if (state.getShaderProc16()) { | 253 if (state.getShaderProc16()) { |
264 state.getShaderProc16()(state, x, y, dstC, count); | 254 state.getShaderProc16()(state, x, y, dstC, count); |
265 return; | 255 return; |
266 } | 256 } |
267 | 257 |
268 // Align buffer to 16 bytes to enable more efficient SIMD optimizations. | 258 uint32_t buffer[BUF_MAX]; |
269 uint32_t SK_ALIGN(16) buffer[BUF_MAX]; | |
270 | |
271 SkBitmapProcState::MatrixProc mproc = state.getMatrixProc(); | 259 SkBitmapProcState::MatrixProc mproc = state.getMatrixProc(); |
272 SkBitmapProcState::SampleProc16 sproc = state.getSampleProc16(); | 260 SkBitmapProcState::SampleProc16 sproc = state.getSampleProc16(); |
273 int max = state.maxCountForBufferSize(sizeof(buffer)); | 261 int max = state.maxCountForBufferSize(sizeof(buffer)); |
274 | 262 |
275 SkASSERT(state.fBitmap->getPixels()); | 263 SkASSERT(state.fBitmap->getPixels()); |
276 SkASSERT(state.fBitmap->pixelRef() == NULL || | 264 SkASSERT(state.fBitmap->pixelRef() == NULL || |
277 state.fBitmap->pixelRef()->isLocked()); | 265 state.fBitmap->pixelRef()->isLocked()); |
278 | 266 |
279 for (;;) { | 267 for (;;) { |
280 int n = count; | 268 int n = count; |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
468 GrEffectRef* effect = NULL; | 456 GrEffectRef* effect = NULL; |
469 if (useBicubic) { | 457 if (useBicubic) { |
470 effect = GrBicubicEffect::Create(texture, matrix, tm); | 458 effect = GrBicubicEffect::Create(texture, matrix, tm); |
471 } else { | 459 } else { |
472 effect = GrSimpleTextureEffect::Create(texture, matrix, params); | 460 effect = GrSimpleTextureEffect::Create(texture, matrix, params); |
473 } | 461 } |
474 GrUnlockAndUnrefCachedBitmapTexture(texture); | 462 GrUnlockAndUnrefCachedBitmapTexture(texture); |
475 return effect; | 463 return effect; |
476 } | 464 } |
477 #endif | 465 #endif |
OLD | NEW |