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

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

Issue 1915073002: Whitespace change. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 8 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 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 SkXfermode::Mode mode; 173 SkXfermode::Mode mode;
174 if (!SkXfermode::AsMode(state->fXfer, &mode)) { return false; } 174 if (!SkXfermode::AsMode(state->fXfer, &mode)) { return false; }
175 175
176 // Need to ensure that our pipeline is created at a 16byte aligned addre ss 176 // Need to ensure that our pipeline is created at a 16byte aligned addre ss
177 fBlitterPipeline = (SkLinearBitmapPipeline*)SkAlign16((intptr_t)fBlitter Storage); 177 fBlitterPipeline = (SkLinearBitmapPipeline*)SkAlign16((intptr_t)fBlitter Storage);
178 if (SkLinearBitmapPipeline::ClonePipelineForBlitting( 178 if (SkLinearBitmapPipeline::ClonePipelineForBlitting(
179 fBlitterPipeline, *fShaderPipeline, 179 fBlitterPipeline, *fShaderPipeline,
180 fMatrixTypeMask, 180 fMatrixTypeMask,
181 fXMode, fYMode, 181 fXMode, fYMode,
182 fFilterQuality, fSrcPixmap, 182 fFilterQuality, fSrcPixmap,
183 fAlpha, mode, dstInfo)) { 183 fAlpha, mode, dstInfo))
184 184 {
185 state->fStorage[0] = fBlitterPipeline; 185 state->fStorage[0] = fBlitterPipeline;
186 state->fBlitBW = &LinearPipelineContext::ForwardToPipeline; 186 state->fBlitBW = &LinearPipelineContext::ForwardToPipeline;
187 187
188 return true; 188 return true;
189 } 189 }
190 190
191 // Did not successfully create a pipeline so don't destruct it. 191 // Did not successfully create a pipeline so don't destruct it.
192 fBlitterPipeline = nullptr; 192 fBlitterPipeline = nullptr;
193 return false; 193 return false;
194 } 194 }
(...skipping 30 matching lines...) Expand all
225 static bool choose_linear_pipeline(const SkShader::ContextRec& rec, const SkImag eInfo& srcInfo) { 225 static bool choose_linear_pipeline(const SkShader::ContextRec& rec, const SkImag eInfo& srcInfo) {
226 // These src attributes are not supported in the new 4f context (yet) 226 // These src attributes are not supported in the new 4f context (yet)
227 // 227 //
228 if (srcInfo.colorType() != kRGBA_8888_SkColorType 228 if (srcInfo.colorType() != kRGBA_8888_SkColorType
229 && srcInfo.colorType() != kBGRA_8888_SkColorType 229 && srcInfo.colorType() != kBGRA_8888_SkColorType
230 && srcInfo.colorType() != kIndex_8_SkColorType 230 && srcInfo.colorType() != kIndex_8_SkColorType
231 && srcInfo.colorType() != kRGBA_F16_SkColorType) { 231 && srcInfo.colorType() != kRGBA_F16_SkColorType) {
232 return false; 232 return false;
233 } 233 }
234 234
235 #if 0 // later we may opt-in to the new code even if the client hasn't request ed it...
236 // These src attributes are only supported in the new 4f context
237 //
238 if (srcInfo.isSRGB() ||
239 kUnpremul_SkAlphaType == srcInfo.alphaType() ||
240 (4 == srcInfo.bytesPerPixel() && kN32_SkColorType != srcInfo.colorType() ))
241 {
242 return true;
243 }
244 #endif
245
246 // If we get here, we can reasonably use either context, respect the caller' s preference 235 // If we get here, we can reasonably use either context, respect the caller' s preference
247 // 236 //
248 return SkShader::ContextRec::kPM4f_DstType == rec.fPreferredDstType; 237 return SkShader::ContextRec::kPM4f_DstType == rec.fPreferredDstType;
249 } 238 }
250 239
251 size_t SkBitmapProcShader::ContextSize(const ContextRec& rec, const SkImageInfo& srcInfo) { 240 size_t SkBitmapProcShader::ContextSize(const ContextRec& rec, const SkImageInfo& srcInfo) {
252 size_t size0 = sizeof(BitmapProcShaderContext) + sizeof(SkBitmapProcState); 241 size_t size0 = sizeof(BitmapProcShaderContext) + sizeof(SkBitmapProcState);
253 size_t size1 = sizeof(LinearPipelineContext) + sizeof(SkBitmapProcInfo); 242 size_t size1 = sizeof(LinearPipelineContext) + sizeof(SkBitmapProcInfo);
254 return SkTMax(size0, size1); 243 return SkTMax(size0, size1);
255 } 244 }
256 245
257 SkShader::Context* SkBitmapProcShader::MakeContext(const SkShader& shader, 246 SkShader::Context* SkBitmapProcShader::MakeContext(const SkShader& shader,
258 TileMode tmx, TileMode tmy, 247 TileMode tmx, TileMode tmy,
259 const SkBitmapProvider& provi der, 248 const SkBitmapProvider& provi der,
260 const ContextRec& rec, void* storage) { 249 const ContextRec& rec, void* storage) {
261 SkMatrix totalInverse; 250 SkMatrix totalInverse;
262 // Do this first, so we know the matrix can be inverted. 251 // Do this first, so we know the matrix can be inverted.
263 if (!shader.computeTotalInverse(rec, &totalInverse)) { 252 if (!shader.computeTotalInverse(rec, &totalInverse)) {
264 return nullptr; 253 return nullptr;
265 } 254 }
266 255
267 // Decide if we can/want to use the new linear pipeline 256 // Decide if we can/want to use the new linear pipeline
268 bool useLinearPipeline = choose_linear_pipeline(rec, provider.info()); 257 bool useLinearPipeline = choose_linear_pipeline(rec, provider.info());
269 258
270 //
271 // For now, only enable locally since we are hitting some crashers on the te st bots
272 //
273 //useLinearPipeline = false;
274
275 if (useLinearPipeline) { 259 if (useLinearPipeline) {
276 void* infoStorage = (char*)storage + sizeof(LinearPipelineContext); 260 void* infoStorage = (char*)storage + sizeof(LinearPipelineContext);
277 SkBitmapProcInfo* info = new (infoStorage) SkBitmapProcInfo(provider, tm x, tmy); 261 SkBitmapProcInfo* info = new (infoStorage) SkBitmapProcInfo(provider, tm x, tmy);
278 if (!info->init(totalInverse, *rec.fPaint)) { 262 if (!info->init(totalInverse, *rec.fPaint)) {
279 info->~SkBitmapProcInfo(); 263 info->~SkBitmapProcInfo();
280 return nullptr; 264 return nullptr;
281 } 265 }
282 if (info->fPixmap.colorType() != kRGBA_8888_SkColorType 266 if (info->fPixmap.colorType() != kRGBA_8888_SkColorType
283 && info->fPixmap.colorType() != kBGRA_8888_SkColorType 267 && info->fPixmap.colorType() != kBGRA_8888_SkColorType
284 && info->fPixmap.colorType() != kIndex_8_SkColorType 268 && info->fPixmap.colorType() != kIndex_8_SkColorType
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
505 inner.reset(GrSimpleTextureEffect::Create(texture, matrix, params)); 489 inner.reset(GrSimpleTextureEffect::Create(texture, matrix, params));
506 } 490 }
507 491
508 if (kAlpha_8_SkColorType == fRawBitmap.colorType()) { 492 if (kAlpha_8_SkColorType == fRawBitmap.colorType()) {
509 return GrFragmentProcessor::MulOutputByInputUnpremulColor(inner); 493 return GrFragmentProcessor::MulOutputByInputUnpremulColor(inner);
510 } 494 }
511 return GrFragmentProcessor::MulOutputByInputAlpha(inner); 495 return GrFragmentProcessor::MulOutputByInputAlpha(inner);
512 } 496 }
513 497
514 #endif 498 #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