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

Unified Diff: src/effects/gradients/SkSweepGradient.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/SkRadialGradient.cpp ('k') | src/effects/gradients/SkTwoPointConicalGradient_gpu.cpp » ('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 8732534746cd3c51f0dbe1b4905a4ba9c080e59e..6e32aa3b7b5eb0da137f1a283180e197e65de2a0 100644
--- a/src/effects/gradients/SkSweepGradient.cpp
+++ b/src/effects/gradients/SkSweepGradient.cpp
@@ -125,28 +125,10 @@ void SkSweepGradient::SweepGradientContext::shadeSpan(int x, int y, SkPMColor* S
#include "glsl/GrGLSLCaps.h"
#include "glsl/GrGLSLFragmentShaderBuilder.h"
-class GrGLSweepGradient : public GrGLGradientEffect {
-public:
-
- GrGLSweepGradient(const GrProcessor&) {}
- virtual ~GrGLSweepGradient() { }
-
- virtual void emitCode(EmitArgs&) override;
-
- static void GenKey(const GrProcessor& processor, const GrGLSLCaps&, GrProcessorKeyBuilder* b) {
- b->add32(GenBaseGradientKey(processor));
- }
-
-private:
-
- typedef GrGLGradientEffect INHERITED;
-
-};
-
-/////////////////////////////////////////////////////////////////////
-
class GrSweepGradient : public GrGradientEffect {
public:
+ class GLSLSweepProcessor;
+
static sk_sp<GrFragmentProcessor> Make(GrContext* ctx, const SkSweepGradient& shader,
const SkMatrix& m) {
return sk_sp<GrFragmentProcessor>(new GrSweepGradient(ctx, shader, m));
@@ -163,14 +145,10 @@ private:
this->initClassID<GrSweepGradient>();
}
- GrGLSLFragmentProcessor* onCreateGLSLInstance() const override {
- return new GrGLSweepGradient(*this);
- }
+ GrGLSLFragmentProcessor* onCreateGLSLInstance() const override;
virtual void onGetGLSLProcessorKey(const GrGLSLCaps& caps,
- GrProcessorKeyBuilder* b) const override {
- GrGLSweepGradient::GenKey(*this, caps, b);
- }
+ GrProcessorKeyBuilder* b) const override;
GR_DECLARE_FRAGMENT_PROCESSOR_TEST;
@@ -179,6 +157,36 @@ private:
/////////////////////////////////////////////////////////////////////
+class GrSweepGradient::GLSLSweepProcessor : public GrGradientEffect::GLSLProcessor {
+public:
+ GLSLSweepProcessor(const GrProcessor&) {}
+ virtual ~GLSLSweepProcessor() { }
+
+ 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* GrSweepGradient::onCreateGLSLInstance() const {
+ return new GrSweepGradient::GLSLSweepProcessor(*this);
+}
+
+void GrSweepGradient::onGetGLSLProcessorKey(const GrGLSLCaps& caps,
+ GrProcessorKeyBuilder* b) const {
+ GrSweepGradient::GLSLSweepProcessor::GenKey(*this, caps, b);
+}
+
+
+/////////////////////////////////////////////////////////////////////
+
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrSweepGradient);
sk_sp<GrFragmentProcessor> GrSweepGradient::TestCreate(GrProcessorTestData* d) {
@@ -201,7 +209,7 @@ sk_sp<GrFragmentProcessor> GrSweepGradient::TestCreate(GrProcessorTestData* d) {
/////////////////////////////////////////////////////////////////////
-void GrGLSweepGradient::emitCode(EmitArgs& args) {
+void GrSweepGradient::GLSLSweepProcessor::emitCode(EmitArgs& args) {
const GrSweepGradient& ge = args.fFp.cast<GrSweepGradient>();
this->emitUniforms(args.fUniformHandler, ge);
SkString coords2D = args.fFragBuilder->ensureFSCoords2D(args.fCoords, 0);
« no previous file with comments | « src/effects/gradients/SkRadialGradient.cpp ('k') | src/effects/gradients/SkTwoPointConicalGradient_gpu.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698