Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(67)

Side by Side Diff: src/core/SkBitmapProcShader.cpp

Issue 2030953002: Add the ability to handle premul and swizzle src bitmap data. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698