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 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 int order = reducer.reduce(quad); | 265 int order = reducer.reduce(quad); |
266 if (order == 2) { // quad became line | 266 if (order == 2) { // quad became line |
267 for (int index = 0; index < order; ++index) { | 267 for (int index = 0; index < order; ++index) { |
268 *reducePts++ = reducer.fLine[index].asSkPoint(); | 268 *reducePts++ = reducer.fLine[index].asSkPoint(); |
269 } | 269 } |
270 } | 270 } |
271 return SkPathOpsPointsToVerb(order - 1); | 271 return SkPathOpsPointsToVerb(order - 1); |
272 } | 272 } |
273 | 273 |
274 SkPath::Verb SkReduceOrder::Cubic(const SkPoint a[4], SkPoint* reducePts) { | 274 SkPath::Verb SkReduceOrder::Cubic(const SkPoint a[4], SkPoint* reducePts) { |
| 275 if (SkDPoint::ApproximatelyEqual(a[0], a[1]) && SkDPoint::ApproximatelyEqual
(a[0], a[2]) |
| 276 && SkDPoint::ApproximatelyEqual(a[0], a[3])) { |
| 277 reducePts[0] = a[0]; |
| 278 return SkPath::kMove_Verb; |
| 279 } |
275 SkDCubic cubic; | 280 SkDCubic cubic; |
276 cubic.set(a); | 281 cubic.set(a); |
277 SkReduceOrder reducer; | 282 SkReduceOrder reducer; |
278 int order = reducer.reduce(cubic, kAllow_Quadratics); | 283 int order = reducer.reduce(cubic, kAllow_Quadratics); |
279 if (order == 2 || order == 3) { // cubic became line or quad | 284 if (order == 2 || order == 3) { // cubic became line or quad |
280 for (int index = 0; index < order; ++index) { | 285 for (int index = 0; index < order; ++index) { |
281 *reducePts++ = reducer.fQuad[index].asSkPoint(); | 286 *reducePts++ = reducer.fQuad[index].asSkPoint(); |
282 } | 287 } |
283 } | 288 } |
284 return SkPathOpsPointsToVerb(order - 1); | 289 return SkPathOpsPointsToVerb(order - 1); |
285 } | 290 } |
OLD | NEW |