| 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/layers/layer.h" | 5 #include "cc/layers/layer.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/thread_task_runner_handle.h" | 9 #include "base/thread_task_runner_handle.h" |
| 10 #include "cc/animation/animation_host.h" | 10 #include "cc/animation/animation_host.h" |
| (...skipping 2031 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2042 | 2042 |
| 2043 TEST_F(LayerLayerTreeHostTest, DestroyHostWithNonNullRootLayer) { | 2043 TEST_F(LayerLayerTreeHostTest, DestroyHostWithNonNullRootLayer) { |
| 2044 scoped_refptr<Layer> root = Layer::Create(layer_settings_); | 2044 scoped_refptr<Layer> root = Layer::Create(layer_settings_); |
| 2045 scoped_refptr<Layer> child = Layer::Create(layer_settings_); | 2045 scoped_refptr<Layer> child = Layer::Create(layer_settings_); |
| 2046 root->AddChild(child); | 2046 root->AddChild(child); |
| 2047 LayerTreeHostFactory factory; | 2047 LayerTreeHostFactory factory; |
| 2048 scoped_ptr<LayerTreeHost> layer_tree_host = factory.Create(); | 2048 scoped_ptr<LayerTreeHost> layer_tree_host = factory.Create(); |
| 2049 layer_tree_host->SetRootLayer(root); | 2049 layer_tree_host->SetRootLayer(root); |
| 2050 } | 2050 } |
| 2051 | 2051 |
| 2052 static bool AddTestAnimation(Layer* layer) { | |
| 2053 scoped_ptr<KeyframedFloatAnimationCurve> curve = | |
| 2054 KeyframedFloatAnimationCurve::Create(); | |
| 2055 curve->AddKeyframe(FloatKeyframe::Create(base::TimeDelta(), 0.3f, nullptr)); | |
| 2056 curve->AddKeyframe( | |
| 2057 FloatKeyframe::Create(base::TimeDelta::FromSecondsD(1.0), 0.7f, nullptr)); | |
| 2058 scoped_ptr<Animation> animation = | |
| 2059 Animation::Create(std::move(curve), 0, 0, TargetProperty::OPACITY); | |
| 2060 | |
| 2061 return layer->AddAnimation(std::move(animation)); | |
| 2062 } | |
| 2063 | |
| 2064 TEST_F(LayerLayerTreeHostTest, ShouldNotAddAnimationWithoutAnimationRegistrar) { | |
| 2065 // This tests isn't needed in new use_compositor_animation_timelines mode. | |
| 2066 if (layer_settings_.use_compositor_animation_timelines) | |
| 2067 return; | |
| 2068 | |
| 2069 scoped_refptr<Layer> layer = Layer::Create(layer_settings_); | |
| 2070 | |
| 2071 // Case 1: without a LayerTreeHost and without an AnimationRegistrar, the | |
| 2072 // animation should not be accepted. | |
| 2073 EXPECT_FALSE(AddTestAnimation(layer.get())); | |
| 2074 | |
| 2075 scoped_ptr<AnimationRegistrar> registrar = AnimationRegistrar::Create(); | |
| 2076 layer->RegisterForAnimations(registrar.get()); | |
| 2077 | |
| 2078 // Case 2: with an AnimationRegistrar, the animation should be accepted. | |
| 2079 EXPECT_TRUE(AddTestAnimation(layer.get())); | |
| 2080 | |
| 2081 LayerTreeSettings settings; | |
| 2082 settings.accelerated_animation_enabled = false; | |
| 2083 settings.use_compositor_animation_timelines = | |
| 2084 layer_settings_.use_compositor_animation_timelines; | |
| 2085 LayerTreeHostFactory factory; | |
| 2086 scoped_ptr<LayerTreeHost> layer_tree_host = factory.Create(settings); | |
| 2087 layer_tree_host->SetRootLayer(layer); | |
| 2088 AssertLayerTreeHostMatchesForSubtree(layer.get(), layer_tree_host.get()); | |
| 2089 | |
| 2090 // Case 3: with a LayerTreeHost where accelerated animation is disabled, the | |
| 2091 // animation should be rejected. | |
| 2092 EXPECT_FALSE(AddTestAnimation(layer.get())); | |
| 2093 } | |
| 2094 | |
| 2095 TEST_F(LayerTest, SafeOpaqueBackgroundColor) { | 2052 TEST_F(LayerTest, SafeOpaqueBackgroundColor) { |
| 2096 LayerTreeHostFactory factory; | 2053 LayerTreeHostFactory factory; |
| 2097 scoped_ptr<LayerTreeHost> layer_tree_host = factory.Create(); | 2054 scoped_ptr<LayerTreeHost> layer_tree_host = factory.Create(); |
| 2098 | 2055 |
| 2099 scoped_refptr<Layer> layer = Layer::Create(layer_settings_); | 2056 scoped_refptr<Layer> layer = Layer::Create(layer_settings_); |
| 2100 layer_tree_host->SetRootLayer(layer); | 2057 layer_tree_host->SetRootLayer(layer); |
| 2101 | 2058 |
| 2102 for (int contents_opaque = 0; contents_opaque < 2; ++contents_opaque) { | 2059 for (int contents_opaque = 0; contents_opaque < 2; ++contents_opaque) { |
| 2103 for (int layer_opaque = 0; layer_opaque < 2; ++layer_opaque) { | 2060 for (int layer_opaque = 0; layer_opaque < 2; ++layer_opaque) { |
| 2104 for (int host_opaque = 0; host_opaque < 2; ++host_opaque) { | 2061 for (int host_opaque = 0; host_opaque < 2; ++host_opaque) { |
| (...skipping 589 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2694 EXPECT_EQ(MutableProperty::kNone, impl_layer->mutable_properties()); | 2651 EXPECT_EQ(MutableProperty::kNone, impl_layer->mutable_properties()); |
| 2695 | 2652 |
| 2696 test_layer->PushPropertiesTo(impl_layer.get()); | 2653 test_layer->PushPropertiesTo(impl_layer.get()); |
| 2697 | 2654 |
| 2698 EXPECT_EQ(2lu, impl_layer->element_id()); | 2655 EXPECT_EQ(2lu, impl_layer->element_id()); |
| 2699 EXPECT_EQ(MutableProperty::kTransform, impl_layer->mutable_properties()); | 2656 EXPECT_EQ(MutableProperty::kTransform, impl_layer->mutable_properties()); |
| 2700 } | 2657 } |
| 2701 | 2658 |
| 2702 } // namespace | 2659 } // namespace |
| 2703 } // namespace cc | 2660 } // namespace cc |
| OLD | NEW |