aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/core/SkAAClip.cpp3
-rw-r--r--src/core/SkRectPriv.h24
2 files changed, 26 insertions, 1 deletions
diff --git a/src/core/SkAAClip.cpp b/src/core/SkAAClip.cpp
index d4db8ee31e..c0707c5b0c 100644
--- a/src/core/SkAAClip.cpp
+++ b/src/core/SkAAClip.cpp
@@ -9,6 +9,7 @@
#include "SkAtomics.h"
#include "SkBlitter.h"
#include "SkColorData.h"
+#include "SkRectPriv.h"
#include "SkPath.h"
#include "SkScan.h"
#include "SkUtils.h"
@@ -703,7 +704,7 @@ bool SkAAClip::setEmpty() {
}
bool SkAAClip::setRect(const SkIRect& bounds) {
- if (bounds.isEmpty()) {
+ if (!SkRectPriv::PositiveDimensions(bounds)) {
return this->setEmpty();
}
diff --git a/src/core/SkRectPriv.h b/src/core/SkRectPriv.h
new file mode 100644
index 0000000000..4dcc4c56ce
--- /dev/null
+++ b/src/core/SkRectPriv.h
@@ -0,0 +1,24 @@
+/*
+ * Copyright 2018 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef SkRectPriv_DEFINED
+#define SkRectPriv_DEFINED
+
+#include "SkRect.h"
+
+class SkRectPriv {
+public:
+ // Returns true iff width and height are positive. Catches inverted, empty, and overflowing
+ // (way too big) rects. This is used by clients that want a non-empty rect that they can also
+ // actually use its computed width/height.
+ //
+ static bool PositiveDimensions(const SkIRect& r) {
+ return r.width() > 0 && r.height() > 0;
+ }
+};
+
+#endif