| 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 |
| 12 SkOpContour contour; |
| 13 SkOpGlobalState globalState( NULL PATH_OPS_DEBUG_PARAMS(&contour)); |
| 11 // turn path into list of segments | 14 // turn path into list of segments |
| 12 SkTArray<SkOpContour> contours; | 15 SkOpEdgeBuilder builder(path, &contour, &allocator, &globalState); |
| 13 SkOpEdgeBuilder builder(path, contours); | 16 if (!builder.finish(&allocator)) { |
| 14 if (!builder.finish()) { | |
| 15 return false; | 17 return false; |
| 16 } | 18 } |
| 17 SkTArray<SkOpContour*, true> contourList; | 19 SkTDArray<SkOpContour* > contourList; |
| 18 MakeContourList(contours, contourList, false, false); | 20 MakeContourList(&contour, contourList, false, false); |
| 19 SkOpContour** currentPtr = contourList.begin(); | 21 SkOpContour** currentPtr = contourList.begin(); |
| 20 result->setEmpty(); | 22 result->setEmpty(); |
| 21 if (!currentPtr) { | 23 if (!currentPtr) { |
| 22 return true; | 24 return true; |
| 23 } | 25 } |
| 24 SkOpContour** listEnd = contourList.end(); | 26 SkOpContour** listEnd = contourList.end(); |
| 25 SkOpContour* current = *currentPtr++; | 27 SkOpContour* current = *currentPtr++; |
| 26 SkPathOpsBounds bounds = current->bounds(); | 28 SkPathOpsBounds bounds = current->bounds(); |
| 27 while (currentPtr != listEnd) { | 29 while (currentPtr != listEnd) { |
| 28 current = *currentPtr++; | 30 current = *currentPtr++; |
| 29 bounds.add(current->bounds()); | 31 bounds.add(current->bounds()); |
| 30 } | 32 } |
| 31 *result = bounds; | 33 *result = bounds; |
| 32 return true; | 34 return true; |
| 33 } | 35 } |
| OLD | NEW |