OLD | NEW |
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 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 | 176 |
177 GrGLFragmentProcessor* Edge2PtConicalEffect::onCreateGLInstance() const { | 177 GrGLFragmentProcessor* Edge2PtConicalEffect::onCreateGLInstance() const { |
178 return new GLEdge2PtConicalEffect(*this); | 178 return new GLEdge2PtConicalEffect(*this); |
179 } | 179 } |
180 | 180 |
181 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(Edge2PtConicalEffect); | 181 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(Edge2PtConicalEffect); |
182 | 182 |
183 /* | 183 /* |
184 * All Two point conical gradient test create functions may occasionally create
edge case shaders | 184 * All Two point conical gradient test create functions may occasionally create
edge case shaders |
185 */ | 185 */ |
186 const GrFragmentProcessor* Edge2PtConicalEffect::TestCreate(GrProcessorTestData*
d) { | 186 GrFragmentProcessor* Edge2PtConicalEffect::TestCreate(GrProcessorTestData* d) { |
187 SkPoint center1 = {d->fRandom->nextUScalar1(), d->fRandom->nextUScalar1()}; | 187 SkPoint center1 = {d->fRandom->nextUScalar1(), d->fRandom->nextUScalar1()}; |
188 SkScalar radius1 = d->fRandom->nextUScalar1(); | 188 SkScalar radius1 = d->fRandom->nextUScalar1(); |
189 SkPoint center2; | 189 SkPoint center2; |
190 SkScalar radius2; | 190 SkScalar radius2; |
191 do { | 191 do { |
192 center2.set(d->fRandom->nextUScalar1(), d->fRandom->nextUScalar1()); | 192 center2.set(d->fRandom->nextUScalar1(), d->fRandom->nextUScalar1()); |
193 // If the circles are identical the factory will give us an empty shader
. | 193 // If the circles are identical the factory will give us an empty shader
. |
194 // This will happen if we pick identical centers | 194 // This will happen if we pick identical centers |
195 } while (center1 == center2); | 195 } while (center1 == center2); |
196 | 196 |
197 // Below makes sure that circle one is contained within circle two | 197 // Below makes sure that circle one is contained within circle two |
198 // and both circles are touching on an edge | 198 // and both circles are touching on an edge |
199 SkPoint diff = center2 - center1; | 199 SkPoint diff = center2 - center1; |
200 SkScalar diffLen = diff.length(); | 200 SkScalar diffLen = diff.length(); |
201 radius2 = radius1 + diffLen; | 201 radius2 = radius1 + diffLen; |
202 | 202 |
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 SkPaint paint; |
213 GrTest::TestMatrix(d->fRandom), NULL, kNone_SkFilterQuality, d->fProcDat
aManager); | 213 GrFragmentProcessor* fp; |
214 GrAlwaysAssert(fp); | 214 GrColor paintColor; |
| 215 SkAssertResult(shader->asFragmentProcessor(d->fContext, paint, |
| 216 GrTest::TestMatrix(d->fRandom), n
ullptr, |
| 217 &paintColor, d->fProcDataManager,
&fp)); |
215 return fp; | 218 return fp; |
216 } | 219 } |
217 | 220 |
218 GLEdge2PtConicalEffect::GLEdge2PtConicalEffect(const GrProcessor&) | 221 GLEdge2PtConicalEffect::GLEdge2PtConicalEffect(const GrProcessor&) |
219 : fVSVaryingName(nullptr) | 222 : fVSVaryingName(nullptr) |
220 , fFSVaryingName(nullptr) | 223 , fFSVaryingName(nullptr) |
221 , fCachedRadius(-SK_ScalarMax) | 224 , fCachedRadius(-SK_ScalarMax) |
222 , fCachedDiffRadius(-SK_ScalarMax) {} | 225 , fCachedDiffRadius(-SK_ScalarMax) {} |
223 | 226 |
224 void GLEdge2PtConicalEffect::emitCode(EmitArgs& args) { | 227 void GLEdge2PtConicalEffect::emitCode(EmitArgs& args) { |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
455 | 458 |
456 GrGLFragmentProcessor* FocalOutside2PtConicalEffect::onCreateGLInstance() const
{ | 459 GrGLFragmentProcessor* FocalOutside2PtConicalEffect::onCreateGLInstance() const
{ |
457 return new GLFocalOutside2PtConicalEffect(*this); | 460 return new GLFocalOutside2PtConicalEffect(*this); |
458 } | 461 } |
459 | 462 |
460 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(FocalOutside2PtConicalEffect); | 463 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(FocalOutside2PtConicalEffect); |
461 | 464 |
462 /* | 465 /* |
463 * All Two point conical gradient test create functions may occasionally create
edge case shaders | 466 * All Two point conical gradient test create functions may occasionally create
edge case shaders |
464 */ | 467 */ |
465 const GrFragmentProcessor* FocalOutside2PtConicalEffect::TestCreate(GrProcessorT
estData* d) { | 468 GrFragmentProcessor* FocalOutside2PtConicalEffect::TestCreate(GrProcessorTestDat
a* d) { |
466 SkPoint center1 = {d->fRandom->nextUScalar1(), d->fRandom->nextUScalar1()}; | 469 SkPoint center1 = {d->fRandom->nextUScalar1(), d->fRandom->nextUScalar1()}; |
467 SkScalar radius1 = 0.f; | 470 SkScalar radius1 = 0.f; |
468 SkPoint center2; | 471 SkPoint center2; |
469 SkScalar radius2; | 472 SkScalar radius2; |
470 do { | 473 do { |
471 center2.set(d->fRandom->nextUScalar1(), d->fRandom->nextUScalar1()); | 474 center2.set(d->fRandom->nextUScalar1(), d->fRandom->nextUScalar1()); |
472 // Need to make sure the centers are not the same or else focal point wi
ll be inside | 475 // Need to make sure the centers are not the same or else focal point wi
ll be inside |
473 } while (center1 == center2); | 476 } while (center1 == center2); |
474 SkPoint diff = center2 - center1; | 477 SkPoint diff = center2 - center1; |
475 SkScalar diffLen = diff.length(); | 478 SkScalar diffLen = diff.length(); |
476 // Below makes sure that the focal point is not contained within circle
two | 479 // Below makes sure that the focal point is not contained within circle
two |
477 radius2 = d->fRandom->nextRangeF(0.f, diffLen); | 480 radius2 = d->fRandom->nextRangeF(0.f, diffLen); |
478 | 481 |
479 SkColor colors[kMaxRandomGradientColors]; | 482 SkColor colors[kMaxRandomGradientColors]; |
480 SkScalar stopsArray[kMaxRandomGradientColors]; | 483 SkScalar stopsArray[kMaxRandomGradientColors]; |
481 SkScalar* stops = stopsArray; | 484 SkScalar* stops = stopsArray; |
482 SkShader::TileMode tm; | 485 SkShader::TileMode tm; |
483 int colorCount = RandomGradientParams(d->fRandom, colors, &stops, &tm); | 486 int colorCount = RandomGradientParams(d->fRandom, colors, &stops, &tm); |
484 SkAutoTUnref<SkShader> shader(SkGradientShader::CreateTwoPointConical(center
1, radius1, | 487 SkAutoTUnref<SkShader> shader(SkGradientShader::CreateTwoPointConical(center
1, radius1, |
485 center
2, radius2, | 488 center
2, radius2, |
486 colors
, stops, colorCount, | 489 colors
, stops, colorCount, |
487 tm)); | 490 tm)); |
488 const GrFragmentProcessor* fp = shader->asFragmentProcessor(d->fContext, | 491 SkPaint paint; |
489 GrTest::TestMatrix(d->fRandom), NULL, kNone_SkFilterQuality, d->fProcDat
aManager); | 492 GrFragmentProcessor* effect; |
490 GrAlwaysAssert(fp); | 493 GrColor paintColor; |
491 return fp; | 494 GrPaint grPaint; |
| 495 SkAssertResult(shader->asFragmentProcessor(d->fContext, paint, |
| 496 GrTest::TestMatrix(d->fRandom), n
ullptr, |
| 497 &paintColor, d->fProcDataManager, |
| 498 &effect)); |
| 499 return effect; |
492 } | 500 } |
493 | 501 |
494 GLFocalOutside2PtConicalEffect::GLFocalOutside2PtConicalEffect(const GrProcessor
& processor) | 502 GLFocalOutside2PtConicalEffect::GLFocalOutside2PtConicalEffect(const GrProcessor
& processor) |
495 : fVSVaryingName(nullptr) | 503 : fVSVaryingName(nullptr) |
496 , fFSVaryingName(nullptr) | 504 , fFSVaryingName(nullptr) |
497 , fCachedFocal(SK_ScalarMax) { | 505 , fCachedFocal(SK_ScalarMax) { |
498 const FocalOutside2PtConicalEffect& data = processor.cast<FocalOutside2PtCon
icalEffect>(); | 506 const FocalOutside2PtConicalEffect& data = processor.cast<FocalOutside2PtCon
icalEffect>(); |
499 fIsFlipped = data.isFlipped(); | 507 fIsFlipped = data.isFlipped(); |
500 } | 508 } |
501 | 509 |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
661 | 669 |
662 GrGLFragmentProcessor* FocalInside2PtConicalEffect::onCreateGLInstance() const { | 670 GrGLFragmentProcessor* FocalInside2PtConicalEffect::onCreateGLInstance() const { |
663 return new GLFocalInside2PtConicalEffect(*this); | 671 return new GLFocalInside2PtConicalEffect(*this); |
664 } | 672 } |
665 | 673 |
666 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(FocalInside2PtConicalEffect); | 674 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(FocalInside2PtConicalEffect); |
667 | 675 |
668 /* | 676 /* |
669 * All Two point conical gradient test create functions may occasionally create
edge case shaders | 677 * All Two point conical gradient test create functions may occasionally create
edge case shaders |
670 */ | 678 */ |
671 const GrFragmentProcessor* FocalInside2PtConicalEffect::TestCreate(GrProcessorTe
stData* d) { | 679 GrFragmentProcessor* FocalInside2PtConicalEffect::TestCreate(GrProcessorTestData
* d) { |
672 SkPoint center1 = {d->fRandom->nextUScalar1(), d->fRandom->nextUScalar1()}; | 680 SkPoint center1 = {d->fRandom->nextUScalar1(), d->fRandom->nextUScalar1()}; |
673 SkScalar radius1 = 0.f; | 681 SkScalar radius1 = 0.f; |
674 SkPoint center2; | 682 SkPoint center2; |
675 SkScalar radius2; | 683 SkScalar radius2; |
676 do { | 684 do { |
677 center2.set(d->fRandom->nextUScalar1(), d->fRandom->nextUScalar1()); | 685 center2.set(d->fRandom->nextUScalar1(), d->fRandom->nextUScalar1()); |
678 // Below makes sure radius2 is larger enouch such that the focal point | 686 // Below makes sure radius2 is larger enouch such that the focal point |
679 // is inside the end circle | 687 // is inside the end circle |
680 SkScalar increase = d->fRandom->nextUScalar1(); | 688 SkScalar increase = d->fRandom->nextUScalar1(); |
681 SkPoint diff = center2 - center1; | 689 SkPoint diff = center2 - center1; |
682 SkScalar diffLen = diff.length(); | 690 SkScalar diffLen = diff.length(); |
683 radius2 = diffLen + increase; | 691 radius2 = diffLen + increase; |
684 // If the circles are identical the factory will give us an empty shader
. | 692 // If the circles are identical the factory will give us an empty shader
. |
685 } while (radius1 == radius2 && center1 == center2); | 693 } while (radius1 == radius2 && center1 == center2); |
686 | 694 |
687 SkColor colors[kMaxRandomGradientColors]; | 695 SkColor colors[kMaxRandomGradientColors]; |
688 SkScalar stopsArray[kMaxRandomGradientColors]; | 696 SkScalar stopsArray[kMaxRandomGradientColors]; |
689 SkScalar* stops = stopsArray; | 697 SkScalar* stops = stopsArray; |
690 SkShader::TileMode tm; | 698 SkShader::TileMode tm; |
691 int colorCount = RandomGradientParams(d->fRandom, colors, &stops, &tm); | 699 int colorCount = RandomGradientParams(d->fRandom, colors, &stops, &tm); |
692 SkAutoTUnref<SkShader> shader(SkGradientShader::CreateTwoPointConical(center
1, radius1, | 700 SkAutoTUnref<SkShader> shader(SkGradientShader::CreateTwoPointConical(center
1, radius1, |
693 center
2, radius2, | 701 center
2, radius2, |
694 colors
, stops, colorCount, | 702 colors
, stops, colorCount, |
695 tm)); | 703 tm)); |
696 const GrFragmentProcessor* fp = shader->asFragmentProcessor(d->fContext, | 704 SkPaint paint; |
697 GrTest::TestMatrix(d->fRandom), NULL, kNone_SkFilterQuality, d->fProcDat
aManager); | 705 GrColor paintColor; |
698 GrAlwaysAssert(fp); | 706 GrFragmentProcessor* fp; |
| 707 SkAssertResult(shader->asFragmentProcessor(d->fContext, paint, |
| 708 GrTest::TestMatrix(d->fRandom), n
ullptr, |
| 709 &paintColor, d->fProcDataManager,
&fp)); |
699 return fp; | 710 return fp; |
700 } | 711 } |
701 | 712 |
702 GLFocalInside2PtConicalEffect::GLFocalInside2PtConicalEffect(const GrProcessor&) | 713 GLFocalInside2PtConicalEffect::GLFocalInside2PtConicalEffect(const GrProcessor&) |
703 : fVSVaryingName(nullptr) | 714 : fVSVaryingName(nullptr) |
704 , fFSVaryingName(nullptr) | 715 , fFSVaryingName(nullptr) |
705 , fCachedFocal(SK_ScalarMax) {} | 716 , fCachedFocal(SK_ScalarMax) {} |
706 | 717 |
707 void GLFocalInside2PtConicalEffect::emitCode(EmitArgs& args) { | 718 void GLFocalInside2PtConicalEffect::emitCode(EmitArgs& args) { |
708 const FocalInside2PtConicalEffect& ge = args.fFp.cast<FocalInside2PtConicalE
ffect>(); | 719 const FocalInside2PtConicalEffect& ge = args.fFp.cast<FocalInside2PtConicalE
ffect>(); |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
905 | 916 |
906 GrGLFragmentProcessor* CircleInside2PtConicalEffect::onCreateGLInstance() const
{ | 917 GrGLFragmentProcessor* CircleInside2PtConicalEffect::onCreateGLInstance() const
{ |
907 return new GLCircleInside2PtConicalEffect(*this); | 918 return new GLCircleInside2PtConicalEffect(*this); |
908 } | 919 } |
909 | 920 |
910 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(CircleInside2PtConicalEffect); | 921 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(CircleInside2PtConicalEffect); |
911 | 922 |
912 /* | 923 /* |
913 * All Two point conical gradient test create functions may occasionally create
edge case shaders | 924 * All Two point conical gradient test create functions may occasionally create
edge case shaders |
914 */ | 925 */ |
915 const GrFragmentProcessor* CircleInside2PtConicalEffect::TestCreate(GrProcessorT
estData* d) { | 926 GrFragmentProcessor* |
| 927 CircleInside2PtConicalEffect::TestCreate(GrProcessorTestData* d) { |
916 SkPoint center1 = {d->fRandom->nextUScalar1(), d->fRandom->nextUScalar1()}; | 928 SkPoint center1 = {d->fRandom->nextUScalar1(), d->fRandom->nextUScalar1()}; |
917 SkScalar radius1 = d->fRandom->nextUScalar1() + 0.0001f; // make sure radius
1 != 0 | 929 SkScalar radius1 = d->fRandom->nextUScalar1() + 0.0001f; // make sure radius
1 != 0 |
918 SkPoint center2; | 930 SkPoint center2; |
919 SkScalar radius2; | 931 SkScalar radius2; |
920 do { | 932 do { |
921 center2.set(d->fRandom->nextUScalar1(), d->fRandom->nextUScalar1()); | 933 center2.set(d->fRandom->nextUScalar1(), d->fRandom->nextUScalar1()); |
922 // Below makes sure that circle one is contained within circle two | 934 // Below makes sure that circle one is contained within circle two |
923 SkScalar increase = d->fRandom->nextUScalar1(); | 935 SkScalar increase = d->fRandom->nextUScalar1(); |
924 SkPoint diff = center2 - center1; | 936 SkPoint diff = center2 - center1; |
925 SkScalar diffLen = diff.length(); | 937 SkScalar diffLen = diff.length(); |
926 radius2 = radius1 + diffLen + increase; | 938 radius2 = radius1 + diffLen + increase; |
927 // If the circles are identical the factory will give us an empty shader
. | 939 // If the circles are identical the factory will give us an empty shader
. |
928 } while (radius1 == radius2 && center1 == center2); | 940 } while (radius1 == radius2 && center1 == center2); |
929 | 941 |
930 SkColor colors[kMaxRandomGradientColors]; | 942 SkColor colors[kMaxRandomGradientColors]; |
931 SkScalar stopsArray[kMaxRandomGradientColors]; | 943 SkScalar stopsArray[kMaxRandomGradientColors]; |
932 SkScalar* stops = stopsArray; | 944 SkScalar* stops = stopsArray; |
933 SkShader::TileMode tm; | 945 SkShader::TileMode tm; |
934 int colorCount = RandomGradientParams(d->fRandom, colors, &stops, &tm); | 946 int colorCount = RandomGradientParams(d->fRandom, colors, &stops, &tm); |
935 SkAutoTUnref<SkShader> shader(SkGradientShader::CreateTwoPointConical(center
1, radius1, | 947 SkAutoTUnref<SkShader> shader(SkGradientShader::CreateTwoPointConical(center
1, radius1, |
936 center
2, radius2, | 948 center
2, radius2, |
937 colors
, stops, colorCount, | 949 colors
, stops, colorCount, |
938 tm)); | 950 tm)); |
939 const GrFragmentProcessor* fp = shader->asFragmentProcessor(d->fContext, | 951 SkPaint paint; |
940 GrTest::TestMatrix(d->fRandom), NULL, kNone_SkFilterQuality, d->fProcDat
aManager); | 952 GrColor paintColor; |
941 GrAlwaysAssert(fp); | 953 GrFragmentProcessor* fp; |
| 954 SkAssertResult(shader->asFragmentProcessor(d->fContext, paint, |
| 955 GrTest::TestMatrix(d->fRandom), n
ullptr, |
| 956 &paintColor, d->fProcDataManager,
&fp)); |
942 return fp; | 957 return fp; |
943 } | 958 } |
944 | 959 |
945 GLCircleInside2PtConicalEffect::GLCircleInside2PtConicalEffect(const GrProcessor
& processor) | 960 GLCircleInside2PtConicalEffect::GLCircleInside2PtConicalEffect(const GrProcessor
& processor) |
946 : fVSVaryingName(nullptr) | 961 : fVSVaryingName(nullptr) |
947 , fFSVaryingName(nullptr) | 962 , fFSVaryingName(nullptr) |
948 , fCachedCenterX(SK_ScalarMax) | 963 , fCachedCenterX(SK_ScalarMax) |
949 , fCachedCenterY(SK_ScalarMax) | 964 , fCachedCenterY(SK_ScalarMax) |
950 , fCachedA(SK_ScalarMax) | 965 , fCachedA(SK_ScalarMax) |
951 , fCachedB(SK_ScalarMax) | 966 , fCachedB(SK_ScalarMax) |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1132 | 1147 |
1133 GrGLFragmentProcessor* CircleOutside2PtConicalEffect::onCreateGLInstance() const
{ | 1148 GrGLFragmentProcessor* CircleOutside2PtConicalEffect::onCreateGLInstance() const
{ |
1134 return new GLCircleOutside2PtConicalEffect(*this); | 1149 return new GLCircleOutside2PtConicalEffect(*this); |
1135 } | 1150 } |
1136 | 1151 |
1137 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(CircleOutside2PtConicalEffect); | 1152 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(CircleOutside2PtConicalEffect); |
1138 | 1153 |
1139 /* | 1154 /* |
1140 * All Two point conical gradient test create functions may occasionally create
edge case shaders | 1155 * All Two point conical gradient test create functions may occasionally create
edge case shaders |
1141 */ | 1156 */ |
1142 const GrFragmentProcessor* CircleOutside2PtConicalEffect::TestCreate(GrProcessor
TestData* d) { | 1157 GrFragmentProcessor* CircleOutside2PtConicalEffect::TestCreate(GrProcessorTestDa
ta* d) { |
1143 SkPoint center1 = {d->fRandom->nextUScalar1(), d->fRandom->nextUScalar1()}; | 1158 SkPoint center1 = {d->fRandom->nextUScalar1(), d->fRandom->nextUScalar1()}; |
1144 SkScalar radius1 = d->fRandom->nextUScalar1() + 0.0001f; // make sure radius
1 != 0 | 1159 SkScalar radius1 = d->fRandom->nextUScalar1() + 0.0001f; // make sure radius
1 != 0 |
1145 SkPoint center2; | 1160 SkPoint center2; |
1146 SkScalar radius2; | 1161 SkScalar radius2; |
1147 SkScalar diffLen; | 1162 SkScalar diffLen; |
1148 do { | 1163 do { |
1149 center2.set(d->fRandom->nextUScalar1(), d->fRandom->nextUScalar1()); | 1164 center2.set(d->fRandom->nextUScalar1(), d->fRandom->nextUScalar1()); |
1150 // If the circles share a center than we can't be in the outside case | 1165 // If the circles share a center than we can't be in the outside case |
1151 } while (center1 == center2); | 1166 } while (center1 == center2); |
1152 SkPoint diff = center2 - center1; | 1167 SkPoint diff = center2 - center1; |
1153 diffLen = diff.length(); | 1168 diffLen = diff.length(); |
1154 // Below makes sure that circle one is not contained within circle two | 1169 // Below makes sure that circle one is not contained within circle two |
1155 // and have radius2 >= radius to match sorting on cpu side | 1170 // and have radius2 >= radius to match sorting on cpu side |
1156 radius2 = radius1 + d->fRandom->nextRangeF(0.f, diffLen); | 1171 radius2 = radius1 + d->fRandom->nextRangeF(0.f, diffLen); |
1157 | 1172 |
1158 SkColor colors[kMaxRandomGradientColors]; | 1173 SkColor colors[kMaxRandomGradientColors]; |
1159 SkScalar stopsArray[kMaxRandomGradientColors]; | 1174 SkScalar stopsArray[kMaxRandomGradientColors]; |
1160 SkScalar* stops = stopsArray; | 1175 SkScalar* stops = stopsArray; |
1161 SkShader::TileMode tm; | 1176 SkShader::TileMode tm; |
1162 int colorCount = RandomGradientParams(d->fRandom, colors, &stops, &tm); | 1177 int colorCount = RandomGradientParams(d->fRandom, colors, &stops, &tm); |
1163 SkAutoTUnref<SkShader> shader(SkGradientShader::CreateTwoPointConical(center
1, radius1, | 1178 SkAutoTUnref<SkShader> shader(SkGradientShader::CreateTwoPointConical(center
1, radius1, |
1164 center
2, radius2, | 1179 center
2, radius2, |
1165 colors
, stops, colorCount, | 1180 colors
, stops, colorCount, |
1166 tm)); | 1181 tm)); |
1167 const GrFragmentProcessor* fp = shader->asFragmentProcessor( | 1182 SkPaint paint; |
1168 d->fContext,GrTest::TestMatrix(d->fRandom), NULL, kNone_SkFilterQuality, | 1183 GrColor paintColor; |
1169 d->fProcDataManager); | 1184 GrFragmentProcessor* fp; |
1170 GrAlwaysAssert(fp); | 1185 SkAssertResult(shader->asFragmentProcessor(d->fContext, paint, |
| 1186 GrTest::TestMatrix(d->fRandom), n
ullptr, |
| 1187 &paintColor, d->fProcDataManager,
&fp)); |
1171 return fp; | 1188 return fp; |
1172 } | 1189 } |
1173 | 1190 |
1174 GLCircleOutside2PtConicalEffect::GLCircleOutside2PtConicalEffect(const GrProcess
or& processor) | 1191 GLCircleOutside2PtConicalEffect::GLCircleOutside2PtConicalEffect(const GrProcess
or& processor) |
1175 : fVSVaryingName(nullptr) | 1192 : fVSVaryingName(nullptr) |
1176 , fFSVaryingName(nullptr) | 1193 , fFSVaryingName(nullptr) |
1177 , fCachedCenterX(SK_ScalarMax) | 1194 , fCachedCenterX(SK_ScalarMax) |
1178 , fCachedCenterY(SK_ScalarMax) | 1195 , fCachedCenterY(SK_ScalarMax) |
1179 , fCachedA(SK_ScalarMax) | 1196 , fCachedA(SK_ScalarMax) |
1180 , fCachedB(SK_ScalarMax) | 1197 , fCachedB(SK_ScalarMax) |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1318 } else if (type == kEdge_ConicalType) { | 1335 } else if (type == kEdge_ConicalType) { |
1319 set_matrix_edge_conical(shader, &matrix); | 1336 set_matrix_edge_conical(shader, &matrix); |
1320 return Edge2PtConicalEffect::Create(ctx, procDataManager, shader, matrix
, tm); | 1337 return Edge2PtConicalEffect::Create(ctx, procDataManager, shader, matrix
, tm); |
1321 } else { | 1338 } else { |
1322 return CircleOutside2PtConicalEffect::Create(ctx, procDataManager, shade
r, matrix, tm, | 1339 return CircleOutside2PtConicalEffect::Create(ctx, procDataManager, shade
r, matrix, tm, |
1323 info); | 1340 info); |
1324 } | 1341 } |
1325 } | 1342 } |
1326 | 1343 |
1327 #endif | 1344 #endif |
OLD | NEW |