Chromium Code Reviews| 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 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 198 | 198 |
| 199 fFlags = flags; | 199 fFlags = flags; |
| 200 } | 200 } |
| 201 | 201 |
| 202 SkBitmapProcShader::BitmapProcShaderContext::~BitmapProcShaderContext() { | 202 SkBitmapProcShader::BitmapProcShaderContext::~BitmapProcShaderContext() { |
| 203 // The bitmap proc state has been created outside of the context on memory t hat will be freed | 203 // The bitmap proc state has been created outside of the context on memory t hat will be freed |
| 204 // elsewhere. Only call the destructor but leave the freeing of the memory t o the caller. | 204 // elsewhere. Only call the destructor but leave the freeing of the memory t o the caller. |
| 205 fState->~SkBitmapProcState(); | 205 fState->~SkBitmapProcState(); |
| 206 } | 206 } |
| 207 | 207 |
| 208 #define BUF_MAX 128 | 208 /* Defines the buffer size for sample pixel indexes, used in the sample proc fun ction calls. |
| 209 * If the operation is bigger than the buffer, it's split into multiple calls. T his split is bad | |
| 210 * for the performance of SIMD optimizations. | |
| 211 * A display in portrait mode, with a width of 720 pixels, requires a buffer siz e of at least 361 | |
| 212 * to run uninterrupted in the most basic operations. (Formula: Width / 2 + 1) | |
| 213 */ | |
| 214 #ifdef ANDROID_LARGE_MEMORY_DEVICE | |
| 215 #define BUF_MAX 541 // 1080p phone display | |
| 216 #else | |
| 217 #define BUF_MAX 241 // 480p phone display | |
| 218 #endif | |
| 209 | 219 |
| 210 #define TEST_BUFFER_OVERRITEx | 220 #define TEST_BUFFER_OVERRITEx |
| 211 | 221 |
| 212 #ifdef TEST_BUFFER_OVERRITE | 222 #ifdef TEST_BUFFER_OVERRITE |
| 213 #define TEST_BUFFER_EXTRA 32 | 223 #define TEST_BUFFER_EXTRA 32 |
| 214 #define TEST_PATTERN 0x88888888 | 224 #define TEST_PATTERN 0x88888888 |
| 215 #else | 225 #else |
| 216 #define TEST_BUFFER_EXTRA 0 | 226 #define TEST_BUFFER_EXTRA 0 |
| 217 #endif | 227 #endif |
| 218 | 228 |
| 219 void SkBitmapProcShader::BitmapProcShaderContext::shadeSpan(int x, int y, SkPMCo lor dstC[], | 229 void SkBitmapProcShader::BitmapProcShaderContext::shadeSpan(int x, int y, SkPMCo lor dstC[], |
| 220 int count) { | 230 int count) { |
| 221 const SkBitmapProcState& state = *fState; | 231 const SkBitmapProcState& state = *fState; |
| 222 if (state.getShaderProc32()) { | 232 if (state.getShaderProc32()) { |
| 223 state.getShaderProc32()(state, x, y, dstC, count); | 233 state.getShaderProc32()(state, x, y, dstC, count); |
| 224 return; | 234 return; |
| 225 } | 235 } |
| 226 | 236 |
| 227 uint32_t buffer[BUF_MAX + TEST_BUFFER_EXTRA]; | 237 // Align buffer to 16 bytes to enable more efficient SIMD optimizations. |
| 238 #ifdef _MSC_VER | |
| 239 __declspec(align(16)) uint32_t buffer[BUF_MAX + TEST_BUFFER_EXTRA]; | |
|
scroggo
2014/04/22 15:18:40
Is there a way to turn this into a macro? Or does
henrik.smiding
2014/04/23 13:34:46
Done.
| |
| 240 #else | |
| 241 uint32_t __attribute__((aligned(16))) buffer[BUF_MAX + TEST_BUFFER_EXTRA]; | |
| 242 #endif | |
| 228 SkBitmapProcState::MatrixProc mproc = state.getMatrixProc(); | 243 SkBitmapProcState::MatrixProc mproc = state.getMatrixProc(); |
| 229 SkBitmapProcState::SampleProc32 sproc = state.getSampleProc32(); | 244 SkBitmapProcState::SampleProc32 sproc = state.getSampleProc32(); |
| 230 int max = state.maxCountForBufferSize(sizeof(buffer[0]) * BUF_MAX); | 245 int max = state.maxCountForBufferSize(sizeof(buffer[0]) * BUF_MAX); |
| 231 | 246 |
| 232 SkASSERT(state.fBitmap->getPixels()); | 247 SkASSERT(state.fBitmap->getPixels()); |
| 233 SkASSERT(state.fBitmap->pixelRef() == NULL || | 248 SkASSERT(state.fBitmap->pixelRef() == NULL || |
| 234 state.fBitmap->pixelRef()->isLocked()); | 249 state.fBitmap->pixelRef()->isLocked()); |
| 235 | 250 |
| 236 for (;;) { | 251 for (;;) { |
| 237 int n = count; | 252 int n = count; |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 486 GrEffectRef* effect = NULL; | 501 GrEffectRef* effect = NULL; |
| 487 if (paintFilterLevel == SkPaint::kHigh_FilterLevel) { | 502 if (paintFilterLevel == SkPaint::kHigh_FilterLevel) { |
| 488 effect = GrBicubicEffect::Create(texture, matrix, tm); | 503 effect = GrBicubicEffect::Create(texture, matrix, tm); |
| 489 } else { | 504 } else { |
| 490 effect = GrSimpleTextureEffect::Create(texture, matrix, params); | 505 effect = GrSimpleTextureEffect::Create(texture, matrix, params); |
| 491 } | 506 } |
| 492 GrUnlockAndUnrefCachedBitmapTexture(texture); | 507 GrUnlockAndUnrefCachedBitmapTexture(texture); |
| 493 return effect; | 508 return effect; |
| 494 } | 509 } |
| 495 #endif | 510 #endif |
| OLD | NEW |