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

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

Issue 318923005: SkShader::asNewEffect Refactoring (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: SkColorShader refactor and fix 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/SkSweepGradient.cpp
diff --git a/src/effects/gradients/SkSweepGradient.cpp b/src/effects/gradients/SkSweepGradient.cpp
index 3dddbbabed10e168f3c6690722bee787d49f9530..89ebd70d035b84949be8403e338f64a276e5fe08 100644
--- a/src/effects/gradients/SkSweepGradient.cpp
+++ b/src/effects/gradients/SkSweepGradient.cpp
@@ -247,7 +247,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 +282,34 @@ 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 {
+ *grColor = this->getColorAsAlpha(paint);
+
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);
+ return NULL != *grEffect;
}
#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

Powered by Google App Engine
This is Rietveld 408576698