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/threading/thread_task_runner_handle.h" | 9 #include "base/threading/thread_task_runner_handle.h" |
10 #include "cc/animation/animation_host.h" | 10 #include "cc/animation/animation_host.h" |
11 #include "cc/animation/animation_id_provider.h" | 11 #include "cc/animation/animation_id_provider.h" |
12 #include "cc/animation/keyframed_animation_curve.h" | 12 #include "cc/animation/keyframed_animation_curve.h" |
13 #include "cc/animation/mutable_properties.h" | 13 #include "cc/animation/mutable_properties.h" |
14 #include "cc/base/math_util.h" | 14 #include "cc/base/math_util.h" |
15 #include "cc/input/main_thread_scrolling_reason.h" | 15 #include "cc/input/main_thread_scrolling_reason.h" |
16 #include "cc/layers/layer_impl.h" | 16 #include "cc/layers/layer_impl.h" |
17 #include "cc/layers/solid_color_scrollbar_layer.h" | 17 #include "cc/layers/solid_color_scrollbar_layer.h" |
18 #include "cc/output/copy_output_request.h" | 18 #include "cc/output/copy_output_request.h" |
19 #include "cc/output/copy_output_result.h" | 19 #include "cc/output/copy_output_result.h" |
20 #include "cc/proto/layer.pb.h" | 20 #include "cc/proto/layer.pb.h" |
21 #include "cc/test/animation_test_common.h" | 21 #include "cc/test/animation_test_common.h" |
22 #include "cc/test/fake_impl_task_runner_provider.h" | 22 #include "cc/test/fake_impl_task_runner_provider.h" |
23 #include "cc/test/fake_layer_tree_host.h" | 23 #include "cc/test/fake_layer_tree_host.h" |
24 #include "cc/test/fake_layer_tree_host_client.h" | 24 #include "cc/test/fake_layer_tree_host_client.h" |
25 #include "cc/test/fake_layer_tree_host_impl.h" | 25 #include "cc/test/fake_layer_tree_host_impl.h" |
26 #include "cc/test/geometry_test_utils.h" | 26 #include "cc/test/geometry_test_utils.h" |
27 #include "cc/test/layer_internals_for_test.h" | 27 #include "cc/test/layer_internals_for_test.h" |
28 #include "cc/test/layer_test_common.h" | 28 #include "cc/test/layer_test_common.h" |
29 #include "cc/test/stub_layer_tree_host_single_thread_client.h" | 29 #include "cc/test/stub_layer_tree_host_single_thread_client.h" |
30 #include "cc/test/test_gpu_memory_buffer_manager.h" | |
31 #include "cc/test/test_shared_bitmap_manager.h" | |
32 #include "cc/test/test_task_graph_runner.h" | 30 #include "cc/test/test_task_graph_runner.h" |
33 #include "cc/trees/layer_tree_host.h" | 31 #include "cc/trees/layer_tree_host.h" |
34 #include "cc/trees/single_thread_proxy.h" | 32 #include "cc/trees/single_thread_proxy.h" |
35 #include "cc/trees/transform_node.h" | 33 #include "cc/trees/transform_node.h" |
36 #include "testing/gmock/include/gmock/gmock.h" | 34 #include "testing/gmock/include/gmock/gmock.h" |
37 #include "testing/gtest/include/gtest/gtest.h" | 35 #include "testing/gtest/include/gtest/gtest.h" |
38 #include "third_party/skia/include/core/SkColor.h" | 36 #include "third_party/skia/include/core/SkColor.h" |
39 #include "ui/gfx/geometry/point3_f.h" | 37 #include "ui/gfx/geometry/point3_f.h" |
40 #include "ui/gfx/geometry/point_f.h" | 38 #include "ui/gfx/geometry/point_f.h" |
41 #include "ui/gfx/geometry/scroll_offset.h" | 39 #include "ui/gfx/geometry/scroll_offset.h" |
(...skipping 853 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
895 | 893 |
896 MOCK_METHOD0(SetNeedsCommit, void()); | 894 MOCK_METHOD0(SetNeedsCommit, void()); |
897 MOCK_METHOD0(SetNeedsUpdateLayers, void()); | 895 MOCK_METHOD0(SetNeedsUpdateLayers, void()); |
898 }; | 896 }; |
899 | 897 |
900 class LayerTest : public testing::Test { | 898 class LayerTest : public testing::Test { |
901 public: | 899 public: |
902 LayerTest() | 900 LayerTest() |
903 : host_impl_(LayerTreeSettings(), | 901 : host_impl_(LayerTreeSettings(), |
904 &task_runner_provider_, | 902 &task_runner_provider_, |
905 &shared_bitmap_manager_, | |
906 &task_graph_runner_) { | 903 &task_graph_runner_) { |
907 timeline_impl_ = | 904 timeline_impl_ = |
908 AnimationTimeline::Create(AnimationIdProvider::NextTimelineId()); | 905 AnimationTimeline::Create(AnimationIdProvider::NextTimelineId()); |
909 timeline_impl_->set_is_impl_only(true); | 906 timeline_impl_->set_is_impl_only(true); |
910 host_impl_.animation_host()->AddAnimationTimeline(timeline_impl_); | 907 host_impl_.animation_host()->AddAnimationTimeline(timeline_impl_); |
911 } | 908 } |
912 | 909 |
913 const LayerTreeSettings& settings() { return settings_; } | 910 const LayerTreeSettings& settings() { return settings_; } |
914 scoped_refptr<AnimationTimeline> timeline_impl() { return timeline_impl_; } | 911 scoped_refptr<AnimationTimeline> timeline_impl() { return timeline_impl_; } |
915 | 912 |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
985 child1_->AddChild(grand_child1_); | 982 child1_->AddChild(grand_child1_); |
986 child1_->AddChild(grand_child2_); | 983 child1_->AddChild(grand_child2_); |
987 child2_->AddChild(grand_child3_); | 984 child2_->AddChild(grand_child3_); |
988 | 985 |
989 Mock::VerifyAndClearExpectations(layer_tree_); | 986 Mock::VerifyAndClearExpectations(layer_tree_); |
990 | 987 |
991 VerifyTestTreeInitialState(); | 988 VerifyTestTreeInitialState(); |
992 } | 989 } |
993 | 990 |
994 FakeImplTaskRunnerProvider task_runner_provider_; | 991 FakeImplTaskRunnerProvider task_runner_provider_; |
995 TestSharedBitmapManager shared_bitmap_manager_; | |
996 TestTaskGraphRunner task_graph_runner_; | 992 TestTaskGraphRunner task_graph_runner_; |
997 FakeLayerTreeHostImpl host_impl_; | 993 FakeLayerTreeHostImpl host_impl_; |
998 | 994 |
999 StubLayerTreeHostSingleThreadClient single_thread_client_; | 995 StubLayerTreeHostSingleThreadClient single_thread_client_; |
1000 FakeLayerTreeHostClient fake_client_; | 996 FakeLayerTreeHostClient fake_client_; |
1001 std::unique_ptr<StrictMock<MockLayerTreeHost>> layer_tree_host_; | 997 std::unique_ptr<StrictMock<MockLayerTreeHost>> layer_tree_host_; |
1002 StrictMock<MockLayerTree>* layer_tree_; | 998 StrictMock<MockLayerTree>* layer_tree_; |
1003 scoped_refptr<Layer> parent_; | 999 scoped_refptr<Layer> parent_; |
1004 scoped_refptr<Layer> child1_; | 1000 scoped_refptr<Layer> child1_; |
1005 scoped_refptr<Layer> child2_; | 1001 scoped_refptr<Layer> child2_; |
(...skipping 812 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1818 | 1814 |
1819 class LayerTreeHostFactory { | 1815 class LayerTreeHostFactory { |
1820 public: | 1816 public: |
1821 std::unique_ptr<LayerTreeHost> Create() { | 1817 std::unique_ptr<LayerTreeHost> Create() { |
1822 return Create(LayerTreeSettings()); | 1818 return Create(LayerTreeSettings()); |
1823 } | 1819 } |
1824 | 1820 |
1825 std::unique_ptr<LayerTreeHost> Create(LayerTreeSettings settings) { | 1821 std::unique_ptr<LayerTreeHost> Create(LayerTreeSettings settings) { |
1826 LayerTreeHostInProcess::InitParams params; | 1822 LayerTreeHostInProcess::InitParams params; |
1827 params.client = &client_; | 1823 params.client = &client_; |
1828 params.shared_bitmap_manager = &shared_bitmap_manager_; | |
1829 params.task_graph_runner = &task_graph_runner_; | 1824 params.task_graph_runner = &task_graph_runner_; |
1830 params.gpu_memory_buffer_manager = &gpu_memory_buffer_manager_; | |
1831 params.settings = &settings; | 1825 params.settings = &settings; |
1832 params.main_task_runner = base::ThreadTaskRunnerHandle::Get(); | 1826 params.main_task_runner = base::ThreadTaskRunnerHandle::Get(); |
1833 params.animation_host = | 1827 params.animation_host = |
1834 AnimationHost::CreateForTesting(ThreadInstance::MAIN); | 1828 AnimationHost::CreateForTesting(ThreadInstance::MAIN); |
1835 return LayerTreeHostInProcess::CreateSingleThreaded(&single_thread_client_, | 1829 return LayerTreeHostInProcess::CreateSingleThreaded(&single_thread_client_, |
1836 ¶ms); | 1830 ¶ms); |
1837 } | 1831 } |
1838 | 1832 |
1839 private: | 1833 private: |
1840 FakeLayerTreeHostClient client_; | 1834 FakeLayerTreeHostClient client_; |
1841 StubLayerTreeHostSingleThreadClient single_thread_client_; | 1835 StubLayerTreeHostSingleThreadClient single_thread_client_; |
1842 TestSharedBitmapManager shared_bitmap_manager_; | |
1843 TestTaskGraphRunner task_graph_runner_; | 1836 TestTaskGraphRunner task_graph_runner_; |
1844 TestGpuMemoryBufferManager gpu_memory_buffer_manager_; | |
1845 }; | 1837 }; |
1846 | 1838 |
1847 void AssertLayerTreeHostMatchesForSubtree(Layer* layer, LayerTreeHost* host) { | 1839 void AssertLayerTreeHostMatchesForSubtree(Layer* layer, LayerTreeHost* host) { |
1848 EXPECT_EQ(host, layer->GetLayerTreeHostForTesting()); | 1840 EXPECT_EQ(host, layer->GetLayerTreeHostForTesting()); |
1849 | 1841 |
1850 for (size_t i = 0; i < layer->children().size(); ++i) | 1842 for (size_t i = 0; i < layer->children().size(); ++i) |
1851 AssertLayerTreeHostMatchesForSubtree(layer->children()[i].get(), host); | 1843 AssertLayerTreeHostMatchesForSubtree(layer->children()[i].get(), host); |
1852 | 1844 |
1853 if (layer->mask_layer()) | 1845 if (layer->mask_layer()) |
1854 AssertLayerTreeHostMatchesForSubtree(layer->mask_layer(), host); | 1846 AssertLayerTreeHostMatchesForSubtree(layer->mask_layer(), host); |
(...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2474 EXPECT_EQ(MutableProperty::kNone, impl_layer->mutable_properties()); | 2466 EXPECT_EQ(MutableProperty::kNone, impl_layer->mutable_properties()); |
2475 | 2467 |
2476 test_layer->PushPropertiesTo(impl_layer.get()); | 2468 test_layer->PushPropertiesTo(impl_layer.get()); |
2477 | 2469 |
2478 EXPECT_EQ(ElementId(2, 0), impl_layer->element_id()); | 2470 EXPECT_EQ(ElementId(2, 0), impl_layer->element_id()); |
2479 EXPECT_EQ(MutableProperty::kTransform, impl_layer->mutable_properties()); | 2471 EXPECT_EQ(MutableProperty::kTransform, impl_layer->mutable_properties()); |
2480 } | 2472 } |
2481 | 2473 |
2482 } // namespace | 2474 } // namespace |
2483 } // namespace cc | 2475 } // namespace cc |
OLD | NEW |