aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar robertphillips <robertphillips@google.com>2014-12-29 14:06:51 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2014-12-29 14:06:51 -0800
commit4f662e62cd44e302ef689fabdb2c0ae8d9471b02 (patch)
treefe32ac5d0e93b9137bc2f38ba0b6cbd06d4eecf7 /src
parentfe7c427e3d1c2c98bce7a3fa0ae6b5864527f169 (diff)
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
Diffstat (limited to 'src')
-rw-r--r--src/core/SkPath.cpp17
-rw-r--r--src/core/SkStroke.cpp5
2 files changed, 8 insertions, 14 deletions
diff --git a/src/core/SkPath.cpp b/src/core/SkPath.cpp
index f8aa8521da..27b7283263 100644
--- a/src/core/SkPath.cpp
+++ b/src/core/SkPath.cpp
@@ -534,18 +534,18 @@ SkPath::PathAsRect SkPath::asRect(Direction* direction) const {
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 @@ bool SkPath::isRect(SkRect* rect) const {
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;
diff --git a/src/core/SkStroke.cpp b/src/core/SkStroke.cpp
index c562c2e433..f8173c0555 100644
--- a/src/core/SkStroke.cpp
+++ b/src/core/SkStroke.cpp
@@ -1414,10 +1414,11 @@ void SkStroke::strokePath(const SkPath& src, SkPath* dst) const {
// If src is really a rect, call our specialty strokeRect() method
{
+ SkRect rect;
bool isClosed;
SkPath::Direction dir;
- if (src.isRect(&isClosed, &dir) && isClosed) {
- this->strokeRect(src.getBounds(), dst, dir);
+ if (src.isRect(&rect, &isClosed, &dir) && isClosed) {
+ this->strokeRect(rect, dst, dir);
// our answer should preserve the inverseness of the src
if (src.isInverseFillType()) {
SkASSERT(!dst->isInverseFillType());