OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 "SkOpEdgeBuilder.h" | 7 #include "SkOpEdgeBuilder.h" |
8 #include "SkPathOpsCommon.h" | 8 #include "SkPathOpsCommon.h" |
9 | 9 |
10 bool TightBounds(const SkPath& path, SkRect* result) { | 10 bool TightBounds(const SkPath& path, SkRect* result) { |
11 SkChunkAlloc allocator(4096); // FIXME: constant-ize, tune | 11 SkChunkAlloc allocator(4096); // FIXME: constant-ize, tune |
12 SkOpContour contour; | 12 SkOpContour contour; |
13 SkOpGlobalState globalState( NULL SkDEBUGPARAMS(&contour)); | 13 SkOpContourHead* contourList = static_cast<SkOpContourHead*>(&contour); |
| 14 SkOpGlobalState globalState(NULL, contourList); |
14 // turn path into list of segments | 15 // turn path into list of segments |
15 SkOpEdgeBuilder builder(path, &contour, &allocator, &globalState); | 16 SkOpEdgeBuilder builder(path, &contour, &allocator, &globalState); |
16 if (!builder.finish(&allocator)) { | 17 if (!builder.finish(&allocator)) { |
17 return false; | 18 return false; |
18 } | 19 } |
19 SkTDArray<SkOpContour* > contourList; | 20 if (!SortContourList(&contourList, false, false)) { |
20 MakeContourList(&contour, contourList, false, false); | 21 result->setEmpty(); |
21 SkOpContour** currentPtr = contourList.begin(); | |
22 result->setEmpty(); | |
23 if (!currentPtr) { | |
24 return true; | 22 return true; |
25 } | 23 } |
26 SkOpContour** listEnd = contourList.end(); | 24 SkOpContour* current = contourList; |
27 SkOpContour* current = *currentPtr++; | |
28 SkPathOpsBounds bounds = current->bounds(); | 25 SkPathOpsBounds bounds = current->bounds(); |
29 while (currentPtr != listEnd) { | 26 while ((current = current->next())) { |
30 current = *currentPtr++; | |
31 bounds.add(current->bounds()); | 27 bounds.add(current->bounds()); |
32 } | 28 } |
33 *result = bounds; | 29 *result = bounds; |
34 return true; | 30 return true; |
35 } | 31 } |
OLD | NEW |