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 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 | 180 |
181 GrGLFragmentProcessor* Edge2PtConicalEffect::createGLInstance() const { | 181 GrGLFragmentProcessor* Edge2PtConicalEffect::createGLInstance() const { |
182 return SkNEW_ARGS(GLEdge2PtConicalEffect, (*this)); | 182 return SkNEW_ARGS(GLEdge2PtConicalEffect, (*this)); |
183 } | 183 } |
184 | 184 |
185 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(Edge2PtConicalEffect); | 185 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(Edge2PtConicalEffect); |
186 | 186 |
187 /* | 187 /* |
188 * All Two point conical gradient test create functions may occasionally create
edge case shaders | 188 * All Two point conical gradient test create functions may occasionally create
edge case shaders |
189 */ | 189 */ |
190 GrFragmentProcessor* Edge2PtConicalEffect::TestCreate(SkRandom* random, | 190 GrFragmentProcessor* Edge2PtConicalEffect::TestCreate(GrProcessorTestData* d) { |
191 GrContext* context, | 191 SkPoint center1 = {d->fRandom->nextUScalar1(), d->fRandom->nextUScalar1()}; |
192 const GrCaps&, | 192 SkScalar radius1 = d->fRandom->nextUScalar1(); |
193 GrTexture**) { | |
194 SkPoint center1 = {random->nextUScalar1(), random->nextUScalar1()}; | |
195 SkScalar radius1 = random->nextUScalar1(); | |
196 SkPoint center2; | 193 SkPoint center2; |
197 SkScalar radius2; | 194 SkScalar radius2; |
198 do { | 195 do { |
199 center2.set(random->nextUScalar1(), random->nextUScalar1()); | 196 center2.set(d->fRandom->nextUScalar1(), d->fRandom->nextUScalar1()); |
200 // If the circles are identical the factory will give us an empty shader
. | 197 // If the circles are identical the factory will give us an empty shader
. |
201 // This will happen if we pick identical centers | 198 // This will happen if we pick identical centers |
202 } while (center1 == center2); | 199 } while (center1 == center2); |
203 | 200 |
204 // Below makes sure that circle one is contained within circle two | 201 // Below makes sure that circle one is contained within circle two |
205 // and both circles are touching on an edge | 202 // and both circles are touching on an edge |
206 SkPoint diff = center2 - center1; | 203 SkPoint diff = center2 - center1; |
207 SkScalar diffLen = diff.length(); | 204 SkScalar diffLen = diff.length(); |
208 radius2 = radius1 + diffLen; | 205 radius2 = radius1 + diffLen; |
209 | 206 |
210 SkColor colors[kMaxRandomGradientColors]; | 207 SkColor colors[kMaxRandomGradientColors]; |
211 SkScalar stopsArray[kMaxRandomGradientColors]; | 208 SkScalar stopsArray[kMaxRandomGradientColors]; |
212 SkScalar* stops = stopsArray; | 209 SkScalar* stops = stopsArray; |
213 SkShader::TileMode tm; | 210 SkShader::TileMode tm; |
214 int colorCount = RandomGradientParams(random, colors, &stops, &tm); | 211 int colorCount = RandomGradientParams(d->fRandom, colors, &stops, &tm); |
215 SkAutoTUnref<SkShader> shader(SkGradientShader::CreateTwoPointConical(center
1, radius1, | 212 SkAutoTUnref<SkShader> shader(SkGradientShader::CreateTwoPointConical(center
1, radius1, |
216 center
2, radius2, | 213 center
2, radius2, |
217 colors
, stops, colorCount, | 214 colors
, stops, colorCount, |
218 tm)); | 215 tm)); |
219 SkPaint paint; | 216 SkPaint paint; |
220 GrFragmentProcessor* fp; | 217 GrFragmentProcessor* fp; |
221 GrColor paintColor; | 218 GrColor paintColor; |
222 GrPaint grPaint; | 219 SkAssertResult(shader->asFragmentProcessor(d->fContext, paint, |
223 SkAssertResult(shader->asFragmentProcessor(context, paint, | 220 GrTest::TestMatrix(d->fRandom), N
ULL, |
224 GrTest::TestMatrix(random), NULL, | 221 &paintColor, d->fShaderDataManage
r, &fp)); |
225 &paintColor, grPaint.getShaderDat
aManager(), &fp)); | |
226 return fp; | 222 return fp; |
227 } | 223 } |
228 | 224 |
229 GLEdge2PtConicalEffect::GLEdge2PtConicalEffect(const GrProcessor&) | 225 GLEdge2PtConicalEffect::GLEdge2PtConicalEffect(const GrProcessor&) |
230 : fVSVaryingName(NULL) | 226 : fVSVaryingName(NULL) |
231 , fFSVaryingName(NULL) | 227 , fFSVaryingName(NULL) |
232 , fCachedRadius(-SK_ScalarMax) | 228 , fCachedRadius(-SK_ScalarMax) |
233 , fCachedDiffRadius(-SK_ScalarMax) {} | 229 , fCachedDiffRadius(-SK_ScalarMax) {} |
234 | 230 |
235 void GLEdge2PtConicalEffect::emitCode(GrGLFPBuilder* builder, | 231 void GLEdge2PtConicalEffect::emitCode(GrGLFPBuilder* builder, |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
475 | 471 |
476 GrGLFragmentProcessor* FocalOutside2PtConicalEffect::createGLInstance() const { | 472 GrGLFragmentProcessor* FocalOutside2PtConicalEffect::createGLInstance() const { |
477 return SkNEW_ARGS(GLFocalOutside2PtConicalEffect, (*this)); | 473 return SkNEW_ARGS(GLFocalOutside2PtConicalEffect, (*this)); |
478 } | 474 } |
479 | 475 |
480 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(FocalOutside2PtConicalEffect); | 476 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(FocalOutside2PtConicalEffect); |
481 | 477 |
482 /* | 478 /* |
483 * All Two point conical gradient test create functions may occasionally create
edge case shaders | 479 * All Two point conical gradient test create functions may occasionally create
edge case shaders |
484 */ | 480 */ |
485 GrFragmentProcessor* FocalOutside2PtConicalEffect::TestCreate(SkRandom* random, | 481 GrFragmentProcessor* FocalOutside2PtConicalEffect::TestCreate(GrProcessorTestDat
a* d) { |
486 GrContext* context
, | 482 SkPoint center1 = {d->fRandom->nextUScalar1(), d->fRandom->nextUScalar1()}; |
487 const GrCaps&, | |
488 GrTexture**) { | |
489 SkPoint center1 = {random->nextUScalar1(), random->nextUScalar1()}; | |
490 SkScalar radius1 = 0.f; | 483 SkScalar radius1 = 0.f; |
491 SkPoint center2; | 484 SkPoint center2; |
492 SkScalar radius2; | 485 SkScalar radius2; |
493 do { | 486 do { |
494 center2.set(random->nextUScalar1(), random->nextUScalar1()); | 487 center2.set(d->fRandom->nextUScalar1(), d->fRandom->nextUScalar1()); |
495 // Need to make sure the centers are not the same or else focal point wi
ll be inside | 488 // Need to make sure the centers are not the same or else focal point wi
ll be inside |
496 } while (center1 == center2); | 489 } while (center1 == center2); |
497 SkPoint diff = center2 - center1; | 490 SkPoint diff = center2 - center1; |
498 SkScalar diffLen = diff.length(); | 491 SkScalar diffLen = diff.length(); |
499 // Below makes sure that the focal point is not contained within circle
two | 492 // Below makes sure that the focal point is not contained within circle
two |
500 radius2 = random->nextRangeF(0.f, diffLen); | 493 radius2 = d->fRandom->nextRangeF(0.f, diffLen); |
501 | 494 |
502 SkColor colors[kMaxRandomGradientColors]; | 495 SkColor colors[kMaxRandomGradientColors]; |
503 SkScalar stopsArray[kMaxRandomGradientColors]; | 496 SkScalar stopsArray[kMaxRandomGradientColors]; |
504 SkScalar* stops = stopsArray; | 497 SkScalar* stops = stopsArray; |
505 SkShader::TileMode tm; | 498 SkShader::TileMode tm; |
506 int colorCount = RandomGradientParams(random, colors, &stops, &tm); | 499 int colorCount = RandomGradientParams(d->fRandom, colors, &stops, &tm); |
507 SkAutoTUnref<SkShader> shader(SkGradientShader::CreateTwoPointConical(center
1, radius1, | 500 SkAutoTUnref<SkShader> shader(SkGradientShader::CreateTwoPointConical(center
1, radius1, |
508 center
2, radius2, | 501 center
2, radius2, |
509 colors
, stops, colorCount, | 502 colors
, stops, colorCount, |
510 tm)); | 503 tm)); |
511 SkPaint paint; | 504 SkPaint paint; |
512 GrFragmentProcessor* effect; | 505 GrFragmentProcessor* effect; |
513 GrColor paintColor; | 506 GrColor paintColor; |
514 GrPaint grPaint; | 507 GrPaint grPaint; |
515 SkAssertResult(shader->asFragmentProcessor(context, paint, | 508 SkAssertResult(shader->asFragmentProcessor(d->fContext, paint, |
516 GrTest::TestMatrix(random), NULL, | 509 GrTest::TestMatrix(d->fRandom), N
ULL, |
517 &paintColor, grPaint.getShaderDat
aManager(), | 510 &paintColor, d->fShaderDataManage
r, |
518 &effect)); | 511 &effect)); |
519 return effect; | 512 return effect; |
520 } | 513 } |
521 | 514 |
522 GLFocalOutside2PtConicalEffect::GLFocalOutside2PtConicalEffect(const GrProcessor
& processor) | 515 GLFocalOutside2PtConicalEffect::GLFocalOutside2PtConicalEffect(const GrProcessor
& processor) |
523 : fVSVaryingName(NULL) | 516 : fVSVaryingName(NULL) |
524 , fFSVaryingName(NULL) | 517 , fFSVaryingName(NULL) |
525 , fCachedFocal(SK_ScalarMax) { | 518 , fCachedFocal(SK_ScalarMax) { |
526 const FocalOutside2PtConicalEffect& data = processor.cast<FocalOutside2PtCon
icalEffect>(); | 519 const FocalOutside2PtConicalEffect& data = processor.cast<FocalOutside2PtCon
icalEffect>(); |
527 fIsFlipped = data.isFlipped(); | 520 fIsFlipped = data.isFlipped(); |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
698 | 691 |
699 GrGLFragmentProcessor* FocalInside2PtConicalEffect::createGLInstance() const { | 692 GrGLFragmentProcessor* FocalInside2PtConicalEffect::createGLInstance() const { |
700 return SkNEW_ARGS(GLFocalInside2PtConicalEffect, (*this)); | 693 return SkNEW_ARGS(GLFocalInside2PtConicalEffect, (*this)); |
701 } | 694 } |
702 | 695 |
703 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(FocalInside2PtConicalEffect); | 696 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(FocalInside2PtConicalEffect); |
704 | 697 |
705 /* | 698 /* |
706 * All Two point conical gradient test create functions may occasionally create
edge case shaders | 699 * All Two point conical gradient test create functions may occasionally create
edge case shaders |
707 */ | 700 */ |
708 GrFragmentProcessor* FocalInside2PtConicalEffect::TestCreate(SkRandom* random, | 701 GrFragmentProcessor* FocalInside2PtConicalEffect::TestCreate(GrProcessorTestData
* d) { |
709 GrContext* context, | 702 SkPoint center1 = {d->fRandom->nextUScalar1(), d->fRandom->nextUScalar1()}; |
710 const GrCaps&, | |
711 GrTexture**) { | |
712 SkPoint center1 = {random->nextUScalar1(), random->nextUScalar1()}; | |
713 SkScalar radius1 = 0.f; | 703 SkScalar radius1 = 0.f; |
714 SkPoint center2; | 704 SkPoint center2; |
715 SkScalar radius2; | 705 SkScalar radius2; |
716 do { | 706 do { |
717 center2.set(random->nextUScalar1(), random->nextUScalar1()); | 707 center2.set(d->fRandom->nextUScalar1(), d->fRandom->nextUScalar1()); |
718 // Below makes sure radius2 is larger enouch such that the focal point | 708 // Below makes sure radius2 is larger enouch such that the focal point |
719 // is inside the end circle | 709 // is inside the end circle |
720 SkScalar increase = random->nextUScalar1(); | 710 SkScalar increase = d->fRandom->nextUScalar1(); |
721 SkPoint diff = center2 - center1; | 711 SkPoint diff = center2 - center1; |
722 SkScalar diffLen = diff.length(); | 712 SkScalar diffLen = diff.length(); |
723 radius2 = diffLen + increase; | 713 radius2 = diffLen + increase; |
724 // If the circles are identical the factory will give us an empty shader
. | 714 // If the circles are identical the factory will give us an empty shader
. |
725 } while (radius1 == radius2 && center1 == center2); | 715 } while (radius1 == radius2 && center1 == center2); |
726 | 716 |
727 SkColor colors[kMaxRandomGradientColors]; | 717 SkColor colors[kMaxRandomGradientColors]; |
728 SkScalar stopsArray[kMaxRandomGradientColors]; | 718 SkScalar stopsArray[kMaxRandomGradientColors]; |
729 SkScalar* stops = stopsArray; | 719 SkScalar* stops = stopsArray; |
730 SkShader::TileMode tm; | 720 SkShader::TileMode tm; |
731 int colorCount = RandomGradientParams(random, colors, &stops, &tm); | 721 int colorCount = RandomGradientParams(d->fRandom, colors, &stops, &tm); |
732 SkAutoTUnref<SkShader> shader(SkGradientShader::CreateTwoPointConical(center
1, radius1, | 722 SkAutoTUnref<SkShader> shader(SkGradientShader::CreateTwoPointConical(center
1, radius1, |
733 center
2, radius2, | 723 center
2, radius2, |
734 colors
, stops, colorCount, | 724 colors
, stops, colorCount, |
735 tm)); | 725 tm)); |
736 SkPaint paint; | 726 SkPaint paint; |
737 GrColor paintColor; | 727 GrColor paintColor; |
738 GrFragmentProcessor* fp; | 728 GrFragmentProcessor* fp; |
739 GrPaint grPaint; | 729 SkAssertResult(shader->asFragmentProcessor(d->fContext, paint, |
740 SkAssertResult(shader->asFragmentProcessor(context, paint, | 730 GrTest::TestMatrix(d->fRandom), N
ULL, |
741 GrTest::TestMatrix(random), NULL, | 731 &paintColor, d->fShaderDataManage
r, &fp)); |
742 &paintColor, grPaint.getShaderDat
aManager(), &fp)); | |
743 return fp; | 732 return fp; |
744 } | 733 } |
745 | 734 |
746 GLFocalInside2PtConicalEffect::GLFocalInside2PtConicalEffect(const GrProcessor&) | 735 GLFocalInside2PtConicalEffect::GLFocalInside2PtConicalEffect(const GrProcessor&) |
747 : fVSVaryingName(NULL) | 736 : fVSVaryingName(NULL) |
748 , fFSVaryingName(NULL) | 737 , fFSVaryingName(NULL) |
749 , fCachedFocal(SK_ScalarMax) {} | 738 , fCachedFocal(SK_ScalarMax) {} |
750 | 739 |
751 void GLFocalInside2PtConicalEffect::emitCode(GrGLFPBuilder* builder, | 740 void GLFocalInside2PtConicalEffect::emitCode(GrGLFPBuilder* builder, |
752 const GrFragmentProcessor& fp, | 741 const GrFragmentProcessor& fp, |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
958 | 947 |
959 GrGLFragmentProcessor* CircleInside2PtConicalEffect::createGLInstance() const { | 948 GrGLFragmentProcessor* CircleInside2PtConicalEffect::createGLInstance() const { |
960 return SkNEW_ARGS(GLCircleInside2PtConicalEffect, (*this)); | 949 return SkNEW_ARGS(GLCircleInside2PtConicalEffect, (*this)); |
961 } | 950 } |
962 | 951 |
963 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(CircleInside2PtConicalEffect); | 952 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(CircleInside2PtConicalEffect); |
964 | 953 |
965 /* | 954 /* |
966 * All Two point conical gradient test create functions may occasionally create
edge case shaders | 955 * All Two point conical gradient test create functions may occasionally create
edge case shaders |
967 */ | 956 */ |
968 GrFragmentProcessor* CircleInside2PtConicalEffect::TestCreate(SkRandom* random, | 957 GrFragmentProcessor* |
969 GrContext* context
, | 958 CircleInside2PtConicalEffect::TestCreate(GrProcessorTestData* d) { |
970 const GrCaps&, | 959 SkPoint center1 = {d->fRandom->nextUScalar1(), d->fRandom->nextUScalar1()}; |
971 GrTexture**) { | 960 SkScalar radius1 = d->fRandom->nextUScalar1() + 0.0001f; // make sure radius
1 != 0 |
972 SkPoint center1 = {random->nextUScalar1(), random->nextUScalar1()}; | |
973 SkScalar radius1 = random->nextUScalar1() + 0.0001f; // make sure radius1 !=
0 | |
974 SkPoint center2; | 961 SkPoint center2; |
975 SkScalar radius2; | 962 SkScalar radius2; |
976 do { | 963 do { |
977 center2.set(random->nextUScalar1(), random->nextUScalar1()); | 964 center2.set(d->fRandom->nextUScalar1(), d->fRandom->nextUScalar1()); |
978 // Below makes sure that circle one is contained within circle two | 965 // Below makes sure that circle one is contained within circle two |
979 SkScalar increase = random->nextUScalar1(); | 966 SkScalar increase = d->fRandom->nextUScalar1(); |
980 SkPoint diff = center2 - center1; | 967 SkPoint diff = center2 - center1; |
981 SkScalar diffLen = diff.length(); | 968 SkScalar diffLen = diff.length(); |
982 radius2 = radius1 + diffLen + increase; | 969 radius2 = radius1 + diffLen + increase; |
983 // If the circles are identical the factory will give us an empty shader
. | 970 // If the circles are identical the factory will give us an empty shader
. |
984 } while (radius1 == radius2 && center1 == center2); | 971 } while (radius1 == radius2 && center1 == center2); |
985 | 972 |
986 SkColor colors[kMaxRandomGradientColors]; | 973 SkColor colors[kMaxRandomGradientColors]; |
987 SkScalar stopsArray[kMaxRandomGradientColors]; | 974 SkScalar stopsArray[kMaxRandomGradientColors]; |
988 SkScalar* stops = stopsArray; | 975 SkScalar* stops = stopsArray; |
989 SkShader::TileMode tm; | 976 SkShader::TileMode tm; |
990 int colorCount = RandomGradientParams(random, colors, &stops, &tm); | 977 int colorCount = RandomGradientParams(d->fRandom, colors, &stops, &tm); |
991 SkAutoTUnref<SkShader> shader(SkGradientShader::CreateTwoPointConical(center
1, radius1, | 978 SkAutoTUnref<SkShader> shader(SkGradientShader::CreateTwoPointConical(center
1, radius1, |
992 center
2, radius2, | 979 center
2, radius2, |
993 colors
, stops, colorCount, | 980 colors
, stops, colorCount, |
994 tm)); | 981 tm)); |
995 SkPaint paint; | 982 SkPaint paint; |
996 GrColor paintColor; | 983 GrColor paintColor; |
997 GrFragmentProcessor* fp; | 984 GrFragmentProcessor* fp; |
998 GrPaint grPaint; | 985 SkAssertResult(shader->asFragmentProcessor(d->fContext, paint, |
999 SkAssertResult(shader->asFragmentProcessor(context, paint, | 986 GrTest::TestMatrix(d->fRandom), N
ULL, |
1000 GrTest::TestMatrix(random), NULL, | 987 &paintColor, d->fShaderDataManage
r, &fp)); |
1001 &paintColor, grPaint.getShaderDat
aManager(), &fp)); | |
1002 return fp; | 988 return fp; |
1003 } | 989 } |
1004 | 990 |
1005 GLCircleInside2PtConicalEffect::GLCircleInside2PtConicalEffect(const GrProcessor
& processor) | 991 GLCircleInside2PtConicalEffect::GLCircleInside2PtConicalEffect(const GrProcessor
& processor) |
1006 : fVSVaryingName(NULL) | 992 : fVSVaryingName(NULL) |
1007 , fFSVaryingName(NULL) | 993 , fFSVaryingName(NULL) |
1008 , fCachedCenterX(SK_ScalarMax) | 994 , fCachedCenterX(SK_ScalarMax) |
1009 , fCachedCenterY(SK_ScalarMax) | 995 , fCachedCenterY(SK_ScalarMax) |
1010 , fCachedA(SK_ScalarMax) | 996 , fCachedA(SK_ScalarMax) |
1011 , fCachedB(SK_ScalarMax) | 997 , fCachedB(SK_ScalarMax) |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1201 | 1187 |
1202 GrGLFragmentProcessor* CircleOutside2PtConicalEffect::createGLInstance() const { | 1188 GrGLFragmentProcessor* CircleOutside2PtConicalEffect::createGLInstance() const { |
1203 return SkNEW_ARGS(GLCircleOutside2PtConicalEffect, (*this)); | 1189 return SkNEW_ARGS(GLCircleOutside2PtConicalEffect, (*this)); |
1204 } | 1190 } |
1205 | 1191 |
1206 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(CircleOutside2PtConicalEffect); | 1192 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(CircleOutside2PtConicalEffect); |
1207 | 1193 |
1208 /* | 1194 /* |
1209 * All Two point conical gradient test create functions may occasionally create
edge case shaders | 1195 * All Two point conical gradient test create functions may occasionally create
edge case shaders |
1210 */ | 1196 */ |
1211 GrFragmentProcessor* CircleOutside2PtConicalEffect::TestCreate(SkRandom* random, | 1197 GrFragmentProcessor* CircleOutside2PtConicalEffect::TestCreate(GrProcessorTestDa
ta* d) { |
1212 GrContext* contex
t, | 1198 SkPoint center1 = {d->fRandom->nextUScalar1(), d->fRandom->nextUScalar1()}; |
1213 const GrCaps&, | 1199 SkScalar radius1 = d->fRandom->nextUScalar1() + 0.0001f; // make sure radius
1 != 0 |
1214 GrTexture**) { | |
1215 SkPoint center1 = {random->nextUScalar1(), random->nextUScalar1()}; | |
1216 SkScalar radius1 = random->nextUScalar1() + 0.0001f; // make sure radius1 !=
0 | |
1217 SkPoint center2; | 1200 SkPoint center2; |
1218 SkScalar radius2; | 1201 SkScalar radius2; |
1219 SkScalar diffLen; | 1202 SkScalar diffLen; |
1220 do { | 1203 do { |
1221 center2.set(random->nextUScalar1(), random->nextUScalar1()); | 1204 center2.set(d->fRandom->nextUScalar1(), d->fRandom->nextUScalar1()); |
1222 // If the circles share a center than we can't be in the outside case | 1205 // If the circles share a center than we can't be in the outside case |
1223 } while (center1 == center2); | 1206 } while (center1 == center2); |
1224 SkPoint diff = center2 - center1; | 1207 SkPoint diff = center2 - center1; |
1225 diffLen = diff.length(); | 1208 diffLen = diff.length(); |
1226 // Below makes sure that circle one is not contained within circle two | 1209 // Below makes sure that circle one is not contained within circle two |
1227 // and have radius2 >= radius to match sorting on cpu side | 1210 // and have radius2 >= radius to match sorting on cpu side |
1228 radius2 = radius1 + random->nextRangeF(0.f, diffLen); | 1211 radius2 = radius1 + d->fRandom->nextRangeF(0.f, diffLen); |
1229 | 1212 |
1230 SkColor colors[kMaxRandomGradientColors]; | 1213 SkColor colors[kMaxRandomGradientColors]; |
1231 SkScalar stopsArray[kMaxRandomGradientColors]; | 1214 SkScalar stopsArray[kMaxRandomGradientColors]; |
1232 SkScalar* stops = stopsArray; | 1215 SkScalar* stops = stopsArray; |
1233 SkShader::TileMode tm; | 1216 SkShader::TileMode tm; |
1234 int colorCount = RandomGradientParams(random, colors, &stops, &tm); | 1217 int colorCount = RandomGradientParams(d->fRandom, colors, &stops, &tm); |
1235 SkAutoTUnref<SkShader> shader(SkGradientShader::CreateTwoPointConical(center
1, radius1, | 1218 SkAutoTUnref<SkShader> shader(SkGradientShader::CreateTwoPointConical(center
1, radius1, |
1236 center
2, radius2, | 1219 center
2, radius2, |
1237 colors
, stops, colorCount, | 1220 colors
, stops, colorCount, |
1238 tm)); | 1221 tm)); |
1239 SkPaint paint; | 1222 SkPaint paint; |
1240 GrColor paintColor; | 1223 GrColor paintColor; |
1241 GrFragmentProcessor* fp; | 1224 GrFragmentProcessor* fp; |
1242 GrPaint grPaint; | 1225 SkAssertResult(shader->asFragmentProcessor(d->fContext, paint, |
1243 SkAssertResult(shader->asFragmentProcessor(context, paint, | 1226 GrTest::TestMatrix(d->fRandom), N
ULL, |
1244 GrTest::TestMatrix(random), NULL, | 1227 &paintColor, d->fShaderDataManage
r, &fp)); |
1245 &paintColor, grPaint.getShaderDat
aManager(), &fp)); | |
1246 return fp; | 1228 return fp; |
1247 } | 1229 } |
1248 | 1230 |
1249 GLCircleOutside2PtConicalEffect::GLCircleOutside2PtConicalEffect(const GrProcess
or& processor) | 1231 GLCircleOutside2PtConicalEffect::GLCircleOutside2PtConicalEffect(const GrProcess
or& processor) |
1250 : fVSVaryingName(NULL) | 1232 : fVSVaryingName(NULL) |
1251 , fFSVaryingName(NULL) | 1233 , fFSVaryingName(NULL) |
1252 , fCachedCenterX(SK_ScalarMax) | 1234 , fCachedCenterX(SK_ScalarMax) |
1253 , fCachedCenterY(SK_ScalarMax) | 1235 , fCachedCenterY(SK_ScalarMax) |
1254 , fCachedA(SK_ScalarMax) | 1236 , fCachedA(SK_ScalarMax) |
1255 , fCachedB(SK_ScalarMax) | 1237 , fCachedB(SK_ScalarMax) |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1397 } else if (type == kEdge_ConicalType) { | 1379 } else if (type == kEdge_ConicalType) { |
1398 set_matrix_edge_conical(shader, &matrix); | 1380 set_matrix_edge_conical(shader, &matrix); |
1399 return Edge2PtConicalEffect::Create(ctx, shaderDataManager, shader, matr
ix, tm); | 1381 return Edge2PtConicalEffect::Create(ctx, shaderDataManager, shader, matr
ix, tm); |
1400 } else { | 1382 } else { |
1401 return CircleOutside2PtConicalEffect::Create(ctx, shaderDataManager, sha
der, matrix, tm, | 1383 return CircleOutside2PtConicalEffect::Create(ctx, shaderDataManager, sha
der, matrix, tm, |
1402 info); | 1384 info); |
1403 } | 1385 } |
1404 } | 1386 } |
1405 | 1387 |
1406 #endif | 1388 #endif |
OLD | NEW |