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 "FloatPoint.h" | 8 #include "FloatPoint.h" |
9 #include "FloatPoint3D.h" | 9 #include "FloatPoint3D.h" |
10 | 10 |
11 namespace WebKit { | 11 namespace WebKit { |
12 class WebTransformationMatrix; | 12 class WebTransformationMatrix; |
13 } | 13 } |
14 | 14 |
15 namespace WebCore { | 15 namespace cc { |
16 | 16 |
17 class IntRect; | 17 class IntRect; |
18 class FloatRect; | 18 class FloatRect; |
19 class FloatQuad; | 19 class FloatQuad; |
20 | 20 |
21 struct HomogeneousCoordinate { | 21 struct HomogeneousCoordinate { |
22 HomogeneousCoordinate(double newX, double newY, double newZ, double newW) | 22 HomogeneousCoordinate(double newX, double newY, double newZ, double newW) |
23 : x(newX) | 23 : x(newX) |
24 , y(newY) | 24 , y(newY) |
25 , z(newZ) | 25 , z(newZ) |
(...skipping 27 matching lines...) Expand all Loading... |
53 double invW = 1.0 / w; | 53 double invW = 1.0 / w; |
54 return FloatPoint3D(x * invW, y * invW, z * invW); | 54 return FloatPoint3D(x * invW, y * invW, z * invW); |
55 } | 55 } |
56 | 56 |
57 double x; | 57 double x; |
58 double y; | 58 double y; |
59 double z; | 59 double z; |
60 double w; | 60 double w; |
61 }; | 61 }; |
62 | 62 |
63 // This class contains math helper functionality that does not belong in WebCore
. | |
64 // It is possible that this functionality should be migrated to WebCore eventual
ly. | |
65 class CCMathUtil { | 63 class CCMathUtil { |
66 public: | 64 public: |
67 | 65 |
68 // Background: WebTransformationMatrix code in WebCore does not do the right
thing in | 66 // Background: WebTransformationMatrix code in WebCore does not do the right
thing in |
69 // mapRect / mapQuad / projectQuad when there is a perspective projection th
at causes | 67 // mapRect / mapQuad / projectQuad when there is a perspective projection th
at causes |
70 // one of the transformed vertices to go to w < 0. In those cases, it is nec
essary to | 68 // one of the transformed vertices to go to w < 0. In those cases, it is nec
essary to |
71 // perform clipping in homogeneous coordinates, after applying the transform
, before | 69 // perform clipping in homogeneous coordinates, after applying the transform
, before |
72 // dividing-by-w to convert to cartesian coordinates. | 70 // dividing-by-w to convert to cartesian coordinates. |
73 // | 71 // |
74 // These functions return the axis-aligned rect that encloses the correctly
clipped, | 72 // These functions return the axis-aligned rect that encloses the correctly
clipped, |
(...skipping 22 matching lines...) Expand all Loading... |
97 static void flattenTransformTo2d(WebKit::WebTransformationMatrix&); | 95 static void flattenTransformTo2d(WebKit::WebTransformationMatrix&); |
98 | 96 |
99 // Returns the smallest angle between the given two vectors in degrees. Neit
her vector is | 97 // Returns the smallest angle between the given two vectors in degrees. Neit
her vector is |
100 // assumed to be normalized. | 98 // assumed to be normalized. |
101 static float smallestAngleBetweenVectors(const FloatSize&, const FloatSize&)
; | 99 static float smallestAngleBetweenVectors(const FloatSize&, const FloatSize&)
; |
102 | 100 |
103 // 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. |
104 static FloatSize projectVector(const FloatSize& source, const FloatSize& des
tination); | 102 static FloatSize projectVector(const FloatSize& source, const FloatSize& des
tination); |
105 }; | 103 }; |
106 | 104 |
107 } // namespace WebCore | 105 } // namespace cc |
108 | 106 |
109 #endif // #define CCMathUtil_h | 107 #endif // #define CCMathUtil_h |
OLD | NEW |