| 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 739 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 750 // also being run on the impl thread, there is no need to request a commit t
o push | 750 // also being run on the impl thread, there is no need to request a commit t
o push |
| 751 // this value over, so set this value directly rather than calling setTransf
orm. | 751 // this value over, so set this value directly rather than calling setTransf
orm. |
| 752 m_transform = transform; | 752 m_transform = transform; |
| 753 } | 753 } |
| 754 | 754 |
| 755 bool Layer::IsActive() const | 755 bool Layer::IsActive() const |
| 756 { | 756 { |
| 757 return true; | 757 return true; |
| 758 } | 758 } |
| 759 | 759 |
| 760 bool Layer::IsOrphaned() const |
| 761 { |
| 762 return !m_layerTreeHost; |
| 763 } |
| 764 |
| 760 bool Layer::addAnimation(scoped_ptr <Animation> animation) | 765 bool Layer::addAnimation(scoped_ptr <Animation> animation) |
| 761 { | 766 { |
| 762 // WebCore currently assumes that accelerated animations will start soon | 767 if (!m_layerAnimationController->animationRegistrar()) |
| 763 // after the animation is added. However we cannot guarantee that if we do | |
| 764 // not have a layerTreeHost that will setNeedsCommit(). | |
| 765 // Unfortunately, the fix below to guarantee correctness causes performance | |
| 766 // regressions on Android, since Android has shipped for a long time | |
| 767 // with all animations accelerated. For this reason, we will live with | |
| 768 // this bug only on Android until the bug is fixed. | |
| 769 // http://crbug.com/129683 | |
| 770 #if !defined(OS_ANDROID) | |
| 771 if (!m_layerTreeHost) | |
| 772 return false; | 768 return false; |
| 773 | 769 |
| 774 if (!m_layerTreeHost->settings().acceleratedAnimationEnabled) | |
| 775 return false; | |
| 776 #endif | |
| 777 | |
| 778 m_layerAnimationController->addAnimation(animation.Pass()); | 770 m_layerAnimationController->addAnimation(animation.Pass()); |
| 779 setNeedsCommit(); | 771 setNeedsCommit(); |
| 780 return true; | 772 return true; |
| 781 } | 773 } |
| 782 | 774 |
| 783 void Layer::pauseAnimation(int animationId, double timeOffset) | 775 void Layer::pauseAnimation(int animationId, double timeOffset) |
| 784 { | 776 { |
| 785 m_layerAnimationController->pauseAnimation(animationId, timeOffset); | 777 m_layerAnimationController->pauseAnimation(animationId, timeOffset); |
| 786 setNeedsCommit(); | 778 setNeedsCommit(); |
| 787 } | 779 } |
| (...skipping 26 matching lines...) Expand all Loading... |
| 814 addLayerAnimationEventObserver(m_layerAnimationController.get()); | 806 addLayerAnimationEventObserver(m_layerAnimationController.get()); |
| 815 setNeedsCommit(); | 807 setNeedsCommit(); |
| 816 } | 808 } |
| 817 | 809 |
| 818 scoped_refptr<LayerAnimationController> Layer::releaseLayerAnimationController() | 810 scoped_refptr<LayerAnimationController> Layer::releaseLayerAnimationController() |
| 819 { | 811 { |
| 820 m_layerAnimationController->removeObserver(this); | 812 m_layerAnimationController->removeObserver(this); |
| 821 scoped_refptr<LayerAnimationController> toReturn = m_layerAnimationControlle
r; | 813 scoped_refptr<LayerAnimationController> toReturn = m_layerAnimationControlle
r; |
| 822 m_layerAnimationController = LayerAnimationController::create(id()); | 814 m_layerAnimationController = LayerAnimationController::create(id()); |
| 823 m_layerAnimationController->addObserver(this); | 815 m_layerAnimationController->addObserver(this); |
| 816 m_layerAnimationController->setAnimationRegistrar(toReturn->animationRegistr
ar()); |
| 824 return toReturn; | 817 return toReturn; |
| 825 } | 818 } |
| 826 | 819 |
| 827 bool Layer::hasActiveAnimation() const | 820 bool Layer::hasActiveAnimation() const |
| 828 { | 821 { |
| 829 return m_layerAnimationController->hasActiveAnimation(); | 822 return m_layerAnimationController->hasActiveAnimation(); |
| 830 } | 823 } |
| 831 | 824 |
| 832 void Layer::notifyAnimationStarted(const AnimationEvent& event, double wallClock
Time) | 825 void Layer::notifyAnimationStarted(const AnimationEvent& event, double wallClock
Time) |
| 833 { | 826 { |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 865 { | 858 { |
| 866 return 0; | 859 return 0; |
| 867 } | 860 } |
| 868 | 861 |
| 869 void sortLayers(std::vector<scoped_refptr<Layer> >::iterator, std::vector<scoped
_refptr<Layer> >::iterator, void*) | 862 void sortLayers(std::vector<scoped_refptr<Layer> >::iterator, std::vector<scoped
_refptr<Layer> >::iterator, void*) |
| 870 { | 863 { |
| 871 // Currently we don't use z-order to decide what to paint, so there's no nee
d to actually sort Layers. | 864 // Currently we don't use z-order to decide what to paint, so there's no nee
d to actually sort Layers. |
| 872 } | 865 } |
| 873 | 866 |
| 874 } // namespace cc | 867 } // namespace cc |
| OLD | NEW |