OLD | NEW |
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 "SkOpCoincidence.h" | 8 #include "SkOpCoincidence.h" |
9 #include "SkOpEdgeBuilder.h" | 9 #include "SkOpEdgeBuilder.h" |
10 #include "SkPathOpsCommon.h" | 10 #include "SkPathOpsCommon.h" |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 fprintf(file, " path.setFillType((SkPath::FillType) %d);\n", two.getFillT
ype()); | 254 fprintf(file, " path.setFillType((SkPath::FillType) %d);\n", two.getFillT
ype()); |
255 dump_path(file, two, false, true); | 255 dump_path(file, two, false, true); |
256 fprintf(file, " SkPath path2(path);\n"); | 256 fprintf(file, " SkPath path2(path);\n"); |
257 fprintf(file, " testPathOp(reporter, path1, path2, (SkPathOp) %d, filenam
e);\n", op); | 257 fprintf(file, " testPathOp(reporter, path1, path2, (SkPathOp) %d, filenam
e);\n", op); |
258 fprintf(file, "}\n"); | 258 fprintf(file, "}\n"); |
259 fclose(file); | 259 fclose(file); |
260 } | 260 } |
261 #endif | 261 #endif |
262 | 262 |
263 bool Op(const SkPath& one, const SkPath& two, SkPathOp op, SkPath* result) { | 263 bool Op(const SkPath& one, const SkPath& two, SkPathOp op, SkPath* result) { |
264 SkChunkAlloc allocator(4096); // FIXME: add a constant expression here, tun
e | |
265 SkOpContour contour; | 264 SkOpContour contour; |
266 SkOpCoincidence coincidence; | 265 SkOpCoincidence coincidence; |
267 SkOpGlobalState globalState(&coincidence PATH_OPS_DEBUG_PARAMS(&contour)); | 266 SkOpGlobalState globalState(&coincidence PATH_OPS_DEBUG_PARAMS(&contour)); |
268 #if DEBUGGING_PATHOPS_FROM_HOST | 267 #if DEBUGGING_PATHOPS_FROM_HOST |
269 dump_op(one, two, op); | 268 dump_op(one, two, op); |
270 #endif | 269 #endif |
271 #if 0 && DEBUG_SHOW_TEST_NAME | 270 #if 0 && DEBUG_SHOW_TEST_NAME |
272 char* debugName = DEBUG_FILENAME_STRING; | 271 char* debugName = DEBUG_FILENAME_STRING; |
273 if (debugName && debugName[0]) { | 272 if (debugName && debugName[0]) { |
274 SkPathOpsDebug::BumpTestName(debugName); | 273 SkPathOpsDebug::BumpTestName(debugName); |
275 SkPathOpsDebug::ShowPath(one, two, op, debugName); | 274 SkPathOpsDebug::ShowPath(one, two, op, debugName); |
276 } | 275 } |
277 #endif | 276 #endif |
278 op = gOpInverse[op][one.isInverseFillType()][two.isInverseFillType()]; | 277 op = gOpInverse[op][one.isInverseFillType()][two.isInverseFillType()]; |
279 SkPath::FillType fillType = gOutInverse[op][one.isInverseFillType()][two.isI
nverseFillType()] | 278 SkPath::FillType fillType = gOutInverse[op][one.isInverseFillType()][two.isI
nverseFillType()] |
280 ? SkPath::kInverseEvenOdd_FillType : SkPath::kEvenOdd_FillType; | 279 ? SkPath::kInverseEvenOdd_FillType : SkPath::kEvenOdd_FillType; |
281 const SkPath* minuend = &one; | 280 const SkPath* minuend = &one; |
282 const SkPath* subtrahend = &two; | 281 const SkPath* subtrahend = &two; |
283 if (op == kReverseDifference_PathOp) { | 282 if (op == kReverseDifference_PathOp) { |
284 minuend = &two; | 283 minuend = &two; |
285 subtrahend = &one; | 284 subtrahend = &one; |
286 op = kDifference_PathOp; | 285 op = kDifference_PathOp; |
287 } | 286 } |
288 #if DEBUG_SORT || DEBUG_SWAP_TOP | 287 #if DEBUG_SORT || DEBUG_SWAP_TOP |
289 SkPathOpsDebug::gSortCount = SkPathOpsDebug::gSortCountDefault; | 288 SkPathOpsDebug::gSortCount = SkPathOpsDebug::gSortCountDefault; |
290 #endif | 289 #endif |
291 // turn path into list of segments | 290 // turn path into list of segments |
| 291 SkChunkAlloc allocator(4096); // FIXME: add a constant expression here, tun
e |
292 SkOpEdgeBuilder builder(*minuend, &contour, &allocator, &globalState); | 292 SkOpEdgeBuilder builder(*minuend, &contour, &allocator, &globalState); |
293 if (builder.unparseable()) { | 293 if (builder.unparseable()) { |
294 return false; | 294 return false; |
295 } | 295 } |
296 const int xorMask = builder.xorMask(); | 296 const int xorMask = builder.xorMask(); |
297 builder.addOperand(*subtrahend); | 297 builder.addOperand(*subtrahend); |
298 if (!builder.finish(&allocator)) { | 298 if (!builder.finish(&allocator)) { |
299 return false; | 299 return false; |
300 } | 300 } |
301 #if !FORCE_RELEASE | 301 #if !FORCE_RELEASE |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
339 { // if some edges could not be resolved, assemble remaining fragments | 339 { // if some edges could not be resolved, assemble remaining fragments |
340 SkPath temp; | 340 SkPath temp; |
341 temp.setFillType(fillType); | 341 temp.setFillType(fillType); |
342 SkPathWriter assembled(temp); | 342 SkPathWriter assembled(temp); |
343 Assemble(wrapper, &assembled); | 343 Assemble(wrapper, &assembled); |
344 *result = *assembled.nativePath(); | 344 *result = *assembled.nativePath(); |
345 result->setFillType(fillType); | 345 result->setFillType(fillType); |
346 } | 346 } |
347 return true; | 347 return true; |
348 } | 348 } |
OLD | NEW |