OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 "SkReduceOrder.h" | 7 #include "SkReduceOrder.h" |
8 | 8 |
9 int SkReduceOrder::reduce(const SkDLine& line) { | 9 int SkReduceOrder::reduce(const SkDLine& line) { |
10 fLine[0] = line[0]; | 10 fLine[0] = line[0]; |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 return 3; | 154 return 3; |
155 } | 155 } |
156 | 156 |
157 static int check_linear(const SkDCubic& cubic, | 157 static int check_linear(const SkDCubic& cubic, |
158 int minX, int maxX, int minY, int maxY, SkDCubic& reduction) { | 158 int minX, int maxX, int minY, int maxY, SkDCubic& reduction) { |
159 int startIndex = 0; | 159 int startIndex = 0; |
160 int endIndex = 3; | 160 int endIndex = 3; |
161 while (cubic[startIndex].approximatelyEqual(cubic[endIndex])) { | 161 while (cubic[startIndex].approximatelyEqual(cubic[endIndex])) { |
162 --endIndex; | 162 --endIndex; |
163 if (endIndex == 0) { | 163 if (endIndex == 0) { |
164 SkDebugf("%s shouldn't get here if all four points are about equal\n
", __FUNCTION__); | 164 endIndex = 3; |
165 SkASSERT(0); | 165 break; |
166 } | 166 } |
167 } | 167 } |
168 if (!cubic.isLinear(startIndex, endIndex)) { | 168 if (!cubic.isLinear(startIndex, endIndex)) { |
169 return 0; | 169 return 0; |
170 } | 170 } |
171 // four are colinear: return line formed by outside | 171 // four are colinear: return line formed by outside |
172 reduction[0] = cubic[0]; | 172 reduction[0] = cubic[0]; |
173 reduction[1] = cubic[3]; | 173 reduction[1] = cubic[3]; |
174 return reductionLineCount(reduction); | 174 return reductionLineCount(reduction); |
175 } | 175 } |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 cubic.set(a); | 276 cubic.set(a); |
277 SkReduceOrder reducer; | 277 SkReduceOrder reducer; |
278 int order = reducer.reduce(cubic, kAllow_Quadratics); | 278 int order = reducer.reduce(cubic, kAllow_Quadratics); |
279 if (order == 2 || order == 3) { // cubic became line or quad | 279 if (order == 2 || order == 3) { // cubic became line or quad |
280 for (int index = 0; index < order; ++index) { | 280 for (int index = 0; index < order; ++index) { |
281 *reducePts++ = reducer.fQuad[index].asSkPoint(); | 281 *reducePts++ = reducer.fQuad[index].asSkPoint(); |
282 } | 282 } |
283 } | 283 } |
284 return SkPathOpsPointsToVerb(order - 1); | 284 return SkPathOpsPointsToVerb(order - 1); |
285 } | 285 } |
OLD | NEW |