| 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 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 | 250 |
| 251 if ((affectsOpacity && attachedPlayer->affects(targetElement, CSSPropert
yOpacity)) | 251 if ((affectsOpacity && attachedPlayer->affects(targetElement, CSSPropert
yOpacity)) |
| 252 || (affectsTransform && attachedPlayer->affects(targetElement, CSSPr
opertyTransform)) | 252 || (affectsTransform && attachedPlayer->affects(targetElement, CSSPr
opertyTransform)) |
| 253 || (affectsFilter && attachedPlayer->affects(targetElement, CSSPrope
rtyWebkitFilter))) | 253 || (affectsFilter && attachedPlayer->affects(targetElement, CSSPrope
rtyWebkitFilter))) |
| 254 attachedPlayer->cancelAnimationOnCompositor(); | 254 attachedPlayer->cancelAnimationOnCompositor(); |
| 255 } | 255 } |
| 256 } | 256 } |
| 257 | 257 |
| 258 bool CompositorAnimations::canStartAnimationOnCompositor(const Element& element) | 258 bool CompositorAnimations::canStartAnimationOnCompositor(const Element& element) |
| 259 { | 259 { |
| 260 return element.renderer() && element.renderer()->compositingState() == Paint
sIntoOwnBacking; | 260 return element.layoutObject() && element.layoutObject()->compositingState()
== PaintsIntoOwnBacking; |
| 261 } | 261 } |
| 262 | 262 |
| 263 bool CompositorAnimations::startAnimationOnCompositor(const Element& element, in
t group, double startTime, double timeOffset, const Timing& timing, const Animat
ionPlayer* player, const AnimationEffect& effect, Vector<int>& startedAnimationI
ds, double playerPlaybackRate) | 263 bool CompositorAnimations::startAnimationOnCompositor(const Element& element, in
t group, double startTime, double timeOffset, const Timing& timing, const Animat
ionPlayer* player, const AnimationEffect& effect, Vector<int>& startedAnimationI
ds, double playerPlaybackRate) |
| 264 { | 264 { |
| 265 ASSERT(startedAnimationIds.isEmpty()); | 265 ASSERT(startedAnimationIds.isEmpty()); |
| 266 ASSERT(isCandidateForAnimationOnCompositor(timing, element, player, effect,
playerPlaybackRate)); | 266 ASSERT(isCandidateForAnimationOnCompositor(timing, element, player, effect,
playerPlaybackRate)); |
| 267 ASSERT(canStartAnimationOnCompositor(element)); | 267 ASSERT(canStartAnimationOnCompositor(element)); |
| 268 | 268 |
| 269 const KeyframeEffectModelBase& keyframeEffect = toKeyframeEffectModelBase(ef
fect); | 269 const KeyframeEffectModelBase& keyframeEffect = toKeyframeEffectModelBase(ef
fect); |
| 270 | 270 |
| 271 Layer* layer = toLayoutBoxModelObject(element.renderer())->layer(); | 271 Layer* layer = toLayoutBoxModelObject(element.layoutObject())->layer(); |
| 272 ASSERT(layer); | 272 ASSERT(layer); |
| 273 | 273 |
| 274 Vector<OwnPtr<WebCompositorAnimation>> animations; | 274 Vector<OwnPtr<WebCompositorAnimation>> animations; |
| 275 CompositorAnimationsImpl::getAnimationOnCompositor(timing, group, startTime,
timeOffset, keyframeEffect, animations, playerPlaybackRate); | 275 CompositorAnimationsImpl::getAnimationOnCompositor(timing, group, startTime,
timeOffset, keyframeEffect, animations, playerPlaybackRate); |
| 276 ASSERT(!animations.isEmpty()); | 276 ASSERT(!animations.isEmpty()); |
| 277 for (auto& animation : animations) { | 277 for (auto& animation : animations) { |
| 278 int id = animation->id(); | 278 int id = animation->id(); |
| 279 if (!layer->compositedLayerMapping()->mainGraphicsLayer()->addAnimation(
animation.release())) { | 279 if (!layer->compositedLayerMapping()->mainGraphicsLayer()->addAnimation(
animation.release())) { |
| 280 // FIXME: We should know ahead of time whether these animations can
be started. | 280 // FIXME: We should know ahead of time whether these animations can
be started. |
| 281 for (int startedAnimationId : startedAnimationIds) | 281 for (int startedAnimationId : startedAnimationIds) |
| (...skipping 10 matching lines...) Expand all Loading... |
| 292 void CompositorAnimations::cancelAnimationOnCompositor(const Element& element, i
nt id) | 292 void CompositorAnimations::cancelAnimationOnCompositor(const Element& element, i
nt id) |
| 293 { | 293 { |
| 294 if (!canStartAnimationOnCompositor(element)) { | 294 if (!canStartAnimationOnCompositor(element)) { |
| 295 // When an element is being detached, we cancel any associated | 295 // When an element is being detached, we cancel any associated |
| 296 // AnimationPlayers for CSS animations. But by the time we get | 296 // AnimationPlayers for CSS animations. But by the time we get |
| 297 // here the mapping will have been removed. | 297 // here the mapping will have been removed. |
| 298 // FIXME: Defer remove/pause operations until after the | 298 // FIXME: Defer remove/pause operations until after the |
| 299 // compositing update. | 299 // compositing update. |
| 300 return; | 300 return; |
| 301 } | 301 } |
| 302 toLayoutBoxModelObject(element.renderer())->layer()->compositedLayerMapping(
)->mainGraphicsLayer()->removeAnimation(id); | 302 toLayoutBoxModelObject(element.layoutObject())->layer()->compositedLayerMapp
ing()->mainGraphicsLayer()->removeAnimation(id); |
| 303 } | 303 } |
| 304 | 304 |
| 305 void CompositorAnimations::pauseAnimationForTestingOnCompositor(const Element& e
lement, int id, double pauseTime) | 305 void CompositorAnimations::pauseAnimationForTestingOnCompositor(const Element& e
lement, int id, double pauseTime) |
| 306 { | 306 { |
| 307 // FIXME: canStartAnimationOnCompositor queries compositingState, which is n
ot necessarily up to date. | 307 // FIXME: canStartAnimationOnCompositor queries compositingState, which is n
ot necessarily up to date. |
| 308 // https://code.google.com/p/chromium/issues/detail?id=339847 | 308 // https://code.google.com/p/chromium/issues/detail?id=339847 |
| 309 DisableCompositingQueryAsserts disabler; | 309 DisableCompositingQueryAsserts disabler; |
| 310 | 310 |
| 311 if (!canStartAnimationOnCompositor(element)) { | 311 if (!canStartAnimationOnCompositor(element)) { |
| 312 ASSERT_NOT_REACHED(); | 312 ASSERT_NOT_REACHED(); |
| 313 return; | 313 return; |
| 314 } | 314 } |
| 315 toLayoutBoxModelObject(element.renderer())->layer()->compositedLayerMapping(
)->mainGraphicsLayer()->pauseAnimation(id, pauseTime); | 315 toLayoutBoxModelObject(element.layoutObject())->layer()->compositedLayerMapp
ing()->mainGraphicsLayer()->pauseAnimation(id, pauseTime); |
| 316 } | 316 } |
| 317 | 317 |
| 318 // ----------------------------------------------------------------------- | 318 // ----------------------------------------------------------------------- |
| 319 // CompositorAnimationsImpl | 319 // CompositorAnimationsImpl |
| 320 // ----------------------------------------------------------------------- | 320 // ----------------------------------------------------------------------- |
| 321 | 321 |
| 322 bool CompositorAnimationsImpl::convertTimingForCompositor(const Timing& timing,
double timeOffset, CompositorTiming& out, double playerPlaybackRate) | 322 bool CompositorAnimationsImpl::convertTimingForCompositor(const Timing& timing,
double timeOffset, CompositorTiming& out, double playerPlaybackRate) |
| 323 { | 323 { |
| 324 timing.assertValid(); | 324 timing.assertValid(); |
| 325 | 325 |
| (...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 621 break; | 621 break; |
| 622 default: | 622 default: |
| 623 ASSERT_NOT_REACHED(); | 623 ASSERT_NOT_REACHED(); |
| 624 } | 624 } |
| 625 animations.append(animation.release()); | 625 animations.append(animation.release()); |
| 626 } | 626 } |
| 627 ASSERT(!animations.isEmpty()); | 627 ASSERT(!animations.isEmpty()); |
| 628 } | 628 } |
| 629 | 629 |
| 630 } // namespace blink | 630 } // namespace blink |
| OLD | NEW |