aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/core/SkRRect.h
diff options
context:
space:
mode:
authorGravatar Brian Salomon <bsalomon@google.com>2017-09-20 11:05:49 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-09-20 15:24:43 +0000
commitfb6a7891915014092eebb874d0655dc886019414 (patch)
tree5e82d7288a9db8839cbb4668edebb28d706721c8 /include/core/SkRRect.h
parent9a725dd9485654155e2e4196c32d372360bcdb61 (diff)
Extra safety for SkRRect.
This moves closer to ensuring that all SkRRects are valid. It also checks for validity of deserialized SkRRects and sets the SkRRect to empty if the serialized data is invalid rather than asserting. It is still possible to use mutators to create invalid SkRRects (e.g. outset() by large number, translate() so that type changes due to fp precision). Bug: skia: Change-Id: Ice5f73a020e99739ef4b3ce362181d3dbb35701c Reviewed-on: https://skia-review.googlesource.com/49220 Reviewed-by: Brian Osman <brianosman@google.com> Commit-Queue: Brian Salomon <bsalomon@google.com>
Diffstat (limited to 'include/core/SkRRect.h')
-rw-r--r--include/core/SkRRect.h7
1 files changed, 4 insertions, 3 deletions
diff --git a/include/core/SkRRect.h b/include/core/SkRRect.h
index f359c9c167..eb983b6c0e 100644
--- a/include/core/SkRRect.h
+++ b/include/core/SkRRect.h
@@ -46,7 +46,7 @@ class SkMatrix;
*/
class SK_API SkRRect {
public:
- SkRRect() { /* unititialized */ }
+ SkRRect() { this->setEmpty(); }
SkRRect(const SkRRect&) = default;
SkRRect& operator=(const SkRRect&) = default;
@@ -135,7 +135,7 @@ public:
fRect = rect;
fRect.sort();
- if (fRect.isEmpty()) {
+ if (fRect.isEmpty() || !fRect.isFinite()) {
this->setEmpty();
return;
}
@@ -178,7 +178,7 @@ public:
fRect = oval;
fRect.sort();
- if (fRect.isEmpty()) {
+ if (fRect.isEmpty() || !fRect.isFinite()) {
this->setEmpty();
return;
}
@@ -290,6 +290,7 @@ public:
bool contains(const SkRect& rect) const;
bool isValid() const;
+ static bool AreRectAndRadiiValid(const SkRect&, const SkVector[4]);
enum {
kSizeInMemory = 12 * sizeof(SkScalar)