OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 } | 254 } |
255 | 255 |
256 // ----------------------------------------------------------------------- | 256 // ----------------------------------------------------------------------- |
257 // CompositorAnimationsImpl | 257 // CompositorAnimationsImpl |
258 // ----------------------------------------------------------------------- | 258 // ----------------------------------------------------------------------- |
259 | 259 |
260 bool CompositorAnimationsImpl::convertTimingForCompositor(const Timing& timing,
double timeOffset, CompositorTiming& out, double playerPlaybackRate) | 260 bool CompositorAnimationsImpl::convertTimingForCompositor(const Timing& timing,
double timeOffset, CompositorTiming& out, double playerPlaybackRate) |
261 { | 261 { |
262 timing.assertValid(); | 262 timing.assertValid(); |
263 | 263 |
264 // All fill modes are supported (the calling code handles them). | 264 if (!timing.iterationCount || !timing.iterationDuration) |
265 | |
266 if (timing.iterationCount <= 0) | |
267 return false; | 265 return false; |
268 | 266 |
269 if (std::isnan(timing.iterationDuration) || !timing.iterationDuration) | |
270 return false; | |
271 | |
272 // All directions are supported. | |
273 | |
274 // Now attempt an actual conversion | |
275 out.scaledDuration = timing.iterationDuration; | |
276 ASSERT(out.scaledDuration > 0); | |
277 | |
278 double scaledStartDelay = timing.startDelay; | |
279 if (scaledStartDelay > 0 && scaledStartDelay > out.scaledDuration * timing.i
terationCount) | |
280 return false; | |
281 | |
282 out.direction = timing.direction; | |
283 | |
284 if (!std::isfinite(timing.iterationCount)) { | 267 if (!std::isfinite(timing.iterationCount)) { |
285 out.adjustedIterationCount = -1; | 268 out.adjustedIterationCount = -1; |
286 } else { | 269 } else { |
287 out.adjustedIterationCount = timing.iterationCount; | 270 out.adjustedIterationCount = timing.iterationCount; |
288 ASSERT(out.adjustedIterationCount > 0); | |
289 } | 271 } |
290 | 272 |
| 273 out.scaledDuration = timing.iterationDuration; |
| 274 out.direction = timing.direction; |
291 // Compositor's time offset is positive for seeking into the animation. | 275 // Compositor's time offset is positive for seeking into the animation. |
292 out.scaledTimeOffset = -scaledStartDelay + timeOffset; | 276 out.scaledTimeOffset = -timing.startDelay + timeOffset; |
293 out.playbackRate = timing.playbackRate * playerPlaybackRate; | 277 out.playbackRate = timing.playbackRate * playerPlaybackRate; |
294 out.fillMode = timing.fillMode == Timing::FillModeAuto ? Timing::FillModeNon
e : timing.fillMode; | 278 out.fillMode = timing.fillMode == Timing::FillModeAuto ? Timing::FillModeNon
e : timing.fillMode; |
295 out.iterationStart = timing.iterationStart; | 279 out.iterationStart = timing.iterationStart; |
296 | 280 out.assertValid(); |
297 return true; | 281 return true; |
298 } | 282 } |
299 | 283 |
300 namespace { | 284 namespace { |
301 | 285 |
302 template<typename PlatformAnimationCurveType, typename PlatformAnimationKeyframe
Type> | 286 template<typename PlatformAnimationCurveType, typename PlatformAnimationKeyframe
Type> |
303 void addKeyframeWithTimingFunction(PlatformAnimationCurveType& curve, const Plat
formAnimationKeyframeType& keyframe, const TimingFunction* timingFunction) | 287 void addKeyframeWithTimingFunction(PlatformAnimationCurveType& curve, const Plat
formAnimationKeyframeType& keyframe, const TimingFunction* timingFunction) |
304 { | 288 { |
305 if (!timingFunction) { | 289 if (!timingFunction) { |
306 curve.add(keyframe); | 290 curve.add(keyframe); |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
490 break; | 474 break; |
491 default: | 475 default: |
492 ASSERT_NOT_REACHED(); | 476 ASSERT_NOT_REACHED(); |
493 } | 477 } |
494 animations.append(animation.release()); | 478 animations.append(animation.release()); |
495 } | 479 } |
496 ASSERT(!animations.isEmpty()); | 480 ASSERT(!animations.isEmpty()); |
497 } | 481 } |
498 | 482 |
499 } // namespace blink | 483 } // namespace blink |
OLD | NEW |