Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(292)

Side by Side Diff: cc/test/layer_tree_test.cc

Issue 1417053005: cc: Split ThreadProxy into ProxyMain and ProxyImpl (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 12 matching lines...) Expand all
23 #include "cc/test/fake_layer_tree_host_client.h" 23 #include "cc/test/fake_layer_tree_host_client.h"
24 #include "cc/test/fake_output_surface.h" 24 #include "cc/test/fake_output_surface.h"
25 #include "cc/test/test_context_provider.h" 25 #include "cc/test/test_context_provider.h"
26 #include "cc/test/test_gpu_memory_buffer_manager.h" 26 #include "cc/test/test_gpu_memory_buffer_manager.h"
27 #include "cc/test/test_shared_bitmap_manager.h" 27 #include "cc/test/test_shared_bitmap_manager.h"
28 #include "cc/test/test_task_graph_runner.h" 28 #include "cc/test/test_task_graph_runner.h"
29 #include "cc/trees/layer_tree_host_client.h" 29 #include "cc/trees/layer_tree_host_client.h"
30 #include "cc/trees/layer_tree_host_impl.h" 30 #include "cc/trees/layer_tree_host_impl.h"
31 #include "cc/trees/layer_tree_host_single_thread_client.h" 31 #include "cc/trees/layer_tree_host_single_thread_client.h"
32 #include "cc/trees/layer_tree_impl.h" 32 #include "cc/trees/layer_tree_impl.h"
33 #include "cc/trees/proxy_impl.h"
34 #include "cc/trees/proxy_main.h"
33 #include "cc/trees/single_thread_proxy.h" 35 #include "cc/trees/single_thread_proxy.h"
34 #include "cc/trees/thread_proxy.h" 36 #include "cc/trees/threaded_channel.h"
35 #include "testing/gmock/include/gmock/gmock.h" 37 #include "testing/gmock/include/gmock/gmock.h"
36 #include "ui/gfx/geometry/size_conversions.h" 38 #include "ui/gfx/geometry/size_conversions.h"
37 39
38 namespace cc { 40 namespace cc {
39 41
40 void CreateVirtualViewportLayers(Layer* root_layer, 42 void CreateVirtualViewportLayers(Layer* root_layer,
41 scoped_refptr<Layer> outer_scroll_layer, 43 scoped_refptr<Layer> outer_scroll_layer,
42 const gfx::Size& inner_bounds, 44 const gfx::Size& inner_bounds,
43 const gfx::Size& outer_bounds, 45 const gfx::Size& outer_bounds,
44 LayerTreeHost* host, 46 LayerTreeHost* host,
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 } 107 }
106 108
107 void TestHooks::CreateResourceAndTileTaskWorkerPool( 109 void TestHooks::CreateResourceAndTileTaskWorkerPool(
108 LayerTreeHostImpl* host_impl, 110 LayerTreeHostImpl* host_impl,
109 scoped_ptr<TileTaskWorkerPool>* tile_task_worker_pool, 111 scoped_ptr<TileTaskWorkerPool>* tile_task_worker_pool,
110 scoped_ptr<ResourcePool>* resource_pool) { 112 scoped_ptr<ResourcePool>* resource_pool) {
111 host_impl->LayerTreeHostImpl::CreateResourceAndTileTaskWorkerPool( 113 host_impl->LayerTreeHostImpl::CreateResourceAndTileTaskWorkerPool(
112 tile_task_worker_pool, resource_pool); 114 tile_task_worker_pool, resource_pool);
113 } 115 }
114 116
115 // Adapts ThreadProxy for test. Injects test hooks for testing. 117 // Adapts ProxyImpl for test. Injects test hooks for testing.
Wez 2015/11/10 01:41:50 nit: Suggest "Creates a ProxyImpl that notifies th
Khushal 2015/11/11 04:17:47 Yeah, that makes it clearer. Done.
116 class ThreadProxyForTest : public ThreadProxy { 118 class ProxyImplForTest : public ProxyImpl {
117 public: 119 public:
118 static scoped_ptr<Proxy> Create( 120 static scoped_ptr<ProxyImpl> Create(
121 TestHooks* test_hooks,
122 ChannelImpl* channel_impl,
123 LayerTreeHost* layer_tree_host,
124 TaskRunnerProvider* task_runner_provider,
125 scoped_ptr<BeginFrameSource> external_begin_frame_source) {
126 return make_scoped_ptr(new ProxyImplForTest(
127 test_hooks, channel_impl, layer_tree_host, task_runner_provider,
128 external_begin_frame_source.Pass()));
129 }
130
131 private:
132 TestHooks* test_hooks_;
133
134 void ScheduledActionSendBeginMainFrame() override {
135 test_hooks_->ScheduledActionWillSendBeginMainFrame();
136 ProxyImpl::ScheduledActionSendBeginMainFrame();
137 test_hooks_->ScheduledActionSendBeginMainFrame();
138 }
139
140 DrawResult ScheduledActionDrawAndSwapIfPossible() override {
141 DrawResult result = ProxyImpl::ScheduledActionDrawAndSwapIfPossible();
142 test_hooks_->ScheduledActionDrawAndSwapIfPossible();
143 return result;
144 }
145
146 void ScheduledActionAnimate() override {
147 ProxyImpl::ScheduledActionAnimate();
148 test_hooks_->ScheduledActionAnimate();
149 }
150
151 void ScheduledActionCommit() override {
152 ProxyImpl::ScheduledActionCommit();
153 test_hooks_->ScheduledActionCommit();
154 }
155
156 void ScheduledActionBeginOutputSurfaceCreation() override {
157 ProxyImpl::ScheduledActionBeginOutputSurfaceCreation();
158 test_hooks_->ScheduledActionBeginOutputSurfaceCreation();
159 }
160
161 void ScheduledActionPrepareTiles() override {
162 ProxyImpl::ScheduledActionPrepareTiles();
163 test_hooks_->ScheduledActionPrepareTiles();
164 }
165
166 void ScheduledActionInvalidateOutputSurface() override {
167 ProxyImpl::ScheduledActionInvalidateOutputSurface();
168 test_hooks_->ScheduledActionInvalidateOutputSurface();
169 }
170
171 void SendBeginMainFrameNotExpectedSoon() override {
172 ProxyImpl::SendBeginMainFrameNotExpectedSoon();
173 test_hooks_->SendBeginMainFrameNotExpectedSoon();
174 }
175
176 void DidActivateSyncTree() override {
177 ProxyImpl::DidActivateSyncTree();
178 test_hooks_->DidActivateSyncTree();
179 }
180
181 void SetThrottleFrameProductionOnImpl(bool throttle) override {
182 test_hooks_->SetThrottleFrameProductionOnImpl(throttle);
183 ProxyImpl::SetThrottleFrameProductionOnImpl(throttle);
184 }
185
186 void InitializeOutputSurfaceOnImpl(OutputSurface* output_surface) override {
187 test_hooks_->InitializeOutputSurfaceOnImpl(output_surface);
188 ProxyImpl::InitializeOutputSurfaceOnImpl(output_surface);
189 }
190
191 void MainThreadHasStoppedFlingingOnImpl() override {
192 test_hooks_->MainThreadHasStoppedFlingingOnImpl();
193 ProxyImpl::MainThreadHasStoppedFlingingOnImpl();
194 }
195
196 void SetInputThrottledUntilCommitOnImpl(bool is_throttled) override {
197 test_hooks_->SetInputThrottledUntilCommitOnImpl(is_throttled);
198 ProxyImpl::SetInputThrottledUntilCommitOnImpl(is_throttled);
199 }
200
201 void UpdateTopControlsStateOnImpl(TopControlsState constraints,
202 TopControlsState current,
203 bool animate) override {
204 test_hooks_->UpdateTopControlsStateOnImpl(constraints, current, animate);
205 ProxyImpl::UpdateTopControlsStateOnImpl(constraints, current, animate);
206 }
207
208 void SetDeferCommitsOnImpl(bool defer_commits) const override {
209 test_hooks_->SetDeferCommitsOnImpl(defer_commits);
210 ProxyImpl::SetDeferCommitsOnImpl(defer_commits);
211 }
212
213 void BeginMainFrameAbortedOnImpl(CommitEarlyOutReason reason) override {
214 test_hooks_->BeginMainFrameAbortedOnImpl(reason);
215 ProxyImpl::BeginMainFrameAbortedOnImpl(reason);
216 }
217
218 void SetNeedsRedrawOnImpl(const gfx::Rect& damage_rect) override {
219 test_hooks_->SetNeedsRedrawOnImpl(damage_rect);
220 ProxyImpl::SetNeedsRedrawOnImpl(damage_rect);
221 };
222
223 void SetNeedsCommitOnImpl() override {
224 test_hooks_->SetNeedsCommitOnImpl();
225 ProxyImpl::SetNeedsCommitOnImpl();
226 }
227
228 void FinishAllRenderingOnImpl(CompletionEvent* completion) override {
229 test_hooks_->FinishAllRenderingOnImpl();
230 ProxyImpl::FinishAllRenderingOnImpl(completion);
231 };
232
233 void SetVisibleOnImpl(bool visible) override {
234 test_hooks_->SetVisibleOnImpl(visible);
235 ProxyImpl::SetVisibleOnImpl(visible);
236 }
237
238 void ReleaseOutputSurfaceOnImpl(CompletionEvent* completion) override {
239 test_hooks_->ReleaseOutputSurfaceOnImpl();
240 ProxyImpl::ReleaseOutputSurfaceOnImpl(completion);
241 }
242
243 void FinishGLOnImpl(CompletionEvent* completion) override {
244 test_hooks_->FinishGLOnImpl();
245 ProxyImpl::FinishGLOnImpl(completion);
246 }
247
248 void StartCommitOnImpl(CompletionEvent* completion,
249 LayerTreeHost* layer_tree_host,
250 bool hold_commit_for_activation) override {
251 test_hooks_->StartCommitOnImpl();
252 ProxyImpl::StartCommitOnImpl(completion, layer_tree_host,
253 hold_commit_for_activation);
254 }
255
256 void LayerTreeHostClosedOnImpl() override {
257 test_hooks_->WillCloseLayerTreeHostOnImpl();
258 ProxyImpl::LayerTreeHostClosedOnImpl();
259 }
260
261 ProxyImplForTest(TestHooks* test_hooks,
262 ChannelImpl* channel_impl,
263 LayerTreeHost* layer_tree_host,
264 TaskRunnerProvider* task_runner_provider,
265 scoped_ptr<BeginFrameSource> external_begin_frame_source)
266 : ProxyImpl(channel_impl,
267 layer_tree_host,
268 task_runner_provider,
269 external_begin_frame_source.Pass()),
270 test_hooks_(test_hooks) {}
271 };
272
273 // Injects ProxyImplForTest for testing.
Wez 2015/11/10 01:41:50 Suggest "ThreadedChannel that will notify |test_ho
Khushal 2015/11/11 04:17:47 Done.
274 class ThreadedChannelForTest : public ThreadedChannel {
275 public:
276 static scoped_ptr<ThreadedChannel> Create(TestHooks* test_hooks,
277 ProxyMain* proxy_main) {
278 return make_scoped_ptr(new ThreadedChannelForTest(test_hooks, proxy_main));
279 }
280
281 private:
282 TestHooks* test_hooks_;
283
284 scoped_ptr<ProxyImpl> CreateProxyImpl(
285 ChannelImpl* channel_impl,
286 LayerTreeHost* layer_tree_host,
287 TaskRunnerProvider* task_runner_provider,
288 scoped_ptr<BeginFrameSource> external_begin_frame_source) override {
289 return ProxyImplForTest::Create(test_hooks_, channel_impl, layer_tree_host,
290 task_runner_provider,
291 external_begin_frame_source.Pass());
292 }
293
294 ThreadedChannelForTest(TestHooks* test_hooks, ProxyMain* proxy_main)
295 : ThreadedChannel(proxy_main), test_hooks_(test_hooks) {}
296 };
297
298 // Adapts ProxyMain for test. Injects test hooks for testing.
Wez 2015/11/10 01:41:50 See suggestions above.
Khushal 2015/11/11 04:17:47 Done.
299 class ProxyMainForTest : public ProxyMain {
300 public:
301 static scoped_ptr<ProxyMain> Create(
119 TestHooks* test_hooks, 302 TestHooks* test_hooks,
120 LayerTreeHost* host, 303 LayerTreeHost* host,
121 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, 304 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner,
122 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner, 305 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner,
123 scoped_ptr<BeginFrameSource> external_begin_frame_source) { 306 scoped_ptr<BeginFrameSource> external_begin_frame_source) {
124 return make_scoped_ptr(new ThreadProxyForTest( 307 return make_scoped_ptr(new ProxyMainForTest(
125 test_hooks, 308 test_hooks, host, main_task_runner, impl_task_runner,
126 host,
127 main_task_runner,
128 impl_task_runner,
129 external_begin_frame_source.Pass())); 309 external_begin_frame_source.Pass()));
130 } 310 }
131 311
132 ~ThreadProxyForTest() override {} 312 ~ProxyMainForTest() override {}
133 313
134 private: 314 private:
135 TestHooks* test_hooks_; 315 TestHooks* test_hooks_;
136 316
137 void SetNeedsUpdateLayers() override { 317 void SetNeedsUpdateLayers() override {
138 ThreadProxy::SetNeedsUpdateLayers(); 318 ProxyMain::SetNeedsUpdateLayers();
139 test_hooks_->DidSetNeedsUpdateLayers(); 319 test_hooks_->DidSetNeedsUpdateLayers();
140 } 320 }
141 321
142 void ScheduledActionSendBeginMainFrame() override {
143 test_hooks_->ScheduledActionWillSendBeginMainFrame();
144 ThreadProxy::ScheduledActionSendBeginMainFrame();
145 test_hooks_->ScheduledActionSendBeginMainFrame();
146 }
147
148 DrawResult ScheduledActionDrawAndSwapIfPossible() override {
149 DrawResult result = ThreadProxy::ScheduledActionDrawAndSwapIfPossible();
150 test_hooks_->ScheduledActionDrawAndSwapIfPossible();
151 return result;
152 }
153
154 void ScheduledActionAnimate() override {
155 ThreadProxy::ScheduledActionAnimate();
156 test_hooks_->ScheduledActionAnimate();
157 }
158
159 void ScheduledActionCommit() override {
160 ThreadProxy::ScheduledActionCommit();
161 test_hooks_->ScheduledActionCommit();
162 }
163
164 void ScheduledActionBeginOutputSurfaceCreation() override {
165 ThreadProxy::ScheduledActionBeginOutputSurfaceCreation();
166 test_hooks_->ScheduledActionBeginOutputSurfaceCreation();
167 }
168
169 void ScheduledActionPrepareTiles() override {
170 ThreadProxy::ScheduledActionPrepareTiles();
171 test_hooks_->ScheduledActionPrepareTiles();
172 }
173
174 void ScheduledActionInvalidateOutputSurface() override {
175 ThreadProxy::ScheduledActionInvalidateOutputSurface();
176 test_hooks_->ScheduledActionInvalidateOutputSurface();
177 }
178
179 void SendBeginMainFrameNotExpectedSoon() override {
180 ThreadProxy::SendBeginMainFrameNotExpectedSoon();
181 test_hooks_->SendBeginMainFrameNotExpectedSoon();
182 }
183
184 void DidActivateSyncTree() override {
185 ThreadProxy::DidActivateSyncTree();
186 test_hooks_->DidActivateSyncTree();
187 }
188
189 void SetThrottleFrameProductionOnImpl(bool throttle) override {
190 test_hooks_->SetThrottleFrameProductionOnImpl(throttle);
191 ThreadProxy::SetThrottleFrameProductionOnImpl(throttle);
192 }
193
194 void InitializeOutputSurfaceOnImpl(OutputSurface* output_surface) override {
195 test_hooks_->InitializeOutputSurfaceOnImpl(output_surface);
196 ThreadProxy::InitializeOutputSurfaceOnImpl(output_surface);
197 }
198
199 void MainThreadHasStoppedFlingingOnImpl() override {
200 test_hooks_->MainThreadHasStoppedFlingingOnImpl();
201 ThreadProxy::MainThreadHasStoppedFlingingOnImpl();
202 }
203
204 void SetInputThrottledUntilCommitOnImpl(bool is_throttled) override {
205 test_hooks_->SetInputThrottledUntilCommitOnImpl(is_throttled);
206 ThreadProxy::SetInputThrottledUntilCommitOnImpl(is_throttled);
207 }
208
209 void UpdateTopControlsStateOnImpl(TopControlsState constraints,
210 TopControlsState current,
211 bool animate) override {
212 test_hooks_->UpdateTopControlsStateOnImpl(constraints, current, animate);
213 ThreadProxy::UpdateTopControlsStateOnImpl(constraints, current, animate);
214 }
215
216 void SetDeferCommitsOnImpl(bool defer_commits) const override {
217 test_hooks_->SetDeferCommitsOnImpl(defer_commits);
218 ThreadProxy::SetDeferCommitsOnImpl(defer_commits);
219 }
220
221 void BeginMainFrameAbortedOnImpl(CommitEarlyOutReason reason) override {
222 test_hooks_->BeginMainFrameAbortedOnImpl(reason);
223 ThreadProxy::BeginMainFrameAbortedOnImpl(reason);
224 }
225
226 void SetNeedsRedrawOnImpl(const gfx::Rect& damage_rect) override {
227 test_hooks_->SetNeedsRedrawOnImpl(damage_rect);
228 ThreadProxy::SetNeedsRedrawOnImpl(damage_rect);
229 };
230
231 void SetNeedsCommitOnImpl() override {
232 test_hooks_->SetNeedsCommitOnImpl();
233 ThreadProxy::SetNeedsCommitOnImpl();
234 }
235
236 void FinishAllRenderingOnImpl(CompletionEvent* completion) override {
237 test_hooks_->FinishAllRenderingOnImpl();
238 ThreadProxy::FinishAllRenderingOnImpl(completion);
239 };
240
241 void SetVisibleOnImpl(bool visible) override {
242 test_hooks_->SetVisibleOnImpl(visible);
243 ThreadProxy::SetVisibleOnImpl(visible);
244 }
245
246 void ReleaseOutputSurfaceOnImpl(CompletionEvent* completion) override {
247 test_hooks_->ReleaseOutputSurfaceOnImpl();
248 ThreadProxy::ReleaseOutputSurfaceOnImpl(completion);
249 }
250
251 void FinishGLOnImpl(CompletionEvent* completion) override {
252 test_hooks_->FinishGLOnImpl();
253 ThreadProxy::FinishGLOnImpl(completion);
254 }
255
256 void StartCommitOnImpl(CompletionEvent* completion,
257 LayerTreeHost* layer_tree_host,
258 bool hold_commit_for_activation) override {
259 test_hooks_->StartCommitOnImpl();
260 ThreadProxy::StartCommitOnImpl(completion, layer_tree_host,
261 hold_commit_for_activation);
262 }
263
264 void InitializeImplOnImpl(CompletionEvent* completion,
265 LayerTreeHost* layer_tree_host) override {
266 ThreadProxy::InitializeImplOnImpl(completion, layer_tree_host);
267 test_hooks_->InitializeImplOnImpl();
268 }
269
270 void LayerTreeHostClosedOnImpl(CompletionEvent* completion) override {
271 test_hooks_->WillCloseLayerTreeHostOnImpl();
272 ThreadProxy::LayerTreeHostClosedOnImpl(completion);
273 }
274
275 void DidCompleteSwapBuffers() override { 322 void DidCompleteSwapBuffers() override {
276 test_hooks_->ReceivedDidCompleteSwapBuffers(); 323 test_hooks_->ReceivedDidCompleteSwapBuffers();
277 ThreadProxy::DidCompleteSwapBuffers(); 324 ProxyMain::DidCompleteSwapBuffers();
278 } 325 }
279 326
280 void SetRendererCapabilitiesMainCopy( 327 void SetRendererCapabilitiesMainCopy(
281 const RendererCapabilities& capabilities) override { 328 const RendererCapabilities& capabilities) override {
282 test_hooks_->ReceivedSetRendererCapabilitiesMainCopy(capabilities); 329 test_hooks_->ReceivedSetRendererCapabilitiesMainCopy(capabilities);
283 ThreadProxy::SetRendererCapabilitiesMainCopy(capabilities); 330 ProxyMain::SetRendererCapabilitiesMainCopy(capabilities);
284 } 331 }
285 332
286 void BeginMainFrameNotExpectedSoon() override { 333 void BeginMainFrameNotExpectedSoon() override {
287 test_hooks_->ReceivedBeginMainFrameNotExpectedSoon(); 334 test_hooks_->ReceivedBeginMainFrameNotExpectedSoon();
288 ThreadProxy::BeginMainFrameNotExpectedSoon(); 335 ProxyMain::BeginMainFrameNotExpectedSoon();
289 } 336 }
290 337
291 void DidCommitAndDrawFrame() override { 338 void DidCommitAndDrawFrame() override {
292 test_hooks_->ReceivedDidCommitAndDrawFrame(); 339 test_hooks_->ReceivedDidCommitAndDrawFrame();
293 ThreadProxy::DidCommitAndDrawFrame(); 340 ProxyMain::DidCommitAndDrawFrame();
294 } 341 }
295 342
296 void SetAnimationEvents(scoped_ptr<AnimationEventsVector> events) override { 343 void SetAnimationEvents(scoped_ptr<AnimationEventsVector> events) override {
297 test_hooks_->ReceivedSetAnimationEvents(); 344 test_hooks_->ReceivedSetAnimationEvents();
298 ThreadProxy::SetAnimationEvents(events.Pass()); 345 ProxyMain::SetAnimationEvents(events.Pass());
299 } 346 }
300 347
301 void DidLoseOutputSurface() override { 348 void DidLoseOutputSurface() override {
302 test_hooks_->ReceivedDidLoseOutputSurface(); 349 test_hooks_->ReceivedDidLoseOutputSurface();
303 ThreadProxy::DidLoseOutputSurface(); 350 ProxyMain::DidLoseOutputSurface();
304 } 351 }
305 352
306 void RequestNewOutputSurface() override { 353 void RequestNewOutputSurface() override {
307 test_hooks_->ReceivedRequestNewOutputSurface(); 354 test_hooks_->ReceivedRequestNewOutputSurface();
308 ThreadProxy::RequestNewOutputSurface(); 355 ProxyMain::RequestNewOutputSurface();
309 } 356 }
310 357
311 void DidInitializeOutputSurface( 358 void DidInitializeOutputSurface(
312 bool success, 359 bool success,
313 const RendererCapabilities& capabilities) override { 360 const RendererCapabilities& capabilities) override {
314 test_hooks_->ReceivedDidInitializeOutputSurface(success, capabilities); 361 test_hooks_->ReceivedDidInitializeOutputSurface(success, capabilities);
315 ThreadProxy::DidInitializeOutputSurface(success, capabilities); 362 ProxyMain::DidInitializeOutputSurface(success, capabilities);
316 } 363 }
317 364
318 void DidCompletePageScaleAnimation() override { 365 void DidCompletePageScaleAnimation() override {
319 test_hooks_->ReceivedDidCompletePageScaleAnimation(); 366 test_hooks_->ReceivedDidCompletePageScaleAnimation();
320 ThreadProxy::DidCompletePageScaleAnimation(); 367 ProxyMain::DidCompletePageScaleAnimation();
321 } 368 }
322 369
323 void PostFrameTimingEventsOnMain( 370 void PostFrameTimingEventsOnMain(
324 scoped_ptr<FrameTimingTracker::CompositeTimingSet> composite_events, 371 scoped_ptr<FrameTimingTracker::CompositeTimingSet> composite_events,
325 scoped_ptr<FrameTimingTracker::MainFrameTimingSet> main_frame_events) 372 scoped_ptr<FrameTimingTracker::MainFrameTimingSet> main_frame_events)
326 override { 373 override {
327 test_hooks_->ReceivedPostFrameTimingEventsOnMain(); 374 test_hooks_->ReceivedPostFrameTimingEventsOnMain();
328 ThreadProxy::PostFrameTimingEventsOnMain(composite_events.Pass(), 375 ProxyMain::PostFrameTimingEventsOnMain(composite_events.Pass(),
329 main_frame_events.Pass()); 376 main_frame_events.Pass());
330 } 377 }
331 378
332 void BeginMainFrame(scoped_ptr<BeginMainFrameAndCommitState> 379 void BeginMainFrame(scoped_ptr<BeginMainFrameAndCommitState>
333 begin_main_frame_state) override { 380 begin_main_frame_state) override {
334 test_hooks_->ReceivedBeginMainFrame(); 381 test_hooks_->ReceivedBeginMainFrame();
335 ThreadProxy::BeginMainFrame(begin_main_frame_state.Pass()); 382 ProxyMain::BeginMainFrame(begin_main_frame_state.Pass());
336 }; 383 };
337 384
338 ThreadProxyForTest( 385 ProxyMainForTest(TestHooks* test_hooks,
339 TestHooks* test_hooks, 386 LayerTreeHost* host,
340 LayerTreeHost* host, 387 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner,
341 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, 388 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner,
342 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner, 389 scoped_ptr<BeginFrameSource> external_begin_frame_source)
343 scoped_ptr<BeginFrameSource> external_begin_frame_source) 390 : ProxyMain(host,
344 : ThreadProxy(host, main_task_runner, 391 main_task_runner,
345 impl_task_runner, 392 impl_task_runner,
346 external_begin_frame_source.Pass()), 393 external_begin_frame_source.Pass()),
347 test_hooks_(test_hooks) {} 394 test_hooks_(test_hooks) {}
348 }; 395 };
349 396
350 // Adapts ThreadProxy for test. Injects test hooks for testing. 397 // Adapts SingleThreadProxy for test. Injects test hooks for testing.
Wez 2015/11/10 01:41:50 See suggestions above re comment style.
Khushal 2015/11/11 04:17:47 Done.
351 class SingleThreadProxyForTest : public SingleThreadProxy { 398 class SingleThreadProxyForTest : public SingleThreadProxy {
352 public: 399 public:
353 static scoped_ptr<Proxy> Create( 400 static scoped_ptr<Proxy> Create(
354 TestHooks* test_hooks, 401 TestHooks* test_hooks,
355 LayerTreeHost* host, 402 LayerTreeHost* host,
356 LayerTreeHostSingleThreadClient* client, 403 LayerTreeHostSingleThreadClient* client,
357 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, 404 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner,
358 scoped_ptr<BeginFrameSource> external_begin_frame_source) { 405 scoped_ptr<BeginFrameSource> external_begin_frame_source) {
359 return make_scoped_ptr(new SingleThreadProxyForTest( 406 return make_scoped_ptr(new SingleThreadProxyForTest(
360 test_hooks, host, client, main_task_runner, 407 test_hooks, host, client, main_task_runner,
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
697 scoped_ptr<BeginFrameSource> external_begin_frame_source) { 744 scoped_ptr<BeginFrameSource> external_begin_frame_source) {
698 LayerTreeHost::InitParams params; 745 LayerTreeHost::InitParams params;
699 params.client = client; 746 params.client = client;
700 params.shared_bitmap_manager = shared_bitmap_manager; 747 params.shared_bitmap_manager = shared_bitmap_manager;
701 params.gpu_memory_buffer_manager = gpu_memory_buffer_manager; 748 params.gpu_memory_buffer_manager = gpu_memory_buffer_manager;
702 params.task_graph_runner = task_graph_runner; 749 params.task_graph_runner = task_graph_runner;
703 params.settings = &settings; 750 params.settings = &settings;
704 scoped_ptr<LayerTreeHostForTesting> layer_tree_host( 751 scoped_ptr<LayerTreeHostForTesting> layer_tree_host(
705 new LayerTreeHostForTesting(test_hooks, &params)); 752 new LayerTreeHostForTesting(test_hooks, &params));
706 if (impl_task_runner.get()) { 753 if (impl_task_runner.get()) {
707 layer_tree_host->InitializeForTesting( 754 scoped_ptr<ProxyMain> proxy_main = ProxyMainForTest::Create(
708 ThreadProxyForTest::Create(test_hooks, 755 test_hooks, layer_tree_host.get(), main_task_runner, impl_task_runner,
709 layer_tree_host.get(), 756 external_begin_frame_source.Pass());
710 main_task_runner, 757 scoped_ptr<ThreadedChannel> threaded_channel =
711 impl_task_runner, 758 ThreadedChannelForTest::Create(test_hooks, proxy_main.get());
712 external_begin_frame_source.Pass())); 759 proxy_main->SetChannel(threaded_channel.Pass());
760 layer_tree_host->InitializeForTesting(proxy_main.Pass());
713 } else { 761 } else {
714 layer_tree_host->InitializeForTesting( 762 layer_tree_host->InitializeForTesting(
715 SingleThreadProxyForTest::Create( 763 SingleThreadProxyForTest::Create(
716 test_hooks, 764 test_hooks,
717 layer_tree_host.get(), 765 layer_tree_host.get(),
718 client, 766 client,
719 main_task_runner, 767 main_task_runner,
720 external_begin_frame_source.Pass())); 768 external_begin_frame_source.Pass()));
721 } 769 }
722 return layer_tree_host.Pass(); 770 return layer_tree_host.Pass();
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after
1153 1201
1154 LayerTreeHost* LayerTreeTest::layer_tree_host() { 1202 LayerTreeHost* LayerTreeTest::layer_tree_host() {
1155 // We check for a null proxy here as we sometimes ask for the layer tree host 1203 // We check for a null proxy here as we sometimes ask for the layer tree host
1156 // when the proxy does not exist, often for checking settings after a test has 1204 // when the proxy does not exist, often for checking settings after a test has
1157 // completed. For example, LTHPixelResourceTest::RunPixelResourceTest. See 1205 // completed. For example, LTHPixelResourceTest::RunPixelResourceTest. See
1158 // elsewhere in this file for other examples. 1206 // elsewhere in this file for other examples.
1159 DCHECK(!proxy() || proxy()->IsMainThread() || proxy()->IsMainThreadBlocked()); 1207 DCHECK(!proxy() || proxy()->IsMainThread() || proxy()->IsMainThreadBlocked());
1160 return layer_tree_host_.get(); 1208 return layer_tree_host_.get();
1161 } 1209 }
1162 1210
1211 ProxyMain* LayerTreeTest::GetProxyMain() const {
1212 DCHECK(HasImplThread());
1213 return static_cast<ProxyMain*>(proxy());
1214 }
1215
1216 ProxyImpl* LayerTreeTest::GetProxyImpl() const {
1217 // Verify that the channel has been initialized since proxy impl exists in the
1218 // channel only after it is initialized.
1219 DCHECK(HasImplThread());
1220 DCHECK(GetProxyMain()->channel_main()->IsInitialized());
1221 ThreadedChannel* threaded_channel =
1222 static_cast<ThreadedChannel*>(GetProxyMain()->channel_main());
1223 return threaded_channel->proxy_impl();
1224 }
1225
1163 } // namespace cc 1226 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698