| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef UI_GFX_GEOMETRY_QUAD_F_H_ | 5 #ifndef UI_GFX_GEOMETRY_QUAD_F_H_ |
| 6 #define UI_GFX_GEOMETRY_QUAD_F_H_ | 6 #define UI_GFX_GEOMETRY_QUAD_F_H_ |
| 7 | 7 |
| 8 #include <algorithm> | 8 #include <algorithm> |
| 9 #include <cmath> | 9 #include <cmath> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 const PointF& p4() const { return p4_; } | 45 const PointF& p4() const { return p4_; } |
| 46 | 46 |
| 47 // Returns true if the quad is an axis-aligned rectangle. | 47 // Returns true if the quad is an axis-aligned rectangle. |
| 48 bool IsRectilinear() const; | 48 bool IsRectilinear() const; |
| 49 | 49 |
| 50 // Returns true if the points of the quad are in counter-clockwise order. This | 50 // Returns true if the points of the quad are in counter-clockwise order. This |
| 51 // assumes that the quad is convex, and that no three points are collinear. | 51 // assumes that the quad is convex, and that no three points are collinear. |
| 52 bool IsCounterClockwise() const; | 52 bool IsCounterClockwise() const; |
| 53 | 53 |
| 54 // Returns true if the |point| is contained within the quad, or lies on on | 54 // Returns true if the |point| is contained within the quad, or lies on on |
| 55 // edge of the quad. | 55 // edge of the quad. This assumes that the quad is convex. |
| 56 bool Contains(const gfx::PointF& point) const; | 56 bool Contains(const gfx::PointF& point) const; |
| 57 | 57 |
| 58 // Returns a rectangle that bounds the four points of the quad. The points of | 58 // Returns a rectangle that bounds the four points of the quad. The points of |
| 59 // the quad may lie on the right/bottom edge of the resulting rectangle, | 59 // the quad may lie on the right/bottom edge of the resulting rectangle, |
| 60 // rather than being strictly inside it. | 60 // rather than being strictly inside it. |
| 61 RectF BoundingBox() const { | 61 RectF BoundingBox() const { |
| 62 float rl = std::min(std::min(p1_.x(), p2_.x()), std::min(p3_.x(), p4_.x())); | 62 float rl = std::min(std::min(p1_.x(), p2_.x()), std::min(p3_.x(), p4_.x())); |
| 63 float rr = std::max(std::max(p1_.x(), p2_.x()), std::max(p3_.x(), p4_.x())); | 63 float rr = std::max(std::max(p1_.x(), p2_.x()), std::max(p3_.x(), p4_.x())); |
| 64 float rt = std::min(std::min(p1_.y(), p2_.y()), std::min(p3_.y(), p4_.y())); | 64 float rt = std::min(std::min(p1_.y(), p2_.y()), std::min(p3_.y(), p4_.y())); |
| 65 float rb = std::max(std::max(p1_.y(), p2_.y()), std::max(p3_.y(), p4_.y())); | 65 float rb = std::max(std::max(p1_.y(), p2_.y()), std::max(p3_.y(), p4_.y())); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 | 100 |
| 101 // Add a vector to a quad, offseting each point in the quad by the vector. | 101 // Add a vector to a quad, offseting each point in the quad by the vector. |
| 102 GFX_EXPORT QuadF operator+(const QuadF& lhs, const Vector2dF& rhs); | 102 GFX_EXPORT QuadF operator+(const QuadF& lhs, const Vector2dF& rhs); |
| 103 // Subtract a vector from a quad, offseting each point in the quad by the | 103 // Subtract a vector from a quad, offseting each point in the quad by the |
| 104 // inverse of the vector. | 104 // inverse of the vector. |
| 105 GFX_EXPORT QuadF operator-(const QuadF& lhs, const Vector2dF& rhs); | 105 GFX_EXPORT QuadF operator-(const QuadF& lhs, const Vector2dF& rhs); |
| 106 | 106 |
| 107 } // namespace gfx | 107 } // namespace gfx |
| 108 | 108 |
| 109 #endif // UI_GFX_GEOMETRY_QUAD_F_H_ | 109 #endif // UI_GFX_GEOMETRY_QUAD_F_H_ |
| OLD | NEW |