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

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

Issue 1228683002: rename GrShaderDataManager -> GrProcessorDataManager (Closed) Base URL: https://skia.googlesource.com/skia.git@grfixuptests
Patch Set: rebase onto origin/master 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 GrProcessorDataManager* procDataManager,
63 const SkTwoPointConicalGradient& shader, 63 const SkTwoPointConicalGradient& shader,
64 const SkMatrix& matrix, 64 const SkMatrix& matrix,
65 SkShader::TileMode tm) { 65 SkShader::TileMode tm) {
66 return SkNEW_ARGS(Edge2PtConicalEffect, (ctx, shaderDataManager, shader, matrix, tm)); 66 return SkNEW_ARGS(Edge2PtConicalEffect, (ctx, procDataManager, shader, m atrix, tm));
67 } 67 }
68 68
69 virtual ~Edge2PtConicalEffect() {} 69 virtual ~Edge2PtConicalEffect() {}
70 70
71 const char* name() const override { 71 const char* name() const override {
72 return "Two-Point Conical Gradient Edge Touching"; 72 return "Two-Point Conical Gradient Edge Touching";
73 } 73 }
74 74
75 void getGLProcessorKey(const GrGLSLCaps&, GrProcessorKeyBuilder*) const over ride; 75 void getGLProcessorKey(const GrGLSLCaps&, GrProcessorKeyBuilder*) const over ride;
76 76
77 GrGLFragmentProcessor* createGLInstance() const override; 77 GrGLFragmentProcessor* createGLInstance() const override;
78 78
79 // 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.
80 SkScalar center() const { return fCenterX1; } 80 SkScalar center() const { return fCenterX1; }
81 SkScalar diffRadius() const { return fDiffRadius; } 81 SkScalar diffRadius() const { return fDiffRadius; }
82 SkScalar radius() const { return fRadius0; } 82 SkScalar radius() const { return fRadius0; }
83 83
84 private: 84 private:
85 bool onIsEqual(const GrFragmentProcessor& sBase) const override { 85 bool onIsEqual(const GrFragmentProcessor& sBase) const override {
86 const Edge2PtConicalEffect& s = sBase.cast<Edge2PtConicalEffect>(); 86 const Edge2PtConicalEffect& s = sBase.cast<Edge2PtConicalEffect>();
87 return (INHERITED::onIsEqual(sBase) && 87 return (INHERITED::onIsEqual(sBase) &&
88 this->fCenterX1 == s.fCenterX1 && 88 this->fCenterX1 == s.fCenterX1 &&
89 this->fRadius0 == s.fRadius0 && 89 this->fRadius0 == s.fRadius0 &&
90 this->fDiffRadius == s.fDiffRadius); 90 this->fDiffRadius == s.fDiffRadius);
91 } 91 }
92 92
93 Edge2PtConicalEffect(GrContext* ctx, 93 Edge2PtConicalEffect(GrContext* ctx,
94 GrShaderDataManager* shaderDataManager, 94 GrProcessorDataManager* procDataManager,
95 const SkTwoPointConicalGradient& shader, 95 const SkTwoPointConicalGradient& shader,
96 const SkMatrix& matrix, 96 const SkMatrix& matrix,
97 SkShader::TileMode tm) 97 SkShader::TileMode tm)
98 : INHERITED(ctx, shaderDataManager, shader, matrix, tm), 98 : INHERITED(ctx, procDataManager, shader, matrix, tm),
99 fCenterX1(shader.getCenterX1()), 99 fCenterX1(shader.getCenterX1()),
100 fRadius0(shader.getStartRadius()), 100 fRadius0(shader.getStartRadius()),
101 fDiffRadius(shader.getDiffRadius()){ 101 fDiffRadius(shader.getDiffRadius()){
102 this->initClassID<Edge2PtConicalEffect>(); 102 this->initClassID<Edge2PtConicalEffect>();
103 // 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
104 // 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
105 // 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
106 // 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
107 // need the sqrt value below 107 // need the sqrt value below
108 SkASSERT(SkScalarAbs(SkScalarAbs(fDiffRadius) - fCenterX1) < 108 SkASSERT(SkScalarAbs(SkScalarAbs(fDiffRadius) - fCenterX1) <
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 int colorCount = RandomGradientParams(d->fRandom, colors, &stops, &tm); 211 int colorCount = RandomGradientParams(d->fRandom, colors, &stops, &tm);
212 SkAutoTUnref<SkShader> shader(SkGradientShader::CreateTwoPointConical(center 1, radius1, 212 SkAutoTUnref<SkShader> shader(SkGradientShader::CreateTwoPointConical(center 1, radius1,
213 center 2, radius2, 213 center 2, radius2,
214 colors , stops, colorCount, 214 colors , stops, colorCount,
215 tm)); 215 tm));
216 SkPaint paint; 216 SkPaint paint;
217 GrFragmentProcessor* fp; 217 GrFragmentProcessor* fp;
218 GrColor paintColor; 218 GrColor paintColor;
219 SkAssertResult(shader->asFragmentProcessor(d->fContext, paint, 219 SkAssertResult(shader->asFragmentProcessor(d->fContext, paint,
220 GrTest::TestMatrix(d->fRandom), N ULL, 220 GrTest::TestMatrix(d->fRandom), N ULL,
221 &paintColor, d->fShaderDataManage r, &fp)); 221 &paintColor, d->fProcDataManager, &fp));
222 return fp; 222 return fp;
223 } 223 }
224 224
225 GLEdge2PtConicalEffect::GLEdge2PtConicalEffect(const GrProcessor&) 225 GLEdge2PtConicalEffect::GLEdge2PtConicalEffect(const GrProcessor&)
226 : fVSVaryingName(NULL) 226 : fVSVaryingName(NULL)
227 , fFSVaryingName(NULL) 227 , fFSVaryingName(NULL)
228 , fCachedRadius(-SK_ScalarMax) 228 , fCachedRadius(-SK_ScalarMax)
229 , fCachedDiffRadius(-SK_ScalarMax) {} 229 , fCachedDiffRadius(-SK_ScalarMax) {}
230 230
231 void GLEdge2PtConicalEffect::emitCode(GrGLFPBuilder* builder, 231 void GLEdge2PtConicalEffect::emitCode(GrGLFPBuilder* builder,
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 372
373 return conicalType; 373 return conicalType;
374 } 374 }
375 375
376 ////////////////////////////////////////////////////////////////////////////// 376 //////////////////////////////////////////////////////////////////////////////
377 377
378 class FocalOutside2PtConicalEffect : public GrGradientEffect { 378 class FocalOutside2PtConicalEffect : public GrGradientEffect {
379 public: 379 public:
380 380
381 static GrFragmentProcessor* Create(GrContext* ctx, 381 static GrFragmentProcessor* Create(GrContext* ctx,
382 GrShaderDataManager* shaderDataManager, 382 GrProcessorDataManager* procDataManager,
383 const SkTwoPointConicalGradient& shader, 383 const SkTwoPointConicalGradient& shader,
384 const SkMatrix& matrix, 384 const SkMatrix& matrix,
385 SkShader::TileMode tm, 385 SkShader::TileMode tm,
386 SkScalar focalX) { 386 SkScalar focalX) {
387 return SkNEW_ARGS(FocalOutside2PtConicalEffect, (ctx, shaderDataManager, shader, matrix, tm, 387 return SkNEW_ARGS(FocalOutside2PtConicalEffect, (ctx, procDataManager, s hader, matrix, tm,
388 focalX)); 388 focalX));
389 } 389 }
390 390
391 virtual ~FocalOutside2PtConicalEffect() { } 391 virtual ~FocalOutside2PtConicalEffect() { }
392 392
393 const char* name() const override { 393 const char* name() const override {
394 return "Two-Point Conical Gradient Focal Outside"; 394 return "Two-Point Conical Gradient Focal Outside";
395 } 395 }
396 396
397 void getGLProcessorKey(const GrGLSLCaps&, GrProcessorKeyBuilder*) const over ride; 397 void getGLProcessorKey(const GrGLSLCaps&, GrProcessorKeyBuilder*) const over ride;
398 398
399 GrGLFragmentProcessor* createGLInstance() const override; 399 GrGLFragmentProcessor* createGLInstance() const override;
400 400
401 bool isFlipped() const { return fIsFlipped; } 401 bool isFlipped() const { return fIsFlipped; }
402 SkScalar focal() const { return fFocalX; } 402 SkScalar focal() const { return fFocalX; }
403 403
404 private: 404 private:
405 bool onIsEqual(const GrFragmentProcessor& sBase) const override { 405 bool onIsEqual(const GrFragmentProcessor& sBase) const override {
406 const FocalOutside2PtConicalEffect& s = sBase.cast<FocalOutside2PtConica lEffect>(); 406 const FocalOutside2PtConicalEffect& s = sBase.cast<FocalOutside2PtConica lEffect>();
407 return (INHERITED::onIsEqual(sBase) && 407 return (INHERITED::onIsEqual(sBase) &&
408 this->fFocalX == s.fFocalX && 408 this->fFocalX == s.fFocalX &&
409 this->fIsFlipped == s.fIsFlipped); 409 this->fIsFlipped == s.fIsFlipped);
410 } 410 }
411 411
412 FocalOutside2PtConicalEffect(GrContext* ctx, 412 FocalOutside2PtConicalEffect(GrContext* ctx,
413 GrShaderDataManager* shaderDataManager, 413 GrProcessorDataManager* procDataManager,
414 const SkTwoPointConicalGradient& shader, 414 const SkTwoPointConicalGradient& shader,
415 const SkMatrix& matrix, 415 const SkMatrix& matrix,
416 SkShader::TileMode tm, 416 SkShader::TileMode tm,
417 SkScalar focalX) 417 SkScalar focalX)
418 : INHERITED(ctx, shaderDataManager, shader, matrix, tm) 418 : INHERITED(ctx, procDataManager, shader, matrix, tm)
419 , fFocalX(focalX) 419 , fFocalX(focalX)
420 , fIsFlipped(shader.isFlippedGrad()) { 420 , fIsFlipped(shader.isFlippedGrad()) {
421 this->initClassID<FocalOutside2PtConicalEffect>(); 421 this->initClassID<FocalOutside2PtConicalEffect>();
422 } 422 }
423 423
424 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; 424 GR_DECLARE_FRAGMENT_PROCESSOR_TEST;
425 425
426 SkScalar fFocalX; 426 SkScalar fFocalX;
427 bool fIsFlipped; 427 bool fIsFlipped;
428 428
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
500 SkAutoTUnref<SkShader> shader(SkGradientShader::CreateTwoPointConical(center 1, radius1, 500 SkAutoTUnref<SkShader> shader(SkGradientShader::CreateTwoPointConical(center 1, radius1,
501 center 2, radius2, 501 center 2, radius2,
502 colors , stops, colorCount, 502 colors , stops, colorCount,
503 tm)); 503 tm));
504 SkPaint paint; 504 SkPaint paint;
505 GrFragmentProcessor* effect; 505 GrFragmentProcessor* effect;
506 GrColor paintColor; 506 GrColor paintColor;
507 GrPaint grPaint; 507 GrPaint grPaint;
508 SkAssertResult(shader->asFragmentProcessor(d->fContext, paint, 508 SkAssertResult(shader->asFragmentProcessor(d->fContext, paint,
509 GrTest::TestMatrix(d->fRandom), N ULL, 509 GrTest::TestMatrix(d->fRandom), N ULL,
510 &paintColor, d->fShaderDataManage r, 510 &paintColor, d->fProcDataManager,
511 &effect)); 511 &effect));
512 return effect; 512 return effect;
513 } 513 }
514 514
515 GLFocalOutside2PtConicalEffect::GLFocalOutside2PtConicalEffect(const GrProcessor & processor) 515 GLFocalOutside2PtConicalEffect::GLFocalOutside2PtConicalEffect(const GrProcessor & processor)
516 : fVSVaryingName(NULL) 516 : fVSVaryingName(NULL)
517 , fFSVaryingName(NULL) 517 , fFSVaryingName(NULL)
518 , fCachedFocal(SK_ScalarMax) { 518 , fCachedFocal(SK_ScalarMax) {
519 const FocalOutside2PtConicalEffect& data = processor.cast<FocalOutside2PtCon icalEffect>(); 519 const FocalOutside2PtConicalEffect& data = processor.cast<FocalOutside2PtCon icalEffect>();
520 fIsFlipped = data.isFlipped(); 520 fIsFlipped = data.isFlipped();
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
597 } 597 }
598 598
599 ////////////////////////////////////////////////////////////////////////////// 599 //////////////////////////////////////////////////////////////////////////////
600 600
601 class GLFocalInside2PtConicalEffect; 601 class GLFocalInside2PtConicalEffect;
602 602
603 class FocalInside2PtConicalEffect : public GrGradientEffect { 603 class FocalInside2PtConicalEffect : public GrGradientEffect {
604 public: 604 public:
605 605
606 static GrFragmentProcessor* Create(GrContext* ctx, 606 static GrFragmentProcessor* Create(GrContext* ctx,
607 GrShaderDataManager* shaderDataManager, 607 GrProcessorDataManager* procDataManager,
608 const SkTwoPointConicalGradient& shader, 608 const SkTwoPointConicalGradient& shader,
609 const SkMatrix& matrix, 609 const SkMatrix& matrix,
610 SkShader::TileMode tm, 610 SkShader::TileMode tm,
611 SkScalar focalX) { 611 SkScalar focalX) {
612 return SkNEW_ARGS(FocalInside2PtConicalEffect, (ctx, shaderDataManager, shader, matrix, tm, 612 return SkNEW_ARGS(FocalInside2PtConicalEffect, (ctx, procDataManager, sh ader, matrix, tm,
613 focalX)); 613 focalX));
614 } 614 }
615 615
616 virtual ~FocalInside2PtConicalEffect() {} 616 virtual ~FocalInside2PtConicalEffect() {}
617 617
618 const char* name() const override { 618 const char* name() const override {
619 return "Two-Point Conical Gradient Focal Inside"; 619 return "Two-Point Conical Gradient Focal Inside";
620 } 620 }
621 621
622 void getGLProcessorKey(const GrGLSLCaps&, GrProcessorKeyBuilder*) const over ride; 622 void getGLProcessorKey(const GrGLSLCaps&, GrProcessorKeyBuilder*) const over ride;
623 623
624 GrGLFragmentProcessor* createGLInstance() const override; 624 GrGLFragmentProcessor* createGLInstance() const override;
625 625
626 SkScalar focal() const { return fFocalX; } 626 SkScalar focal() const { return fFocalX; }
627 627
628 typedef GLFocalInside2PtConicalEffect GLProcessor; 628 typedef GLFocalInside2PtConicalEffect GLProcessor;
629 629
630 private: 630 private:
631 bool onIsEqual(const GrFragmentProcessor& sBase) const override { 631 bool onIsEqual(const GrFragmentProcessor& sBase) const override {
632 const FocalInside2PtConicalEffect& s = sBase.cast<FocalInside2PtConicalE ffect>(); 632 const FocalInside2PtConicalEffect& s = sBase.cast<FocalInside2PtConicalE ffect>();
633 return (INHERITED::onIsEqual(sBase) && 633 return (INHERITED::onIsEqual(sBase) &&
634 this->fFocalX == s.fFocalX); 634 this->fFocalX == s.fFocalX);
635 } 635 }
636 636
637 FocalInside2PtConicalEffect(GrContext* ctx, 637 FocalInside2PtConicalEffect(GrContext* ctx,
638 GrShaderDataManager* shaderDataManager, 638 GrProcessorDataManager* procDataManager,
639 const SkTwoPointConicalGradient& shader, 639 const SkTwoPointConicalGradient& shader,
640 const SkMatrix& matrix, 640 const SkMatrix& matrix,
641 SkShader::TileMode tm, 641 SkShader::TileMode tm,
642 SkScalar focalX) 642 SkScalar focalX)
643 : INHERITED(ctx, shaderDataManager, shader, matrix, tm), fFocalX(focalX) { 643 : INHERITED(ctx, procDataManager, shader, matrix, tm), fFocalX(focalX) {
644 this->initClassID<FocalInside2PtConicalEffect>(); 644 this->initClassID<FocalInside2PtConicalEffect>();
645 } 645 }
646 646
647 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; 647 GR_DECLARE_FRAGMENT_PROCESSOR_TEST;
648 648
649 SkScalar fFocalX; 649 SkScalar fFocalX;
650 650
651 typedef GrGradientEffect INHERITED; 651 typedef GrGradientEffect INHERITED;
652 }; 652 };
653 653
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
721 int colorCount = RandomGradientParams(d->fRandom, colors, &stops, &tm); 721 int colorCount = RandomGradientParams(d->fRandom, colors, &stops, &tm);
722 SkAutoTUnref<SkShader> shader(SkGradientShader::CreateTwoPointConical(center 1, radius1, 722 SkAutoTUnref<SkShader> shader(SkGradientShader::CreateTwoPointConical(center 1, radius1,
723 center 2, radius2, 723 center 2, radius2,
724 colors , stops, colorCount, 724 colors , stops, colorCount,
725 tm)); 725 tm));
726 SkPaint paint; 726 SkPaint paint;
727 GrColor paintColor; 727 GrColor paintColor;
728 GrFragmentProcessor* fp; 728 GrFragmentProcessor* fp;
729 SkAssertResult(shader->asFragmentProcessor(d->fContext, paint, 729 SkAssertResult(shader->asFragmentProcessor(d->fContext, paint,
730 GrTest::TestMatrix(d->fRandom), N ULL, 730 GrTest::TestMatrix(d->fRandom), N ULL,
731 &paintColor, d->fShaderDataManage r, &fp)); 731 &paintColor, d->fProcDataManager, &fp));
732 return fp; 732 return fp;
733 } 733 }
734 734
735 GLFocalInside2PtConicalEffect::GLFocalInside2PtConicalEffect(const GrProcessor&) 735 GLFocalInside2PtConicalEffect::GLFocalInside2PtConicalEffect(const GrProcessor&)
736 : fVSVaryingName(NULL) 736 : fVSVaryingName(NULL)
737 , fFSVaryingName(NULL) 737 , fFSVaryingName(NULL)
738 , fCachedFocal(SK_ScalarMax) {} 738 , fCachedFocal(SK_ScalarMax) {}
739 739
740 void GLFocalInside2PtConicalEffect::emitCode(GrGLFPBuilder* builder, 740 void GLFocalInside2PtConicalEffect::emitCode(GrGLFPBuilder* builder,
741 const GrFragmentProcessor& fp, 741 const GrFragmentProcessor& fp,
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
844 if (A < 0.f) { 844 if (A < 0.f) {
845 return kInside_ConicalType; 845 return kInside_ConicalType;
846 } 846 }
847 return kOutside_ConicalType; 847 return kOutside_ConicalType;
848 } 848 }
849 849
850 class CircleInside2PtConicalEffect : public GrGradientEffect { 850 class CircleInside2PtConicalEffect : public GrGradientEffect {
851 public: 851 public:
852 852
853 static GrFragmentProcessor* Create(GrContext* ctx, 853 static GrFragmentProcessor* Create(GrContext* ctx,
854 GrShaderDataManager* shaderDataManager, 854 GrProcessorDataManager* procDataManager,
855 const SkTwoPointConicalGradient& shader, 855 const SkTwoPointConicalGradient& shader,
856 const SkMatrix& matrix, 856 const SkMatrix& matrix,
857 SkShader::TileMode tm, 857 SkShader::TileMode tm,
858 const CircleConicalInfo& info) { 858 const CircleConicalInfo& info) {
859 return SkNEW_ARGS(CircleInside2PtConicalEffect, (ctx, shaderDataManager, shader, matrix, tm, 859 return SkNEW_ARGS(CircleInside2PtConicalEffect, (ctx, procDataManager, s hader, matrix, tm,
860 info)); 860 info));
861 } 861 }
862 862
863 virtual ~CircleInside2PtConicalEffect() {} 863 virtual ~CircleInside2PtConicalEffect() {}
864 864
865 const char* name() const override { return "Two-Point Conical Gradient Insid e"; } 865 const char* name() const override { return "Two-Point Conical Gradient Insid e"; }
866 866
867 virtual void getGLProcessorKey(const GrGLSLCaps& caps, 867 virtual void getGLProcessorKey(const GrGLSLCaps& caps,
868 GrProcessorKeyBuilder* b) const override; 868 GrProcessorKeyBuilder* b) const override;
869 869
870 GrGLFragmentProcessor* createGLInstance() const override; 870 GrGLFragmentProcessor* createGLInstance() const override;
871 871
872 SkScalar centerX() const { return fInfo.fCenterEnd.fX; } 872 SkScalar centerX() const { return fInfo.fCenterEnd.fX; }
873 SkScalar centerY() const { return fInfo.fCenterEnd.fY; } 873 SkScalar centerY() const { return fInfo.fCenterEnd.fY; }
874 SkScalar A() const { return fInfo.fA; } 874 SkScalar A() const { return fInfo.fA; }
875 SkScalar B() const { return fInfo.fB; } 875 SkScalar B() const { return fInfo.fB; }
876 SkScalar C() const { return fInfo.fC; } 876 SkScalar C() const { return fInfo.fC; }
877 877
878 private: 878 private:
879 bool onIsEqual(const GrFragmentProcessor& sBase) const override { 879 bool onIsEqual(const GrFragmentProcessor& sBase) const override {
880 const CircleInside2PtConicalEffect& s = sBase.cast<CircleInside2PtConica lEffect>(); 880 const CircleInside2PtConicalEffect& s = sBase.cast<CircleInside2PtConica lEffect>();
881 return (INHERITED::onIsEqual(sBase) && 881 return (INHERITED::onIsEqual(sBase) &&
882 this->fInfo.fCenterEnd == s.fInfo.fCenterEnd && 882 this->fInfo.fCenterEnd == s.fInfo.fCenterEnd &&
883 this->fInfo.fA == s.fInfo.fA && 883 this->fInfo.fA == s.fInfo.fA &&
884 this->fInfo.fB == s.fInfo.fB && 884 this->fInfo.fB == s.fInfo.fB &&
885 this->fInfo.fC == s.fInfo.fC); 885 this->fInfo.fC == s.fInfo.fC);
886 } 886 }
887 887
888 CircleInside2PtConicalEffect(GrContext* ctx, 888 CircleInside2PtConicalEffect(GrContext* ctx,
889 GrShaderDataManager* shaderDataManager, 889 GrProcessorDataManager* procDataManager,
890 const SkTwoPointConicalGradient& shader, 890 const SkTwoPointConicalGradient& shader,
891 const SkMatrix& matrix, 891 const SkMatrix& matrix,
892 SkShader::TileMode tm, 892 SkShader::TileMode tm,
893 const CircleConicalInfo& info) 893 const CircleConicalInfo& info)
894 : INHERITED(ctx, shaderDataManager, shader, matrix, tm), fInfo(info) { 894 : INHERITED(ctx, procDataManager, shader, matrix, tm), fInfo(info) {
895 this->initClassID<CircleInside2PtConicalEffect>(); 895 this->initClassID<CircleInside2PtConicalEffect>();
896 } 896 }
897 897
898 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; 898 GR_DECLARE_FRAGMENT_PROCESSOR_TEST;
899 899
900 const CircleConicalInfo fInfo; 900 const CircleConicalInfo fInfo;
901 901
902 typedef GrGradientEffect INHERITED; 902 typedef GrGradientEffect INHERITED;
903 }; 903 };
904 904
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
977 int colorCount = RandomGradientParams(d->fRandom, colors, &stops, &tm); 977 int colorCount = RandomGradientParams(d->fRandom, colors, &stops, &tm);
978 SkAutoTUnref<SkShader> shader(SkGradientShader::CreateTwoPointConical(center 1, radius1, 978 SkAutoTUnref<SkShader> shader(SkGradientShader::CreateTwoPointConical(center 1, radius1,
979 center 2, radius2, 979 center 2, radius2,
980 colors , stops, colorCount, 980 colors , stops, colorCount,
981 tm)); 981 tm));
982 SkPaint paint; 982 SkPaint paint;
983 GrColor paintColor; 983 GrColor paintColor;
984 GrFragmentProcessor* fp; 984 GrFragmentProcessor* fp;
985 SkAssertResult(shader->asFragmentProcessor(d->fContext, paint, 985 SkAssertResult(shader->asFragmentProcessor(d->fContext, paint,
986 GrTest::TestMatrix(d->fRandom), N ULL, 986 GrTest::TestMatrix(d->fRandom), N ULL,
987 &paintColor, d->fShaderDataManage r, &fp)); 987 &paintColor, d->fProcDataManager, &fp));
988 return fp; 988 return fp;
989 } 989 }
990 990
991 GLCircleInside2PtConicalEffect::GLCircleInside2PtConicalEffect(const GrProcessor & processor) 991 GLCircleInside2PtConicalEffect::GLCircleInside2PtConicalEffect(const GrProcessor & processor)
992 : fVSVaryingName(NULL) 992 : fVSVaryingName(NULL)
993 , fFSVaryingName(NULL) 993 , fFSVaryingName(NULL)
994 , fCachedCenterX(SK_ScalarMax) 994 , fCachedCenterX(SK_ScalarMax)
995 , fCachedCenterY(SK_ScalarMax) 995 , fCachedCenterY(SK_ScalarMax)
996 , fCachedA(SK_ScalarMax) 996 , fCachedA(SK_ScalarMax)
997 , fCachedB(SK_ScalarMax) 997 , fCachedB(SK_ScalarMax)
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
1069 const GrGLSLCaps&, GrProcessorKeyBui lder* b) { 1069 const GrGLSLCaps&, GrProcessorKeyBui lder* b) {
1070 b->add32(GenBaseGradientKey(processor)); 1070 b->add32(GenBaseGradientKey(processor));
1071 } 1071 }
1072 1072
1073 ////////////////////////////////////////////////////////////////////////////// 1073 //////////////////////////////////////////////////////////////////////////////
1074 1074
1075 class CircleOutside2PtConicalEffect : public GrGradientEffect { 1075 class CircleOutside2PtConicalEffect : public GrGradientEffect {
1076 public: 1076 public:
1077 1077
1078 static GrFragmentProcessor* Create(GrContext* ctx, 1078 static GrFragmentProcessor* Create(GrContext* ctx,
1079 GrShaderDataManager* shaderDataManager, 1079 GrProcessorDataManager* procDataManager,
1080 const SkTwoPointConicalGradient& shader, 1080 const SkTwoPointConicalGradient& shader,
1081 const SkMatrix& matrix, 1081 const SkMatrix& matrix,
1082 SkShader::TileMode tm, 1082 SkShader::TileMode tm,
1083 const CircleConicalInfo& info) { 1083 const CircleConicalInfo& info) {
1084 return SkNEW_ARGS(CircleOutside2PtConicalEffect, (ctx, shaderDataManager , shader, matrix, 1084 return SkNEW_ARGS(CircleOutside2PtConicalEffect, (ctx, procDataManager, shader, matrix,
1085 tm, info)); 1085 tm, info));
1086 } 1086 }
1087 1087
1088 virtual ~CircleOutside2PtConicalEffect() {} 1088 virtual ~CircleOutside2PtConicalEffect() {}
1089 1089
1090 const char* name() const override { return "Two-Point Conical Gradient Outsi de"; } 1090 const char* name() const override { return "Two-Point Conical Gradient Outsi de"; }
1091 1091
1092 void getGLProcessorKey(const GrGLSLCaps&, GrProcessorKeyBuilder*) const over ride; 1092 void getGLProcessorKey(const GrGLSLCaps&, GrProcessorKeyBuilder*) const over ride;
1093 1093
1094 GrGLFragmentProcessor* createGLInstance() const override; 1094 GrGLFragmentProcessor* createGLInstance() const override;
(...skipping 12 matching lines...) Expand all
1107 return (INHERITED::onIsEqual(sBase) && 1107 return (INHERITED::onIsEqual(sBase) &&
1108 this->fInfo.fCenterEnd == s.fInfo.fCenterEnd && 1108 this->fInfo.fCenterEnd == s.fInfo.fCenterEnd &&
1109 this->fInfo.fA == s.fInfo.fA && 1109 this->fInfo.fA == s.fInfo.fA &&
1110 this->fInfo.fB == s.fInfo.fB && 1110 this->fInfo.fB == s.fInfo.fB &&
1111 this->fInfo.fC == s.fInfo.fC && 1111 this->fInfo.fC == s.fInfo.fC &&
1112 this->fTLimit == s.fTLimit && 1112 this->fTLimit == s.fTLimit &&
1113 this->fIsFlipped == s.fIsFlipped); 1113 this->fIsFlipped == s.fIsFlipped);
1114 } 1114 }
1115 1115
1116 CircleOutside2PtConicalEffect(GrContext* ctx, 1116 CircleOutside2PtConicalEffect(GrContext* ctx,
1117 GrShaderDataManager* shaderDataManager, 1117 GrProcessorDataManager* procDataManager,
1118 const SkTwoPointConicalGradient& shader, 1118 const SkTwoPointConicalGradient& shader,
1119 const SkMatrix& matrix, 1119 const SkMatrix& matrix,
1120 SkShader::TileMode tm, 1120 SkShader::TileMode tm,
1121 const CircleConicalInfo& info) 1121 const CircleConicalInfo& info)
1122 : INHERITED(ctx, shaderDataManager, shader, matrix, tm), fInfo(info) { 1122 : INHERITED(ctx, procDataManager, shader, matrix, tm), fInfo(info) {
1123 this->initClassID<CircleOutside2PtConicalEffect>(); 1123 this->initClassID<CircleOutside2PtConicalEffect>();
1124 if (shader.getStartRadius() != shader.getEndRadius()) { 1124 if (shader.getStartRadius() != shader.getEndRadius()) {
1125 fTLimit = shader.getStartRadius() / (shader.getStartRadius() - shade r.getEndRadius()); 1125 fTLimit = shader.getStartRadius() / (shader.getStartRadius() - shade r.getEndRadius());
1126 } else { 1126 } else {
1127 fTLimit = SK_ScalarMin; 1127 fTLimit = SK_ScalarMin;
1128 } 1128 }
1129 1129
1130 fIsFlipped = shader.isFlippedGrad(); 1130 fIsFlipped = shader.isFlippedGrad();
1131 } 1131 }
1132 1132
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
1217 int colorCount = RandomGradientParams(d->fRandom, colors, &stops, &tm); 1217 int colorCount = RandomGradientParams(d->fRandom, colors, &stops, &tm);
1218 SkAutoTUnref<SkShader> shader(SkGradientShader::CreateTwoPointConical(center 1, radius1, 1218 SkAutoTUnref<SkShader> shader(SkGradientShader::CreateTwoPointConical(center 1, radius1,
1219 center 2, radius2, 1219 center 2, radius2,
1220 colors , stops, colorCount, 1220 colors , stops, colorCount,
1221 tm)); 1221 tm));
1222 SkPaint paint; 1222 SkPaint paint;
1223 GrColor paintColor; 1223 GrColor paintColor;
1224 GrFragmentProcessor* fp; 1224 GrFragmentProcessor* fp;
1225 SkAssertResult(shader->asFragmentProcessor(d->fContext, paint, 1225 SkAssertResult(shader->asFragmentProcessor(d->fContext, paint,
1226 GrTest::TestMatrix(d->fRandom), N ULL, 1226 GrTest::TestMatrix(d->fRandom), N ULL,
1227 &paintColor, d->fShaderDataManage r, &fp)); 1227 &paintColor, d->fProcDataManager, &fp));
1228 return fp; 1228 return fp;
1229 } 1229 }
1230 1230
1231 GLCircleOutside2PtConicalEffect::GLCircleOutside2PtConicalEffect(const GrProcess or& processor) 1231 GLCircleOutside2PtConicalEffect::GLCircleOutside2PtConicalEffect(const GrProcess or& processor)
1232 : fVSVaryingName(NULL) 1232 : fVSVaryingName(NULL)
1233 , fFSVaryingName(NULL) 1233 , fFSVaryingName(NULL)
1234 , fCachedCenterX(SK_ScalarMax) 1234 , fCachedCenterX(SK_ScalarMax)
1235 , fCachedCenterY(SK_ScalarMax) 1235 , fCachedCenterY(SK_ScalarMax)
1236 , fCachedA(SK_ScalarMax) 1236 , fCachedA(SK_ScalarMax)
1237 , fCachedB(SK_ScalarMax) 1237 , fCachedB(SK_ScalarMax)
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
1332 void GLCircleOutside2PtConicalEffect::GenKey(const GrProcessor& processor, 1332 void GLCircleOutside2PtConicalEffect::GenKey(const GrProcessor& processor,
1333 const GrGLSLCaps&, GrProcessorKeyBu ilder* b) { 1333 const GrGLSLCaps&, GrProcessorKeyBu ilder* b) {
1334 uint32_t* key = b->add32n(2); 1334 uint32_t* key = b->add32n(2);
1335 key[0] = GenBaseGradientKey(processor); 1335 key[0] = GenBaseGradientKey(processor);
1336 key[1] = processor.cast<CircleOutside2PtConicalEffect>().isFlipped(); 1336 key[1] = processor.cast<CircleOutside2PtConicalEffect>().isFlipped();
1337 } 1337 }
1338 1338
1339 ////////////////////////////////////////////////////////////////////////////// 1339 //////////////////////////////////////////////////////////////////////////////
1340 1340
1341 GrFragmentProcessor* Gr2PtConicalGradientEffect::Create(GrContext* ctx, 1341 GrFragmentProcessor* Gr2PtConicalGradientEffect::Create(GrContext* ctx,
1342 GrShaderDataManager* sha derDataManager, 1342 GrProcessorDataManager* procDataManager,
1343 const SkTwoPointConicalG radient& shader, 1343 const SkTwoPointConicalG radient& shader,
1344 SkShader::TileMode tm, 1344 SkShader::TileMode tm,
1345 const SkMatrix* localMat rix) { 1345 const SkMatrix* localMat rix) {
1346 SkMatrix matrix; 1346 SkMatrix matrix;
1347 if (!shader.getLocalMatrix().invert(&matrix)) { 1347 if (!shader.getLocalMatrix().invert(&matrix)) {
1348 return NULL; 1348 return NULL;
1349 } 1349 }
1350 if (localMatrix) { 1350 if (localMatrix) {
1351 SkMatrix inv; 1351 SkMatrix inv;
1352 if (!localMatrix->invert(&inv)) { 1352 if (!localMatrix->invert(&inv)) {
1353 return NULL; 1353 return NULL;
1354 } 1354 }
1355 matrix.postConcat(inv); 1355 matrix.postConcat(inv);
1356 } 1356 }
1357 1357
1358 if (shader.getStartRadius() < kErrorTol) { 1358 if (shader.getStartRadius() < kErrorTol) {
1359 SkScalar focalX; 1359 SkScalar focalX;
1360 ConicalType type = set_matrix_focal_conical(shader, &matrix, &focalX); 1360 ConicalType type = set_matrix_focal_conical(shader, &matrix, &focalX);
1361 if (type == kInside_ConicalType) { 1361 if (type == kInside_ConicalType) {
1362 return FocalInside2PtConicalEffect::Create(ctx, shaderDataManager, s hader, matrix, tm, 1362 return FocalInside2PtConicalEffect::Create(ctx, procDataManager, sha der, matrix, tm,
1363 focalX); 1363 focalX);
1364 } else if(type == kEdge_ConicalType) { 1364 } else if(type == kEdge_ConicalType) {
1365 set_matrix_edge_conical(shader, &matrix); 1365 set_matrix_edge_conical(shader, &matrix);
1366 return Edge2PtConicalEffect::Create(ctx, shaderDataManager, shader, matrix, tm); 1366 return Edge2PtConicalEffect::Create(ctx, procDataManager, shader, ma trix, tm);
1367 } else { 1367 } else {
1368 return FocalOutside2PtConicalEffect::Create(ctx, shaderDataManager, shader, matrix, tm, 1368 return FocalOutside2PtConicalEffect::Create(ctx, procDataManager, sh ader, matrix, tm,
1369 focalX); 1369 focalX);
1370 } 1370 }
1371 } 1371 }
1372 1372
1373 CircleConicalInfo info; 1373 CircleConicalInfo info;
1374 ConicalType type = set_matrix_circle_conical(shader, &matrix, &info); 1374 ConicalType type = set_matrix_circle_conical(shader, &matrix, &info);
1375 1375
1376 if (type == kInside_ConicalType) { 1376 if (type == kInside_ConicalType) {
1377 return CircleInside2PtConicalEffect::Create(ctx, shaderDataManager, sha der, matrix, tm, 1377 return CircleInside2PtConicalEffect::Create(ctx, procDataManager, shade r, matrix, tm,
1378 info); 1378 info);
1379 } else if (type == kEdge_ConicalType) { 1379 } else if (type == kEdge_ConicalType) {
1380 set_matrix_edge_conical(shader, &matrix); 1380 set_matrix_edge_conical(shader, &matrix);
1381 return Edge2PtConicalEffect::Create(ctx, shaderDataManager, shader, matr ix, tm); 1381 return Edge2PtConicalEffect::Create(ctx, procDataManager, shader, matrix , tm);
1382 } else { 1382 } else {
1383 return CircleOutside2PtConicalEffect::Create(ctx, shaderDataManager, sha der, matrix, tm, 1383 return CircleOutside2PtConicalEffect::Create(ctx, procDataManager, shade r, matrix, tm,
1384 info); 1384 info);
1385 } 1385 }
1386 } 1386 }
1387 1387
1388 #endif 1388 #endif
OLDNEW
« no previous file with comments | « src/effects/gradients/SkTwoPointConicalGradient_gpu.h ('k') | src/gpu/GrProcessorDataManager.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698