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