OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 "SkTwoPointConicalGradient_gpu.h" | 8 #include "SkTwoPointConicalGradient_gpu.h" |
9 | 9 |
10 #include "SkTwoPointConicalGradient.h" | 10 #include "SkTwoPointConicalGradient.h" |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 rot.setSinCos(-SkScalarMul(invDiffLen, diff.fY), | 55 rot.setSinCos(-SkScalarMul(invDiffLen, diff.fY), |
56 SkScalarMul(invDiffLen, diff.fX)); | 56 SkScalarMul(invDiffLen, diff.fX)); |
57 invLMatrix->postConcat(rot); | 57 invLMatrix->postConcat(rot); |
58 } | 58 } |
59 } | 59 } |
60 | 60 |
61 class Edge2PtConicalEffect : public GrGradientEffect { | 61 class Edge2PtConicalEffect : public GrGradientEffect { |
62 public: | 62 public: |
63 class GLSLEdge2PtConicalProcessor; | 63 class GLSLEdge2PtConicalProcessor; |
64 | 64 |
65 static sk_sp<GrFragmentProcessor> Make(GrContext* ctx, | 65 static sk_sp<GrFragmentProcessor> Make(const CreateArgs& args) { |
66 const SkTwoPointConicalGradient& shad
er, | 66 return sk_sp<GrFragmentProcessor>(new Edge2PtConicalEffect(args)); |
67 const SkMatrix& matrix, | |
68 SkShader::TileMode tm) { | |
69 return sk_sp<GrFragmentProcessor>(new Edge2PtConicalEffect(ctx, shader,
matrix, tm)); | |
70 } | 67 } |
71 | 68 |
72 virtual ~Edge2PtConicalEffect() {} | 69 virtual ~Edge2PtConicalEffect() {} |
73 | 70 |
74 const char* name() const override { | 71 const char* name() const override { |
75 return "Two-Point Conical Gradient Edge Touching"; | 72 return "Two-Point Conical Gradient Edge Touching"; |
76 } | 73 } |
77 | 74 |
78 // The radial gradient parameters can collapse to a linear (instead of quadr
atic) equation. | 75 // The radial gradient parameters can collapse to a linear (instead of quadr
atic) equation. |
79 SkScalar center() const { return fCenterX1; } | 76 SkScalar center() const { return fCenterX1; } |
80 SkScalar diffRadius() const { return fDiffRadius; } | 77 SkScalar diffRadius() const { return fDiffRadius; } |
81 SkScalar radius() const { return fRadius0; } | 78 SkScalar radius() const { return fRadius0; } |
82 | 79 |
83 private: | 80 private: |
84 GrGLSLFragmentProcessor* onCreateGLSLInstance() const override; | 81 GrGLSLFragmentProcessor* onCreateGLSLInstance() const override; |
85 | 82 |
86 void onGetGLSLProcessorKey(const GrGLSLCaps&, GrProcessorKeyBuilder*) const
override; | 83 void onGetGLSLProcessorKey(const GrGLSLCaps&, GrProcessorKeyBuilder*) const
override; |
87 | 84 |
88 bool onIsEqual(const GrFragmentProcessor& sBase) const override { | 85 bool onIsEqual(const GrFragmentProcessor& sBase) const override { |
89 const Edge2PtConicalEffect& s = sBase.cast<Edge2PtConicalEffect>(); | 86 const Edge2PtConicalEffect& s = sBase.cast<Edge2PtConicalEffect>(); |
90 return (INHERITED::onIsEqual(sBase) && | 87 return (INHERITED::onIsEqual(sBase) && |
91 this->fCenterX1 == s.fCenterX1 && | 88 this->fCenterX1 == s.fCenterX1 && |
92 this->fRadius0 == s.fRadius0 && | 89 this->fRadius0 == s.fRadius0 && |
93 this->fDiffRadius == s.fDiffRadius); | 90 this->fDiffRadius == s.fDiffRadius); |
94 } | 91 } |
95 | 92 |
96 Edge2PtConicalEffect(GrContext* ctx, | 93 Edge2PtConicalEffect(const CreateArgs& args) |
97 const SkTwoPointConicalGradient& shader, | 94 : INHERITED(args) { |
98 const SkMatrix& matrix, | 95 const SkTwoPointConicalGradient& shader = |
99 SkShader::TileMode tm) | 96 *static_cast<const SkTwoPointConicalGradient*>(args.fShader); |
100 : INHERITED(ctx, shader, matrix, tm), | 97 fCenterX1 = shader.getCenterX1(); |
101 fCenterX1(shader.getCenterX1()), | 98 fRadius0 = shader.getStartRadius(); |
102 fRadius0(shader.getStartRadius()), | 99 fDiffRadius = shader.getDiffRadius(); |
103 fDiffRadius(shader.getDiffRadius()){ | |
104 this->initClassID<Edge2PtConicalEffect>(); | 100 this->initClassID<Edge2PtConicalEffect>(); |
105 // We should only be calling this shader if we are degenerate case with
touching circles | 101 // We should only be calling this shader if we are degenerate case with
touching circles |
106 // When deciding if we are in edge case, we scaled by the end radius for
cases when the | 102 // When deciding if we are in edge case, we scaled by the end radius for
cases when the |
107 // start radius was close to zero, otherwise we scaled by the start radi
us. In addition | 103 // start radius was close to zero, otherwise we scaled by the start radi
us. In addition |
108 // Our test for the edge case in set_matrix_circle_conical has a higher
tolerance so we | 104 // Our test for the edge case in set_matrix_circle_conical has a higher
tolerance so we |
109 // need the sqrt value below | 105 // need the sqrt value below |
110 SkASSERT(SkScalarAbs(SkScalarAbs(fDiffRadius) - fCenterX1) < | 106 SkASSERT(SkScalarAbs(SkScalarAbs(fDiffRadius) - fCenterX1) < |
111 (fRadius0 < kErrorTol ? shader.getEndRadius() * kEdgeErrorTol : | 107 (fRadius0 < kErrorTol ? shader.getEndRadius() * kEdgeErrorTol : |
112 fRadius0 * sqrt(kEdgeErrorTol))); | 108 fRadius0 * sqrt(kEdgeErrorTol))); |
113 | 109 |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
369 | 365 |
370 return conicalType; | 366 return conicalType; |
371 } | 367 } |
372 | 368 |
373 ////////////////////////////////////////////////////////////////////////////// | 369 ////////////////////////////////////////////////////////////////////////////// |
374 | 370 |
375 class FocalOutside2PtConicalEffect : public GrGradientEffect { | 371 class FocalOutside2PtConicalEffect : public GrGradientEffect { |
376 public: | 372 public: |
377 class GLSLFocalOutside2PtConicalProcessor; | 373 class GLSLFocalOutside2PtConicalProcessor; |
378 | 374 |
379 static sk_sp<GrFragmentProcessor> Make(GrContext* ctx, | 375 static sk_sp<GrFragmentProcessor> Make(const CreateArgs& args, SkScalar foca
lX) { |
380 const SkTwoPointConicalGradient& shad
er, | |
381 const SkMatrix& matrix, | |
382 SkShader::TileMode tm, | |
383 SkScalar focalX) { | |
384 return sk_sp<GrFragmentProcessor>( | 376 return sk_sp<GrFragmentProcessor>( |
385 new FocalOutside2PtConicalEffect(ctx, shader, matrix, tm, focalX)); | 377 new FocalOutside2PtConicalEffect(args, focalX)); |
386 } | 378 } |
387 | 379 |
388 virtual ~FocalOutside2PtConicalEffect() { } | 380 virtual ~FocalOutside2PtConicalEffect() { } |
389 | 381 |
390 const char* name() const override { | 382 const char* name() const override { |
391 return "Two-Point Conical Gradient Focal Outside"; | 383 return "Two-Point Conical Gradient Focal Outside"; |
392 } | 384 } |
393 | 385 |
394 bool isFlipped() const { return fIsFlipped; } | 386 bool isFlipped() const { return fIsFlipped; } |
395 SkScalar focal() const { return fFocalX; } | 387 SkScalar focal() const { return fFocalX; } |
396 | 388 |
397 private: | 389 private: |
398 GrGLSLFragmentProcessor* onCreateGLSLInstance() const override; | 390 GrGLSLFragmentProcessor* onCreateGLSLInstance() const override; |
399 | 391 |
400 void onGetGLSLProcessorKey(const GrGLSLCaps&, GrProcessorKeyBuilder*) const
override; | 392 void onGetGLSLProcessorKey(const GrGLSLCaps&, GrProcessorKeyBuilder*) const
override; |
401 | 393 |
402 bool onIsEqual(const GrFragmentProcessor& sBase) const override { | 394 bool onIsEqual(const GrFragmentProcessor& sBase) const override { |
403 const FocalOutside2PtConicalEffect& s = sBase.cast<FocalOutside2PtConica
lEffect>(); | 395 const FocalOutside2PtConicalEffect& s = sBase.cast<FocalOutside2PtConica
lEffect>(); |
404 return (INHERITED::onIsEqual(sBase) && | 396 return (INHERITED::onIsEqual(sBase) && |
405 this->fFocalX == s.fFocalX && | 397 this->fFocalX == s.fFocalX && |
406 this->fIsFlipped == s.fIsFlipped); | 398 this->fIsFlipped == s.fIsFlipped); |
407 } | 399 } |
408 | 400 |
409 FocalOutside2PtConicalEffect(GrContext* ctx, | 401 FocalOutside2PtConicalEffect(const CreateArgs& args, SkScalar focalX) |
410 const SkTwoPointConicalGradient& shader, | 402 : INHERITED(args) |
411 const SkMatrix& matrix, | |
412 SkShader::TileMode tm, | |
413 SkScalar focalX) | |
414 : INHERITED(ctx, shader, matrix, tm) | |
415 , fFocalX(focalX) | 403 , fFocalX(focalX) |
416 , fIsFlipped(shader.isFlippedGrad()) { | 404 , fIsFlipped(static_cast<const SkTwoPointConicalGradient*>(args.fShader)->is
FlippedGrad()) { |
417 this->initClassID<FocalOutside2PtConicalEffect>(); | 405 this->initClassID<FocalOutside2PtConicalEffect>(); |
418 } | 406 } |
419 | 407 |
420 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; | 408 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; |
421 | 409 |
422 SkScalar fFocalX; | 410 SkScalar fFocalX; |
423 bool fIsFlipped; | 411 bool fIsFlipped; |
424 | 412 |
425 typedef GrGradientEffect INHERITED; | 413 typedef GrGradientEffect INHERITED; |
426 }; | 414 }; |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
584 key[0] = GenBaseGradientKey(processor); | 572 key[0] = GenBaseGradientKey(processor); |
585 key[1] = processor.cast<FocalOutside2PtConicalEffect>().isFlipped(); | 573 key[1] = processor.cast<FocalOutside2PtConicalEffect>().isFlipped(); |
586 } | 574 } |
587 | 575 |
588 ////////////////////////////////////////////////////////////////////////////// | 576 ////////////////////////////////////////////////////////////////////////////// |
589 | 577 |
590 class FocalInside2PtConicalEffect : public GrGradientEffect { | 578 class FocalInside2PtConicalEffect : public GrGradientEffect { |
591 public: | 579 public: |
592 class GLSLFocalInside2PtConicalProcessor; | 580 class GLSLFocalInside2PtConicalProcessor; |
593 | 581 |
594 static sk_sp<GrFragmentProcessor> Make(GrContext* ctx, | 582 static sk_sp<GrFragmentProcessor> Make(const CreateArgs& args, SkScalar foca
lX) { |
595 const SkTwoPointConicalGradient& shad
er, | |
596 const SkMatrix& matrix, | |
597 SkShader::TileMode tm, | |
598 SkScalar focalX) { | |
599 return sk_sp<GrFragmentProcessor>( | 583 return sk_sp<GrFragmentProcessor>( |
600 new FocalInside2PtConicalEffect(ctx, shader, matrix, tm, focalX)); | 584 new FocalInside2PtConicalEffect(args, focalX)); |
601 } | 585 } |
602 | 586 |
603 virtual ~FocalInside2PtConicalEffect() {} | 587 virtual ~FocalInside2PtConicalEffect() {} |
604 | 588 |
605 const char* name() const override { | 589 const char* name() const override { |
606 return "Two-Point Conical Gradient Focal Inside"; | 590 return "Two-Point Conical Gradient Focal Inside"; |
607 } | 591 } |
608 | 592 |
609 SkScalar focal() const { return fFocalX; } | 593 SkScalar focal() const { return fFocalX; } |
610 | 594 |
611 typedef FocalInside2PtConicalEffect::GLSLFocalInside2PtConicalProcessor GLSL
Processor; | 595 typedef FocalInside2PtConicalEffect::GLSLFocalInside2PtConicalProcessor GLSL
Processor; |
612 | 596 |
613 private: | 597 private: |
614 GrGLSLFragmentProcessor* onCreateGLSLInstance() const override; | 598 GrGLSLFragmentProcessor* onCreateGLSLInstance() const override; |
615 | 599 |
616 void onGetGLSLProcessorKey(const GrGLSLCaps&, GrProcessorKeyBuilder*) const
override; | 600 void onGetGLSLProcessorKey(const GrGLSLCaps&, GrProcessorKeyBuilder*) const
override; |
617 | 601 |
618 bool onIsEqual(const GrFragmentProcessor& sBase) const override { | 602 bool onIsEqual(const GrFragmentProcessor& sBase) const override { |
619 const FocalInside2PtConicalEffect& s = sBase.cast<FocalInside2PtConicalE
ffect>(); | 603 const FocalInside2PtConicalEffect& s = sBase.cast<FocalInside2PtConicalE
ffect>(); |
620 return (INHERITED::onIsEqual(sBase) && | 604 return (INHERITED::onIsEqual(sBase) && |
621 this->fFocalX == s.fFocalX); | 605 this->fFocalX == s.fFocalX); |
622 } | 606 } |
623 | 607 |
624 FocalInside2PtConicalEffect(GrContext* ctx, | 608 FocalInside2PtConicalEffect(const CreateArgs& args, SkScalar focalX) |
625 const SkTwoPointConicalGradient& shader, | 609 : INHERITED(args), fFocalX(focalX) { |
626 const SkMatrix& matrix, | |
627 SkShader::TileMode tm, | |
628 SkScalar focalX) | |
629 : INHERITED(ctx, shader, matrix, tm), fFocalX(focalX) { | |
630 this->initClassID<FocalInside2PtConicalEffect>(); | 610 this->initClassID<FocalInside2PtConicalEffect>(); |
631 } | 611 } |
632 | 612 |
633 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; | 613 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; |
634 | 614 |
635 SkScalar fFocalX; | 615 SkScalar fFocalX; |
636 | 616 |
637 typedef GrGradientEffect INHERITED; | 617 typedef GrGradientEffect INHERITED; |
638 }; | 618 }; |
639 | 619 |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
830 if (A < 0.f) { | 810 if (A < 0.f) { |
831 return kInside_ConicalType; | 811 return kInside_ConicalType; |
832 } | 812 } |
833 return kOutside_ConicalType; | 813 return kOutside_ConicalType; |
834 } | 814 } |
835 | 815 |
836 class CircleInside2PtConicalEffect : public GrGradientEffect { | 816 class CircleInside2PtConicalEffect : public GrGradientEffect { |
837 public: | 817 public: |
838 class GLSLCircleInside2PtConicalProcessor; | 818 class GLSLCircleInside2PtConicalProcessor; |
839 | 819 |
840 static sk_sp<GrFragmentProcessor> Make(GrContext* ctx, | 820 static sk_sp<GrFragmentProcessor> Make(const CreateArgs& args, const CircleC
onicalInfo& info) { |
841 const SkTwoPointConicalGradient& shad
er, | |
842 const SkMatrix& matrix, | |
843 SkShader::TileMode tm, | |
844 const CircleConicalInfo& info) { | |
845 return sk_sp<GrFragmentProcessor>( | 821 return sk_sp<GrFragmentProcessor>( |
846 new CircleInside2PtConicalEffect(ctx, shader, matrix, tm, info)); | 822 new CircleInside2PtConicalEffect(args, info)); |
847 } | 823 } |
848 | 824 |
849 virtual ~CircleInside2PtConicalEffect() {} | 825 virtual ~CircleInside2PtConicalEffect() {} |
850 | 826 |
851 const char* name() const override { return "Two-Point Conical Gradient Insid
e"; } | 827 const char* name() const override { return "Two-Point Conical Gradient Insid
e"; } |
852 | 828 |
853 SkScalar centerX() const { return fInfo.fCenterEnd.fX; } | 829 SkScalar centerX() const { return fInfo.fCenterEnd.fX; } |
854 SkScalar centerY() const { return fInfo.fCenterEnd.fY; } | 830 SkScalar centerY() const { return fInfo.fCenterEnd.fY; } |
855 SkScalar A() const { return fInfo.fA; } | 831 SkScalar A() const { return fInfo.fA; } |
856 SkScalar B() const { return fInfo.fB; } | 832 SkScalar B() const { return fInfo.fB; } |
857 SkScalar C() const { return fInfo.fC; } | 833 SkScalar C() const { return fInfo.fC; } |
858 | 834 |
859 private: | 835 private: |
860 GrGLSLFragmentProcessor* onCreateGLSLInstance() const override; | 836 GrGLSLFragmentProcessor* onCreateGLSLInstance() const override; |
861 | 837 |
862 virtual void onGetGLSLProcessorKey(const GrGLSLCaps& caps, | 838 virtual void onGetGLSLProcessorKey(const GrGLSLCaps& caps, |
863 GrProcessorKeyBuilder* b) const override; | 839 GrProcessorKeyBuilder* b) const override; |
864 | 840 |
865 bool onIsEqual(const GrFragmentProcessor& sBase) const override { | 841 bool onIsEqual(const GrFragmentProcessor& sBase) const override { |
866 const CircleInside2PtConicalEffect& s = sBase.cast<CircleInside2PtConica
lEffect>(); | 842 const CircleInside2PtConicalEffect& s = sBase.cast<CircleInside2PtConica
lEffect>(); |
867 return (INHERITED::onIsEqual(sBase) && | 843 return (INHERITED::onIsEqual(sBase) && |
868 this->fInfo.fCenterEnd == s.fInfo.fCenterEnd && | 844 this->fInfo.fCenterEnd == s.fInfo.fCenterEnd && |
869 this->fInfo.fA == s.fInfo.fA && | 845 this->fInfo.fA == s.fInfo.fA && |
870 this->fInfo.fB == s.fInfo.fB && | 846 this->fInfo.fB == s.fInfo.fB && |
871 this->fInfo.fC == s.fInfo.fC); | 847 this->fInfo.fC == s.fInfo.fC); |
872 } | 848 } |
873 | 849 |
874 CircleInside2PtConicalEffect(GrContext* ctx, | 850 CircleInside2PtConicalEffect(const CreateArgs& args, const CircleConicalInfo
& info) |
875 const SkTwoPointConicalGradient& shader, | 851 : INHERITED(args), fInfo(info) { |
876 const SkMatrix& matrix, | |
877 SkShader::TileMode tm, | |
878 const CircleConicalInfo& info) | |
879 : INHERITED(ctx, shader, matrix, tm), fInfo(info) { | |
880 this->initClassID<CircleInside2PtConicalEffect>(); | 852 this->initClassID<CircleInside2PtConicalEffect>(); |
881 } | 853 } |
882 | 854 |
883 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; | 855 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; |
884 | 856 |
885 const CircleConicalInfo fInfo; | 857 const CircleConicalInfo fInfo; |
886 | 858 |
887 typedef GrGradientEffect INHERITED; | 859 typedef GrGradientEffect INHERITED; |
888 }; | 860 }; |
889 | 861 |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1053 const GrGLSLCaps&, GrProcessorKeyBui
lder* b) { | 1025 const GrGLSLCaps&, GrProcessorKeyBui
lder* b) { |
1054 b->add32(GenBaseGradientKey(processor)); | 1026 b->add32(GenBaseGradientKey(processor)); |
1055 } | 1027 } |
1056 | 1028 |
1057 ////////////////////////////////////////////////////////////////////////////// | 1029 ////////////////////////////////////////////////////////////////////////////// |
1058 | 1030 |
1059 class CircleOutside2PtConicalEffect : public GrGradientEffect { | 1031 class CircleOutside2PtConicalEffect : public GrGradientEffect { |
1060 public: | 1032 public: |
1061 class GLSLCircleOutside2PtConicalProcessor; | 1033 class GLSLCircleOutside2PtConicalProcessor; |
1062 | 1034 |
1063 static sk_sp<GrFragmentProcessor> Make(GrContext* ctx, | 1035 static sk_sp<GrFragmentProcessor> Make(const CreateArgs& args, const CircleC
onicalInfo& info) { |
1064 const SkTwoPointConicalGradient& shad
er, | |
1065 const SkMatrix& matrix, | |
1066 SkShader::TileMode tm, | |
1067 const CircleConicalInfo& info) { | |
1068 return sk_sp<GrFragmentProcessor>( | 1036 return sk_sp<GrFragmentProcessor>( |
1069 new CircleOutside2PtConicalEffect(ctx, shader, matrix, tm, info)); | 1037 new CircleOutside2PtConicalEffect(args, info)); |
1070 } | 1038 } |
1071 | 1039 |
1072 virtual ~CircleOutside2PtConicalEffect() {} | 1040 virtual ~CircleOutside2PtConicalEffect() {} |
1073 | 1041 |
1074 const char* name() const override { return "Two-Point Conical Gradient Outsi
de"; } | 1042 const char* name() const override { return "Two-Point Conical Gradient Outsi
de"; } |
1075 | 1043 |
1076 SkScalar centerX() const { return fInfo.fCenterEnd.fX; } | 1044 SkScalar centerX() const { return fInfo.fCenterEnd.fX; } |
1077 SkScalar centerY() const { return fInfo.fCenterEnd.fY; } | 1045 SkScalar centerY() const { return fInfo.fCenterEnd.fY; } |
1078 SkScalar A() const { return fInfo.fA; } | 1046 SkScalar A() const { return fInfo.fA; } |
1079 SkScalar B() const { return fInfo.fB; } | 1047 SkScalar B() const { return fInfo.fB; } |
(...skipping 10 matching lines...) Expand all Loading... |
1090 const CircleOutside2PtConicalEffect& s = sBase.cast<CircleOutside2PtConi
calEffect>(); | 1058 const CircleOutside2PtConicalEffect& s = sBase.cast<CircleOutside2PtConi
calEffect>(); |
1091 return (INHERITED::onIsEqual(sBase) && | 1059 return (INHERITED::onIsEqual(sBase) && |
1092 this->fInfo.fCenterEnd == s.fInfo.fCenterEnd && | 1060 this->fInfo.fCenterEnd == s.fInfo.fCenterEnd && |
1093 this->fInfo.fA == s.fInfo.fA && | 1061 this->fInfo.fA == s.fInfo.fA && |
1094 this->fInfo.fB == s.fInfo.fB && | 1062 this->fInfo.fB == s.fInfo.fB && |
1095 this->fInfo.fC == s.fInfo.fC && | 1063 this->fInfo.fC == s.fInfo.fC && |
1096 this->fTLimit == s.fTLimit && | 1064 this->fTLimit == s.fTLimit && |
1097 this->fIsFlipped == s.fIsFlipped); | 1065 this->fIsFlipped == s.fIsFlipped); |
1098 } | 1066 } |
1099 | 1067 |
1100 CircleOutside2PtConicalEffect(GrContext* ctx, | 1068 CircleOutside2PtConicalEffect(const CreateArgs& args, const CircleConicalInf
o& info) |
1101 const SkTwoPointConicalGradient& shader, | 1069 : INHERITED(args), fInfo(info) { |
1102 const SkMatrix& matrix, | |
1103 SkShader::TileMode tm, | |
1104 const CircleConicalInfo& info) | |
1105 : INHERITED(ctx, shader, matrix, tm), fInfo(info) { | |
1106 this->initClassID<CircleOutside2PtConicalEffect>(); | 1070 this->initClassID<CircleOutside2PtConicalEffect>(); |
| 1071 const SkTwoPointConicalGradient& shader = |
| 1072 *static_cast<const SkTwoPointConicalGradient*>(args.fShader); |
1107 if (shader.getStartRadius() != shader.getEndRadius()) { | 1073 if (shader.getStartRadius() != shader.getEndRadius()) { |
1108 fTLimit = shader.getStartRadius() / (shader.getStartRadius() - shade
r.getEndRadius()); | 1074 fTLimit = shader.getStartRadius() / (shader.getStartRadius() - shade
r.getEndRadius()); |
1109 } else { | 1075 } else { |
1110 fTLimit = SK_ScalarMin; | 1076 fTLimit = SK_ScalarMin; |
1111 } | 1077 } |
1112 | 1078 |
1113 fIsFlipped = shader.isFlippedGrad(); | 1079 fIsFlipped = shader.isFlippedGrad(); |
1114 } | 1080 } |
1115 | 1081 |
1116 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; | 1082 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1315 void CircleOutside2PtConicalEffect::GLSLCircleOutside2PtConicalProcessor::GenKey
( | 1281 void CircleOutside2PtConicalEffect::GLSLCircleOutside2PtConicalProcessor::GenKey
( |
1316 const GrProcessor& processor, | 1282 const GrProcessor& processor, |
1317 const GrGLSLCaps&, GrProcessorKeyBui
lder* b) { | 1283 const GrGLSLCaps&, GrProcessorKeyBui
lder* b) { |
1318 uint32_t* key = b->add32n(2); | 1284 uint32_t* key = b->add32n(2); |
1319 key[0] = GenBaseGradientKey(processor); | 1285 key[0] = GenBaseGradientKey(processor); |
1320 key[1] = processor.cast<CircleOutside2PtConicalEffect>().isFlipped(); | 1286 key[1] = processor.cast<CircleOutside2PtConicalEffect>().isFlipped(); |
1321 } | 1287 } |
1322 | 1288 |
1323 ////////////////////////////////////////////////////////////////////////////// | 1289 ////////////////////////////////////////////////////////////////////////////// |
1324 | 1290 |
1325 sk_sp<GrFragmentProcessor> Gr2PtConicalGradientEffect::Make(GrContext* ctx, | 1291 sk_sp<GrFragmentProcessor> Gr2PtConicalGradientEffect::Make( |
1326 const SkTwoPointConi
calGradient& shader, | 1292 const GrGradientEffect:
:CreateArgs& args) { |
1327 SkShader::TileMode t
m, | 1293 const SkTwoPointConicalGradient& shader = |
1328 const SkMatrix* loca
lMatrix) { | 1294 *static_cast<const SkTwoPointConicalGradient*>(args.fShader); |
| 1295 |
1329 SkMatrix matrix; | 1296 SkMatrix matrix; |
1330 if (!shader.getLocalMatrix().invert(&matrix)) { | 1297 if (!shader.getLocalMatrix().invert(&matrix)) { |
1331 return nullptr; | 1298 return nullptr; |
1332 } | 1299 } |
1333 if (localMatrix) { | 1300 if (args.fMatrix) { |
1334 SkMatrix inv; | 1301 SkMatrix inv; |
1335 if (!localMatrix->invert(&inv)) { | 1302 if (!args.fMatrix->invert(&inv)) { |
1336 return nullptr; | 1303 return nullptr; |
1337 } | 1304 } |
1338 matrix.postConcat(inv); | 1305 matrix.postConcat(inv); |
1339 } | 1306 } |
1340 | 1307 |
| 1308 GrGradientEffect::CreateArgs newArgs(args.fContext, args.fShader, &matrix, a
rgs.fTileMode); |
| 1309 |
1341 if (shader.getStartRadius() < kErrorTol) { | 1310 if (shader.getStartRadius() < kErrorTol) { |
1342 SkScalar focalX; | 1311 SkScalar focalX; |
1343 ConicalType type = set_matrix_focal_conical(shader, &matrix, &focalX); | 1312 ConicalType type = set_matrix_focal_conical(shader, &matrix, &focalX); |
1344 if (type == kInside_ConicalType) { | 1313 if (type == kInside_ConicalType) { |
1345 return FocalInside2PtConicalEffect::Make(ctx, shader, matrix, tm, fo
calX); | 1314 return FocalInside2PtConicalEffect::Make(newArgs, focalX); |
1346 } else if(type == kEdge_ConicalType) { | 1315 } else if(type == kEdge_ConicalType) { |
1347 set_matrix_edge_conical(shader, &matrix); | 1316 set_matrix_edge_conical(shader, &matrix); |
1348 return Edge2PtConicalEffect::Make(ctx, shader, matrix, tm); | 1317 return Edge2PtConicalEffect::Make(newArgs); |
1349 } else { | 1318 } else { |
1350 return FocalOutside2PtConicalEffect::Make(ctx, shader, matrix, tm, f
ocalX); | 1319 return FocalOutside2PtConicalEffect::Make(newArgs, focalX); |
1351 } | 1320 } |
1352 } | 1321 } |
1353 | 1322 |
1354 CircleConicalInfo info; | 1323 CircleConicalInfo info; |
1355 ConicalType type = set_matrix_circle_conical(shader, &matrix, &info); | 1324 ConicalType type = set_matrix_circle_conical(shader, &matrix, &info); |
1356 | 1325 |
1357 if (type == kInside_ConicalType) { | 1326 if (type == kInside_ConicalType) { |
1358 return CircleInside2PtConicalEffect::Make(ctx, shader, matrix, tm, info)
; | 1327 return CircleInside2PtConicalEffect::Make(newArgs, info); |
1359 } else if (type == kEdge_ConicalType) { | 1328 } else if (type == kEdge_ConicalType) { |
1360 set_matrix_edge_conical(shader, &matrix); | 1329 set_matrix_edge_conical(shader, &matrix); |
1361 return Edge2PtConicalEffect::Make(ctx, shader, matrix, tm); | 1330 return Edge2PtConicalEffect::Make(newArgs); |
1362 } else { | 1331 } else { |
1363 return CircleOutside2PtConicalEffect::Make(ctx, shader, matrix, tm, info
); | 1332 return CircleOutside2PtConicalEffect::Make(newArgs, info); |
1364 } | 1333 } |
1365 } | 1334 } |
1366 | 1335 |
1367 #endif | 1336 #endif |
OLD | NEW |