aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar robertphillips <robertphillips@google.com>2015-02-23 11:17:01 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2015-02-23 11:17:01 -0800
commitb8de1f46594c3cd9c537f0b128c6d6eb30a9f463 (patch)
tree27d33b3f054cb71848dd8d712db5923632c731b1
parent1a9600f2537ad62e85529801a634167f2913bc24 (diff)
Reset conicWeights in SkPath::consumeDegenerateSegments when rewinding to last Move op
Without this patch the iterator can end up running off the end of the conic weights if there is a mixture of degenerate and non-degenerate ops Note: we might want to suppress the generation of degenerate conics and lines in SkPath::addRRect BUG=459897 Review URL: https://codereview.chromium.org/954453003
-rw-r--r--src/core/SkPath.cpp5
-rw-r--r--tests/PathTest.cpp14
2 files changed, 19 insertions, 0 deletions
diff --git a/src/core/SkPath.cpp b/src/core/SkPath.cpp
index de3d297da3..0b796fc537 100644
--- a/src/core/SkPath.cpp
+++ b/src/core/SkPath.cpp
@@ -1660,6 +1660,7 @@ void SkPath::Iter::consumeDegenerateSegments() {
// forward before the next move is seen
const uint8_t* lastMoveVerb = 0;
const SkPoint* lastMovePt = 0;
+ const SkScalar* lastMoveWeight = NULL;
SkPoint lastPt = fLastPt;
while (fVerbs != fVerbStop) {
unsigned verb = *(fVerbs - 1); // fVerbs is one beyond the current verb
@@ -1668,6 +1669,7 @@ void SkPath::Iter::consumeDegenerateSegments() {
// Keep a record of this most recent move
lastMoveVerb = fVerbs;
lastMovePt = fPts;
+ lastMoveWeight = fConicWeights;
lastPt = fPts[0];
fVerbs--;
fPts++;
@@ -1688,6 +1690,7 @@ void SkPath::Iter::consumeDegenerateSegments() {
if (lastMoveVerb) {
fVerbs = lastMoveVerb;
fPts = lastMovePt;
+ fConicWeights = lastMoveWeight;
return;
}
return;
@@ -1703,6 +1706,7 @@ void SkPath::Iter::consumeDegenerateSegments() {
if (lastMoveVerb) {
fVerbs = lastMoveVerb;
fPts = lastMovePt;
+ fConicWeights = lastMoveWeight;
return;
}
return;
@@ -1718,6 +1722,7 @@ void SkPath::Iter::consumeDegenerateSegments() {
if (lastMoveVerb) {
fVerbs = lastMoveVerb;
fPts = lastMovePt;
+ fConicWeights = lastMoveWeight;
return;
}
return;
diff --git a/tests/PathTest.cpp b/tests/PathTest.cpp
index 7db65a899f..a868d93d78 100644
--- a/tests/PathTest.cpp
+++ b/tests/PathTest.cpp
@@ -2475,6 +2475,20 @@ static void test_iter(skiatest::Reporter* reporter) {
REPORTER_ASSERT(reporter, SkPath::kDone_Verb == iter.next(pts, true));
// The GM degeneratesegments.cpp test is more extensive
+
+ // Test out mixed degenerate and non-degenerate geometry with Conics
+ const SkVector radii[4] = { { 0, 0 }, { 0, 0 }, { 0, 0 }, { 100, 100 } };
+ SkRect r = SkRect::MakeWH(100, 100);
+ SkRRect rr;
+ rr.setRectRadii(r, radii);
+ p.reset();
+ p.addRRect(rr);
+ iter.setPath(p, false);
+ REPORTER_ASSERT(reporter, SkPath::kMove_Verb == iter.next(pts));
+ REPORTER_ASSERT(reporter, SkPath::kLine_Verb == iter.next(pts));
+ REPORTER_ASSERT(reporter, SkPath::kLine_Verb == iter.next(pts));
+ REPORTER_ASSERT(reporter, SkPath::kConic_Verb == iter.next(pts));
+ REPORTER_ASSERT(reporter, SK_ScalarRoot2Over2 == iter.conicWeight());
}
static void test_raw_iter(skiatest::Reporter* reporter) {