diff options
author | reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-06-21 17:32:32 +0000 |
---|---|---|
committer | reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-06-21 17:32:32 +0000 |
commit | da2b21fa9ba43df374f21b0e05d9816ab1dfb876 (patch) | |
tree | 433432e154725aeb169ef88f03df9fd1b72f1832 /src/core | |
parent | 56a57aeb3c0d71faf72a05c19787c403e76fa474 (diff) |
add rect-output parameter to isRect, allowing us to return the correct bounds even if a rectagular path has a trailing moveTo
https://code.google.com/p/chromium/issues/detail?id=247770
R=caryclark@google.com
Review URL: https://codereview.chromium.org/16950021
git-svn-id: http://skia.googlecode.com/svn/trunk@9724 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/SkPath.cpp | 21 | ||||
-rw-r--r-- | src/core/SkStroke.cpp | 5 |
2 files changed, 12 insertions, 14 deletions
diff --git a/src/core/SkPath.cpp b/src/core/SkPath.cpp index e997b80e4f..2d819c168d 100644 --- a/src/core/SkPath.cpp +++ b/src/core/SkPath.cpp @@ -584,22 +584,19 @@ bool SkPath::isRectContour(bool allowPartial, int* currVerb, const SkPoint** pts return result; } -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(); - bool result = isRectContour(false, &currVerb, &pts, NULL, NULL); - if (result && rect) { - *rect = getBounds(); + const SkPoint* first = pts; + if (!this->isRectContour(false, &currVerb, &pts, isClosed, direction)) { + return false; } - return result; -} - -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); + + if (rect) { + rect->set(first, SkToS32(pts - first)); + } + return true; } bool SkPath::isNestedRects(SkRect rects[2], Direction dirs[2]) const { diff --git a/src/core/SkStroke.cpp b/src/core/SkStroke.cpp index d094ef65b7..2fd5a14c2c 100644 --- a/src/core/SkStroke.cpp +++ b/src/core/SkStroke.cpp @@ -549,10 +549,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()); |