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) { | 36 void add(const SkDPoint& pt) { |
37 if (pt.fX < fLeft) fLeft = pt.fX; | 37 if (pt.fX < fLeft) fLeft = SkDoubleToScalar(pt.fX); |
38 if (pt.fY < fTop) fTop = pt.fY; | 38 if (pt.fY < fTop) fTop = SkDoubleToScalar(pt.fY); |
39 if (pt.fX > fRight) fRight = pt.fX; | 39 if (pt.fX > fRight) fRight = SkDoubleToScalar(pt.fX); |
40 if (pt.fY > fBottom) fBottom = pt.fY; | 40 if (pt.fY > fBottom) fBottom = SkDoubleToScalar(pt.fY); |
41 } | 41 } |
42 | 42 |
43 bool almostContains(const SkPoint& pt) { | 43 bool almostContains(const SkPoint& pt) { |
44 return AlmostLessOrEqualUlps(fLeft, pt.fX) | 44 return AlmostLessOrEqualUlps(fLeft, pt.fX) |
45 && AlmostLessOrEqualUlps(pt.fX, fRight) | 45 && AlmostLessOrEqualUlps(pt.fX, fRight) |
46 && AlmostLessOrEqualUlps(fTop, pt.fY) | 46 && AlmostLessOrEqualUlps(fTop, pt.fY) |
47 && AlmostLessOrEqualUlps(pt.fY, fBottom); | 47 && AlmostLessOrEqualUlps(pt.fY, fBottom); |
48 } | 48 } |
49 | 49 |
50 // unlike isEmpty(), this permits lines, but not points | 50 // unlike isEmpty(), this permits lines, but not points |
51 // FIXME: unused for now | 51 // FIXME: unused for now |
52 bool isReallyEmpty() const { | 52 bool isReallyEmpty() const { |
53 // use !<= instead of > to detect NaN values | 53 // use !<= instead of > to detect NaN values |
54 return !(fLeft <= fRight) || !(fTop <= fBottom) | 54 return !(fLeft <= fRight) || !(fTop <= fBottom) |
55 || (fLeft == fRight && fTop == fBottom); | 55 || (fLeft == fRight && fTop == fBottom); |
56 } | 56 } |
57 | 57 |
58 void setConicBounds(const SkPoint a[3], SkScalar weight); | 58 void setPointBounds(const SkDPoint& pt) { |
59 void setCubicBounds(const SkPoint a[4], SkScalar ); | 59 fLeft = fRight = SkDoubleToScalar(pt.fX); |
60 void setLineBounds(const SkPoint a[2], SkScalar ); | 60 fTop = fBottom = SkDoubleToScalar(pt.fY); |
61 void setQuadBounds(const SkPoint a[3], SkScalar ); | |
62 | |
63 void setPointBounds(const SkPoint& pt) { | |
64 fLeft = fRight = pt.fX; | |
65 fTop = fBottom = pt.fY; | |
66 } | 61 } |
67 | 62 |
68 typedef SkRect INHERITED; | 63 typedef SkRect INHERITED; |
69 }; | 64 }; |
70 | 65 |
71 extern void (SkPathOpsBounds::* const SetCurveBounds[])(const SkPoint[], SkScala
r weight); | |
72 | |
73 #endif | 66 #endif |
OLD | NEW |