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

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

Issue 1394503003: fix some pathops bugs found in 1M skps (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: init to avoid warning Created 5 years, 2 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
« no previous file with comments | « src/pathops/SkPathOpsOp.cpp ('k') | src/pathops/SkPathOpsTSect.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 "SkOpCoincidence.h" 8 #include "SkOpCoincidence.h"
9 #include "SkOpEdgeBuilder.h" 9 #include "SkOpEdgeBuilder.h"
10 #include "SkPathOpsCommon.h" 10 #include "SkPathOpsCommon.h"
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 SkOpContourHead* contourList = static_cast<SkOpContourHead*>(&contour); 169 SkOpContourHead* contourList = static_cast<SkOpContourHead*>(&contour);
170 SkOpGlobalState globalState(&coincidence, contourList SkDEBUGPARAMS(nullptr )); 170 SkOpGlobalState globalState(&coincidence, contourList SkDEBUGPARAMS(nullptr ));
171 #if DEBUG_SORT 171 #if DEBUG_SORT
172 SkPathOpsDebug::gSortCount = SkPathOpsDebug::gSortCountDefault; 172 SkPathOpsDebug::gSortCount = SkPathOpsDebug::gSortCountDefault;
173 #endif 173 #endif
174 SkOpEdgeBuilder builder(path, &contour, &allocator, &globalState); 174 SkOpEdgeBuilder builder(path, &contour, &allocator, &globalState);
175 if (!builder.finish(&allocator)) { 175 if (!builder.finish(&allocator)) {
176 return false; 176 return false;
177 } 177 }
178 #if DEBUG_DUMP_SEGMENTS 178 #if DEBUG_DUMP_SEGMENTS
179 contour.dumpSegments((SkPathOp) -1); 179 contour.dumpSegments();
180 #endif 180 #endif
181 if (!SortContourList(&contourList, false, false)) { 181 if (!SortContourList(&contourList, false, false)) {
182 result->reset(); 182 result->reset();
183 result->setFillType(fillType); 183 result->setFillType(fillType);
184 return true; 184 return true;
185 } 185 }
186 // find all intersections between segments 186 // find all intersections between segments
187 SkOpContour* current = contourList; 187 SkOpContour* current = contourList;
188 do { 188 do {
189 SkOpContour* next = current; 189 SkOpContour* next = current;
190 while (AddIntersectTs(current, next, &coincidence, &allocator) 190 while (AddIntersectTs(current, next, &coincidence, &allocator)
191 && (next = next->next())); 191 && (next = next->next()));
192 } while ((current = current->next())); 192 } while ((current = current->next()));
193 #if DEBUG_VALIDATE 193 #if DEBUG_VALIDATE
194 globalState.setPhase(SkOpGlobalState::kWalking); 194 globalState.setPhase(SkOpGlobalState::kWalking);
195 #endif 195 #endif
196 if (!HandleCoincidence(contourList, &coincidence, &allocator)) { 196 if (!HandleCoincidence(contourList, &coincidence, &allocator)) {
197 return false; 197 return false;
198 } 198 }
199 #if DEBUG_DUMP_ALIGNMENT
200 contour.dumpSegments("aligned");
201 #endif
199 // construct closed contours 202 // construct closed contours
200 result->reset(); 203 result->reset();
201 result->setFillType(fillType); 204 result->setFillType(fillType);
202 SkPathWriter wrapper(*result); 205 SkPathWriter wrapper(*result);
203 if (builder.xorMask() == kWinding_PathOpsMask ? bridgeWinding(contourList, & wrapper, &allocator) 206 if (builder.xorMask() == kWinding_PathOpsMask ? bridgeWinding(contourList, & wrapper, &allocator)
204 : !bridgeXor(contourList, &wrapper, &allocator)) 207 : !bridgeXor(contourList, &wrapper, &allocator))
205 { // if some edges could not be resolved, assemble remaining fragments 208 { // if some edges could not be resolved, assemble remaining fragments
206 SkPath temp; 209 SkPath temp;
207 temp.setFillType(fillType); 210 temp.setFillType(fillType);
208 SkPathWriter assembled(temp); 211 SkPathWriter assembled(temp);
209 Assemble(wrapper, &assembled); 212 Assemble(wrapper, &assembled);
210 *result = *assembled.nativePath(); 213 *result = *assembled.nativePath();
211 result->setFillType(fillType); 214 result->setFillType(fillType);
212 } 215 }
213 return true; 216 return true;
214 } 217 }
215 218
OLDNEW
« no previous file with comments | « src/pathops/SkPathOpsOp.cpp ('k') | src/pathops/SkPathOpsTSect.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698