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

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

Issue 14371011: path ops : add support for inverse fill (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
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 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 return closable; 142 return closable;
143 } 143 }
144 144
145 // FIXME : add this as a member of SkPath 145 // FIXME : add this as a member of SkPath
146 void Simplify(const SkPath& path, SkPath* result) { 146 void Simplify(const SkPath& path, SkPath* result) {
147 #if DEBUG_SORT || DEBUG_SWAP_TOP 147 #if DEBUG_SORT || DEBUG_SWAP_TOP
148 gDebugSortCount = gDebugSortCountDefault; 148 gDebugSortCount = gDebugSortCountDefault;
149 #endif 149 #endif
150 // returns 1 for evenodd, -1 for winding, regardless of inverse-ness 150 // returns 1 for evenodd, -1 for winding, regardless of inverse-ness
151 result->reset(); 151 result->reset();
152 result->setFillType(SkPath::kEvenOdd_FillType); 152 SkPath::FillType fillType = path.isInverseFillType() ? SkPath::kInverseEvenO dd_FillType
153 : SkPath::kEvenOdd_FillType;
154 result->setFillType(fillType);
153 SkPathWriter simple(*result); 155 SkPathWriter simple(*result);
154 156
155 // turn path into list of segments 157 // turn path into list of segments
156 SkTArray<SkOpContour> contours; 158 SkTArray<SkOpContour> contours;
157 SkOpEdgeBuilder builder(path, contours); 159 SkOpEdgeBuilder builder(path, contours);
158 builder.finish(); 160 builder.finish();
159 SkTDArray<SkOpContour*> contourList; 161 SkTDArray<SkOpContour*> contourList;
160 MakeContourList(contours, contourList, false, false); 162 MakeContourList(contours, contourList, false, false);
161 SkOpContour** currentPtr = contourList.begin(); 163 SkOpContour** currentPtr = contourList.begin();
162 if (!currentPtr) { 164 if (!currentPtr) {
(...skipping 17 matching lines...) Expand all
180 FixOtherTIndex(&contourList); 182 FixOtherTIndex(&contourList);
181 SortSegments(&contourList); 183 SortSegments(&contourList);
182 #if DEBUG_ACTIVE_SPANS 184 #if DEBUG_ACTIVE_SPANS
183 DebugShowActiveSpans(contourList); 185 DebugShowActiveSpans(contourList);
184 #endif 186 #endif
185 // construct closed contours 187 // construct closed contours
186 if (builder.xorMask() == kWinding_PathOpsMask ? bridgeWinding(contourList, & simple) 188 if (builder.xorMask() == kWinding_PathOpsMask ? bridgeWinding(contourList, & simple)
187 : !bridgeXor(contourList, &simple)) 189 : !bridgeXor(contourList, &simple))
188 { // if some edges could not be resolved, assemble remaining fragments 190 { // if some edges could not be resolved, assemble remaining fragments
189 SkPath temp; 191 SkPath temp;
190 temp.setFillType(SkPath::kEvenOdd_FillType); 192 temp.setFillType(fillType);
191 SkPathWriter assembled(temp); 193 SkPathWriter assembled(temp);
192 Assemble(simple, &assembled); 194 Assemble(simple, &assembled);
193 *result = *assembled.nativePath(); 195 *result = *assembled.nativePath();
194 } 196 }
195 } 197 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698