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 2826 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2837 SkScalar dy = y1 - y0; | 2837 SkScalar dy = y1 - y0; |
2838 | 2838 |
2839 int dir = 1; | 2839 int dir = 1; |
2840 if (y0 > y1) { | 2840 if (y0 > y1) { |
2841 SkTSwap(y0, y1); | 2841 SkTSwap(y0, y1); |
2842 dir = -1; | 2842 dir = -1; |
2843 } | 2843 } |
2844 if (y < y0 || y > y1) { | 2844 if (y < y0 || y > y1) { |
2845 return 0; | 2845 return 0; |
2846 } | 2846 } |
2847 if (y == y1) { | 2847 if (y == pts[1].fY) { |
2848 if (y0 == y1 && between(x0, x, x1) && x != x1) { // check if on horizon
tal line | 2848 if (y0 == y1 && between(x0, x, x1) && x != x1) { // check if on horizon
tal line |
2849 *onCurveCount += 1; | 2849 *onCurveCount += 1; |
2850 } | 2850 } |
2851 return 0; | 2851 return 0; |
2852 } | 2852 } |
2853 SkScalar cross = SkScalarMul(x1 - x0, y - pts[0].fY) - SkScalarMul(dy, x - x
0); | 2853 SkScalar cross = SkScalarMul(x1 - x0, y - pts[0].fY) - SkScalarMul(dy, x - x
0); |
2854 | 2854 |
2855 if (!cross) { | 2855 if (!cross) { |
2856 if (x != x1 || y != pts[1].fY) { // don't test end points since they're
also start points | 2856 // zero cross means the point is on the line, and since the case where |
2857 *onCurveCount += 1; // zero cross means the point is on the line | 2857 // y of the query point is at the end point is handled above, we can be |
2858 } | 2858 // sure that we're on the line (excluding the end point) here |
| 2859 *onCurveCount += 1; |
2859 dir = 0; | 2860 dir = 0; |
2860 } else if (SkScalarSignAsInt(cross) == dir) { | 2861 } else if (SkScalarSignAsInt(cross) == dir) { |
2861 dir = 0; | 2862 dir = 0; |
2862 } | 2863 } |
2863 return dir; | 2864 return dir; |
2864 } | 2865 } |
2865 | 2866 |
2866 static void tangent_cubic(const SkPoint pts[], SkScalar x, SkScalar y, | 2867 static void tangent_cubic(const SkPoint pts[], SkScalar x, SkScalar y, |
2867 SkTDArray<SkVector>* tangents) { | 2868 SkTDArray<SkVector>* tangents) { |
2868 if (!between(pts[0].fY, y, pts[1].fY) && !between(pts[1].fY, y, pts[2].fY) | 2869 if (!between(pts[0].fY, y, pts[1].fY) && !between(pts[1].fY, y, pts[2].fY) |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3066 } | 3067 } |
3067 } while (!done); | 3068 } while (!done); |
3068 return SkToBool(tangents.count()) ^ isInverse; | 3069 return SkToBool(tangents.count()) ^ isInverse; |
3069 } | 3070 } |
3070 | 3071 |
3071 int SkPath::ConvertConicToQuads(const SkPoint& p0, const SkPoint& p1, const SkPo
int& p2, | 3072 int SkPath::ConvertConicToQuads(const SkPoint& p0, const SkPoint& p1, const SkPo
int& p2, |
3072 SkScalar w, SkPoint pts[], int pow2) { | 3073 SkScalar w, SkPoint pts[], int pow2) { |
3073 const SkConic conic(p0, p1, p2, w); | 3074 const SkConic conic(p0, p1, p2, w); |
3074 return conic.chopIntoQuadsPOW2(pts, pow2); | 3075 return conic.chopIntoQuadsPOW2(pts, pow2); |
3075 } | 3076 } |
OLD | NEW |