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

Side by Side Diff: ui/gfx/geometry/vector2d.h

Issue 649203003: Type conversion fixes, ui/gfx/ edition. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Review comments Created 6 years, 1 month 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
« no previous file with comments | « ui/gfx/geometry/size.h ('k') | ui/gfx/interpolated_transform.cc » ('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 // Defines a simple integer vector class. This class is used to indicate a 5 // Defines a simple integer vector class. This class is used to indicate a
6 // distance in two dimensions between two points. Subtracting two points should 6 // distance in two dimensions between two points. Subtracting two points should
7 // produce a vector, and adding a vector to a point produces the point at the 7 // produce a vector, and adding a vector to a point produces the point at the
8 // vector's distance from the original point. 8 // vector's distance from the original point.
9 9
10 #ifndef UI_GFX_GEOMETRY_VECTOR2D_H_ 10 #ifndef UI_GFX_GEOMETRY_VECTOR2D_H_
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 53
54 // Gives the square of the diagonal length of the vector. Since this is 54 // Gives the square of the diagonal length of the vector. Since this is
55 // cheaper to compute than Length(), it is useful when you want to compare 55 // cheaper to compute than Length(), it is useful when you want to compare
56 // relative lengths of different vectors without needing the actual lengths. 56 // relative lengths of different vectors without needing the actual lengths.
57 int64 LengthSquared() const; 57 int64 LengthSquared() const;
58 // Gives the diagonal length of the vector. 58 // Gives the diagonal length of the vector.
59 float Length() const; 59 float Length() const;
60 60
61 std::string ToString() const; 61 std::string ToString() const;
62 62
63 operator Vector2dF() const { return Vector2dF(x_, y_); } 63 operator Vector2dF() const {
64 return Vector2dF(static_cast<float>(x()), static_cast<float>(y()));
65 }
64 66
65 private: 67 private:
66 int x_; 68 int x_;
67 int y_; 69 int y_;
68 }; 70 };
69 71
70 inline bool operator==(const Vector2d& lhs, const Vector2d& rhs) { 72 inline bool operator==(const Vector2d& lhs, const Vector2d& rhs) {
71 return lhs.x() == rhs.x() && lhs.y() == rhs.y(); 73 return lhs.x() == rhs.x() && lhs.y() == rhs.y();
72 } 74 }
73 75
(...skipping 14 matching lines...) Expand all
88 } 90 }
89 91
90 // This is declared here for use in gtest-based unit tests but is defined in 92 // This is declared here for use in gtest-based unit tests but is defined in
91 // the gfx_test_support target. Depend on that to use this in your unit test. 93 // the gfx_test_support target. Depend on that to use this in your unit test.
92 // This should not be used in production code - call ToString() instead. 94 // This should not be used in production code - call ToString() instead.
93 void PrintTo(const Vector2d& vector, ::std::ostream* os); 95 void PrintTo(const Vector2d& vector, ::std::ostream* os);
94 96
95 } // namespace gfx 97 } // namespace gfx
96 98
97 #endif // UI_GFX_GEOMETRY_VECTOR2D_H_ 99 #endif // UI_GFX_GEOMETRY_VECTOR2D_H_
OLDNEW
« no previous file with comments | « ui/gfx/geometry/size.h ('k') | ui/gfx/interpolated_transform.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698