Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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/keyframed_animation_curve.h" | 7 #include "cc/keyframed_animation_curve.h" |
| 8 #include "cc/layer_impl.h" | 8 #include "cc/layer_impl.h" |
| 9 #include "cc/layer_painter.h" | 9 #include "cc/layer_painter.h" |
| 10 #include "cc/layer_tree_host.h" | 10 #include "cc/layer_tree_host.h" |
| (...skipping 826 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 837 static bool addTestAnimation(Layer* layer) | 837 static bool addTestAnimation(Layer* layer) |
| 838 { | 838 { |
| 839 scoped_ptr<KeyframedFloatAnimationCurve> curve(KeyframedFloatAnimationCurve: :create()); | 839 scoped_ptr<KeyframedFloatAnimationCurve> curve(KeyframedFloatAnimationCurve: :create()); |
| 840 curve->addKeyframe(FloatKeyframe::create(0, 0.3f, scoped_ptr<TimingFunction> ())); | 840 curve->addKeyframe(FloatKeyframe::create(0, 0.3f, scoped_ptr<TimingFunction> ())); |
| 841 curve->addKeyframe(FloatKeyframe::create(1, 0.7f, scoped_ptr<TimingFunction> ())); | 841 curve->addKeyframe(FloatKeyframe::create(1, 0.7f, scoped_ptr<TimingFunction> ())); |
| 842 scoped_ptr<Animation> animation(Animation::create(curve.PassAs<AnimationCurv e>(), 0, 0, Animation::Opacity)); | 842 scoped_ptr<Animation> animation(Animation::create(curve.PassAs<AnimationCurv e>(), 0, 0, Animation::Opacity)); |
| 843 | 843 |
| 844 return layer->addAnimation(animation.Pass()); | 844 return layer->addAnimation(animation.Pass()); |
| 845 } | 845 } |
| 846 | 846 |
| 847 TEST(LayerLayerTreeHostTest, shouldNotAddAnimationWithoutLayerTreeHost) | 847 TEST(LayerLayerTreeHostTest, shouldNotAddAnimationWithoutAnimationRegistrar) |
| 848 { | 848 { |
| 849 // Currently, WebCore assumes that animations will be started immediately / very soon | |
| 850 // if a composited layer's addAnimation() returns true. However, without a l ayerTreeHost, | |
| 851 // layers cannot actually animate yet. So, to prevent violating this WebCore assumption, | |
| 852 // the animation should not be accepted if the layer doesn't already have a layerTreeHost. | |
| 853 | |
| 854 scoped_refptr<Layer> layer = Layer::create(); | 849 scoped_refptr<Layer> layer = Layer::create(); |
| 855 | 850 |
| 856 // Case 1: without a layerTreeHost, the animation should not be accepted. | 851 // Case 1: without a LayerTreeHost and without an AnimationRegistrar, the |
| 857 #if defined(OS_ANDROID) | 852 // animation should not be accepted. |
| 858 // All animations are enabled on Android to avoid performance regressions. | |
| 859 // Other platforms will be enabled with http://crbug.com/129683 | |
| 860 EXPECT_TRUE(addTestAnimation(layer.get())); | |
| 861 #else | |
| 862 EXPECT_FALSE(addTestAnimation(layer.get())); | 853 EXPECT_FALSE(addTestAnimation(layer.get())); |
| 863 #endif | |
| 864 | 854 |
| 865 scoped_ptr<FakeLayerImplTreeHost> layerTreeHost(FakeLayerImplTreeHost::creat e()); | 855 scoped_ptr<FakeLayerImplTreeHost> layerTreeHost(FakeLayerImplTreeHost::creat e()); |
| 856 layer->layerAnimationController()->setAnimationRegistrar(layerTreeHost->anim ationRegistrar()); | |
| 857 | |
| 858 // Case 2: with an AnimationRegistrar, the animation should be accepted. | |
| 859 EXPECT_TRUE(addTestAnimation(layer.get())); | |
| 860 | |
| 866 layerTreeHost->setRootLayer(layer.get()); | 861 layerTreeHost->setRootLayer(layer.get()); |
| 867 layer->setLayerTreeHost(layerTreeHost.get()); | 862 layer->setLayerTreeHost(layerTreeHost.get()); |
| 868 assertLayerTreeHostMatchesForSubtree(layer.get(), layerTreeHost.get()); | 863 assertLayerTreeHostMatchesForSubtree(layer.get(), layerTreeHost.get()); |
| 869 | 864 |
| 870 // Case 2: with a layerTreeHost, the animation should be accepted. | 865 // Case 3: with a LayerTreeHost, the animation should be accepted. |
|
Ian Vollick
2013/02/25 18:27:29
Maybe we could add a LTH with no registrar and che
| |
| 871 EXPECT_TRUE(addTestAnimation(layer.get())); | 866 EXPECT_TRUE(addTestAnimation(layer.get())); |
| 872 } | 867 } |
| 873 | 868 |
| 874 } // namespace | 869 } // namespace |
| 875 } // namespace cc | 870 } // namespace cc |
| OLD | NEW |