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

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

Issue 2221133002: Refactor various gradient effect classes (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Brian's suggestions Created 4 years, 4 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/SkGradientShaderPriv.h ('k') | src/effects/gradients/SkRadialGradient.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/effects/gradients/SkLinearGradient.cpp
diff --git a/src/effects/gradients/SkLinearGradient.cpp b/src/effects/gradients/SkLinearGradient.cpp
index cdac5c8f5f01b2486a328ea4c5d9c270510f8d2c..872c6e81d100263c74a705a71b7aaa944feb229f 100644
--- a/src/effects/gradients/SkLinearGradient.cpp
+++ b/src/effects/gradients/SkLinearGradient.cpp
@@ -347,28 +347,9 @@ SkShader::GradientType SkLinearGradient::asAGradient(GradientInfo* info) const {
/////////////////////////////////////////////////////////////////////
-class GrGLLinearGradient : public GrGLGradientEffect {
-public:
-
- GrGLLinearGradient(const GrProcessor&) {}
-
- virtual ~GrGLLinearGradient() { }
-
- virtual void emitCode(EmitArgs&) override;
-
- static void GenKey(const GrProcessor& processor, const GrGLSLCaps&, GrProcessorKeyBuilder* b) {
- b->add32(GenBaseGradientKey(processor));
- }
-
-private:
-
- typedef GrGLGradientEffect INHERITED;
-};
-
-/////////////////////////////////////////////////////////////////////
-
class GrLinearGradient : public GrGradientEffect {
public:
+ class GLSLLinearProcessor;
static sk_sp<GrFragmentProcessor> Make(GrContext* ctx,
const SkLinearGradient& shader,
@@ -390,14 +371,10 @@ private:
this->initClassID<GrLinearGradient>();
}
- GrGLSLFragmentProcessor* onCreateGLSLInstance() const override {
- return new GrGLLinearGradient(*this);
- }
+ GrGLSLFragmentProcessor* onCreateGLSLInstance() const override;
virtual void onGetGLSLProcessorKey(const GrGLSLCaps& caps,
- GrProcessorKeyBuilder* b) const override {
- GrGLLinearGradient::GenKey(*this, caps, b);
- }
+ GrProcessorKeyBuilder* b) const override;
GR_DECLARE_FRAGMENT_PROCESSOR_TEST;
@@ -406,6 +383,35 @@ private:
/////////////////////////////////////////////////////////////////////
+class GrLinearGradient::GLSLLinearProcessor : public GrGradientEffect::GLSLProcessor {
+public:
+ GLSLLinearProcessor(const GrProcessor&) {}
+
+ virtual ~GLSLLinearProcessor() { }
+
+ virtual void emitCode(EmitArgs&) override;
+
+ static void GenKey(const GrProcessor& processor, const GrGLSLCaps&, GrProcessorKeyBuilder* b) {
+ b->add32(GenBaseGradientKey(processor));
+ }
+
+private:
+ typedef GrGradientEffect::GLSLProcessor INHERITED;
+};
+
+/////////////////////////////////////////////////////////////////////
+
+GrGLSLFragmentProcessor* GrLinearGradient::onCreateGLSLInstance() const {
+ return new GrLinearGradient::GLSLLinearProcessor(*this);
+}
+
+void GrLinearGradient::onGetGLSLProcessorKey(const GrGLSLCaps& caps,
+ GrProcessorKeyBuilder* b) const {
+ GrLinearGradient::GLSLLinearProcessor::GenKey(*this, caps, b);
+}
+
+/////////////////////////////////////////////////////////////////////
+
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrLinearGradient);
sk_sp<GrFragmentProcessor> GrLinearGradient::TestCreate(GrProcessorTestData* d) {
@@ -428,7 +434,7 @@ sk_sp<GrFragmentProcessor> GrLinearGradient::TestCreate(GrProcessorTestData* d)
/////////////////////////////////////////////////////////////////////
-void GrGLLinearGradient::emitCode(EmitArgs& args) {
+void GrLinearGradient::GLSLLinearProcessor::emitCode(EmitArgs& args) {
const GrLinearGradient& ge = args.fFp.cast<GrLinearGradient>();
this->emitUniforms(args.fUniformHandler, ge);
SkString t = args.fFragBuilder->ensureFSCoords2D(args.fCoords, 0);
@@ -436,7 +442,8 @@ void GrGLLinearGradient::emitCode(EmitArgs& args) {
this->emitColor(args.fFragBuilder,
args.fUniformHandler,
args.fGLSLCaps,
- ge, t.c_str(),
+ ge,
+ t.c_str(),
args.fOutputColor,
args.fInputColor,
args.fTexSamplers);
« no previous file with comments | « src/effects/gradients/SkGradientShaderPriv.h ('k') | src/effects/gradients/SkRadialGradient.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698