| OLD | NEW |
| 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 728 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 739 // also being run on the impl thread, there is no need to request a commit t
o push | 739 // also being run on the impl thread, there is no need to request a commit t
o push |
| 740 // this value over, so set this value directly rather than calling setTransf
orm. | 740 // this value over, so set this value directly rather than calling setTransf
orm. |
| 741 m_transform = transform; | 741 m_transform = transform; |
| 742 } | 742 } |
| 743 | 743 |
| 744 bool Layer::IsActive() const | 744 bool Layer::IsActive() const |
| 745 { | 745 { |
| 746 return true; | 746 return true; |
| 747 } | 747 } |
| 748 | 748 |
| 749 bool Layer::IsOrphaned() const |
| 750 { |
| 751 return !m_layerTreeHost; |
| 752 } |
| 753 |
| 749 bool Layer::addAnimation(scoped_ptr <Animation> animation) | 754 bool Layer::addAnimation(scoped_ptr <Animation> animation) |
| 750 { | 755 { |
| 751 // WebCore currently assumes that accelerated animations will start soon | 756 if (!m_layerAnimationController->animationRegistrar()) |
| 752 // after the animation is added. However we cannot guarantee that if we do | |
| 753 // not have a layerTreeHost that will setNeedsCommit(). | |
| 754 // Unfortunately, the fix below to guarantee correctness causes performance | |
| 755 // regressions on Android, since Android has shipped for a long time | |
| 756 // with all animations accelerated. For this reason, we will live with | |
| 757 // this bug only on Android until the bug is fixed. | |
| 758 // http://crbug.com/129683 | |
| 759 #if !defined(OS_ANDROID) | |
| 760 if (!m_layerTreeHost) | |
| 761 return false; | 757 return false; |
| 762 | 758 |
| 763 if (!m_layerTreeHost->settings().acceleratedAnimationEnabled) | |
| 764 return false; | |
| 765 #endif | |
| 766 | |
| 767 m_layerAnimationController->addAnimation(animation.Pass()); | 759 m_layerAnimationController->addAnimation(animation.Pass()); |
| 768 setNeedsCommit(); | 760 setNeedsCommit(); |
| 769 return true; | 761 return true; |
| 770 } | 762 } |
| 771 | 763 |
| 772 void Layer::pauseAnimation(int animationId, double timeOffset) | 764 void Layer::pauseAnimation(int animationId, double timeOffset) |
| 773 { | 765 { |
| 774 m_layerAnimationController->pauseAnimation(animationId, timeOffset); | 766 m_layerAnimationController->pauseAnimation(animationId, timeOffset); |
| 775 setNeedsCommit(); | 767 setNeedsCommit(); |
| 776 } | 768 } |
| (...skipping 26 matching lines...) Expand all Loading... |
| 803 addLayerAnimationEventObserver(m_layerAnimationController.get()); | 795 addLayerAnimationEventObserver(m_layerAnimationController.get()); |
| 804 setNeedsCommit(); | 796 setNeedsCommit(); |
| 805 } | 797 } |
| 806 | 798 |
| 807 scoped_refptr<LayerAnimationController> Layer::releaseLayerAnimationController() | 799 scoped_refptr<LayerAnimationController> Layer::releaseLayerAnimationController() |
| 808 { | 800 { |
| 809 m_layerAnimationController->removeObserver(this); | 801 m_layerAnimationController->removeObserver(this); |
| 810 scoped_refptr<LayerAnimationController> toReturn = m_layerAnimationControlle
r; | 802 scoped_refptr<LayerAnimationController> toReturn = m_layerAnimationControlle
r; |
| 811 m_layerAnimationController = LayerAnimationController::create(id()); | 803 m_layerAnimationController = LayerAnimationController::create(id()); |
| 812 m_layerAnimationController->addObserver(this); | 804 m_layerAnimationController->addObserver(this); |
| 805 m_layerAnimationController->setAnimationRegistrar(toReturn->animationRegistr
ar()); |
| 813 return toReturn; | 806 return toReturn; |
| 814 } | 807 } |
| 815 | 808 |
| 816 bool Layer::hasActiveAnimation() const | 809 bool Layer::hasActiveAnimation() const |
| 817 { | 810 { |
| 818 return m_layerAnimationController->hasActiveAnimation(); | 811 return m_layerAnimationController->hasActiveAnimation(); |
| 819 } | 812 } |
| 820 | 813 |
| 821 void Layer::notifyAnimationStarted(const AnimationEvent& event, double wallClock
Time) | 814 void Layer::notifyAnimationStarted(const AnimationEvent& event, double wallClock
Time) |
| 822 { | 815 { |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 854 { | 847 { |
| 855 return 0; | 848 return 0; |
| 856 } | 849 } |
| 857 | 850 |
| 858 void sortLayers(std::vector<scoped_refptr<Layer> >::iterator, std::vector<scoped
_refptr<Layer> >::iterator, void*) | 851 void sortLayers(std::vector<scoped_refptr<Layer> >::iterator, std::vector<scoped
_refptr<Layer> >::iterator, void*) |
| 859 { | 852 { |
| 860 // Currently we don't use z-order to decide what to paint, so there's no nee
d to actually sort Layers. | 853 // Currently we don't use z-order to decide what to paint, so there's no nee
d to actually sort Layers. |
| 861 } | 854 } |
| 862 | 855 |
| 863 } // namespace cc | 856 } // namespace cc |
| OLD | NEW |