Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(836)

Unified Diff: src/pathops/SkOpEdgeBuilder.cpp

Issue 1037953004: add conics to path ops (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix linux build Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/pathops/SkOpEdgeBuilder.h ('k') | src/pathops/SkOpSegment.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/pathops/SkOpEdgeBuilder.cpp
diff --git a/src/pathops/SkOpEdgeBuilder.cpp b/src/pathops/SkOpEdgeBuilder.cpp
index e3dc1398655273d6236da70e086433c5d82d0bc8..a180387b3611a575bb3fdca072632e0cbe358173 100644
--- a/src/pathops/SkOpEdgeBuilder.cpp
+++ b/src/pathops/SkOpEdgeBuilder.cpp
@@ -114,7 +114,18 @@ int SkOpEdgeBuilder::preFetch() {
continue; // skip degenerate points
}
break;
- case SkPath::kConic_Verb: {
+ case SkPath::kConic_Verb:
+ if (true) {
reed1 2015/04/15 20:06:24 do we need to keep the "else" code?
+ force_small_to_zero(&pts[1]);
+ force_small_to_zero(&pts[2]);
+ curve[1] = pts[1];
+ curve[2] = pts[2];
+ verb = SkReduceOrder::Conic(curve, iter.conicWeight(), pts);
+ if (verb == SkPath::kMove_Verb) {
+ continue; // skip degenerate points
+ }
+ break;
+ } else {
const SkPoint* quadPts = quadder.computeQuads(pts, iter.conicWeight(),
quadderTol);
const int nQuads = quadder.countQuads();
@@ -124,8 +135,9 @@ int SkOpEdgeBuilder::preFetch() {
fPathPts.append(nQuads * 2, &quadPts[1]);
curve[0] = pts[2];
lastCurve = true;
+ verb = SkPath::kQuad_Verb;
+ continue;
}
- continue;
case SkPath::kCubic_Verb:
force_small_to_zero(&pts[1]);
force_small_to_zero(&pts[2]);
@@ -148,6 +160,9 @@ int SkOpEdgeBuilder::preFetch() {
*fPathVerbs.append() = verb;
int ptCount = SkPathOpsVerbToPoints(verb);
fPathPts.append(ptCount, &pts[1]);
+ if (verb == SkPath::kConic_Verb) {
+ *fWeights.append() = iter.conicWeight();
+ }
curve[0] = pts[ptCount];
lastCurve = true;
} while (verb != SkPath::kDone_Verb);
@@ -167,6 +182,7 @@ bool SkOpEdgeBuilder::walk(SkChunkAlloc* allocator) {
uint8_t* verbPtr = fPathVerbs.begin();
uint8_t* endOfFirstHalf = &verbPtr[fSecondHalf];
SkPoint* pointsPtr = fPathPts.begin() - 1;
+ SkScalar* weightPtr = fWeights.begin();
SkPath::Verb verb;
while ((verb = (SkPath::Verb) *verbPtr) != SkPath::kDone_Verb) {
if (verbPtr == endOfFirstHalf) {
@@ -195,6 +211,9 @@ bool SkOpEdgeBuilder::walk(SkChunkAlloc* allocator) {
case SkPath::kQuad_Verb:
fCurrentContour->addQuad(pointsPtr, fAllocator);
break;
+ case SkPath::kConic_Verb:
+ fCurrentContour->addConic(pointsPtr, *weightPtr++, fAllocator);
+ break;
case SkPath::kCubic_Verb: {
// split self-intersecting cubics in two before proceeding
// if the cubic is convex, it doesn't self intersect.
« no previous file with comments | « src/pathops/SkOpEdgeBuilder.h ('k') | src/pathops/SkOpSegment.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698