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/point_base.h

Issue 11081007: Remove implicit flooring Scale() method from Point and Size. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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/point.h ('k') | ui/gfx/point_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 #ifndef UI_GFX_POINT_BASE_H_ 5 #ifndef UI_GFX_POINT_BASE_H_
6 #define UI_GFX_POINT_BASE_H_ 6 #define UI_GFX_POINT_BASE_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
(...skipping 15 matching lines...) Expand all
26 } 26 }
27 27
28 void set_x(Type x) { x_ = x; } 28 void set_x(Type x) { x_ = x; }
29 void set_y(Type y) { y_ = y; } 29 void set_y(Type y) { y_ = y; }
30 30
31 void Offset(Type delta_x, Type delta_y) { 31 void Offset(Type delta_x, Type delta_y) {
32 x_ += delta_x; 32 x_ += delta_x;
33 y_ += delta_y; 33 y_ += delta_y;
34 } 34 }
35 35
36 Class Scale(float scale) const WARN_UNUSED_RESULT {
37 return Scale(scale, scale);
38 }
39
40 Class Scale(float x_scale, float y_scale) const WARN_UNUSED_RESULT {
41 return Class(static_cast<Type>(x_ * x_scale),
42 static_cast<Type>(y_ * y_scale));
43 }
44
45 Class Add(const Class& other) const WARN_UNUSED_RESULT { 36 Class Add(const Class& other) const WARN_UNUSED_RESULT {
46 const Class* orig = static_cast<const Class*>(this); 37 const Class* orig = static_cast<const Class*>(this);
47 Class copy = *orig; 38 Class copy = *orig;
48 copy.Offset(other.x_, other.y_); 39 copy.Offset(other.x_, other.y_);
49 return copy; 40 return copy;
50 } 41 }
51 42
52 Class Subtract(const Class& other) const WARN_UNUSED_RESULT { 43 Class Subtract(const Class& other) const WARN_UNUSED_RESULT {
53 const Class* orig = static_cast<const Class*>(this); 44 const Class* orig = static_cast<const Class*>(this);
54 Class copy = *orig; 45 Class copy = *orig;
(...skipping 30 matching lines...) Expand all
85 ~PointBase() {} 76 ~PointBase() {}
86 77
87 private: 78 private:
88 Type x_; 79 Type x_;
89 Type y_; 80 Type y_;
90 }; 81 };
91 82
92 } // namespace gfx 83 } // namespace gfx
93 84
94 #endif // UI_GFX_POINT_BASE_H_ 85 #endif // UI_GFX_POINT_BASE_H_
OLDNEW
« no previous file with comments | « ui/gfx/point.h ('k') | ui/gfx/point_conversions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698