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

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

Issue 1187273005: initialize firstDir (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase first next time Created 5 years, 6 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 | « no previous file | no next file » | 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 7
8 #include "SkMatrix.h" 8 #include "SkMatrix.h"
9 #include "SkOpEdgeBuilder.h" 9 #include "SkOpEdgeBuilder.h"
10 #include "SkPathPriv.h" 10 #include "SkPathPriv.h"
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 fOps.reset(); 99 fOps.reset();
100 } 100 }
101 101
102 /* OPTIMIZATION: Union doesn't need to be all-or-nothing. A run of three or more convex 102 /* OPTIMIZATION: Union doesn't need to be all-or-nothing. A run of three or more convex
103 paths with union ops could be locally resolved and still improve over doing t he 103 paths with union ops could be locally resolved and still improve over doing t he
104 ops one at a time. */ 104 ops one at a time. */
105 bool SkOpBuilder::resolve(SkPath* result) { 105 bool SkOpBuilder::resolve(SkPath* result) {
106 SkPath original = *result; 106 SkPath original = *result;
107 int count = fOps.count(); 107 int count = fOps.count();
108 bool allUnion = true; 108 bool allUnion = true;
109 SkPathPriv::FirstDirection firstDir; 109 SkPathPriv::FirstDirection firstDir = SkPathPriv::kUnknown_FirstDirection;
110 for (int index = 0; index < count; ++index) { 110 for (int index = 0; index < count; ++index) {
111 SkPath* test = &fPathRefs[index]; 111 SkPath* test = &fPathRefs[index];
112 if (kUnion_SkPathOp != fOps[index] || test->isInverseFillType()) { 112 if (kUnion_SkPathOp != fOps[index] || test->isInverseFillType()) {
113 allUnion = false; 113 allUnion = false;
114 break; 114 break;
115 } 115 }
116 // If all paths are convex, track direction, reversing as needed. 116 // If all paths are convex, track direction, reversing as needed.
117 if (test->isConvex()) { 117 if (test->isConvex()) {
118 SkPathPriv::FirstDirection dir; 118 SkPathPriv::FirstDirection dir;
119 if (!SkPathPriv::CheapComputeFirstDirection(*test, &dir)) { 119 if (!SkPathPriv::CheapComputeFirstDirection(*test, &dir)) {
120 allUnion = false; 120 allUnion = false;
121 break; 121 break;
122 } 122 }
123 if (index == 0) { 123 if (firstDir == SkPathPriv::kUnknown_FirstDirection) {
124 firstDir = dir; 124 firstDir = dir;
125 } else if (firstDir != dir) { 125 } else if (firstDir != dir) {
126 SkPath temp; 126 SkPath temp;
127 temp.reverseAddPath(*test); 127 temp.reverseAddPath(*test);
128 *test = temp; 128 *test = temp;
129 } 129 }
130 continue; 130 continue;
131 } 131 }
132 // If the path is not convex but its bounds do not intersect the others, simplify is enough. 132 // If the path is not convex but its bounds do not intersect the others, simplify is enough.
133 const SkRect& testBounds = test->getBounds(); 133 const SkRect& testBounds = test->getBounds();
(...skipping 28 matching lines...) Expand all
162 FixWinding(&fPathRefs[index]); 162 FixWinding(&fPathRefs[index]);
163 sum.addPath(fPathRefs[index]); 163 sum.addPath(fPathRefs[index]);
164 } 164 }
165 reset(); 165 reset();
166 bool success = Simplify(sum, result); 166 bool success = Simplify(sum, result);
167 if (!success) { 167 if (!success) {
168 *result = original; 168 *result = original;
169 } 169 }
170 return success; 170 return success;
171 } 171 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698