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

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

Issue 2321973005: Rewriting path writer (Closed)
Patch Set: revert unneeded test changes Created 4 years, 3 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
« no previous file with comments | « src/pathops/SkPathOpsSimplify.cpp ('k') | src/pathops/SkPathWriter.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 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 }
OLDNEW
« no previous file with comments | « src/pathops/SkPathOpsSimplify.cpp ('k') | src/pathops/SkPathWriter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698