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

Side by Side Diff: src/pathops/SkPathOpsOp.cpp

Issue 18058007: path ops work in progress (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: try try again Created 7 years, 5 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/pathops/SkPathOpsDebug.cpp ('k') | src/pathops/SkPathOpsPoint.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2012 Google Inc. 2 * Copyright 2012 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 #include "SkAddIntersections.h" 7 #include "SkAddIntersections.h"
8 #include "SkOpEdgeBuilder.h" 8 #include "SkOpEdgeBuilder.h"
9 #include "SkPathOpsCommon.h" 9 #include "SkPathOpsCommon.h"
10 #include "SkPathWriter.h" 10 #include "SkPathWriter.h"
(...skipping 23 matching lines...) Expand all
34 return last->segment(); 34 return last->segment();
35 } 35 }
36 if (done == angles.count()) { 36 if (done == angles.count()) {
37 continue; 37 continue;
38 } 38 }
39 SkSTArray<SkOpAngle::kStackBasedCount, SkOpAngle*, true> sorted; 39 SkSTArray<SkOpAngle::kStackBasedCount, SkOpAngle*, true> sorted;
40 bool sortable = SkOpSegment::SortAngles(angles, &sorted, 40 bool sortable = SkOpSegment::SortAngles(angles, &sorted,
41 SkOpSegment::kMayBeUnordered_SortAngleKind); 41 SkOpSegment::kMayBeUnordered_SortAngleKind);
42 int angleCount = sorted.count(); 42 int angleCount = sorted.count();
43 #if DEBUG_SORT 43 #if DEBUG_SORT
44 sorted[0]->segment()->debugShowSort(__FUNCTION__, sorted, 0); 44 sorted[0]->segment()->debugShowSort(__FUNCTION__, sorted, 0, sortable);
45 #endif 45 #endif
46 if (!sortable) { 46 if (!sortable) {
47 continue; 47 continue;
48 } 48 }
49 // find first angle, initialize winding to computed fWindSum 49 // find first angle, initialize winding to computed fWindSum
50 int firstIndex = -1; 50 int firstIndex = -1;
51 const SkOpAngle* angle; 51 const SkOpAngle* angle;
52 do { 52 do {
53 angle = sorted[++firstIndex]; 53 angle = sorted[++firstIndex];
54 segment = angle->segment(); 54 segment = angle->segment();
55 } while (segment->windSum(angle) == SK_MinS32); 55 } while (segment->windSum(angle) == SK_MinS32);
56 #if DEBUG_SORT 56 #if DEBUG_SORT
57 segment->debugShowSort(__FUNCTION__, sorted, firstIndex); 57 segment->debugShowSort(__FUNCTION__, sorted, firstIndex, sortable);
58 #endif 58 #endif
59 int sumMiWinding = segment->updateWindingReverse(angle); 59 int sumMiWinding = segment->updateWindingReverse(angle);
60 int sumSuWinding = segment->updateOppWindingReverse(angle); 60 int sumSuWinding = segment->updateOppWindingReverse(angle);
61 if (segment->operand()) { 61 if (segment->operand()) {
62 SkTSwap<int>(sumMiWinding, sumSuWinding); 62 SkTSwap<int>(sumMiWinding, sumSuWinding);
63 } 63 }
64 int nextIndex = firstIndex + 1; 64 int nextIndex = firstIndex + 1;
65 int lastIndex = firstIndex != 0 ? firstIndex : angleCount; 65 int lastIndex = firstIndex != 0 ? firstIndex : angleCount;
66 SkOpSegment* first = NULL; 66 SkOpSegment* first = NULL;
67 do { 67 do {
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 225
226 static const bool gOutInverse[kReverseDifference_PathOp + 1][2][2] = { 226 static const bool gOutInverse[kReverseDifference_PathOp + 1][2][2] = {
227 {{ false, false }, { true, false }}, // diff 227 {{ false, false }, { true, false }}, // diff
228 {{ false, false }, { false, true }}, // sect 228 {{ false, false }, { false, true }}, // sect
229 {{ false, true }, { true, true }}, // union 229 {{ false, true }, { true, true }}, // union
230 {{ false, true }, { true, false }}, // xor 230 {{ false, true }, { true, false }}, // xor
231 {{ false, true }, { false, false }}, // rev diff 231 {{ false, true }, { false, false }}, // rev diff
232 }; 232 };
233 233
234 bool Op(const SkPath& one, const SkPath& two, SkPathOp op, SkPath* result) { 234 bool Op(const SkPath& one, const SkPath& two, SkPathOp op, SkPath* result) {
235 #if DEBUG_SHOW_PATH 235 #if DEBUG_SHOW_TEST_NAME
236 ShowFunctionHeader(); 236 char* debugName = DEBUG_FILENAME_STRING;
237 ShowPath(one, "path"); 237 if (debugName && debugName[0]) {
238 ShowPath(two, "pathB"); 238 DebugBumpTestName(debugName);
239 ShowOp(op, "path", "pathB"); 239 DebugShowPath(one, two, op, debugName);
240 }
240 #endif 241 #endif
241 op = gOpInverse[op][one.isInverseFillType()][two.isInverseFillType()]; 242 op = gOpInverse[op][one.isInverseFillType()][two.isInverseFillType()];
242 SkPath::FillType fillType = gOutInverse[op][one.isInverseFillType()][two.isI nverseFillType()] 243 SkPath::FillType fillType = gOutInverse[op][one.isInverseFillType()][two.isI nverseFillType()]
243 ? SkPath::kInverseEvenOdd_FillType : SkPath::kEvenOdd_FillType; 244 ? SkPath::kInverseEvenOdd_FillType : SkPath::kEvenOdd_FillType;
244 const SkPath* minuend = &one; 245 const SkPath* minuend = &one;
245 const SkPath* subtrahend = &two; 246 const SkPath* subtrahend = &two;
246 if (op == kReverseDifference_PathOp) { 247 if (op == kReverseDifference_PathOp) {
247 minuend = &two; 248 minuend = &two;
248 subtrahend = &one; 249 subtrahend = &one;
249 op = kDifference_PathOp; 250 op = kDifference_PathOp;
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 { // if some edges could not be resolved, assemble remaining fragments 309 { // if some edges could not be resolved, assemble remaining fragments
309 SkPath temp; 310 SkPath temp;
310 temp.setFillType(fillType); 311 temp.setFillType(fillType);
311 SkPathWriter assembled(temp); 312 SkPathWriter assembled(temp);
312 Assemble(wrapper, &assembled); 313 Assemble(wrapper, &assembled);
313 *result = *assembled.nativePath(); 314 *result = *assembled.nativePath();
314 result->setFillType(fillType); 315 result->setFillType(fillType);
315 } 316 }
316 return true; 317 return true;
317 } 318 }
OLDNEW
« no previous file with comments | « src/pathops/SkPathOpsDebug.cpp ('k') | src/pathops/SkPathOpsPoint.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698