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

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

Issue 16951017: convert pathops to use SkSTArray where possible. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: pathops use SkTArray Created 7 years, 6 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
« no previous file with comments | « src/pathops/SkPathOpsOp.cpp ('k') | src/pathops/SkReduceOrder.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 "SkOpEdgeBuilder.h" 8 #include "SkOpEdgeBuilder.h"
9 #include "SkPathOpsCommon.h" 9 #include "SkPathOpsCommon.h"
10 #include "SkPathWriter.h" 10 #include "SkPathWriter.h"
11 11
12 static bool bridgeWinding(SkTDArray<SkOpContour*>& contourList, SkPathWriter* si mple) { 12 static bool bridgeWinding(SkTArray<SkOpContour*, true>& contourList, SkPathWrite r* simple) {
13 bool firstContour = true; 13 bool firstContour = true;
14 bool unsortable = false; 14 bool unsortable = false;
15 bool topUnsortable = false; 15 bool topUnsortable = false;
16 SkPoint topLeft = {SK_ScalarMin, SK_ScalarMin}; 16 SkPoint topLeft = {SK_ScalarMin, SK_ScalarMin};
17 do { 17 do {
18 int index, endIndex; 18 int index, endIndex;
19 bool topDone; 19 bool topDone;
20 SkOpSegment* current = FindSortableTop(contourList, &firstContour, &inde x, &endIndex, 20 SkOpSegment* current = FindSortableTop(contourList, &firstContour, &inde x, &endIndex,
21 &topLeft, &topUnsortable, &topDone, false); 21 &topLeft, &topUnsortable, &topDone, false);
22 if (!current) { 22 if (!current) {
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 #endif 87 #endif
88 if (!current) { 88 if (!current) {
89 break; 89 break;
90 } 90 }
91 } while (true); 91 } while (true);
92 } while (true); 92 } while (true);
93 return simple->someAssemblyRequired(); 93 return simple->someAssemblyRequired();
94 } 94 }
95 95
96 // returns true if all edges were processed 96 // returns true if all edges were processed
97 static bool bridgeXor(SkTDArray<SkOpContour*>& contourList, SkPathWriter* simple ) { 97 static bool bridgeXor(SkTArray<SkOpContour*, true>& contourList, SkPathWriter* s imple) {
98 SkOpSegment* current; 98 SkOpSegment* current;
99 int start, end; 99 int start, end;
100 bool unsortable = false; 100 bool unsortable = false;
101 bool closable = true; 101 bool closable = true;
102 while ((current = FindUndone(contourList, &start, &end))) { 102 while ((current = FindUndone(contourList, &start, &end))) {
103 do { 103 do {
104 #if DEBUG_ACTIVE_SPANS 104 #if DEBUG_ACTIVE_SPANS
105 if (!unsortable && current->done()) { 105 if (!unsortable && current->done()) {
106 DebugShowActiveSpans(contourList); 106 DebugShowActiveSpans(contourList);
107 } 107 }
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 // returns 1 for evenodd, -1 for winding, regardless of inverse-ness 154 // returns 1 for evenodd, -1 for winding, regardless of inverse-ness
155 SkPath::FillType fillType = path.isInverseFillType() ? SkPath::kInverseEvenO dd_FillType 155 SkPath::FillType fillType = path.isInverseFillType() ? SkPath::kInverseEvenO dd_FillType
156 : SkPath::kEvenOdd_FillType; 156 : SkPath::kEvenOdd_FillType;
157 157
158 // turn path into list of segments 158 // turn path into list of segments
159 SkTArray<SkOpContour> contours; 159 SkTArray<SkOpContour> contours;
160 SkOpEdgeBuilder builder(path, contours); 160 SkOpEdgeBuilder builder(path, contours);
161 if (!builder.finish()) { 161 if (!builder.finish()) {
162 return false; 162 return false;
163 } 163 }
164 SkTDArray<SkOpContour*> contourList; 164 SkTArray<SkOpContour*, true> contourList;
165 MakeContourList(contours, contourList, false, false); 165 MakeContourList(contours, contourList, false, false);
166 SkOpContour** currentPtr = contourList.begin(); 166 SkOpContour** currentPtr = contourList.begin();
167 result->setFillType(fillType); 167 result->setFillType(fillType);
168 result->reset(); 168 result->reset();
169 if (!currentPtr) { 169 if (!currentPtr) {
170 return true; 170 return true;
171 } 171 }
172 SkOpContour** listEnd = contourList.end(); 172 SkOpContour** listEnd = contourList.end();
173 // find all intersections between segments 173 // find all intersections between segments
174 do { 174 do {
(...skipping 21 matching lines...) Expand all
196 { // if some edges could not be resolved, assemble remaining fragments 196 { // if some edges could not be resolved, assemble remaining fragments
197 SkPath temp; 197 SkPath temp;
198 temp.setFillType(fillType); 198 temp.setFillType(fillType);
199 SkPathWriter assembled(temp); 199 SkPathWriter assembled(temp);
200 Assemble(simple, &assembled); 200 Assemble(simple, &assembled);
201 *result = *assembled.nativePath(); 201 *result = *assembled.nativePath();
202 result->setFillType(fillType); 202 result->setFillType(fillType);
203 } 203 }
204 return true; 204 return true;
205 } 205 }
OLDNEW
« no previous file with comments | « src/pathops/SkPathOpsOp.cpp ('k') | src/pathops/SkReduceOrder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698