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 #ifndef SkPathOpsRect_DEFINED | 7 #ifndef SkPathOpsRect_DEFINED |
8 #define SkPathOpsRect_DEFINED | 8 #define SkPathOpsRect_DEFINED |
9 | 9 |
10 #include "SkPathOpsPoint.h" | 10 #include "SkPathOpsPoint.h" |
11 | 11 |
12 struct SkDRect { | 12 struct SkDRect { |
13 double fLeft, fTop, fRight, fBottom; | 13 double fLeft, fTop, fRight, fBottom; |
14 | 14 |
15 void add(const SkDPoint& pt) { | 15 void add(const SkDPoint& pt) { |
16 fLeft = SkTMin(fLeft, pt.fX); | 16 fLeft = SkTMin(fLeft, pt.fX); |
17 fTop = SkTMin(fTop, pt.fY); | 17 fTop = SkTMin(fTop, pt.fY); |
18 fRight = SkTMax(fRight, pt.fX); | 18 fRight = SkTMax(fRight, pt.fX); |
19 fBottom = SkTMax(fBottom, pt.fY); | 19 fBottom = SkTMax(fBottom, pt.fY); |
20 } | 20 } |
21 | 21 |
22 bool contains(const SkDPoint& pt) const { | 22 bool contains(const SkDPoint& pt) const { |
23 return approximately_between(fLeft, pt.fX, fRight) | 23 return approximately_between(fLeft, pt.fX, fRight) |
24 && approximately_between(fTop, pt.fY, fBottom); | 24 && approximately_between(fTop, pt.fY, fBottom); |
25 } | 25 } |
26 | 26 |
27 bool intersects(const SkDRect& r) const { | 27 bool intersects(const SkDRect& r) const { |
28 if (fLeft > fRight) { | |
29 SkDebugf("!"); | |
30 } | |
31 SkASSERT(fLeft <= fRight); | 28 SkASSERT(fLeft <= fRight); |
32 SkASSERT(fTop <= fBottom); | 29 SkASSERT(fTop <= fBottom); |
33 SkASSERT(r.fLeft <= r.fRight); | 30 SkASSERT(r.fLeft <= r.fRight); |
34 SkASSERT(r.fTop <= r.fBottom); | 31 SkASSERT(r.fTop <= r.fBottom); |
35 return r.fLeft <= fRight && fLeft <= r.fRight && r.fTop <= fBottom && fT
op <= r.fBottom; | 32 return r.fLeft <= fRight && fLeft <= r.fRight && r.fTop <= fBottom && fT
op <= r.fBottom; |
36 } | 33 } |
37 | 34 |
38 void set(const SkDPoint& pt) { | 35 void set(const SkDPoint& pt) { |
39 fLeft = fRight = pt.fX; | 36 fLeft = fRight = pt.fX; |
40 fTop = fBottom = pt.fY; | 37 fTop = fBottom = pt.fY; |
(...skipping 20 matching lines...) Expand all Loading... |
61 void setBounds(const SkDCubic& curve, const SkDCubic& sub, double tStart, do
uble tEnd); | 58 void setBounds(const SkDCubic& curve, const SkDCubic& sub, double tStart, do
uble tEnd); |
62 | 59 |
63 void setBounds(const SkDQuad& curve) { | 60 void setBounds(const SkDQuad& curve) { |
64 setBounds(curve, curve, 0, 1); | 61 setBounds(curve, curve, 0, 1); |
65 } | 62 } |
66 | 63 |
67 void setBounds(const SkDQuad& curve, const SkDQuad& sub, double tStart, doub
le tEnd); | 64 void setBounds(const SkDQuad& curve, const SkDQuad& sub, double tStart, doub
le tEnd); |
68 }; | 65 }; |
69 | 66 |
70 #endif | 67 #endif |
OLD | NEW |