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

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

Issue 14474002: path ops : make it real (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/pathops/SkOpEdgeBuilder.cpp ('k') | no next file » | 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 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 static const bool gOutInverse[kReverseDifference_PathOp + 1][2][2] = { 221 static const bool gOutInverse[kReverseDifference_PathOp + 1][2][2] = {
222 {{ false, false }, { true, false }}, // diff 222 {{ false, false }, { true, false }}, // diff
223 {{ false, false }, { false, true }}, // sect 223 {{ false, false }, { false, true }}, // sect
224 {{ false, true }, { true, true }}, // union 224 {{ false, true }, { true, true }}, // union
225 {{ false, true }, { true, false }}, // xor 225 {{ false, true }, { true, false }}, // xor
226 {{ false, true }, { false, false }}, // rev diff 226 {{ false, true }, { false, false }}, // rev diff
227 }; 227 };
228 228
229 void Op(const SkPath& one, const SkPath& two, SkPathOp op, SkPath* result) { 229 void Op(const SkPath& one, const SkPath& two, SkPathOp op, SkPath* result) {
230 op = gOpInverse[op][one.isInverseFillType()][two.isInverseFillType()]; 230 op = gOpInverse[op][one.isInverseFillType()][two.isInverseFillType()];
231 result->reset();
232 SkPath::FillType fillType = gOutInverse[op][one.isInverseFillType()][two.isI nverseFillType()] 231 SkPath::FillType fillType = gOutInverse[op][one.isInverseFillType()][two.isI nverseFillType()]
233 ? SkPath::kInverseEvenOdd_FillType : SkPath::kEvenOdd_FillType; 232 ? SkPath::kInverseEvenOdd_FillType : SkPath::kEvenOdd_FillType;
234 result->setFillType(fillType);
235 const SkPath* minuend = &one; 233 const SkPath* minuend = &one;
236 const SkPath* subtrahend = &two; 234 const SkPath* subtrahend = &two;
237 if (op == kReverseDifference_PathOp) { 235 if (op == kReverseDifference_PathOp) {
238 minuend = &two; 236 minuend = &two;
239 subtrahend = &one; 237 subtrahend = &one;
240 op = kDifference_PathOp; 238 op = kDifference_PathOp;
241 } 239 }
242 #if DEBUG_SORT || DEBUG_SWAP_TOP 240 #if DEBUG_SORT || DEBUG_SWAP_TOP
243 gDebugSortCount = gDebugSortCountDefault; 241 gDebugSortCount = gDebugSortCountDefault;
244 #endif 242 #endif
245 // turn path into list of segments 243 // turn path into list of segments
246 SkTArray<SkOpContour> contours; 244 SkTArray<SkOpContour> contours;
247 // FIXME: add self-intersecting cubics' T values to segment 245 // FIXME: add self-intersecting cubics' T values to segment
248 SkOpEdgeBuilder builder(*minuend, contours); 246 SkOpEdgeBuilder builder(*minuend, contours);
249 const int xorMask = builder.xorMask(); 247 const int xorMask = builder.xorMask();
250 builder.addOperand(*subtrahend); 248 builder.addOperand(*subtrahend);
251 builder.finish(); 249 builder.finish();
250 result->reset();
251 result->setFillType(fillType);
252 const int xorOpMask = builder.xorMask(); 252 const int xorOpMask = builder.xorMask();
253 SkTDArray<SkOpContour*> contourList; 253 SkTDArray<SkOpContour*> contourList;
254 MakeContourList(contours, contourList, xorMask == kEvenOdd_PathOpsMask, 254 MakeContourList(contours, contourList, xorMask == kEvenOdd_PathOpsMask,
255 xorOpMask == kEvenOdd_PathOpsMask); 255 xorOpMask == kEvenOdd_PathOpsMask);
256 SkOpContour** currentPtr = contourList.begin(); 256 SkOpContour** currentPtr = contourList.begin();
257 if (!currentPtr) { 257 if (!currentPtr) {
258 return; 258 return;
259 } 259 }
260 SkOpContour** listEnd = contourList.end(); 260 SkOpContour** listEnd = contourList.end();
261 // find all intersections between segments 261 // find all intersections between segments
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 SkPathWriter wrapper(*result); 293 SkPathWriter wrapper(*result);
294 bridgeOp(contourList, op, xorMask, xorOpMask, &wrapper); 294 bridgeOp(contourList, op, xorMask, xorOpMask, &wrapper);
295 { // if some edges could not be resolved, assemble remaining fragments 295 { // if some edges could not be resolved, assemble remaining fragments
296 SkPath temp; 296 SkPath temp;
297 temp.setFillType(fillType); 297 temp.setFillType(fillType);
298 SkPathWriter assembled(temp); 298 SkPathWriter assembled(temp);
299 Assemble(wrapper, &assembled); 299 Assemble(wrapper, &assembled);
300 *result = *assembled.nativePath(); 300 *result = *assembled.nativePath();
301 } 301 }
302 } 302 }
OLDNEW
« no previous file with comments | « src/pathops/SkOpEdgeBuilder.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698