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/test/layer_tree_test.h" | 5 #include "cc/test/layer_tree_test.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/location.h" | 8 #include "base/location.h" |
9 #include "base/single_thread_task_runner.h" | 9 #include "base/single_thread_task_runner.h" |
10 #include "base/thread_task_runner_handle.h" | 10 #include "base/thread_task_runner_handle.h" |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 main_task_runner, | 74 main_task_runner, |
75 impl_task_runner, | 75 impl_task_runner, |
76 external_begin_frame_source.Pass())); | 76 external_begin_frame_source.Pass())); |
77 } | 77 } |
78 | 78 |
79 ~ThreadProxyForTest() override {} | 79 ~ThreadProxyForTest() override {} |
80 | 80 |
81 private: | 81 private: |
82 TestHooks* test_hooks_; | 82 TestHooks* test_hooks_; |
83 | 83 |
| 84 void WillBeginImplFrame(const BeginFrameArgs& args) override { |
| 85 ThreadProxy::WillBeginImplFrame(args); |
| 86 test_hooks_->WillBeginImplFrame(args); |
| 87 } |
| 88 |
84 void ScheduledActionSendBeginMainFrame() override { | 89 void ScheduledActionSendBeginMainFrame() override { |
85 test_hooks_->ScheduledActionWillSendBeginMainFrame(); | 90 test_hooks_->ScheduledActionWillSendBeginMainFrame(); |
86 ThreadProxy::ScheduledActionSendBeginMainFrame(); | 91 ThreadProxy::ScheduledActionSendBeginMainFrame(); |
87 test_hooks_->ScheduledActionSendBeginMainFrame(); | 92 test_hooks_->ScheduledActionSendBeginMainFrame(); |
88 } | 93 } |
89 | 94 |
90 DrawResult ScheduledActionDrawAndSwapIfPossible() override { | 95 DrawResult ScheduledActionDrawAndSwapIfPossible() override { |
91 DrawResult result = ThreadProxy::ScheduledActionDrawAndSwapIfPossible(); | 96 DrawResult result = ThreadProxy::ScheduledActionDrawAndSwapIfPossible(); |
92 test_hooks_->ScheduledActionDrawAndSwapIfPossible(); | 97 test_hooks_->ScheduledActionDrawAndSwapIfPossible(); |
93 return result; | 98 return result; |
(...skipping 17 matching lines...) Expand all Loading... |
111 void ScheduledActionPrepareTiles() override { | 116 void ScheduledActionPrepareTiles() override { |
112 ThreadProxy::ScheduledActionPrepareTiles(); | 117 ThreadProxy::ScheduledActionPrepareTiles(); |
113 test_hooks_->ScheduledActionPrepareTiles(); | 118 test_hooks_->ScheduledActionPrepareTiles(); |
114 } | 119 } |
115 | 120 |
116 void ScheduledActionInvalidateOutputSurface() override { | 121 void ScheduledActionInvalidateOutputSurface() override { |
117 ThreadProxy::ScheduledActionInvalidateOutputSurface(); | 122 ThreadProxy::ScheduledActionInvalidateOutputSurface(); |
118 test_hooks_->ScheduledActionInvalidateOutputSurface(); | 123 test_hooks_->ScheduledActionInvalidateOutputSurface(); |
119 } | 124 } |
120 | 125 |
121 void SendBeginMainFrameNotExpectedSoon() override { | |
122 ThreadProxy::SendBeginMainFrameNotExpectedSoon(); | |
123 test_hooks_->SendBeginMainFrameNotExpectedSoon(); | |
124 } | |
125 | |
126 ThreadProxyForTest( | 126 ThreadProxyForTest( |
127 TestHooks* test_hooks, | 127 TestHooks* test_hooks, |
128 LayerTreeHost* host, | 128 LayerTreeHost* host, |
129 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, | 129 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
130 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner, | 130 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner, |
131 scoped_ptr<BeginFrameSource> external_begin_frame_source) | 131 scoped_ptr<BeginFrameSource> external_begin_frame_source) |
132 : ThreadProxy(host, main_task_runner, | 132 : ThreadProxy(host, main_task_runner, |
133 impl_task_runner, | 133 impl_task_runner, |
134 external_begin_frame_source.Pass()), | 134 external_begin_frame_source.Pass()), |
135 test_hooks_(test_hooks) {} | 135 test_hooks_(test_hooks) {} |
(...skipping 11 matching lines...) Expand all Loading... |
147 return make_scoped_ptr(new SingleThreadProxyForTest( | 147 return make_scoped_ptr(new SingleThreadProxyForTest( |
148 test_hooks, host, client, main_task_runner, | 148 test_hooks, host, client, main_task_runner, |
149 external_begin_frame_source.Pass())); | 149 external_begin_frame_source.Pass())); |
150 } | 150 } |
151 | 151 |
152 ~SingleThreadProxyForTest() override {} | 152 ~SingleThreadProxyForTest() override {} |
153 | 153 |
154 private: | 154 private: |
155 TestHooks* test_hooks_; | 155 TestHooks* test_hooks_; |
156 | 156 |
| 157 void WillBeginImplFrame(const BeginFrameArgs& args) override { |
| 158 SingleThreadProxy::WillBeginImplFrame(args); |
| 159 test_hooks_->WillBeginImplFrame(args); |
| 160 } |
| 161 |
157 void ScheduledActionSendBeginMainFrame() override { | 162 void ScheduledActionSendBeginMainFrame() override { |
158 test_hooks_->ScheduledActionWillSendBeginMainFrame(); | 163 test_hooks_->ScheduledActionWillSendBeginMainFrame(); |
159 SingleThreadProxy::ScheduledActionSendBeginMainFrame(); | 164 SingleThreadProxy::ScheduledActionSendBeginMainFrame(); |
160 test_hooks_->ScheduledActionSendBeginMainFrame(); | 165 test_hooks_->ScheduledActionSendBeginMainFrame(); |
161 } | 166 } |
162 | 167 |
163 DrawResult ScheduledActionDrawAndSwapIfPossible() override { | 168 DrawResult ScheduledActionDrawAndSwapIfPossible() override { |
164 DrawResult result = | 169 DrawResult result = |
165 SingleThreadProxy::ScheduledActionDrawAndSwapIfPossible(); | 170 SingleThreadProxy::ScheduledActionDrawAndSwapIfPossible(); |
166 test_hooks_->ScheduledActionDrawAndSwapIfPossible(); | 171 test_hooks_->ScheduledActionDrawAndSwapIfPossible(); |
(...skipping 13 matching lines...) Expand all Loading... |
180 void ScheduledActionBeginOutputSurfaceCreation() override { | 185 void ScheduledActionBeginOutputSurfaceCreation() override { |
181 SingleThreadProxy::ScheduledActionBeginOutputSurfaceCreation(); | 186 SingleThreadProxy::ScheduledActionBeginOutputSurfaceCreation(); |
182 test_hooks_->ScheduledActionBeginOutputSurfaceCreation(); | 187 test_hooks_->ScheduledActionBeginOutputSurfaceCreation(); |
183 } | 188 } |
184 | 189 |
185 void ScheduledActionPrepareTiles() override { | 190 void ScheduledActionPrepareTiles() override { |
186 SingleThreadProxy::ScheduledActionPrepareTiles(); | 191 SingleThreadProxy::ScheduledActionPrepareTiles(); |
187 test_hooks_->ScheduledActionPrepareTiles(); | 192 test_hooks_->ScheduledActionPrepareTiles(); |
188 } | 193 } |
189 | 194 |
190 void ScheduledActionInvalidateOutputSurface() override { | |
191 SingleThreadProxy::ScheduledActionInvalidateOutputSurface(); | |
192 test_hooks_->ScheduledActionInvalidateOutputSurface(); | |
193 } | |
194 | |
195 void SendBeginMainFrameNotExpectedSoon() override { | |
196 SingleThreadProxy::SendBeginMainFrameNotExpectedSoon(); | |
197 test_hooks_->SendBeginMainFrameNotExpectedSoon(); | |
198 } | |
199 | |
200 SingleThreadProxyForTest( | 195 SingleThreadProxyForTest( |
201 TestHooks* test_hooks, | 196 TestHooks* test_hooks, |
202 LayerTreeHost* host, | 197 LayerTreeHost* host, |
203 LayerTreeHostSingleThreadClient* client, | 198 LayerTreeHostSingleThreadClient* client, |
204 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, | 199 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
205 scoped_ptr<BeginFrameSource> external_begin_frame_source) | 200 scoped_ptr<BeginFrameSource> external_begin_frame_source) |
206 : SingleThreadProxy(host, client, main_task_runner, | 201 : SingleThreadProxy(host, client, main_task_runner, |
207 external_begin_frame_source.Pass()), | 202 external_begin_frame_source.Pass()), |
208 test_hooks_(test_hooks) {} | 203 test_hooks_(test_hooks) {} |
209 }; | 204 }; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 scoped_ptr<ResourcePool>* staging_resource_pool) override { | 248 scoped_ptr<ResourcePool>* staging_resource_pool) override { |
254 test_hooks_->CreateResourceAndTileTaskWorkerPool( | 249 test_hooks_->CreateResourceAndTileTaskWorkerPool( |
255 this, tile_task_worker_pool, resource_pool, staging_resource_pool); | 250 this, tile_task_worker_pool, resource_pool, staging_resource_pool); |
256 } | 251 } |
257 | 252 |
258 void WillBeginImplFrame(const BeginFrameArgs& args) override { | 253 void WillBeginImplFrame(const BeginFrameArgs& args) override { |
259 LayerTreeHostImpl::WillBeginImplFrame(args); | 254 LayerTreeHostImpl::WillBeginImplFrame(args); |
260 test_hooks_->WillBeginImplFrameOnThread(this, args); | 255 test_hooks_->WillBeginImplFrameOnThread(this, args); |
261 } | 256 } |
262 | 257 |
263 void DidFinishImplFrame() override { | |
264 LayerTreeHostImpl::DidFinishImplFrame(); | |
265 test_hooks_->DidFinishImplFrameOnThread(this); | |
266 } | |
267 | |
268 void BeginMainFrameAborted(CommitEarlyOutReason reason) override { | 258 void BeginMainFrameAborted(CommitEarlyOutReason reason) override { |
269 LayerTreeHostImpl::BeginMainFrameAborted(reason); | 259 LayerTreeHostImpl::BeginMainFrameAborted(reason); |
270 test_hooks_->BeginMainFrameAbortedOnThread(this, reason); | 260 test_hooks_->BeginMainFrameAbortedOnThread(this, reason); |
271 } | 261 } |
272 | 262 |
273 void BeginCommit() override { | 263 void BeginCommit() override { |
274 LayerTreeHostImpl::BeginCommit(); | 264 LayerTreeHostImpl::BeginCommit(); |
275 test_hooks_->BeginCommitOnThread(this); | 265 test_hooks_->BeginCommitOnThread(this); |
276 } | 266 } |
277 | 267 |
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
715 gfx::ScaleSize(root_bounds, layer_tree_host_->device_scale_factor())); | 705 gfx::ScaleSize(root_bounds, layer_tree_host_->device_scale_factor())); |
716 layer_tree_host_->SetViewportSize(device_root_bounds); | 706 layer_tree_host_->SetViewportSize(device_root_bounds); |
717 } | 707 } |
718 | 708 |
719 void LayerTreeTest::Timeout() { | 709 void LayerTreeTest::Timeout() { |
720 timed_out_ = true; | 710 timed_out_ = true; |
721 EndTest(); | 711 EndTest(); |
722 } | 712 } |
723 | 713 |
724 void LayerTreeTest::RealEndTest() { | 714 void LayerTreeTest::RealEndTest() { |
725 // TODO(mithro): Make this method only end when not inside an impl frame. | |
726 if (layer_tree_host_ && !timed_out_ && | 715 if (layer_tree_host_ && !timed_out_ && |
727 proxy()->MainFrameWillHappenForTesting()) { | 716 proxy()->MainFrameWillHappenForTesting()) { |
728 main_task_runner_->PostTask( | 717 main_task_runner_->PostTask( |
729 FROM_HERE, | 718 FROM_HERE, |
730 base::Bind(&LayerTreeTest::RealEndTest, main_thread_weak_ptr_)); | 719 base::Bind(&LayerTreeTest::RealEndTest, main_thread_weak_ptr_)); |
731 return; | 720 return; |
732 } | 721 } |
733 | 722 |
734 base::MessageLoop::current()->Quit(); | 723 base::MessageLoop::current()->Quit(); |
735 } | 724 } |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
900 LayerTreeHost* LayerTreeTest::layer_tree_host() { | 889 LayerTreeHost* LayerTreeTest::layer_tree_host() { |
901 // We check for a null proxy here as we sometimes ask for the layer tree host | 890 // We check for a null proxy here as we sometimes ask for the layer tree host |
902 // when the proxy does not exist, often for checking settings after a test has | 891 // when the proxy does not exist, often for checking settings after a test has |
903 // completed. For example, LTHPixelResourceTest::RunPixelResourceTest. See | 892 // completed. For example, LTHPixelResourceTest::RunPixelResourceTest. See |
904 // elsewhere in this file for other examples. | 893 // elsewhere in this file for other examples. |
905 DCHECK(!proxy() || proxy()->IsMainThread() || proxy()->IsMainThreadBlocked()); | 894 DCHECK(!proxy() || proxy()->IsMainThread() || proxy()->IsMainThreadBlocked()); |
906 return layer_tree_host_.get(); | 895 return layer_tree_host_.get(); |
907 } | 896 } |
908 | 897 |
909 } // namespace cc | 898 } // namespace cc |
OLD | NEW |