OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "SkBitmapProcShader.h" | 8 #include "SkBitmapProcShader.h" |
9 #include "SkBitmapProcState.h" | 9 #include "SkBitmapProcState.h" |
10 #include "SkBitmapProvider.h" | 10 #include "SkBitmapProvider.h" |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 const SkBitmapProvider& provi
der, | 219 const SkBitmapProvider& provi
der, |
220 const ContextRec& rec, void*
storage) { | 220 const ContextRec& rec, void*
storage) { |
221 SkMatrix totalInverse; | 221 SkMatrix totalInverse; |
222 // Do this first, so we know the matrix can be inverted. | 222 // Do this first, so we know the matrix can be inverted. |
223 if (!shader.computeTotalInverse(rec, &totalInverse)) { | 223 if (!shader.computeTotalInverse(rec, &totalInverse)) { |
224 return nullptr; | 224 return nullptr; |
225 } | 225 } |
226 | 226 |
227 // Decide if we can/want to use the new linear pipeline | 227 // Decide if we can/want to use the new linear pipeline |
228 bool useLinearPipeline = choose_linear_pipeline(rec, provider.info()); | 228 bool useLinearPipeline = choose_linear_pipeline(rec, provider.info()); |
| 229 SkMipMap::SrcGammaMode mode = SkMipMap::DeduceMode(rec); |
229 | 230 |
230 if (useLinearPipeline) { | 231 if (useLinearPipeline) { |
231 void* infoStorage = (char*)storage + sizeof(LinearPipelineContext); | 232 void* infoStorage = (char*)storage + sizeof(LinearPipelineContext); |
232 SkBitmapProcInfo* info = new (infoStorage) SkBitmapProcInfo(provider, tm
x, tmy); | 233 SkBitmapProcInfo* info = new (infoStorage) SkBitmapProcInfo(provider, tm
x, tmy, mode); |
233 if (!info->init(totalInverse, *rec.fPaint)) { | 234 if (!info->init(totalInverse, *rec.fPaint)) { |
234 info->~SkBitmapProcInfo(); | 235 info->~SkBitmapProcInfo(); |
235 return nullptr; | 236 return nullptr; |
236 } | 237 } |
237 | 238 |
238 return new (storage) LinearPipelineContext(shader, rec, info); | 239 return new (storage) LinearPipelineContext(shader, rec, info); |
239 } else { | 240 } else { |
240 void* stateStorage = (char*)storage + sizeof(BitmapProcShaderContext); | 241 void* stateStorage = (char*)storage + sizeof(BitmapProcShaderContext); |
241 SkBitmapProcState* state = new (stateStorage) SkBitmapProcState(provider
, tmx, tmy); | 242 SkBitmapProcState* state = new (stateStorage) SkBitmapProcState(provider
, tmx, tmy, mode); |
242 if (!state->setup(totalInverse, *rec.fPaint)) { | 243 if (!state->setup(totalInverse, *rec.fPaint)) { |
243 state->~SkBitmapProcState(); | 244 state->~SkBitmapProcState(); |
244 return nullptr; | 245 return nullptr; |
245 } | 246 } |
246 return new (storage) BitmapProcShaderContext(shader, rec, state); | 247 return new (storage) BitmapProcShaderContext(shader, rec, state); |
247 } | 248 } |
248 } | 249 } |
249 | 250 |
250 SkShader::Context* SkBitmapProcShader::onCreateContext(const ContextRec& rec, vo
id* storage) const { | 251 SkShader::Context* SkBitmapProcShader::onCreateContext(const ContextRec& rec, vo
id* storage) const { |
251 return MakeContext(*this, (TileMode)fTileModeX, (TileMode)fTileModeY, | 252 return MakeContext(*this, (TileMode)fTileModeX, (TileMode)fTileModeY, |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
455 inner.reset(GrSimpleTextureEffect::Create(texture, matrix, params)); | 456 inner.reset(GrSimpleTextureEffect::Create(texture, matrix, params)); |
456 } | 457 } |
457 | 458 |
458 if (kAlpha_8_SkColorType == fRawBitmap.colorType()) { | 459 if (kAlpha_8_SkColorType == fRawBitmap.colorType()) { |
459 return GrFragmentProcessor::MulOutputByInputUnpremulColor(inner); | 460 return GrFragmentProcessor::MulOutputByInputUnpremulColor(inner); |
460 } | 461 } |
461 return GrFragmentProcessor::MulOutputByInputAlpha(inner); | 462 return GrFragmentProcessor::MulOutputByInputAlpha(inner); |
462 } | 463 } |
463 | 464 |
464 #endif | 465 #endif |
OLD | NEW |