OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2008 Apple Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 // isEmpty tests that the bounding box is empty. This will not identify | 77 // isEmpty tests that the bounding box is empty. This will not identify |
78 // "slanted" empty quads. | 78 // "slanted" empty quads. |
79 bool isEmpty() const { return boundingBox().isEmpty(); } | 79 bool isEmpty() const { return boundingBox().isEmpty(); } |
80 | 80 |
81 // Tests whether this quad can be losslessly represented by a FloatRect, | 81 // Tests whether this quad can be losslessly represented by a FloatRect, |
82 // that is, if two edges are parallel to the x-axis and the other two | 82 // that is, if two edges are parallel to the x-axis and the other two |
83 // are parallel to the y-axis. If this method returns true, the | 83 // are parallel to the y-axis. If this method returns true, the |
84 // corresponding FloatRect can be retrieved with boundingBox(). | 84 // corresponding FloatRect can be retrieved with boundingBox(). |
85 bool isRectilinear() const; | 85 bool isRectilinear() const; |
86 | 86 |
87 // Tests whether the given point is inside, or on an edge or corner of this qu
ad. | 87 // Tests whether the given point is inside, or on an edge or corner of this |
| 88 // quad. |
88 bool containsPoint(const FloatPoint&) const; | 89 bool containsPoint(const FloatPoint&) const; |
89 | 90 |
90 // Tests whether the four corners of other are inside, or coincident with the
sides of this quad. | 91 // Tests whether the four corners of other are inside, or coincident with the |
91 // Note that this only works for convex quads, but that includes all quads tha
t originate | 92 // sides of this quad. Note that this only works for convex quads, but that |
| 93 // includes all quads that originate |
92 // from transformed rects. | 94 // from transformed rects. |
93 bool containsQuad(const FloatQuad&) const; | 95 bool containsQuad(const FloatQuad&) const; |
94 | 96 |
95 // Tests whether any part of the rectangle intersects with this quad. | 97 // Tests whether any part of the rectangle intersects with this quad. |
96 // This only works for convex quads. | 98 // This only works for convex quads. |
97 bool intersectsRect(const FloatRect&) const; | 99 bool intersectsRect(const FloatRect&) const; |
98 | 100 |
99 // Test whether any part of the circle/ellipse intersects with this quad. | 101 // Test whether any part of the circle/ellipse intersects with this quad. |
100 // Note that these two functions only work for convex quads. | 102 // Note that these two functions only work for convex quads. |
101 bool intersectsCircle(const FloatPoint& center, float radius) const; | 103 bool intersectsCircle(const FloatPoint& center, float radius) const; |
102 bool intersectsEllipse(const FloatPoint& center, | 104 bool intersectsEllipse(const FloatPoint& center, |
103 const FloatSize& radii) const; | 105 const FloatSize& radii) const; |
104 | 106 |
105 // The center of the quad. If the quad is the result of a affine-transformed r
ectangle this is the same as the original center transformed. | 107 // The center of the quad. If the quad is the result of a affine-transformed |
| 108 // rectangle this is the same as the original center transformed. |
106 FloatPoint center() const { | 109 FloatPoint center() const { |
107 return FloatPoint((m_p1.x() + m_p2.x() + m_p3.x() + m_p4.x()) / 4.0, | 110 return FloatPoint((m_p1.x() + m_p2.x() + m_p3.x() + m_p4.x()) / 4.0, |
108 (m_p1.y() + m_p2.y() + m_p3.y() + m_p4.y()) / 4.0); | 111 (m_p1.y() + m_p2.y() + m_p3.y() + m_p4.y()) / 4.0); |
109 } | 112 } |
110 | 113 |
111 FloatRect boundingBox() const; | 114 FloatRect boundingBox() const; |
112 IntRect enclosingBoundingBox() const { | 115 IntRect enclosingBoundingBox() const { |
113 return enclosingIntRect(boundingBox()); | 116 return enclosingIntRect(boundingBox()); |
114 } | 117 } |
115 | 118 |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 a.p4() != b.p4(); | 174 a.p4() != b.p4(); |
172 } | 175 } |
173 | 176 |
174 // Redeclared here to avoid ODR issues. | 177 // Redeclared here to avoid ODR issues. |
175 // See platform/testing/GeometryPrinters.h. | 178 // See platform/testing/GeometryPrinters.h. |
176 void PrintTo(const FloatQuad&, std::ostream*); | 179 void PrintTo(const FloatQuad&, std::ostream*); |
177 | 180 |
178 } // namespace blink | 181 } // namespace blink |
179 | 182 |
180 #endif // FloatQuad_h | 183 #endif // FloatQuad_h |
OLD | NEW |