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)); |