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

Unified Diff: src/effects/gradients/SkLinearGradient.cpp

Issue 318923005: SkShader::asNewEffect Refactoring (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: change contract on SkShader::asNewEffect and added fix for SkBitmapProcShader::asNewEffect taking i… 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 side-by-side diff with in-line comments
Download patch
Index: src/effects/gradients/SkLinearGradient.cpp
diff --git a/src/effects/gradients/SkLinearGradient.cpp b/src/effects/gradients/SkLinearGradient.cpp
index 4766364e8db46b9f5a40fb1a4416b73691a31c9f..19a73ac2682cfdb22bac7c1103c966ce879948ff 100644
--- a/src/effects/gradients/SkLinearGradient.cpp
+++ b/src/effects/gradients/SkLinearGradient.cpp
@@ -6,6 +6,7 @@
*/
#include "SkLinearGradient.h"
+#include "SkGr.h"
static inline int repeat_bits(int x, const int bits) {
return x & ((1 << bits) - 1);
@@ -527,7 +528,10 @@ GrEffectRef* GrLinearGradient::TestCreate(SkRandom* random,
colors, stops, colorCount,
tm));
SkPaint paint;
- return shader->asNewEffect(context, paint, NULL);
+ GrColor grColor;
+ GrEffectRef* effect;
+ shader->asNewEffect(context, paint, NULL, &grColor, &effect);
+ return effect;
}
/////////////////////////////////////////////////////////////////////
@@ -547,29 +551,37 @@ void GrGLLinearGradient::emitCode(GrGLShaderBuilder* builder,
/////////////////////////////////////////////////////////////////////
-GrEffectRef* SkLinearGradient::asNewEffect(GrContext* context, const SkPaint&,
- const SkMatrix* localMatrix) const {
+bool SkLinearGradient::asNewEffect(GrContext* context, const SkPaint& paint,
+ const SkMatrix* localMatrix, GrColor* grColor,
+ GrEffectRef** grEffect) const {
SkASSERT(NULL != context);
+
SkMatrix matrix;
if (!this->getLocalMatrix().invert(&matrix)) {
- return NULL;
+ return false;
}
if (localMatrix) {
SkMatrix inv;
if (!localMatrix->invert(&inv)) {
- return NULL;
+ return false;
}
matrix.postConcat(inv);
}
matrix.postConcat(fPtsToUnit);
- return GrLinearGradient::Create(context, *this, matrix, fTileMode);
+
+ *grColor = SkColor2GrColorJustAlpha(paint.getColor());
+ *grEffect = GrLinearGradient::Create(context, *this, matrix, fTileMode);
+
+ return true;
}
#else
-GrEffectRef* SkLinearGradient::asNewEffect(GrContext*, const SkPaint&, const SkMatrix*) const {
+bool SkLinearGradient::asNewEffect(GrContext* context, const SkPaint& paint,
+ const SkMatrix* localMatrix, GrColor* grColor,
+ GrEffectRef** grEffect) const {
SkDEBUGFAIL("Should not call in GPU-less build");
- return NULL;
+ return false;
}
#endif

Powered by Google App Engine
This is Rietveld 408576698