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

Side by Side Diff: ui/gfx/point3.h

Issue 7044062: Use SkMatrix44 for the underlying implementation of ui::Transform (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Added 2D unittests Created 9 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 | « ui/gfx/compositor/compositor_win.cc ('k') | ui/gfx/transform.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef UI_GFX_POINT3_H_
6 #define UI_GFX_POINT3_H_
7 #pragma once
8
9 #include <cmath>
10
11 #include "base/basictypes.h"
12 #include "ui/gfx/point.h"
13
14 namespace gfx {
15
16 // A point has an x, y and z coordinate.
17 template <typename T>
18 class Point3 {
19 public:
20 Point3()
21 : x_(0), y_(0), z_(0)
sky 2011/06/17 16:38:23 Move the member initializer list to 20.
22 {}
23
24 Point3(const T& x, const T& y, const T& z)
sky 2011/06/17 16:38:23 We generally don't use references for primitive ty
25 : x_(x), y_(y), z_(z)
sky 2011/06/17 16:38:23 If you can't fit the constructor and member initia
26 {}
27
28 Point3(const Point& point)
29 : x_(point.x())
sky 2011/06/17 16:38:23 trailing commas, not leading. And 4 space indent.
30 , y_(point.y())
31 , z_(0)
32 {}
33
34 ~Point3() {}
35
36 T x() { return x_; }
sky 2011/06/17 16:38:23 These functions should be const.
37 T y() { return y_; }
38 T z() { return z_; }
39
40 void set_x(const T& x) { x_ = x; }
41 void set_y(const T& y) { y_ = y; }
42 void set_z(const T& z) { z_ = z; }
43
44 void SetPoint(const T& x, const T& y, const T& z) {
sky 2011/06/17 16:38:23 no reference.
45 x_ = x;
46 y_ = y;
47 z_ = z;
48 }
49
50 void SetPoint(const Point3<T>& other) {
51 x_ = other.x_;
52 y_ = other.y_;
53 z_ = other.z_;
54 }
55
56 void Add(const Point3<T>& other) {
57 x_ += other.x_;
58 y_ += other.y_;
59 z_ += other.z_;
60 }
61
62 void Multiply(const T& s) {
sky 2011/06/17 16:38:23 no reference.
63 x_ *= s;
64 y_ *= s;
65 z_ *= s;
66 }
67
68 T Dist2(const Point3<T>& other) const {
sky 2011/06/17 16:38:23 Add a description as what this does isn't obvious
wjmaclean 2011/06/17 16:58:07 Rename "DistanceSquared"? "NormSquared"? (Or use "
69 T dx = x_ - other.x_;
70 T dy = y_ - other.y_;
71 T dz = z_ - other.z_;
72 return dx * dx + dy * dy + dz * dz;
73 }
74
75 Point AsPoint() {
76 return Point(
77 static_cast<int>(std::floor(x_)),
sky 2011/06/17 16:38:23 77/78 should be 4 space indented. Or better yet, a
78 static_cast<int>(std::floor(y_)));
79 }
80
81 private:
82 T x_;
83 T y_;
84 T z_;
85
86 DISALLOW_COPY_AND_ASSIGN(Point3);
sky 2011/06/17 16:38:23 I know I mentioned not enabling assignment operato
87 };
88
89 // Could point this at Skia and we'd be ok.
90 typedef Point3<float> Point3f;
91 typedef Point3<double> Point3d;
92
93 } // namespace gfx
94
95 #endif // UI_GFX_POINT3_H_
OLDNEW
« no previous file with comments | « ui/gfx/compositor/compositor_win.cc ('k') | ui/gfx/transform.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698