| 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 #ifndef SkPathOpsCurve_DEFINE | 7 #ifndef SkPathOpsCurve_DEFINE |
| 8 #define SkPathOpsCurve_DEFINE | 8 #define SkPathOpsCurve_DEFINE |
| 9 | 9 |
| 10 #include "SkPathOpsCubic.h" | 10 #include "SkPathOpsCubic.h" |
| 11 #include "SkPathOpsLine.h" | 11 #include "SkPathOpsLine.h" |
| 12 #include "SkPathOpsQuad.h" | 12 #include "SkPathOpsQuad.h" |
| 13 | 13 |
| 14 static SkDPoint dline_xy_at_t(const SkPoint a[2], double t) { | 14 static SkDPoint dline_xy_at_t(const SkPoint a[2], double t) { |
| 15 SkDLine line; | 15 SkDLine line; |
| 16 line.set(a); | 16 line.set(a); |
| 17 return line.xyAtT(t); | 17 return line.ptAtT(t); |
| 18 } | 18 } |
| 19 | 19 |
| 20 static SkDPoint dquad_xy_at_t(const SkPoint a[3], double t) { | 20 static SkDPoint dquad_xy_at_t(const SkPoint a[3], double t) { |
| 21 SkDQuad quad; | 21 SkDQuad quad; |
| 22 quad.set(a); | 22 quad.set(a); |
| 23 return quad.xyAtT(t); | 23 return quad.ptAtT(t); |
| 24 } | 24 } |
| 25 | 25 |
| 26 static SkDPoint dcubic_xy_at_t(const SkPoint a[4], double t) { | 26 static SkDPoint dcubic_xy_at_t(const SkPoint a[4], double t) { |
| 27 SkDCubic cubic; | 27 SkDCubic cubic; |
| 28 cubic.set(a); | 28 cubic.set(a); |
| 29 return cubic.xyAtT(t); | 29 return cubic.ptAtT(t); |
| 30 } | 30 } |
| 31 | 31 |
| 32 static SkDPoint (* const CurveDPointAtT[])(const SkPoint[], double ) = { | 32 static SkDPoint (* const CurveDPointAtT[])(const SkPoint[], double ) = { |
| 33 NULL, | 33 NULL, |
| 34 dline_xy_at_t, | 34 dline_xy_at_t, |
| 35 dquad_xy_at_t, | 35 dquad_xy_at_t, |
| 36 dcubic_xy_at_t | 36 dcubic_xy_at_t |
| 37 }; | 37 }; |
| 38 | 38 |
| 39 static SkPoint fline_xy_at_t(const SkPoint a[2], double t) { | 39 static SkPoint fline_xy_at_t(const SkPoint a[2], double t) { |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 static SkPoint (* const CurveTop[])(const SkPoint[], double , double ) = { | 116 static SkPoint (* const CurveTop[])(const SkPoint[], double , double ) = { |
| 117 NULL, | 117 NULL, |
| 118 NULL, | 118 NULL, |
| 119 quad_top, | 119 quad_top, |
| 120 cubic_top | 120 cubic_top |
| 121 }; | 121 }; |
| 122 | 122 |
| 123 static bool line_is_vertical(const SkPoint a[2], double startT, double endT) { | 123 static bool line_is_vertical(const SkPoint a[2], double startT, double endT) { |
| 124 SkDLine line; | 124 SkDLine line; |
| 125 line.set(a); | 125 line.set(a); |
| 126 SkDPoint dst[2] = { line.xyAtT(startT), line.xyAtT(endT) }; | 126 SkDPoint dst[2] = { line.ptAtT(startT), line.ptAtT(endT) }; |
| 127 return AlmostEqualUlps(dst[0].fX, dst[1].fX); | 127 return AlmostEqualUlps(dst[0].fX, dst[1].fX); |
| 128 } | 128 } |
| 129 | 129 |
| 130 static bool quad_is_vertical(const SkPoint a[3], double startT, double endT) { | 130 static bool quad_is_vertical(const SkPoint a[3], double startT, double endT) { |
| 131 SkDQuad quad; | 131 SkDQuad quad; |
| 132 quad.set(a); | 132 quad.set(a); |
| 133 SkDQuad dst = quad.subDivide(startT, endT); | 133 SkDQuad dst = quad.subDivide(startT, endT); |
| 134 return AlmostEqualUlps(dst[0].fX, dst[1].fX) && AlmostEqualUlps(dst[1].fX, d
st[2].fX); | 134 return AlmostEqualUlps(dst[0].fX, dst[1].fX) && AlmostEqualUlps(dst[1].fX, d
st[2].fX); |
| 135 } | 135 } |
| 136 | 136 |
| 137 static bool cubic_is_vertical(const SkPoint a[4], double startT, double endT) { | 137 static bool cubic_is_vertical(const SkPoint a[4], double startT, double endT) { |
| 138 SkDCubic cubic; | 138 SkDCubic cubic; |
| 139 cubic.set(a); | 139 cubic.set(a); |
| 140 SkDCubic dst = cubic.subDivide(startT, endT); | 140 SkDCubic dst = cubic.subDivide(startT, endT); |
| 141 return AlmostEqualUlps(dst[0].fX, dst[1].fX) && AlmostEqualUlps(dst[1].fX, d
st[2].fX) | 141 return AlmostEqualUlps(dst[0].fX, dst[1].fX) && AlmostEqualUlps(dst[1].fX, d
st[2].fX) |
| 142 && AlmostEqualUlps(dst[2].fX, dst[3].fX); | 142 && AlmostEqualUlps(dst[2].fX, dst[3].fX); |
| 143 } | 143 } |
| 144 | 144 |
| 145 static bool (* const CurveIsVertical[])(const SkPoint[], double , double) = { | 145 static bool (* const CurveIsVertical[])(const SkPoint[], double , double) = { |
| 146 NULL, | 146 NULL, |
| 147 line_is_vertical, | 147 line_is_vertical, |
| 148 quad_is_vertical, | 148 quad_is_vertical, |
| 149 cubic_is_vertical | 149 cubic_is_vertical |
| 150 }; | 150 }; |
| 151 | 151 |
| 152 #endif | 152 #endif |
| OLD | NEW |