OLD | NEW |
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 Loading... |
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(const CreateArgs& args) { | 132 static sk_sp<GrFragmentProcessor> Make(GrContext* ctx, const SkSweepGradient
& shader, |
133 return sk_sp<GrFragmentProcessor>(new GrSweepGradient(args)); | 133 const SkMatrix& m) { |
| 134 return sk_sp<GrFragmentProcessor>(new GrSweepGradient(ctx, shader, m)); |
134 } | 135 } |
135 virtual ~GrSweepGradient() { } | 136 virtual ~GrSweepGradient() { } |
136 | 137 |
137 const char* name() const override { return "Sweep Gradient"; } | 138 const char* name() const override { return "Sweep Gradient"; } |
138 | 139 |
139 private: | 140 private: |
140 GrSweepGradient(const CreateArgs& args) | 141 GrSweepGradient(GrContext* ctx, |
141 : INHERITED(args) { | 142 const SkSweepGradient& shader, |
| 143 const SkMatrix& matrix) |
| 144 : INHERITED(ctx, shader, matrix, SkShader::kClamp_TileMode) { |
142 this->initClassID<GrSweepGradient>(); | 145 this->initClassID<GrSweepGradient>(); |
143 } | 146 } |
144 | 147 |
145 GrGLSLFragmentProcessor* onCreateGLSLInstance() const override; | 148 GrGLSLFragmentProcessor* onCreateGLSLInstance() const override; |
146 | 149 |
147 virtual void onGetGLSLProcessorKey(const GrGLSLCaps& caps, | 150 virtual void onGetGLSLProcessorKey(const GrGLSLCaps& caps, |
148 GrProcessorKeyBuilder* b) const override; | 151 GrProcessorKeyBuilder* b) const override; |
149 | 152 |
150 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; | 153 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; |
151 | 154 |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 } | 243 } |
241 if (args.fLocalMatrix) { | 244 if (args.fLocalMatrix) { |
242 SkMatrix inv; | 245 SkMatrix inv; |
243 if (!args.fLocalMatrix->invert(&inv)) { | 246 if (!args.fLocalMatrix->invert(&inv)) { |
244 return nullptr; | 247 return nullptr; |
245 } | 248 } |
246 matrix.postConcat(inv); | 249 matrix.postConcat(inv); |
247 } | 250 } |
248 matrix.postConcat(fPtsToUnit); | 251 matrix.postConcat(fPtsToUnit); |
249 | 252 |
250 sk_sp<GrFragmentProcessor> inner(GrSweepGradient::Make( | 253 sk_sp<GrFragmentProcessor> inner(GrSweepGradient::Make(args.fContext, *this,
matrix)); |
251 GrGradientEffect::CreateArgs(args.fContext, this, &matrix, SkShader::kCl
amp_TileMode))); | |
252 return GrFragmentProcessor::MulOutputByInputAlpha(std::move(inner)); | 254 return GrFragmentProcessor::MulOutputByInputAlpha(std::move(inner)); |
253 } | 255 } |
254 | 256 |
255 #endif | 257 #endif |
256 | 258 |
257 #ifndef SK_IGNORE_TO_STRING | 259 #ifndef SK_IGNORE_TO_STRING |
258 void SkSweepGradient::toString(SkString* str) const { | 260 void SkSweepGradient::toString(SkString* str) const { |
259 str->append("SkSweepGradient: ("); | 261 str->append("SkSweepGradient: ("); |
260 | 262 |
261 str->append("center: ("); | 263 str->append("center: ("); |
262 str->appendScalar(fCenter.fX); | 264 str->appendScalar(fCenter.fX); |
263 str->append(", "); | 265 str->append(", "); |
264 str->appendScalar(fCenter.fY); | 266 str->appendScalar(fCenter.fY); |
265 str->append(") "); | 267 str->append(") "); |
266 | 268 |
267 this->INHERITED::toString(str); | 269 this->INHERITED::toString(str); |
268 | 270 |
269 str->append(")"); | 271 str->append(")"); |
270 } | 272 } |
271 #endif | 273 #endif |
OLD | NEW |