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