| 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 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 418 return result; | 418 return result; |
| 419 } | 419 } |
| 420 if (allowQuadratics == SkReduceOrder::kAllow_Quadratics | 420 if (allowQuadratics == SkReduceOrder::kAllow_Quadratics |
| 421 && (result = check_quadratic(cubic, fCubic))) { | 421 && (result = check_quadratic(cubic, fCubic))) { |
| 422 return result; | 422 return result; |
| 423 } | 423 } |
| 424 fCubic = cubic; | 424 fCubic = cubic; |
| 425 return 4; | 425 return 4; |
| 426 } | 426 } |
| 427 | 427 |
| 428 SkPath::Verb SkReduceOrder::Quad(const SkPoint a[3], SkTArray<SkPoint, true>* re
ducePts) { | 428 SkPath::Verb SkReduceOrder::Quad(const SkPoint a[3], SkPoint* reducePts) { |
| 429 SkDQuad quad; | 429 SkDQuad quad; |
| 430 quad.set(a); | 430 quad.set(a); |
| 431 SkReduceOrder reducer; | 431 SkReduceOrder reducer; |
| 432 int order = reducer.reduce(quad, kFill_Style); | 432 int order = reducer.reduce(quad, kFill_Style); |
| 433 if (order == 2) { // quad became line | 433 if (order == 2) { // quad became line |
| 434 for (int index = 0; index < order; ++index) { | 434 for (int index = 0; index < order; ++index) { |
| 435 SkPoint& pt = reducePts->push_back(); | 435 *reducePts++ = reducer.fLine[index].asSkPoint(); |
| 436 pt.fX = SkDoubleToScalar(reducer.fLine[index].fX); | |
| 437 pt.fY = SkDoubleToScalar(reducer.fLine[index].fY); | |
| 438 } | 436 } |
| 439 } | 437 } |
| 440 return SkPathOpsPointsToVerb(order - 1); | 438 return SkPathOpsPointsToVerb(order - 1); |
| 441 } | 439 } |
| 442 | 440 |
| 443 SkPath::Verb SkReduceOrder::Cubic(const SkPoint a[4], SkTArray<SkPoint, true>* r
educePts) { | 441 SkPath::Verb SkReduceOrder::Cubic(const SkPoint a[4], SkPoint* reducePts) { |
| 444 SkDCubic cubic; | 442 SkDCubic cubic; |
| 445 cubic.set(a); | 443 cubic.set(a); |
| 446 SkReduceOrder reducer; | 444 SkReduceOrder reducer; |
| 447 int order = reducer.reduce(cubic, kAllow_Quadratics, kFill_Style); | 445 int order = reducer.reduce(cubic, kAllow_Quadratics, kFill_Style); |
| 448 if (order == 2 || order == 3) { // cubic became line or quad | 446 if (order == 2 || order == 3) { // cubic became line or quad |
| 449 for (int index = 0; index < order; ++index) { | 447 for (int index = 0; index < order; ++index) { |
| 450 SkPoint& pt = reducePts->push_back(); | 448 *reducePts++ = reducer.fQuad[index].asSkPoint(); |
| 451 pt.fX = SkDoubleToScalar(reducer.fQuad[index].fX); | |
| 452 pt.fY = SkDoubleToScalar(reducer.fQuad[index].fY); | |
| 453 } | 449 } |
| 454 } | 450 } |
| 455 return SkPathOpsPointsToVerb(order - 1); | 451 return SkPathOpsPointsToVerb(order - 1); |
| 456 } | 452 } |
| OLD | NEW |