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

Unified Diff: src/effects/gradients/SkSweepGradient.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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/effects/gradients/SkSweepGradient.h ('k') | src/effects/gradients/SkTwoPointConicalGradient.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/effects/gradients/SkSweepGradient.cpp
diff --git a/src/effects/gradients/SkSweepGradient.cpp b/src/effects/gradients/SkSweepGradient.cpp
index 3dddbbabed10e168f3c6690722bee787d49f9530..154e3a2f13850d6a54a87c20b9681fd379f97a05 100644
--- a/src/effects/gradients/SkSweepGradient.cpp
+++ b/src/effects/gradients/SkSweepGradient.cpp
@@ -174,6 +174,7 @@ void SkSweepGradient::SweepGradientContext::shadeSpan16(int x, int y, uint16_t*
#if SK_SUPPORT_GPU
#include "GrTBackendEffectFactory.h"
+#include "SkGr.h"
class GrGLSweepGradient : public GrGLGradientEffect {
public:
@@ -247,7 +248,10 @@ GrEffectRef* GrSweepGradient::TestCreate(SkRandom* random,
SkAutoTUnref<SkShader> shader(SkGradientShader::CreateSweep(center.fX, center.fY,
colors, stops, colorCount));
SkPaint paint;
- return shader->asNewEffect(context, paint, NULL);
+ GrEffectRef* effect;
+ GrColor grColor;
+ shader->asNewEffect(context, paint, NULL, &grColor, &effect);
+ return effect;
}
/////////////////////////////////////////////////////////////////////
@@ -279,28 +283,36 @@ void GrGLSweepGradient::emitCode(GrGLShaderBuilder* builder,
/////////////////////////////////////////////////////////////////////
-GrEffectRef* SkSweepGradient::asNewEffect(GrContext* context, const SkPaint&,
- const SkMatrix* localMatrix) const {
+bool SkSweepGradient::asNewEffect(GrContext* context, const SkPaint& paint,
+ const SkMatrix* localMatrix, GrColor* grColor,
+ GrEffectRef** grEffect) const {
+
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 GrSweepGradient::Create(context, *this, matrix);
+
+ *grEffect = GrSweepGradient::Create(context, *this, matrix);
+ *grColor = SkColor2GrColorJustAlpha(paint.getColor());
+
+ return true;
}
#else
-GrEffectRef* SkSweepGradient::asNewEffect(GrContext*, const SkPaint&, const SkMatrix*) const {
+bool SkSweepGradient::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
« no previous file with comments | « src/effects/gradients/SkSweepGradient.h ('k') | src/effects/gradients/SkTwoPointConicalGradient.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698