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

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

Issue 1037953004: add conics to path ops (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix linux build Created 5 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
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 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 if (path.isConvex()) { 184 if (path.isConvex()) {
185 if (result != &path) { 185 if (result != &path) {
186 *result = path; 186 *result = path;
187 } 187 }
188 result->setFillType(fillType); 188 result->setFillType(fillType);
189 return true; 189 return true;
190 } 190 }
191 // turn path into list of segments 191 // turn path into list of segments
192 SkOpCoincidence coincidence; 192 SkOpCoincidence coincidence;
193 SkOpContour contour; 193 SkOpContour contour;
194 SkOpGlobalState globalState(&coincidence PATH_OPS_DEBUG_PARAMS(&contour)); 194 SkOpGlobalState globalState(&coincidence SkDEBUGPARAMS(&contour));
195 #if DEBUG_SORT || DEBUG_SWAP_TOP 195 #if DEBUG_SORT || DEBUG_SWAP_TOP
196 SkPathOpsDebug::gSortCount = SkPathOpsDebug::gSortCountDefault; 196 SkPathOpsDebug::gSortCount = SkPathOpsDebug::gSortCountDefault;
197 #endif 197 #endif
198 SkOpEdgeBuilder builder(path, &contour, &allocator, &globalState); 198 SkOpEdgeBuilder builder(path, &contour, &allocator, &globalState);
199 if (!builder.finish(&allocator)) { 199 if (!builder.finish(&allocator)) {
200 return false; 200 return false;
201 } 201 }
202 #if !FORCE_RELEASE 202 #if !FORCE_RELEASE
203 contour.dumpSegments((SkPathOp) -1); 203 contour.dumpSegments((SkPathOp) -1);
204 #endif 204 #endif
205 result->reset();
206 result->setFillType(fillType);
207 SkTDArray<SkOpContour* > contourList; 205 SkTDArray<SkOpContour* > contourList;
208 MakeContourList(&contour, contourList, false, false); 206 MakeContourList(&contour, contourList, false, false);
209 SkOpContour** currentPtr = contourList.begin(); 207 SkOpContour** currentPtr = contourList.begin();
210 if (!currentPtr) { 208 if (!currentPtr) {
209 result->reset();
210 result->setFillType(fillType);
211 return true; 211 return true;
212 } 212 }
213 if ((*currentPtr)->count() == 0) { 213 if ((*currentPtr)->count() == 0) {
214 SkASSERT((*currentPtr)->next() == NULL); 214 SkASSERT((*currentPtr)->next() == NULL);
215 result->reset();
216 result->setFillType(fillType);
215 return true; 217 return true;
216 } 218 }
217 SkOpContour** listEnd2 = contourList.end(); 219 SkOpContour** listEnd2 = contourList.end();
218 // find all intersections between segments 220 // find all intersections between segments
219 do { 221 do {
220 SkOpContour** nextPtr = currentPtr; 222 SkOpContour** nextPtr = currentPtr;
221 SkOpContour* current = *currentPtr++; 223 SkOpContour* current = *currentPtr++;
222 SkOpContour* next; 224 SkOpContour* next;
223 do { 225 do {
224 next = *nextPtr++; 226 next = *nextPtr++;
225 } while (AddIntersectTs(current, next, &coincidence, &allocator) && next Ptr != listEnd2); 227 } while (AddIntersectTs(current, next, &coincidence, &allocator) && next Ptr != listEnd2);
226 } while (currentPtr != listEnd2); 228 } while (currentPtr != listEnd2);
227 #if DEBUG_VALIDATE 229 #if DEBUG_VALIDATE
228 globalState.setPhase(SkOpGlobalState::kWalking); 230 globalState.setPhase(SkOpGlobalState::kWalking);
229 #endif 231 #endif
230 if (!HandleCoincidence(&contourList, &coincidence, &allocator, &globalState) ) { 232 if (!HandleCoincidence(&contourList, &coincidence, &allocator, &globalState) ) {
231 return false; 233 return false;
232 } 234 }
233 // construct closed contours 235 // construct closed contours
236 result->reset();
237 result->setFillType(fillType);
234 SkPathWriter wrapper(*result); 238 SkPathWriter wrapper(*result);
235 if (builder.xorMask() == kWinding_PathOpsMask ? bridgeWinding(contourList, & wrapper, &allocator) 239 if (builder.xorMask() == kWinding_PathOpsMask ? bridgeWinding(contourList, & wrapper, &allocator)
236 : !bridgeXor(contourList, &wrapper, &allocator)) 240 : !bridgeXor(contourList, &wrapper, &allocator))
237 { // if some edges could not be resolved, assemble remaining fragments 241 { // if some edges could not be resolved, assemble remaining fragments
238 SkPath temp; 242 SkPath temp;
239 temp.setFillType(fillType); 243 temp.setFillType(fillType);
240 SkPathWriter assembled(temp); 244 SkPathWriter assembled(temp);
241 Assemble(wrapper, &assembled); 245 Assemble(wrapper, &assembled);
242 *result = *assembled.nativePath(); 246 *result = *assembled.nativePath();
243 result->setFillType(fillType); 247 result->setFillType(fillType);
244 } 248 }
245 return true; 249 return true;
246 } 250 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698