Fix conical test where r1 = r2 = 0

Bug: skia:7436
Change-Id: I0fdbd458d4e2da53e587be27ac90fbb2d32584e5
Reviewed-on: https://skia-review.googlesource.com/89520
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Yuqian Li <liyuqian@google.com>
This commit is contained in:
Yuqian Li 2017-12-27 11:31:46 -05:00 committed by Skia Commit-Bot
parent 047ae27431
commit 7a4d067d88

View File

@ -172,10 +172,23 @@ std::unique_ptr<GrFragmentProcessor> TwoPointConicalEffect::TestCreate(
int type = mask & kTestTypeMask;
if (type == TwoPointConicalEffect::kRadial_Type) {
center2 = center1;
// Make sure that the radii are different
if (SkScalarNearlyZero(radius1 - radius2)) {
radius2 += .1f;
}
} else if (type == TwoPointConicalEffect::kStrip_Type) {
radius1 = SkTMax(radius1, .1f); // Make sure that the radius is non-zero
radius2 = radius1;
// Make sure that the centers are different
if (SkScalarNearlyZero(SkPoint::Distance(center1, center2))) {
center2.fX += .1f;
}
} else { // kFocal_Type
// Make sure that the centers are different
if (SkScalarNearlyZero(SkPoint::Distance(center1, center2))) {
center2.fX += .1f;
}
if (kTestNativelyFocalBit & mask) {
radius1 = 0;
}
@ -186,12 +199,18 @@ std::unique_ptr<GrFragmentProcessor> TwoPointConicalEffect::TestCreate(
std::swap(radius1, radius2);
radius2 = 0;
}
// Make sure that the radii are different
if (SkScalarNearlyZero(radius1 - radius2)) {
radius2 += .1f;
}
}
if (SkScalarNearlyZero(radius1 - radius2) &&
SkScalarNearlyZero(SkPoint::Distance(center1, center2))) {
radius2 += .1f; // make sure that we're not degenerated
}
RandomGradientParams params(d->fRandom);
auto shader = params.fUseColors4f ?
SkGradientShader::MakeTwoPointConical(center1, radius1, center2, radius2,