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 void debugInit(); |
| 28 |
27 bool intersects(const SkDRect& r) const { | 29 bool intersects(const SkDRect& r) const { |
28 SkASSERT(fLeft <= fRight); | 30 SkASSERT(fLeft <= fRight); |
29 SkASSERT(fTop <= fBottom); | 31 SkASSERT(fTop <= fBottom); |
30 SkASSERT(r.fLeft <= r.fRight); | 32 SkASSERT(r.fLeft <= r.fRight); |
31 SkASSERT(r.fTop <= r.fBottom); | 33 SkASSERT(r.fTop <= r.fBottom); |
32 return r.fLeft <= fRight && fLeft <= r.fRight && r.fTop <= fBottom && fT
op <= r.fBottom; | 34 return r.fLeft <= fRight && fLeft <= r.fRight && r.fTop <= fBottom && fT
op <= r.fBottom; |
33 } | 35 } |
34 | 36 |
35 void set(const SkDPoint& pt) { | 37 void set(const SkDPoint& pt) { |
36 fLeft = fRight = pt.fX; | 38 fLeft = fRight = pt.fX; |
(...skipping 21 matching lines...) Expand all Loading... |
58 void setBounds(const SkDCubic& curve, const SkDCubic& sub, double tStart, do
uble tEnd); | 60 void setBounds(const SkDCubic& curve, const SkDCubic& sub, double tStart, do
uble tEnd); |
59 | 61 |
60 void setBounds(const SkDQuad& curve) { | 62 void setBounds(const SkDQuad& curve) { |
61 setBounds(curve, curve, 0, 1); | 63 setBounds(curve, curve, 0, 1); |
62 } | 64 } |
63 | 65 |
64 void setBounds(const SkDQuad& curve, const SkDQuad& sub, double tStart, doub
le tEnd); | 66 void setBounds(const SkDQuad& curve, const SkDQuad& sub, double tStart, doub
le tEnd); |
65 }; | 67 }; |
66 | 68 |
67 #endif | 69 #endif |
OLD | NEW |