[Reland] Fix SkTwoPointConicalGradient zero-radius handling
r == 0 is within valid gradient range, we shouldn't skip it.
BUG=skia:5023
R=caryclark@google.com,reed@google.com
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1756573002
Committed: https://skia.googlesource.com/skia/+/9c0b02a557e9be663a0eb07519e1b6a61a6c3df2
Review URL: https://codereview.chromium.org/1756573002
diff --git a/src/effects/gradients/SkGradientShader.cpp b/src/effects/gradients/SkGradientShader.cpp
index 5444c1c..985d459 100644
--- a/src/effects/gradients/SkGradientShader.cpp
+++ b/src/effects/gradients/SkGradientShader.cpp
@@ -840,8 +840,10 @@
if (!valid_grad(colors, pos, colorCount, mode)) {
return nullptr;
}
- if (start == end && startRadius == endRadius) {
- return SkShader::CreateEmptyShader();
+ if (startRadius == endRadius) {
+ if (start == end || startRadius == 0) {
+ return SkShader::CreateEmptyShader();
+ }
}
EXPAND_1_COLOR(colorCount);
diff --git a/src/effects/gradients/SkTwoPointConicalGradient.cpp b/src/effects/gradients/SkTwoPointConicalGradient.cpp
index b938ebd..2209306 100644
--- a/src/effects/gradients/SkTwoPointConicalGradient.cpp
+++ b/src/effects/gradients/SkTwoPointConicalGradient.cpp
@@ -122,10 +122,10 @@
// find_quad_roots returns the values sorted, so we start with the last
float t = roots[countRoots - 1];
float r = lerp(fRec.fRadius, fRec.fDRadius, t);
- if (r <= 0) {
+ if (r < 0) {
t = roots[0]; // might be the same as roots[countRoots-1]
r = lerp(fRec.fRadius, fRec.fDRadius, t);
- if (r <= 0) {
+ if (r < 0) {
return TwoPtRadial::kDontDrawT;
}
}