Update stroke path to use rect returned from isRect (to fix trailing moveTo bug)
This basically recreates what was done 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) with the addition of GM representation
BUG=skia:247770
Review URL: https://codereview.chromium.org/834503002
diff --git a/src/core/SkPath.cpp b/src/core/SkPath.cpp
index f8aa852..27b7283 100644
--- a/src/core/SkPath.cpp
+++ b/src/core/SkPath.cpp
@@ -534,18 +534,18 @@
return (PathAsRect) (isRect(&isClosed, direction) + isClosed);
}
-bool SkPath::isRect(SkRect* rect) const {
+bool SkPath::isRect(SkRect* rect, bool* isClosed, Direction* direction) const {
SkDEBUGCODE(this->validate();)
int currVerb = 0;
const SkPoint* pts = fPathRef->points();
const SkPoint* first = pts;
- bool isClosed;
- if (!this->isRectContour(false, &currVerb, &pts, &isClosed, NULL)) {
+ if (!this->isRectContour(false, &currVerb, &pts, isClosed, direction)) {
return false;
}
if (rect) {
- if (isClosed) {
- rect->set(first, SkToS32(pts - first));
+ int32_t num = SkToS32(pts - first);
+ if (num) {
+ rect->set(first, num);
} else {
// 'pts' isn't updated for open rects
*rect = this->getBounds();
@@ -554,13 +554,6 @@
return true;
}
-bool SkPath::isRect(bool* isClosed, Direction* direction) const {
- SkDEBUGCODE(this->validate();)
- int currVerb = 0;
- const SkPoint* pts = fPathRef->points();
- return isRectContour(false, &currVerb, &pts, isClosed, direction);
-}
-
bool SkPath::isNestedRects(SkRect rects[2], Direction dirs[2]) const {
SkDEBUGCODE(this->validate();)
int currVerb = 0;