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 bool isMono = is_mono_quad(pts[0].fY, pts[1].fY, pts[2].fY) || !conic.chopAt YExtrema(chopped); |
reed1
2016/01/06 16:12:06
maybe a comment describing why we check for the ch
| |
2770 | 2769 int w = winding_mono_conic(isMono ? conic : chopped[0], x, y, onCurveCount); |
2771 if (!is_mono_quad(pts[0].fY, pts[1].fY, pts[2].fY)) { | 2770 if (!isMono) { |
2772 n = conic.chopAtYExtrema(chopped); | |
2773 c = chopped; | |
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); | 2771 w += winding_mono_conic(chopped[1], x, y, onCurveCount); |
2778 } | 2772 } |
2779 return w; | 2773 return w; |
2780 } | 2774 } |
2781 | 2775 |
2782 static int winding_mono_quad(const SkPoint pts[], SkScalar x, SkScalar y, int* o nCurveCount) { | 2776 static int winding_mono_quad(const SkPoint pts[], SkScalar x, SkScalar y, int* o nCurveCount) { |
2783 SkScalar y0 = pts[0].fY; | 2777 SkScalar y0 = pts[0].fY; |
2784 SkScalar y2 = pts[2].fY; | 2778 SkScalar y2 = pts[2].fY; |
2785 | 2779 |
2786 int dir = 1; | 2780 int dir = 1; |
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3091 } | 3085 } |
3092 } while (!done); | 3086 } while (!done); |
3093 return SkToBool(tangents.count()) ^ isInverse; | 3087 return SkToBool(tangents.count()) ^ isInverse; |
3094 } | 3088 } |
3095 | 3089 |
3096 int SkPath::ConvertConicToQuads(const SkPoint& p0, const SkPoint& p1, const SkPo int& p2, | 3090 int SkPath::ConvertConicToQuads(const SkPoint& p0, const SkPoint& p1, const SkPo int& p2, |
3097 SkScalar w, SkPoint pts[], int pow2) { | 3091 SkScalar w, SkPoint pts[], int pow2) { |
3098 const SkConic conic(p0, p1, p2, w); | 3092 const SkConic conic(p0, p1, p2, w); |
3099 return conic.chopIntoQuadsPOW2(pts, pow2); | 3093 return conic.chopIntoQuadsPOW2(pts, pow2); |
3100 } | 3094 } |
OLD | NEW |