| 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 "Sk4fLinearGradient.h" | 8 #include "Sk4fLinearGradient.h" |
| 9 #include "SkLinearGradient.h" | 9 #include "SkLinearGradient.h" |
| 10 #include "SkRefCnt.h" | 10 #include "SkRefCnt.h" |
| (...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 344 #include "glsl/GrGLSLCaps.h" | 344 #include "glsl/GrGLSLCaps.h" |
| 345 #include "glsl/GrGLSLFragmentShaderBuilder.h" | 345 #include "glsl/GrGLSLFragmentShaderBuilder.h" |
| 346 #include "SkGr.h" | 346 #include "SkGr.h" |
| 347 | 347 |
| 348 ///////////////////////////////////////////////////////////////////// | 348 ///////////////////////////////////////////////////////////////////// |
| 349 | 349 |
| 350 class GrLinearGradient : public GrGradientEffect { | 350 class GrLinearGradient : public GrGradientEffect { |
| 351 public: | 351 public: |
| 352 class GLSLLinearProcessor; | 352 class GLSLLinearProcessor; |
| 353 | 353 |
| 354 static sk_sp<GrFragmentProcessor> Make(GrContext* ctx, | 354 static sk_sp<GrFragmentProcessor> Make(const CreateArgs& args) { |
| 355 const SkLinearGradient& shader, | 355 return sk_sp<GrFragmentProcessor>(new GrLinearGradient(args)); |
| 356 const SkMatrix& matrix, | |
| 357 SkShader::TileMode tm) { | |
| 358 return sk_sp<GrFragmentProcessor>(new GrLinearGradient(ctx, shader, matr
ix, tm)); | |
| 359 } | 356 } |
| 360 | 357 |
| 361 virtual ~GrLinearGradient() { } | 358 virtual ~GrLinearGradient() { } |
| 362 | 359 |
| 363 const char* name() const override { return "Linear Gradient"; } | 360 const char* name() const override { return "Linear Gradient"; } |
| 364 | 361 |
| 365 private: | 362 private: |
| 366 GrLinearGradient(GrContext* ctx, | 363 GrLinearGradient(const CreateArgs& args) |
| 367 const SkLinearGradient& shader, | 364 : INHERITED(args) { |
| 368 const SkMatrix& matrix, | |
| 369 SkShader::TileMode tm) | |
| 370 : INHERITED(ctx, shader, matrix, tm) { | |
| 371 this->initClassID<GrLinearGradient>(); | 365 this->initClassID<GrLinearGradient>(); |
| 372 } | 366 } |
| 373 | 367 |
| 374 GrGLSLFragmentProcessor* onCreateGLSLInstance() const override; | 368 GrGLSLFragmentProcessor* onCreateGLSLInstance() const override; |
| 375 | 369 |
| 376 virtual void onGetGLSLProcessorKey(const GrGLSLCaps& caps, | 370 virtual void onGetGLSLProcessorKey(const GrGLSLCaps& caps, |
| 377 GrProcessorKeyBuilder* b) const override; | 371 GrProcessorKeyBuilder* b) const override; |
| 378 | 372 |
| 379 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; | 373 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; |
| 380 | 374 |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 460 } | 454 } |
| 461 if (args.fLocalMatrix) { | 455 if (args.fLocalMatrix) { |
| 462 SkMatrix inv; | 456 SkMatrix inv; |
| 463 if (!args.fLocalMatrix->invert(&inv)) { | 457 if (!args.fLocalMatrix->invert(&inv)) { |
| 464 return nullptr; | 458 return nullptr; |
| 465 } | 459 } |
| 466 matrix.postConcat(inv); | 460 matrix.postConcat(inv); |
| 467 } | 461 } |
| 468 matrix.postConcat(fPtsToUnit); | 462 matrix.postConcat(fPtsToUnit); |
| 469 | 463 |
| 470 sk_sp<GrFragmentProcessor> inner( | 464 sk_sp<GrFragmentProcessor> inner(GrLinearGradient::Make( |
| 471 GrLinearGradient::Make(args.fContext, *this, matrix, fTileMode)); | 465 GrGradientEffect::CreateArgs(args.fContext, this, &matrix, fTileMode))); |
| 472 return GrFragmentProcessor::MulOutputByInputAlpha(std::move(inner)); | 466 return GrFragmentProcessor::MulOutputByInputAlpha(std::move(inner)); |
| 473 } | 467 } |
| 474 | 468 |
| 475 | 469 |
| 476 #endif | 470 #endif |
| 477 | 471 |
| 478 #ifndef SK_IGNORE_TO_STRING | 472 #ifndef SK_IGNORE_TO_STRING |
| 479 void SkLinearGradient::toString(SkString* str) const { | 473 void SkLinearGradient::toString(SkString* str) const { |
| 480 str->append("SkLinearGradient ("); | 474 str->append("SkLinearGradient ("); |
| 481 | 475 |
| (...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 760 this->shade4_dx_clamp<false, true>(dstC, count, fx, dx, invDx, dithe
r); | 754 this->shade4_dx_clamp<false, true>(dstC, count, fx, dx, invDx, dithe
r); |
| 761 } | 755 } |
| 762 } else { | 756 } else { |
| 763 if (fApplyAlphaAfterInterp) { | 757 if (fApplyAlphaAfterInterp) { |
| 764 this->shade4_dx_clamp<true, false>(dstC, count, fx, dx, invDx, dithe
r); | 758 this->shade4_dx_clamp<true, false>(dstC, count, fx, dx, invDx, dithe
r); |
| 765 } else { | 759 } else { |
| 766 this->shade4_dx_clamp<false, false>(dstC, count, fx, dx, invDx, dith
er); | 760 this->shade4_dx_clamp<false, false>(dstC, count, fx, dx, invDx, dith
er); |
| 767 } | 761 } |
| 768 } | 762 } |
| 769 } | 763 } |
| OLD | NEW |