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

Side by Side Diff: ui/gfx/rect_f.cc

Issue 11428076: Inline hot ctor/dtors for struct-like gfx:: geometry types (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix style issues Created 8 years 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 | « ui/gfx/rect_f.h ('k') | ui/gfx/size.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 #include "ui/gfx/rect_f.h" 5 #include "ui/gfx/rect_f.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/stringprintf.h" 10 #include "base/stringprintf.h"
11 #include "ui/gfx/insets_f.h" 11 #include "ui/gfx/insets_f.h"
12 #include "ui/gfx/rect_base_impl.h" 12 #include "ui/gfx/rect_base_impl.h"
13 #include "ui/gfx/safe_integer_conversions.h" 13 #include "ui/gfx/safe_integer_conversions.h"
14 14
15 namespace gfx { 15 namespace gfx {
16 16
17 template class RectBase<RectF, PointF, SizeF, InsetsF, Vector2dF, float>; 17 template class RectBase<RectF, PointF, SizeF, InsetsF, Vector2dF, float>;
18 18
19 typedef class RectBase<RectF, PointF, SizeF, InsetsF, Vector2dF, 19 typedef class RectBase<RectF, PointF, SizeF, InsetsF, Vector2dF,
20 float> RectBaseT; 20 float> RectBaseT;
21 21
22 RectF::RectF() : RectBaseT(gfx::SizeF()) {
23 }
24
25 RectF::RectF(float width, float height)
26 : RectBaseT(gfx::SizeF(width, height)) {
27 }
28
29 RectF::RectF(float x, float y, float width, float height)
30 : RectBaseT(gfx::PointF(x, y), gfx::SizeF(width, height)) {
31 }
32
33 RectF::RectF(const gfx::SizeF& size)
34 : RectBaseT(size) {
35 }
36
37 RectF::RectF(const gfx::PointF& origin, const gfx::SizeF& size)
38 : RectBaseT(origin, size) {
39 }
40
41 RectF::~RectF() {}
42
43 bool RectF::IsExpressibleAsRect() const { 22 bool RectF::IsExpressibleAsRect() const {
44 return IsExpressibleAsInt(x()) && IsExpressibleAsInt(y()) && 23 return IsExpressibleAsInt(x()) && IsExpressibleAsInt(y()) &&
45 IsExpressibleAsInt(width()) && IsExpressibleAsInt(height()) && 24 IsExpressibleAsInt(width()) && IsExpressibleAsInt(height()) &&
46 IsExpressibleAsInt(right()) && IsExpressibleAsInt(bottom()); 25 IsExpressibleAsInt(right()) && IsExpressibleAsInt(bottom());
47 } 26 }
48 27
49 std::string RectF::ToString() const { 28 std::string RectF::ToString() const {
50 return base::StringPrintf("%s %s", 29 return base::StringPrintf("%s %s",
51 origin().ToString().c_str(), 30 origin().ToString().c_str(),
52 size().ToString().c_str()); 31 size().ToString().c_str());
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 69
91 RectF BoundingRect(const PointF& p1, const PointF& p2) { 70 RectF BoundingRect(const PointF& p1, const PointF& p2) {
92 float rx = std::min(p1.x(), p2.x()); 71 float rx = std::min(p1.x(), p2.x());
93 float ry = std::min(p1.y(), p2.y()); 72 float ry = std::min(p1.y(), p2.y());
94 float rr = std::max(p1.x(), p2.x()); 73 float rr = std::max(p1.x(), p2.x());
95 float rb = std::max(p1.y(), p2.y()); 74 float rb = std::max(p1.y(), p2.y());
96 return RectF(rx, ry, rr - rx, rb - ry); 75 return RectF(rx, ry, rr - rx, rb - ry);
97 } 76 }
98 77
99 } // namespace gfx 78 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gfx/rect_f.h ('k') | ui/gfx/size.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698