diff options
author | robertphillips <robertphillips@google.com> | 2014-12-29 11:36:39 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-12-29 11:36:39 -0800 |
commit | fe7c427e3d1c2c98bce7a3fa0ae6b5864527f169 (patch) | |
tree | 3bb31eeeb6bd859e3a6a23c6c57c879d4ad65391 /src | |
parent | 40d4bd8dafe9ed844f29a3de3d8965672248ee73 (diff) |
Fix bound returned by SkPath::isRect when the path contains a trailing moveTo
Oddly enough this was fixed in:
https://codereview.chromium.org/16950021/ (add rect-output parameter to isRect, allowing us to return the correct bounds even if a rectagular path has a trailing moveTo)
but was reverted here:
https://skia.googlesource.com/skia/+/8fd160350ca5f57fbb1b2e03383c5778414a9b48
since it appeared to be crashing Chrome's trybots. I think it just fell through the cracks after that.
If this sticks I will land a follow on patch for the stroke issue reported in the original bug (crbug.com/247770).
BUG=247770,445368
Review URL: https://codereview.chromium.org/834483002
Diffstat (limited to 'src')
-rw-r--r-- | src/core/SkPath.cpp | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/src/core/SkPath.cpp b/src/core/SkPath.cpp index cee93d352e..f8aa8521da 100644 --- a/src/core/SkPath.cpp +++ b/src/core/SkPath.cpp @@ -538,11 +538,20 @@ bool SkPath::isRect(SkRect* rect) const { SkDEBUGCODE(this->validate();) int currVerb = 0; const SkPoint* pts = fPathRef->points(); - bool result = isRectContour(false, &currVerb, &pts, NULL, NULL); - if (result && rect) { - *rect = getBounds(); + const SkPoint* first = pts; + bool isClosed; + if (!this->isRectContour(false, &currVerb, &pts, &isClosed, NULL)) { + return false; } - return result; + if (rect) { + if (isClosed) { + rect->set(first, SkToS32(pts - first)); + } else { + // 'pts' isn't updated for open rects + *rect = this->getBounds(); + } + } + return true; } bool SkPath::isRect(bool* isClosed, Direction* direction) const { |