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 25 matching lines...) Expand all Loading... |
36 #include "core/animation/ElementAnimations.h" | 36 #include "core/animation/ElementAnimations.h" |
37 #include "core/animation/CompositorAnimationsImpl.h" | 37 #include "core/animation/CompositorAnimationsImpl.h" |
38 #include "core/animation/animatable/AnimatableDouble.h" | 38 #include "core/animation/animatable/AnimatableDouble.h" |
39 #include "core/animation/animatable/AnimatableFilterOperations.h" | 39 #include "core/animation/animatable/AnimatableFilterOperations.h" |
40 #include "core/animation/animatable/AnimatableTransform.h" | 40 #include "core/animation/animatable/AnimatableTransform.h" |
41 #include "core/animation/animatable/AnimatableValue.h" | 41 #include "core/animation/animatable/AnimatableValue.h" |
42 #include "core/layout/Layer.h" | 42 #include "core/layout/Layer.h" |
43 #include "core/layout/LayoutBoxModelObject.h" | 43 #include "core/layout/LayoutBoxModelObject.h" |
44 #include "core/layout/LayoutObject.h" | 44 #include "core/layout/LayoutObject.h" |
45 #include "core/layout/compositing/CompositedLayerMapping.h" | 45 #include "core/layout/compositing/CompositedLayerMapping.h" |
| 46 #include "platform/RuntimeEnabledFeatures.h" |
46 #include "platform/geometry/FloatBox.h" | 47 #include "platform/geometry/FloatBox.h" |
47 #include "public/platform/Platform.h" | 48 #include "public/platform/Platform.h" |
48 #include "public/platform/WebCompositorAnimation.h" | 49 #include "public/platform/WebCompositorAnimation.h" |
| 50 #include "public/platform/WebCompositorAnimationPlayer.h" |
49 #include "public/platform/WebCompositorSupport.h" | 51 #include "public/platform/WebCompositorSupport.h" |
50 #include "public/platform/WebFilterAnimationCurve.h" | 52 #include "public/platform/WebFilterAnimationCurve.h" |
51 #include "public/platform/WebFilterKeyframe.h" | 53 #include "public/platform/WebFilterKeyframe.h" |
52 #include "public/platform/WebFloatAnimationCurve.h" | 54 #include "public/platform/WebFloatAnimationCurve.h" |
53 #include "public/platform/WebFloatKeyframe.h" | 55 #include "public/platform/WebFloatKeyframe.h" |
54 #include "public/platform/WebTransformAnimationCurve.h" | 56 #include "public/platform/WebTransformAnimationCurve.h" |
55 #include "public/platform/WebTransformKeyframe.h" | 57 #include "public/platform/WebTransformKeyframe.h" |
56 | 58 |
57 #include <algorithm> | 59 #include <algorithm> |
58 #include <cmath> | 60 #include <cmath> |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 const KeyframeEffectModelBase& keyframeEffect = toKeyframeEffectModelBase(ef
fect); | 271 const KeyframeEffectModelBase& keyframeEffect = toKeyframeEffectModelBase(ef
fect); |
270 | 272 |
271 Layer* layer = toLayoutBoxModelObject(element.layoutObject())->layer(); | 273 Layer* layer = toLayoutBoxModelObject(element.layoutObject())->layer(); |
272 ASSERT(layer); | 274 ASSERT(layer); |
273 | 275 |
274 Vector<OwnPtr<WebCompositorAnimation>> animations; | 276 Vector<OwnPtr<WebCompositorAnimation>> animations; |
275 CompositorAnimationsImpl::getAnimationOnCompositor(timing, group, startTime,
timeOffset, keyframeEffect, animations, playerPlaybackRate); | 277 CompositorAnimationsImpl::getAnimationOnCompositor(timing, group, startTime,
timeOffset, keyframeEffect, animations, playerPlaybackRate); |
276 ASSERT(!animations.isEmpty()); | 278 ASSERT(!animations.isEmpty()); |
277 for (auto& animation : animations) { | 279 for (auto& animation : animations) { |
278 int id = animation->id(); | 280 int id = animation->id(); |
279 if (!layer->compositedLayerMapping()->mainGraphicsLayer()->addAnimation(
animation.release())) { | 281 if (RuntimeEnabledFeatures::compositorAnimationTimelinesEnabled()) { |
| 282 ASSERT(player); |
| 283 WebCompositorAnimationPlayer* compositorPlayer = player->compositorP
layer(); |
| 284 ASSERT(compositorPlayer); |
| 285 compositorPlayer->attachLayer(layer->compositedLayerMapping()->mainG
raphicsLayer()->platformLayer()); |
| 286 compositorPlayer->addAnimation(animation.leakPtr()); |
| 287 } else if (!layer->compositedLayerMapping()->mainGraphicsLayer()->addAni
mation(animation.release())) { |
280 // FIXME: We should know ahead of time whether these animations can
be started. | 288 // FIXME: We should know ahead of time whether these animations can
be started. |
281 for (int startedAnimationId : startedAnimationIds) | 289 for (int startedAnimationId : startedAnimationIds) |
282 cancelAnimationOnCompositor(element, startedAnimationId); | 290 cancelAnimationOnCompositor(element, player, startedAnimationId)
; |
283 startedAnimationIds.clear(); | 291 startedAnimationIds.clear(); |
284 return false; | 292 return false; |
285 } | 293 } |
286 startedAnimationIds.append(id); | 294 startedAnimationIds.append(id); |
287 } | 295 } |
288 ASSERT(!startedAnimationIds.isEmpty()); | 296 ASSERT(!startedAnimationIds.isEmpty()); |
289 return true; | 297 return true; |
290 } | 298 } |
291 | 299 |
292 void CompositorAnimations::cancelAnimationOnCompositor(const Element& element, i
nt id) | 300 void CompositorAnimations::cancelAnimationOnCompositor(const Element& element, c
onst AnimationPlayer* player, int id) |
293 { | 301 { |
294 if (!canStartAnimationOnCompositor(element)) { | 302 if (!canStartAnimationOnCompositor(element)) { |
295 // When an element is being detached, we cancel any associated | 303 // When an element is being detached, we cancel any associated |
296 // AnimationPlayers for CSS animations. But by the time we get | 304 // AnimationPlayers for CSS animations. But by the time we get |
297 // here the mapping will have been removed. | 305 // here the mapping will have been removed. |
298 // FIXME: Defer remove/pause operations until after the | 306 // FIXME: Defer remove/pause operations until after the |
299 // compositing update. | 307 // compositing update. |
300 return; | 308 return; |
301 } | 309 } |
302 toLayoutBoxModelObject(element.layoutObject())->layer()->compositedLayerMapp
ing()->mainGraphicsLayer()->removeAnimation(id); | 310 if (RuntimeEnabledFeatures::compositorAnimationTimelinesEnabled()) { |
| 311 ASSERT(player); |
| 312 WebCompositorAnimationPlayer* compositorPlayer = player->compositorPlaye
r(); |
| 313 ASSERT(compositorPlayer); |
| 314 compositorPlayer->removeAnimation(id); |
| 315 } else { |
| 316 toLayoutBoxModelObject(element.layoutObject())->layer()->compositedLayer
Mapping()->mainGraphicsLayer()->removeAnimation(id); |
| 317 } |
303 } | 318 } |
304 | 319 |
305 void CompositorAnimations::pauseAnimationForTestingOnCompositor(const Element& e
lement, int id, double pauseTime) | 320 void CompositorAnimations::pauseAnimationForTestingOnCompositor(const Element& e
lement, const AnimationPlayer* player, int id, double pauseTime) |
306 { | 321 { |
307 // FIXME: canStartAnimationOnCompositor queries compositingState, which is n
ot necessarily up to date. | 322 // FIXME: canStartAnimationOnCompositor queries compositingState, which is n
ot necessarily up to date. |
308 // https://code.google.com/p/chromium/issues/detail?id=339847 | 323 // https://code.google.com/p/chromium/issues/detail?id=339847 |
309 DisableCompositingQueryAsserts disabler; | 324 DisableCompositingQueryAsserts disabler; |
310 | 325 |
311 if (!canStartAnimationOnCompositor(element)) { | 326 if (!canStartAnimationOnCompositor(element)) { |
312 ASSERT_NOT_REACHED(); | 327 ASSERT_NOT_REACHED(); |
313 return; | 328 return; |
314 } | 329 } |
315 toLayoutBoxModelObject(element.layoutObject())->layer()->compositedLayerMapp
ing()->mainGraphicsLayer()->pauseAnimation(id, pauseTime); | 330 if (RuntimeEnabledFeatures::compositorAnimationTimelinesEnabled()) { |
| 331 ASSERT(player); |
| 332 WebCompositorAnimationPlayer* compositorPlayer = player->compositorPlaye
r(); |
| 333 ASSERT(compositorPlayer); |
| 334 compositorPlayer->pauseAnimation(id, pauseTime); |
| 335 } else { |
| 336 toLayoutBoxModelObject(element.layoutObject())->layer()->compositedLayer
Mapping()->mainGraphicsLayer()->pauseAnimation(id, pauseTime); |
| 337 } |
316 } | 338 } |
317 | 339 |
318 // ----------------------------------------------------------------------- | 340 // ----------------------------------------------------------------------- |
319 // CompositorAnimationsImpl | 341 // CompositorAnimationsImpl |
320 // ----------------------------------------------------------------------- | 342 // ----------------------------------------------------------------------- |
321 | 343 |
322 bool CompositorAnimationsImpl::convertTimingForCompositor(const Timing& timing,
double timeOffset, CompositorTiming& out, double playerPlaybackRate) | 344 bool CompositorAnimationsImpl::convertTimingForCompositor(const Timing& timing,
double timeOffset, CompositorTiming& out, double playerPlaybackRate) |
323 { | 345 { |
324 timing.assertValid(); | 346 timing.assertValid(); |
325 | 347 |
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
621 break; | 643 break; |
622 default: | 644 default: |
623 ASSERT_NOT_REACHED(); | 645 ASSERT_NOT_REACHED(); |
624 } | 646 } |
625 animations.append(animation.release()); | 647 animations.append(animation.release()); |
626 } | 648 } |
627 ASSERT(!animations.isEmpty()); | 649 ASSERT(!animations.isEmpty()); |
628 } | 650 } |
629 | 651 |
630 } // namespace blink | 652 } // namespace blink |
OLD | NEW |