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

Side by Side Diff: cc/base/math_util.h

Issue 23043011: cc: Use SkMScalar instead of doubles everywhere in cc (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: danakj review Created 7 years, 3 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 | « cc/base/float_quad_unittest.cc ('k') | cc/base/math_util.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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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 #ifndef CC_BASE_MATH_UTIL_H_ 5 #ifndef CC_BASE_MATH_UTIL_H_
6 #define CC_BASE_MATH_UTIL_H_ 6 #define CC_BASE_MATH_UTIL_H_
7 7
8 #include <algorithm> 8 #include <algorithm>
9 #include <cmath> 9 #include <cmath>
10 10
(...skipping 27 matching lines...) Expand all
38 38
39 bool ShouldBeClipped() const { return w() <= 0.0; } 39 bool ShouldBeClipped() const { return w() <= 0.0; }
40 40
41 gfx::PointF CartesianPoint2d() const { 41 gfx::PointF CartesianPoint2d() const {
42 if (w() == 1.0) 42 if (w() == 1.0)
43 return gfx::PointF(x(), y()); 43 return gfx::PointF(x(), y());
44 44
45 // For now, because this code is used privately only by MathUtil, it should 45 // For now, because this code is used privately only by MathUtil, it should
46 // never be called when w == 0, and we do not yet need to handle that case. 46 // never be called when w == 0, and we do not yet need to handle that case.
47 DCHECK(w()); 47 DCHECK(w());
48 double inv_w = 1.0 / w(); 48 SkMScalar inv_w = 1.0 / w();
49 return gfx::PointF(x() * inv_w, y() * inv_w); 49 return gfx::PointF(x() * inv_w, y() * inv_w);
50 } 50 }
51 51
52 gfx::Point3F CartesianPoint3d() const { 52 gfx::Point3F CartesianPoint3d() const {
53 if (w() == 1) 53 if (w() == 1)
54 return gfx::Point3F(x(), y(), z()); 54 return gfx::Point3F(x(), y(), z());
55 55
56 // For now, because this code is used privately only by MathUtil, it should 56 // For now, because this code is used privately only by MathUtil, it should
57 // never be called when w == 0, and we do not yet need to handle that case. 57 // never be called when w == 0, and we do not yet need to handle that case.
58 DCHECK(w()); 58 DCHECK(w());
59 double inv_w = 1.0 / w(); 59 SkMScalar inv_w = 1.0 / w();
60 return gfx::Point3F(x() * inv_w, y() * inv_w, z() * inv_w); 60 return gfx::Point3F(x() * inv_w, y() * inv_w, z() * inv_w);
61 } 61 }
62 62
63 SkMScalar x() const { return vec[0]; } 63 SkMScalar x() const { return vec[0]; }
64 SkMScalar y() const { return vec[1]; } 64 SkMScalar y() const { return vec[1]; }
65 SkMScalar z() const { return vec[2]; } 65 SkMScalar z() const { return vec[2]; }
66 SkMScalar w() const { return vec[3]; } 66 SkMScalar w() const { return vec[3]; }
67 67
68 SkMScalar vec[4]; 68 SkMScalar vec[4];
69 }; 69 };
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 175
176 // Returns a base::Value representation of the floating point value. 176 // Returns a base::Value representation of the floating point value.
177 // If the value is inf, returns max double/float representation. 177 // If the value is inf, returns max double/float representation.
178 static scoped_ptr<base::Value> AsValueSafely(double value); 178 static scoped_ptr<base::Value> AsValueSafely(double value);
179 static scoped_ptr<base::Value> AsValueSafely(float value); 179 static scoped_ptr<base::Value> AsValueSafely(float value);
180 }; 180 };
181 181
182 } // namespace cc 182 } // namespace cc
183 183
184 #endif // CC_BASE_MATH_UTIL_H_ 184 #endif // CC_BASE_MATH_UTIL_H_
OLDNEW
« no previous file with comments | « cc/base/float_quad_unittest.cc ('k') | cc/base/math_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698