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

Side by Side Diff: cc/layer.cc

Issue 11830056: Enable accelerated animations for orphaned layers (Closed) Base URL: http://git.chromium.org/chromium/src.git@MakeLayerTreeHostAnimateLayersTakeWallClockTime
Patch Set: Fix nit Created 7 years, 11 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
« no previous file with comments | « cc/layer.h ('k') | cc/layer_animation_controller.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2010 The Chromium Authors. All rights reserved. 1 // Copyright 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/layer.h" 5 #include "cc/layer.h"
6 6
7 #include "cc/animation.h" 7 #include "cc/animation.h"
8 #include "cc/animation_events.h" 8 #include "cc/animation_events.h"
9 #include "cc/layer_animation_controller.h" 9 #include "cc/layer_animation_controller.h"
10 #include "cc/layer_impl.h" 10 #include "cc/layer_impl.h"
(...skipping 724 matching lines...) Expand 10 before | Expand all | Expand 10 after
735 // also being run on the impl thread, there is no need to request a commit t o push 735 // also being run on the impl thread, there is no need to request a commit t o push
736 // this value over, so set this value directly rather than calling setTransf orm. 736 // this value over, so set this value directly rather than calling setTransf orm.
737 m_transform = transform; 737 m_transform = transform;
738 } 738 }
739 739
740 bool Layer::IsActive() const 740 bool Layer::IsActive() const
741 { 741 {
742 return true; 742 return true;
743 } 743 }
744 744
745 bool Layer::IsOrphaned() const
746 {
747 return !m_layerTreeHost;
748 }
749
745 bool Layer::addAnimation(scoped_ptr <Animation> animation) 750 bool Layer::addAnimation(scoped_ptr <Animation> animation)
746 { 751 {
747 // WebCore currently assumes that accelerated animations will start soon 752 if (!m_layerAnimationController->animationRegistrar())
748 // after the animation is added. However we cannot guarantee that if we do
749 // not have a layerTreeHost that will setNeedsCommit().
750 // Unfortunately, the fix below to guarantee correctness causes performance
751 // regressions on Android, since Android has shipped for a long time
752 // with all animations accelerated. For this reason, we will live with
753 // this bug only on Android until the bug is fixed.
754 // http://crbug.com/129683
755 #if !defined(OS_ANDROID)
756 if (!m_layerTreeHost)
757 return false; 753 return false;
758 754
759 if (!m_layerTreeHost->settings().acceleratedAnimationEnabled)
760 return false;
761 #endif
762
763 m_layerAnimationController->addAnimation(animation.Pass()); 755 m_layerAnimationController->addAnimation(animation.Pass());
764 setNeedsCommit(); 756 setNeedsCommit();
765 return true; 757 return true;
766 } 758 }
767 759
768 void Layer::pauseAnimation(int animationId, double timeOffset) 760 void Layer::pauseAnimation(int animationId, double timeOffset)
769 { 761 {
770 m_layerAnimationController->pauseAnimation(animationId, timeOffset); 762 m_layerAnimationController->pauseAnimation(animationId, timeOffset);
771 setNeedsCommit(); 763 setNeedsCommit();
772 } 764 }
(...skipping 26 matching lines...) Expand all
799 addLayerAnimationEventObserver(m_layerAnimationController.get()); 791 addLayerAnimationEventObserver(m_layerAnimationController.get());
800 setNeedsCommit(); 792 setNeedsCommit();
801 } 793 }
802 794
803 scoped_refptr<LayerAnimationController> Layer::releaseLayerAnimationController() 795 scoped_refptr<LayerAnimationController> Layer::releaseLayerAnimationController()
804 { 796 {
805 m_layerAnimationController->removeObserver(this); 797 m_layerAnimationController->removeObserver(this);
806 scoped_refptr<LayerAnimationController> toReturn = m_layerAnimationControlle r; 798 scoped_refptr<LayerAnimationController> toReturn = m_layerAnimationControlle r;
807 m_layerAnimationController = LayerAnimationController::create(id()); 799 m_layerAnimationController = LayerAnimationController::create(id());
808 m_layerAnimationController->addObserver(this); 800 m_layerAnimationController->addObserver(this);
801 m_layerAnimationController->setAnimationRegistrar(toReturn->animationRegistr ar());
809 return toReturn; 802 return toReturn;
810 } 803 }
811 804
812 bool Layer::hasActiveAnimation() const 805 bool Layer::hasActiveAnimation() const
813 { 806 {
814 return m_layerAnimationController->hasActiveAnimation(); 807 return m_layerAnimationController->hasActiveAnimation();
815 } 808 }
816 809
817 void Layer::notifyAnimationStarted(const AnimationEvent& event, double wallClock Time) 810 void Layer::notifyAnimationStarted(const AnimationEvent& event, double wallClock Time)
818 { 811 {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
850 { 843 {
851 return 0; 844 return 0;
852 } 845 }
853 846
854 void sortLayers(std::vector<scoped_refptr<Layer> >::iterator, std::vector<scoped _refptr<Layer> >::iterator, void*) 847 void sortLayers(std::vector<scoped_refptr<Layer> >::iterator, std::vector<scoped _refptr<Layer> >::iterator, void*)
855 { 848 {
856 // Currently we don't use z-order to decide what to paint, so there's no nee d to actually sort Layers. 849 // Currently we don't use z-order to decide what to paint, so there's no nee d to actually sort Layers.
857 } 850 }
858 851
859 } // namespace cc 852 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layer.h ('k') | cc/layer_animation_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698