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

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

Issue 11414284: Inline gfx::Vector2d* ctors and integer conversions (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix compile Created 8 years 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/vector2d.h ('k') | ui/gfx/vector2d_f.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 #include "ui/gfx/vector2d.h" 5 #include "ui/gfx/vector2d.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 8
9 #include "base/stringprintf.h" 9 #include "base/stringprintf.h"
10 10
11 namespace gfx { 11 namespace gfx {
12 12
13 Vector2d::Vector2d() : x_(0), y_(0) {
14 }
15
16 Vector2d::Vector2d(int x, int y) : x_(x), y_(y) {
17 }
18
19 bool Vector2d::IsZero() const { 13 bool Vector2d::IsZero() const {
20 return x_ == 0 && y_ == 0; 14 return x_ == 0 && y_ == 0;
21 } 15 }
22 16
23 void Vector2d::Add(const Vector2d& other) { 17 void Vector2d::Add(const Vector2d& other) {
24 x_ += other.x_; 18 x_ += other.x_;
25 y_ += other.y_; 19 y_ += other.y_;
26 } 20 }
27 21
28 void Vector2d::Subtract(const Vector2d& other) { 22 void Vector2d::Subtract(const Vector2d& other) {
29 x_ -= other.x_; 23 x_ -= other.x_;
30 y_ -= other.y_; 24 y_ -= other.y_;
31 } 25 }
32 26
33 int64 Vector2d::LengthSquared() const { 27 int64 Vector2d::LengthSquared() const {
34 return static_cast<int64>(x_) * x_ + static_cast<int64>(y_) * y_; 28 return static_cast<int64>(x_) * x_ + static_cast<int64>(y_) * y_;
35 } 29 }
36 30
37 float Vector2d::Length() const { 31 float Vector2d::Length() const {
38 return static_cast<float>(std::sqrt(static_cast<double>(LengthSquared()))); 32 return static_cast<float>(std::sqrt(static_cast<double>(LengthSquared())));
39 } 33 }
40 34
41 std::string Vector2d::ToString() const { 35 std::string Vector2d::ToString() const {
42 return base::StringPrintf("[%d %d]", x_, y_); 36 return base::StringPrintf("[%d %d]", x_, y_);
43 } 37 }
44 38
45 } // namespace gfx 39 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gfx/vector2d.h ('k') | ui/gfx/vector2d_f.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698