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

Unified Diff: src/effects/gradients/SkTwoPointRadialGradient.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/SkTwoPointRadialGradient.h ('k') | src/gpu/SkGpuDevice.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/effects/gradients/SkTwoPointRadialGradient.cpp
diff --git a/src/effects/gradients/SkTwoPointRadialGradient.cpp b/src/effects/gradients/SkTwoPointRadialGradient.cpp
index 8243cda33cf4114b4ee8651b7b88db11b0d060e0..e3d89960c65f1c95621ef8aef4f4b46c356cc503 100644
--- a/src/effects/gradients/SkTwoPointRadialGradient.cpp
+++ b/src/effects/gradients/SkTwoPointRadialGradient.cpp
@@ -6,7 +6,7 @@
* found in the LICENSE file.
*/
- #include "SkTwoPointRadialGradient.h"
+#include "SkTwoPointRadialGradient.h"
/* Two-point radial gradients are specified by two circles, each with a center
point and radius. The gradient can be considered to be a series of
@@ -383,6 +383,7 @@ void SkTwoPointRadialGradient::init() {
#if SK_SUPPORT_GPU
#include "GrTBackendEffectFactory.h"
+#include "SkGr.h"
// For brevity
typedef GrGLUniformManager::UniformHandle UniformHandle;
@@ -530,7 +531,10 @@ GrEffectRef* GrRadial2Gradient::TestCreate(SkRandom* random,
colors, stops, colorCount,
tm));
SkPaint paint;
- return shader->asNewEffect(context, paint, NULL);
+ GrEffectRef* effect;
+ GrColor grColor;
+ shader->asNewEffect(context, paint, NULL, &grColor, &effect);
+ return effect;
}
/////////////////////////////////////////////////////////////////////
@@ -670,18 +674,20 @@ GrGLEffect::EffectKey GrGLRadial2Gradient::GenKey(const GrDrawEffect& drawEffect
/////////////////////////////////////////////////////////////////////
-GrEffectRef* SkTwoPointRadialGradient::asNewEffect(GrContext* context, const SkPaint&,
- const SkMatrix* localMatrix) const {
+bool SkTwoPointRadialGradient::asNewEffect(GrContext* context, const SkPaint& paint,
+ const SkMatrix* localMatrix, GrColor* grColor,
+ GrEffectRef** grEffect) const {
SkASSERT(NULL != context);
+
// invert the localM, translate to center1 (fPtsToUni), rotate so center2 is on x axis.
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);
}
@@ -696,15 +702,19 @@ GrEffectRef* SkTwoPointRadialGradient::asNewEffect(GrContext* context, const SkP
matrix.postConcat(rot);
}
- return GrRadial2Gradient::Create(context, *this, matrix, fTileMode);
+ *grColor = SkColor2GrColorJustAlpha(paint.getColor());
+ *grEffect = GrRadial2Gradient::Create(context, *this, matrix, fTileMode);
+
+ return true;
}
#else
-GrEffectRef* SkTwoPointRadialGradient::asNewEffect(GrContext*, const SkPaint&,
- const SkMatrix*) const {
+bool SkTwoPointRadialGradient::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/SkTwoPointRadialGradient.h ('k') | src/gpu/SkGpuDevice.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698