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

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

Issue 1543183002: Switch to standard integer types in ui/gfx/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 12 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
« no previous file with comments | « ui/gfx/geometry/vector2d.h ('k') | ui/gfx/geometry/vector2d_unittest.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 #include "ui/gfx/geometry/vector2d.h" 5 #include "ui/gfx/geometry/vector2d.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 8
9 #include "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
10 10
11 namespace gfx { 11 namespace gfx {
12 12
13 bool Vector2d::IsZero() const { 13 bool Vector2d::IsZero() const {
14 return x_ == 0 && y_ == 0; 14 return x_ == 0 && y_ == 0;
15 } 15 }
16 16
17 void Vector2d::Add(const Vector2d& other) { 17 void Vector2d::Add(const Vector2d& other) {
18 x_ += other.x_; 18 x_ += other.x_;
19 y_ += other.y_; 19 y_ += other.y_;
20 } 20 }
21 21
22 void Vector2d::Subtract(const Vector2d& other) { 22 void Vector2d::Subtract(const Vector2d& other) {
23 x_ -= other.x_; 23 x_ -= other.x_;
24 y_ -= other.y_; 24 y_ -= other.y_;
25 } 25 }
26 26
27 int64 Vector2d::LengthSquared() const { 27 int64_t Vector2d::LengthSquared() const {
28 return static_cast<int64>(x_) * x_ + static_cast<int64>(y_) * y_; 28 return static_cast<int64_t>(x_) * x_ + static_cast<int64_t>(y_) * y_;
29 } 29 }
30 30
31 float Vector2d::Length() const { 31 float Vector2d::Length() const {
32 return static_cast<float>(std::sqrt(static_cast<double>(LengthSquared()))); 32 return static_cast<float>(std::sqrt(static_cast<double>(LengthSquared())));
33 } 33 }
34 34
35 std::string Vector2d::ToString() const { 35 std::string Vector2d::ToString() const {
36 return base::StringPrintf("[%d %d]", x_, y_); 36 return base::StringPrintf("[%d %d]", x_, y_);
37 } 37 }
38 38
39 } // namespace gfx 39 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gfx/geometry/vector2d.h ('k') | ui/gfx/geometry/vector2d_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698