| 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 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 SkXfermode::D32Proc fXferProc; | 169 SkXfermode::D32Proc fXferProc; |
| 170 | 170 |
| 171 typedef BitmapProcInfoContext INHERITED; | 171 typedef BitmapProcInfoContext INHERITED; |
| 172 }; | 172 }; |
| 173 | 173 |
| 174 ////////////////////////////////////////////////////////////////////////////////
/////////////////// | 174 ////////////////////////////////////////////////////////////////////////////////
/////////////////// |
| 175 | 175 |
| 176 static bool choose_linear_pipeline(const SkShader::ContextRec& rec, const SkImag
eInfo& srcInfo) { | 176 static bool choose_linear_pipeline(const SkShader::ContextRec& rec, const SkImag
eInfo& srcInfo) { |
| 177 // These src attributes are not supported in the new 4f context (yet) | 177 // These src attributes are not supported in the new 4f context (yet) |
| 178 // | 178 // |
| 179 if (srcInfo.bytesPerPixel() < 4 || | 179 if (srcInfo.colorType() != kRGBA_8888_SkColorType |
| 180 kRGBA_F16_SkColorType == srcInfo.colorType() || | 180 && srcInfo.colorType() != kBGRA_8888_SkColorType |
| 181 kIndex_8_SkColorType == srcInfo.colorType()) { | 181 && srcInfo.colorType() != kIndex_8_SkColorType) { |
| 182 return false; | 182 return false; |
| 183 } | 183 } |
| 184 | 184 |
| 185 #if 0 // later we may opt-in to the new code even if the client hasn't request
ed it... | 185 #if 0 // later we may opt-in to the new code even if the client hasn't request
ed it... |
| 186 // These src attributes are only supported in the new 4f context | 186 // These src attributes are only supported in the new 4f context |
| 187 // | 187 // |
| 188 if (srcInfo.isSRGB() || | 188 if (srcInfo.isSRGB() || |
| 189 kUnpremul_SkAlphaType == srcInfo.alphaType() || | 189 kUnpremul_SkAlphaType == srcInfo.alphaType() || |
| 190 (4 == srcInfo.bytesPerPixel() && kN32_SkColorType != srcInfo.colorType()
)) | 190 (4 == srcInfo.bytesPerPixel() && kN32_SkColorType != srcInfo.colorType()
)) |
| 191 { | 191 { |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 //useLinearPipeline = false; | 223 //useLinearPipeline = false; |
| 224 | 224 |
| 225 if (useLinearPipeline) { | 225 if (useLinearPipeline) { |
| 226 void* infoStorage = (char*)storage + sizeof(LinearPipelineContext); | 226 void* infoStorage = (char*)storage + sizeof(LinearPipelineContext); |
| 227 SkBitmapProcInfo* info = new (infoStorage) SkBitmapProcInfo(provider, tm
x, tmy); | 227 SkBitmapProcInfo* info = new (infoStorage) SkBitmapProcInfo(provider, tm
x, tmy); |
| 228 if (!info->init(totalInverse, *rec.fPaint)) { | 228 if (!info->init(totalInverse, *rec.fPaint)) { |
| 229 info->~SkBitmapProcInfo(); | 229 info->~SkBitmapProcInfo(); |
| 230 return nullptr; | 230 return nullptr; |
| 231 } | 231 } |
| 232 if (info->fPixmap.colorType() != kRGBA_8888_SkColorType | 232 if (info->fPixmap.colorType() != kRGBA_8888_SkColorType |
| 233 && info->fPixmap.colorType() != kBGRA_8888_SkColorType) { | 233 && info->fPixmap.colorType() != kBGRA_8888_SkColorType |
| 234 && info->fPixmap.colorType() != kIndex_8_SkColorType) { |
| 234 return nullptr; | 235 return nullptr; |
| 235 } | 236 } |
| 236 return new (storage) LinearPipelineContext(shader, rec, info); | 237 return new (storage) LinearPipelineContext(shader, rec, info); |
| 237 } else { | 238 } else { |
| 238 void* stateStorage = (char*)storage + sizeof(BitmapProcShaderContext); | 239 void* stateStorage = (char*)storage + sizeof(BitmapProcShaderContext); |
| 239 SkBitmapProcState* state = new (stateStorage) SkBitmapProcState(provider
, tmx, tmy); | 240 SkBitmapProcState* state = new (stateStorage) SkBitmapProcState(provider
, tmx, tmy); |
| 240 if (!state->setup(totalInverse, *rec.fPaint)) { | 241 if (!state->setup(totalInverse, *rec.fPaint)) { |
| 241 state->~SkBitmapProcState(); | 242 state->~SkBitmapProcState(); |
| 242 return nullptr; | 243 return nullptr; |
| 243 } | 244 } |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 453 inner.reset(GrSimpleTextureEffect::Create(texture, matrix, params)); | 454 inner.reset(GrSimpleTextureEffect::Create(texture, matrix, params)); |
| 454 } | 455 } |
| 455 | 456 |
| 456 if (kAlpha_8_SkColorType == fRawBitmap.colorType()) { | 457 if (kAlpha_8_SkColorType == fRawBitmap.colorType()) { |
| 457 return GrFragmentProcessor::MulOutputByInputUnpremulColor(inner); | 458 return GrFragmentProcessor::MulOutputByInputUnpremulColor(inner); |
| 458 } | 459 } |
| 459 return GrFragmentProcessor::MulOutputByInputAlpha(inner); | 460 return GrFragmentProcessor::MulOutputByInputAlpha(inner); |
| 460 } | 461 } |
| 461 | 462 |
| 462 #endif | 463 #endif |
| OLD | NEW |