aboutsummaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
authorGravatar reed <reed@google.com>2015-07-28 06:00:50 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2015-07-28 06:00:50 -0700
commit91f283bb4e6ea71bbd4e6efc27befc29118ee543 (patch)
tree3145ec8b092c25f8beb4d2b39629a8a100fc9a9f /include
parentb2c07364a33fa381dcb78c47763d1bf98ab4b8ff (diff)
change getBounds to return 0000 iff there are zero points
This is a contract change for SkPath::getBounds(), which formally was defined to return 0,0,0,0 for a 1-point path, regardless of the coordinates of that point. This seems wacky/inconsistent, and was causing other bugs (incorrect bounds) when this was unioned with other rects. Does anyone remember why we defined it this way? BUG=513799 Review URL: https://codereview.chromium.org/1261773002
Diffstat (limited to 'include')
-rw-r--r--include/core/SkPath.h11
-rw-r--r--include/core/SkPathRef.h8
2 files changed, 7 insertions, 12 deletions
diff --git a/include/core/SkPath.h b/include/core/SkPath.h
index fe89766558..dc50ae76c3 100644
--- a/include/core/SkPath.h
+++ b/include/core/SkPath.h
@@ -273,11 +273,12 @@ public:
//! Swap contents of this and other. Guaranteed not to throw
void swap(SkPath& other);
- /** Returns the bounds of the path's points. If the path contains 0 or 1
- points, the bounds is set to (0,0,0,0), and isEmpty() will return true.
- Note: this bounds may be larger than the actual shape, since curves
- do not extend as far as their control points. Additionally this bound
- can contain trailing MoveTo points (cf. isRect).
+ /**
+ * Returns the bounds of the path's points. If the path contains zero points/verbs, this
+ * will return the "empty" rect [0, 0, 0, 0].
+ * Note: this bounds may be larger than the actual shape, since curves
+ * do not extend as far as their control points. Additionally this bound encompases all points,
+ * even isolated moveTos either preceeding or following the last non-degenerate contour.
*/
const SkRect& getBounds() const {
return fPathRef->getBounds();
diff --git a/include/core/SkPathRef.h b/include/core/SkPathRef.h
index ae8945de08..e7cc31cff4 100644
--- a/include/core/SkPathRef.h
+++ b/include/core/SkPathRef.h
@@ -278,13 +278,7 @@ private:
// Return true if the computed bounds are finite.
static bool ComputePtBounds(SkRect* bounds, const SkPathRef& ref) {
- int count = ref.countPoints();
- if (count <= 1) { // we ignore just 1 point (moveto)
- bounds->setEmpty();
- return count ? ref.points()->isFinite() : true;
- } else {
- return bounds->setBoundsCheck(ref.points(), count);
- }
+ return bounds->setBoundsCheck(ref.points(), ref.countPoints());
}
// called, if dirty, by getBounds()