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 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 simple->close(); | 170 simple->close(); |
171 #if DEBUG_ACTIVE_SPANS | 171 #if DEBUG_ACTIVE_SPANS |
172 DebugShowActiveSpans(contourList); | 172 DebugShowActiveSpans(contourList); |
173 #endif | 173 #endif |
174 } | 174 } |
175 return closable; | 175 return closable; |
176 } | 176 } |
177 | 177 |
178 // FIXME : add this as a member of SkPath | 178 // FIXME : add this as a member of SkPath |
179 bool Simplify(const SkPath& path, SkPath* result) { | 179 bool Simplify(const SkPath& path, SkPath* result) { |
180 SkChunkAlloc allocator(4096); // FIXME: constant-ize, tune | |
181 // returns 1 for evenodd, -1 for winding, regardless of inverse-ness | 180 // returns 1 for evenodd, -1 for winding, regardless of inverse-ness |
182 SkPath::FillType fillType = path.isInverseFillType() ? SkPath::kInverseEvenO
dd_FillType | 181 SkPath::FillType fillType = path.isInverseFillType() ? SkPath::kInverseEvenO
dd_FillType |
183 : SkPath::kEvenOdd_FillType; | 182 : SkPath::kEvenOdd_FillType; |
184 if (path.isConvex()) { | 183 if (path.isConvex()) { |
185 if (result != &path) { | 184 if (result != &path) { |
186 *result = path; | 185 *result = path; |
187 } | 186 } |
188 result->setFillType(fillType); | 187 result->setFillType(fillType); |
189 return true; | 188 return true; |
190 } | 189 } |
191 // turn path into list of segments | 190 // turn path into list of segments |
192 SkOpCoincidence coincidence; | 191 SkOpCoincidence coincidence; |
193 SkOpContour contour; | 192 SkOpContour contour; |
194 SkOpGlobalState globalState(&coincidence PATH_OPS_DEBUG_PARAMS(&contour)); | 193 SkOpGlobalState globalState(&coincidence PATH_OPS_DEBUG_PARAMS(&contour)); |
195 #if DEBUG_SORT || DEBUG_SWAP_TOP | 194 #if DEBUG_SORT || DEBUG_SWAP_TOP |
196 SkPathOpsDebug::gSortCount = SkPathOpsDebug::gSortCountDefault; | 195 SkPathOpsDebug::gSortCount = SkPathOpsDebug::gSortCountDefault; |
197 #endif | 196 #endif |
| 197 SkChunkAlloc allocator(4096); // FIXME: constant-ize, tune |
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(); | 205 result->reset(); |
206 result->setFillType(fillType); | 206 result->setFillType(fillType); |
207 SkTDArray<SkOpContour* > contourList; | 207 SkTDArray<SkOpContour* > contourList; |
(...skipping 29 matching lines...) Expand all Loading... |
237 { // if some edges could not be resolved, assemble remaining fragments | 237 { // if some edges could not be resolved, assemble remaining fragments |
238 SkPath temp; | 238 SkPath temp; |
239 temp.setFillType(fillType); | 239 temp.setFillType(fillType); |
240 SkPathWriter assembled(temp); | 240 SkPathWriter assembled(temp); |
241 Assemble(wrapper, &assembled); | 241 Assemble(wrapper, &assembled); |
242 *result = *assembled.nativePath(); | 242 *result = *assembled.nativePath(); |
243 result->setFillType(fillType); | 243 result->setFillType(fillType); |
244 } | 244 } |
245 return true; | 245 return true; |
246 } | 246 } |
OLD | NEW |