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

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

Issue 1225923010: Refugee from Dead Machine 4: MDB Monster Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Last update from dead machine Created 4 years, 7 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
« no previous file with comments | « src/effects/gradients/SkTwoPointConicalGradient_gpu.h ('k') | src/gpu/GrAtlas.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 invLMatrix->postConcat(rot); 56 invLMatrix->postConcat(rot);
57 } 57 }
58 } 58 }
59 59
60 class Edge2PtConicalEffect : public GrGradientEffect { 60 class Edge2PtConicalEffect : public GrGradientEffect {
61 public: 61 public:
62 62
63 static GrFragmentProcessor* Create(GrContext* ctx, 63 static GrFragmentProcessor* Create(GrContext* ctx,
64 const SkTwoPointConicalGradient& shader, 64 const SkTwoPointConicalGradient& shader,
65 const SkMatrix& matrix, 65 const SkMatrix& matrix,
66 SkShader::TileMode tm) { 66 SkShader::TileMode tm, GrRenderTarget* ds t) {
67 return new Edge2PtConicalEffect(ctx, shader, matrix, tm); 67 return new Edge2PtConicalEffect(ctx, shader, matrix, tm, dst);
68 } 68 }
69 69
70 virtual ~Edge2PtConicalEffect() {} 70 virtual ~Edge2PtConicalEffect() {}
71 71
72 const char* name() const override { 72 const char* name() const override {
73 return "Two-Point Conical Gradient Edge Touching"; 73 return "Two-Point Conical Gradient Edge Touching";
74 } 74 }
75 75
76 // The radial gradient parameters can collapse to a linear (instead of quadr atic) equation. 76 // The radial gradient parameters can collapse to a linear (instead of quadr atic) equation.
77 SkScalar center() const { return fCenterX1; } 77 SkScalar center() const { return fCenterX1; }
78 SkScalar diffRadius() const { return fDiffRadius; } 78 SkScalar diffRadius() const { return fDiffRadius; }
79 SkScalar radius() const { return fRadius0; } 79 SkScalar radius() const { return fRadius0; }
80 80
81 private: 81 private:
82 GrGLFragmentProcessor* onCreateGLInstance() const override; 82 GrGLFragmentProcessor* onCreateGLInstance() const override;
83 83
84 void onGetGLProcessorKey(const GrGLSLCaps&, GrProcessorKeyBuilder*) const ov erride; 84 void onGetGLProcessorKey(const GrGLSLCaps&, GrProcessorKeyBuilder*) const ov erride;
85 85
86 bool onIsEqual(const GrFragmentProcessor& sBase) const override { 86 bool onIsEqual(const GrFragmentProcessor& sBase) const override {
87 const Edge2PtConicalEffect& s = sBase.cast<Edge2PtConicalEffect>(); 87 const Edge2PtConicalEffect& s = sBase.cast<Edge2PtConicalEffect>();
88 return (INHERITED::onIsEqual(sBase) && 88 return (INHERITED::onIsEqual(sBase) &&
89 this->fCenterX1 == s.fCenterX1 && 89 this->fCenterX1 == s.fCenterX1 &&
90 this->fRadius0 == s.fRadius0 && 90 this->fRadius0 == s.fRadius0 &&
91 this->fDiffRadius == s.fDiffRadius); 91 this->fDiffRadius == s.fDiffRadius);
92 } 92 }
93 93
94 Edge2PtConicalEffect(GrContext* ctx, 94 Edge2PtConicalEffect(GrContext* ctx,
95 const SkTwoPointConicalGradient& shader, 95 const SkTwoPointConicalGradient& shader,
96 const SkMatrix& matrix, 96 const SkMatrix& matrix,
97 SkShader::TileMode tm) 97 SkShader::TileMode tm, GrRenderTarget* dst)
98 : INHERITED(ctx, shader, matrix, tm), 98 : INHERITED(ctx, shader, matrix, tm, dst),
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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 SkColor colors[kMaxRandomGradientColors]; 203 SkColor colors[kMaxRandomGradientColors];
204 SkScalar stopsArray[kMaxRandomGradientColors]; 204 SkScalar stopsArray[kMaxRandomGradientColors];
205 SkScalar* stops = stopsArray; 205 SkScalar* stops = stopsArray;
206 SkShader::TileMode tm; 206 SkShader::TileMode tm;
207 int colorCount = RandomGradientParams(d->fRandom, colors, &stops, &tm); 207 int colorCount = RandomGradientParams(d->fRandom, colors, &stops, &tm);
208 SkAutoTUnref<SkShader> shader(SkGradientShader::CreateTwoPointConical(center 1, radius1, 208 SkAutoTUnref<SkShader> shader(SkGradientShader::CreateTwoPointConical(center 1, radius1,
209 center 2, radius2, 209 center 2, radius2,
210 colors , stops, colorCount, 210 colors , stops, colorCount,
211 tm)); 211 tm));
212 const GrFragmentProcessor* fp = shader->asFragmentProcessor(d->fContext, 212 const GrFragmentProcessor* fp = shader->asFragmentProcessor(d->fContext,
213 GrTest::TestMatrix(d->fRandom), NULL, kNone_SkFilterQuality); 213 GrTest::TestMatrix(d->fRandom), NULL, kNone_SkFilterQuality, NULL);
214 GrAlwaysAssert(fp); 214 GrAlwaysAssert(fp);
215 return fp; 215 return fp;
216 } 216 }
217 217
218 GLEdge2PtConicalEffect::GLEdge2PtConicalEffect(const GrProcessor&) 218 GLEdge2PtConicalEffect::GLEdge2PtConicalEffect(const GrProcessor&)
219 : fVSVaryingName(nullptr) 219 : fVSVaryingName(nullptr)
220 , fFSVaryingName(nullptr) 220 , fFSVaryingName(nullptr)
221 , fCachedRadius(-SK_ScalarMax) 221 , fCachedRadius(-SK_ScalarMax)
222 , fCachedDiffRadius(-SK_ScalarMax) {} 222 , fCachedDiffRadius(-SK_ScalarMax) {}
223 223
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 364
365 ////////////////////////////////////////////////////////////////////////////// 365 //////////////////////////////////////////////////////////////////////////////
366 366
367 class FocalOutside2PtConicalEffect : public GrGradientEffect { 367 class FocalOutside2PtConicalEffect : public GrGradientEffect {
368 public: 368 public:
369 369
370 static GrFragmentProcessor* Create(GrContext* ctx, 370 static GrFragmentProcessor* Create(GrContext* ctx,
371 const SkTwoPointConicalGradient& shader, 371 const SkTwoPointConicalGradient& shader,
372 const SkMatrix& matrix, 372 const SkMatrix& matrix,
373 SkShader::TileMode tm, 373 SkShader::TileMode tm,
374 SkScalar focalX) { 374 SkScalar focalX, GrRenderTarget* dst) {
375 return new FocalOutside2PtConicalEffect(ctx, shader, matrix, tm, focalX) ; 375 return new FocalOutside2PtConicalEffect(ctx, shader, matrix, tm, focalX, dst);
376 } 376 }
377 377
378 virtual ~FocalOutside2PtConicalEffect() { } 378 virtual ~FocalOutside2PtConicalEffect() { }
379 379
380 const char* name() const override { 380 const char* name() const override {
381 return "Two-Point Conical Gradient Focal Outside"; 381 return "Two-Point Conical Gradient Focal Outside";
382 } 382 }
383 383
384 bool isFlipped() const { return fIsFlipped; } 384 bool isFlipped() const { return fIsFlipped; }
385 SkScalar focal() const { return fFocalX; } 385 SkScalar focal() const { return fFocalX; }
386 386
387 private: 387 private:
388 GrGLFragmentProcessor* onCreateGLInstance() const override; 388 GrGLFragmentProcessor* onCreateGLInstance() const override;
389 389
390 void onGetGLProcessorKey(const GrGLSLCaps&, GrProcessorKeyBuilder*) const ov erride; 390 void onGetGLProcessorKey(const GrGLSLCaps&, GrProcessorKeyBuilder*) const ov erride;
391 391
392 bool onIsEqual(const GrFragmentProcessor& sBase) const override { 392 bool onIsEqual(const GrFragmentProcessor& sBase) const override {
393 const FocalOutside2PtConicalEffect& s = sBase.cast<FocalOutside2PtConica lEffect>(); 393 const FocalOutside2PtConicalEffect& s = sBase.cast<FocalOutside2PtConica lEffect>();
394 return (INHERITED::onIsEqual(sBase) && 394 return (INHERITED::onIsEqual(sBase) &&
395 this->fFocalX == s.fFocalX && 395 this->fFocalX == s.fFocalX &&
396 this->fIsFlipped == s.fIsFlipped); 396 this->fIsFlipped == s.fIsFlipped);
397 } 397 }
398 398
399 FocalOutside2PtConicalEffect(GrContext* ctx, 399 FocalOutside2PtConicalEffect(GrContext* ctx,
400 const SkTwoPointConicalGradient& shader, 400 const SkTwoPointConicalGradient& shader,
401 const SkMatrix& matrix, 401 const SkMatrix& matrix,
402 SkShader::TileMode tm, 402 SkShader::TileMode tm,
403 SkScalar focalX) 403 SkScalar focalX, GrRenderTarget* dst)
404 : INHERITED(ctx, shader, matrix, tm) 404 : INHERITED(ctx, shader, matrix, tm, dst)
405 , fFocalX(focalX) 405 , fFocalX(focalX)
406 , fIsFlipped(shader.isFlippedGrad()) { 406 , fIsFlipped(shader.isFlippedGrad()) {
407 this->initClassID<FocalOutside2PtConicalEffect>(); 407 this->initClassID<FocalOutside2PtConicalEffect>();
408 } 408 }
409 409
410 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; 410 GR_DECLARE_FRAGMENT_PROCESSOR_TEST;
411 411
412 SkScalar fFocalX; 412 SkScalar fFocalX;
413 bool fIsFlipped; 413 bool fIsFlipped;
414 414
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
477 SkColor colors[kMaxRandomGradientColors]; 477 SkColor colors[kMaxRandomGradientColors];
478 SkScalar stopsArray[kMaxRandomGradientColors]; 478 SkScalar stopsArray[kMaxRandomGradientColors];
479 SkScalar* stops = stopsArray; 479 SkScalar* stops = stopsArray;
480 SkShader::TileMode tm; 480 SkShader::TileMode tm;
481 int colorCount = RandomGradientParams(d->fRandom, colors, &stops, &tm); 481 int colorCount = RandomGradientParams(d->fRandom, colors, &stops, &tm);
482 SkAutoTUnref<SkShader> shader(SkGradientShader::CreateTwoPointConical(center 1, radius1, 482 SkAutoTUnref<SkShader> shader(SkGradientShader::CreateTwoPointConical(center 1, radius1,
483 center 2, radius2, 483 center 2, radius2,
484 colors , stops, colorCount, 484 colors , stops, colorCount,
485 tm)); 485 tm));
486 const GrFragmentProcessor* fp = shader->asFragmentProcessor(d->fContext, 486 const GrFragmentProcessor* fp = shader->asFragmentProcessor(d->fContext,
487 GrTest::TestMatrix(d->fRandom), NULL, kNone_SkFilterQuality); 487 GrTest::TestMatrix(d->fRandom), NULL, kNone_SkFilterQuality, NULL);
488 GrAlwaysAssert(fp); 488 GrAlwaysAssert(fp);
489 return fp; 489 return fp;
490 } 490 }
491 491
492 GLFocalOutside2PtConicalEffect::GLFocalOutside2PtConicalEffect(const GrProcessor & processor) 492 GLFocalOutside2PtConicalEffect::GLFocalOutside2PtConicalEffect(const GrProcessor & processor)
493 : fVSVaryingName(nullptr) 493 : fVSVaryingName(nullptr)
494 , fFSVaryingName(nullptr) 494 , fFSVaryingName(nullptr)
495 , fCachedFocal(SK_ScalarMax) { 495 , fCachedFocal(SK_ScalarMax) {
496 const FocalOutside2PtConicalEffect& data = processor.cast<FocalOutside2PtCon icalEffect>(); 496 const FocalOutside2PtConicalEffect& data = processor.cast<FocalOutside2PtCon icalEffect>();
497 fIsFlipped = data.isFlipped(); 497 fIsFlipped = data.isFlipped();
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
573 573
574 class GLFocalInside2PtConicalEffect; 574 class GLFocalInside2PtConicalEffect;
575 575
576 class FocalInside2PtConicalEffect : public GrGradientEffect { 576 class FocalInside2PtConicalEffect : public GrGradientEffect {
577 public: 577 public:
578 578
579 static GrFragmentProcessor* Create(GrContext* ctx, 579 static GrFragmentProcessor* Create(GrContext* ctx,
580 const SkTwoPointConicalGradient& shader, 580 const SkTwoPointConicalGradient& shader,
581 const SkMatrix& matrix, 581 const SkMatrix& matrix,
582 SkShader::TileMode tm, 582 SkShader::TileMode tm,
583 SkScalar focalX) { 583 SkScalar focalX, GrRenderTarget* dst) {
584 return new FocalInside2PtConicalEffect(ctx, shader, matrix, tm, focalX); 584 return new FocalInside2PtConicalEffect(ctx, shader, matrix, tm, focalX, dst);
585 } 585 }
586 586
587 virtual ~FocalInside2PtConicalEffect() {} 587 virtual ~FocalInside2PtConicalEffect() {}
588 588
589 const char* name() const override { 589 const char* name() const override {
590 return "Two-Point Conical Gradient Focal Inside"; 590 return "Two-Point Conical Gradient Focal Inside";
591 } 591 }
592 592
593 SkScalar focal() const { return fFocalX; } 593 SkScalar focal() const { return fFocalX; }
594 594
595 typedef GLFocalInside2PtConicalEffect GLProcessor; 595 typedef GLFocalInside2PtConicalEffect GLProcessor;
596 596
597 private: 597 private:
598 GrGLFragmentProcessor* onCreateGLInstance() const override; 598 GrGLFragmentProcessor* onCreateGLInstance() const override;
599 599
600 void onGetGLProcessorKey(const GrGLSLCaps&, GrProcessorKeyBuilder*) const ov erride; 600 void onGetGLProcessorKey(const GrGLSLCaps&, GrProcessorKeyBuilder*) const ov erride;
601 601
602 bool onIsEqual(const GrFragmentProcessor& sBase) const override { 602 bool onIsEqual(const GrFragmentProcessor& sBase) const override {
603 const FocalInside2PtConicalEffect& s = sBase.cast<FocalInside2PtConicalE ffect>(); 603 const FocalInside2PtConicalEffect& s = sBase.cast<FocalInside2PtConicalE ffect>();
604 return (INHERITED::onIsEqual(sBase) && 604 return (INHERITED::onIsEqual(sBase) &&
605 this->fFocalX == s.fFocalX); 605 this->fFocalX == s.fFocalX);
606 } 606 }
607 607
608 FocalInside2PtConicalEffect(GrContext* ctx, 608 FocalInside2PtConicalEffect(GrContext* ctx,
609 const SkTwoPointConicalGradient& shader, 609 const SkTwoPointConicalGradient& shader,
610 const SkMatrix& matrix, 610 const SkMatrix& matrix,
611 SkShader::TileMode tm, 611 SkShader::TileMode tm,
612 SkScalar focalX) 612 SkScalar focalX, GrRenderTarget* dst)
613 : INHERITED(ctx, shader, matrix, tm), fFocalX(focalX) { 613 : INHERITED(ctx, shader, matrix, tm, dst), fFocalX(focalX) {
614 this->initClassID<FocalInside2PtConicalEffect>(); 614 this->initClassID<FocalInside2PtConicalEffect>();
615 } 615 }
616 616
617 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; 617 GR_DECLARE_FRAGMENT_PROCESSOR_TEST;
618 618
619 SkScalar fFocalX; 619 SkScalar fFocalX;
620 620
621 typedef GrGradientEffect INHERITED; 621 typedef GrGradientEffect INHERITED;
622 }; 622 };
623 623
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
683 SkColor colors[kMaxRandomGradientColors]; 683 SkColor colors[kMaxRandomGradientColors];
684 SkScalar stopsArray[kMaxRandomGradientColors]; 684 SkScalar stopsArray[kMaxRandomGradientColors];
685 SkScalar* stops = stopsArray; 685 SkScalar* stops = stopsArray;
686 SkShader::TileMode tm; 686 SkShader::TileMode tm;
687 int colorCount = RandomGradientParams(d->fRandom, colors, &stops, &tm); 687 int colorCount = RandomGradientParams(d->fRandom, colors, &stops, &tm);
688 SkAutoTUnref<SkShader> shader(SkGradientShader::CreateTwoPointConical(center 1, radius1, 688 SkAutoTUnref<SkShader> shader(SkGradientShader::CreateTwoPointConical(center 1, radius1,
689 center 2, radius2, 689 center 2, radius2,
690 colors , stops, colorCount, 690 colors , stops, colorCount,
691 tm)); 691 tm));
692 const GrFragmentProcessor* fp = shader->asFragmentProcessor(d->fContext, 692 const GrFragmentProcessor* fp = shader->asFragmentProcessor(d->fContext,
693 GrTest::TestMatrix(d->fRandom), NULL, kNone_SkFilterQuality); 693 GrTest::TestMatrix(d->fRandom), NULL, kNone_SkFilterQuality, NULL);
694 GrAlwaysAssert(fp); 694 GrAlwaysAssert(fp);
695 return fp; 695 return fp;
696 } 696 }
697 697
698 GLFocalInside2PtConicalEffect::GLFocalInside2PtConicalEffect(const GrProcessor&) 698 GLFocalInside2PtConicalEffect::GLFocalInside2PtConicalEffect(const GrProcessor&)
699 : fVSVaryingName(nullptr) 699 : fVSVaryingName(nullptr)
700 , fFSVaryingName(nullptr) 700 , fFSVaryingName(nullptr)
701 , fCachedFocal(SK_ScalarMax) {} 701 , fCachedFocal(SK_ScalarMax) {}
702 702
703 void GLFocalInside2PtConicalEffect::emitCode(EmitArgs& args) { 703 void GLFocalInside2PtConicalEffect::emitCode(EmitArgs& args) {
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
806 return kOutside_ConicalType; 806 return kOutside_ConicalType;
807 } 807 }
808 808
809 class CircleInside2PtConicalEffect : public GrGradientEffect { 809 class CircleInside2PtConicalEffect : public GrGradientEffect {
810 public: 810 public:
811 811
812 static GrFragmentProcessor* Create(GrContext* ctx, 812 static GrFragmentProcessor* Create(GrContext* ctx,
813 const SkTwoPointConicalGradient& shader, 813 const SkTwoPointConicalGradient& shader,
814 const SkMatrix& matrix, 814 const SkMatrix& matrix,
815 SkShader::TileMode tm, 815 SkShader::TileMode tm,
816 const CircleConicalInfo& info) { 816 const CircleConicalInfo& info, GrRenderTa rget* dst) {
817 return new CircleInside2PtConicalEffect(ctx, shader, matrix, tm, info); 817 return new CircleInside2PtConicalEffect(ctx, shader, matrix, tm, info, d st);
818 } 818 }
819 819
820 virtual ~CircleInside2PtConicalEffect() {} 820 virtual ~CircleInside2PtConicalEffect() {}
821 821
822 const char* name() const override { return "Two-Point Conical Gradient Insid e"; } 822 const char* name() const override { return "Two-Point Conical Gradient Insid e"; }
823 823
824 SkScalar centerX() const { return fInfo.fCenterEnd.fX; } 824 SkScalar centerX() const { return fInfo.fCenterEnd.fX; }
825 SkScalar centerY() const { return fInfo.fCenterEnd.fY; } 825 SkScalar centerY() const { return fInfo.fCenterEnd.fY; }
826 SkScalar A() const { return fInfo.fA; } 826 SkScalar A() const { return fInfo.fA; }
827 SkScalar B() const { return fInfo.fB; } 827 SkScalar B() const { return fInfo.fB; }
(...skipping 11 matching lines...) Expand all
839 this->fInfo.fCenterEnd == s.fInfo.fCenterEnd && 839 this->fInfo.fCenterEnd == s.fInfo.fCenterEnd &&
840 this->fInfo.fA == s.fInfo.fA && 840 this->fInfo.fA == s.fInfo.fA &&
841 this->fInfo.fB == s.fInfo.fB && 841 this->fInfo.fB == s.fInfo.fB &&
842 this->fInfo.fC == s.fInfo.fC); 842 this->fInfo.fC == s.fInfo.fC);
843 } 843 }
844 844
845 CircleInside2PtConicalEffect(GrContext* ctx, 845 CircleInside2PtConicalEffect(GrContext* ctx,
846 const SkTwoPointConicalGradient& shader, 846 const SkTwoPointConicalGradient& shader,
847 const SkMatrix& matrix, 847 const SkMatrix& matrix,
848 SkShader::TileMode tm, 848 SkShader::TileMode tm,
849 const CircleConicalInfo& info) 849 const CircleConicalInfo& info, GrRenderTarget* dst)
850 : INHERITED(ctx, shader, matrix, tm), fInfo(info) { 850 : INHERITED(ctx, shader, matrix, tm, dst), fInfo(info) {
851 this->initClassID<CircleInside2PtConicalEffect>(); 851 this->initClassID<CircleInside2PtConicalEffect>();
852 } 852 }
853 853
854 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; 854 GR_DECLARE_FRAGMENT_PROCESSOR_TEST;
855 855
856 const CircleConicalInfo fInfo; 856 const CircleConicalInfo fInfo;
857 857
858 typedef GrGradientEffect INHERITED; 858 typedef GrGradientEffect INHERITED;
859 }; 859 };
860 860
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
924 SkColor colors[kMaxRandomGradientColors]; 924 SkColor colors[kMaxRandomGradientColors];
925 SkScalar stopsArray[kMaxRandomGradientColors]; 925 SkScalar stopsArray[kMaxRandomGradientColors];
926 SkScalar* stops = stopsArray; 926 SkScalar* stops = stopsArray;
927 SkShader::TileMode tm; 927 SkShader::TileMode tm;
928 int colorCount = RandomGradientParams(d->fRandom, colors, &stops, &tm); 928 int colorCount = RandomGradientParams(d->fRandom, colors, &stops, &tm);
929 SkAutoTUnref<SkShader> shader(SkGradientShader::CreateTwoPointConical(center 1, radius1, 929 SkAutoTUnref<SkShader> shader(SkGradientShader::CreateTwoPointConical(center 1, radius1,
930 center 2, radius2, 930 center 2, radius2,
931 colors , stops, colorCount, 931 colors , stops, colorCount,
932 tm)); 932 tm));
933 const GrFragmentProcessor* fp = shader->asFragmentProcessor(d->fContext, 933 const GrFragmentProcessor* fp = shader->asFragmentProcessor(d->fContext,
934 GrTest::TestMatrix(d->fRandom), NULL, kNone_SkFilterQuality); 934 GrTest::TestMatrix(d->fRandom), NULL, kNone_SkFilterQuality, NULL);
935 GrAlwaysAssert(fp); 935 GrAlwaysAssert(fp);
936 return fp; 936 return fp;
937 } 937 }
938 938
939 GLCircleInside2PtConicalEffect::GLCircleInside2PtConicalEffect(const GrProcessor & processor) 939 GLCircleInside2PtConicalEffect::GLCircleInside2PtConicalEffect(const GrProcessor & processor)
940 : fVSVaryingName(nullptr) 940 : fVSVaryingName(nullptr)
941 , fFSVaryingName(nullptr) 941 , fFSVaryingName(nullptr)
942 , fCachedCenterX(SK_ScalarMax) 942 , fCachedCenterX(SK_ScalarMax)
943 , fCachedCenterY(SK_ScalarMax) 943 , fCachedCenterY(SK_ScalarMax)
944 , fCachedA(SK_ScalarMax) 944 , fCachedA(SK_ScalarMax)
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
1016 1016
1017 ////////////////////////////////////////////////////////////////////////////// 1017 //////////////////////////////////////////////////////////////////////////////
1018 1018
1019 class CircleOutside2PtConicalEffect : public GrGradientEffect { 1019 class CircleOutside2PtConicalEffect : public GrGradientEffect {
1020 public: 1020 public:
1021 1021
1022 static GrFragmentProcessor* Create(GrContext* ctx, 1022 static GrFragmentProcessor* Create(GrContext* ctx,
1023 const SkTwoPointConicalGradient& shader, 1023 const SkTwoPointConicalGradient& shader,
1024 const SkMatrix& matrix, 1024 const SkMatrix& matrix,
1025 SkShader::TileMode tm, 1025 SkShader::TileMode tm,
1026 const CircleConicalInfo& info) { 1026 const CircleConicalInfo& info, GrRenderTa rget* dst) {
1027 return new CircleOutside2PtConicalEffect(ctx, shader, matrix, tm, info); 1027 return new CircleOutside2PtConicalEffect(ctx, shader, matrix, tm, info, dst);
1028 } 1028 }
1029 1029
1030 virtual ~CircleOutside2PtConicalEffect() {} 1030 virtual ~CircleOutside2PtConicalEffect() {}
1031 1031
1032 const char* name() const override { return "Two-Point Conical Gradient Outsi de"; } 1032 const char* name() const override { return "Two-Point Conical Gradient Outsi de"; }
1033 1033
1034 SkScalar centerX() const { return fInfo.fCenterEnd.fX; } 1034 SkScalar centerX() const { return fInfo.fCenterEnd.fX; }
1035 SkScalar centerY() const { return fInfo.fCenterEnd.fY; } 1035 SkScalar centerY() const { return fInfo.fCenterEnd.fY; }
1036 SkScalar A() const { return fInfo.fA; } 1036 SkScalar A() const { return fInfo.fA; }
1037 SkScalar B() const { return fInfo.fB; } 1037 SkScalar B() const { return fInfo.fB; }
(...skipping 14 matching lines...) Expand all
1052 this->fInfo.fB == s.fInfo.fB && 1052 this->fInfo.fB == s.fInfo.fB &&
1053 this->fInfo.fC == s.fInfo.fC && 1053 this->fInfo.fC == s.fInfo.fC &&
1054 this->fTLimit == s.fTLimit && 1054 this->fTLimit == s.fTLimit &&
1055 this->fIsFlipped == s.fIsFlipped); 1055 this->fIsFlipped == s.fIsFlipped);
1056 } 1056 }
1057 1057
1058 CircleOutside2PtConicalEffect(GrContext* ctx, 1058 CircleOutside2PtConicalEffect(GrContext* ctx,
1059 const SkTwoPointConicalGradient& shader, 1059 const SkTwoPointConicalGradient& shader,
1060 const SkMatrix& matrix, 1060 const SkMatrix& matrix,
1061 SkShader::TileMode tm, 1061 SkShader::TileMode tm,
1062 const CircleConicalInfo& info) 1062 const CircleConicalInfo& info, GrRenderTarget* dst)
1063 : INHERITED(ctx, shader, matrix, tm), fInfo(info) { 1063 : INHERITED(ctx, shader, matrix, tm, dst), fInfo(info) {
1064 this->initClassID<CircleOutside2PtConicalEffect>(); 1064 this->initClassID<CircleOutside2PtConicalEffect>();
1065 if (shader.getStartRadius() != shader.getEndRadius()) { 1065 if (shader.getStartRadius() != shader.getEndRadius()) {
1066 fTLimit = shader.getStartRadius() / (shader.getStartRadius() - shade r.getEndRadius()); 1066 fTLimit = shader.getStartRadius() / (shader.getStartRadius() - shade r.getEndRadius());
1067 } else { 1067 } else {
1068 fTLimit = SK_ScalarMin; 1068 fTLimit = SK_ScalarMin;
1069 } 1069 }
1070 1070
1071 fIsFlipped = shader.isFlippedGrad(); 1071 fIsFlipped = shader.isFlippedGrad();
1072 } 1072 }
1073 1073
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
1150 SkColor colors[kMaxRandomGradientColors]; 1150 SkColor colors[kMaxRandomGradientColors];
1151 SkScalar stopsArray[kMaxRandomGradientColors]; 1151 SkScalar stopsArray[kMaxRandomGradientColors];
1152 SkScalar* stops = stopsArray; 1152 SkScalar* stops = stopsArray;
1153 SkShader::TileMode tm; 1153 SkShader::TileMode tm;
1154 int colorCount = RandomGradientParams(d->fRandom, colors, &stops, &tm); 1154 int colorCount = RandomGradientParams(d->fRandom, colors, &stops, &tm);
1155 SkAutoTUnref<SkShader> shader(SkGradientShader::CreateTwoPointConical(center 1, radius1, 1155 SkAutoTUnref<SkShader> shader(SkGradientShader::CreateTwoPointConical(center 1, radius1,
1156 center 2, radius2, 1156 center 2, radius2,
1157 colors , stops, colorCount, 1157 colors , stops, colorCount,
1158 tm)); 1158 tm));
1159 const GrFragmentProcessor* fp = shader->asFragmentProcessor( 1159 const GrFragmentProcessor* fp = shader->asFragmentProcessor(
1160 d->fContext,GrTest::TestMatrix(d->fRandom), NULL, kNone_SkFilterQuality) ; 1160 d->fContext,GrTest::TestMatrix(d->fRandom), NULL, kNone_SkFilterQuality, NULL);
1161 GrAlwaysAssert(fp); 1161 GrAlwaysAssert(fp);
1162 return fp; 1162 return fp;
1163 } 1163 }
1164 1164
1165 GLCircleOutside2PtConicalEffect::GLCircleOutside2PtConicalEffect(const GrProcess or& processor) 1165 GLCircleOutside2PtConicalEffect::GLCircleOutside2PtConicalEffect(const GrProcess or& processor)
1166 : fVSVaryingName(nullptr) 1166 : fVSVaryingName(nullptr)
1167 , fFSVaryingName(nullptr) 1167 , fFSVaryingName(nullptr)
1168 , fCachedCenterX(SK_ScalarMax) 1168 , fCachedCenterX(SK_ScalarMax)
1169 , fCachedCenterY(SK_ScalarMax) 1169 , fCachedCenterY(SK_ScalarMax)
1170 , fCachedA(SK_ScalarMax) 1170 , fCachedA(SK_ScalarMax)
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
1264 uint32_t* key = b->add32n(2); 1264 uint32_t* key = b->add32n(2);
1265 key[0] = GenBaseGradientKey(processor); 1265 key[0] = GenBaseGradientKey(processor);
1266 key[1] = processor.cast<CircleOutside2PtConicalEffect>().isFlipped(); 1266 key[1] = processor.cast<CircleOutside2PtConicalEffect>().isFlipped();
1267 } 1267 }
1268 1268
1269 ////////////////////////////////////////////////////////////////////////////// 1269 //////////////////////////////////////////////////////////////////////////////
1270 1270
1271 GrFragmentProcessor* Gr2PtConicalGradientEffect::Create(GrContext* ctx, 1271 GrFragmentProcessor* Gr2PtConicalGradientEffect::Create(GrContext* ctx,
1272 const SkTwoPointConicalG radient& shader, 1272 const SkTwoPointConicalG radient& shader,
1273 SkShader::TileMode tm, 1273 SkShader::TileMode tm,
1274 const SkMatrix* localMat rix) { 1274 const SkMatrix* localMat rix, GrRenderTarget* dst) {
1275 SkMatrix matrix; 1275 SkMatrix matrix;
1276 if (!shader.getLocalMatrix().invert(&matrix)) { 1276 if (!shader.getLocalMatrix().invert(&matrix)) {
1277 return nullptr; 1277 return nullptr;
1278 } 1278 }
1279 if (localMatrix) { 1279 if (localMatrix) {
1280 SkMatrix inv; 1280 SkMatrix inv;
1281 if (!localMatrix->invert(&inv)) { 1281 if (!localMatrix->invert(&inv)) {
1282 return nullptr; 1282 return nullptr;
1283 } 1283 }
1284 matrix.postConcat(inv); 1284 matrix.postConcat(inv);
1285 } 1285 }
1286 1286
1287 if (shader.getStartRadius() < kErrorTol) { 1287 if (shader.getStartRadius() < kErrorTol) {
1288 SkScalar focalX; 1288 SkScalar focalX;
1289 ConicalType type = set_matrix_focal_conical(shader, &matrix, &focalX); 1289 ConicalType type = set_matrix_focal_conical(shader, &matrix, &focalX);
1290 if (type == kInside_ConicalType) { 1290 if (type == kInside_ConicalType) {
1291 return FocalInside2PtConicalEffect::Create(ctx, shader, matrix, tm, focalX); 1291 return FocalInside2PtConicalEffect::Create(ctx, shader, matrix, tm,
1292 focalX, dst);
1292 } else if(type == kEdge_ConicalType) { 1293 } else if(type == kEdge_ConicalType) {
1293 set_matrix_edge_conical(shader, &matrix); 1294 set_matrix_edge_conical(shader, &matrix);
1294 return Edge2PtConicalEffect::Create(ctx, shader, matrix, tm); 1295 return Edge2PtConicalEffect::Create(ctx, shader, matrix, tm, dst);
1295 } else { 1296 } else {
1296 return FocalOutside2PtConicalEffect::Create(ctx, shader, matrix, tm, focalX); 1297 return FocalOutside2PtConicalEffect::Create(ctx, shader, matrix, tm,
1298 focalX, dst);
1297 } 1299 }
1298 } 1300 }
1299 1301
1300 CircleConicalInfo info; 1302 CircleConicalInfo info;
1301 ConicalType type = set_matrix_circle_conical(shader, &matrix, &info); 1303 ConicalType type = set_matrix_circle_conical(shader, &matrix, &info);
1302 1304
1303 if (type == kInside_ConicalType) { 1305 if (type == kInside_ConicalType) {
1304 return CircleInside2PtConicalEffect::Create(ctx, shader, matrix, tm, inf o); 1306 return CircleInside2PtConicalEffect::Create(ctx, shader, matrix, tm,
1307 info, dst);
1305 } else if (type == kEdge_ConicalType) { 1308 } else if (type == kEdge_ConicalType) {
1306 set_matrix_edge_conical(shader, &matrix); 1309 set_matrix_edge_conical(shader, &matrix);
1307 return Edge2PtConicalEffect::Create(ctx, shader, matrix, tm); 1310 return Edge2PtConicalEffect::Create(ctx, shader, matrix, tm, dst);
1308 } else { 1311 } else {
1309 return CircleOutside2PtConicalEffect::Create(ctx, shader, matrix, tm, in fo); 1312 return CircleOutside2PtConicalEffect::Create(ctx, shader, matrix, tm,
1313 info, dst);
1310 } 1314 }
1311 } 1315 }
1312 1316
1313 #endif 1317 #endif
OLDNEW
« no previous file with comments | « src/effects/gradients/SkTwoPointConicalGradient_gpu.h ('k') | src/gpu/GrAtlas.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698