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

Side by Side Diff: cc/trees/thread_proxy.cc

Issue 1377063003: Split ThreadProxy methods to ProxyMain and ProxyImpl. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use completion events for blocking calls from ProxyMain. Created 5 years, 2 months 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
« no previous file with comments | « cc/trees/thread_proxy.h ('k') | cc/trees/threaded_channel.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/trees/thread_proxy.h" 5 #include "cc/trees/thread_proxy.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 9
10 #include "base/auto_reset.h" 10 #include "base/auto_reset.h"
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 main().channel_main = threaded_channel_.get(); 132 main().channel_main = threaded_channel_.get();
133 } 133 }
134 134
135 void ThreadProxy::FinishAllRendering() { 135 void ThreadProxy::FinishAllRendering() {
136 DCHECK(Proxy::IsMainThread()); 136 DCHECK(Proxy::IsMainThread());
137 DCHECK(!main().defer_commits); 137 DCHECK(!main().defer_commits);
138 138
139 // Make sure all GL drawing is finished on the impl thread. 139 // Make sure all GL drawing is finished on the impl thread.
140 DebugScopedSetMainThreadBlocked main_thread_blocked(this); 140 DebugScopedSetMainThreadBlocked main_thread_blocked(this);
141 CompletionEvent completion; 141 CompletionEvent completion;
142 Proxy::ImplThreadTaskRunner()->PostTask( 142 main().channel_main->FinishAllRenderingOnImpl(&completion);
vmpstr 2015/10/15 20:25:04 It's a bit awkward for me that channel_main refers
Khushal 2015/10/15 23:45:51 Since the class is split into the main and impl co
vmpstr 2015/10/17 00:05:51 I'm not sure, that's also very verbose. I guess we
Khushal 2015/10/17 02:02:48 main() wouldn't be there when ProxyMain comes. The
143 FROM_HERE,
144 base::Bind(&ThreadProxy::FinishAllRenderingOnImplThread,
145 impl_thread_weak_ptr_,
146 &completion));
147 completion.Wait(); 143 completion.Wait();
vmpstr 2015/10/15 20:25:04 The typical thing to do is create a completion / p
Khushal 2015/10/15 23:45:50 Right now completion events make it explicit to me
vmpstr 2015/10/17 00:05:51 Specifically what logic are you referring to? I mo
Khushal 2015/10/17 02:02:48 I like the idea of keeping it completely in the ch
148 } 144 }
149 145
150 bool ThreadProxy::IsStarted() const { 146 bool ThreadProxy::IsStarted() const {
151 DCHECK(Proxy::IsMainThread()); 147 DCHECK(Proxy::IsMainThread());
152 return main().started; 148 return main().started;
153 } 149 }
154 150
155 bool ThreadProxy::CommitToActiveTree() const { 151 bool ThreadProxy::CommitToActiveTree() const {
156 // With ThreadProxy, we use a pending tree and activate it once it's ready to 152 // With ThreadProxy, we use a pending tree and activate it once it's ready to
157 // draw to allow input to modify the active tree and draw during raster. 153 // draw to allow input to modify the active tree and draw during raster.
158 return false; 154 return false;
159 } 155 }
160 156
161 void ThreadProxy::SetVisible(bool visible) { 157 void ThreadProxy::SetVisible(bool visible) {
162 TRACE_EVENT1("cc", "ThreadProxy::SetVisible", "visible", visible); 158 TRACE_EVENT1("cc", "ThreadProxy::SetVisible", "visible", visible);
163 DebugScopedSetMainThreadBlocked main_thread_blocked(this); 159 DebugScopedSetMainThreadBlocked main_thread_blocked(this);
164 160
165 CompletionEvent completion; 161 CompletionEvent completion;
166 Proxy::ImplThreadTaskRunner()->PostTask( 162 main().channel_main->SetVisibleOnImpl(&completion, visible);
167 FROM_HERE,
168 base::Bind(&ThreadProxy::SetVisibleOnImplThread,
169 impl_thread_weak_ptr_,
170 &completion,
171 visible));
172 completion.Wait(); 163 completion.Wait();
173 } 164 }
174 165
175 void ThreadProxy::SetVisibleOnImplThread(CompletionEvent* completion, 166 void ThreadProxy::SetVisibleOnImpl(CompletionEvent* completion, bool visible) {
176 bool visible) {
177 TRACE_EVENT1("cc", "ThreadProxy::SetVisibleOnImplThread", "visible", visible); 167 TRACE_EVENT1("cc", "ThreadProxy::SetVisibleOnImplThread", "visible", visible);
178 impl().layer_tree_host_impl->SetVisible(visible); 168 impl().layer_tree_host_impl->SetVisible(visible);
179 impl().scheduler->SetVisible(visible); 169 impl().scheduler->SetVisible(visible);
180 completion->Signal(); 170 completion->Signal();
181 } 171 }
182 172
183 void ThreadProxy::SetThrottleFrameProduction(bool throttle) { 173 void ThreadProxy::SetThrottleFrameProduction(bool throttle) {
184 TRACE_EVENT1("cc", "ThreadProxy::SetThrottleFrameProduction", "throttle", 174 TRACE_EVENT1("cc", "ThreadProxy::SetThrottleFrameProduction", "throttle",
185 throttle); 175 throttle);
186 main().channel_main->SetThrottleFrameProductionOnImpl(throttle); 176 main().channel_main->SetThrottleFrameProductionOnImpl(throttle);
(...skipping 10 matching lines...) Expand all
197 DCHECK(IsMainThread()); 187 DCHECK(IsMainThread());
198 layer_tree_host()->DidLoseOutputSurface(); 188 layer_tree_host()->DidLoseOutputSurface();
199 } 189 }
200 190
201 void ThreadProxy::RequestNewOutputSurface() { 191 void ThreadProxy::RequestNewOutputSurface() {
202 DCHECK(IsMainThread()); 192 DCHECK(IsMainThread());
203 layer_tree_host()->RequestNewOutputSurface(); 193 layer_tree_host()->RequestNewOutputSurface();
204 } 194 }
205 195
206 void ThreadProxy::SetOutputSurface(OutputSurface* output_surface) { 196 void ThreadProxy::SetOutputSurface(OutputSurface* output_surface) {
207 Proxy::ImplThreadTaskRunner()->PostTask( 197 main().channel_main->InitializeOutputSurfaceOnImpl(output_surface);
208 FROM_HERE, base::Bind(&ThreadProxy::InitializeOutputSurfaceOnImplThread,
209 impl_thread_weak_ptr_, output_surface));
210 } 198 }
211 199
212 void ThreadProxy::ReleaseOutputSurface() { 200 void ThreadProxy::ReleaseOutputSurface() {
213 DCHECK(IsMainThread()); 201 DCHECK(IsMainThread());
214 DCHECK(layer_tree_host()->output_surface_lost()); 202 DCHECK(layer_tree_host()->output_surface_lost());
215 203
216 DebugScopedSetMainThreadBlocked main_thread_blocked(this); 204 DebugScopedSetMainThreadBlocked main_thread_blocked(this);
217 CompletionEvent completion; 205 CompletionEvent completion;
218 Proxy::ImplThreadTaskRunner()->PostTask( 206 main().channel_main->ReleaseOutputSurfaceOnImpl(&completion);
219 FROM_HERE, base::Bind(&ThreadProxy::ReleaseOutputSurfaceOnImplThread,
220 impl_thread_weak_ptr_, &completion));
221 completion.Wait(); 207 completion.Wait();
222 } 208 }
223 209
224 void ThreadProxy::DidInitializeOutputSurface( 210 void ThreadProxy::DidInitializeOutputSurface(
225 bool success, 211 bool success,
226 const RendererCapabilities& capabilities) { 212 const RendererCapabilities& capabilities) {
227 TRACE_EVENT0("cc", "ThreadProxy::DidInitializeOutputSurface"); 213 TRACE_EVENT0("cc", "ThreadProxy::DidInitializeOutputSurface");
228 DCHECK(IsMainThread()); 214 DCHECK(IsMainThread());
229 215
230 if (!success) { 216 if (!success) {
231 layer_tree_host()->DidFailToInitializeOutputSurface(); 217 layer_tree_host()->DidFailToInitializeOutputSurface();
232 return; 218 return;
233 } 219 }
234 main().renderer_capabilities_main_thread_copy = capabilities; 220 main().renderer_capabilities_main_thread_copy = capabilities;
235 layer_tree_host()->DidInitializeOutputSurface(); 221 layer_tree_host()->DidInitializeOutputSurface();
236 } 222 }
237 223
238 void ThreadProxy::SetRendererCapabilitiesMainThreadCopy( 224 void ThreadProxy::SetRendererCapabilitiesMainCopy(
239 const RendererCapabilities& capabilities) { 225 const RendererCapabilities& capabilities) {
240 main().renderer_capabilities_main_thread_copy = capabilities; 226 main().renderer_capabilities_main_thread_copy = capabilities;
241 } 227 }
242 228
243 bool ThreadProxy::SendCommitRequestToImplThreadIfNeeded( 229 bool ThreadProxy::SendCommitRequestToImplThreadIfNeeded(
244 CommitPipelineStage required_stage) { 230 CommitPipelineStage required_stage) {
245 DCHECK(IsMainThread()); 231 DCHECK(IsMainThread());
246 DCHECK_NE(NO_PIPELINE_STAGE, required_stage); 232 DCHECK_NE(NO_PIPELINE_STAGE, required_stage);
247 bool already_posted = 233 bool already_posted =
248 main().max_requested_pipeline_stage != NO_PIPELINE_STAGE; 234 main().max_requested_pipeline_stage != NO_PIPELINE_STAGE;
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 return; 287 return;
302 } 288 }
303 if (SendCommitRequestToImplThreadIfNeeded(COMMIT_PIPELINE_STAGE)) { 289 if (SendCommitRequestToImplThreadIfNeeded(COMMIT_PIPELINE_STAGE)) {
304 TRACE_EVENT_INSTANT0("cc", "ThreadProxy::SetNeedsCommit", 290 TRACE_EVENT_INSTANT0("cc", "ThreadProxy::SetNeedsCommit",
305 TRACE_EVENT_SCOPE_THREAD); 291 TRACE_EVENT_SCOPE_THREAD);
306 } 292 }
307 } 293 }
308 294
309 void ThreadProxy::UpdateRendererCapabilitiesOnImplThread() { 295 void ThreadProxy::UpdateRendererCapabilitiesOnImplThread() {
310 DCHECK(IsImplThread()); 296 DCHECK(IsImplThread());
311 Proxy::MainThreadTaskRunner()->PostTask( 297 impl().channel_impl->SetRendererCapabilitiesMainCopy(
312 FROM_HERE, 298 impl()
313 base::Bind(&ThreadProxy::SetRendererCapabilitiesMainThreadCopy, 299 .layer_tree_host_impl->GetRendererCapabilities()
314 main_thread_weak_ptr_, 300 .MainThreadCapabilities());
315 impl()
316 .layer_tree_host_impl->GetRendererCapabilities()
317 .MainThreadCapabilities()));
318 } 301 }
319 302
320 void ThreadProxy::DidLoseOutputSurfaceOnImplThread() { 303 void ThreadProxy::DidLoseOutputSurfaceOnImplThread() {
321 TRACE_EVENT0("cc", "ThreadProxy::DidLoseOutputSurfaceOnImplThread"); 304 TRACE_EVENT0("cc", "ThreadProxy::DidLoseOutputSurfaceOnImplThread");
322 DCHECK(IsImplThread()); 305 DCHECK(IsImplThread());
323 Proxy::MainThreadTaskRunner()->PostTask( 306 impl().channel_impl->DidLoseOutputSurface();
324 FROM_HERE,
325 base::Bind(&ThreadProxy::DidLoseOutputSurface, main_thread_weak_ptr_));
326 impl().scheduler->DidLoseOutputSurface(); 307 impl().scheduler->DidLoseOutputSurface();
327 } 308 }
328 309
329 void ThreadProxy::CommitVSyncParameters(base::TimeTicks timebase, 310 void ThreadProxy::CommitVSyncParameters(base::TimeTicks timebase,
330 base::TimeDelta interval) { 311 base::TimeDelta interval) {
331 impl().scheduler->CommitVSyncParameters(timebase, interval); 312 impl().scheduler->CommitVSyncParameters(timebase, interval);
332 } 313 }
333 314
334 void ThreadProxy::SetEstimatedParentDrawTime(base::TimeDelta draw_time) { 315 void ThreadProxy::SetEstimatedParentDrawTime(base::TimeDelta draw_time) {
335 impl().scheduler->SetEstimatedParentDrawTime(draw_time); 316 impl().scheduler->SetEstimatedParentDrawTime(draw_time);
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 // In tests the layer tree is destroyed after the scheduler is. 376 // In tests the layer tree is destroyed after the scheduler is.
396 if (impl().scheduler) 377 if (impl().scheduler)
397 impl().scheduler->SetVideoNeedsBeginFrames(needs_begin_frames); 378 impl().scheduler->SetVideoNeedsBeginFrames(needs_begin_frames);
398 } 379 }
399 380
400 void ThreadProxy::PostAnimationEventsToMainThreadOnImplThread( 381 void ThreadProxy::PostAnimationEventsToMainThreadOnImplThread(
401 scoped_ptr<AnimationEventsVector> events) { 382 scoped_ptr<AnimationEventsVector> events) {
402 TRACE_EVENT0("cc", 383 TRACE_EVENT0("cc",
403 "ThreadProxy::PostAnimationEventsToMainThreadOnImplThread"); 384 "ThreadProxy::PostAnimationEventsToMainThreadOnImplThread");
404 DCHECK(IsImplThread()); 385 DCHECK(IsImplThread());
405 Proxy::MainThreadTaskRunner()->PostTask( 386 impl().channel_impl->SetAnimationEvents(events.Pass());
406 FROM_HERE,
407 base::Bind(&ThreadProxy::SetAnimationEvents,
408 main_thread_weak_ptr_,
409 base::Passed(&events)));
410 } 387 }
411 388
412 bool ThreadProxy::IsInsideDraw() { return impl().inside_draw; } 389 bool ThreadProxy::IsInsideDraw() { return impl().inside_draw; }
413 390
414 void ThreadProxy::SetNeedsRedraw(const gfx::Rect& damage_rect) { 391 void ThreadProxy::SetNeedsRedraw(const gfx::Rect& damage_rect) {
415 TRACE_EVENT0("cc", "ThreadProxy::SetNeedsRedraw"); 392 TRACE_EVENT0("cc", "ThreadProxy::SetNeedsRedraw");
416 DCHECK(IsMainThread()); 393 DCHECK(IsMainThread());
417 Proxy::ImplThreadTaskRunner()->PostTask( 394 Proxy::ImplThreadTaskRunner()->PostTask(
vmpstr 2015/10/15 20:25:04 Why did you only do this for a particular set of P
Khushal 2015/10/15 23:45:50 I missed this one. Will change it in this patch.
vmpstr 2015/10/17 00:05:51 You can probably do all of the call sites that are
Khushal 2015/10/17 02:02:48 Done. The only calls left are for initializing and
418 FROM_HERE, 395 FROM_HERE,
419 base::Bind(&ThreadProxy::SetNeedsRedrawRectOnImplThread, 396 base::Bind(&ThreadProxy::SetNeedsRedrawRectOnImplThread,
420 impl_thread_weak_ptr_, 397 impl_thread_weak_ptr_,
421 damage_rect)); 398 damage_rect));
422 } 399 }
423 400
424 void ThreadProxy::SetNextCommitWaitsForActivation() { 401 void ThreadProxy::SetNextCommitWaitsForActivation() {
425 DCHECK(IsMainThread()); 402 DCHECK(IsMainThread());
426 DCHECK(!blocked_main().main_thread_inside_commit); 403 DCHECK(!blocked_main().main_thread_inside_commit);
427 blocked_main().commit_waits_for_activation = true; 404 blocked_main().commit_waits_for_activation = true;
428 } 405 }
429 406
430 void ThreadProxy::SetDeferCommits(bool defer_commits) { 407 void ThreadProxy::SetDeferCommits(bool defer_commits) {
431 DCHECK(IsMainThread()); 408 DCHECK(IsMainThread());
432 if (main().defer_commits == defer_commits) 409 if (main().defer_commits == defer_commits)
433 return; 410 return;
434 411
435 main().defer_commits = defer_commits; 412 main().defer_commits = defer_commits;
436 if (main().defer_commits) 413 if (main().defer_commits)
437 TRACE_EVENT_ASYNC_BEGIN0("cc", "ThreadProxy::SetDeferCommits", this); 414 TRACE_EVENT_ASYNC_BEGIN0("cc", "ThreadProxy::SetDeferCommits", this);
438 else 415 else
439 TRACE_EVENT_ASYNC_END0("cc", "ThreadProxy::SetDeferCommits", this); 416 TRACE_EVENT_ASYNC_END0("cc", "ThreadProxy::SetDeferCommits", this);
440 417
441 Proxy::ImplThreadTaskRunner()->PostTask( 418 main().channel_main->SetDeferCommitsOnImpl(defer_commits);
442 FROM_HERE,
443 base::Bind(&ThreadProxy::SetDeferCommitsOnImplThread,
444 impl_thread_weak_ptr_,
445 defer_commits));
446 } 419 }
447 420
448 void ThreadProxy::SetDeferCommitsOnImplThread(bool defer_commits) const { 421 void ThreadProxy::SetDeferCommitsOnImpl(bool defer_commits) {
449 DCHECK(IsImplThread()); 422 DCHECK(IsImplThread());
450 impl().scheduler->SetDeferCommits(defer_commits); 423 impl().scheduler->SetDeferCommits(defer_commits);
451 } 424 }
452 425
453 bool ThreadProxy::CommitRequested() const { 426 bool ThreadProxy::CommitRequested() const {
454 DCHECK(IsMainThread()); 427 DCHECK(IsMainThread());
455 // TODO(skyostil): Split this into something like CommitRequested() and 428 // TODO(skyostil): Split this into something like CommitRequested() and
456 // CommitInProgress(). 429 // CommitInProgress().
457 return main().current_pipeline_stage != NO_PIPELINE_STAGE || 430 return main().current_pipeline_stage != NO_PIPELINE_STAGE ||
458 main().max_requested_pipeline_stage >= COMMIT_PIPELINE_STAGE; 431 main().max_requested_pipeline_stage >= COMMIT_PIPELINE_STAGE;
(...skipping 22 matching lines...) Expand all
481 } 454 }
482 455
483 void ThreadProxy::SetNeedsRedrawRectOnImplThread(const gfx::Rect& damage_rect) { 456 void ThreadProxy::SetNeedsRedrawRectOnImplThread(const gfx::Rect& damage_rect) {
484 DCHECK(IsImplThread()); 457 DCHECK(IsImplThread());
485 impl().layer_tree_host_impl->SetViewportDamage(damage_rect); 458 impl().layer_tree_host_impl->SetViewportDamage(damage_rect);
486 SetNeedsRedrawOnImplThread(); 459 SetNeedsRedrawOnImplThread();
487 } 460 }
488 461
489 void ThreadProxy::MainThreadHasStoppedFlinging() { 462 void ThreadProxy::MainThreadHasStoppedFlinging() {
490 DCHECK(IsMainThread()); 463 DCHECK(IsMainThread());
491 Proxy::ImplThreadTaskRunner()->PostTask( 464 main().channel_main->MainThreadHasStoppedFlingingOnImpl();
492 FROM_HERE,
493 base::Bind(&ThreadProxy::MainThreadHasStoppedFlingingOnImplThread,
494 impl_thread_weak_ptr_));
495 } 465 }
496 466
497 void ThreadProxy::MainThreadHasStoppedFlingingOnImplThread() { 467 void ThreadProxy::MainThreadHasStoppedFlingingOnImpl() {
498 DCHECK(IsImplThread()); 468 DCHECK(IsImplThread());
499 impl().layer_tree_host_impl->MainThreadHasStoppedFlinging(); 469 impl().layer_tree_host_impl->MainThreadHasStoppedFlinging();
500 } 470 }
501 471
502 void ThreadProxy::NotifyInputThrottledUntilCommit() { 472 void ThreadProxy::NotifyInputThrottledUntilCommit() {
503 DCHECK(IsMainThread()); 473 DCHECK(IsMainThread());
504 Proxy::ImplThreadTaskRunner()->PostTask( 474 main().channel_main->SetInputThrottledUntilCommitOnImpl(true);
505 FROM_HERE,
506 base::Bind(&ThreadProxy::SetInputThrottledUntilCommitOnImplThread,
507 impl_thread_weak_ptr_,
508 true));
509 } 475 }
510 476
511 void ThreadProxy::SetInputThrottledUntilCommitOnImplThread(bool is_throttled) { 477 void ThreadProxy::SetInputThrottledUntilCommitOnImpl(bool is_throttled) {
512 DCHECK(IsImplThread()); 478 DCHECK(IsImplThread());
513 if (is_throttled == impl().input_throttled_until_commit) 479 if (is_throttled == impl().input_throttled_until_commit)
514 return; 480 return;
515 impl().input_throttled_until_commit = is_throttled; 481 impl().input_throttled_until_commit = is_throttled;
516 RenewTreePriority(); 482 RenewTreePriority();
517 } 483 }
518 484
519 LayerTreeHost* ThreadProxy::layer_tree_host() { 485 LayerTreeHost* ThreadProxy::layer_tree_host() {
520 return blocked_main().layer_tree_host; 486 return blocked_main().layer_tree_host;
521 } 487 }
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
577 TRACE_EVENT0("cc", "ThreadProxy::Stop"); 543 TRACE_EVENT0("cc", "ThreadProxy::Stop");
578 DCHECK(IsMainThread()); 544 DCHECK(IsMainThread());
579 DCHECK(main().started); 545 DCHECK(main().started);
580 546
581 // Synchronously finishes pending GL operations and deletes the impl. 547 // Synchronously finishes pending GL operations and deletes the impl.
582 // The two steps are done as separate post tasks, so that tasks posted 548 // The two steps are done as separate post tasks, so that tasks posted
583 // by the GL implementation due to the Finish can be executed by the 549 // by the GL implementation due to the Finish can be executed by the
584 // renderer before shutting it down. 550 // renderer before shutting it down.
585 { 551 {
586 DebugScopedSetMainThreadBlocked main_thread_blocked(this); 552 DebugScopedSetMainThreadBlocked main_thread_blocked(this);
587
588 CompletionEvent completion; 553 CompletionEvent completion;
589 Proxy::ImplThreadTaskRunner()->PostTask( 554 main().channel_main->FinishGLOnImpl(&completion);
590 FROM_HERE,
591 base::Bind(&ThreadProxy::FinishGLOnImplThread,
592 impl_thread_weak_ptr_,
593 &completion));
594 completion.Wait(); 555 completion.Wait();
595 } 556 }
596 { 557 {
597 DebugScopedSetMainThreadBlocked main_thread_blocked(this); 558 DebugScopedSetMainThreadBlocked main_thread_blocked(this);
598 559
599 CompletionEvent completion; 560 CompletionEvent completion;
600 Proxy::ImplThreadTaskRunner()->PostTask( 561 Proxy::ImplThreadTaskRunner()->PostTask(
601 FROM_HERE, 562 FROM_HERE,
602 base::Bind(&ThreadProxy::LayerTreeHostClosedOnImplThread, 563 base::Bind(&ThreadProxy::LayerTreeHostClosedOnImplThread,
603 impl_thread_weak_ptr_, 564 impl_thread_weak_ptr_,
604 &completion)); 565 &completion));
605 completion.Wait(); 566 completion.Wait();
606 } 567 }
607 568
608 main().weak_factory.InvalidateWeakPtrs(); 569 main().weak_factory.InvalidateWeakPtrs();
609 blocked_main().layer_tree_host = NULL; 570 blocked_main().layer_tree_host = NULL;
610 main().started = false; 571 main().started = false;
611 } 572 }
612 573
613 bool ThreadProxy::SupportsImplScrolling() const { 574 bool ThreadProxy::SupportsImplScrolling() const {
614 return true; 575 return true;
615 } 576 }
616 577
617 void ThreadProxy::FinishAllRenderingOnImplThread(CompletionEvent* completion) { 578 void ThreadProxy::FinishAllRenderingOnImpl(CompletionEvent* completion) {
618 TRACE_EVENT0("cc", "ThreadProxy::FinishAllRenderingOnImplThread"); 579 TRACE_EVENT0("cc", "ThreadProxy::FinishAllRenderingOnImplThread");
619 DCHECK(IsImplThread()); 580 DCHECK(IsImplThread());
620 impl().layer_tree_host_impl->FinishAllRendering(); 581 impl().layer_tree_host_impl->FinishAllRendering();
621 completion->Signal(); 582 completion->Signal();
622 } 583 }
623 584
624 void ThreadProxy::ScheduledActionSendBeginMainFrame() { 585 void ThreadProxy::ScheduledActionSendBeginMainFrame() {
625 unsigned int begin_frame_id = nextBeginFrameId++; 586 unsigned int begin_frame_id = nextBeginFrameId++;
626 benchmark_instrumentation::ScopedBeginFrameTask begin_frame_task( 587 benchmark_instrumentation::ScopedBeginFrameTask begin_frame_task(
627 benchmark_instrumentation::kSendBeginFrame, begin_frame_id); 588 benchmark_instrumentation::kSendBeginFrame, begin_frame_id);
(...skipping 15 matching lines...) Expand all
643 Proxy::MainThreadTaskRunner()->PostTask( 604 Proxy::MainThreadTaskRunner()->PostTask(
644 FROM_HERE, 605 FROM_HERE,
645 base::Bind(&ThreadProxy::BeginMainFrame, 606 base::Bind(&ThreadProxy::BeginMainFrame,
646 main_thread_weak_ptr_, 607 main_thread_weak_ptr_,
647 base::Passed(&begin_main_frame_state))); 608 base::Passed(&begin_main_frame_state)));
648 devtools_instrumentation::DidRequestMainThreadFrame( 609 devtools_instrumentation::DidRequestMainThreadFrame(
649 impl().layer_tree_host_id); 610 impl().layer_tree_host_id);
650 } 611 }
651 612
652 void ThreadProxy::SendBeginMainFrameNotExpectedSoon() { 613 void ThreadProxy::SendBeginMainFrameNotExpectedSoon() {
653 Proxy::MainThreadTaskRunner()->PostTask( 614 impl().channel_impl->BeginMainFrameNotExpectedSoon();
654 FROM_HERE, base::Bind(&ThreadProxy::BeginMainFrameNotExpectedSoon,
655 main_thread_weak_ptr_));
656 } 615 }
657 616
658 void ThreadProxy::BeginMainFrame( 617 void ThreadProxy::BeginMainFrame(
659 scoped_ptr<BeginMainFrameAndCommitState> begin_main_frame_state) { 618 scoped_ptr<BeginMainFrameAndCommitState> begin_main_frame_state) {
660 benchmark_instrumentation::ScopedBeginFrameTask begin_frame_task( 619 benchmark_instrumentation::ScopedBeginFrameTask begin_frame_task(
661 benchmark_instrumentation::kDoBeginFrame, 620 benchmark_instrumentation::kDoBeginFrame,
662 begin_main_frame_state->begin_frame_id); 621 begin_main_frame_state->begin_frame_id);
663 TRACE_EVENT_SYNTHETIC_DELAY_BEGIN("cc.BeginMainFrame"); 622 TRACE_EVENT_SYNTHETIC_DELAY_BEGIN("cc.BeginMainFrame");
664 DCHECK(IsMainThread()); 623 DCHECK(IsMainThread());
665 DCHECK_EQ(NO_PIPELINE_STAGE, main().current_pipeline_stage); 624 DCHECK_EQ(NO_PIPELINE_STAGE, main().current_pipeline_stage);
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
809 void ThreadProxy::BeginMainFrameAbortedOnImplThread( 768 void ThreadProxy::BeginMainFrameAbortedOnImplThread(
810 CommitEarlyOutReason reason) { 769 CommitEarlyOutReason reason) {
811 TRACE_EVENT1("cc", "ThreadProxy::BeginMainFrameAbortedOnImplThread", "reason", 770 TRACE_EVENT1("cc", "ThreadProxy::BeginMainFrameAbortedOnImplThread", "reason",
812 CommitEarlyOutReasonToString(reason)); 771 CommitEarlyOutReasonToString(reason));
813 DCHECK(IsImplThread()); 772 DCHECK(IsImplThread());
814 DCHECK(impl().scheduler); 773 DCHECK(impl().scheduler);
815 DCHECK(impl().scheduler->CommitPending()); 774 DCHECK(impl().scheduler->CommitPending());
816 DCHECK(!impl().layer_tree_host_impl->pending_tree()); 775 DCHECK(!impl().layer_tree_host_impl->pending_tree());
817 776
818 if (CommitEarlyOutHandledCommit(reason)) { 777 if (CommitEarlyOutHandledCommit(reason)) {
819 SetInputThrottledUntilCommitOnImplThread(false); 778 SetInputThrottledUntilCommitOnImpl(false);
820 impl().last_processed_begin_main_frame_args = 779 impl().last_processed_begin_main_frame_args =
821 impl().last_begin_main_frame_args; 780 impl().last_begin_main_frame_args;
822 } 781 }
823 impl().layer_tree_host_impl->BeginMainFrameAborted(reason); 782 impl().layer_tree_host_impl->BeginMainFrameAborted(reason);
824 impl().scheduler->BeginMainFrameAborted(reason); 783 impl().scheduler->BeginMainFrameAborted(reason);
825 } 784 }
826 785
827 void ThreadProxy::ScheduledActionAnimate() { 786 void ThreadProxy::ScheduledActionAnimate() {
828 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionAnimate"); 787 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionAnimate");
829 DCHECK(IsImplThread()); 788 DCHECK(IsImplThread());
(...skipping 28 matching lines...) Expand all
858 impl().commit_completion_event->Signal(); 817 impl().commit_completion_event->Signal();
859 impl().commit_completion_event = NULL; 818 impl().commit_completion_event = NULL;
860 } 819 }
861 820
862 impl().scheduler->DidCommit(); 821 impl().scheduler->DidCommit();
863 822
864 // Delay this step until afer the main thread has been released as it's 823 // Delay this step until afer the main thread has been released as it's
865 // often a good bit of work to update the tree and prepare the new frame. 824 // often a good bit of work to update the tree and prepare the new frame.
866 impl().layer_tree_host_impl->CommitComplete(); 825 impl().layer_tree_host_impl->CommitComplete();
867 826
868 SetInputThrottledUntilCommitOnImplThread(false); 827 SetInputThrottledUntilCommitOnImpl(false);
869 828
870 impl().next_frame_is_newly_committed_frame = true; 829 impl().next_frame_is_newly_committed_frame = true;
871 } 830 }
872 831
873 void ThreadProxy::ScheduledActionActivateSyncTree() { 832 void ThreadProxy::ScheduledActionActivateSyncTree() {
874 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionActivateSyncTree"); 833 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionActivateSyncTree");
875 DCHECK(IsImplThread()); 834 DCHECK(IsImplThread());
876 impl().layer_tree_host_impl->ActivateSyncTree(); 835 impl().layer_tree_host_impl->ActivateSyncTree();
877 } 836 }
878 837
879 void ThreadProxy::ScheduledActionBeginOutputSurfaceCreation() { 838 void ThreadProxy::ScheduledActionBeginOutputSurfaceCreation() {
880 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionBeginOutputSurfaceCreation"); 839 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionBeginOutputSurfaceCreation");
881 DCHECK(IsImplThread()); 840 DCHECK(IsImplThread());
882 Proxy::MainThreadTaskRunner()->PostTask( 841 impl().channel_impl->RequestNewOutputSurface();
883 FROM_HERE,
884 base::Bind(&ThreadProxy::RequestNewOutputSurface, main_thread_weak_ptr_));
885 } 842 }
886 843
887 DrawResult ThreadProxy::DrawSwapInternal(bool forced_draw) { 844 DrawResult ThreadProxy::DrawSwapInternal(bool forced_draw) {
888 TRACE_EVENT_SYNTHETIC_DELAY("cc.DrawAndSwap"); 845 TRACE_EVENT_SYNTHETIC_DELAY("cc.DrawAndSwap");
889 DrawResult result; 846 DrawResult result;
890 847
891 DCHECK(IsImplThread()); 848 DCHECK(IsImplThread());
892 DCHECK(impl().layer_tree_host_impl.get()); 849 DCHECK(impl().layer_tree_host_impl.get());
893 850
894 base::AutoReset<bool> mark_inside(&impl().inside_draw, true); 851 base::AutoReset<bool> mark_inside(&impl().inside_draw, true);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
930 887
931 bool start_ready_animations = draw_frame; 888 bool start_ready_animations = draw_frame;
932 impl().layer_tree_host_impl->UpdateAnimationState(start_ready_animations); 889 impl().layer_tree_host_impl->UpdateAnimationState(start_ready_animations);
933 890
934 if (draw_frame) 891 if (draw_frame)
935 impl().layer_tree_host_impl->SwapBuffers(frame); 892 impl().layer_tree_host_impl->SwapBuffers(frame);
936 893
937 // Tell the main thread that the the newly-commited frame was drawn. 894 // Tell the main thread that the the newly-commited frame was drawn.
938 if (impl().next_frame_is_newly_committed_frame) { 895 if (impl().next_frame_is_newly_committed_frame) {
939 impl().next_frame_is_newly_committed_frame = false; 896 impl().next_frame_is_newly_committed_frame = false;
940 Proxy::MainThreadTaskRunner()->PostTask( 897 impl().channel_impl->DidCommitAndDrawFrame();
941 FROM_HERE,
942 base::Bind(&ThreadProxy::DidCommitAndDrawFrame, main_thread_weak_ptr_));
943 } 898 }
944 899
945 DCHECK_NE(INVALID_RESULT, result); 900 DCHECK_NE(INVALID_RESULT, result);
946 return result; 901 return result;
947 } 902 }
948 903
949 void ThreadProxy::ScheduledActionPrepareTiles() { 904 void ThreadProxy::ScheduledActionPrepareTiles() {
950 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionPrepareTiles"); 905 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionPrepareTiles");
951 impl().layer_tree_host_impl->PrepareTiles(); 906 impl().layer_tree_host_impl->PrepareTiles();
952 } 907 }
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
1026 this, scheduler_settings, impl().layer_tree_host_id, 981 this, scheduler_settings, impl().layer_tree_host_id,
1027 ImplThreadTaskRunner(), impl().external_begin_frame_source.get(), 982 ImplThreadTaskRunner(), impl().external_begin_frame_source.get(),
1028 compositor_timing_history.Pass()); 983 compositor_timing_history.Pass());
1029 984
1030 DCHECK_EQ(impl().scheduler->visible(), 985 DCHECK_EQ(impl().scheduler->visible(),
1031 impl().layer_tree_host_impl->visible()); 986 impl().layer_tree_host_impl->visible());
1032 impl_thread_weak_ptr_ = impl().weak_factory.GetWeakPtr(); 987 impl_thread_weak_ptr_ = impl().weak_factory.GetWeakPtr();
1033 completion->Signal(); 988 completion->Signal();
1034 } 989 }
1035 990
1036 void ThreadProxy::InitializeOutputSurfaceOnImplThread( 991 void ThreadProxy::InitializeOutputSurfaceOnImpl(OutputSurface* output_surface) {
1037 OutputSurface* output_surface) {
1038 TRACE_EVENT0("cc", "ThreadProxy::InitializeOutputSurfaceOnImplThread"); 992 TRACE_EVENT0("cc", "ThreadProxy::InitializeOutputSurfaceOnImplThread");
1039 DCHECK(IsImplThread()); 993 DCHECK(IsImplThread());
1040 994
1041 LayerTreeHostImpl* host_impl = impl().layer_tree_host_impl.get(); 995 LayerTreeHostImpl* host_impl = impl().layer_tree_host_impl.get();
1042 bool success = host_impl->InitializeRenderer(output_surface); 996 bool success = host_impl->InitializeRenderer(output_surface);
1043 RendererCapabilities capabilities; 997 RendererCapabilities capabilities;
1044 if (success) { 998 if (success) {
1045 capabilities = 999 capabilities =
1046 host_impl->GetRendererCapabilities().MainThreadCapabilities(); 1000 host_impl->GetRendererCapabilities().MainThreadCapabilities();
1047 } 1001 }
1048 1002
1049 Proxy::MainThreadTaskRunner()->PostTask( 1003 impl().channel_impl->DidInitializeOutputSurface(success, capabilities);
1050 FROM_HERE,
1051 base::Bind(&ThreadProxy::DidInitializeOutputSurface,
1052 main_thread_weak_ptr_,
1053 success,
1054 capabilities));
1055 1004
1056 if (success) 1005 if (success)
1057 impl().scheduler->DidCreateAndInitializeOutputSurface(); 1006 impl().scheduler->DidCreateAndInitializeOutputSurface();
1058 } 1007 }
1059 1008
1060 void ThreadProxy::ReleaseOutputSurfaceOnImplThread( 1009 void ThreadProxy::ReleaseOutputSurfaceOnImpl(CompletionEvent* completion) {
1061 CompletionEvent* completion) {
1062 DCHECK(IsImplThread()); 1010 DCHECK(IsImplThread());
1063 1011
1064 // Unlike DidLoseOutputSurfaceOnImplThread, we don't need to call 1012 // Unlike DidLoseOutputSurfaceOnImplThread, we don't need to call
1065 // LayerTreeHost::DidLoseOutputSurface since it already knows. 1013 // LayerTreeHost::DidLoseOutputSurface since it already knows.
1066 impl().scheduler->DidLoseOutputSurface(); 1014 impl().scheduler->DidLoseOutputSurface();
1067 impl().layer_tree_host_impl->ReleaseOutputSurface(); 1015 impl().layer_tree_host_impl->ReleaseOutputSurface();
1068 completion->Signal(); 1016 completion->Signal();
1069 } 1017 }
1070 1018
1071 void ThreadProxy::FinishGLOnImplThread(CompletionEvent* completion) { 1019 void ThreadProxy::FinishGLOnImpl(CompletionEvent* completion) {
1072 TRACE_EVENT0("cc", "ThreadProxy::FinishGLOnImplThread"); 1020 TRACE_EVENT0("cc", "ThreadProxy::FinishGLOnImplThread");
1073 DCHECK(IsImplThread()); 1021 DCHECK(IsImplThread());
1074 if (impl().layer_tree_host_impl->output_surface()) { 1022 if (impl().layer_tree_host_impl->output_surface()) {
1075 ContextProvider* context_provider = 1023 ContextProvider* context_provider =
1076 impl().layer_tree_host_impl->output_surface()->context_provider(); 1024 impl().layer_tree_host_impl->output_surface()->context_provider();
1077 if (context_provider) 1025 if (context_provider)
1078 context_provider->ContextGL()->Finish(); 1026 context_provider->ContextGL()->Finish();
1079 } 1027 }
1080 completion->Signal(); 1028 completion->Signal();
1081 } 1029 }
(...skipping 14 matching lines...) Expand all
1096 } 1044 }
1097 1045
1098 ThreadProxy::BeginMainFrameAndCommitState::BeginMainFrameAndCommitState() 1046 ThreadProxy::BeginMainFrameAndCommitState::BeginMainFrameAndCommitState()
1099 : memory_allocation_limit_bytes(0), 1047 : memory_allocation_limit_bytes(0),
1100 evicted_ui_resources(false) {} 1048 evicted_ui_resources(false) {}
1101 1049
1102 ThreadProxy::BeginMainFrameAndCommitState::~BeginMainFrameAndCommitState() {} 1050 ThreadProxy::BeginMainFrameAndCommitState::~BeginMainFrameAndCommitState() {}
1103 1051
1104 bool ThreadProxy::MainFrameWillHappenForTesting() { 1052 bool ThreadProxy::MainFrameWillHappenForTesting() {
1105 DCHECK(IsMainThread()); 1053 DCHECK(IsMainThread());
1106 CompletionEvent completion;
1107 bool main_frame_will_happen = false; 1054 bool main_frame_will_happen = false;
1108 { 1055 {
1109 DebugScopedSetMainThreadBlocked main_thread_blocked(this); 1056 DebugScopedSetMainThreadBlocked main_thread_blocked(this);
1110 Proxy::ImplThreadTaskRunner()->PostTask( 1057 CompletionEvent completion;
1111 FROM_HERE, 1058 main().channel_main->MainFrameWillHappenOnImplForTesting(
1112 base::Bind(&ThreadProxy::MainFrameWillHappenOnImplThreadForTesting, 1059 &completion, &main_frame_will_happen);
1113 impl_thread_weak_ptr_,
1114 &completion,
1115 &main_frame_will_happen));
1116 completion.Wait(); 1060 completion.Wait();
1117 } 1061 }
1118 return main_frame_will_happen; 1062 return main_frame_will_happen;
1119 } 1063 }
1120 1064
1121 void ThreadProxy::SetChildrenNeedBeginFrames(bool children_need_begin_frames) { 1065 void ThreadProxy::SetChildrenNeedBeginFrames(bool children_need_begin_frames) {
1122 NOTREACHED() << "Only used by SingleThreadProxy"; 1066 NOTREACHED() << "Only used by SingleThreadProxy";
1123 } 1067 }
1124 1068
1125 void ThreadProxy::MainFrameWillHappenOnImplThreadForTesting( 1069 void ThreadProxy::MainFrameWillHappenOnImplForTesting(
1126 CompletionEvent* completion, 1070 CompletionEvent* completion,
1127 bool* main_frame_will_happen) { 1071 bool* main_frame_will_happen) {
1128 DCHECK(IsImplThread()); 1072 DCHECK(IsImplThread());
1129 if (impl().layer_tree_host_impl->output_surface()) { 1073 if (impl().layer_tree_host_impl->output_surface()) {
1130 *main_frame_will_happen = impl().scheduler->MainFrameForTestingWillHappen(); 1074 *main_frame_will_happen = impl().scheduler->MainFrameForTestingWillHappen();
1131 } else { 1075 } else {
1132 *main_frame_will_happen = false; 1076 *main_frame_will_happen = false;
1133 } 1077 }
1134 completion->Signal(); 1078 completion->Signal();
1135 } 1079 }
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
1210 impl().scheduler->WillPrepareTiles(); 1154 impl().scheduler->WillPrepareTiles();
1211 } 1155 }
1212 1156
1213 void ThreadProxy::DidPrepareTiles() { 1157 void ThreadProxy::DidPrepareTiles() {
1214 DCHECK(IsImplThread()); 1158 DCHECK(IsImplThread());
1215 impl().scheduler->DidPrepareTiles(); 1159 impl().scheduler->DidPrepareTiles();
1216 } 1160 }
1217 1161
1218 void ThreadProxy::DidCompletePageScaleAnimationOnImplThread() { 1162 void ThreadProxy::DidCompletePageScaleAnimationOnImplThread() {
1219 DCHECK(IsImplThread()); 1163 DCHECK(IsImplThread());
1220 Proxy::MainThreadTaskRunner()->PostTask( 1164 impl().channel_impl->DidCompletePageScaleAnimation();
1221 FROM_HERE, base::Bind(&ThreadProxy::DidCompletePageScaleAnimation,
1222 main_thread_weak_ptr_));
1223 } 1165 }
1224 1166
1225 void ThreadProxy::OnDrawForOutputSurface() { 1167 void ThreadProxy::OnDrawForOutputSurface() {
1226 DCHECK(IsImplThread()); 1168 DCHECK(IsImplThread());
1227 impl().scheduler->OnDrawForOutputSurface(); 1169 impl().scheduler->OnDrawForOutputSurface();
1228 } 1170 }
1229 1171
1230 void ThreadProxy::PostFrameTimingEventsOnImplThread( 1172 void ThreadProxy::PostFrameTimingEventsOnImplThread(
1231 scoped_ptr<FrameTimingTracker::CompositeTimingSet> composite_events, 1173 scoped_ptr<FrameTimingTracker::CompositeTimingSet> composite_events,
1232 scoped_ptr<FrameTimingTracker::MainFrameTimingSet> main_frame_events) { 1174 scoped_ptr<FrameTimingTracker::MainFrameTimingSet> main_frame_events) {
1233 DCHECK(IsImplThread()); 1175 DCHECK(IsImplThread());
1234 Proxy::MainThreadTaskRunner()->PostTask( 1176 impl().channel_impl->PostFrameTimingEventsOnMain(composite_events.Pass(),
1235 FROM_HERE, 1177 main_frame_events.Pass());
1236 base::Bind(&ThreadProxy::PostFrameTimingEvents, main_thread_weak_ptr_,
1237 base::Passed(composite_events.Pass()),
1238 base::Passed(main_frame_events.Pass())));
1239 } 1178 }
1240 1179
1241 void ThreadProxy::PostFrameTimingEvents( 1180 void ThreadProxy::PostFrameTimingEventsOnMain(
1242 scoped_ptr<FrameTimingTracker::CompositeTimingSet> composite_events, 1181 scoped_ptr<FrameTimingTracker::CompositeTimingSet> composite_events,
1243 scoped_ptr<FrameTimingTracker::MainFrameTimingSet> main_frame_events) { 1182 scoped_ptr<FrameTimingTracker::MainFrameTimingSet> main_frame_events) {
1244 DCHECK(IsMainThread()); 1183 DCHECK(IsMainThread());
1245 layer_tree_host()->RecordFrameTimingEvents(composite_events.Pass(), 1184 layer_tree_host()->RecordFrameTimingEvents(composite_events.Pass(),
1246 main_frame_events.Pass()); 1185 main_frame_events.Pass());
1247 } 1186 }
1248 1187
1249 base::WeakPtr<ProxyMain> ThreadProxy::GetMainWeakPtr() { 1188 base::WeakPtr<ProxyMain> ThreadProxy::GetMainWeakPtr() {
1250 return main_thread_weak_ptr_; 1189 return main_thread_weak_ptr_;
1251 } 1190 }
1252 1191
1253 base::WeakPtr<ProxyImpl> ThreadProxy::GetImplWeakPtr() { 1192 base::WeakPtr<ProxyImpl> ThreadProxy::GetImplWeakPtr() {
1254 return impl_thread_weak_ptr_; 1193 return impl_thread_weak_ptr_;
1255 } 1194 }
1256 1195
1257 } // namespace cc 1196 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/thread_proxy.h ('k') | cc/trees/threaded_channel.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698