OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/animation/animation_host.h" | 5 #include "cc/animation/animation_host.h" |
6 | 6 |
7 #include "base/threading/thread_task_runner_handle.h" | 7 #include "base/threading/thread_task_runner_handle.h" |
8 #include "cc/animation/animation_id_provider.h" | 8 #include "cc/animation/animation_id_provider.h" |
9 #include "cc/animation/animation_player.h" | 9 #include "cc/animation/animation_player.h" |
10 #include "cc/animation/animation_timeline.h" | 10 #include "cc/animation/animation_timeline.h" |
11 #include "cc/debug/lap_timer.h" | 11 #include "cc/debug/lap_timer.h" |
12 #include "cc/layers/layer.h" | 12 #include "cc/layers/layer.h" |
13 #include "cc/test/fake_impl_task_runner_provider.h" | 13 #include "cc/test/fake_impl_task_runner_provider.h" |
14 #include "cc/test/fake_layer_tree_host.h" | 14 #include "cc/test/fake_layer_tree_host.h" |
15 #include "cc/test/fake_layer_tree_host_client.h" | 15 #include "cc/test/fake_layer_tree_host_client.h" |
16 #include "cc/test/fake_layer_tree_host_impl.h" | 16 #include "cc/test/fake_layer_tree_host_impl.h" |
| 17 #include "cc/test/stub_layer_tree_host_single_thread_client.h" |
17 #include "cc/test/test_task_graph_runner.h" | 18 #include "cc/test/test_task_graph_runner.h" |
18 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
19 #include "testing/perf/perf_test.h" | 20 #include "testing/perf/perf_test.h" |
20 | 21 |
21 namespace cc { | 22 namespace cc { |
22 | 23 |
23 class AnimationHostPerfTest : public testing::Test { | 24 class AnimationHostPerfTest : public testing::Test { |
24 protected: | 25 protected: |
25 void SetUp() override { | 26 void SetUp() override { |
26 LayerTreeSettings settings; | 27 LayerTreeSettings settings; |
27 layer_tree_host_ = | 28 layer_tree_host_ = |
28 FakeLayerTreeHost::Create(&fake_client_, &task_graph_runner_, settings); | 29 FakeLayerTreeHost::Create(&fake_client_, &task_graph_runner_, settings); |
29 layer_tree_host_->InitializeSingleThreaded( | 30 layer_tree_host_->InitializeSingleThreaded( |
30 &fake_client_, base::ThreadTaskRunnerHandle::Get(), nullptr); | 31 &single_thread_client_, base::ThreadTaskRunnerHandle::Get(), nullptr); |
31 | 32 |
32 root_layer_ = Layer::Create(); | 33 root_layer_ = Layer::Create(); |
33 layer_tree_host_->SetRootLayer(root_layer_); | 34 layer_tree_host_->SetRootLayer(root_layer_); |
34 | 35 |
35 root_layer_impl_ = layer_tree_host_->CommitAndCreateLayerImplTree(); | 36 root_layer_impl_ = layer_tree_host_->CommitAndCreateLayerImplTree(); |
36 } | 37 } |
37 | 38 |
38 void TearDown() override { | 39 void TearDown() override { |
39 root_layer_ = nullptr; | 40 root_layer_ = nullptr; |
40 root_layer_impl_ = nullptr; | 41 root_layer_impl_ = nullptr; |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 do { | 106 do { |
106 host()->PushPropertiesTo(host_impl()); | 107 host()->PushPropertiesTo(host_impl()); |
107 timer_.NextLap(); | 108 timer_.NextLap(); |
108 } while (!timer_.HasTimeLimitExpired()); | 109 } while (!timer_.HasTimeLimitExpired()); |
109 | 110 |
110 perf_test::PrintResult("push_properties_to", "", "", timer_.LapsPerSecond(), | 111 perf_test::PrintResult("push_properties_to", "", "", timer_.LapsPerSecond(), |
111 "runs/s", true); | 112 "runs/s", true); |
112 } | 113 } |
113 | 114 |
114 protected: | 115 protected: |
| 116 StubLayerTreeHostSingleThreadClient single_thread_client_; |
| 117 FakeLayerTreeHostClient fake_client_; |
115 std::unique_ptr<FakeLayerTreeHost> layer_tree_host_; | 118 std::unique_ptr<FakeLayerTreeHost> layer_tree_host_; |
116 scoped_refptr<Layer> root_layer_; | 119 scoped_refptr<Layer> root_layer_; |
117 LayerImpl* root_layer_impl_; | 120 LayerImpl* root_layer_impl_; |
118 | 121 |
119 LapTimer timer_; | 122 LapTimer timer_; |
120 TestTaskGraphRunner task_graph_runner_; | 123 TestTaskGraphRunner task_graph_runner_; |
121 FakeLayerTreeHostClient fake_client_; | |
122 }; | 124 }; |
123 | 125 |
124 TEST_F(AnimationHostPerfTest, Push1000PlayersPropertiesTo) { | 126 TEST_F(AnimationHostPerfTest, Push1000PlayersPropertiesTo) { |
125 CreatePlayers(1000); | 127 CreatePlayers(1000); |
126 DoTest(); | 128 DoTest(); |
127 } | 129 } |
128 | 130 |
129 TEST_F(AnimationHostPerfTest, Push10TimelinesPropertiesTo) { | 131 TEST_F(AnimationHostPerfTest, Push10TimelinesPropertiesTo) { |
130 CreateTimelines(10); | 132 CreateTimelines(10); |
131 DoTest(); | 133 DoTest(); |
132 } | 134 } |
133 | 135 |
134 TEST_F(AnimationHostPerfTest, Push1000TimelinesPropertiesTo) { | 136 TEST_F(AnimationHostPerfTest, Push1000TimelinesPropertiesTo) { |
135 CreateTimelines(1000); | 137 CreateTimelines(1000); |
136 DoTest(); | 138 DoTest(); |
137 } | 139 } |
138 | 140 |
139 } // namespace cc | 141 } // namespace cc |
OLD | NEW |