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

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

Issue 15298013: ui: Inline QuadF::BoundingBox() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | ui/gfx/quad_f.cc » ('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_QUAD_F_H_ 5 #ifndef UI_GFX_QUAD_F_H_
6 #define UI_GFX_QUAD_F_H_ 6 #define UI_GFX_QUAD_F_H_
7 7
8 #include <cmath>
8 #include <string> 9 #include <string>
9 10
10 #include "ui/base/ui_export.h" 11 #include "ui/base/ui_export.h"
11 #include "ui/gfx/point_f.h" 12 #include "ui/gfx/point_f.h"
12 #include "ui/gfx/rect_f.h" 13 #include "ui/gfx/rect_f.h"
13 14
14 namespace gfx { 15 namespace gfx {
15 16
16 // A Quad is defined by four corners, allowing it to have edges that are not 17 // A Quad is defined by four corners, allowing it to have edges that are not
17 // axis-aligned, unlike a Rect. 18 // axis-aligned, unlike a Rect.
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 // assumes that the quad is convex, and that no three points are collinear. 50 // assumes that the quad is convex, and that no three points are collinear.
50 bool IsCounterClockwise() const; 51 bool IsCounterClockwise() const;
51 52
52 // Returns true if the |point| is contained within the quad, or lies on on 53 // Returns true if the |point| is contained within the quad, or lies on on
53 // edge of the quad. 54 // edge of the quad.
54 bool Contains(const gfx::PointF& point) const; 55 bool Contains(const gfx::PointF& point) const;
55 56
56 // Returns a rectangle that bounds the four points of the quad. The points of 57 // Returns a rectangle that bounds the four points of the quad. The points of
57 // the quad may lie on the right/bottom edge of the resulting rectangle, 58 // the quad may lie on the right/bottom edge of the resulting rectangle,
58 // rather than being strictly inside it. 59 // rather than being strictly inside it.
59 RectF BoundingBox() const; 60 RectF BoundingBox() const {
61 float rl = std::min(std::min(p1_.x(), p2_.x()), std::min(p3_.x(), p4_.x()));
62 float rr = std::max(std::max(p1_.x(), p2_.x()), std::max(p3_.x(), p4_.x()));
63 float rt = std::min(std::min(p1_.y(), p2_.y()), std::min(p3_.y(), p4_.y()));
64 float rb = std::max(std::max(p1_.y(), p2_.y()), std::max(p3_.y(), p4_.y()));
65 return RectF(rl, rt, rr - rl, rb - rt);
66 }
60 67
61 // Add a vector to the quad, offseting each point in the quad by the vector. 68 // Add a vector to the quad, offseting each point in the quad by the vector.
62 void operator+=(const Vector2dF& rhs); 69 void operator+=(const Vector2dF& rhs);
63 // Subtract a vector from the quad, offseting each point in the quad by the 70 // Subtract a vector from the quad, offseting each point in the quad by the
64 // inverse of the vector. 71 // inverse of the vector.
65 void operator-=(const Vector2dF& rhs); 72 void operator-=(const Vector2dF& rhs);
66 73
67 // Scale each point in the quad by the |scale| factor. 74 // Scale each point in the quad by the |scale| factor.
68 void Scale(float scale) { Scale(scale, scale); } 75 void Scale(float scale) { Scale(scale, scale); }
69 76
(...skipping 22 matching lines...) Expand all
92 99
93 // Add a vector to a quad, offseting each point in the quad by the vector. 100 // Add a vector to a quad, offseting each point in the quad by the vector.
94 UI_EXPORT QuadF operator+(const QuadF& lhs, const Vector2dF& rhs); 101 UI_EXPORT QuadF operator+(const QuadF& lhs, const Vector2dF& rhs);
95 // Subtract a vector from a quad, offseting each point in the quad by the 102 // Subtract a vector from a quad, offseting each point in the quad by the
96 // inverse of the vector. 103 // inverse of the vector.
97 UI_EXPORT QuadF operator-(const QuadF& lhs, const Vector2dF& rhs); 104 UI_EXPORT QuadF operator-(const QuadF& lhs, const Vector2dF& rhs);
98 105
99 } // namespace gfx 106 } // namespace gfx
100 107
101 #endif // UI_GFX_QUAD_F_H_ 108 #endif // UI_GFX_QUAD_F_H_
OLDNEW
« no previous file with comments | « no previous file | ui/gfx/quad_f.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698