Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(79)

Side by Side Diff: third_party/WebKit/Source/core/animation/CompositorAnimations.cpp

Issue 1739743003: Blink Compositor Animation: Erase old animation system. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Exclude histograms.xml Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 } 340 }
341 341
342 bool CompositorAnimations::startAnimationOnCompositor(const Element& element, in t group, double startTime, double timeOffset, const Timing& timing, const Animat ion& animation, const EffectModel& effect, Vector<int>& startedAnimationIds, dou ble animationPlaybackRate) 342 bool CompositorAnimations::startAnimationOnCompositor(const Element& element, in t group, double startTime, double timeOffset, const Timing& timing, const Animat ion& animation, const EffectModel& effect, Vector<int>& startedAnimationIds, dou ble animationPlaybackRate)
343 { 343 {
344 ASSERT(startedAnimationIds.isEmpty()); 344 ASSERT(startedAnimationIds.isEmpty());
345 ASSERT(isCandidateForAnimationOnCompositor(timing, element, &animation, effe ct, animationPlaybackRate)); 345 ASSERT(isCandidateForAnimationOnCompositor(timing, element, &animation, effe ct, animationPlaybackRate));
346 ASSERT(canStartAnimationOnCompositor(element)); 346 ASSERT(canStartAnimationOnCompositor(element));
347 347
348 const KeyframeEffectModelBase& keyframeEffect = toKeyframeEffectModelBase(ef fect); 348 const KeyframeEffectModelBase& keyframeEffect = toKeyframeEffectModelBase(ef fect);
349 349
350 PaintLayer* layer = toLayoutBoxModelObject(element.layoutObject())->layer();
351 ASSERT(layer);
352
353 Vector<OwnPtr<CompositorAnimation>> animations; 350 Vector<OwnPtr<CompositorAnimation>> animations;
354 CompositorAnimationsImpl::getAnimationOnCompositor(timing, group, startTime, timeOffset, keyframeEffect, animations, animationPlaybackRate); 351 CompositorAnimationsImpl::getAnimationOnCompositor(timing, group, startTime, timeOffset, keyframeEffect, animations, animationPlaybackRate);
355 ASSERT(!animations.isEmpty()); 352 ASSERT(!animations.isEmpty());
356 for (auto& compositorAnimation : animations) { 353 for (auto& compositorAnimation : animations) {
357 int id = compositorAnimation->id(); 354 int id = compositorAnimation->id();
358 if (RuntimeEnabledFeatures::compositorAnimationTimelinesEnabled()) { 355 CompositorAnimationPlayer* compositorPlayer = animation.compositorPlayer ();
359 CompositorAnimationPlayer* compositorPlayer = animation.compositorPl ayer(); 356 ASSERT(compositorPlayer);
360 ASSERT(compositorPlayer); 357 compositorPlayer->addAnimation(compositorAnimation.leakPtr());
361 compositorPlayer->addAnimation(compositorAnimation.leakPtr());
362 } else if (!layer->compositedLayerMapping()->mainGraphicsLayer()->addAni mation(compositorAnimation.release())) {
363 // FIXME: We should know ahead of time whether these animations can be started.
364 for (int startedAnimationId : startedAnimationIds)
365 cancelAnimationOnCompositor(element, animation, startedAnimation Id);
366 startedAnimationIds.clear();
367 return false;
368 }
369 startedAnimationIds.append(id); 358 startedAnimationIds.append(id);
370 } 359 }
371 ASSERT(!startedAnimationIds.isEmpty()); 360 ASSERT(!startedAnimationIds.isEmpty());
372 return true; 361 return true;
373 } 362 }
374 363
375 void CompositorAnimations::cancelAnimationOnCompositor(const Element& element, c onst Animation& animation, int id) 364 void CompositorAnimations::cancelAnimationOnCompositor(const Element& element, c onst Animation& animation, int id)
376 { 365 {
377 if (!canStartAnimationOnCompositor(element)) { 366 if (!canStartAnimationOnCompositor(element)) {
378 // When an element is being detached, we cancel any associated 367 // When an element is being detached, we cancel any associated
379 // Animations for CSS animations. But by the time we get 368 // Animations for CSS animations. But by the time we get
380 // here the mapping will have been removed. 369 // here the mapping will have been removed.
381 // FIXME: Defer remove/pause operations until after the 370 // FIXME: Defer remove/pause operations until after the
382 // compositing update. 371 // compositing update.
383 return; 372 return;
384 } 373 }
385 if (RuntimeEnabledFeatures::compositorAnimationTimelinesEnabled()) { 374 CompositorAnimationPlayer* compositorPlayer = animation.compositorPlayer();
386 CompositorAnimationPlayer* compositorPlayer = animation.compositorPlayer (); 375 if (compositorPlayer)
387 if (compositorPlayer) 376 compositorPlayer->removeAnimation(id);
388 compositorPlayer->removeAnimation(id);
389 } else {
390 toLayoutBoxModelObject(element.layoutObject())->layer()->compositedLayer Mapping()->mainGraphicsLayer()->removeAnimation(id);
391 }
392 } 377 }
393 378
394 void CompositorAnimations::pauseAnimationForTestingOnCompositor(const Element& e lement, const Animation& animation, int id, double pauseTime) 379 void CompositorAnimations::pauseAnimationForTestingOnCompositor(const Element& e lement, const Animation& animation, int id, double pauseTime)
395 { 380 {
396 // FIXME: canStartAnimationOnCompositor queries compositingState, which is n ot necessarily up to date. 381 // FIXME: canStartAnimationOnCompositor queries compositingState, which is n ot necessarily up to date.
397 // https://code.google.com/p/chromium/issues/detail?id=339847 382 // https://code.google.com/p/chromium/issues/detail?id=339847
398 DisableCompositingQueryAsserts disabler; 383 DisableCompositingQueryAsserts disabler;
399 384
400 if (!canStartAnimationOnCompositor(element)) { 385 if (!canStartAnimationOnCompositor(element)) {
401 ASSERT_NOT_REACHED(); 386 ASSERT_NOT_REACHED();
402 return; 387 return;
403 } 388 }
404 if (RuntimeEnabledFeatures::compositorAnimationTimelinesEnabled()) { 389 CompositorAnimationPlayer* compositorPlayer = animation.compositorPlayer();
405 CompositorAnimationPlayer* compositorPlayer = animation.compositorPlayer (); 390 ASSERT(compositorPlayer);
406 ASSERT(compositorPlayer); 391 compositorPlayer->pauseAnimation(id, pauseTime);
407 compositorPlayer->pauseAnimation(id, pauseTime);
408 } else {
409 toLayoutBoxModelObject(element.layoutObject())->layer()->compositedLayer Mapping()->mainGraphicsLayer()->pauseAnimation(id, pauseTime);
410 }
411 } 392 }
412 393
413 bool CompositorAnimations::canAttachCompositedLayers(const Element& element, con st Animation& animation) 394 bool CompositorAnimations::canAttachCompositedLayers(const Element& element, con st Animation& animation)
414 { 395 {
415 if (!RuntimeEnabledFeatures::compositorAnimationTimelinesEnabled())
416 return false;
417
418 if (!animation.compositorPlayer()) 396 if (!animation.compositorPlayer())
419 return false; 397 return false;
420 398
421 if (!element.layoutObject() || !element.layoutObject()->isBoxModelObject()) 399 if (!element.layoutObject() || !element.layoutObject()->isBoxModelObject())
422 return false; 400 return false;
423 401
424 PaintLayer* layer = toLayoutBoxModelObject(element.layoutObject())->layer(); 402 PaintLayer* layer = toLayoutBoxModelObject(element.layoutObject())->layer();
425 403
426 if (!layer || !layer->isAllowedToQueryCompositingState() 404 if (!layer || !layer->isAllowedToQueryCompositingState()
427 || !layer->compositedLayerMapping() 405 || !layer->compositedLayerMapping()
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
758 break; 736 break;
759 default: 737 default:
760 ASSERT_NOT_REACHED(); 738 ASSERT_NOT_REACHED();
761 } 739 }
762 animations.append(animation.release()); 740 animations.append(animation.release());
763 } 741 }
764 ASSERT(!animations.isEmpty()); 742 ASSERT(!animations.isEmpty());
765 } 743 }
766 744
767 } // namespace blink 745 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698