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

Side by Side Diff: gfx/point.h

Issue 2867009: Add const to two methods. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 10 years, 6 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 | no next file » | 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 GFX_POINT_H_ 5 #ifndef GFX_POINT_H_
6 #define GFX_POINT_H_ 6 #define GFX_POINT_H_
7 7
8 #include "build/build_config.h" 8 #include "build/build_config.h"
9 9
10 #include <iosfwd> 10 #include <iosfwd>
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 } 45 }
46 46
47 void set_x(int x) { x_ = x; } 47 void set_x(int x) { x_ = x; }
48 void set_y(int y) { y_ = y; } 48 void set_y(int y) { y_ = y; }
49 49
50 void Offset(int delta_x, int delta_y) { 50 void Offset(int delta_x, int delta_y) {
51 x_ += delta_x; 51 x_ += delta_x;
52 y_ += delta_y; 52 y_ += delta_y;
53 } 53 }
54 54
55 Point Add(const Point& other) { 55 Point Add(const Point& other) const{
56 Point copy = *this; 56 Point copy = *this;
57 copy.Offset(other.x_, other.y_); 57 copy.Offset(other.x_, other.y_);
58 return copy; 58 return copy;
59 } 59 }
60 60
61 Point Subtract(const Point& other) { 61 Point Subtract(const Point& other) const {
62 Point copy = *this; 62 Point copy = *this;
63 copy.Offset(-other.x_, -other.y_); 63 copy.Offset(-other.x_, -other.y_);
64 return copy; 64 return copy;
65 } 65 }
66 66
67 bool operator==(const Point& rhs) const { 67 bool operator==(const Point& rhs) const {
68 return x_ == rhs.x_ && y_ == rhs.y_; 68 return x_ == rhs.x_ && y_ == rhs.y_;
69 } 69 }
70 70
71 bool operator!=(const Point& rhs) const { 71 bool operator!=(const Point& rhs) const {
72 return !(*this == rhs); 72 return !(*this == rhs);
73 } 73 }
74 74
75 #if defined(OS_WIN) 75 #if defined(OS_WIN)
76 POINT ToPOINT() const; 76 POINT ToPOINT() const;
77 #elif defined(OS_MACOSX) 77 #elif defined(OS_MACOSX)
78 CGPoint ToCGPoint() const; 78 CGPoint ToCGPoint() const;
79 #endif 79 #endif
80 80
81 private: 81 private:
82 int x_; 82 int x_;
83 int y_; 83 int y_;
84 }; 84 };
85 85
86 } // namespace gfx 86 } // namespace gfx
87 87
88 std::ostream& operator<<(std::ostream& out, const gfx::Point& p); 88 std::ostream& operator<<(std::ostream& out, const gfx::Point& p);
89 89
90 #endif // GFX_POINT_H_ 90 #endif // GFX_POINT_H_
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698