Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(157)

Unified Diff: src/core/SkPath.cpp

Issue 834483002: Fix bound returned by SkPath::isRect when the path contains a trailing moveTo (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tests/PathTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkPath.cpp
diff --git a/src/core/SkPath.cpp b/src/core/SkPath.cpp
index cee93d352e7537aa4b95fa98ea3efa2f78a6d622..f8aa8521dadb1e13cc6e785d7fa7b88acf0bb4bc 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 {
« no previous file with comments | « no previous file | tests/PathTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698