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

Side by Side Diff: ppapi/cpp/point.h

Issue 7617018: Small changes such as spacing and adding [in/out] identifiers after @params. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 4 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 | « ppapi/cpp/paint_manager.h ('k') | ppapi/cpp/rect.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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 PPAPI_CPP_POINT_H_ 5 #ifndef PPAPI_CPP_POINT_H_
6 #define PPAPI_CPP_POINT_H_ 6 #define PPAPI_CPP_POINT_H_
7 7
8 #include "ppapi/c/pp_point.h" 8 #include "ppapi/c/pp_point.h"
9 9
10 /// @file 10 /// @file
11 /// This file defines the API to create a 2 dimensional point. 11 /// This file defines the API to create a 2 dimensional point.
12 12
13 namespace pp { 13 namespace pp {
14 14
15 /// A 2 dimensional point with 0,0 being the upper-left starting coordinate. 15 /// A 2 dimensional point with 0,0 being the upper-left starting coordinate.
16 class Point { 16 class Point {
17 public: 17 public:
18 /// The default constructor for a point at 0,0. 18 /// The default constructor for a point at 0,0.
19 Point() { 19 Point() {
20 point_.x = 0; 20 point_.x = 0;
21 point_.y = 0; 21 point_.y = 0;
22 } 22 }
23 23
24 /// A constructor accepting two int32_t values for x and y and converting 24 /// A constructor accepting two int32_t values for x and y and converting
25 /// them to a Point. 25 /// them to a Point.
26 ///
26 /// @param[in] in_x An int32_t value representing a horizontal coordinate 27 /// @param[in] in_x An int32_t value representing a horizontal coordinate
27 /// of a point, starting with 0 as the left-most coordinate. 28 /// of a point, starting with 0 as the left-most coordinate.
28 /// @param[in] in_y An int32_t value representing a vertical coordinate 29 /// @param[in] in_y An int32_t value representing a vertical coordinate
29 /// of a point, starting with 0 as the top-most coordinate. 30 /// of a point, starting with 0 as the top-most coordinate.
30 Point(int32_t in_x, int32_t in_y) { 31 Point(int32_t in_x, int32_t in_y) {
31 point_.x = in_x; 32 point_.x = in_x;
32 point_.y = in_y; 33 point_.y = in_y;
33 } 34 }
34 35
35 /// A constructor accepting a pointer to a PP_Point and converting the 36 /// A constructor accepting a pointer to a PP_Point and converting the
36 /// PP_Point to a Point. This is an implicit conversion constructor. 37 /// PP_Point to a Point. This is an implicit conversion constructor.
38 ///
37 /// @param[in] point A pointer to a PP_Point. 39 /// @param[in] point A pointer to a PP_Point.
38 Point(const PP_Point& point) { // Implicit. 40 Point(const PP_Point& point) { // Implicit.
39 point_.x = point.x; 41 point_.x = point.x;
40 point_.y = point.y; 42 point_.y = point.y;
41 } 43 }
42 44
43 /// Destructor. 45 /// Destructor.
44 ~Point() { 46 ~Point() {
45 } 47 }
46 48
47 /// A function allowing implicit conversion of a Point to a PP_Point. 49 /// A function allowing implicit conversion of a Point to a PP_Point.
48 /// @return A Point. 50 /// @return A Point.
49 operator PP_Point() const { 51 operator PP_Point() const {
50 return point_; 52 return point_;
51 } 53 }
52 54
53 /// Getter function for returning the internal PP_Point struct. 55 /// Getter function for returning the internal PP_Point struct.
56 ///
54 /// @return A const reference to the internal PP_Point struct. 57 /// @return A const reference to the internal PP_Point struct.
55 const PP_Point& pp_point() const { 58 const PP_Point& pp_point() const {
56 return point_; 59 return point_;
57 } 60 }
58 61
59 /// Getter function for returning the internal PP_Point struct. 62 /// Getter function for returning the internal PP_Point struct.
63 ///
60 /// @return A mutable reference to the PP_Point struct. 64 /// @return A mutable reference to the PP_Point struct.
61 PP_Point& pp_point() { 65 PP_Point& pp_point() {
62 return point_; 66 return point_;
63 } 67 }
64 68
65 /// Getter function for returning the value of x. 69 /// Getter function for returning the value of x.
70 ///
66 /// @return The value of x for this Point. 71 /// @return The value of x for this Point.
67 int32_t x() const { return point_.x; } 72 int32_t x() const { return point_.x; }
68 73
69 /// Setter function for setting the value of x. 74 /// Setter function for setting the value of x.
75 ///
70 /// @param[in] in_x A new x value. 76 /// @param[in] in_x A new x value.
71 void set_x(int32_t in_x) { 77 void set_x(int32_t in_x) {
72 point_.x = in_x; 78 point_.x = in_x;
73 } 79 }
74 80
75 /// Getter function for returning the value of y. 81 /// Getter function for returning the value of y.
82 ///
76 /// @return The value of y for this Point. 83 /// @return The value of y for this Point.
77 int32_t y() const { return point_.y; } 84 int32_t y() const { return point_.y; }
78 85
79 /// Setter function for setting the value of y. 86 /// Setter function for setting the value of y.
87 ///
80 /// @param[in] in_y A new y value. 88 /// @param[in] in_y A new y value.
81 void set_y(int32_t in_y) { 89 void set_y(int32_t in_y) {
82 point_.y = in_y; 90 point_.y = in_y;
83 } 91 }
84 92
85 /// Adds two Points (this and other) together by adding their x values and 93 /// Adds two Points (this and other) together by adding their x values and
86 /// y values. 94 /// y values.
95 ///
87 /// @param[in] other A Point. 96 /// @param[in] other A Point.
97 ///
88 /// @return A new Point containing the result. 98 /// @return A new Point containing the result.
89 Point operator+(const Point& other) const { 99 Point operator+(const Point& other) const {
90 return Point(x() + other.x(), y() + other.y()); 100 return Point(x() + other.x(), y() + other.y());
91 } 101 }
92 102
93 /// Subtracts one Point from another Point by subtracting their x values 103 /// Subtracts one Point from another Point by subtracting their x values
94 /// and y values. Returnes a new point with the result. 104 /// and y values. Returnes a new point with the result.
105 ///
95 /// @param[in] other A Point. 106 /// @param[in] other A Point.
107 ///
96 /// @return A new Point containing the result. 108 /// @return A new Point containing the result.
97 Point operator-(const Point& other) const { 109 Point operator-(const Point& other) const {
98 return Point(x() - other.x(), y() - other.y()); 110 return Point(x() - other.x(), y() - other.y());
99 } 111 }
100 112
101 /// Adds two Points (this and other) together by adding their x and y 113 /// Adds two Points (this and other) together by adding their x and y
102 /// values. Returns this point as the result. 114 /// values. Returns this point as the result.
115 ///
103 /// @param[in] other A Point. 116 /// @param[in] other A Point.
117 ///
104 /// @return This Point containing the result. 118 /// @return This Point containing the result.
105 Point& operator+=(const Point& other) { 119 Point& operator+=(const Point& other) {
106 point_.x += other.x(); 120 point_.x += other.x();
107 point_.y += other.y(); 121 point_.y += other.y();
108 return *this; 122 return *this;
109 } 123 }
110 124
111 /// Subtracts one Point from another Point by subtracting their x values 125 /// Subtracts one Point from another Point by subtracting their x values
112 /// and y values. Returns this point as the result. 126 /// and y values. Returns this point as the result.
127 ///
113 /// @param[in] other A Point. 128 /// @param[in] other A Point.
129 ///
114 /// @return This Point containing the result. 130 /// @return This Point containing the result.
115 Point& operator-=(const Point& other) { 131 Point& operator-=(const Point& other) {
116 point_.x -= other.x(); 132 point_.x -= other.x();
117 point_.y -= other.y(); 133 point_.y -= other.y();
118 return *this; 134 return *this;
119 } 135 }
120 136
121 /// Swaps the coordinates of two Points. 137 /// Swaps the coordinates of two Points.
138 ///
122 /// @param[in] other A Point. 139 /// @param[in] other A Point.
123 void swap(Point& other) { 140 void swap(Point& other) {
124 int32_t x = point_.x; 141 int32_t x = point_.x;
125 int32_t y = point_.y; 142 int32_t y = point_.y;
126 point_.x = other.point_.x; 143 point_.x = other.point_.x;
127 point_.y = other.point_.y; 144 point_.y = other.point_.y;
128 other.point_.x = x; 145 other.point_.x = x;
129 other.point_.y = y; 146 other.point_.y = y;
130 } 147 }
131 148
(...skipping 19 matching lines...) Expand all
151 /// 168 ///
152 /// @param[in] in_y An value representing a vertical coordinate of a point, 169 /// @param[in] in_y An value representing a vertical coordinate of a point,
153 /// starting with 0 as the top-most coordinate. 170 /// starting with 0 as the top-most coordinate.
154 FloatPoint(float in_x, float in_y) { 171 FloatPoint(float in_x, float in_y) {
155 float_point_.x = in_x; 172 float_point_.x = in_x;
156 float_point_.y = in_y; 173 float_point_.y = in_y;
157 } 174 }
158 175
159 /// A constructor accepting a pointer to a PP_FloatPoint and converting the 176 /// A constructor accepting a pointer to a PP_FloatPoint and converting the
160 /// PP_Point to a Point. This is an implicit conversion constructor. 177 /// PP_Point to a Point. This is an implicit conversion constructor.
178 ///
161 /// @param[in] point A PP_FloatPoint. 179 /// @param[in] point A PP_FloatPoint.
162 FloatPoint(const PP_FloatPoint& point) { // Implicit. 180 FloatPoint(const PP_FloatPoint& point) { // Implicit.
163 float_point_.x = point.x; 181 float_point_.x = point.x;
164 float_point_.y = point.y; 182 float_point_.y = point.y;
165 } 183 }
166 /// Destructor. 184 /// Destructor.
167 ~FloatPoint() { 185 ~FloatPoint() {
168 } 186 }
169 187
170 /// A function allowing implicit conversion of a FloatPoint to a 188 /// A function allowing implicit conversion of a FloatPoint to a
171 /// PP_FloatPoint. 189 /// PP_FloatPoint.
172 operator PP_FloatPoint() const { 190 operator PP_FloatPoint() const {
173 return float_point_; 191 return float_point_;
174 } 192 }
175 193
176 /// Getter function for returning the internal PP_FloatPoint struct. 194 /// Getter function for returning the internal PP_FloatPoint struct.
195 ///
177 /// @return A const reference to the internal PP_FloatPoint struct. 196 /// @return A const reference to the internal PP_FloatPoint struct.
178 const PP_FloatPoint& pp_float_point() const { 197 const PP_FloatPoint& pp_float_point() const {
179 return float_point_; 198 return float_point_;
180 } 199 }
181 200
182 /// Getter function for returning the internal PP_Point struct. 201 /// Getter function for returning the internal PP_Point struct.
202 ///
183 /// @return A mutable reference to the PP_Point struct. 203 /// @return A mutable reference to the PP_Point struct.
184 PP_FloatPoint& pp_float_point() { 204 PP_FloatPoint& pp_float_point() {
185 return float_point_; 205 return float_point_;
186 } 206 }
187 207
188 /// Getter function for returning the value of x. 208 /// Getter function for returning the value of x.
209 ///
189 /// @return The value of x for this Point. 210 /// @return The value of x for this Point.
190 float x() const { return float_point_.x; } 211 float x() const { return float_point_.x; }
191 212
192 /// Setter function for setting the value of x. 213 /// Setter function for setting the value of x.
214 ///
193 /// @param[in] in_x A new x value. 215 /// @param[in] in_x A new x value.
194 void set_x(float in_x) { 216 void set_x(float in_x) {
195 float_point_.x = in_x; 217 float_point_.x = in_x;
196 } 218 }
197 219
198 /// Getter function for returning the value of y. 220 /// Getter function for returning the value of y.
221 ///
199 /// @return The value of y for this Point. 222 /// @return The value of y for this Point.
200 float y() const { return float_point_.y; } 223 float y() const { return float_point_.y; }
201 224
202 /// Setter function for setting the value of y. 225 /// Setter function for setting the value of y.
226 ///
203 /// @param[in] in_y A new y value. 227 /// @param[in] in_y A new y value.
204 void set_y(float in_y) { 228 void set_y(float in_y) {
205 float_point_.y = in_y; 229 float_point_.y = in_y;
206 } 230 }
207 231
208 /// Adds two Points (this and other) together by adding their x values and 232 /// Adds two Points (this and other) together by adding their x values and
209 /// y values. 233 /// y values.
234 ///
210 /// @param[in] other A Point. 235 /// @param[in] other A Point.
236 ///
211 /// @return A new Point containing the result. 237 /// @return A new Point containing the result.
212 FloatPoint operator+(const FloatPoint& other) const { 238 FloatPoint operator+(const FloatPoint& other) const {
213 return FloatPoint(x() + other.x(), y() + other.y()); 239 return FloatPoint(x() + other.x(), y() + other.y());
214 } 240 }
215 241
216 /// Subtracts one Point from another Point by subtracting their x values 242 /// Subtracts one Point from another Point by subtracting their x values
217 /// and y values. Returnes a new point with the result. 243 /// and y values. Returnes a new point with the result.
244 ///
218 /// @param[in] other A FloatPoint. 245 /// @param[in] other A FloatPoint.
246 ///
219 /// @return A new Point containing the result. 247 /// @return A new Point containing the result.
220 FloatPoint operator-(const FloatPoint& other) const { 248 FloatPoint operator-(const FloatPoint& other) const {
221 return FloatPoint(x() - other.x(), y() - other.y()); 249 return FloatPoint(x() - other.x(), y() - other.y());
222 } 250 }
223 251
224 /// Adds two Points (this and other) together by adding their x and y 252 /// Adds two Points (this and other) together by adding their x and y
225 /// values. Returns this point as the result. 253 /// values. Returns this point as the result.
254 ///
226 /// @param[in] other A Point. 255 /// @param[in] other A Point.
256 ///
227 /// @return This Point containing the result. 257 /// @return This Point containing the result.
228 FloatPoint& operator+=(const FloatPoint& other) { 258 FloatPoint& operator+=(const FloatPoint& other) {
229 float_point_.x += other.x(); 259 float_point_.x += other.x();
230 float_point_.y += other.y(); 260 float_point_.y += other.y();
231 return *this; 261 return *this;
232 } 262 }
233 263
234 /// Subtracts one Point from another Point by subtracting their x values 264 /// Subtracts one Point from another Point by subtracting their x values
235 /// and y values. Returns this point as the result. 265 /// and y values. Returns this point as the result.
266 ///
236 /// @param[in] other A Point. 267 /// @param[in] other A Point.
268 ///
237 /// @return This Point containing the result. 269 /// @return This Point containing the result.
238 FloatPoint& operator-=(const FloatPoint& other) { 270 FloatPoint& operator-=(const FloatPoint& other) {
239 float_point_.x -= other.x(); 271 float_point_.x -= other.x();
240 float_point_.y -= other.y(); 272 float_point_.y -= other.y();
241 return *this; 273 return *this;
242 } 274 }
243 275
244 /// Swaps the coordinates of two Points. 276 /// Swaps the coordinates of two Points.
277 ///
245 /// @param[in] other A Point. 278 /// @param[in] other A Point.
246 void swap(FloatPoint& other) { 279 void swap(FloatPoint& other) {
247 float x = float_point_.x; 280 float x = float_point_.x;
248 float y = float_point_.y; 281 float y = float_point_.y;
249 float_point_.x = other.float_point_.x; 282 float_point_.x = other.float_point_.x;
250 float_point_.y = other.float_point_.y; 283 float_point_.y = other.float_point_.y;
251 other.float_point_.x = x; 284 other.float_point_.x = x;
252 other.float_point_.y = y; 285 other.float_point_.y = y;
253 } 286 }
254 287
255 private: 288 private:
256 PP_FloatPoint float_point_; 289 PP_FloatPoint float_point_;
257 }; 290 };
258 291
259 } // namespace pp 292 } // namespace pp
260 293
261 /// Determines whether the x and y values of two Points are equal. 294 /// Determines whether the x and y values of two Points are equal.
295 ///
262 /// @param[in] lhs The Point on the left-hand side of the equation. 296 /// @param[in] lhs The Point on the left-hand side of the equation.
263 /// @param[in] rhs The Point on the right-hand side of the equation. 297 /// @param[in] rhs The Point on the right-hand side of the equation.
298 ///
264 /// @return true if they are equal, false if unequal. 299 /// @return true if they are equal, false if unequal.
265 inline bool operator==(const pp::Point& lhs, const pp::Point& rhs) { 300 inline bool operator==(const pp::Point& lhs, const pp::Point& rhs) {
266 return lhs.x() == rhs.x() && lhs.y() == rhs.y(); 301 return lhs.x() == rhs.x() && lhs.y() == rhs.y();
267 } 302 }
268 303
269 /// Determines whether two Points have different coordinates. 304 /// Determines whether two Points have different coordinates.
305 ///
270 /// @param[in] lhs The Point on the left-hand side of the equation. 306 /// @param[in] lhs The Point on the left-hand side of the equation.
271 /// @param[in] rhs The Point on the right-hand side of the equation. 307 /// @param[in] rhs The Point on the right-hand side of the equation.
308 ///
272 /// @return true if the coordinates of lhs are equal to the coordinates 309 /// @return true if the coordinates of lhs are equal to the coordinates
273 /// of rhs, otherwise false. 310 /// of rhs, otherwise false.
274 inline bool operator!=(const pp::Point& lhs, const pp::Point& rhs) { 311 inline bool operator!=(const pp::Point& lhs, const pp::Point& rhs) {
275 return !(lhs == rhs); 312 return !(lhs == rhs);
276 } 313 }
277 314
278 /// Determines whether the x and y values of two FloatPoints are equal. 315 /// Determines whether the x and y values of two FloatPoints are equal.
316 ///
279 /// @param[in] lhs The Point on the left-hand side of the equation. 317 /// @param[in] lhs The Point on the left-hand side of the equation.
280 /// @param[in] rhs The Point on the right-hand side of the equation. 318 /// @param[in] rhs The Point on the right-hand side of the equation.
319 ///
281 /// @return true if they are equal, false if unequal. 320 /// @return true if they are equal, false if unequal.
282 inline bool operator==(const pp::FloatPoint& lhs, const pp::FloatPoint& rhs) { 321 inline bool operator==(const pp::FloatPoint& lhs, const pp::FloatPoint& rhs) {
283 return lhs.x() == rhs.x() && lhs.y() == rhs.y(); 322 return lhs.x() == rhs.x() && lhs.y() == rhs.y();
284 } 323 }
285 324
286 /// Determines whether two Points have different coordinates. 325 /// Determines whether two Points have different coordinates.
326 ///
287 /// @param[in] lhs The Point on the left-hand side of the equation. 327 /// @param[in] lhs The Point on the left-hand side of the equation.
288 /// @param[in] rhs The Point on the right-hand side of the equation. 328 /// @param[in] rhs The Point on the right-hand side of the equation.
329 ///
289 /// @return true if the coordinates of lhs are equal to the coordinates 330 /// @return true if the coordinates of lhs are equal to the coordinates
290 /// of rhs, otherwise false. 331 /// of rhs, otherwise false.
291 inline bool operator!=(const pp::FloatPoint& lhs, const pp::FloatPoint& rhs) { 332 inline bool operator!=(const pp::FloatPoint& lhs, const pp::FloatPoint& rhs) {
292 return !(lhs == rhs); 333 return !(lhs == rhs);
293 } 334 }
294 335
295 #endif // PPAPI_CPP_POINT_H_ 336 #endif // PPAPI_CPP_POINT_H_
OLDNEW
« no previous file with comments | « ppapi/cpp/paint_manager.h ('k') | ppapi/cpp/rect.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698