| 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 |
| 11 #include "SkTwoPointConicalGradient.h" | 11 #include "SkTwoPointConicalGradient.h" |
| 12 | 12 |
| 13 #if SK_SUPPORT_GPU | 13 #if SK_SUPPORT_GPU |
| 14 #include "GrTBackendEffectFactory.h" | 14 #include "GrTBackendEffectFactory.h" |
| 15 // For brevity | 15 // For brevity |
| 16 typedef GrGLUniformManager::UniformHandle UniformHandle; | 16 typedef GrGLUniformManager::UniformHandle UniformHandle; |
| 17 | 17 |
| 18 static const SkScalar kErrorTol = 0.00001; | 18 static const SkScalar kErrorTol = 0.00001f; |
| 19 | 19 |
| 20 /** | 20 /** |
| 21 * We have three general cases for 2pt conical gradients. First we always assume
that | 21 * We have three general cases for 2pt conical gradients. First we always assume
that |
| 22 * the start radius <= end radius. Our first case (kInside_) is when the start c
ircle | 22 * the start radius <= end radius. Our first case (kInside_) is when the start c
ircle |
| 23 * is completely enclosed by the end circle. The second case (kOutside_) is the
case | 23 * is completely enclosed by the end circle. The second case (kOutside_) is the
case |
| 24 * when the start circle is either completely outside the end circle or the circ
les | 24 * when the start circle is either completely outside the end circle or the circ
les |
| 25 * overlap. The final case (kEdge_) is when the start circle is inside the end o
ne, | 25 * overlap. The final case (kEdge_) is when the start circle is inside the end o
ne, |
| 26 * but the two are just barely touching at 1 point along their edges. | 26 * but the two are just barely touching at 1 point along their edges. |
| 27 */ | 27 */ |
| 28 enum ConicalType { | 28 enum ConicalType { |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 298 | 298 |
| 299 static ConicalType set_matrix_focal_conical(const SkTwoPointConicalGradient& sha
der, | 299 static ConicalType set_matrix_focal_conical(const SkTwoPointConicalGradient& sha
der, |
| 300 SkMatrix* invLMatrix, SkScalar* foca
lX) { | 300 SkMatrix* invLMatrix, SkScalar* foca
lX) { |
| 301 // Inverse of the current local matrix is passed in then, | 301 // Inverse of the current local matrix is passed in then, |
| 302 // translate, scale, and rotate such that endCircle is unit circle on x-axis
, | 302 // translate, scale, and rotate such that endCircle is unit circle on x-axis
, |
| 303 // and focal point is at the origin. | 303 // and focal point is at the origin. |
| 304 ConicalType conicalType; | 304 ConicalType conicalType; |
| 305 const SkPoint& focal = shader.getStartCenter(); | 305 const SkPoint& focal = shader.getStartCenter(); |
| 306 const SkPoint& centerEnd = shader.getEndCenter(); | 306 const SkPoint& centerEnd = shader.getEndCenter(); |
| 307 SkScalar radius = shader.getEndRadius(); | 307 SkScalar radius = shader.getEndRadius(); |
| 308 SkScalar invRadius = 1.0 / radius; | 308 SkScalar invRadius = 1.f / radius; |
| 309 | 309 |
| 310 SkMatrix matrix; | 310 SkMatrix matrix; |
| 311 | 311 |
| 312 matrix.setTranslate(-centerEnd.fX, -centerEnd.fY); | 312 matrix.setTranslate(-centerEnd.fX, -centerEnd.fY); |
| 313 matrix.postScale(invRadius, invRadius); | 313 matrix.postScale(invRadius, invRadius); |
| 314 | 314 |
| 315 SkPoint focalTrans; | 315 SkPoint focalTrans; |
| 316 matrix.mapPoints(&focalTrans, &focal, 1); | 316 matrix.mapPoints(&focalTrans, &focal, 1); |
| 317 *focalX = focalTrans.length(); | 317 *focalX = focalTrans.length(); |
| 318 | 318 |
| 319 if (0.0 != *focalX) { | 319 if (0.f != *focalX) { |
| 320 SkScalar invFocalX = SkScalarInvert(*focalX); | 320 SkScalar invFocalX = SkScalarInvert(*focalX); |
| 321 SkMatrix rot; | 321 SkMatrix rot; |
| 322 rot.setSinCos(-SkScalarMul(invFocalX, focalTrans.fY), | 322 rot.setSinCos(-SkScalarMul(invFocalX, focalTrans.fY), |
| 323 SkScalarMul(invFocalX, focalTrans.fX)); | 323 SkScalarMul(invFocalX, focalTrans.fX)); |
| 324 matrix.postConcat(rot); | 324 matrix.postConcat(rot); |
| 325 } | 325 } |
| 326 | 326 |
| 327 matrix.postTranslate(-(*focalX), 0.0); | 327 matrix.postTranslate(-(*focalX), 0.f); |
| 328 | 328 |
| 329 // If the focal point is touching the edge of the circle it will | 329 // If the focal point is touching the edge of the circle it will |
| 330 // cause a degenerate case that must be handled separately | 330 // cause a degenerate case that must be handled separately |
| 331 // 5 * kErrorTol was picked after manual testing the stability trade off | 331 // 5 * kErrorTol was picked after manual testing the stability trade off |
| 332 // versus the linear approx used in the Edge Shader | 332 // versus the linear approx used in the Edge Shader |
| 333 if (SkScalarAbs(1.0 - (*focalX)) < 5 * kErrorTol) { | 333 if (SkScalarAbs(1.f - (*focalX)) < 5 * kErrorTol) { |
| 334 return kEdge_ConicalType; | 334 return kEdge_ConicalType; |
| 335 } | 335 } |
| 336 | 336 |
| 337 // Scale factor 1 / (1 - focalX * focalX) | 337 // Scale factor 1 / (1 - focalX * focalX) |
| 338 SkScalar oneMinusF2 = 1.0 - SkScalarMul(*focalX, *focalX); | 338 SkScalar oneMinusF2 = 1.f - SkScalarMul(*focalX, *focalX); |
| 339 SkScalar s = SkScalarDiv(1.0, oneMinusF2); | 339 SkScalar s = SkScalarDiv(1.f, oneMinusF2); |
| 340 | 340 |
| 341 | 341 |
| 342 if (s >= 0.0) { | 342 if (s >= 0.f) { |
| 343 conicalType = kInside_ConicalType; | 343 conicalType = kInside_ConicalType; |
| 344 matrix.postScale(s, s * SkScalarSqrt(oneMinusF2)); | 344 matrix.postScale(s, s * SkScalarSqrt(oneMinusF2)); |
| 345 } else { | 345 } else { |
| 346 conicalType = kOutside_ConicalType; | 346 conicalType = kOutside_ConicalType; |
| 347 matrix.postScale(s, s); | 347 matrix.postScale(s, s); |
| 348 } | 348 } |
| 349 | 349 |
| 350 invLMatrix->postConcat(matrix); | 350 invLMatrix->postConcat(matrix); |
| 351 | 351 |
| 352 return conicalType; | 352 return conicalType; |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 441 return GrTBackendEffectFactory<FocalOutside2PtConicalEffect>::getInstance(); | 441 return GrTBackendEffectFactory<FocalOutside2PtConicalEffect>::getInstance(); |
| 442 } | 442 } |
| 443 | 443 |
| 444 GR_DEFINE_EFFECT_TEST(FocalOutside2PtConicalEffect); | 444 GR_DEFINE_EFFECT_TEST(FocalOutside2PtConicalEffect); |
| 445 | 445 |
| 446 GrEffectRef* FocalOutside2PtConicalEffect::TestCreate(SkRandom* random, | 446 GrEffectRef* FocalOutside2PtConicalEffect::TestCreate(SkRandom* random, |
| 447 GrContext* context, | 447 GrContext* context, |
| 448 const GrDrawTargetCaps&, | 448 const GrDrawTargetCaps&, |
| 449 GrTexture**) { | 449 GrTexture**) { |
| 450 SkPoint center1 = {random->nextUScalar1(), random->nextUScalar1()}; | 450 SkPoint center1 = {random->nextUScalar1(), random->nextUScalar1()}; |
| 451 SkScalar radius1 = 0.0; | 451 SkScalar radius1 = 0.f; |
| 452 SkPoint center2; | 452 SkPoint center2; |
| 453 SkScalar radius2; | 453 SkScalar radius2; |
| 454 do { | 454 do { |
| 455 center2.set(random->nextUScalar1(), random->nextUScalar1()); | 455 center2.set(random->nextUScalar1(), random->nextUScalar1()); |
| 456 // Need to make sure the centers are not the same or else focal point wi
ll be inside | 456 // Need to make sure the centers are not the same or else focal point wi
ll be inside |
| 457 } while (center1 == center2); | 457 } while (center1 == center2); |
| 458 SkPoint diff = center2 - center1; | 458 SkPoint diff = center2 - center1; |
| 459 SkScalar diffLen = diff.length(); | 459 SkScalar diffLen = diff.length(); |
| 460 // Below makes sure that the focal point is not contained within circle
two | 460 // Below makes sure that the focal point is not contained within circle
two |
| 461 radius2 = random->nextRangeF(0.0, diffLen); | 461 radius2 = random->nextRangeF(0.f, diffLen); |
| 462 | 462 |
| 463 SkColor colors[kMaxRandomGradientColors]; | 463 SkColor colors[kMaxRandomGradientColors]; |
| 464 SkScalar stopsArray[kMaxRandomGradientColors]; | 464 SkScalar stopsArray[kMaxRandomGradientColors]; |
| 465 SkScalar* stops = stopsArray; | 465 SkScalar* stops = stopsArray; |
| 466 SkShader::TileMode tm; | 466 SkShader::TileMode tm; |
| 467 int colorCount = RandomGradientParams(random, colors, &stops, &tm); | 467 int colorCount = RandomGradientParams(random, colors, &stops, &tm); |
| 468 SkAutoTUnref<SkShader> shader(SkGradientShader::CreateTwoPointConical(center
1, radius1, | 468 SkAutoTUnref<SkShader> shader(SkGradientShader::CreateTwoPointConical(center
1, radius1, |
| 469 center
2, radius2, | 469 center
2, radius2, |
| 470 colors
, stops, colorCount, | 470 colors
, stops, colorCount, |
| 471 tm)); | 471 tm)); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 531 } | 531 } |
| 532 | 532 |
| 533 void GLFocalOutside2PtConicalEffect::setData(const GrGLUniformManager& uman, | 533 void GLFocalOutside2PtConicalEffect::setData(const GrGLUniformManager& uman, |
| 534 const GrDrawEffect& drawEffect) { | 534 const GrDrawEffect& drawEffect) { |
| 535 INHERITED::setData(uman, drawEffect); | 535 INHERITED::setData(uman, drawEffect); |
| 536 const FocalOutside2PtConicalEffect& data = drawEffect.castEffect<FocalOutsid
e2PtConicalEffect>(); | 536 const FocalOutside2PtConicalEffect& data = drawEffect.castEffect<FocalOutsid
e2PtConicalEffect>(); |
| 537 SkASSERT(data.isFlipped() == fIsFlipped); | 537 SkASSERT(data.isFlipped() == fIsFlipped); |
| 538 SkScalar focal = data.focal(); | 538 SkScalar focal = data.focal(); |
| 539 | 539 |
| 540 if (fCachedFocal != focal) { | 540 if (fCachedFocal != focal) { |
| 541 SkScalar oneMinus2F = 1.0 - SkScalarMul(focal, focal); | 541 SkScalar oneMinus2F = 1.f - SkScalarMul(focal, focal); |
| 542 | 542 |
| 543 float values[2] = { | 543 float values[2] = { |
| 544 SkScalarToFloat(focal), | 544 SkScalarToFloat(focal), |
| 545 SkScalarToFloat(oneMinus2F), | 545 SkScalarToFloat(oneMinus2F), |
| 546 }; | 546 }; |
| 547 | 547 |
| 548 uman.set1fv(fParamUni, 2, values); | 548 uman.set1fv(fParamUni, 2, values); |
| 549 fCachedFocal = focal; | 549 fCachedFocal = focal; |
| 550 } | 550 } |
| 551 } | 551 } |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 648 return GrTBackendEffectFactory<FocalInside2PtConicalEffect>::getInstance(); | 648 return GrTBackendEffectFactory<FocalInside2PtConicalEffect>::getInstance(); |
| 649 } | 649 } |
| 650 | 650 |
| 651 GR_DEFINE_EFFECT_TEST(FocalInside2PtConicalEffect); | 651 GR_DEFINE_EFFECT_TEST(FocalInside2PtConicalEffect); |
| 652 | 652 |
| 653 GrEffectRef* FocalInside2PtConicalEffect::TestCreate(SkRandom* random, | 653 GrEffectRef* FocalInside2PtConicalEffect::TestCreate(SkRandom* random, |
| 654 GrContext* context, | 654 GrContext* context, |
| 655 const GrDrawTargetCaps&, | 655 const GrDrawTargetCaps&, |
| 656 GrTexture**) { | 656 GrTexture**) { |
| 657 SkPoint center1 = {random->nextUScalar1(), random->nextUScalar1()}; | 657 SkPoint center1 = {random->nextUScalar1(), random->nextUScalar1()}; |
| 658 SkScalar radius1 = 0.0; | 658 SkScalar radius1 = 0.f; |
| 659 SkPoint center2; | 659 SkPoint center2; |
| 660 SkScalar radius2; | 660 SkScalar radius2; |
| 661 do { | 661 do { |
| 662 center2.set(random->nextUScalar1(), random->nextUScalar1()); | 662 center2.set(random->nextUScalar1(), random->nextUScalar1()); |
| 663 // Below makes sure radius2 is larger enouch such that the focal point | 663 // Below makes sure radius2 is larger enouch such that the focal point |
| 664 // is inside the end circle | 664 // is inside the end circle |
| 665 SkScalar increase = random->nextUScalar1(); | 665 SkScalar increase = random->nextUScalar1(); |
| 666 SkPoint diff = center2 - center1; | 666 SkPoint diff = center2 - center1; |
| 667 SkScalar diffLen = diff.length(); | 667 SkScalar diffLen = diff.length(); |
| 668 radius2 = diffLen + increase; | 668 radius2 = diffLen + increase; |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 751 // translate and scale such that start circle is on the origin and has radiu
s 1 | 751 // translate and scale such that start circle is on the origin and has radiu
s 1 |
| 752 const SkPoint& centerStart = shader.getStartCenter(); | 752 const SkPoint& centerStart = shader.getStartCenter(); |
| 753 const SkPoint& centerEnd = shader.getEndCenter(); | 753 const SkPoint& centerEnd = shader.getEndCenter(); |
| 754 SkScalar radiusStart = shader.getStartRadius(); | 754 SkScalar radiusStart = shader.getStartRadius(); |
| 755 SkScalar radiusEnd = shader.getEndRadius(); | 755 SkScalar radiusEnd = shader.getEndRadius(); |
| 756 | 756 |
| 757 SkMatrix matrix; | 757 SkMatrix matrix; |
| 758 | 758 |
| 759 matrix.setTranslate(-centerStart.fX, -centerStart.fY); | 759 matrix.setTranslate(-centerStart.fX, -centerStart.fY); |
| 760 | 760 |
| 761 SkScalar invStartRad = 1.0 / radiusStart; | 761 SkScalar invStartRad = 1.f / radiusStart; |
| 762 matrix.postScale(invStartRad, invStartRad); | 762 matrix.postScale(invStartRad, invStartRad); |
| 763 | 763 |
| 764 radiusEnd /= radiusStart; | 764 radiusEnd /= radiusStart; |
| 765 | 765 |
| 766 SkPoint centerEndTrans; | 766 SkPoint centerEndTrans; |
| 767 matrix.mapPoints(¢erEndTrans, ¢erEnd, 1); | 767 matrix.mapPoints(¢erEndTrans, ¢erEnd, 1); |
| 768 | 768 |
| 769 SkScalar A = centerEndTrans.fX * centerEndTrans.fX + centerEndTrans.fY * cen
terEndTrans.fY | 769 SkScalar A = centerEndTrans.fX * centerEndTrans.fX + centerEndTrans.fY * cen
terEndTrans.fY |
| 770 - radiusEnd * radiusEnd + 2 * radiusEnd - 1; | 770 - radiusEnd * radiusEnd + 2 * radiusEnd - 1; |
| 771 | 771 |
| 772 // Check to see if start circle is inside end circle with edges touching. | 772 // Check to see if start circle is inside end circle with edges touching. |
| 773 // If touching we return that it is of kEdge_ConicalType, and leave the matr
ix setting | 773 // If touching we return that it is of kEdge_ConicalType, and leave the matr
ix setting |
| 774 // to the edge shader. 5 * kErrorTol was picked after manual testing so that
C = 1 / A | 774 // to the edge shader. 5 * kErrorTol was picked after manual testing so that
C = 1 / A |
| 775 // is stable, and the linear approximation used in the Edge shader is still
accurate. | 775 // is stable, and the linear approximation used in the Edge shader is still
accurate. |
| 776 if (SkScalarAbs(A) < 5 * kErrorTol) { | 776 if (SkScalarAbs(A) < 5 * kErrorTol) { |
| 777 return kEdge_ConicalType; | 777 return kEdge_ConicalType; |
| 778 } | 778 } |
| 779 | 779 |
| 780 SkScalar C = 1.0 / A; | 780 SkScalar C = 1.f / A; |
| 781 SkScalar B = (radiusEnd - 1.0) * C; | 781 SkScalar B = (radiusEnd - 1.f) * C; |
| 782 | 782 |
| 783 matrix.postScale(C, C); | 783 matrix.postScale(C, C); |
| 784 | 784 |
| 785 invLMatrix->postConcat(matrix); | 785 invLMatrix->postConcat(matrix); |
| 786 | 786 |
| 787 info->fCenterEnd = centerEndTrans; | 787 info->fCenterEnd = centerEndTrans; |
| 788 info->fA = A; | 788 info->fA = A; |
| 789 info->fB = B; | 789 info->fB = B; |
| 790 info->fC = C; | 790 info->fC = C; |
| 791 | 791 |
| 792 // if A ends up being negative, the start circle is contained completely ins
ide the end cirlce | 792 // if A ends up being negative, the start circle is contained completely ins
ide the end cirlce |
| 793 if (A < 0.0) { | 793 if (A < 0.f) { |
| 794 return kInside_ConicalType; | 794 return kInside_ConicalType; |
| 795 } | 795 } |
| 796 return kOutside_ConicalType; | 796 return kOutside_ConicalType; |
| 797 } | 797 } |
| 798 | 798 |
| 799 class GLCircleInside2PtConicalEffect; | 799 class GLCircleInside2PtConicalEffect; |
| 800 | 800 |
| 801 class CircleInside2PtConicalEffect : public GrGradientEffect { | 801 class CircleInside2PtConicalEffect : public GrGradientEffect { |
| 802 public: | 802 public: |
| 803 | 803 |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 890 return GrTBackendEffectFactory<CircleInside2PtConicalEffect>::getInstance(); | 890 return GrTBackendEffectFactory<CircleInside2PtConicalEffect>::getInstance(); |
| 891 } | 891 } |
| 892 | 892 |
| 893 GR_DEFINE_EFFECT_TEST(CircleInside2PtConicalEffect); | 893 GR_DEFINE_EFFECT_TEST(CircleInside2PtConicalEffect); |
| 894 | 894 |
| 895 GrEffectRef* CircleInside2PtConicalEffect::TestCreate(SkRandom* random, | 895 GrEffectRef* CircleInside2PtConicalEffect::TestCreate(SkRandom* random, |
| 896 GrContext* context, | 896 GrContext* context, |
| 897 const GrDrawTargetCaps&, | 897 const GrDrawTargetCaps&, |
| 898 GrTexture**) { | 898 GrTexture**) { |
| 899 SkPoint center1 = {random->nextUScalar1(), random->nextUScalar1()}; | 899 SkPoint center1 = {random->nextUScalar1(), random->nextUScalar1()}; |
| 900 SkScalar radius1 = random->nextUScalar1() + 0.0001; // make sure radius1 !=
0 | 900 SkScalar radius1 = random->nextUScalar1() + 0.0001f; // make sure radius1 !=
0 |
| 901 SkPoint center2; | 901 SkPoint center2; |
| 902 SkScalar radius2; | 902 SkScalar radius2; |
| 903 do { | 903 do { |
| 904 center2.set(random->nextUScalar1(), random->nextUScalar1()); | 904 center2.set(random->nextUScalar1(), random->nextUScalar1()); |
| 905 // Below makes sure that circle one is contained within circle two | 905 // Below makes sure that circle one is contained within circle two |
| 906 SkScalar increase = random->nextUScalar1(); | 906 SkScalar increase = random->nextUScalar1(); |
| 907 SkPoint diff = center2 - center1; | 907 SkPoint diff = center2 - center1; |
| 908 SkScalar diffLen = diff.length(); | 908 SkScalar diffLen = diff.length(); |
| 909 radius2 = radius1 + diffLen + increase; | 909 radius2 = radius1 + diffLen + increase; |
| 910 // If the circles are identical the factory will give us an empty shader
. | 910 // If the circles are identical the factory will give us an empty shader
. |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1117 return GrTBackendEffectFactory<CircleOutside2PtConicalEffect>::getInstance()
; | 1117 return GrTBackendEffectFactory<CircleOutside2PtConicalEffect>::getInstance()
; |
| 1118 } | 1118 } |
| 1119 | 1119 |
| 1120 GR_DEFINE_EFFECT_TEST(CircleOutside2PtConicalEffect); | 1120 GR_DEFINE_EFFECT_TEST(CircleOutside2PtConicalEffect); |
| 1121 | 1121 |
| 1122 GrEffectRef* CircleOutside2PtConicalEffect::TestCreate(SkRandom* random, | 1122 GrEffectRef* CircleOutside2PtConicalEffect::TestCreate(SkRandom* random, |
| 1123 GrContext* context, | 1123 GrContext* context, |
| 1124 const GrDrawTargetCaps&, | 1124 const GrDrawTargetCaps&, |
| 1125 GrTexture**) { | 1125 GrTexture**) { |
| 1126 SkPoint center1 = {random->nextUScalar1(), random->nextUScalar1()}; | 1126 SkPoint center1 = {random->nextUScalar1(), random->nextUScalar1()}; |
| 1127 SkScalar radius1 = random->nextUScalar1() + 0.0001; // make sure radius1 !=
0 | 1127 SkScalar radius1 = random->nextUScalar1() + 0.0001f; // make sure radius1 !=
0 |
| 1128 SkPoint center2; | 1128 SkPoint center2; |
| 1129 SkScalar radius2; | 1129 SkScalar radius2; |
| 1130 SkScalar diffLen; | 1130 SkScalar diffLen; |
| 1131 do { | 1131 do { |
| 1132 center2.set(random->nextUScalar1(), random->nextUScalar1()); | 1132 center2.set(random->nextUScalar1(), random->nextUScalar1()); |
| 1133 // If the circles share a center than we can't be in the outside case | 1133 // If the circles share a center than we can't be in the outside case |
| 1134 } while (center1 == center2); | 1134 } while (center1 == center2); |
| 1135 SkPoint diff = center2 - center1; | 1135 SkPoint diff = center2 - center1; |
| 1136 diffLen = diff.length(); | 1136 diffLen = diff.length(); |
| 1137 // Below makes sure that circle one is not contained within circle two | 1137 // Below makes sure that circle one is not contained within circle two |
| 1138 // and have radius2 >= radius to match sorting on cpu side | 1138 // and have radius2 >= radius to match sorting on cpu side |
| 1139 radius2 = radius1 + random->nextRangeF(0.0, diffLen); | 1139 radius2 = radius1 + random->nextRangeF(0.f, diffLen); |
| 1140 | 1140 |
| 1141 SkColor colors[kMaxRandomGradientColors]; | 1141 SkColor colors[kMaxRandomGradientColors]; |
| 1142 SkScalar stopsArray[kMaxRandomGradientColors]; | 1142 SkScalar stopsArray[kMaxRandomGradientColors]; |
| 1143 SkScalar* stops = stopsArray; | 1143 SkScalar* stops = stopsArray; |
| 1144 SkShader::TileMode tm; | 1144 SkShader::TileMode tm; |
| 1145 int colorCount = RandomGradientParams(random, colors, &stops, &tm); | 1145 int colorCount = RandomGradientParams(random, colors, &stops, &tm); |
| 1146 SkAutoTUnref<SkShader> shader(SkGradientShader::CreateTwoPointConical(center
1, radius1, | 1146 SkAutoTUnref<SkShader> shader(SkGradientShader::CreateTwoPointConical(center
1, radius1, |
| 1147 center
2, radius2, | 1147 center
2, radius2, |
| 1148 colors
, stops, colorCount, | 1148 colors
, stops, colorCount, |
| 1149 tm)); | 1149 tm)); |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1293 return CircleInside2PtConicalEffect::Create(ctx, shader, matrix, tm, inf
o); | 1293 return CircleInside2PtConicalEffect::Create(ctx, shader, matrix, tm, inf
o); |
| 1294 } else if (type == kEdge_ConicalType) { | 1294 } else if (type == kEdge_ConicalType) { |
| 1295 set_matrix_edge_conical(shader, &matrix); | 1295 set_matrix_edge_conical(shader, &matrix); |
| 1296 return Edge2PtConicalEffect::Create(ctx, shader, matrix, tm); | 1296 return Edge2PtConicalEffect::Create(ctx, shader, matrix, tm); |
| 1297 } else { | 1297 } else { |
| 1298 return CircleOutside2PtConicalEffect::Create(ctx, shader, matrix, tm, in
fo); | 1298 return CircleOutside2PtConicalEffect::Create(ctx, shader, matrix, tm, in
fo); |
| 1299 } | 1299 } |
| 1300 } | 1300 } |
| 1301 | 1301 |
| 1302 #endif | 1302 #endif |
| OLD | NEW |