OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 1999 Antti Koivisto (koivisto@kde.org) | 2 * Copyright (C) 1999 Antti Koivisto (koivisto@kde.org) |
3 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. | 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. |
4 * | 4 * |
5 * This library is free software; you can redistribute it and/or | 5 * This library is free software; you can redistribute it and/or |
6 * modify it under the terms of the GNU Library General Public | 6 * modify it under the terms of the GNU Library General Public |
7 * License as published by the Free Software Foundation; either | 7 * License as published by the Free Software Foundation; either |
8 * version 2 of the License, or (at your option) any later version. | 8 * version 2 of the License, or (at your option) any later version. |
9 * | 9 * |
10 * This library is distributed in the hope that it will be useful, | 10 * This library is distributed in the hope that it will be useful, |
(...skipping 11 matching lines...) Expand all Loading... |
22 #include "config.h" | 22 #include "config.h" |
23 #include "platform/transforms/RotateTransformOperation.h" | 23 #include "platform/transforms/RotateTransformOperation.h" |
24 | 24 |
25 #include "platform/animation/AnimationUtilities.h" | 25 #include "platform/animation/AnimationUtilities.h" |
26 #include "platform/geometry/FloatPoint3D.h" | 26 #include "platform/geometry/FloatPoint3D.h" |
27 #include "wtf/MathExtras.h" | 27 #include "wtf/MathExtras.h" |
28 #include <algorithm> | 28 #include <algorithm> |
29 | 29 |
30 using namespace std; | 30 using namespace std; |
31 | 31 |
32 namespace WebCore { | 32 namespace blink { |
33 | 33 |
34 static const double angleEpsilon = 1e-4; | 34 static const double angleEpsilon = 1e-4; |
35 | 35 |
36 FloatPoint3D RotateTransformOperation::axis() const | 36 FloatPoint3D RotateTransformOperation::axis() const |
37 { | 37 { |
38 return FloatPoint3D(x(), y(), z()); | 38 return FloatPoint3D(x(), y(), z()); |
39 } | 39 } |
40 | 40 |
41 bool RotateTransformOperation::shareSameAxis(const RotateTransformOperation* fro
m, const RotateTransformOperation* to, FloatPoint3D* axis, double* fromAngle, do
uble* toAngle) | 41 bool RotateTransformOperation::shareSameAxis(const RotateTransformOperation* fro
m, const RotateTransformOperation* to, FloatPoint3D* axis, double* fromAngle, do
uble* toAngle) |
42 { | 42 { |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 const RotateTransformOperation* fromOp = static_cast<const RotateTransformOp
eration*>(from); | 93 const RotateTransformOperation* fromOp = static_cast<const RotateTransformOp
eration*>(from); |
94 | 94 |
95 // Optimize for single axis rotation | 95 // Optimize for single axis rotation |
96 if (!fromOp || (fromOp->m_x == 0 && fromOp->m_y == 0 && fromOp->m_z == 1) || | 96 if (!fromOp || (fromOp->m_x == 0 && fromOp->m_y == 0 && fromOp->m_z == 1) || |
97 (fromOp->m_x == 0 && fromOp->m_y == 1 && fromOp->m_z == 0) || | 97 (fromOp->m_x == 0 && fromOp->m_y == 1 && fromOp->m_z == 0) || |
98 (fromOp->m_x == 1 && fromOp->m_y == 0 && fromOp->m_z == 0)) { | 98 (fromOp->m_x == 1 && fromOp->m_y == 0 && fromOp->m_z == 0)) { |
99 double fromAngle = fromOp ? fromOp->m_angle : 0; | 99 double fromAngle = fromOp ? fromOp->m_angle : 0; |
100 return RotateTransformOperation::create(fromOp ? fromOp->m_x : m_x, | 100 return RotateTransformOperation::create(fromOp ? fromOp->m_x : m_x, |
101 fromOp ? fromOp->m_y : m_y, | 101 fromOp ? fromOp->m_y : m_y, |
102 fromOp ? fromOp->m_z : m_z, | 102 fromOp ? fromOp->m_z : m_z, |
103 WebCore::blend(fromAngle, m_angl
e, progress), m_type); | 103 blink::blend(fromAngle, m_angle,
progress), m_type); |
104 } | 104 } |
105 double fromAngle; | 105 double fromAngle; |
106 double toAngle; | 106 double toAngle; |
107 FloatPoint3D axis; | 107 FloatPoint3D axis; |
108 | 108 |
109 if (shareSameAxis(fromOp, this, &axis, &fromAngle, &toAngle)) | 109 if (shareSameAxis(fromOp, this, &axis, &fromAngle, &toAngle)) |
110 return RotateTransformOperation::create(axis.x(), axis.y(), axis.z(), We
bCore::blend(fromAngle, toAngle, progress), m_type); | 110 return RotateTransformOperation::create(axis.x(), axis.y(), axis.z(), bl
ink::blend(fromAngle, toAngle, progress), m_type); |
111 | 111 |
112 const RotateTransformOperation* toOp = this; | 112 const RotateTransformOperation* toOp = this; |
113 | 113 |
114 // Create the 2 rotation matrices | 114 // Create the 2 rotation matrices |
115 TransformationMatrix fromT; | 115 TransformationMatrix fromT; |
116 TransformationMatrix toT; | 116 TransformationMatrix toT; |
117 fromT.rotate3d((fromOp ? fromOp->m_x : 0), | 117 fromT.rotate3d((fromOp ? fromOp->m_x : 0), |
118 (fromOp ? fromOp->m_y : 0), | 118 (fromOp ? fromOp->m_y : 0), |
119 (fromOp ? fromOp->m_z : 1), | 119 (fromOp ? fromOp->m_z : 1), |
120 (fromOp ? fromOp->m_angle : 0)); | 120 (fromOp ? fromOp->m_angle : 0)); |
(...skipping 28 matching lines...) Expand all Loading... |
149 z = 1; | 149 z = 1; |
150 } | 150 } |
151 return RotateTransformOperation::create(x, y, z, angle, Rotate3D); | 151 return RotateTransformOperation::create(x, y, z, angle, Rotate3D); |
152 } | 152 } |
153 | 153 |
154 bool RotateTransformOperation::canBlendWith(const TransformOperation& other) con
st | 154 bool RotateTransformOperation::canBlendWith(const TransformOperation& other) con
st |
155 { | 155 { |
156 return other.isSameType(*this); | 156 return other.isSameType(*this); |
157 } | 157 } |
158 | 158 |
159 } // namespace WebCore | 159 } // namespace blink |
OLD | NEW |