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

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

Issue 318923005: SkShader::asNewEffect Refactoring (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: added macros to check for gpu support Created 6 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 | « src/core/SkPictureShader.cpp ('k') | src/effects/SkPerlinNoiseShader.cpp » ('j') | 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 2006 The Android Open Source Project 2 * Copyright 2006 The Android Open Source Project
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 "SkEmptyShader.h" 9 #include "SkEmptyShader.h"
10 #include "SkReadBuffer.h" 10 #include "SkReadBuffer.h"
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 ////////////////////////////////////////////////////////////////////////////// 201 //////////////////////////////////////////////////////////////////////////////
202 202
203 SkShader::BitmapType SkShader::asABitmap(SkBitmap*, SkMatrix*, TileMode*) const { 203 SkShader::BitmapType SkShader::asABitmap(SkBitmap*, SkMatrix*, TileMode*) const {
204 return kNone_BitmapType; 204 return kNone_BitmapType;
205 } 205 }
206 206
207 SkShader::GradientType SkShader::asAGradient(GradientInfo* info) const { 207 SkShader::GradientType SkShader::asAGradient(GradientInfo* info) const {
208 return kNone_GradientType; 208 return kNone_GradientType;
209 } 209 }
210 210
211 GrEffectRef* SkShader::asNewEffect(GrContext*, const SkPaint&, const SkMatrix*) const { 211 bool SkShader::asNewEffect(GrContext* context, const SkPaint& paint,
212 return NULL; 212 const SkMatrix* localMatrixOrNull, GrColor* grColor,
213 GrEffectRef** grEffect) const {
214 return false;
213 } 215 }
214 216
215 SkShader* SkShader::refAsALocalMatrixShader(SkMatrix*) const { 217 SkShader* SkShader::refAsALocalMatrixShader(SkMatrix*) const {
216 return NULL; 218 return NULL;
217 } 219 }
218 220
219 SkShader* SkShader::CreateEmptyShader() { 221 SkShader* SkShader::CreateEmptyShader() {
220 return SkNEW(SkEmptyShader); 222 return SkNEW(SkEmptyShader);
221 } 223 }
222 224
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 if (info) { 336 if (info) {
335 if (info->fColors && info->fColorCount >= 1) { 337 if (info->fColors && info->fColorCount >= 1) {
336 info->fColors[0] = fColor; 338 info->fColors[0] = fColor;
337 } 339 }
338 info->fColorCount = 1; 340 info->fColorCount = 1;
339 info->fTileMode = SkShader::kRepeat_TileMode; 341 info->fTileMode = SkShader::kRepeat_TileMode;
340 } 342 }
341 return kColor_GradientType; 343 return kColor_GradientType;
342 } 344 }
343 345
346 #if SK_SUPPORT_GPU
347
348 #include "SkGr.h"
349
350 bool SkColorShader::asNewEffect(GrContext* context, const SkPaint& paint,
351 const SkMatrix* localMatrix, GrColor* grColor,
352 GrEffectRef** grEffect) const {
353 *grEffect = NULL;
354 SkColor skColor = fColor;
355 U8CPU newA = SkMulDiv255Round(SkColorGetA(fColor), paint.getAlpha());
356 *grColor = SkColor2GrColor(SkColorSetA(skColor, newA));
357 return true;
358 }
359
360 #else
361
362 bool SkColorShader::asNewEffect(GrContext* context, const SkPaint& paint,
363 const SkMatrix* localMatrix, GrColor* grCol or,
364 GrEffectRef** grEffect) const {
365 SkDEBUGFAIL("Should not call in GPU-less build");
366 return false;
367 }
368
369 #endif
370
344 #ifndef SK_IGNORE_TO_STRING 371 #ifndef SK_IGNORE_TO_STRING
345 void SkColorShader::toString(SkString* str) const { 372 void SkColorShader::toString(SkString* str) const {
346 str->append("SkColorShader: ("); 373 str->append("SkColorShader: (");
347 374
348 str->append("Color: "); 375 str->append("Color: ");
349 str->appendHex(fColor); 376 str->appendHex(fColor);
350 377
351 this->INHERITED::toString(str); 378 this->INHERITED::toString(str);
352 379
353 str->append(")"); 380 str->append(")");
354 } 381 }
355 #endif 382 #endif
356 383
357 /////////////////////////////////////////////////////////////////////////////// 384 ///////////////////////////////////////////////////////////////////////////////
358 385
359 #ifndef SK_IGNORE_TO_STRING 386 #ifndef SK_IGNORE_TO_STRING
360 #include "SkEmptyShader.h" 387 #include "SkEmptyShader.h"
361 388
362 void SkEmptyShader::toString(SkString* str) const { 389 void SkEmptyShader::toString(SkString* str) const {
363 str->append("SkEmptyShader: ("); 390 str->append("SkEmptyShader: (");
364 391
365 this->INHERITED::toString(str); 392 this->INHERITED::toString(str);
366 393
367 str->append(")"); 394 str->append(")");
368 } 395 }
369 #endif 396 #endif
OLDNEW
« no previous file with comments | « src/core/SkPictureShader.cpp ('k') | src/effects/SkPerlinNoiseShader.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698