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 2746 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2757 if (y0 < y1) { | 2757 if (y0 < y1) { |
2758 return y1 <= y2; | 2758 return y1 <= y2; |
2759 } else { | 2759 } else { |
2760 return y1 >= y2; | 2760 return y1 >= y2; |
2761 } | 2761 } |
2762 } | 2762 } |
2763 | 2763 |
2764 static int winding_conic(const SkPoint pts[], SkScalar x, SkScalar y, SkScalar w
eight, | 2764 static int winding_conic(const SkPoint pts[], SkScalar x, SkScalar y, SkScalar w
eight, |
2765 int* onCurveCount) { | 2765 int* onCurveCount) { |
2766 SkConic conic(pts, weight); | 2766 SkConic conic(pts, weight); |
2767 SkConic *c = &conic; | |
2768 SkConic chopped[2]; | 2767 SkConic chopped[2]; |
2769 int n = 0; | 2768 // If the data points are very large, the conic may not be monotonic but may
also |
2770 | 2769 // fail to chop. Then, the chopper does not split the original conic in two. |
2771 if (!is_mono_quad(pts[0].fY, pts[1].fY, pts[2].fY)) { | 2770 bool isMono = is_mono_quad(pts[0].fY, pts[1].fY, pts[2].fY) || !conic.chopAt
YExtrema(chopped); |
2772 n = conic.chopAtYExtrema(chopped); | 2771 int w = winding_mono_conic(isMono ? conic : chopped[0], x, y, onCurveCount); |
2773 c = chopped; | 2772 if (!isMono) { |
2774 } | |
2775 int w = winding_mono_conic(*c, x, y, onCurveCount); | |
2776 if (n > 0) { | |
2777 w += winding_mono_conic(chopped[1], x, y, onCurveCount); | 2773 w += winding_mono_conic(chopped[1], x, y, onCurveCount); |
2778 } | 2774 } |
2779 return w; | 2775 return w; |
2780 } | 2776 } |
2781 | 2777 |
2782 static int winding_mono_quad(const SkPoint pts[], SkScalar x, SkScalar y, int* o
nCurveCount) { | 2778 static int winding_mono_quad(const SkPoint pts[], SkScalar x, SkScalar y, int* o
nCurveCount) { |
2783 SkScalar y0 = pts[0].fY; | 2779 SkScalar y0 = pts[0].fY; |
2784 SkScalar y2 = pts[2].fY; | 2780 SkScalar y2 = pts[2].fY; |
2785 | 2781 |
2786 int dir = 1; | 2782 int dir = 1; |
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3091 } | 3087 } |
3092 } while (!done); | 3088 } while (!done); |
3093 return SkToBool(tangents.count()) ^ isInverse; | 3089 return SkToBool(tangents.count()) ^ isInverse; |
3094 } | 3090 } |
3095 | 3091 |
3096 int SkPath::ConvertConicToQuads(const SkPoint& p0, const SkPoint& p1, const SkPo
int& p2, | 3092 int SkPath::ConvertConicToQuads(const SkPoint& p0, const SkPoint& p1, const SkPo
int& p2, |
3097 SkScalar w, SkPoint pts[], int pow2) { | 3093 SkScalar w, SkPoint pts[], int pow2) { |
3098 const SkConic conic(p0, p1, p2, w); | 3094 const SkConic conic(p0, p1, p2, w); |
3099 return conic.chopIntoQuadsPOW2(pts, pow2); | 3095 return conic.chopIntoQuadsPOW2(pts, pow2); |
3100 } | 3096 } |
OLD | NEW |