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

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

Powered by Google App Engine
This is Rietveld 408576698