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 <iosfwd> | 10 #include <iosfwd> |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
60 // the quad may lie on the right/bottom edge of the resulting rectangle, | 60 // the quad may lie on the right/bottom edge of the resulting rectangle, |
61 // rather than being strictly inside it. | 61 // rather than being strictly inside it. |
62 RectF BoundingBox() const { | 62 RectF BoundingBox() const { |
63 float rl = std::min(std::min(p1_.x(), p2_.x()), std::min(p3_.x(), p4_.x())); | 63 float rl = std::min(std::min(p1_.x(), p2_.x()), std::min(p3_.x(), p4_.x())); |
64 float rr = std::max(std::max(p1_.x(), p2_.x()), std::max(p3_.x(), p4_.x())); | 64 float rr = std::max(std::max(p1_.x(), p2_.x()), std::max(p3_.x(), p4_.x())); |
65 float rt = std::min(std::min(p1_.y(), p2_.y()), std::min(p3_.y(), p4_.y())); | 65 float rt = std::min(std::min(p1_.y(), p2_.y()), std::min(p3_.y(), p4_.y())); |
66 float rb = std::max(std::max(p1_.y(), p2_.y()), std::max(p3_.y(), p4_.y())); | 66 float rb = std::max(std::max(p1_.y(), p2_.y()), std::max(p3_.y(), p4_.y())); |
67 return RectF(rl, rt, rr - rl, rb - rt); | 67 return RectF(rl, rt, rr - rl, rb - rt); |
68 } | 68 } |
69 | 69 |
70 void Rotate(size_t times) { | |
enne (OOO)
2015/02/04 21:24:00
Can you leave a comment about what this does? Rota
awoloszyn
2015/02/12 16:48:52
Renamed to Realign and added comment.
| |
71 for (size_t i = 0; i < times % 4; ++i) { | |
72 PointF temp = p1_; | |
73 p1_ = p2_; | |
74 p2_ = p3_; | |
75 p3_ = p4_; | |
76 p4_ = temp; | |
77 } | |
78 } | |
79 | |
70 // Add a vector to the quad, offseting each point in the quad by the vector. | 80 // Add a vector to the quad, offseting each point in the quad by the vector. |
71 void operator+=(const Vector2dF& rhs); | 81 void operator+=(const Vector2dF& rhs); |
72 // Subtract a vector from the quad, offseting each point in the quad by the | 82 // Subtract a vector from the quad, offseting each point in the quad by the |
73 // inverse of the vector. | 83 // inverse of the vector. |
74 void operator-=(const Vector2dF& rhs); | 84 void operator-=(const Vector2dF& rhs); |
75 | 85 |
76 // Scale each point in the quad by the |scale| factor. | 86 // Scale each point in the quad by the |scale| factor. |
77 void Scale(float scale) { Scale(scale, scale); } | 87 void Scale(float scale) { Scale(scale, scale); } |
78 | 88 |
79 // Scale each point in the quad by the scale factors along each axis. | 89 // Scale each point in the quad by the scale factors along each axis. |
(...skipping 26 matching lines...) Expand all Loading... | |
106 GFX_EXPORT QuadF operator-(const QuadF& lhs, const Vector2dF& rhs); | 116 GFX_EXPORT QuadF operator-(const QuadF& lhs, const Vector2dF& rhs); |
107 | 117 |
108 // This is declared here for use in gtest-based unit tests but is defined in | 118 // This is declared here for use in gtest-based unit tests but is defined in |
109 // the gfx_test_support target. Depend on that to use this in your unit test. | 119 // the gfx_test_support target. Depend on that to use this in your unit test. |
110 // This should not be used in production code - call ToString() instead. | 120 // This should not be used in production code - call ToString() instead. |
111 void PrintTo(const QuadF& quad, ::std::ostream* os); | 121 void PrintTo(const QuadF& quad, ::std::ostream* os); |
112 | 122 |
113 } // namespace gfx | 123 } // namespace gfx |
114 | 124 |
115 #endif // UI_GFX_GEOMETRY_QUAD_F_H_ | 125 #endif // UI_GFX_GEOMETRY_QUAD_F_H_ |
OLD | NEW |