| OLD | NEW |
| 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 CCMathUtil_h | 5 #ifndef CCMathUtil_h |
| 6 #define CCMathUtil_h | 6 #define CCMathUtil_h |
| 7 | 7 |
| 8 #include "base/logging.h" | |
| 9 #include "FloatPoint.h" | 8 #include "FloatPoint.h" |
| 10 #include "FloatPoint3D.h" | 9 #include "FloatPoint3D.h" |
| 11 | 10 |
| 12 namespace WebKit { | 11 namespace WebKit { |
| 13 class WebTransformationMatrix; | 12 class WebTransformationMatrix; |
| 14 } | 13 } |
| 15 | 14 |
| 16 namespace cc { | 15 namespace cc { |
| 17 | 16 |
| 18 class IntRect; | 17 class IntRect; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 32 { | 31 { |
| 33 return w <= 0; | 32 return w <= 0; |
| 34 } | 33 } |
| 35 | 34 |
| 36 FloatPoint cartesianPoint2d() const | 35 FloatPoint cartesianPoint2d() const |
| 37 { | 36 { |
| 38 if (w == 1) | 37 if (w == 1) |
| 39 return FloatPoint(x, y); | 38 return FloatPoint(x, y); |
| 40 | 39 |
| 41 // For now, because this code is used privately only by CCMathUtil, it s
hould never be called when w == 0, and we do not yet need to handle that case. | 40 // For now, because this code is used privately only by CCMathUtil, it s
hould never be called when w == 0, and we do not yet need to handle that case. |
| 42 DCHECK(w); | 41 ASSERT(w); |
| 43 double invW = 1.0 / w; | 42 double invW = 1.0 / w; |
| 44 return FloatPoint(x * invW, y * invW); | 43 return FloatPoint(x * invW, y * invW); |
| 45 } | 44 } |
| 46 | 45 |
| 47 FloatPoint3D cartesianPoint3d() const | 46 FloatPoint3D cartesianPoint3d() const |
| 48 { | 47 { |
| 49 if (w == 1) | 48 if (w == 1) |
| 50 return FloatPoint3D(x, y, z); | 49 return FloatPoint3D(x, y, z); |
| 51 | 50 |
| 52 // For now, because this code is used privately only by CCMathUtil, it s
hould never be called when w == 0, and we do not yet need to handle that case. | 51 // For now, because this code is used privately only by CCMathUtil, it s
hould never be called when w == 0, and we do not yet need to handle that case. |
| 53 DCHECK(w); | 52 ASSERT(w); |
| 54 double invW = 1.0 / w; | 53 double invW = 1.0 / w; |
| 55 return FloatPoint3D(x * invW, y * invW, z * invW); | 54 return FloatPoint3D(x * invW, y * invW, z * invW); |
| 56 } | 55 } |
| 57 | 56 |
| 58 double x; | 57 double x; |
| 59 double y; | 58 double y; |
| 60 double z; | 59 double z; |
| 61 double w; | 60 double w; |
| 62 }; | 61 }; |
| 63 | 62 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 // assumed to be normalized. | 98 // assumed to be normalized. |
| 100 static float smallestAngleBetweenVectors(const FloatSize&, const FloatSize&)
; | 99 static float smallestAngleBetweenVectors(const FloatSize&, const FloatSize&)
; |
| 101 | 100 |
| 102 // Projects the |source| vector onto |destination|. Neither vector is assume
d to be normalized. | 101 // Projects the |source| vector onto |destination|. Neither vector is assume
d to be normalized. |
| 103 static FloatSize projectVector(const FloatSize& source, const FloatSize& des
tination); | 102 static FloatSize projectVector(const FloatSize& source, const FloatSize& des
tination); |
| 104 }; | 103 }; |
| 105 | 104 |
| 106 } // namespace cc | 105 } // namespace cc |
| 107 | 106 |
| 108 #endif // #define CCMathUtil_h | 107 #endif // #define CCMathUtil_h |
| OLD | NEW |