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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 | 81 |
82 private: | 82 private: |
83 LinearTimingFunction() | 83 LinearTimingFunction() |
84 : TimingFunction(LinearFunction) | 84 : TimingFunction(LinearFunction) |
85 { | 85 { |
86 } | 86 } |
87 }; | 87 }; |
88 | 88 |
89 | 89 |
90 // Forward declare so we can friend it below. Don't use in production code! | 90 // Forward declare so we can friend it below. Don't use in production code! |
91 class ChainedTimingFunctionPrinter; | 91 class ChainedTimingFunctionTestHelper; |
92 | 92 |
93 class CubicBezierTimingFunction : public TimingFunction { | 93 class CubicBezierTimingFunction : public TimingFunction { |
94 public: | 94 public: |
95 enum SubType { | 95 enum SubType { |
96 Ease, | 96 Ease, |
97 EaseIn, | 97 EaseIn, |
98 EaseOut, | 98 EaseOut, |
99 EaseInOut, | 99 EaseInOut, |
100 Custom | 100 Custom |
101 }; | 101 }; |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 return segment->evaluate(fraction, accuracy); | 258 return segment->evaluate(fraction, accuracy); |
259 } | 259 } |
260 | 260 |
261 private: | 261 private: |
262 class Segment { | 262 class Segment { |
263 public: | 263 public: |
264 Segment(double min, double max, TimingFunction* timingFunction) | 264 Segment(double min, double max, TimingFunction* timingFunction) |
265 : m_min(min) | 265 : m_min(min) |
266 , m_max(max) | 266 , m_max(max) |
267 , m_timingFunction(timingFunction) | 267 , m_timingFunction(timingFunction) |
268 { } | 268 { ASSERT(timingFunction); } |
269 | 269 |
270 double max() const { return m_max; } | 270 double max() const { return m_max; } |
271 double evaluate(double fraction, double accuracy) const | 271 double evaluate(double fraction, double accuracy) const |
272 { | 272 { |
273 return scaleFromLocal(m_timingFunction->evaluate(scaleToLocal(fracti
on), accuracy)); | 273 return scaleFromLocal(m_timingFunction->evaluate(scaleToLocal(fracti
on), accuracy)); |
274 } | 274 } |
275 | 275 |
276 private: | 276 private: |
277 double scaleToLocal(double x) const { return (x - m_min) / (m_max - m_mi
n); } | 277 double scaleToLocal(double x) const { return (x - m_min) / (m_max - m_mi
n); } |
278 double scaleFromLocal(double x) const { return blend(m_min, m_max, x); } | 278 double scaleFromLocal(double x) const { return blend(m_min, m_max, x); } |
279 | 279 |
280 double m_min; | 280 double m_min; |
281 double m_max; | 281 double m_max; |
282 RefPtr<TimingFunction> m_timingFunction; | 282 RefPtr<TimingFunction> m_timingFunction; |
283 | 283 |
284 // Allow printing of our segments. Can be removed once | 284 // Allow PrintTo/operator== of the segments. Can be removed once |
285 // ChainedTimingFunction has a public API for segments. | 285 // ChainedTimingFunction has a public API for segments. |
286 friend class ChainedTimingFunctionPrinter; | 286 friend class ChainedTimingFunctionTestHelper; |
287 }; | 287 }; |
288 | 288 |
289 ChainedTimingFunction() | 289 ChainedTimingFunction() |
290 : TimingFunction(ChainedFunction) | 290 : TimingFunction(ChainedFunction) |
291 { | 291 { |
292 ASSERT(RuntimeEnabledFeatures::webAnimationsEnabled()); | 292 ASSERT(RuntimeEnabledFeatures::webAnimationsEnabled()); |
293 } | 293 } |
294 | 294 |
295 Vector<Segment> m_segments; | 295 Vector<Segment> m_segments; |
296 | 296 |
297 // Allow printing of our segments. Can be removed once | 297 // Allow PrintTo/operator== of the segments. Can be removed once |
298 // ChainedTimingFunction has a public API for segments. | 298 // ChainedTimingFunction has a public API for segments. |
299 friend class ChainedTimingFunctionPrinter; | 299 friend class ChainedTimingFunctionTestHelper; |
300 }; | 300 }; |
301 | 301 |
302 } // namespace WebCore | 302 } // namespace WebCore |
303 | 303 |
304 #endif // TimingFunction_h | 304 #endif // TimingFunction_h |
OLD | NEW |