Check SkRRect::transform result, don't assume S+T matrix is safe

Bug: chromium:1132739
Change-Id: I67b7ac535232925e98e44c0bb90964fded9f4d05
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/320068
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
This commit is contained in:
Michael Ludwig 2020-09-28 11:24:05 -04:00 committed by Skia Commit-Bot
parent 9c983682e4
commit 3dad80308d

View File

@ -570,16 +570,19 @@ void GrClipStack::RawElement::simplify(const SkIRect& deviceBounds, bool forceAA
SkASSERT(fOuterBounds.contains(fInnerBounds) || fInnerBounds.isEmpty());
}
} else if (fShape.isRRect()) {
// Can't transform in place
SkRRect src = fShape.rrect();
SkAssertResult(src.transform(fLocalToDevice, &fShape.rrect()));
fLocalToDevice.setIdentity();
fDeviceToLocal.setIdentity();
// Can't transform in place and must still check transform result since some very
// ill-formed scale+translate matrices can cause invalid rrect radii.
SkRRect src;
if (fShape.rrect().transform(fLocalToDevice, &src)) {
fShape.rrect() = src;
fLocalToDevice.setIdentity();
fDeviceToLocal.setIdentity();
SkRect inner = SkRRectPriv::InnerBounds(fShape.rrect());
fInnerBounds = GrClip::GetPixelIBounds(inner, fAA, BoundsType::kInterior);
if (!fInnerBounds.intersect(deviceBounds)) {
fInnerBounds = SkIRect::MakeEmpty();
SkRect inner = SkRRectPriv::InnerBounds(fShape.rrect());
fInnerBounds = GrClip::GetPixelIBounds(inner, fAA, BoundsType::kInterior);
if (!fInnerBounds.intersect(deviceBounds)) {
fInnerBounds = SkIRect::MakeEmpty();
}
}
}
}