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 789 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
800 root->addChild(child); | 800 root->addChild(child); |
801 scoped_ptr<FakeLayerImplTreeHost> layerTreeHost(FakeLayerImplTreeHost::creat
e()); | 801 scoped_ptr<FakeLayerImplTreeHost> layerTreeHost(FakeLayerImplTreeHost::creat
e()); |
802 layerTreeHost->setRootLayer(root); | 802 layerTreeHost->setRootLayer(root); |
803 } | 803 } |
804 | 804 |
805 static bool addTestAnimation(Layer* layer) | 805 static bool addTestAnimation(Layer* layer) |
806 { | 806 { |
807 scoped_ptr<KeyframedFloatAnimationCurve> curve(KeyframedFloatAnimationCurve:
:create()); | 807 scoped_ptr<KeyframedFloatAnimationCurve> curve(KeyframedFloatAnimationCurve:
:create()); |
808 curve->addKeyframe(FloatKeyframe::create(0, 0.3f, scoped_ptr<TimingFunction>
())); | 808 curve->addKeyframe(FloatKeyframe::create(0, 0.3f, scoped_ptr<TimingFunction>
())); |
809 curve->addKeyframe(FloatKeyframe::create(1, 0.7f, scoped_ptr<TimingFunction>
())); | 809 curve->addKeyframe(FloatKeyframe::create(1, 0.7f, scoped_ptr<TimingFunction>
())); |
810 scoped_ptr<ActiveAnimation> animation(ActiveAnimation::create(curve.PassAs<A
nimationCurve>(), 0, 0, ActiveAnimation::Opacity)); | 810 scoped_ptr<Animation> animation(Animation::create(curve.PassAs<AnimationCurv
e>(), 0, 0, Animation::Opacity)); |
811 | 811 |
812 return layer->addAnimation(animation.Pass()); | 812 return layer->addAnimation(animation.Pass()); |
813 } | 813 } |
814 | 814 |
815 TEST(LayerLayerTreeHostTest, shouldNotAddAnimationWithoutLayerTreeHost) | 815 TEST(LayerLayerTreeHostTest, shouldNotAddAnimationWithoutLayerTreeHost) |
816 { | 816 { |
817 // Currently, WebCore assumes that animations will be started immediately /
very soon | 817 // Currently, WebCore assumes that animations will be started immediately /
very soon |
818 // if a composited layer's addAnimation() returns true. However, without a l
ayerTreeHost, | 818 // if a composited layer's addAnimation() returns true. However, without a l
ayerTreeHost, |
819 // layers cannot actually animate yet. So, to prevent violating this WebCore
assumption, | 819 // layers cannot actually animate yet. So, to prevent violating this WebCore
assumption, |
820 // the animation should not be accepted if the layer doesn't already have a
layerTreeHost. | 820 // the animation should not be accepted if the layer doesn't already have a
layerTreeHost. |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
854 scoped_refptr<MockLayer> layer(new MockLayer); | 854 scoped_refptr<MockLayer> layer(new MockLayer); |
855 EXPECT_FALSE(layer->needsDisplay()); | 855 EXPECT_FALSE(layer->needsDisplay()); |
856 layer->setBounds(gfx::Size(0, 10)); | 856 layer->setBounds(gfx::Size(0, 10)); |
857 EXPECT_FALSE(layer->needsDisplay()); | 857 EXPECT_FALSE(layer->needsDisplay()); |
858 layer->setBounds(gfx::Size(10, 10)); | 858 layer->setBounds(gfx::Size(10, 10)); |
859 EXPECT_TRUE(layer->needsDisplay()); | 859 EXPECT_TRUE(layer->needsDisplay()); |
860 } | 860 } |
861 | 861 |
862 } // namespace | 862 } // namespace |
863 } // namespace cc | 863 } // namespace cc |
OLD | NEW |