OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2000 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 2000 Lars Knoll (knoll@kde.org) |
3 * (C) 2000 Antti Koivisto (koivisto@kde.org) | 3 * (C) 2000 Antti Koivisto (koivisto@kde.org) |
4 * (C) 2000 Dirk Mueller (mueller@kde.org) | 4 * (C) 2000 Dirk Mueller (mueller@kde.org) |
5 * Copyright (C) 2003, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. | 5 * Copyright (C) 2003, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. |
6 * Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com) | 6 * Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com) |
7 * | 7 * |
8 * This library is free software; you can redistribute it and/or | 8 * This library is free software; you can redistribute it and/or |
9 * modify it under the terms of the GNU Library General Public | 9 * modify it under the terms of the GNU Library General Public |
10 * License as published by the Free Software Foundation; either | 10 * License as published by the Free Software Foundation; either |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 public: | 68 public: |
69 static PassRefPtr<LinearTimingFunction> create() | 69 static PassRefPtr<LinearTimingFunction> create() |
70 { | 70 { |
71 return adoptRef(new LinearTimingFunction); | 71 return adoptRef(new LinearTimingFunction); |
72 } | 72 } |
73 | 73 |
74 ~LinearTimingFunction() { } | 74 ~LinearTimingFunction() { } |
75 | 75 |
76 virtual double evaluate(double fraction, double) const | 76 virtual double evaluate(double fraction, double) const |
77 { | 77 { |
78 ASSERT(RuntimeEnabledFeatures::webAnimationsEnabled() || (fraction >= 0
&& fraction <= 1)); | 78 ASSERT(RuntimeEnabledFeatures::webAnimationsCSSEnabled() || (fraction >=
0 && fraction <= 1)); |
79 ASSERT_WITH_MESSAGE(!RuntimeEnabledFeatures::webAnimationsEnabled() || (
fraction >= 0 && fraction <= 1), "Web Animations not yet implemented: Timing fun
ction behavior outside the range [0, 1] is not yet specified"); | 79 ASSERT_WITH_MESSAGE(!RuntimeEnabledFeatures::webAnimationsCSSEnabled() |
| (fraction >= 0 && fraction <= 1), "Web Animations not yet implemented: Timing
function behavior outside the range [0, 1] is not yet specified"); |
80 return fraction; | 80 return fraction; |
81 } | 81 } |
82 | 82 |
83 private: | 83 private: |
84 LinearTimingFunction() | 84 LinearTimingFunction() |
85 : TimingFunction(LinearFunction) | 85 : TimingFunction(LinearFunction) |
86 { | 86 { |
87 } | 87 } |
88 }; | 88 }; |
89 | 89 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 default: | 132 default: |
133 ASSERT_NOT_REACHED(); | 133 ASSERT_NOT_REACHED(); |
134 return 0; | 134 return 0; |
135 } | 135 } |
136 } | 136 } |
137 | 137 |
138 ~CubicBezierTimingFunction() { } | 138 ~CubicBezierTimingFunction() { } |
139 | 139 |
140 virtual double evaluate(double fraction, double accuracy) const | 140 virtual double evaluate(double fraction, double accuracy) const |
141 { | 141 { |
142 ASSERT(RuntimeEnabledFeatures::webAnimationsEnabled() || (fraction >= 0
&& fraction <= 1)); | 142 ASSERT(RuntimeEnabledFeatures::webAnimationsCSSEnabled() || (fraction >=
0 && fraction <= 1)); |
143 ASSERT_WITH_MESSAGE(!RuntimeEnabledFeatures::webAnimationsEnabled() || (
fraction >= 0 && fraction <= 1), "Web Animations not yet implemented: Timing fun
ction behavior outside the range [0, 1] is not yet specified"); | 143 ASSERT_WITH_MESSAGE(!RuntimeEnabledFeatures::webAnimationsCSSEnabled() |
| (fraction >= 0 && fraction <= 1), "Web Animations not yet implemented: Timing
function behavior outside the range [0, 1] is not yet specified"); |
144 if (!m_bezier) | 144 if (!m_bezier) |
145 m_bezier = adoptPtr(new UnitBezier(m_x1, m_y1, m_x2, m_y2)); | 145 m_bezier = adoptPtr(new UnitBezier(m_x1, m_y1, m_x2, m_y2)); |
146 return m_bezier->solve(fraction, accuracy); | 146 return m_bezier->solve(fraction, accuracy); |
147 } | 147 } |
148 | 148 |
149 double x1() const { return m_x1; } | 149 double x1() const { return m_x1; } |
150 double y1() const { return m_y1; } | 150 double y1() const { return m_y1; } |
151 double x2() const { return m_x2; } | 151 double x2() const { return m_x2; } |
152 double y2() const { return m_y2; } | 152 double y2() const { return m_y2; } |
153 | 153 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 ASSERT_NOT_REACHED(); | 202 ASSERT_NOT_REACHED(); |
203 return 0; | 203 return 0; |
204 } | 204 } |
205 } | 205 } |
206 | 206 |
207 | 207 |
208 ~StepsTimingFunction() { } | 208 ~StepsTimingFunction() { } |
209 | 209 |
210 virtual double evaluate(double fraction, double) const | 210 virtual double evaluate(double fraction, double) const |
211 { | 211 { |
212 ASSERT(RuntimeEnabledFeatures::webAnimationsEnabled() || (fraction >= 0
&& fraction <= 1)); | 212 ASSERT(RuntimeEnabledFeatures::webAnimationsCSSEnabled() || (fraction >=
0 && fraction <= 1)); |
213 ASSERT_WITH_MESSAGE(!RuntimeEnabledFeatures::webAnimationsEnabled() || (
fraction >= 0 && fraction <= 1), "Web Animations not yet implemented: Timing fun
ction behavior outside the range [0, 1] is not yet specified"); | 213 ASSERT_WITH_MESSAGE(!RuntimeEnabledFeatures::webAnimationsCSSEnabled() |
| (fraction >= 0 && fraction <= 1), "Web Animations not yet implemented: Timing
function behavior outside the range [0, 1] is not yet specified"); |
214 return std::min(1.0, (floor(m_steps * fraction) + m_stepAtStart) / m_ste
ps); | 214 return std::min(1.0, (floor(m_steps * fraction) + m_stepAtStart) / m_ste
ps); |
215 } | 215 } |
216 | 216 |
217 int numberOfSteps() const { return m_steps; } | 217 int numberOfSteps() const { return m_steps; } |
218 bool stepAtStart() const { return m_stepAtStart; } | 218 bool stepAtStart() const { return m_stepAtStart; } |
219 | 219 |
220 SubType subType() const { return m_subType; } | 220 SubType subType() const { return m_subType; } |
221 | 221 |
222 private: | 222 private: |
223 StepsTimingFunction(SubType subType, int steps, bool stepAtStart) | 223 StepsTimingFunction(SubType subType, int steps, bool stepAtStart) |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 friend class CompositorAnimationsTimingFunctionReverser; | 289 friend class CompositorAnimationsTimingFunctionReverser; |
290 | 290 |
291 // Allow PrintTo/operator== of the segments. Can be removed once | 291 // Allow PrintTo/operator== of the segments. Can be removed once |
292 // ChainedTimingFunction has a public API for segments. | 292 // ChainedTimingFunction has a public API for segments. |
293 friend class ChainedTimingFunctionTestHelper; | 293 friend class ChainedTimingFunctionTestHelper; |
294 }; | 294 }; |
295 | 295 |
296 ChainedTimingFunction() | 296 ChainedTimingFunction() |
297 : TimingFunction(ChainedFunction) | 297 : TimingFunction(ChainedFunction) |
298 { | 298 { |
299 ASSERT(RuntimeEnabledFeatures::webAnimationsEnabled()); | 299 ASSERT(RuntimeEnabledFeatures::webAnimationsCSSEnabled()); |
300 } | 300 } |
301 | 301 |
302 Vector<Segment> m_segments; | 302 Vector<Segment> m_segments; |
303 | 303 |
304 // FIXME: Come up with a public API for the segments and remove this. | 304 // FIXME: Come up with a public API for the segments and remove this. |
305 friend class CompositorAnimationsImpl; | 305 friend class CompositorAnimationsImpl; |
306 | 306 |
307 // Allow the compositor to reverse the timing function. | 307 // Allow the compositor to reverse the timing function. |
308 friend class CompositorAnimationsTimingFunctionReverser; | 308 friend class CompositorAnimationsTimingFunctionReverser; |
309 | 309 |
310 // Allow PrintTo/operator== of the segments. Can be removed once | 310 // Allow PrintTo/operator== of the segments. Can be removed once |
311 // ChainedTimingFunction has a public API for segments. | 311 // ChainedTimingFunction has a public API for segments. |
312 friend class ChainedTimingFunctionTestHelper; | 312 friend class ChainedTimingFunctionTestHelper; |
313 }; | 313 }; |
314 | 314 |
315 #define DEFINE_TIMING_FUNCTION_TYPE_CASTS(typeName) \ | 315 #define DEFINE_TIMING_FUNCTION_TYPE_CASTS(typeName) \ |
316 DEFINE_TYPE_CASTS( \ | 316 DEFINE_TYPE_CASTS( \ |
317 typeName##TimingFunction, TimingFunction, value, \ | 317 typeName##TimingFunction, TimingFunction, value, \ |
318 value->type() == TimingFunction::typeName##Function, \ | 318 value->type() == TimingFunction::typeName##Function, \ |
319 value.type() == TimingFunction::typeName##Function) | 319 value.type() == TimingFunction::typeName##Function) |
320 | 320 |
321 DEFINE_TIMING_FUNCTION_TYPE_CASTS(Linear); | 321 DEFINE_TIMING_FUNCTION_TYPE_CASTS(Linear); |
322 DEFINE_TIMING_FUNCTION_TYPE_CASTS(CubicBezier); | 322 DEFINE_TIMING_FUNCTION_TYPE_CASTS(CubicBezier); |
323 DEFINE_TIMING_FUNCTION_TYPE_CASTS(Steps); | 323 DEFINE_TIMING_FUNCTION_TYPE_CASTS(Steps); |
324 DEFINE_TIMING_FUNCTION_TYPE_CASTS(Chained); | 324 DEFINE_TIMING_FUNCTION_TYPE_CASTS(Chained); |
325 | 325 |
326 } // namespace WebCore | 326 } // namespace WebCore |
327 | 327 |
328 #endif // TimingFunction_h | 328 #endif // TimingFunction_h |
OLD | NEW |