aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/pathops
diff options
context:
space:
mode:
authorGravatar caryclark <caryclark@google.com>2016-11-04 11:38:41 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-11-04 11:38:41 -0700
commitd8db392be9dd1887df04b10b5670991d6b098c17 (patch)
treee968ba01ec4043801bf6a74f0ff87de1d6f78f07 /src/pathops
parent8bd45cd98eb0eff1fb074fac9f469fdad5ca51f9 (diff)
use reversePathTo in place of addPathReverse
Path ops was using addPathReverse, instead of reversePathTo. The former adds a moveTo always, and the latter requires that the caller add the moveTo if needed. Simplify the reversePathTo implementation. R=reed@google.com GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2481463002 Review-Url: https://codereview.chromium.org/2481463002
Diffstat (limited to 'src/pathops')
-rw-r--r--src/pathops/SkOpBuilder.cpp20
-rw-r--r--src/pathops/SkPathWriter.cpp2
2 files changed, 14 insertions, 8 deletions
diff --git a/src/pathops/SkOpBuilder.cpp b/src/pathops/SkOpBuilder.cpp
index 011d6a6aba..075520d2c1 100644
--- a/src/pathops/SkOpBuilder.cpp
+++ b/src/pathops/SkOpBuilder.cpp
@@ -25,7 +25,17 @@ static bool one_contour(const SkPath& path) {
return true;
}
-bool FixWinding(SkPath* path) {
+void SkOpBuilder::ReversePath(SkPath* path) {
+ SkPath temp;
+ SkPoint lastPt;
+ SkAssertResult(path->getLastPt(&lastPt));
+ temp.moveTo(lastPt);
+ temp.reversePathTo(*path);
+ temp.close();
+ *path = temp;
+}
+
+bool SkOpBuilder::FixWinding(SkPath* path) {
SkPath::FillType fillType = path->getFillType();
if (fillType == SkPath::kInverseEvenOdd_FillType) {
fillType = SkPath::kInverseWinding_FillType;
@@ -35,9 +45,7 @@ bool FixWinding(SkPath* path) {
SkPathPriv::FirstDirection dir;
if (one_contour(*path) && SkPathPriv::CheapComputeFirstDirection(*path, &dir)) {
if (dir != SkPathPriv::kCCW_FirstDirection) {
- SkPath temp;
- temp.reverseAddPath(*path);
- *path = temp;
+ ReversePath(path);
}
path->setFillType(fillType);
return true;
@@ -133,9 +141,7 @@ bool SkOpBuilder::resolve(SkPath* result) {
if (firstDir == SkPathPriv::kUnknown_FirstDirection) {
firstDir = dir;
} else if (firstDir != dir) {
- SkPath temp;
- temp.reverseAddPath(*test);
- *test = temp;
+ ReversePath(test);
}
continue;
}
diff --git a/src/pathops/SkPathWriter.cpp b/src/pathops/SkPathWriter.cpp
index c94809e8ec..9893a502ca 100644
--- a/src/pathops/SkPathWriter.cpp
+++ b/src/pathops/SkPathWriter.cpp
@@ -306,7 +306,7 @@ void SkPathWriter::assemble() {
first ? SkPath::kAppend_AddPathMode : SkPath::kExtend_AddPathMode);
} else {
SkASSERT(!first);
- fPathPtr->reverseAddPath(contour);
+ fPathPtr->reversePathTo(contour);
}
if (first) {
first = false;