| 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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 // The SkBitmapProcState is stored outside of the context object, with the c
ontext holding | 110 // The SkBitmapProcState is stored outside of the context object, with the c
ontext holding |
| 111 // a pointer to it. | 111 // a pointer to it. |
| 112 return sizeof(BitmapProcShaderContext) + sizeof(SkBitmapProcState); | 112 return sizeof(BitmapProcShaderContext) + sizeof(SkBitmapProcState); |
| 113 } | 113 } |
| 114 | 114 |
| 115 SkBitmapProcShader::BitmapProcShaderContext::BitmapProcShaderContext( | 115 SkBitmapProcShader::BitmapProcShaderContext::BitmapProcShaderContext( |
| 116 const SkBitmapProcShader& shader, const ContextRec& rec, SkBitmapProcSta
te* state) | 116 const SkBitmapProcShader& shader, const ContextRec& rec, SkBitmapProcSta
te* state) |
| 117 : INHERITED(shader, rec) | 117 : INHERITED(shader, rec) |
| 118 , fState(state) | 118 , fState(state) |
| 119 { | 119 { |
| 120 const SkBitmap& bitmap = *fState->fBitmap; | 120 const SkPixmap& pixmap = fState->fPixmap; |
| 121 bool bitmapIsOpaque = bitmap.isOpaque(); | 121 bool isOpaque = pixmap.isOpaque(); |
| 122 | 122 |
| 123 // update fFlags | 123 // update fFlags |
| 124 uint32_t flags = 0; | 124 uint32_t flags = 0; |
| 125 if (bitmapIsOpaque && (255 == this->getPaintAlpha())) { | 125 if (isOpaque && (255 == this->getPaintAlpha())) { |
| 126 flags |= kOpaqueAlpha_Flag; | 126 flags |= kOpaqueAlpha_Flag; |
| 127 } | 127 } |
| 128 | 128 |
| 129 switch (bitmap.colorType()) { | 129 switch (pixmap.colorType()) { |
| 130 case kRGB_565_SkColorType: | 130 case kRGB_565_SkColorType: |
| 131 flags |= (kHasSpan16_Flag | kIntrinsicly16_Flag); | 131 flags |= (kHasSpan16_Flag | kIntrinsicly16_Flag); |
| 132 break; | 132 break; |
| 133 case kIndex_8_SkColorType: | 133 case kIndex_8_SkColorType: |
| 134 case kN32_SkColorType: | 134 case kN32_SkColorType: |
| 135 if (bitmapIsOpaque) { | 135 if (isOpaque) { |
| 136 flags |= kHasSpan16_Flag; | 136 flags |= kHasSpan16_Flag; |
| 137 } | 137 } |
| 138 break; | 138 break; |
| 139 case kAlpha_8_SkColorType: | 139 case kAlpha_8_SkColorType: |
| 140 break; // never set kHasSpan16_Flag | 140 break; // never set kHasSpan16_Flag |
| 141 default: | 141 default: |
| 142 break; | 142 break; |
| 143 } | 143 } |
| 144 | 144 |
| 145 if (rec.fPaint->isDither() && bitmap.colorType() != kRGB_565_SkColorType) { | 145 if (rec.fPaint->isDither() && pixmap.colorType() != kRGB_565_SkColorType) { |
| 146 // gradients can auto-dither in their 16bit sampler, but we don't so | 146 // gradients can auto-dither in their 16bit sampler, but we don't so |
| 147 // we clear the flag here. | 147 // we clear the flag here. |
| 148 flags &= ~kHasSpan16_Flag; | 148 flags &= ~kHasSpan16_Flag; |
| 149 } | 149 } |
| 150 | 150 |
| 151 // if we're only 1-pixel high, and we don't rotate, then we can claim this | 151 // if we're only 1-pixel high, and we don't rotate, then we can claim this |
| 152 if (1 == bitmap.height() && | 152 if (1 == pixmap.height() && |
| 153 only_scale_and_translate(this->getTotalInverse())) { | 153 only_scale_and_translate(this->getTotalInverse())) { |
| 154 flags |= kConstInY32_Flag; | 154 flags |= kConstInY32_Flag; |
| 155 if (flags & kHasSpan16_Flag) { | 155 if (flags & kHasSpan16_Flag) { |
| 156 flags |= kConstInY16_Flag; | 156 flags |= kConstInY16_Flag; |
| 157 } | 157 } |
| 158 } | 158 } |
| 159 | 159 |
| 160 fFlags = flags; | 160 fFlags = flags; |
| 161 } | 161 } |
| 162 | 162 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 183 if (state.getShaderProc32()) { | 183 if (state.getShaderProc32()) { |
| 184 state.getShaderProc32()(state, x, y, dstC, count); | 184 state.getShaderProc32()(state, x, y, dstC, count); |
| 185 return; | 185 return; |
| 186 } | 186 } |
| 187 | 187 |
| 188 uint32_t buffer[BUF_MAX + TEST_BUFFER_EXTRA]; | 188 uint32_t buffer[BUF_MAX + TEST_BUFFER_EXTRA]; |
| 189 SkBitmapProcState::MatrixProc mproc = state.getMatrixProc(); | 189 SkBitmapProcState::MatrixProc mproc = state.getMatrixProc(); |
| 190 SkBitmapProcState::SampleProc32 sproc = state.getSampleProc32(); | 190 SkBitmapProcState::SampleProc32 sproc = state.getSampleProc32(); |
| 191 int max = state.maxCountForBufferSize(sizeof(buffer[0]) * BUF_MAX); | 191 int max = state.maxCountForBufferSize(sizeof(buffer[0]) * BUF_MAX); |
| 192 | 192 |
| 193 SkASSERT(state.fBitmap->getPixels()); | 193 SkASSERT(state.fPixmap.addr()); |
| 194 SkASSERT(state.fBitmap->pixelRef() == NULL || | |
| 195 state.fBitmap->pixelRef()->isLocked()); | |
| 196 | 194 |
| 197 for (;;) { | 195 for (;;) { |
| 198 int n = count; | 196 int n = count; |
| 199 if (n > max) { | 197 if (n > max) { |
| 200 n = max; | 198 n = max; |
| 201 } | 199 } |
| 202 SkASSERT(n > 0 && n < BUF_MAX*2); | 200 SkASSERT(n > 0 && n < BUF_MAX*2); |
| 203 #ifdef TEST_BUFFER_OVERRITE | 201 #ifdef TEST_BUFFER_OVERRITE |
| 204 for (int i = 0; i < TEST_BUFFER_EXTRA; i++) { | 202 for (int i = 0; i < TEST_BUFFER_EXTRA; i++) { |
| 205 buffer[BUF_MAX + i] = TEST_PATTERN; | 203 buffer[BUF_MAX + i] = TEST_PATTERN; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 236 if (state.getShaderProc16()) { | 234 if (state.getShaderProc16()) { |
| 237 state.getShaderProc16()(state, x, y, dstC, count); | 235 state.getShaderProc16()(state, x, y, dstC, count); |
| 238 return; | 236 return; |
| 239 } | 237 } |
| 240 | 238 |
| 241 uint32_t buffer[BUF_MAX]; | 239 uint32_t buffer[BUF_MAX]; |
| 242 SkBitmapProcState::MatrixProc mproc = state.getMatrixProc(); | 240 SkBitmapProcState::MatrixProc mproc = state.getMatrixProc(); |
| 243 SkBitmapProcState::SampleProc16 sproc = state.getSampleProc16(); | 241 SkBitmapProcState::SampleProc16 sproc = state.getSampleProc16(); |
| 244 int max = state.maxCountForBufferSize(sizeof(buffer)); | 242 int max = state.maxCountForBufferSize(sizeof(buffer)); |
| 245 | 243 |
| 246 SkASSERT(state.fBitmap->getPixels()); | 244 SkASSERT(state.fPixmap.addr()); |
| 247 SkASSERT(state.fBitmap->pixelRef() == NULL || | |
| 248 state.fBitmap->pixelRef()->isLocked()); | |
| 249 | 245 |
| 250 for (;;) { | 246 for (;;) { |
| 251 int n = count; | 247 int n = count; |
| 252 if (n > max) { | 248 if (n > max) { |
| 253 n = max; | 249 n = max; |
| 254 } | 250 } |
| 255 mproc(state, buffer, n, x, y); | 251 mproc(state, buffer, n, x, y); |
| 256 sproc(state, buffer, n, dstC); | 252 sproc(state, buffer, n, dstC); |
| 257 | 253 |
| 258 if ((count -= n) == 0) { | 254 if ((count -= n) == 0) { |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 455 #else | 451 #else |
| 456 | 452 |
| 457 bool SkBitmapProcShader::asFragmentProcessor(GrContext*, const SkPaint&, const S
kMatrix&, | 453 bool SkBitmapProcShader::asFragmentProcessor(GrContext*, const SkPaint&, const S
kMatrix&, |
| 458 const SkMatrix*, GrColor*, | 454 const SkMatrix*, GrColor*, |
| 459 GrFragmentProcessor**) const { | 455 GrFragmentProcessor**) const { |
| 460 SkDEBUGFAIL("Should not call in GPU-less build"); | 456 SkDEBUGFAIL("Should not call in GPU-less build"); |
| 461 return false; | 457 return false; |
| 462 } | 458 } |
| 463 | 459 |
| 464 #endif | 460 #endif |
| OLD | NEW |