SkShader::asNewEffect Refactoring
The new signature is:
bool asNewEffect(GrContext* context, const SkPaint& paint, GrColor* grColor, GrEffectRef** grEffect, const SkMatrix* localMatrixOrNull) const;
It will fix the hack for skcolorshader by modifying the GrColor parameter in SkGr::SkPaint2GrPaintShader.
BUG=skia:2646
R=jvanverth@google.com, bsalomon@google.com
Author: dandov@google.com
Review URL: https://codereview.chromium.org/318923005
diff --git a/src/effects/gradients/SkRadialGradient.cpp b/src/effects/gradients/SkRadialGradient.cpp
index 3b9d175..f0cb161 100644
--- a/src/effects/gradients/SkRadialGradient.cpp
+++ b/src/effects/gradients/SkRadialGradient.cpp
@@ -458,6 +458,7 @@
#if SK_SUPPORT_GPU
#include "GrTBackendEffectFactory.h"
+#include "SkGr.h"
class GrGLRadialGradient : public GrGLGradientEffect {
public:
@@ -538,7 +539,10 @@
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;
}
/////////////////////////////////////////////////////////////////////
@@ -559,30 +563,37 @@
/////////////////////////////////////////////////////////////////////
-GrEffectRef* SkRadialGradient::asNewEffect(GrContext* context, const SkPaint&,
- const SkMatrix* localMatrix) const {
+bool SkRadialGradient::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 GrRadialGradient::Create(context, *this, matrix, fTileMode);
+
+ *grColor = SkColor2GrColorJustAlpha(paint.getColor());
+ *grEffect = GrRadialGradient::Create(context, *this, matrix, fTileMode);
+
+ return true;
}
#else
-GrEffectRef* SkRadialGradient::asNewEffect(GrContext*, const SkPaint&, const SkMatrix*) const {
+bool SkRadialGradient::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