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

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

Issue 10996037: Do not convert from RectF to Rect by flooring. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixing mac build. Created 8 years, 2 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 | « ui/gfx/rect.h ('k') | ui/gfx/rect_conversions.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 // A template for a simple rectangle class. The containment semantics 5 // A template for a simple rectangle class. The containment semantics
6 // are array-like; that is, the coordinate (x, y) is considered to be 6 // are array-like; that is, the coordinate (x, y) is considered to be
7 // contained by the rectangle, but the coordinate (x + width, y) is not. 7 // contained by the rectangle, but the coordinate (x + width, y) is not.
8 // The class will happily let you create malformed rectangles (that is, 8 // The class will happily let you create malformed rectangles (that is,
9 // rectangles with negative width and/or height), but there will be assertions 9 // rectangles with negative width and/or height), but there will be assertions
10 // in the operations (such as Contains()) to complain in this case. 10 // in the operations (such as Contains()) to complain in this case.
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 58
59 // Shrink the rectangle by the specified amount on each side. 59 // Shrink the rectangle by the specified amount on each side.
60 void Inset(Type left, Type top, Type right, Type bottom); 60 void Inset(Type left, Type top, Type right, Type bottom);
61 61
62 // Move the rectangle by a horizontal and vertical distance. 62 // Move the rectangle by a horizontal and vertical distance.
63 void Offset(Type horizontal, Type vertical); 63 void Offset(Type horizontal, Type vertical);
64 void Offset(const PointClass& point) { 64 void Offset(const PointClass& point) {
65 Offset(point.x(), point.y()); 65 Offset(point.x(), point.y());
66 } 66 }
67 67
68 /// Scales the rectangle by |scale|.
69 Class Scale(float scale) const WARN_UNUSED_RESULT {
70 return Scale(scale, scale);
71 }
72
73 Class Scale(float x_scale, float y_scale) const WARN_UNUSED_RESULT {
74 return Class(origin_.Scale(x_scale, y_scale),
75 size_.Scale(x_scale, y_scale));
76 }
77
78 InsetsClass InsetsFrom(const Class& inner) const { 68 InsetsClass InsetsFrom(const Class& inner) const {
79 return InsetsClass(inner.y() - y(), 69 return InsetsClass(inner.y() - y(),
80 inner.x() - x(), 70 inner.x() - x(),
81 bottom() - inner.bottom(), 71 bottom() - inner.bottom(),
82 right() - inner.right()); 72 right() - inner.right());
83 } 73 }
84 74
85 // Returns true if the area of the rectangle is zero. 75 // Returns true if the area of the rectangle is zero.
86 bool IsEmpty() const { return size_.IsEmpty(); } 76 bool IsEmpty() const { return size_.IsEmpty(); }
87 77
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 ~RectBase(); 153 ~RectBase();
164 154
165 private: 155 private:
166 PointClass origin_; 156 PointClass origin_;
167 SizeClass size_; 157 SizeClass size_;
168 }; 158 };
169 159
170 } // namespace gfx 160 } // namespace gfx
171 161
172 #endif // UI_GFX_RECT_BASE_H_ 162 #endif // UI_GFX_RECT_BASE_H_
OLDNEW
« no previous file with comments | « ui/gfx/rect.h ('k') | ui/gfx/rect_conversions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698