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

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

Issue 2128633003: pathops coincidence and security rewrite (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: require resulting t to be between 0 and 1 Created 4 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
OLDNEW
1 /* 1 /*
2 * Copyright 2014 Google Inc. 2 * Copyright 2014 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 7
8 #include "SkMatrix.h" 8 #include "SkMatrix.h"
9 #include "SkOpEdgeBuilder.h" 9 #include "SkOpEdgeBuilder.h"
10 #include "SkPathPriv.h" 10 #include "SkPathPriv.h"
(...skipping 26 matching lines...) Expand all
37 if (dir != SkPathPriv::kCCW_FirstDirection) { 37 if (dir != SkPathPriv::kCCW_FirstDirection) {
38 SkPath temp; 38 SkPath temp;
39 temp.reverseAddPath(*path); 39 temp.reverseAddPath(*path);
40 *path = temp; 40 *path = temp;
41 } 41 }
42 path->setFillType(fillType); 42 path->setFillType(fillType);
43 return true; 43 return true;
44 } 44 }
45 SkChunkAlloc allocator(4096); 45 SkChunkAlloc allocator(4096);
46 SkOpContourHead contourHead; 46 SkOpContourHead contourHead;
47 SkOpGlobalState globalState(nullptr, &contourHead SkDEBUGPARAMS(false) 47 SkOpGlobalState globalState(&contourHead, &allocator SkDEBUGPARAMS(false)
48 SkDEBUGPARAMS(nullptr)); 48 SkDEBUGPARAMS(nullptr));
49 SkOpEdgeBuilder builder(*path, &contourHead, &allocator, &globalState); 49 SkOpEdgeBuilder builder(*path, &contourHead, &globalState);
50 builder.finish(&allocator); 50 builder.finish();
51 if (!contourHead.next()) { 51 SkASSERT(contourHead.next());
52 return false;
53 }
54 contourHead.resetReverse(); 52 contourHead.resetReverse();
55 bool writePath = false; 53 bool writePath = false;
56 SkOpSpan* topSpan; 54 SkOpSpan* topSpan;
57 globalState.setPhase(SkOpGlobalState::kFixWinding); 55 globalState.setPhase(SkOpGlobalState::kFixWinding);
58 while ((topSpan = FindSortableTop(&contourHead))) { 56 while ((topSpan = FindSortableTop(&contourHead))) {
59 SkOpSegment* topSegment = topSpan->segment(); 57 SkOpSegment* topSegment = topSpan->segment();
60 SkOpContour* topContour = topSegment->contour(); 58 SkOpContour* topContour = topSegment->contour();
61 SkASSERT(topContour->isCcw() >= 0); 59 SkASSERT(topContour->isCcw() >= 0);
62 #if DEBUG_WINDING 60 #if DEBUG_WINDING
63 SkDebugf("%s id=%d nested=%d ccw=%d\n", __FUNCTION__, 61 SkDebugf("%s id=%d nested=%d ccw=%d\n", __FUNCTION__,
64 topSegment->debugID(), globalState.nested(), topContour->isCcw() ); 62 topSegment->debugID(), globalState.nested(), topContour->isCcw() );
65 #endif 63 #endif
66 if ((globalState.nested() & 1) != SkToBool(topContour->isCcw())) { 64 if ((globalState.nested() & 1) != SkToBool(topContour->isCcw())) {
67 topContour->setReverse(); 65 topContour->setReverse();
68 writePath = true; 66 writePath = true;
69 } 67 }
70 topContour->markDone(); 68 topContour->markAllDone();
71 globalState.clearNested(); 69 globalState.clearNested();
72 } 70 }
73 if (!writePath) { 71 if (!writePath) {
74 path->setFillType(fillType); 72 path->setFillType(fillType);
75 return true; 73 return true;
76 } 74 }
77 SkPath empty; 75 SkPath empty;
78 SkPathWriter woundPath(empty); 76 SkPathWriter woundPath(empty);
79 SkOpContour* test = &contourHead; 77 SkOpContour* test = &contourHead;
80 do { 78 do {
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 sum.addPath(fPathRefs[index]); 169 sum.addPath(fPathRefs[index]);
172 } 170 }
173 } 171 }
174 reset(); 172 reset();
175 bool success = Simplify(sum, result); 173 bool success = Simplify(sum, result);
176 if (!success) { 174 if (!success) {
177 *result = original; 175 *result = original;
178 } 176 }
179 return success; 177 return success;
180 } 178 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698