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 "SkRadialGradient.h" | 8 #include "SkRadialGradient.h" |
9 #include "SkNx.h" | 9 #include "SkNx.h" |
10 | 10 |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 #if SK_SUPPORT_GPU | 239 #if SK_SUPPORT_GPU |
240 | 240 |
241 #include "SkGr.h" | 241 #include "SkGr.h" |
242 #include "glsl/GrGLSLCaps.h" | 242 #include "glsl/GrGLSLCaps.h" |
243 #include "glsl/GrGLSLFragmentShaderBuilder.h" | 243 #include "glsl/GrGLSLFragmentShaderBuilder.h" |
244 | 244 |
245 class GrRadialGradient : public GrGradientEffect { | 245 class GrRadialGradient : public GrGradientEffect { |
246 public: | 246 public: |
247 class GLSLRadialProcessor; | 247 class GLSLRadialProcessor; |
248 | 248 |
249 static sk_sp<GrFragmentProcessor> Make(GrContext* ctx, | 249 static sk_sp<GrFragmentProcessor> Make(const CreateArgs& args) { |
250 const SkRadialGradient& shader, | 250 return sk_sp<GrFragmentProcessor>(new GrRadialGradient(args)); |
251 const SkMatrix& matrix, | |
252 SkShader::TileMode tm) { | |
253 return sk_sp<GrFragmentProcessor>(new GrRadialGradient(ctx, shader, matr
ix, tm)); | |
254 } | 251 } |
255 | 252 |
256 virtual ~GrRadialGradient() { } | 253 virtual ~GrRadialGradient() { } |
257 | 254 |
258 const char* name() const override { return "Radial Gradient"; } | 255 const char* name() const override { return "Radial Gradient"; } |
259 | 256 |
260 private: | 257 private: |
261 GrRadialGradient(GrContext* ctx, | 258 GrRadialGradient(const CreateArgs& args) |
262 const SkRadialGradient& shader, | 259 : INHERITED(args) { |
263 const SkMatrix& matrix, | |
264 SkShader::TileMode tm) | |
265 : INHERITED(ctx, shader, matrix, tm) { | |
266 this->initClassID<GrRadialGradient>(); | 260 this->initClassID<GrRadialGradient>(); |
267 } | 261 } |
268 | 262 |
269 GrGLSLFragmentProcessor* onCreateGLSLInstance() const override; | 263 GrGLSLFragmentProcessor* onCreateGLSLInstance() const override; |
270 | 264 |
271 virtual void onGetGLSLProcessorKey(const GrGLSLCaps& caps, | 265 virtual void onGetGLSLProcessorKey(const GrGLSLCaps& caps, |
272 GrProcessorKeyBuilder* b) const override; | 266 GrProcessorKeyBuilder* b) const override; |
273 | 267 |
274 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; | 268 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; |
275 | 269 |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
354 return nullptr; | 348 return nullptr; |
355 } | 349 } |
356 if (args.fLocalMatrix) { | 350 if (args.fLocalMatrix) { |
357 SkMatrix inv; | 351 SkMatrix inv; |
358 if (!args.fLocalMatrix->invert(&inv)) { | 352 if (!args.fLocalMatrix->invert(&inv)) { |
359 return nullptr; | 353 return nullptr; |
360 } | 354 } |
361 matrix.postConcat(inv); | 355 matrix.postConcat(inv); |
362 } | 356 } |
363 matrix.postConcat(fPtsToUnit); | 357 matrix.postConcat(fPtsToUnit); |
364 sk_sp<GrFragmentProcessor> inner( | 358 sk_sp<GrFragmentProcessor> inner(GrRadialGradient::Make( |
365 GrRadialGradient::Make(args.fContext, *this, matrix, fTileMode)); | 359 GrGradientEffect::CreateArgs(args.fContext, this, &matrix, fTileMode))); |
366 return GrFragmentProcessor::MulOutputByInputAlpha(std::move(inner)); | 360 return GrFragmentProcessor::MulOutputByInputAlpha(std::move(inner)); |
367 } | 361 } |
368 | 362 |
369 #endif | 363 #endif |
370 | 364 |
371 #ifndef SK_IGNORE_TO_STRING | 365 #ifndef SK_IGNORE_TO_STRING |
372 void SkRadialGradient::toString(SkString* str) const { | 366 void SkRadialGradient::toString(SkString* str) const { |
373 str->append("SkRadialGradient: ("); | 367 str->append("SkRadialGradient: ("); |
374 | 368 |
375 str->append("center: ("); | 369 str->append("center: ("); |
376 str->appendScalar(fCenter.fX); | 370 str->appendScalar(fCenter.fX); |
377 str->append(", "); | 371 str->append(", "); |
378 str->appendScalar(fCenter.fY); | 372 str->appendScalar(fCenter.fY); |
379 str->append(") radius: "); | 373 str->append(") radius: "); |
380 str->appendScalar(fRadius); | 374 str->appendScalar(fRadius); |
381 str->append(" "); | 375 str->append(" "); |
382 | 376 |
383 this->INHERITED::toString(str); | 377 this->INHERITED::toString(str); |
384 | 378 |
385 str->append(")"); | 379 str->append(")"); |
386 } | 380 } |
387 #endif | 381 #endif |
OLD | NEW |