| 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 CC_MATH_UTIL_H_ | 5 #ifndef CC_MATH_UTIL_H_ |
| 6 #define CC_MATH_UTIL_H_ | 6 #define CC_MATH_UTIL_H_ |
| 7 | 7 |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "cc/cc_export.h" | 9 #include "cc/cc_export.h" |
| 10 #include "ui/gfx/point_f.h" | 10 #include "ui/gfx/point_f.h" |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 } | 60 } |
| 61 | 61 |
| 62 double x; | 62 double x; |
| 63 double y; | 63 double y; |
| 64 double z; | 64 double z; |
| 65 double w; | 65 double w; |
| 66 }; | 66 }; |
| 67 | 67 |
| 68 class CC_EXPORT MathUtil { | 68 class CC_EXPORT MathUtil { |
| 69 public: | 69 public: |
| 70 static const double PI_DOUBLE; |
| 71 static const float PI_FLOAT; |
| 72 |
| 73 static double Deg2Rad(double deg) { return deg * PI_DOUBLE / 180; } |
| 74 static double Rad2Deg(double rad) { return rad * 180 / PI_DOUBLE; } |
| 75 |
| 76 static float Deg2Rad(float deg) { return deg * PI_FLOAT / 180; } |
| 77 static float Rad2Deg(float rad) { return rad * 180 / PI_FLOAT; } |
| 70 | 78 |
| 71 // Background: WebTransformationMatrix code in WebCore does not do the right
thing in | 79 // Background: WebTransformationMatrix code in WebCore does not do the right
thing in |
| 72 // mapRect / mapQuad / projectQuad when there is a perspective projection th
at causes | 80 // mapRect / mapQuad / projectQuad when there is a perspective projection th
at causes |
| 73 // one of the transformed vertices to go to w < 0. In those cases, it is nec
essary to | 81 // one of the transformed vertices to go to w < 0. In those cases, it is nec
essary to |
| 74 // perform clipping in homogeneous coordinates, after applying the transform
, before | 82 // perform clipping in homogeneous coordinates, after applying the transform
, before |
| 75 // dividing-by-w to convert to cartesian coordinates. | 83 // dividing-by-w to convert to cartesian coordinates. |
| 76 // | 84 // |
| 77 // These functions return the axis-aligned rect that encloses the correctly
clipped, | 85 // These functions return the axis-aligned rect that encloses the correctly
clipped, |
| 78 // transformed polygon. | 86 // transformed polygon. |
| 79 static gfx::Rect mapClippedRect(const WebKit::WebTransformationMatrix&, cons
t gfx::Rect&); | 87 static gfx::Rect mapClippedRect(const WebKit::WebTransformationMatrix&, cons
t gfx::Rect&); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 105 // assumed to be normalized. | 113 // assumed to be normalized. |
| 106 static float smallestAngleBetweenVectors(gfx::Vector2dF, gfx::Vector2dF); | 114 static float smallestAngleBetweenVectors(gfx::Vector2dF, gfx::Vector2dF); |
| 107 | 115 |
| 108 // Projects the |source| vector onto |destination|. Neither vector is assume
d to be normalized. | 116 // Projects the |source| vector onto |destination|. Neither vector is assume
d to be normalized. |
| 109 static gfx::Vector2dF projectVector(gfx::Vector2dF source, gfx::Vector2dF de
stination); | 117 static gfx::Vector2dF projectVector(gfx::Vector2dF source, gfx::Vector2dF de
stination); |
| 110 }; | 118 }; |
| 111 | 119 |
| 112 } // namespace cc | 120 } // namespace cc |
| 113 | 121 |
| 114 #endif // CC_MATH_UTIL_H_ | 122 #endif // CC_MATH_UTIL_H_ |
| OLD | NEW |