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/test_gpu_memory_buffer_manager.h" | 30 #include "cc/test/test_gpu_memory_buffer_manager.h" |
30 #include "cc/test/test_shared_bitmap_manager.h" | 31 #include "cc/test/test_shared_bitmap_manager.h" |
31 #include "cc/test/test_task_graph_runner.h" | 32 #include "cc/test/test_task_graph_runner.h" |
32 #include "cc/trees/layer_tree_host.h" | 33 #include "cc/trees/layer_tree_host.h" |
33 #include "cc/trees/single_thread_proxy.h" | 34 #include "cc/trees/single_thread_proxy.h" |
34 #include "cc/trees/transform_node.h" | 35 #include "cc/trees/transform_node.h" |
35 #include "testing/gmock/include/gmock/gmock.h" | 36 #include "testing/gmock/include/gmock/gmock.h" |
36 #include "testing/gtest/include/gtest/gtest.h" | 37 #include "testing/gtest/include/gtest/gtest.h" |
37 #include "third_party/skia/include/core/SkColor.h" | 38 #include "third_party/skia/include/core/SkColor.h" |
38 #include "ui/gfx/geometry/point3_f.h" | 39 #include "ui/gfx/geometry/point3_f.h" |
(...skipping 873 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
912 protected: | 913 protected: |
913 void SetUp() override { | 914 void SetUp() override { |
914 LayerTreeHost::InitParams params; | 915 LayerTreeHost::InitParams params; |
915 params.client = &fake_client_; | 916 params.client = &fake_client_; |
916 params.settings = &settings_; | 917 params.settings = &settings_; |
917 params.task_graph_runner = &task_graph_runner_; | 918 params.task_graph_runner = &task_graph_runner_; |
918 params.animation_host = | 919 params.animation_host = |
919 AnimationHost::CreateForTesting(ThreadInstance::MAIN); | 920 AnimationHost::CreateForTesting(ThreadInstance::MAIN); |
920 | 921 |
921 layer_tree_host_.reset( | 922 layer_tree_host_.reset( |
922 new StrictMock<MockLayerTreeHost>(&fake_client_, ¶ms)); | 923 new StrictMock<MockLayerTreeHost>(&single_thread_client_, ¶ms)); |
vmpstr
2016/07/22 21:08:42
It's a bit inconsistent that we pass a single_thre
danakj
2016/07/22 21:19:30
LTHClient and LTHSingleThreadClient are 2 diff int
| |
923 } | 924 } |
924 | 925 |
925 void TearDown() override { | 926 void TearDown() override { |
926 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); | 927 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); |
927 EXPECT_CALL(*layer_tree_host_, SetNeedsFullTreeSync()).Times(AnyNumber()); | 928 EXPECT_CALL(*layer_tree_host_, SetNeedsFullTreeSync()).Times(AnyNumber()); |
928 parent_ = nullptr; | 929 parent_ = nullptr; |
929 child1_ = nullptr; | 930 child1_ = nullptr; |
930 child2_ = nullptr; | 931 child2_ = nullptr; |
931 child3_ = nullptr; | 932 child3_ = nullptr; |
932 grand_child1_ = nullptr; | 933 grand_child1_ = nullptr; |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
981 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); | 982 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); |
982 | 983 |
983 VerifyTestTreeInitialState(); | 984 VerifyTestTreeInitialState(); |
984 } | 985 } |
985 | 986 |
986 FakeImplTaskRunnerProvider task_runner_provider_; | 987 FakeImplTaskRunnerProvider task_runner_provider_; |
987 TestSharedBitmapManager shared_bitmap_manager_; | 988 TestSharedBitmapManager shared_bitmap_manager_; |
988 TestTaskGraphRunner task_graph_runner_; | 989 TestTaskGraphRunner task_graph_runner_; |
989 FakeLayerTreeHostImpl host_impl_; | 990 FakeLayerTreeHostImpl host_impl_; |
990 | 991 |
992 StubLayerTreeHostSingleThreadClient single_thread_client_; | |
991 FakeLayerTreeHostClient fake_client_; | 993 FakeLayerTreeHostClient fake_client_; |
992 std::unique_ptr<StrictMock<MockLayerTreeHost>> layer_tree_host_; | 994 std::unique_ptr<StrictMock<MockLayerTreeHost>> layer_tree_host_; |
993 scoped_refptr<Layer> parent_; | 995 scoped_refptr<Layer> parent_; |
994 scoped_refptr<Layer> child1_; | 996 scoped_refptr<Layer> child1_; |
995 scoped_refptr<Layer> child2_; | 997 scoped_refptr<Layer> child2_; |
996 scoped_refptr<Layer> child3_; | 998 scoped_refptr<Layer> child3_; |
997 scoped_refptr<Layer> grand_child1_; | 999 scoped_refptr<Layer> grand_child1_; |
998 scoped_refptr<Layer> grand_child2_; | 1000 scoped_refptr<Layer> grand_child2_; |
999 scoped_refptr<Layer> grand_child3_; | 1001 scoped_refptr<Layer> grand_child3_; |
1000 | 1002 |
(...skipping 851 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1852 std::unique_ptr<LayerTreeHost> Create(LayerTreeSettings settings) { | 1854 std::unique_ptr<LayerTreeHost> Create(LayerTreeSettings settings) { |
1853 LayerTreeHost::InitParams params; | 1855 LayerTreeHost::InitParams params; |
1854 params.client = &client_; | 1856 params.client = &client_; |
1855 params.shared_bitmap_manager = &shared_bitmap_manager_; | 1857 params.shared_bitmap_manager = &shared_bitmap_manager_; |
1856 params.task_graph_runner = &task_graph_runner_; | 1858 params.task_graph_runner = &task_graph_runner_; |
1857 params.gpu_memory_buffer_manager = &gpu_memory_buffer_manager_; | 1859 params.gpu_memory_buffer_manager = &gpu_memory_buffer_manager_; |
1858 params.settings = &settings; | 1860 params.settings = &settings; |
1859 params.main_task_runner = base::ThreadTaskRunnerHandle::Get(); | 1861 params.main_task_runner = base::ThreadTaskRunnerHandle::Get(); |
1860 params.animation_host = | 1862 params.animation_host = |
1861 AnimationHost::CreateForTesting(ThreadInstance::MAIN); | 1863 AnimationHost::CreateForTesting(ThreadInstance::MAIN); |
1862 return LayerTreeHost::CreateSingleThreaded(&client_, ¶ms); | 1864 return LayerTreeHost::CreateSingleThreaded(&single_thread_client_, ¶ms); |
1863 } | 1865 } |
1864 | 1866 |
1865 private: | 1867 private: |
1866 FakeLayerTreeHostClient client_; | 1868 FakeLayerTreeHostClient client_; |
1869 StubLayerTreeHostSingleThreadClient single_thread_client_; | |
1867 TestSharedBitmapManager shared_bitmap_manager_; | 1870 TestSharedBitmapManager shared_bitmap_manager_; |
1868 TestTaskGraphRunner task_graph_runner_; | 1871 TestTaskGraphRunner task_graph_runner_; |
1869 TestGpuMemoryBufferManager gpu_memory_buffer_manager_; | 1872 TestGpuMemoryBufferManager gpu_memory_buffer_manager_; |
1870 }; | 1873 }; |
1871 | 1874 |
1872 void AssertLayerTreeHostMatchesForSubtree(Layer* layer, LayerTreeHost* host) { | 1875 void AssertLayerTreeHostMatchesForSubtree(Layer* layer, LayerTreeHost* host) { |
1873 EXPECT_EQ(host, layer->layer_tree_host()); | 1876 EXPECT_EQ(host, layer->layer_tree_host()); |
1874 | 1877 |
1875 for (size_t i = 0; i < layer->children().size(); ++i) | 1878 for (size_t i = 0; i < layer->children().size(); ++i) |
1876 AssertLayerTreeHostMatchesForSubtree(layer->children()[i].get(), host); | 1879 AssertLayerTreeHostMatchesForSubtree(layer->children()[i].get(), host); |
(...skipping 654 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2531 EXPECT_EQ(MutableProperty::kNone, impl_layer->mutable_properties()); | 2534 EXPECT_EQ(MutableProperty::kNone, impl_layer->mutable_properties()); |
2532 | 2535 |
2533 test_layer->PushPropertiesTo(impl_layer.get()); | 2536 test_layer->PushPropertiesTo(impl_layer.get()); |
2534 | 2537 |
2535 EXPECT_EQ(ElementId(2, 0), impl_layer->element_id()); | 2538 EXPECT_EQ(ElementId(2, 0), impl_layer->element_id()); |
2536 EXPECT_EQ(MutableProperty::kTransform, impl_layer->mutable_properties()); | 2539 EXPECT_EQ(MutableProperty::kTransform, impl_layer->mutable_properties()); |
2537 } | 2540 } |
2538 | 2541 |
2539 } // namespace | 2542 } // namespace |
2540 } // namespace cc | 2543 } // namespace cc |
OLD | NEW |