Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(152)

Side by Side Diff: src/effects/gradients/SkTwoPointConicalGradient_gpu.cpp

Issue 1215643006: more threading of GrShaderDataManager (Closed) Base URL: https://skia.googlesource.com/skia.git@GrShaderDataManager3
Patch Set: tweaks Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2014 Google Inc. 3 * Copyright 2014 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 #include "SkTwoPointConicalGradient_gpu.h" 9 #include "SkTwoPointConicalGradient_gpu.h"
10 10
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 rot.setSinCos(-SkScalarMul(invDiffLen, diff.fY), 51 rot.setSinCos(-SkScalarMul(invDiffLen, diff.fY),
52 SkScalarMul(invDiffLen, diff.fX)); 52 SkScalarMul(invDiffLen, diff.fX));
53 invLMatrix->postConcat(rot); 53 invLMatrix->postConcat(rot);
54 } 54 }
55 } 55 }
56 56
57 class Edge2PtConicalEffect : public GrGradientEffect { 57 class Edge2PtConicalEffect : public GrGradientEffect {
58 public: 58 public:
59 59
60 static GrFragmentProcessor* Create(GrContext* ctx, 60 static GrFragmentProcessor* Create(GrContext* ctx,
61 GrShaderDataManager* shaderDataManager,
61 const SkTwoPointConicalGradient& shader, 62 const SkTwoPointConicalGradient& shader,
62 const SkMatrix& matrix, 63 const SkMatrix& matrix,
63 SkShader::TileMode tm) { 64 SkShader::TileMode tm) {
64 return SkNEW_ARGS(Edge2PtConicalEffect, (ctx, shader, matrix, tm)); 65 return SkNEW_ARGS(Edge2PtConicalEffect, (ctx, shaderDataManager, shader, matrix, tm));
65 } 66 }
66 67
67 virtual ~Edge2PtConicalEffect() {} 68 virtual ~Edge2PtConicalEffect() {}
68 69
69 const char* name() const override { 70 const char* name() const override {
70 return "Two-Point Conical Gradient Edge Touching"; 71 return "Two-Point Conical Gradient Edge Touching";
71 } 72 }
72 73
73 void getGLProcessorKey(const GrGLSLCaps&, GrProcessorKeyBuilder*) const over ride; 74 void getGLProcessorKey(const GrGLSLCaps&, GrProcessorKeyBuilder*) const over ride;
74 75
75 GrGLFragmentProcessor* createGLInstance() const override; 76 GrGLFragmentProcessor* createGLInstance() const override;
76 77
77 // 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.
78 SkScalar center() const { return fCenterX1; } 79 SkScalar center() const { return fCenterX1; }
79 SkScalar diffRadius() const { return fDiffRadius; } 80 SkScalar diffRadius() const { return fDiffRadius; }
80 SkScalar radius() const { return fRadius0; } 81 SkScalar radius() const { return fRadius0; }
81 82
82 private: 83 private:
83 bool onIsEqual(const GrFragmentProcessor& sBase) const override { 84 bool onIsEqual(const GrFragmentProcessor& sBase) const override {
84 const Edge2PtConicalEffect& s = sBase.cast<Edge2PtConicalEffect>(); 85 const Edge2PtConicalEffect& s = sBase.cast<Edge2PtConicalEffect>();
85 return (INHERITED::onIsEqual(sBase) && 86 return (INHERITED::onIsEqual(sBase) &&
86 this->fCenterX1 == s.fCenterX1 && 87 this->fCenterX1 == s.fCenterX1 &&
87 this->fRadius0 == s.fRadius0 && 88 this->fRadius0 == s.fRadius0 &&
88 this->fDiffRadius == s.fDiffRadius); 89 this->fDiffRadius == s.fDiffRadius);
89 } 90 }
90 91
91 Edge2PtConicalEffect(GrContext* ctx, 92 Edge2PtConicalEffect(GrContext* ctx,
93 GrShaderDataManager* shaderDataManager,
92 const SkTwoPointConicalGradient& shader, 94 const SkTwoPointConicalGradient& shader,
93 const SkMatrix& matrix, 95 const SkMatrix& matrix,
94 SkShader::TileMode tm) 96 SkShader::TileMode tm)
95 : INHERITED(ctx, shader, matrix, tm), 97 : INHERITED(ctx, shaderDataManager, shader, matrix, tm),
96 fCenterX1(shader.getCenterX1()), 98 fCenterX1(shader.getCenterX1()),
97 fRadius0(shader.getStartRadius()), 99 fRadius0(shader.getStartRadius()),
98 fDiffRadius(shader.getDiffRadius()){ 100 fDiffRadius(shader.getDiffRadius()){
99 this->initClassID<Edge2PtConicalEffect>(); 101 this->initClassID<Edge2PtConicalEffect>();
100 // We should only be calling this shader if we are degenerate case with touching circles 102 // We should only be calling this shader if we are degenerate case with touching circles
101 // When deciding if we are in edge case, we scaled by the end radius for cases when the 103 // When deciding if we are in edge case, we scaled by the end radius for cases when the
102 // start radius was close to zero, otherwise we scaled by the start radi us. In addition 104 // start radius was close to zero, otherwise we scaled by the start radi us. In addition
103 // Our test for the edge case in set_matrix_circle_conical has a higher tolerance so we 105 // Our test for the edge case in set_matrix_circle_conical has a higher tolerance so we
104 // need the sqrt value below 106 // need the sqrt value below
105 SkASSERT(SkScalarAbs(SkScalarAbs(fDiffRadius) - fCenterX1) < 107 SkASSERT(SkScalarAbs(SkScalarAbs(fDiffRadius) - fCenterX1) <
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 374
373 return conicalType; 375 return conicalType;
374 } 376 }
375 377
376 ////////////////////////////////////////////////////////////////////////////// 378 //////////////////////////////////////////////////////////////////////////////
377 379
378 class FocalOutside2PtConicalEffect : public GrGradientEffect { 380 class FocalOutside2PtConicalEffect : public GrGradientEffect {
379 public: 381 public:
380 382
381 static GrFragmentProcessor* Create(GrContext* ctx, 383 static GrFragmentProcessor* Create(GrContext* ctx,
384 GrShaderDataManager* shaderDataManager,
382 const SkTwoPointConicalGradient& shader, 385 const SkTwoPointConicalGradient& shader,
383 const SkMatrix& matrix, 386 const SkMatrix& matrix,
384 SkShader::TileMode tm, 387 SkShader::TileMode tm,
385 SkScalar focalX) { 388 SkScalar focalX) {
386 return SkNEW_ARGS(FocalOutside2PtConicalEffect, (ctx, shader, matrix, tm , focalX)); 389 return SkNEW_ARGS(FocalOutside2PtConicalEffect, (ctx, shaderDataManager, shader, matrix, tm,
390 focalX));
387 } 391 }
388 392
389 virtual ~FocalOutside2PtConicalEffect() { } 393 virtual ~FocalOutside2PtConicalEffect() { }
390 394
391 const char* name() const override { 395 const char* name() const override {
392 return "Two-Point Conical Gradient Focal Outside"; 396 return "Two-Point Conical Gradient Focal Outside";
393 } 397 }
394 398
395 void getGLProcessorKey(const GrGLSLCaps&, GrProcessorKeyBuilder*) const over ride; 399 void getGLProcessorKey(const GrGLSLCaps&, GrProcessorKeyBuilder*) const over ride;
396 400
397 GrGLFragmentProcessor* createGLInstance() const override; 401 GrGLFragmentProcessor* createGLInstance() const override;
398 402
399 bool isFlipped() const { return fIsFlipped; } 403 bool isFlipped() const { return fIsFlipped; }
400 SkScalar focal() const { return fFocalX; } 404 SkScalar focal() const { return fFocalX; }
401 405
402 private: 406 private:
403 bool onIsEqual(const GrFragmentProcessor& sBase) const override { 407 bool onIsEqual(const GrFragmentProcessor& sBase) const override {
404 const FocalOutside2PtConicalEffect& s = sBase.cast<FocalOutside2PtConica lEffect>(); 408 const FocalOutside2PtConicalEffect& s = sBase.cast<FocalOutside2PtConica lEffect>();
405 return (INHERITED::onIsEqual(sBase) && 409 return (INHERITED::onIsEqual(sBase) &&
406 this->fFocalX == s.fFocalX && 410 this->fFocalX == s.fFocalX &&
407 this->fIsFlipped == s.fIsFlipped); 411 this->fIsFlipped == s.fIsFlipped);
408 } 412 }
409 413
410 FocalOutside2PtConicalEffect(GrContext* ctx, 414 FocalOutside2PtConicalEffect(GrContext* ctx,
415 GrShaderDataManager* shaderDataManager,
411 const SkTwoPointConicalGradient& shader, 416 const SkTwoPointConicalGradient& shader,
412 const SkMatrix& matrix, 417 const SkMatrix& matrix,
413 SkShader::TileMode tm, 418 SkShader::TileMode tm,
414 SkScalar focalX) 419 SkScalar focalX)
415 : INHERITED(ctx, shader, matrix, tm), fFocalX(focalX), fIsFlipped(shader.isF lippedGrad()) { 420 : INHERITED(ctx, shaderDataManager, shader, matrix, tm)
421 , fFocalX(focalX)
422 , fIsFlipped(shader.isFlippedGrad()) {
416 this->initClassID<FocalOutside2PtConicalEffect>(); 423 this->initClassID<FocalOutside2PtConicalEffect>();
417 } 424 }
418 425
419 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; 426 GR_DECLARE_FRAGMENT_PROCESSOR_TEST;
420 427
421 SkScalar fFocalX; 428 SkScalar fFocalX;
422 bool fIsFlipped; 429 bool fIsFlipped;
423 430
424 typedef GrGradientEffect INHERITED; 431 typedef GrGradientEffect INHERITED;
425 }; 432 };
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
594 } 601 }
595 602
596 ////////////////////////////////////////////////////////////////////////////// 603 //////////////////////////////////////////////////////////////////////////////
597 604
598 class GLFocalInside2PtConicalEffect; 605 class GLFocalInside2PtConicalEffect;
599 606
600 class FocalInside2PtConicalEffect : public GrGradientEffect { 607 class FocalInside2PtConicalEffect : public GrGradientEffect {
601 public: 608 public:
602 609
603 static GrFragmentProcessor* Create(GrContext* ctx, 610 static GrFragmentProcessor* Create(GrContext* ctx,
611 GrShaderDataManager* shaderDataManager,
604 const SkTwoPointConicalGradient& shader, 612 const SkTwoPointConicalGradient& shader,
605 const SkMatrix& matrix, 613 const SkMatrix& matrix,
606 SkShader::TileMode tm, 614 SkShader::TileMode tm,
607 SkScalar focalX) { 615 SkScalar focalX) {
608 return SkNEW_ARGS(FocalInside2PtConicalEffect, (ctx, shader, matrix, tm, focalX)); 616 return SkNEW_ARGS(FocalInside2PtConicalEffect, (ctx, shaderDataManager, shader, matrix, tm,
617 focalX));
609 } 618 }
610 619
611 virtual ~FocalInside2PtConicalEffect() {} 620 virtual ~FocalInside2PtConicalEffect() {}
612 621
613 const char* name() const override { 622 const char* name() const override {
614 return "Two-Point Conical Gradient Focal Inside"; 623 return "Two-Point Conical Gradient Focal Inside";
615 } 624 }
616 625
617 void getGLProcessorKey(const GrGLSLCaps&, GrProcessorKeyBuilder*) const over ride; 626 void getGLProcessorKey(const GrGLSLCaps&, GrProcessorKeyBuilder*) const over ride;
618 627
619 GrGLFragmentProcessor* createGLInstance() const override; 628 GrGLFragmentProcessor* createGLInstance() const override;
620 629
621 SkScalar focal() const { return fFocalX; } 630 SkScalar focal() const { return fFocalX; }
622 631
623 typedef GLFocalInside2PtConicalEffect GLProcessor; 632 typedef GLFocalInside2PtConicalEffect GLProcessor;
624 633
625 private: 634 private:
626 bool onIsEqual(const GrFragmentProcessor& sBase) const override { 635 bool onIsEqual(const GrFragmentProcessor& sBase) const override {
627 const FocalInside2PtConicalEffect& s = sBase.cast<FocalInside2PtConicalE ffect>(); 636 const FocalInside2PtConicalEffect& s = sBase.cast<FocalInside2PtConicalE ffect>();
628 return (INHERITED::onIsEqual(sBase) && 637 return (INHERITED::onIsEqual(sBase) &&
629 this->fFocalX == s.fFocalX); 638 this->fFocalX == s.fFocalX);
630 } 639 }
631 640
632 FocalInside2PtConicalEffect(GrContext* ctx, 641 FocalInside2PtConicalEffect(GrContext* ctx,
642 GrShaderDataManager* shaderDataManager,
633 const SkTwoPointConicalGradient& shader, 643 const SkTwoPointConicalGradient& shader,
634 const SkMatrix& matrix, 644 const SkMatrix& matrix,
635 SkShader::TileMode tm, 645 SkShader::TileMode tm,
636 SkScalar focalX) 646 SkScalar focalX)
637 : INHERITED(ctx, shader, matrix, tm), fFocalX(focalX) { 647 : INHERITED(ctx, shaderDataManager, shader, matrix, tm), fFocalX(focalX) {
638 this->initClassID<FocalInside2PtConicalEffect>(); 648 this->initClassID<FocalInside2PtConicalEffect>();
639 } 649 }
640 650
641 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; 651 GR_DECLARE_FRAGMENT_PROCESSOR_TEST;
642 652
643 SkScalar fFocalX; 653 SkScalar fFocalX;
644 654
645 typedef GrGradientEffect INHERITED; 655 typedef GrGradientEffect INHERITED;
646 }; 656 };
647 657
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
841 if (A < 0.f) { 851 if (A < 0.f) {
842 return kInside_ConicalType; 852 return kInside_ConicalType;
843 } 853 }
844 return kOutside_ConicalType; 854 return kOutside_ConicalType;
845 } 855 }
846 856
847 class CircleInside2PtConicalEffect : public GrGradientEffect { 857 class CircleInside2PtConicalEffect : public GrGradientEffect {
848 public: 858 public:
849 859
850 static GrFragmentProcessor* Create(GrContext* ctx, 860 static GrFragmentProcessor* Create(GrContext* ctx,
861 GrShaderDataManager* shaderDataManager,
851 const SkTwoPointConicalGradient& shader, 862 const SkTwoPointConicalGradient& shader,
852 const SkMatrix& matrix, 863 const SkMatrix& matrix,
853 SkShader::TileMode tm, 864 SkShader::TileMode tm,
854 const CircleConicalInfo& info) { 865 const CircleConicalInfo& info) {
855 return SkNEW_ARGS(CircleInside2PtConicalEffect, (ctx, shader, matrix, tm , info)); 866 return SkNEW_ARGS(CircleInside2PtConicalEffect, (ctx, shaderDataManager, shader, matrix, tm,
867 info));
856 } 868 }
857 869
858 virtual ~CircleInside2PtConicalEffect() {} 870 virtual ~CircleInside2PtConicalEffect() {}
859 871
860 const char* name() const override { return "Two-Point Conical Gradient Insid e"; } 872 const char* name() const override { return "Two-Point Conical Gradient Insid e"; }
861 873
862 virtual void getGLProcessorKey(const GrGLSLCaps& caps, 874 virtual void getGLProcessorKey(const GrGLSLCaps& caps,
863 GrProcessorKeyBuilder* b) const override; 875 GrProcessorKeyBuilder* b) const override;
864 876
865 GrGLFragmentProcessor* createGLInstance() const override; 877 GrGLFragmentProcessor* createGLInstance() const override;
866 878
867 SkScalar centerX() const { return fInfo.fCenterEnd.fX; } 879 SkScalar centerX() const { return fInfo.fCenterEnd.fX; }
868 SkScalar centerY() const { return fInfo.fCenterEnd.fY; } 880 SkScalar centerY() const { return fInfo.fCenterEnd.fY; }
869 SkScalar A() const { return fInfo.fA; } 881 SkScalar A() const { return fInfo.fA; }
870 SkScalar B() const { return fInfo.fB; } 882 SkScalar B() const { return fInfo.fB; }
871 SkScalar C() const { return fInfo.fC; } 883 SkScalar C() const { return fInfo.fC; }
872 884
873 private: 885 private:
874 bool onIsEqual(const GrFragmentProcessor& sBase) const override { 886 bool onIsEqual(const GrFragmentProcessor& sBase) const override {
875 const CircleInside2PtConicalEffect& s = sBase.cast<CircleInside2PtConica lEffect>(); 887 const CircleInside2PtConicalEffect& s = sBase.cast<CircleInside2PtConica lEffect>();
876 return (INHERITED::onIsEqual(sBase) && 888 return (INHERITED::onIsEqual(sBase) &&
877 this->fInfo.fCenterEnd == s.fInfo.fCenterEnd && 889 this->fInfo.fCenterEnd == s.fInfo.fCenterEnd &&
878 this->fInfo.fA == s.fInfo.fA && 890 this->fInfo.fA == s.fInfo.fA &&
879 this->fInfo.fB == s.fInfo.fB && 891 this->fInfo.fB == s.fInfo.fB &&
880 this->fInfo.fC == s.fInfo.fC); 892 this->fInfo.fC == s.fInfo.fC);
881 } 893 }
882 894
883 CircleInside2PtConicalEffect(GrContext* ctx, 895 CircleInside2PtConicalEffect(GrContext* ctx,
896 GrShaderDataManager* shaderDataManager,
884 const SkTwoPointConicalGradient& shader, 897 const SkTwoPointConicalGradient& shader,
885 const SkMatrix& matrix, 898 const SkMatrix& matrix,
886 SkShader::TileMode tm, 899 SkShader::TileMode tm,
887 const CircleConicalInfo& info) 900 const CircleConicalInfo& info)
888 : INHERITED(ctx, shader, matrix, tm), fInfo(info) { 901 : INHERITED(ctx, shaderDataManager, shader, matrix, tm), fInfo(info) {
889 this->initClassID<CircleInside2PtConicalEffect>(); 902 this->initClassID<CircleInside2PtConicalEffect>();
890 } 903 }
891 904
892 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; 905 GR_DECLARE_FRAGMENT_PROCESSOR_TEST;
893 906
894 const CircleConicalInfo fInfo; 907 const CircleConicalInfo fInfo;
895 908
896 typedef GrGradientEffect INHERITED; 909 typedef GrGradientEffect INHERITED;
897 }; 910 };
898 911
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
1065 const GrGLSLCaps&, GrProcessorKeyBui lder* b) { 1078 const GrGLSLCaps&, GrProcessorKeyBui lder* b) {
1066 b->add32(GenBaseGradientKey(processor)); 1079 b->add32(GenBaseGradientKey(processor));
1067 } 1080 }
1068 1081
1069 ////////////////////////////////////////////////////////////////////////////// 1082 //////////////////////////////////////////////////////////////////////////////
1070 1083
1071 class CircleOutside2PtConicalEffect : public GrGradientEffect { 1084 class CircleOutside2PtConicalEffect : public GrGradientEffect {
1072 public: 1085 public:
1073 1086
1074 static GrFragmentProcessor* Create(GrContext* ctx, 1087 static GrFragmentProcessor* Create(GrContext* ctx,
1088 GrShaderDataManager* shaderDataManager,
1075 const SkTwoPointConicalGradient& shader, 1089 const SkTwoPointConicalGradient& shader,
1076 const SkMatrix& matrix, 1090 const SkMatrix& matrix,
1077 SkShader::TileMode tm, 1091 SkShader::TileMode tm,
1078 const CircleConicalInfo& info) { 1092 const CircleConicalInfo& info) {
1079 return SkNEW_ARGS(CircleOutside2PtConicalEffect, (ctx, shader, matrix, t m, info)); 1093 return SkNEW_ARGS(CircleOutside2PtConicalEffect, (ctx, shaderDataManager , shader, matrix,
1094 tm, info));
1080 } 1095 }
1081 1096
1082 virtual ~CircleOutside2PtConicalEffect() {} 1097 virtual ~CircleOutside2PtConicalEffect() {}
1083 1098
1084 const char* name() const override { return "Two-Point Conical Gradient Outsi de"; } 1099 const char* name() const override { return "Two-Point Conical Gradient Outsi de"; }
1085 1100
1086 void getGLProcessorKey(const GrGLSLCaps&, GrProcessorKeyBuilder*) const over ride; 1101 void getGLProcessorKey(const GrGLSLCaps&, GrProcessorKeyBuilder*) const over ride;
1087 1102
1088 GrGLFragmentProcessor* createGLInstance() const override; 1103 GrGLFragmentProcessor* createGLInstance() const override;
1089 1104
(...skipping 11 matching lines...) Expand all
1101 return (INHERITED::onIsEqual(sBase) && 1116 return (INHERITED::onIsEqual(sBase) &&
1102 this->fInfo.fCenterEnd == s.fInfo.fCenterEnd && 1117 this->fInfo.fCenterEnd == s.fInfo.fCenterEnd &&
1103 this->fInfo.fA == s.fInfo.fA && 1118 this->fInfo.fA == s.fInfo.fA &&
1104 this->fInfo.fB == s.fInfo.fB && 1119 this->fInfo.fB == s.fInfo.fB &&
1105 this->fInfo.fC == s.fInfo.fC && 1120 this->fInfo.fC == s.fInfo.fC &&
1106 this->fTLimit == s.fTLimit && 1121 this->fTLimit == s.fTLimit &&
1107 this->fIsFlipped == s.fIsFlipped); 1122 this->fIsFlipped == s.fIsFlipped);
1108 } 1123 }
1109 1124
1110 CircleOutside2PtConicalEffect(GrContext* ctx, 1125 CircleOutside2PtConicalEffect(GrContext* ctx,
1126 GrShaderDataManager* shaderDataManager,
1111 const SkTwoPointConicalGradient& shader, 1127 const SkTwoPointConicalGradient& shader,
1112 const SkMatrix& matrix, 1128 const SkMatrix& matrix,
1113 SkShader::TileMode tm, 1129 SkShader::TileMode tm,
1114 const CircleConicalInfo& info) 1130 const CircleConicalInfo& info)
1115 : INHERITED(ctx, shader, matrix, tm), fInfo(info) { 1131 : INHERITED(ctx, shaderDataManager, shader, matrix, tm), fInfo(info) {
1116 this->initClassID<CircleOutside2PtConicalEffect>(); 1132 this->initClassID<CircleOutside2PtConicalEffect>();
1117 if (shader.getStartRadius() != shader.getEndRadius()) { 1133 if (shader.getStartRadius() != shader.getEndRadius()) {
1118 fTLimit = shader.getStartRadius() / (shader.getStartRadius() - shade r.getEndRadius()); 1134 fTLimit = shader.getStartRadius() / (shader.getStartRadius() - shade r.getEndRadius());
1119 } else { 1135 } else {
1120 fTLimit = SK_ScalarMin; 1136 fTLimit = SK_ScalarMin;
1121 } 1137 }
1122 1138
1123 fIsFlipped = shader.isFlippedGrad(); 1139 fIsFlipped = shader.isFlippedGrad();
1124 } 1140 }
1125 1141
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
1329 void GLCircleOutside2PtConicalEffect::GenKey(const GrProcessor& processor, 1345 void GLCircleOutside2PtConicalEffect::GenKey(const GrProcessor& processor,
1330 const GrGLSLCaps&, GrProcessorKeyBu ilder* b) { 1346 const GrGLSLCaps&, GrProcessorKeyBu ilder* b) {
1331 uint32_t* key = b->add32n(2); 1347 uint32_t* key = b->add32n(2);
1332 key[0] = GenBaseGradientKey(processor); 1348 key[0] = GenBaseGradientKey(processor);
1333 key[1] = processor.cast<CircleOutside2PtConicalEffect>().isFlipped(); 1349 key[1] = processor.cast<CircleOutside2PtConicalEffect>().isFlipped();
1334 } 1350 }
1335 1351
1336 ////////////////////////////////////////////////////////////////////////////// 1352 //////////////////////////////////////////////////////////////////////////////
1337 1353
1338 GrFragmentProcessor* Gr2PtConicalGradientEffect::Create(GrContext* ctx, 1354 GrFragmentProcessor* Gr2PtConicalGradientEffect::Create(GrContext* ctx,
1355 GrShaderDataManager* sha derDataManager,
1339 const SkTwoPointConicalG radient& shader, 1356 const SkTwoPointConicalG radient& shader,
1340 SkShader::TileMode tm, 1357 SkShader::TileMode tm,
1341 const SkMatrix* localMat rix) { 1358 const SkMatrix* localMat rix) {
1342 SkMatrix matrix; 1359 SkMatrix matrix;
1343 if (!shader.getLocalMatrix().invert(&matrix)) { 1360 if (!shader.getLocalMatrix().invert(&matrix)) {
1344 return NULL; 1361 return NULL;
1345 } 1362 }
1346 if (localMatrix) { 1363 if (localMatrix) {
1347 SkMatrix inv; 1364 SkMatrix inv;
1348 if (!localMatrix->invert(&inv)) { 1365 if (!localMatrix->invert(&inv)) {
1349 return NULL; 1366 return NULL;
1350 } 1367 }
1351 matrix.postConcat(inv); 1368 matrix.postConcat(inv);
1352 } 1369 }
1353 1370
1354 if (shader.getStartRadius() < kErrorTol) { 1371 if (shader.getStartRadius() < kErrorTol) {
1355 SkScalar focalX; 1372 SkScalar focalX;
1356 ConicalType type = set_matrix_focal_conical(shader, &matrix, &focalX); 1373 ConicalType type = set_matrix_focal_conical(shader, &matrix, &focalX);
1357 if (type == kInside_ConicalType) { 1374 if (type == kInside_ConicalType) {
1358 return FocalInside2PtConicalEffect::Create(ctx, shader, matrix, tm, focalX); 1375 return FocalInside2PtConicalEffect::Create(ctx, shaderDataManager, s hader, matrix, tm,
1376 focalX);
1359 } else if(type == kEdge_ConicalType) { 1377 } else if(type == kEdge_ConicalType) {
1360 set_matrix_edge_conical(shader, &matrix); 1378 set_matrix_edge_conical(shader, &matrix);
1361 return Edge2PtConicalEffect::Create(ctx, shader, matrix, tm); 1379 return Edge2PtConicalEffect::Create(ctx, shaderDataManager, shader, matrix, tm);
1362 } else { 1380 } else {
1363 return FocalOutside2PtConicalEffect::Create(ctx, shader, matrix, tm, focalX); 1381 return FocalOutside2PtConicalEffect::Create(ctx, shaderDataManager, shader, matrix, tm,
1382 focalX);
1364 } 1383 }
1365 } 1384 }
1366 1385
1367 CircleConicalInfo info; 1386 CircleConicalInfo info;
1368 ConicalType type = set_matrix_circle_conical(shader, &matrix, &info); 1387 ConicalType type = set_matrix_circle_conical(shader, &matrix, &info);
1369 1388
1370 if (type == kInside_ConicalType) { 1389 if (type == kInside_ConicalType) {
1371 return CircleInside2PtConicalEffect::Create(ctx, shader, matrix, tm, inf o); 1390 return CircleInside2PtConicalEffect::Create(ctx, shaderDataManager, sha der, matrix, tm,
1391 info);
1372 } else if (type == kEdge_ConicalType) { 1392 } else if (type == kEdge_ConicalType) {
1373 set_matrix_edge_conical(shader, &matrix); 1393 set_matrix_edge_conical(shader, &matrix);
1374 return Edge2PtConicalEffect::Create(ctx, shader, matrix, tm); 1394 return Edge2PtConicalEffect::Create(ctx, shaderDataManager, shader, matr ix, tm);
1375 } else { 1395 } else {
1376 return CircleOutside2PtConicalEffect::Create(ctx, shader, matrix, tm, in fo); 1396 return CircleOutside2PtConicalEffect::Create(ctx, shaderDataManager, sha der, matrix, tm,
1397 info);
1377 } 1398 }
1378 } 1399 }
1379 1400
1380 #endif 1401 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698