Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(87)

Side by Side Diff: ui/gfx/geometry/quad_f.h

Issue 1001833005: Update from https://crrev.com/320343 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Supress Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/gfx/BUILD.gn ('k') | ui/gfx/hud_font.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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>
11 #include <string> 11 #include <string>
12 12
13 #include "base/logging.h"
13 #include "ui/gfx/geometry/point_f.h" 14 #include "ui/gfx/geometry/point_f.h"
14 #include "ui/gfx/geometry/rect_f.h" 15 #include "ui/gfx/geometry/rect_f.h"
15 #include "ui/gfx/gfx_export.h" 16 #include "ui/gfx/gfx_export.h"
16 17
17 namespace gfx { 18 namespace gfx {
18 19
19 // A Quad is defined by four corners, allowing it to have edges that are not 20 // A Quad is defined by four corners, allowing it to have edges that are not
20 // axis-aligned, unlike a Rect. 21 // axis-aligned, unlike a Rect.
21 class GFX_EXPORT QuadF { 22 class GFX_EXPORT QuadF {
22 public: 23 public:
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 // the quad may lie on the right/bottom edge of the resulting rectangle, 61 // the quad may lie on the right/bottom edge of the resulting rectangle,
61 // rather than being strictly inside it. 62 // rather than being strictly inside it.
62 RectF BoundingBox() const { 63 RectF BoundingBox() const {
63 float rl = std::min(std::min(p1_.x(), p2_.x()), std::min(p3_.x(), p4_.x())); 64 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())); 65 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())); 66 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())); 67 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); 68 return RectF(rl, rt, rr - rl, rb - rt);
68 } 69 }
69 70
71 // Realigns the corners in the quad by rotating them n corners to the right.
72 void Realign(size_t times) {
73 DCHECK_LE(times, 4u);
74 for (size_t i = 0; i < times; ++i) {
75 PointF temp = p1_;
76 p1_ = p2_;
77 p2_ = p3_;
78 p3_ = p4_;
79 p4_ = temp;
80 }
81 }
82
70 // Add a vector to the quad, offseting each point in the quad by the vector. 83 // Add a vector to the quad, offseting each point in the quad by the vector.
71 void operator+=(const Vector2dF& rhs); 84 void operator+=(const Vector2dF& rhs);
72 // Subtract a vector from the quad, offseting each point in the quad by the 85 // Subtract a vector from the quad, offseting each point in the quad by the
73 // inverse of the vector. 86 // inverse of the vector.
74 void operator-=(const Vector2dF& rhs); 87 void operator-=(const Vector2dF& rhs);
75 88
76 // Scale each point in the quad by the |scale| factor. 89 // Scale each point in the quad by the |scale| factor.
77 void Scale(float scale) { Scale(scale, scale); } 90 void Scale(float scale) { Scale(scale, scale); }
78 91
79 // Scale each point in the quad by the scale factors along each axis. 92 // Scale each point in the quad by the scale factors along each axis.
(...skipping 26 matching lines...) Expand all
106 GFX_EXPORT QuadF operator-(const QuadF& lhs, const Vector2dF& rhs); 119 GFX_EXPORT QuadF operator-(const QuadF& lhs, const Vector2dF& rhs);
107 120
108 // This is declared here for use in gtest-based unit tests but is defined in 121 // 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. 122 // 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. 123 // This should not be used in production code - call ToString() instead.
111 void PrintTo(const QuadF& quad, ::std::ostream* os); 124 void PrintTo(const QuadF& quad, ::std::ostream* os);
112 125
113 } // namespace gfx 126 } // namespace gfx
114 127
115 #endif // UI_GFX_GEOMETRY_QUAD_F_H_ 128 #endif // UI_GFX_GEOMETRY_QUAD_F_H_
OLDNEW
« no previous file with comments | « ui/gfx/BUILD.gn ('k') | ui/gfx/hud_font.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698