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

Side by Side Diff: src/effects/gradients/SkSweepGradient.cpp

Issue 2332213007: Bundle common arguments to GrGradientEffect creation (Closed)
Patch Set: Fix non-GPU compile errors Created 4 years, 3 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright 2012 Google Inc. 2 * Copyright 2012 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkSweepGradient.h" 8 #include "SkSweepGradient.h"
9 9
10 static SkMatrix translate(SkScalar dx, SkScalar dy) { 10 static SkMatrix translate(SkScalar dx, SkScalar dy) {
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 122
123 #include "SkGr.h" 123 #include "SkGr.h"
124 #include "gl/GrGLContext.h" 124 #include "gl/GrGLContext.h"
125 #include "glsl/GrGLSLCaps.h" 125 #include "glsl/GrGLSLCaps.h"
126 #include "glsl/GrGLSLFragmentShaderBuilder.h" 126 #include "glsl/GrGLSLFragmentShaderBuilder.h"
127 127
128 class GrSweepGradient : public GrGradientEffect { 128 class GrSweepGradient : public GrGradientEffect {
129 public: 129 public:
130 class GLSLSweepProcessor; 130 class GLSLSweepProcessor;
131 131
132 static sk_sp<GrFragmentProcessor> Make(GrContext* ctx, const SkSweepGradient & shader, 132 static sk_sp<GrFragmentProcessor> Make(const CreateArgs& args) {
133 const SkMatrix& m) { 133 return sk_sp<GrFragmentProcessor>(new GrSweepGradient(args));
134 return sk_sp<GrFragmentProcessor>(new GrSweepGradient(ctx, shader, m));
135 } 134 }
136 virtual ~GrSweepGradient() { } 135 virtual ~GrSweepGradient() { }
137 136
138 const char* name() const override { return "Sweep Gradient"; } 137 const char* name() const override { return "Sweep Gradient"; }
139 138
140 private: 139 private:
141 GrSweepGradient(GrContext* ctx, 140 GrSweepGradient(const CreateArgs& args)
142 const SkSweepGradient& shader, 141 : INHERITED(args) {
143 const SkMatrix& matrix)
144 : INHERITED(ctx, shader, matrix, SkShader::kClamp_TileMode) {
145 this->initClassID<GrSweepGradient>(); 142 this->initClassID<GrSweepGradient>();
146 } 143 }
147 144
148 GrGLSLFragmentProcessor* onCreateGLSLInstance() const override; 145 GrGLSLFragmentProcessor* onCreateGLSLInstance() const override;
149 146
150 virtual void onGetGLSLProcessorKey(const GrGLSLCaps& caps, 147 virtual void onGetGLSLProcessorKey(const GrGLSLCaps& caps,
151 GrProcessorKeyBuilder* b) const override; 148 GrProcessorKeyBuilder* b) const override;
152 149
153 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; 150 GR_DECLARE_FRAGMENT_PROCESSOR_TEST;
154 151
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 } 240 }
244 if (args.fLocalMatrix) { 241 if (args.fLocalMatrix) {
245 SkMatrix inv; 242 SkMatrix inv;
246 if (!args.fLocalMatrix->invert(&inv)) { 243 if (!args.fLocalMatrix->invert(&inv)) {
247 return nullptr; 244 return nullptr;
248 } 245 }
249 matrix.postConcat(inv); 246 matrix.postConcat(inv);
250 } 247 }
251 matrix.postConcat(fPtsToUnit); 248 matrix.postConcat(fPtsToUnit);
252 249
253 sk_sp<GrFragmentProcessor> inner(GrSweepGradient::Make(args.fContext, *this, matrix)); 250 sk_sp<GrFragmentProcessor> inner(GrSweepGradient::Make(
251 GrGradientEffect::CreateArgs(args.fContext, this, &matrix, SkShader::kCl amp_TileMode)));
254 return GrFragmentProcessor::MulOutputByInputAlpha(std::move(inner)); 252 return GrFragmentProcessor::MulOutputByInputAlpha(std::move(inner));
255 } 253 }
256 254
257 #endif 255 #endif
258 256
259 #ifndef SK_IGNORE_TO_STRING 257 #ifndef SK_IGNORE_TO_STRING
260 void SkSweepGradient::toString(SkString* str) const { 258 void SkSweepGradient::toString(SkString* str) const {
261 str->append("SkSweepGradient: ("); 259 str->append("SkSweepGradient: (");
262 260
263 str->append("center: ("); 261 str->append("center: (");
264 str->appendScalar(fCenter.fX); 262 str->appendScalar(fCenter.fX);
265 str->append(", "); 263 str->append(", ");
266 str->appendScalar(fCenter.fY); 264 str->appendScalar(fCenter.fY);
267 str->append(") "); 265 str->append(") ");
268 266
269 this->INHERITED::toString(str); 267 this->INHERITED::toString(str);
270 268
271 str->append(")"); 269 str->append(")");
272 } 270 }
273 #endif 271 #endif
OLDNEW
« no previous file with comments | « src/effects/gradients/SkRadialGradient.cpp ('k') | src/effects/gradients/SkTwoPointConicalGradient.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698