Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(128)

Unified Diff: src/core/SkRRect.cpp

Issue 913743002: check for nonfinites in rrects (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: update test for nonfinites Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « include/core/SkScalar.h ('k') | tests/PathTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkRRect.cpp
diff --git a/src/core/SkRRect.cpp b/src/core/SkRRect.cpp
index 52b1486a759c5116864c1d3c78091a177522b3ea..d3dce98ad5f103ddade09c219c4e09a117d2f884 100644
--- a/src/core/SkRRect.cpp
+++ b/src/core/SkRRect.cpp
@@ -11,11 +11,14 @@
///////////////////////////////////////////////////////////////////////////////
void SkRRect::setRectXY(const SkRect& rect, SkScalar xRad, SkScalar yRad) {
- if (rect.isEmpty()) {
+ if (rect.isEmpty() || !rect.isFinite()) {
this->setEmpty();
return;
}
+ if (!SkScalarsAreFinite(xRad, yRad)) {
+ xRad = yRad = 0; // devolve into a simple rect
+ }
if (xRad <= 0 || yRad <= 0) {
// all corners are square in this case
this->setRect(rect);
@@ -45,11 +48,17 @@ void SkRRect::setRectXY(const SkRect& rect, SkScalar xRad, SkScalar yRad) {
void SkRRect::setNinePatch(const SkRect& rect, SkScalar leftRad, SkScalar topRad,
SkScalar rightRad, SkScalar bottomRad) {
- if (rect.isEmpty()) {
+ if (rect.isEmpty() || !rect.isFinite()) {
this->setEmpty();
return;
}
+ const SkScalar array[4] = { leftRad, topRad, rightRad, bottomRad };
+ if (!SkScalarsAreFinite(array, 4)) {
+ this->setRect(rect); // devolve into a simple rect
+ return;
+ }
+
leftRad = SkMaxScalar(leftRad, 0);
topRad = SkMaxScalar(topRad, 0);
rightRad = SkMaxScalar(rightRad, 0);
@@ -125,11 +134,16 @@ static SkScalar clamp_radius_sub(SkScalar rad, SkScalar min, SkScalar max) {
}
void SkRRect::setRectRadii(const SkRect& rect, const SkVector radii[4]) {
- if (rect.isEmpty()) {
+ if (rect.isEmpty() || !rect.isFinite()) {
this->setEmpty();
return;
}
+ if (!SkScalarsAreFinite(&radii[0].fX, 8)) {
+ this->setRect(rect); // devolve into a simple rect
+ return;
+ }
+
fRect = rect;
memcpy(fRadii, radii, sizeof(fRadii));
« no previous file with comments | « include/core/SkScalar.h ('k') | tests/PathTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698