Revert "Fix div-by-zero loophole in gradient factory func"
This reverts commit c34dd6c526
.
Reason for revert: Speculative fix for Chrome roll (gradient layout test failures)
Original change's description:
> Fix div-by-zero loophole in gradient factory func
>
> Bug: oss-fuzz:10373
> Change-Id: I4277fb63e3186ee34feaf09ecf6aeddeb532f9c1
> Reviewed-on: https://skia-review.googlesource.com/c/168269
> Reviewed-by: Kevin Lubick <kjlubick@google.com>
> Commit-Queue: Michael Ludwig <michaelludwig@google.com>
TBR=jvanverth@google.com,kjlubick@google.com,michaelludwig@google.com
Change-Id: I6333390d2ecc559ad98bd4d734ab1c674e23037f
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: oss-fuzz:10373
Reviewed-on: https://skia-review.googlesource.com/c/168460
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
This commit is contained in:
parent
422f95bce8
commit
2dfab27d69
@ -694,23 +694,19 @@ sk_sp<SkShader> SkGradientShader::MakeTwoPointConical(const SkPoint& start,
|
|||||||
if (startRadius < 0 || endRadius < 0) {
|
if (startRadius < 0 || endRadius < 0) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
if (SkScalarNearlyZero((start - end).length())) {
|
if (SkScalarNearlyZero((start - end).length()) && SkScalarNearlyZero(startRadius)) {
|
||||||
// If the center positions are the same, then the gradient is the radial variant of a
|
|
||||||
// 2 pt conical gradient, or an actual radial gradient (startRadius == 0), or it is
|
|
||||||
// fully degenerate (startRadius == endRadius).
|
|
||||||
if (SkScalarNearlyEqual(startRadius, endRadius)) {
|
|
||||||
// Degenerate case
|
|
||||||
return SkShader::MakeEmptyShader();
|
|
||||||
} else if (SkScalarNearlyZero(startRadius)) {
|
|
||||||
// We can treat this gradient as radial, which is faster.
|
// We can treat this gradient as radial, which is faster.
|
||||||
return MakeRadial(start, endRadius, colors, std::move(colorSpace), pos, colorCount,
|
return MakeRadial(start, endRadius, colors, std::move(colorSpace), pos, colorCount,
|
||||||
mode, flags, localMatrix);
|
mode, flags, localMatrix);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (!valid_grad(colors, pos, colorCount, mode)) {
|
if (!valid_grad(colors, pos, colorCount, mode)) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
if (startRadius == endRadius) {
|
||||||
|
if (start == end || startRadius == 0) {
|
||||||
|
return SkShader::MakeEmptyShader();
|
||||||
|
}
|
||||||
|
}
|
||||||
if (localMatrix && !localMatrix->invert(nullptr)) {
|
if (localMatrix && !localMatrix->invert(nullptr)) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
@ -55,10 +55,8 @@ sk_sp<SkShader> SkTwoPointConicalGradient::Create(const SkPoint& c0, SkScalar r0
|
|||||||
Type gradientType;
|
Type gradientType;
|
||||||
|
|
||||||
if (SkScalarNearlyZero((c0 - c1).length())) {
|
if (SkScalarNearlyZero((c0 - c1).length())) {
|
||||||
if (SkScalarNearlyZero(SkTMax(r0, r1)) || SkScalarNearlyEqual(r0, r1)) {
|
if (SkScalarNearlyZero(SkTMax(r0, r1))) {
|
||||||
// Degenerate case; avoid dividing by zero. Should have been caught by caller but
|
return nullptr; // Degenerate case; avoid dividing by zero.
|
||||||
// just in case, recheck here.
|
|
||||||
return nullptr;
|
|
||||||
}
|
}
|
||||||
// Concentric case: we can pretend we're radial (with a tiny twist).
|
// Concentric case: we can pretend we're radial (with a tiny twist).
|
||||||
const SkScalar scale = sk_ieee_float_divide(1, SkTMax(r0, r1));
|
const SkScalar scale = sk_ieee_float_divide(1, SkTMax(r0, r1));
|
||||||
|
Loading…
Reference in New Issue
Block a user