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 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 SkReduceOrder reducer; | 264 SkReduceOrder reducer; |
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::Conic(const SkPoint a[3], SkScalar weight, SkPoint*
reducePts) { |
| 275 SkPath::Verb verb = SkReduceOrder::Quad(a, reducePts); |
| 276 if (verb > SkPath::kLine_Verb && weight == 1) { |
| 277 return SkPath::kQuad_Verb; |
| 278 } |
| 279 return verb == SkPath::kQuad_Verb ? SkPath::kConic_Verb : verb; |
| 280 } |
| 281 |
274 SkPath::Verb SkReduceOrder::Cubic(const SkPoint a[4], SkPoint* reducePts) { | 282 SkPath::Verb SkReduceOrder::Cubic(const SkPoint a[4], SkPoint* reducePts) { |
275 if (SkDPoint::ApproximatelyEqual(a[0], a[1]) && SkDPoint::ApproximatelyEqual
(a[0], a[2]) | 283 if (SkDPoint::ApproximatelyEqual(a[0], a[1]) && SkDPoint::ApproximatelyEqual
(a[0], a[2]) |
276 && SkDPoint::ApproximatelyEqual(a[0], a[3])) { | 284 && SkDPoint::ApproximatelyEqual(a[0], a[3])) { |
277 reducePts[0] = a[0]; | 285 reducePts[0] = a[0]; |
278 return SkPath::kMove_Verb; | 286 return SkPath::kMove_Verb; |
279 } | 287 } |
280 SkDCubic cubic; | 288 SkDCubic cubic; |
281 cubic.set(a); | 289 cubic.set(a); |
282 SkReduceOrder reducer; | 290 SkReduceOrder reducer; |
283 int order = reducer.reduce(cubic, kAllow_Quadratics); | 291 int order = reducer.reduce(cubic, kAllow_Quadratics); |
284 if (order == 2 || order == 3) { // cubic became line or quad | 292 if (order == 2 || order == 3) { // cubic became line or quad |
285 for (int index = 0; index < order; ++index) { | 293 for (int index = 0; index < order; ++index) { |
286 *reducePts++ = reducer.fQuad[index].asSkPoint(); | 294 *reducePts++ = reducer.fQuad[index].asSkPoint(); |
287 } | 295 } |
288 } | 296 } |
289 return SkPathOpsPointsToVerb(order - 1); | 297 return SkPathOpsPointsToVerb(order - 1); |
290 } | 298 } |
OLD | NEW |