| 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 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 const KeyframeEffectModelBase& keyframeEffect = toKeyframeEffectModelBase(ef
fect); | 280 const KeyframeEffectModelBase& keyframeEffect = toKeyframeEffectModelBase(ef
fect); |
| 281 | 281 |
| 282 DeprecatedPaintLayer* layer = toLayoutBoxModelObject(element.layoutObject())
->layer(); | 282 DeprecatedPaintLayer* layer = toLayoutBoxModelObject(element.layoutObject())
->layer(); |
| 283 ASSERT(layer); | 283 ASSERT(layer); |
| 284 | 284 |
| 285 Vector<OwnPtr<WebCompositorAnimation>> animations; | 285 Vector<OwnPtr<WebCompositorAnimation>> animations; |
| 286 CompositorAnimationsImpl::getAnimationOnCompositor(timing, group, startTime,
timeOffset, keyframeEffect, animations, playerPlaybackRate); | 286 CompositorAnimationsImpl::getAnimationOnCompositor(timing, group, startTime,
timeOffset, keyframeEffect, animations, playerPlaybackRate); |
| 287 ASSERT(!animations.isEmpty()); | 287 ASSERT(!animations.isEmpty()); |
| 288 for (auto& animation : animations) { | 288 for (auto& animation : animations) { |
| 289 int id = animation->id(); | 289 int id = animation->id(); |
| 290 if (RuntimeEnabledFeatures::compositorAnimationTimelinesEnabled()) { | 290 WebCompositorAnimationPlayer* compositorPlayer = player.compositorPlayer
(); |
| 291 WebCompositorAnimationPlayer* compositorPlayer = player.compositorPl
ayer(); | 291 ASSERT(compositorPlayer); |
| 292 ASSERT(compositorPlayer); | 292 compositorPlayer->addAnimation(animation.leakPtr()); |
| 293 compositorPlayer->addAnimation(animation.leakPtr()); | |
| 294 } else if (!layer->compositedDeprecatedPaintLayerMapping()->mainGraphics
Layer()->addAnimation(animation.release())) { | |
| 295 // FIXME: We should know ahead of time whether these animations can
be started. | |
| 296 for (int startedAnimationId : startedAnimationIds) | |
| 297 cancelAnimationOnCompositor(element, player, startedAnimationId)
; | |
| 298 startedAnimationIds.clear(); | |
| 299 return false; | |
| 300 } | |
| 301 startedAnimationIds.append(id); | 293 startedAnimationIds.append(id); |
| 302 } | 294 } |
| 303 ASSERT(!startedAnimationIds.isEmpty()); | 295 ASSERT(!startedAnimationIds.isEmpty()); |
| 304 return true; | 296 return true; |
| 305 } | 297 } |
| 306 | 298 |
| 307 void CompositorAnimations::cancelAnimationOnCompositor(const Element& element, c
onst AnimationPlayer& player, int id) | 299 void CompositorAnimations::cancelAnimationOnCompositor(const Element& element, c
onst AnimationPlayer& player, int id) |
| 308 { | 300 { |
| 309 if (!canStartAnimationOnCompositor(element)) { | 301 if (!canStartAnimationOnCompositor(element)) { |
| 310 // When an element is being detached, we cancel any associated | 302 // When an element is being detached, we cancel any associated |
| 311 // AnimationPlayers for CSS animations. But by the time we get | 303 // AnimationPlayers for CSS animations. But by the time we get |
| 312 // here the mapping will have been removed. | 304 // here the mapping will have been removed. |
| 313 // FIXME: Defer remove/pause operations until after the | 305 // FIXME: Defer remove/pause operations until after the |
| 314 // compositing update. | 306 // compositing update. |
| 315 return; | 307 return; |
| 316 } | 308 } |
| 317 if (RuntimeEnabledFeatures::compositorAnimationTimelinesEnabled()) { | 309 |
| 318 WebCompositorAnimationPlayer* compositorPlayer = player.compositorPlayer
(); | 310 WebCompositorAnimationPlayer* compositorPlayer = player.compositorPlayer(); |
| 319 ASSERT(compositorPlayer); | 311 ASSERT(compositorPlayer); |
| 320 compositorPlayer->removeAnimation(id); | 312 compositorPlayer->removeAnimation(id); |
| 321 } else { | |
| 322 toLayoutBoxModelObject(element.layoutObject())->layer()->compositedDepre
catedPaintLayerMapping()->mainGraphicsLayer()->removeAnimation(id); | |
| 323 } | |
| 324 } | 313 } |
| 325 | 314 |
| 326 void CompositorAnimations::pauseAnimationForTestingOnCompositor(const Element& e
lement, const AnimationPlayer& player, int id, double pauseTime) | 315 void CompositorAnimations::pauseAnimationForTestingOnCompositor(const Element& e
lement, const AnimationPlayer& player, int id, double pauseTime) |
| 327 { | 316 { |
| 328 // FIXME: canStartAnimationOnCompositor queries compositingState, which is n
ot necessarily up to date. | 317 // FIXME: canStartAnimationOnCompositor queries compositingState, which is n
ot necessarily up to date. |
| 329 // https://code.google.com/p/chromium/issues/detail?id=339847 | 318 // https://code.google.com/p/chromium/issues/detail?id=339847 |
| 330 DisableCompositingQueryAsserts disabler; | 319 DisableCompositingQueryAsserts disabler; |
| 331 | 320 |
| 332 if (!canStartAnimationOnCompositor(element)) { | 321 if (!canStartAnimationOnCompositor(element)) { |
| 333 ASSERT_NOT_REACHED(); | 322 ASSERT_NOT_REACHED(); |
| 334 return; | 323 return; |
| 335 } | 324 } |
| 336 if (RuntimeEnabledFeatures::compositorAnimationTimelinesEnabled()) { | 325 |
| 337 WebCompositorAnimationPlayer* compositorPlayer = player.compositorPlayer
(); | 326 WebCompositorAnimationPlayer* compositorPlayer = player.compositorPlayer(); |
| 338 ASSERT(compositorPlayer); | 327 ASSERT(compositorPlayer); |
| 339 compositorPlayer->pauseAnimation(id, pauseTime); | 328 compositorPlayer->pauseAnimation(id, pauseTime); |
| 340 } else { | |
| 341 toLayoutBoxModelObject(element.layoutObject())->layer()->compositedDepre
catedPaintLayerMapping()->mainGraphicsLayer()->pauseAnimation(id, pauseTime); | |
| 342 } | |
| 343 } | 329 } |
| 344 | 330 |
| 345 bool CompositorAnimations::canAttachCompositedLayers(const Element& element, con
st AnimationPlayer& player) | 331 bool CompositorAnimations::canAttachCompositedLayers(const Element& element, con
st AnimationPlayer& player) |
| 346 { | 332 { |
| 347 if (!RuntimeEnabledFeatures::compositorAnimationTimelinesEnabled()) | |
| 348 return false; | |
| 349 | |
| 350 if (!player.compositorPlayer()) | 333 if (!player.compositorPlayer()) |
| 351 return false; | 334 return false; |
| 352 | 335 |
| 353 if (!element.layoutObject() || !element.layoutObject()->isBoxModelObject()) | 336 if (!element.layoutObject() || !element.layoutObject()->isBoxModelObject()) |
| 354 return false; | 337 return false; |
| 355 | 338 |
| 356 DeprecatedPaintLayer* layer = toLayoutBoxModelObject(element.layoutObject())
->layer(); | 339 DeprecatedPaintLayer* layer = toLayoutBoxModelObject(element.layoutObject())
->layer(); |
| 357 | 340 |
| 358 if (!layer || !layer->isAllowedToQueryCompositingState() | 341 if (!layer || !layer->isAllowedToQueryCompositingState() |
| 359 || !layer->compositedDeprecatedPaintLayerMapping() | 342 || !layer->compositedDeprecatedPaintLayerMapping() |
| (...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 686 break; | 669 break; |
| 687 default: | 670 default: |
| 688 ASSERT_NOT_REACHED(); | 671 ASSERT_NOT_REACHED(); |
| 689 } | 672 } |
| 690 animations.append(animation.release()); | 673 animations.append(animation.release()); |
| 691 } | 674 } |
| 692 ASSERT(!animations.isEmpty()); | 675 ASSERT(!animations.isEmpty()); |
| 693 } | 676 } |
| 694 | 677 |
| 695 } // namespace blink | 678 } // namespace blink |
| OLD | NEW |