| 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 SkOpContourHead* contourList = static_cast<SkOpContourHead*>(&contour); | 13 SkOpContourHead* contourList = static_cast<SkOpContourHead*>(&contour); |
| 14 SkOpGlobalState globalState(contourList, &allocator SkDEBUGPARAMS(false) | 14 SkOpGlobalState globalState(contourList, &allocator SkDEBUGPARAMS(false) |
| 15 SkDEBUGPARAMS(nullptr)); | 15 SkDEBUGPARAMS(nullptr)); |
| 16 // turn path into list of segments | 16 // turn path into list of segments |
| 17 SkScalar scaleFactor = ScaleFactor(path); | 17 SkScalar scaleFactor = ScaleFactor(path); |
| 18 SkPath scaledPath; | 18 SkPath scaledPath; |
| 19 const SkPath* workingPath; | 19 const SkPath* workingPath; |
| 20 if (scaleFactor > SK_Scalar1) { | 20 if (scaleFactor > SK_Scalar1) { |
| 21 ScalePath(path, 1.f / scaleFactor, &scaledPath); | 21 ScalePath(path, 1.f / scaleFactor, &scaledPath); |
| 22 workingPath = &scaledPath; | 22 workingPath = &scaledPath; |
| 23 } else { | 23 } else { |
| 24 workingPath = &path; | 24 workingPath = &path; |
| 25 } | 25 } |
| 26 SkOpEdgeBuilder builder(*workingPath, &contour, &globalState); | 26 SkOpEdgeBuilder builder(*workingPath, contourList, &globalState); |
| 27 if (!builder.finish()) { | 27 if (!builder.finish()) { |
| 28 return false; | 28 return false; |
| 29 } | 29 } |
| 30 if (!SortContourList(&contourList, false, false)) { | 30 if (!SortContourList(&contourList, false, false)) { |
| 31 result->setEmpty(); | 31 result->setEmpty(); |
| 32 return true; | 32 return true; |
| 33 } | 33 } |
| 34 SkOpContour* current = contourList; | 34 SkOpContour* current = contourList; |
| 35 SkPathOpsBounds bounds = current->bounds(); | 35 SkPathOpsBounds bounds = current->bounds(); |
| 36 while ((current = current->next())) { | 36 while ((current = current->next())) { |
| 37 bounds.add(current->bounds()); | 37 bounds.add(current->bounds()); |
| 38 } | 38 } |
| 39 *result = bounds; | 39 *result = bounds; |
| 40 return true; | 40 return true; |
| 41 } | 41 } |
| OLD | NEW |