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