OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 Google Inc. |
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 #include "SkPathOpsConic.h" | 7 #include "SkPathOpsConic.h" |
8 #include "SkPathOpsCubic.h" | 8 #include "SkPathOpsCubic.h" |
9 #include "SkPathOpsLine.h" | 9 #include "SkPathOpsLine.h" |
10 #include "SkPathOpsQuad.h" | 10 #include "SkPathOpsQuad.h" |
11 #include "SkPathOpsRect.h" | 11 #include "SkPathOpsRect.h" |
12 | 12 |
13 void SkDRect::setBounds(const SkDQuad& quad) { | 13 void SkDRect::setBounds(const SkDQuad& curve, const SkDQuad& sub, double startT,
double endT) { |
14 set(quad[0]); | 14 set(sub[0]); |
15 add(quad[2]); | 15 add(sub[2]); |
16 double tValues[2]; | 16 double tValues[2]; |
17 int roots = 0; | 17 int roots = 0; |
18 if (!between(quad[0].fX, quad[1].fX, quad[2].fX)) { | 18 if (!sub.monotonicInX()) { |
19 roots = SkDQuad::FindExtrema(quad[0].fX, quad[1].fX, quad[2].fX, tValues
); | 19 roots = SkDQuad::FindExtrema(&sub[0].fX, tValues); |
20 } | 20 } |
21 if (!between(quad[0].fY, quad[1].fY, quad[2].fY)) { | 21 if (!sub.monotonicInY()) { |
22 roots += SkDQuad::FindExtrema(quad[0].fY, quad[1].fY, quad[2].fY, &tValu
es[roots]); | 22 roots += SkDQuad::FindExtrema(&sub[0].fY, &tValues[roots]); |
23 } | 23 } |
24 for (int x = 0; x < roots; ++x) { | 24 for (int index = 0; index < roots; ++index) { |
25 add(quad.ptAtT(tValues[x])); | 25 double t = startT + (endT - startT) * tValues[index]; |
| 26 add(curve.ptAtT(t)); |
26 } | 27 } |
27 } | 28 } |
28 | 29 |
29 void SkDRect::setBounds(const SkDConic& conic) { | 30 void SkDRect::setBounds(const SkDConic& curve, const SkDConic& sub, double start
T, double endT) { |
30 set(conic[0]); | 31 set(sub[0]); |
31 add(conic[2]); | 32 add(sub[2]); |
32 double tValues[2]; | 33 double tValues[2]; |
33 int roots = 0; | 34 int roots = 0; |
34 if (!between(conic[0].fX, conic[1].fX, conic[2].fX)) { | 35 if (!sub.monotonicInX()) { |
35 roots = SkDConic::FindExtrema(&conic[0].fX, conic.fWeight, tValues); | 36 roots = SkDConic::FindExtrema(&sub[0].fX, sub.fWeight, tValues); |
36 } | 37 } |
37 if (!between(conic[0].fY, conic[1].fY, conic[2].fY)) { | 38 if (!sub.monotonicInY()) { |
38 roots += SkDConic::FindExtrema(&conic[0].fY, conic.fWeight, &tValues[roo
ts]); | 39 roots += SkDConic::FindExtrema(&sub[0].fY, sub.fWeight, &tValues[roots])
; |
39 } | 40 } |
40 for (int x = 0; x < roots; ++x) { | 41 for (int index = 0; index < roots; ++index) { |
41 add(conic.ptAtT(tValues[x])); | 42 double t = startT + (endT - startT) * tValues[index]; |
| 43 add(curve.ptAtT(t)); |
42 } | 44 } |
43 } | 45 } |
44 | 46 |
45 static bool is_bounded_by_end_points(double a, double b, double c, double d) { | 47 void SkDRect::setBounds(const SkDCubic& curve, const SkDCubic& sub, double start
T, double endT) { |
46 return between(a, b, d) && between(a, c, d); | 48 set(sub[0]); |
47 } | 49 add(sub[3]); |
48 | |
49 void SkDRect::setBounds(const SkDCubic& c) { | |
50 set(c[0]); | |
51 add(c[3]); | |
52 double tValues[4]; | 50 double tValues[4]; |
53 int roots = 0; | 51 int roots = 0; |
54 if (!is_bounded_by_end_points(c[0].fX, c[1].fX, c[2].fX, c[3].fX)) { | 52 if (!sub.monotonicInX()) { |
55 roots = SkDCubic::FindExtrema(c[0].fX, c[1].fX, c[2].fX, c[3].fX, tValue
s); | 53 roots = SkDCubic::FindExtrema(&sub[0].fX, tValues); |
56 } | 54 } |
57 if (!is_bounded_by_end_points(c[0].fY, c[1].fY, c[2].fY, c[3].fY)) { | 55 if (!sub.monotonicInY()) { |
58 roots += SkDCubic::FindExtrema(c[0].fY, c[1].fY, c[2].fY, c[3].fY, &tVal
ues[roots]); | 56 roots += SkDCubic::FindExtrema(&sub[0].fY, &tValues[roots]); |
59 } | 57 } |
60 for (int x = 0; x < roots; ++x) { | 58 for (int index = 0; index < roots; ++index) { |
61 add(c.ptAtT(tValues[x])); | 59 double t = startT + (endT - startT) * tValues[index]; |
| 60 add(curve.ptAtT(t)); |
62 } | 61 } |
63 } | 62 } |
OLD | NEW |