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