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

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

Issue 14034014: path ops -- use standard SkTQSort (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 2013 Google Inc. 2 * Copyright 2013 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 "SkIntersections.h" 7 #include "SkIntersections.h"
8 #include "SkOpContour.h" 8 #include "SkOpContour.h"
9 #include "SkPathWriter.h" 9 #include "SkPathWriter.h"
10 #include "TSearch.h" 10 #include "SkTSort.h"
11 11
12 void SkOpContour::addCoincident(int index, SkOpContour* other, int otherIndex, 12 void SkOpContour::addCoincident(int index, SkOpContour* other, int otherIndex,
13 const SkIntersections& ts, bool swap) { 13 const SkIntersections& ts, bool swap) {
14 SkCoincidence& coincidence = *fCoincidences.append(); 14 SkCoincidence& coincidence = *fCoincidences.append();
15 coincidence.fContours[0] = this; // FIXME: no need to store 15 coincidence.fContours[0] = this; // FIXME: no need to store
16 coincidence.fContours[1] = other; 16 coincidence.fContours[1] = other;
17 coincidence.fSegments[0] = index; 17 coincidence.fSegments[0] = index;
18 coincidence.fSegments[1] = otherIndex; 18 coincidence.fSegments[1] = otherIndex;
19 coincidence.fTs[swap][0] = ts[0][0]; 19 coincidence.fTs[swap][0] = ts[0][0];
20 coincidence.fTs[swap][1] = ts[0][1]; 20 coincidence.fTs[swap][1] = ts[0][1];
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 #endif 152 #endif
153 } 153 }
154 } 154 }
155 155
156 void SkOpContour::sortSegments() { 156 void SkOpContour::sortSegments() {
157 int segmentCount = fSegments.count(); 157 int segmentCount = fSegments.count();
158 fSortedSegments.setReserve(segmentCount); 158 fSortedSegments.setReserve(segmentCount);
159 for (int test = 0; test < segmentCount; ++test) { 159 for (int test = 0; test < segmentCount; ++test) {
160 *fSortedSegments.append() = &fSegments[test]; 160 *fSortedSegments.append() = &fSegments[test];
161 } 161 }
162 QSort<SkOpSegment>(fSortedSegments.begin(), fSortedSegments.end() - 1); 162 SkTQSort<SkOpSegment>(fSortedSegments.begin(), fSortedSegments.end() - 1);
163 fFirstSorted = 0; 163 fFirstSorted = 0;
164 } 164 }
165 165
166 void SkOpContour::toPath(SkPathWriter* path) const { 166 void SkOpContour::toPath(SkPathWriter* path) const {
167 int segmentCount = fSegments.count(); 167 int segmentCount = fSegments.count();
168 const SkPoint& pt = fSegments.front().pts()[0]; 168 const SkPoint& pt = fSegments.front().pts()[0];
169 path->deferredMove(pt); 169 path->deferredMove(pt);
170 for (int test = 0; test < segmentCount; ++test) { 170 for (int test = 0; test < segmentCount; ++test) {
171 fSegments[test].addCurveTo(0, 1, path, true); 171 fSegments[test].addCurveTo(0, 1, path, true);
172 } 172 }
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 SkDebugf("%s empty contour\n", __FUNCTION__); 255 SkDebugf("%s empty contour\n", __FUNCTION__);
256 SkASSERT(0); 256 SkASSERT(0);
257 // FIXME: delete empty contour? 257 // FIXME: delete empty contour?
258 return; 258 return;
259 } 259 }
260 fBounds = fSegments.front().bounds(); 260 fBounds = fSegments.front().bounds();
261 for (int index = 1; index < count; ++index) { 261 for (int index = 1; index < count; ++index) {
262 fBounds.add(fSegments[index].bounds()); 262 fBounds.add(fSegments[index].bounds());
263 } 263 }
264 } 264 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698