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 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 SkFilterQuality fFilterQuality; | 198 SkFilterQuality fFilterQuality; |
199 | 199 |
200 typedef BitmapProcInfoContext INHERITED; | 200 typedef BitmapProcInfoContext INHERITED; |
201 }; | 201 }; |
202 | 202 |
203 ////////////////////////////////////////////////////////////////////////////////
/////////////////// | 203 ////////////////////////////////////////////////////////////////////////////////
/////////////////// |
204 | 204 |
205 static bool choose_linear_pipeline(const SkShader::ContextRec& rec, const SkImag
eInfo& srcInfo) { | 205 static bool choose_linear_pipeline(const SkShader::ContextRec& rec, const SkImag
eInfo& srcInfo) { |
206 // If we get here, we can reasonably use either context, respect the caller'
s preference | 206 // If we get here, we can reasonably use either context, respect the caller'
s preference |
207 // | 207 // |
208 return SkShader::ContextRec::kPM4f_DstType == rec.fPreferredDstType; | 208 bool needsPremul = srcInfo.alphaType() == kUnpremul_SkAlphaType; |
| 209 bool needsSwizzle = srcInfo.bytesPerPixel() == 4 && srcInfo.colorType() != k
N32_SkColorType; |
| 210 return SkShader::ContextRec::kPM4f_DstType == rec.fPreferredDstType |
| 211 || needsPremul || needsSwizzle; |
209 } | 212 } |
210 | 213 |
211 size_t SkBitmapProcShader::ContextSize(const ContextRec& rec, const SkImageInfo&
srcInfo) { | 214 size_t SkBitmapProcShader::ContextSize(const ContextRec& rec, const SkImageInfo&
srcInfo) { |
212 size_t size0 = sizeof(BitmapProcShaderContext) + sizeof(SkBitmapProcState); | 215 size_t size0 = sizeof(BitmapProcShaderContext) + sizeof(SkBitmapProcState); |
213 size_t size1 = sizeof(LinearPipelineContext) + sizeof(SkBitmapProcInfo); | 216 size_t size1 = sizeof(LinearPipelineContext) + sizeof(SkBitmapProcInfo); |
214 return SkTMax(size0, size1); | 217 return SkTMax(size0, size1); |
215 } | 218 } |
216 | 219 |
217 SkShader::Context* SkBitmapProcShader::MakeContext(const SkShader& shader, | 220 SkShader::Context* SkBitmapProcShader::MakeContext(const SkShader& shader, |
218 TileMode tmx, TileMode tmy, | 221 TileMode tmx, TileMode tmy, |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
455 inner.reset(GrSimpleTextureEffect::Create(texture, matrix, params)); | 458 inner.reset(GrSimpleTextureEffect::Create(texture, matrix, params)); |
456 } | 459 } |
457 | 460 |
458 if (kAlpha_8_SkColorType == fRawBitmap.colorType()) { | 461 if (kAlpha_8_SkColorType == fRawBitmap.colorType()) { |
459 return GrFragmentProcessor::MulOutputByInputUnpremulColor(inner); | 462 return GrFragmentProcessor::MulOutputByInputUnpremulColor(inner); |
460 } | 463 } |
461 return GrFragmentProcessor::MulOutputByInputAlpha(inner); | 464 return GrFragmentProcessor::MulOutputByInputAlpha(inner); |
462 } | 465 } |
463 | 466 |
464 #endif | 467 #endif |
OLD | NEW |