OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2006 The Android Open Source Project | 2 * Copyright 2006 The Android Open Source Project |
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 | 7 |
8 #include <cmath> | 8 #include <cmath> |
9 #include "SkBuffer.h" | 9 #include "SkBuffer.h" |
10 #include "SkCubicClipper.h" | 10 #include "SkCubicClipper.h" |
(...skipping 2795 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2806 if (x < min) { | 2806 if (x < min) { |
2807 return 0; | 2807 return 0; |
2808 } | 2808 } |
2809 if (x > max) { | 2809 if (x > max) { |
2810 return dir; | 2810 return dir; |
2811 } | 2811 } |
2812 | 2812 |
2813 // compute the actual x(t) value | 2813 // compute the actual x(t) value |
2814 SkScalar t; | 2814 SkScalar t; |
2815 if (!SkCubicClipper::ChopMonoAtY(pts, y, &t)) { | 2815 if (!SkCubicClipper::ChopMonoAtY(pts, y, &t)) { |
2816 return 0; | 2816 return 0; |
2817 } | 2817 } |
2818 SkScalar xt = eval_cubic_pts(pts[0].fX, pts[1].fX, pts[2].fX, pts[3].fX, t); | 2818 SkScalar xt = eval_cubic_pts(pts[0].fX, pts[1].fX, pts[2].fX, pts[3].fX, t); |
2819 if (SkScalarNearlyEqual(xt, x)) { | 2819 if (SkScalarNearlyEqual(xt, x)) { |
2820 if (x != pts[3].fX || y != pts[3].fY) { // don't test end points; they'
re start points | 2820 if (x != pts[3].fX || y != pts[3].fY) { // don't test end points; they'
re start points |
2821 *onCurveCount += 1; | 2821 *onCurveCount += 1; |
2822 return 0; | 2822 return 0; |
2823 } | 2823 } |
2824 } | 2824 } |
2825 return xt < x ? dir : 0; | 2825 return xt < x ? dir : 0; |
2826 } | 2826 } |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3045 if (!between(pts[0].fX, x, pts[1].fX) && !between(pts[1].fX, x, pts[2].fX) | 3045 if (!between(pts[0].fX, x, pts[1].fX) && !between(pts[1].fX, x, pts[2].fX) |
3046 && !between(pts[2].fX, x, pts[3].fX)) { | 3046 && !between(pts[2].fX, x, pts[3].fX)) { |
3047 return; | 3047 return; |
3048 } | 3048 } |
3049 SkPoint dst[10]; | 3049 SkPoint dst[10]; |
3050 int n = SkChopCubicAtYExtrema(pts, dst); | 3050 int n = SkChopCubicAtYExtrema(pts, dst); |
3051 for (int i = 0; i <= n; ++i) { | 3051 for (int i = 0; i <= n; ++i) { |
3052 SkPoint* c = &dst[i * 3]; | 3052 SkPoint* c = &dst[i * 3]; |
3053 SkScalar t; | 3053 SkScalar t; |
3054 if (!SkCubicClipper::ChopMonoAtY(c, y, &t)) { | 3054 if (!SkCubicClipper::ChopMonoAtY(c, y, &t)) { |
3055 continue; | 3055 continue; |
3056 } | 3056 } |
3057 SkScalar xt = eval_cubic_pts(c[0].fX, c[1].fX, c[2].fX, c[3].fX, t); | 3057 SkScalar xt = eval_cubic_pts(c[0].fX, c[1].fX, c[2].fX, c[3].fX, t); |
3058 if (!SkScalarNearlyEqual(x, xt)) { | 3058 if (!SkScalarNearlyEqual(x, xt)) { |
3059 continue; | 3059 continue; |
3060 } | 3060 } |
3061 SkVector tangent; | 3061 SkVector tangent; |
3062 SkEvalCubicAt(c, t, nullptr, &tangent, nullptr); | 3062 SkEvalCubicAt(c, t, nullptr, &tangent, nullptr); |
3063 tangents->push(tangent); | 3063 tangents->push(tangent); |
3064 } | 3064 } |
3065 } | 3065 } |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3242 } | 3242 } |
3243 } while (!done); | 3243 } while (!done); |
3244 return SkToBool(tangents.count()) ^ isInverse; | 3244 return SkToBool(tangents.count()) ^ isInverse; |
3245 } | 3245 } |
3246 | 3246 |
3247 int SkPath::ConvertConicToQuads(const SkPoint& p0, const SkPoint& p1, const SkPo
int& p2, | 3247 int SkPath::ConvertConicToQuads(const SkPoint& p0, const SkPoint& p1, const SkPo
int& p2, |
3248 SkScalar w, SkPoint pts[], int pow2) { | 3248 SkScalar w, SkPoint pts[], int pow2) { |
3249 const SkConic conic(p0, p1, p2, w); | 3249 const SkConic conic(p0, p1, p2, w); |
3250 return conic.chopIntoQuadsPOW2(pts, pow2); | 3250 return conic.chopIntoQuadsPOW2(pts, pow2); |
3251 } | 3251 } |
OLD | NEW |