| 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 "SkBuffer.h" | 8 #include "SkBuffer.h" |
| 9 #include "SkCubicClipper.h" | 9 #include "SkCubicClipper.h" |
| 10 #include "SkErrorInternals.h" | 10 #include "SkErrorInternals.h" |
| (...skipping 2782 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2793 find_minmax<4>(pts, &min, &max); | 2793 find_minmax<4>(pts, &min, &max); |
| 2794 if (x < min) { | 2794 if (x < min) { |
| 2795 return 0; | 2795 return 0; |
| 2796 } | 2796 } |
| 2797 if (x > max) { | 2797 if (x > max) { |
| 2798 return dir; | 2798 return dir; |
| 2799 } | 2799 } |
| 2800 | 2800 |
| 2801 // compute the actual x(t) value | 2801 // compute the actual x(t) value |
| 2802 SkScalar t; | 2802 SkScalar t; |
| 2803 SkAssertResult(SkCubicClipper::ChopMonoAtY(pts, y, &t)); | 2803 if (!SkCubicClipper::ChopMonoAtY(pts, y, &t)) { |
| 2804 return 0; |
| 2805 } |
| 2804 SkScalar xt = eval_cubic_pts(pts[0].fX, pts[1].fX, pts[2].fX, pts[3].fX, t); | 2806 SkScalar xt = eval_cubic_pts(pts[0].fX, pts[1].fX, pts[2].fX, pts[3].fX, t); |
| 2805 if (SkScalarNearlyEqual(xt, x)) { | 2807 if (SkScalarNearlyEqual(xt, x)) { |
| 2806 if (x != pts[3].fX || y != pts[3].fY) { // don't test end points; they'
re start points | 2808 if (x != pts[3].fX || y != pts[3].fY) { // don't test end points; they'
re start points |
| 2807 *onCurveCount += 1; | 2809 *onCurveCount += 1; |
| 2808 return 0; | 2810 return 0; |
| 2809 } | 2811 } |
| 2810 } | 2812 } |
| 2811 return xt < x ? dir : 0; | 2813 return xt < x ? dir : 0; |
| 2812 } | 2814 } |
| 2813 | 2815 |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3030 } | 3032 } |
| 3031 if (!between(pts[0].fX, x, pts[1].fX) && !between(pts[1].fX, x, pts[2].fX) | 3033 if (!between(pts[0].fX, x, pts[1].fX) && !between(pts[1].fX, x, pts[2].fX) |
| 3032 && !between(pts[2].fX, x, pts[3].fX)) { | 3034 && !between(pts[2].fX, x, pts[3].fX)) { |
| 3033 return; | 3035 return; |
| 3034 } | 3036 } |
| 3035 SkPoint dst[10]; | 3037 SkPoint dst[10]; |
| 3036 int n = SkChopCubicAtYExtrema(pts, dst); | 3038 int n = SkChopCubicAtYExtrema(pts, dst); |
| 3037 for (int i = 0; i <= n; ++i) { | 3039 for (int i = 0; i <= n; ++i) { |
| 3038 SkPoint* c = &dst[i * 3]; | 3040 SkPoint* c = &dst[i * 3]; |
| 3039 SkScalar t; | 3041 SkScalar t; |
| 3040 SkAssertResult(SkCubicClipper::ChopMonoAtY(c, y, &t)); | 3042 if (!SkCubicClipper::ChopMonoAtY(c, y, &t)) { |
| 3043 continue; |
| 3044 } |
| 3041 SkScalar xt = eval_cubic_pts(c[0].fX, c[1].fX, c[2].fX, c[3].fX, t); | 3045 SkScalar xt = eval_cubic_pts(c[0].fX, c[1].fX, c[2].fX, c[3].fX, t); |
| 3042 if (!SkScalarNearlyEqual(x, xt)) { | 3046 if (!SkScalarNearlyEqual(x, xt)) { |
| 3043 continue; | 3047 continue; |
| 3044 } | 3048 } |
| 3045 SkVector tangent; | 3049 SkVector tangent; |
| 3046 SkEvalCubicAt(c, t, nullptr, &tangent, nullptr); | 3050 SkEvalCubicAt(c, t, nullptr, &tangent, nullptr); |
| 3047 tangents->push(tangent); | 3051 tangents->push(tangent); |
| 3048 } | 3052 } |
| 3049 } | 3053 } |
| 3050 | 3054 |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3226 } | 3230 } |
| 3227 } while (!done); | 3231 } while (!done); |
| 3228 return SkToBool(tangents.count()) ^ isInverse; | 3232 return SkToBool(tangents.count()) ^ isInverse; |
| 3229 } | 3233 } |
| 3230 | 3234 |
| 3231 int SkPath::ConvertConicToQuads(const SkPoint& p0, const SkPoint& p1, const SkPo
int& p2, | 3235 int SkPath::ConvertConicToQuads(const SkPoint& p0, const SkPoint& p1, const SkPo
int& p2, |
| 3232 SkScalar w, SkPoint pts[], int pow2) { | 3236 SkScalar w, SkPoint pts[], int pow2) { |
| 3233 const SkConic conic(p0, p1, p2, w); | 3237 const SkConic conic(p0, p1, p2, w); |
| 3234 return conic.chopIntoQuadsPOW2(pts, pow2); | 3238 return conic.chopIntoQuadsPOW2(pts, pow2); |
| 3235 } | 3239 } |
| OLD | NEW |