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 SkPathOpBounds_DEFINED | 7 #ifndef SkPathOpBounds_DEFINED |
8 #define SkPathOpBounds_DEFINED | 8 #define SkPathOpBounds_DEFINED |
9 | 9 |
10 #include "SkPathOpsRect.h" | 10 #include "SkPathOpsRect.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 if (left < fLeft) fLeft = left; | 26 if (left < fLeft) fLeft = left; |
27 if (top < fTop) fTop = top; | 27 if (top < fTop) fTop = top; |
28 if (right > fRight) fRight = right; | 28 if (right > fRight) fRight = right; |
29 if (bottom > fBottom) fBottom = bottom; | 29 if (bottom > fBottom) fBottom = bottom; |
30 } | 30 } |
31 | 31 |
32 void add(const SkPathOpsBounds& toAdd) { | 32 void add(const SkPathOpsBounds& toAdd) { |
33 add(toAdd.fLeft, toAdd.fTop, toAdd.fRight, toAdd.fBottom); | 33 add(toAdd.fLeft, toAdd.fTop, toAdd.fRight, toAdd.fBottom); |
34 } | 34 } |
35 | 35 |
| 36 void add(const SkPoint& pt) { |
| 37 if (pt.fX < fLeft) fLeft = pt.fX; |
| 38 if (pt.fY < fTop) fTop = pt.fY; |
| 39 if (pt.fX > fRight) fRight = pt.fX; |
| 40 if (pt.fY > fBottom) fBottom = pt.fY; |
| 41 } |
| 42 |
36 void add(const SkDPoint& pt) { | 43 void add(const SkDPoint& pt) { |
37 if (pt.fX < fLeft) fLeft = SkDoubleToScalar(pt.fX); | 44 if (pt.fX < fLeft) fLeft = SkDoubleToScalar(pt.fX); |
38 if (pt.fY < fTop) fTop = SkDoubleToScalar(pt.fY); | 45 if (pt.fY < fTop) fTop = SkDoubleToScalar(pt.fY); |
39 if (pt.fX > fRight) fRight = SkDoubleToScalar(pt.fX); | 46 if (pt.fX > fRight) fRight = SkDoubleToScalar(pt.fX); |
40 if (pt.fY > fBottom) fBottom = SkDoubleToScalar(pt.fY); | 47 if (pt.fY > fBottom) fBottom = SkDoubleToScalar(pt.fY); |
41 } | 48 } |
42 | 49 |
43 bool almostContains(const SkPoint& pt) { | 50 bool almostContains(const SkPoint& pt) const { |
44 return AlmostLessOrEqualUlps(fLeft, pt.fX) | 51 return AlmostLessOrEqualUlps(fLeft, pt.fX) |
45 && AlmostLessOrEqualUlps(pt.fX, fRight) | 52 && AlmostLessOrEqualUlps(pt.fX, fRight) |
46 && AlmostLessOrEqualUlps(fTop, pt.fY) | 53 && AlmostLessOrEqualUlps(fTop, pt.fY) |
47 && AlmostLessOrEqualUlps(pt.fY, fBottom); | 54 && AlmostLessOrEqualUlps(pt.fY, fBottom); |
48 } | 55 } |
49 | 56 |
| 57 bool contains(const SkPoint& pt) const { |
| 58 return fLeft <= pt.fX && fTop <= pt.fY && |
| 59 fRight >= pt.fX && fBottom >= pt.fY; |
| 60 } |
| 61 |
50 typedef SkRect INHERITED; | 62 typedef SkRect INHERITED; |
51 }; | 63 }; |
52 | 64 |
53 #endif | 65 #endif |
OLD | NEW |