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

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

Issue 1418953002: cc: Send shared variables between main and impl side using the channel (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressing comments. 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
« 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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 impl_task_runner, 55 impl_task_runner,
56 external_begin_frame_source.Pass())); 56 external_begin_frame_source.Pass()));
57 } 57 }
58 58
59 ThreadProxy::ThreadProxy( 59 ThreadProxy::ThreadProxy(
60 LayerTreeHost* layer_tree_host, 60 LayerTreeHost* layer_tree_host,
61 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, 61 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner,
62 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner, 62 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner,
63 scoped_ptr<BeginFrameSource> external_begin_frame_source) 63 scoped_ptr<BeginFrameSource> external_begin_frame_source)
64 : Proxy(main_task_runner, impl_task_runner), 64 : Proxy(main_task_runner, impl_task_runner),
65 main_thread_only_vars_unsafe_(this, layer_tree_host->id()), 65 main_thread_only_vars_unsafe_(this, layer_tree_host),
66 main_thread_or_blocked_vars_unsafe_(layer_tree_host),
67 compositor_thread_vars_unsafe_( 66 compositor_thread_vars_unsafe_(
68 this, 67 this,
69 layer_tree_host->id(), 68 layer_tree_host->id(),
70 layer_tree_host->rendering_stats_instrumentation(), 69 layer_tree_host->rendering_stats_instrumentation(),
71 external_begin_frame_source.Pass()) { 70 external_begin_frame_source.Pass()) {
72 TRACE_EVENT0("cc", "ThreadProxy::ThreadProxy"); 71 TRACE_EVENT0("cc", "ThreadProxy::ThreadProxy");
73 DCHECK(IsMainThread()); 72 DCHECK(IsMainThread());
74 DCHECK(this->layer_tree_host()); 73 DCHECK(this->main().layer_tree_host);
75 // TODO(khushalsagar): Move this to LayerTreeHost#InitializeThreaded once 74 // TODO(khushalsagar): Move this to LayerTreeHost#InitializeThreaded once
76 // ThreadProxy is split. LayerTreeHost creates the channel and passes it to 75 // ThreadProxy is split. LayerTreeHost creates the channel and passes it to
77 // ProxyMain#SetChannel. 76 // ProxyMain#SetChannel.
78 SetChannel(ThreadedChannel::Create(this, main_task_runner, impl_task_runner)); 77 SetChannel(ThreadedChannel::Create(this, main_task_runner, impl_task_runner));
79 } 78 }
80 79
81 ThreadProxy::MainThreadOnly::MainThreadOnly(ThreadProxy* proxy, 80 ThreadProxy::MainThreadOnly::MainThreadOnly(ThreadProxy* proxy,
82 int layer_tree_host_id) 81 LayerTreeHost* layer_tree_host)
83 : layer_tree_host_id(layer_tree_host_id), 82 : layer_tree_host_id(layer_tree_host->id()),
83 layer_tree_host(layer_tree_host),
84 max_requested_pipeline_stage(NO_PIPELINE_STAGE), 84 max_requested_pipeline_stage(NO_PIPELINE_STAGE),
85 current_pipeline_stage(NO_PIPELINE_STAGE), 85 current_pipeline_stage(NO_PIPELINE_STAGE),
86 final_pipeline_stage(NO_PIPELINE_STAGE), 86 final_pipeline_stage(NO_PIPELINE_STAGE),
87 commit_waits_for_activation(false),
87 started(false), 88 started(false),
88 prepare_tiles_pending(false), 89 prepare_tiles_pending(false),
89 defer_commits(false), 90 defer_commits(false),
90 weak_factory(proxy) {} 91 weak_factory(proxy) {}
91 92
92 ThreadProxy::MainThreadOnly::~MainThreadOnly() {} 93 ThreadProxy::MainThreadOnly::~MainThreadOnly() {}
93 94
94 ThreadProxy::MainThreadOrBlockedMainThread::MainThreadOrBlockedMainThread( 95 ThreadProxy::BlockedMainCommitOnly::BlockedMainCommitOnly()
95 LayerTreeHost* host) 96 : layer_tree_host(nullptr) {}
96 : layer_tree_host(host),
97 commit_waits_for_activation(false),
98 main_thread_inside_commit(false) {}
99 97
100 ThreadProxy::MainThreadOrBlockedMainThread::~MainThreadOrBlockedMainThread() {} 98 ThreadProxy::BlockedMainCommitOnly::~BlockedMainCommitOnly() {}
101 99
102 ThreadProxy::CompositorThreadOnly::CompositorThreadOnly( 100 ThreadProxy::CompositorThreadOnly::CompositorThreadOnly(
103 ThreadProxy* proxy, 101 ThreadProxy* proxy,
104 int layer_tree_host_id, 102 int layer_tree_host_id,
105 RenderingStatsInstrumentation* rendering_stats_instrumentation, 103 RenderingStatsInstrumentation* rendering_stats_instrumentation,
106 scoped_ptr<BeginFrameSource> external_begin_frame_source) 104 scoped_ptr<BeginFrameSource> external_begin_frame_source)
107 : layer_tree_host_id(layer_tree_host_id), 105 : layer_tree_host_id(layer_tree_host_id),
106 next_commit_waits_for_activation(false),
108 commit_completion_event(nullptr), 107 commit_completion_event(nullptr),
109 completion_event_for_commit_held_on_tree_activation(nullptr),
110 next_frame_is_newly_committed_frame(false), 108 next_frame_is_newly_committed_frame(false),
111 inside_draw(false), 109 inside_draw(false),
112 input_throttled_until_commit(false), 110 input_throttled_until_commit(false),
113 smoothness_priority_expiration_notifier( 111 smoothness_priority_expiration_notifier(
114 proxy->ImplThreadTaskRunner(), 112 proxy->ImplThreadTaskRunner(),
115 base::Bind(&ThreadProxy::RenewTreePriority, base::Unretained(proxy)), 113 base::Bind(&ThreadProxy::RenewTreePriority, base::Unretained(proxy)),
116 base::TimeDelta::FromMilliseconds( 114 base::TimeDelta::FromMilliseconds(
117 kSmoothnessTakesPriorityExpirationDelay * 1000)), 115 kSmoothnessTakesPriorityExpirationDelay * 1000)),
118 external_begin_frame_source(external_begin_frame_source.Pass()), 116 external_begin_frame_source(external_begin_frame_source.Pass()),
119 rendering_stats_instrumentation(rendering_stats_instrumentation), 117 rendering_stats_instrumentation(rendering_stats_instrumentation),
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 176
179 void ThreadProxy::SetThrottleFrameProductionOnImpl(bool throttle) { 177 void ThreadProxy::SetThrottleFrameProductionOnImpl(bool throttle) {
180 TRACE_EVENT1("cc", "ThreadProxy::SetThrottleFrameProductionOnImplThread", 178 TRACE_EVENT1("cc", "ThreadProxy::SetThrottleFrameProductionOnImplThread",
181 "throttle", throttle); 179 "throttle", throttle);
182 impl().scheduler->SetThrottleFrameProduction(throttle); 180 impl().scheduler->SetThrottleFrameProduction(throttle);
183 } 181 }
184 182
185 void ThreadProxy::DidLoseOutputSurface() { 183 void ThreadProxy::DidLoseOutputSurface() {
186 TRACE_EVENT0("cc", "ThreadProxy::DidLoseOutputSurface"); 184 TRACE_EVENT0("cc", "ThreadProxy::DidLoseOutputSurface");
187 DCHECK(IsMainThread()); 185 DCHECK(IsMainThread());
188 layer_tree_host()->DidLoseOutputSurface(); 186 main().layer_tree_host->DidLoseOutputSurface();
189 } 187 }
190 188
191 void ThreadProxy::RequestNewOutputSurface() { 189 void ThreadProxy::RequestNewOutputSurface() {
192 DCHECK(IsMainThread()); 190 DCHECK(IsMainThread());
193 layer_tree_host()->RequestNewOutputSurface(); 191 main().layer_tree_host->RequestNewOutputSurface();
194 } 192 }
195 193
196 void ThreadProxy::SetOutputSurface(OutputSurface* output_surface) { 194 void ThreadProxy::SetOutputSurface(OutputSurface* output_surface) {
197 main().channel_main->InitializeOutputSurfaceOnImpl(output_surface); 195 main().channel_main->InitializeOutputSurfaceOnImpl(output_surface);
198 } 196 }
199 197
200 void ThreadProxy::ReleaseOutputSurface() { 198 void ThreadProxy::ReleaseOutputSurface() {
201 DCHECK(IsMainThread()); 199 DCHECK(IsMainThread());
202 DCHECK(layer_tree_host()->output_surface_lost()); 200 DCHECK(main().layer_tree_host->output_surface_lost());
203 201
204 DebugScopedSetMainThreadBlocked main_thread_blocked(this); 202 DebugScopedSetMainThreadBlocked main_thread_blocked(this);
205 CompletionEvent completion; 203 CompletionEvent completion;
206 main().channel_main->ReleaseOutputSurfaceOnImpl(&completion); 204 main().channel_main->ReleaseOutputSurfaceOnImpl(&completion);
207 completion.Wait(); 205 completion.Wait();
208 } 206 }
209 207
210 void ThreadProxy::DidInitializeOutputSurface( 208 void ThreadProxy::DidInitializeOutputSurface(
211 bool success, 209 bool success,
212 const RendererCapabilities& capabilities) { 210 const RendererCapabilities& capabilities) {
213 TRACE_EVENT0("cc", "ThreadProxy::DidInitializeOutputSurface"); 211 TRACE_EVENT0("cc", "ThreadProxy::DidInitializeOutputSurface");
214 DCHECK(IsMainThread()); 212 DCHECK(IsMainThread());
215 213
216 if (!success) { 214 if (!success) {
217 layer_tree_host()->DidFailToInitializeOutputSurface(); 215 main().layer_tree_host->DidFailToInitializeOutputSurface();
218 return; 216 return;
219 } 217 }
220 main().renderer_capabilities_main_thread_copy = capabilities; 218 main().renderer_capabilities_main_thread_copy = capabilities;
221 layer_tree_host()->DidInitializeOutputSurface(); 219 main().layer_tree_host->DidInitializeOutputSurface();
222 } 220 }
223 221
224 void ThreadProxy::SetRendererCapabilitiesMainCopy( 222 void ThreadProxy::SetRendererCapabilitiesMainCopy(
225 const RendererCapabilities& capabilities) { 223 const RendererCapabilities& capabilities) {
226 main().renderer_capabilities_main_thread_copy = capabilities; 224 main().renderer_capabilities_main_thread_copy = capabilities;
227 } 225 }
228 226
229 bool ThreadProxy::SendCommitRequestToImplThreadIfNeeded( 227 bool ThreadProxy::SendCommitRequestToImplThreadIfNeeded(
230 CommitPipelineStage required_stage) { 228 CommitPipelineStage required_stage) {
231 DCHECK(IsMainThread()); 229 DCHECK(IsMainThread());
232 DCHECK_NE(NO_PIPELINE_STAGE, required_stage); 230 DCHECK_NE(NO_PIPELINE_STAGE, required_stage);
233 bool already_posted = 231 bool already_posted =
234 main().max_requested_pipeline_stage != NO_PIPELINE_STAGE; 232 main().max_requested_pipeline_stage != NO_PIPELINE_STAGE;
235 main().max_requested_pipeline_stage = 233 main().max_requested_pipeline_stage =
236 std::max(main().max_requested_pipeline_stage, required_stage); 234 std::max(main().max_requested_pipeline_stage, required_stage);
237 if (already_posted) 235 if (already_posted)
238 return false; 236 return false;
239 main().channel_main->SetNeedsCommitOnImpl(); 237 main().channel_main->SetNeedsCommitOnImpl();
240 return true; 238 return true;
241 } 239 }
242 240
243 void ThreadProxy::SetNeedsCommitOnImpl() { 241 void ThreadProxy::SetNeedsCommitOnImpl() {
244 SetNeedsCommitOnImplThread(); 242 SetNeedsCommitOnImplThread();
245 } 243 }
246 244
247 void ThreadProxy::DidCompletePageScaleAnimation() { 245 void ThreadProxy::DidCompletePageScaleAnimation() {
248 DCHECK(IsMainThread()); 246 DCHECK(IsMainThread());
249 layer_tree_host()->DidCompletePageScaleAnimation(); 247 main().layer_tree_host->DidCompletePageScaleAnimation();
250 } 248 }
251 249
252 const RendererCapabilities& ThreadProxy::GetRendererCapabilities() const { 250 const RendererCapabilities& ThreadProxy::GetRendererCapabilities() const {
253 DCHECK(IsMainThread()); 251 DCHECK(IsMainThread());
254 DCHECK(!layer_tree_host()->output_surface_lost()); 252 DCHECK(!main().layer_tree_host->output_surface_lost());
255 return main().renderer_capabilities_main_thread_copy; 253 return main().renderer_capabilities_main_thread_copy;
256 } 254 }
257 255
258 void ThreadProxy::SetNeedsAnimate() { 256 void ThreadProxy::SetNeedsAnimate() {
259 DCHECK(IsMainThread()); 257 DCHECK(IsMainThread());
260 if (SendCommitRequestToImplThreadIfNeeded(ANIMATE_PIPELINE_STAGE)) { 258 if (SendCommitRequestToImplThreadIfNeeded(ANIMATE_PIPELINE_STAGE)) {
261 TRACE_EVENT_INSTANT0("cc", "ThreadProxy::SetNeedsAnimate", 259 TRACE_EVENT_INSTANT0("cc", "ThreadProxy::SetNeedsAnimate",
262 TRACE_EVENT_SCOPE_THREAD); 260 TRACE_EVENT_SCOPE_THREAD);
263 } 261 }
264 } 262 }
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 main().channel_main->SetNeedsRedrawOnImpl(damage_rect); 399 main().channel_main->SetNeedsRedrawOnImpl(damage_rect);
402 } 400 }
403 401
404 void ThreadProxy::SetNeedsRedrawOnImpl(const gfx::Rect& damage_rect) { 402 void ThreadProxy::SetNeedsRedrawOnImpl(const gfx::Rect& damage_rect) {
405 DCHECK(IsImplThread()); 403 DCHECK(IsImplThread());
406 SetNeedsRedrawRectOnImplThread(damage_rect); 404 SetNeedsRedrawRectOnImplThread(damage_rect);
407 } 405 }
408 406
409 void ThreadProxy::SetNextCommitWaitsForActivation() { 407 void ThreadProxy::SetNextCommitWaitsForActivation() {
410 DCHECK(IsMainThread()); 408 DCHECK(IsMainThread());
411 DCHECK(!blocked_main().main_thread_inside_commit); 409 main().commit_waits_for_activation = true;
412 blocked_main().commit_waits_for_activation = true;
413 } 410 }
414 411
415 void ThreadProxy::SetDeferCommits(bool defer_commits) { 412 void ThreadProxy::SetDeferCommits(bool defer_commits) {
416 DCHECK(IsMainThread()); 413 DCHECK(IsMainThread());
417 if (main().defer_commits == defer_commits) 414 if (main().defer_commits == defer_commits)
418 return; 415 return;
419 416
420 main().defer_commits = defer_commits; 417 main().defer_commits = defer_commits;
421 if (main().defer_commits) 418 if (main().defer_commits)
422 TRACE_EVENT_ASYNC_BEGIN0("cc", "ThreadProxy::SetDeferCommits", this); 419 TRACE_EVENT_ASYNC_BEGIN0("cc", "ThreadProxy::SetDeferCommits", this);
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
483 } 480 }
484 481
485 void ThreadProxy::SetInputThrottledUntilCommitOnImpl(bool is_throttled) { 482 void ThreadProxy::SetInputThrottledUntilCommitOnImpl(bool is_throttled) {
486 DCHECK(IsImplThread()); 483 DCHECK(IsImplThread());
487 if (is_throttled == impl().input_throttled_until_commit) 484 if (is_throttled == impl().input_throttled_until_commit)
488 return; 485 return;
489 impl().input_throttled_until_commit = is_throttled; 486 impl().input_throttled_until_commit = is_throttled;
490 RenewTreePriority(); 487 RenewTreePriority();
491 } 488 }
492 489
493 LayerTreeHost* ThreadProxy::layer_tree_host() {
494 return blocked_main().layer_tree_host;
495 }
496
497 const LayerTreeHost* ThreadProxy::layer_tree_host() const {
498 return blocked_main().layer_tree_host;
499 }
500
501 ThreadProxy::MainThreadOnly& ThreadProxy::main() { 490 ThreadProxy::MainThreadOnly& ThreadProxy::main() {
502 DCHECK(IsMainThread()); 491 DCHECK(IsMainThread());
503 return main_thread_only_vars_unsafe_; 492 return main_thread_only_vars_unsafe_;
504 } 493 }
505 const ThreadProxy::MainThreadOnly& ThreadProxy::main() const { 494 const ThreadProxy::MainThreadOnly& ThreadProxy::main() const {
506 DCHECK(IsMainThread()); 495 DCHECK(IsMainThread());
507 return main_thread_only_vars_unsafe_; 496 return main_thread_only_vars_unsafe_;
508 } 497 }
509 498
510 ThreadProxy::MainThreadOrBlockedMainThread& ThreadProxy::blocked_main() { 499 ThreadProxy::BlockedMainCommitOnly& ThreadProxy::blocked_main_commit() {
511 DCHECK(IsMainThread() || IsMainThreadBlocked()); 500 DCHECK(IsMainThreadBlocked());
512 return main_thread_or_blocked_vars_unsafe_; 501 DCHECK(impl().commit_completion_event);
513 } 502 return main_thread_blocked_commit_vars_unsafe_;
514
515 const ThreadProxy::MainThreadOrBlockedMainThread& ThreadProxy::blocked_main()
516 const {
517 DCHECK(IsMainThread() || IsMainThreadBlocked());
518 return main_thread_or_blocked_vars_unsafe_;
519 } 503 }
520 504
521 ThreadProxy::CompositorThreadOnly& ThreadProxy::impl() { 505 ThreadProxy::CompositorThreadOnly& ThreadProxy::impl() {
522 DCHECK(IsImplThread()); 506 DCHECK(IsImplThread());
523 return compositor_thread_vars_unsafe_; 507 return compositor_thread_vars_unsafe_;
524 } 508 }
525 509
526 const ThreadProxy::CompositorThreadOnly& ThreadProxy::impl() const { 510 const ThreadProxy::CompositorThreadOnly& ThreadProxy::impl() const {
527 DCHECK(IsImplThread()); 511 DCHECK(IsImplThread());
528 return compositor_thread_vars_unsafe_; 512 return compositor_thread_vars_unsafe_;
529 } 513 }
530 514
531 void ThreadProxy::Start() { 515 void ThreadProxy::Start() {
532 DCHECK(IsMainThread()); 516 DCHECK(IsMainThread());
533 DCHECK(Proxy::HasImplThread()); 517 DCHECK(Proxy::HasImplThread());
534 518
535 // Create LayerTreeHostImpl. 519 // Create LayerTreeHostImpl.
536 DebugScopedSetMainThreadBlocked main_thread_blocked(this); 520 DebugScopedSetMainThreadBlocked main_thread_blocked(this);
537 CompletionEvent completion; 521 CompletionEvent completion;
538 Proxy::ImplThreadTaskRunner()->PostTask( 522 main().channel_main->InitializeImplOnImpl(&completion,
539 FROM_HERE, 523 main().layer_tree_host);
540 base::Bind(&ThreadProxy::InitializeImplOnImplThread,
541 base::Unretained(this),
542 &completion));
543 completion.Wait(); 524 completion.Wait();
544 525
545 main_thread_weak_ptr_ = main().weak_factory.GetWeakPtr(); 526 main_thread_weak_ptr_ = main().weak_factory.GetWeakPtr();
546 527
547 main().started = true; 528 main().started = true;
548 } 529 }
549 530
550 void ThreadProxy::Stop() { 531 void ThreadProxy::Stop() {
551 TRACE_EVENT0("cc", "ThreadProxy::Stop"); 532 TRACE_EVENT0("cc", "ThreadProxy::Stop");
552 DCHECK(IsMainThread()); 533 DCHECK(IsMainThread());
553 DCHECK(main().started); 534 DCHECK(main().started);
554 535
555 // Synchronously finishes pending GL operations and deletes the impl. 536 // Synchronously finishes pending GL operations and deletes the impl.
556 // The two steps are done as separate post tasks, so that tasks posted 537 // The two steps are done as separate post tasks, so that tasks posted
557 // by the GL implementation due to the Finish can be executed by the 538 // by the GL implementation due to the Finish can be executed by the
558 // renderer before shutting it down. 539 // renderer before shutting it down.
559 { 540 {
560 DebugScopedSetMainThreadBlocked main_thread_blocked(this); 541 DebugScopedSetMainThreadBlocked main_thread_blocked(this);
561 CompletionEvent completion; 542 CompletionEvent completion;
562 main().channel_main->FinishGLOnImpl(&completion); 543 main().channel_main->FinishGLOnImpl(&completion);
563 completion.Wait(); 544 completion.Wait();
564 } 545 }
565 { 546 {
566 DebugScopedSetMainThreadBlocked main_thread_blocked(this); 547 DebugScopedSetMainThreadBlocked main_thread_blocked(this);
567 548
568 CompletionEvent completion; 549 CompletionEvent completion;
569 Proxy::ImplThreadTaskRunner()->PostTask( 550 main().channel_main->LayerTreeHostClosedOnImpl(&completion);
570 FROM_HERE,
571 base::Bind(&ThreadProxy::LayerTreeHostClosedOnImplThread,
572 impl_thread_weak_ptr_,
573 &completion));
574 completion.Wait(); 551 completion.Wait();
575 } 552 }
576 553
577 main().weak_factory.InvalidateWeakPtrs(); 554 main().weak_factory.InvalidateWeakPtrs();
578 blocked_main().layer_tree_host = NULL; 555 main().layer_tree_host = nullptr;
579 main().started = false; 556 main().started = false;
580 } 557 }
581 558
582 bool ThreadProxy::SupportsImplScrolling() const { 559 bool ThreadProxy::SupportsImplScrolling() const {
583 return true; 560 return true;
584 } 561 }
585 562
586 void ThreadProxy::FinishAllRenderingOnImpl(CompletionEvent* completion) { 563 void ThreadProxy::FinishAllRenderingOnImpl(CompletionEvent* completion) {
587 TRACE_EVENT0("cc", "ThreadProxy::FinishAllRenderingOnImplThread"); 564 TRACE_EVENT0("cc", "ThreadProxy::FinishAllRenderingOnImplThread");
588 DCHECK(IsImplThread()); 565 DCHECK(IsImplThread());
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
631 TRACE_EVENT_INSTANT0("cc", "EarlyOut_DeferCommit", 608 TRACE_EVENT_INSTANT0("cc", "EarlyOut_DeferCommit",
632 TRACE_EVENT_SCOPE_THREAD); 609 TRACE_EVENT_SCOPE_THREAD);
633 main().channel_main->BeginMainFrameAbortedOnImpl( 610 main().channel_main->BeginMainFrameAbortedOnImpl(
634 CommitEarlyOutReason::ABORTED_DEFERRED_COMMIT); 611 CommitEarlyOutReason::ABORTED_DEFERRED_COMMIT);
635 return; 612 return;
636 } 613 }
637 614
638 // If the commit finishes, LayerTreeHost will transfer its swap promises to 615 // If the commit finishes, LayerTreeHost will transfer its swap promises to
639 // LayerTreeImpl. The destructor of ScopedSwapPromiseChecker aborts the 616 // LayerTreeImpl. The destructor of ScopedSwapPromiseChecker aborts the
640 // remaining swap promises. 617 // remaining swap promises.
641 ScopedAbortRemainingSwapPromises swap_promise_checker(layer_tree_host()); 618 ScopedAbortRemainingSwapPromises swap_promise_checker(main().layer_tree_host);
642 619
643 main().final_pipeline_stage = main().max_requested_pipeline_stage; 620 main().final_pipeline_stage = main().max_requested_pipeline_stage;
644 main().max_requested_pipeline_stage = NO_PIPELINE_STAGE; 621 main().max_requested_pipeline_stage = NO_PIPELINE_STAGE;
645 622
646 if (!layer_tree_host()->visible()) { 623 if (!main().layer_tree_host->visible()) {
647 TRACE_EVENT_INSTANT0("cc", "EarlyOut_NotVisible", TRACE_EVENT_SCOPE_THREAD); 624 TRACE_EVENT_INSTANT0("cc", "EarlyOut_NotVisible", TRACE_EVENT_SCOPE_THREAD);
648 main().channel_main->BeginMainFrameAbortedOnImpl( 625 main().channel_main->BeginMainFrameAbortedOnImpl(
649 CommitEarlyOutReason::ABORTED_NOT_VISIBLE); 626 CommitEarlyOutReason::ABORTED_NOT_VISIBLE);
650 return; 627 return;
651 } 628 }
652 629
653 if (layer_tree_host()->output_surface_lost()) { 630 if (main().layer_tree_host->output_surface_lost()) {
654 TRACE_EVENT_INSTANT0( 631 TRACE_EVENT_INSTANT0(
655 "cc", "EarlyOut_OutputSurfaceLost", TRACE_EVENT_SCOPE_THREAD); 632 "cc", "EarlyOut_OutputSurfaceLost", TRACE_EVENT_SCOPE_THREAD);
656 main().channel_main->BeginMainFrameAbortedOnImpl( 633 main().channel_main->BeginMainFrameAbortedOnImpl(
657 CommitEarlyOutReason::ABORTED_OUTPUT_SURFACE_LOST); 634 CommitEarlyOutReason::ABORTED_OUTPUT_SURFACE_LOST);
658 return; 635 return;
659 } 636 }
660 637
661 main().current_pipeline_stage = ANIMATE_PIPELINE_STAGE; 638 main().current_pipeline_stage = ANIMATE_PIPELINE_STAGE;
662 639
663 layer_tree_host()->ApplyScrollAndScale( 640 main().layer_tree_host->ApplyScrollAndScale(
664 begin_main_frame_state->scroll_info.get()); 641 begin_main_frame_state->scroll_info.get());
665 642
666 layer_tree_host()->WillBeginMainFrame(); 643 main().layer_tree_host->WillBeginMainFrame();
667 644
668 layer_tree_host()->BeginMainFrame(begin_main_frame_state->begin_frame_args); 645 main().layer_tree_host->BeginMainFrame(
669 layer_tree_host()->AnimateLayers( 646 begin_main_frame_state->begin_frame_args);
647 main().layer_tree_host->AnimateLayers(
670 begin_main_frame_state->begin_frame_args.frame_time); 648 begin_main_frame_state->begin_frame_args.frame_time);
671 649
672 // Recreate all UI resources if there were evicted UI resources when the impl 650 // Recreate all UI resources if there were evicted UI resources when the impl
673 // thread initiated the commit. 651 // thread initiated the commit.
674 if (begin_main_frame_state->evicted_ui_resources) 652 if (begin_main_frame_state->evicted_ui_resources)
675 layer_tree_host()->RecreateUIResources(); 653 main().layer_tree_host->RecreateUIResources();
676 654
677 layer_tree_host()->Layout(); 655 main().layer_tree_host->Layout();
678 TRACE_EVENT_SYNTHETIC_DELAY_END("cc.BeginMainFrame"); 656 TRACE_EVENT_SYNTHETIC_DELAY_END("cc.BeginMainFrame");
679 657
680 bool can_cancel_this_commit = 658 bool can_cancel_this_commit =
681 main().final_pipeline_stage < COMMIT_PIPELINE_STAGE && 659 main().final_pipeline_stage < COMMIT_PIPELINE_STAGE &&
682 !begin_main_frame_state->evicted_ui_resources; 660 !begin_main_frame_state->evicted_ui_resources;
683 661
684 main().current_pipeline_stage = UPDATE_LAYERS_PIPELINE_STAGE; 662 main().current_pipeline_stage = UPDATE_LAYERS_PIPELINE_STAGE;
685 bool should_update_layers = 663 bool should_update_layers =
686 main().final_pipeline_stage >= UPDATE_LAYERS_PIPELINE_STAGE; 664 main().final_pipeline_stage >= UPDATE_LAYERS_PIPELINE_STAGE;
687 bool updated = should_update_layers && layer_tree_host()->UpdateLayers(); 665 bool updated = should_update_layers && main().layer_tree_host->UpdateLayers();
688 666
689 layer_tree_host()->WillCommit(); 667 main().layer_tree_host->WillCommit();
690 devtools_instrumentation::ScopedCommitTrace commit_task( 668 devtools_instrumentation::ScopedCommitTrace commit_task(
691 layer_tree_host()->id()); 669 main().layer_tree_host->id());
692 670
693 main().current_pipeline_stage = COMMIT_PIPELINE_STAGE; 671 main().current_pipeline_stage = COMMIT_PIPELINE_STAGE;
694 if (!updated && can_cancel_this_commit) { 672 if (!updated && can_cancel_this_commit) {
695 TRACE_EVENT_INSTANT0("cc", "EarlyOut_NoUpdates", TRACE_EVENT_SCOPE_THREAD); 673 TRACE_EVENT_INSTANT0("cc", "EarlyOut_NoUpdates", TRACE_EVENT_SCOPE_THREAD);
696 main().channel_main->BeginMainFrameAbortedOnImpl( 674 main().channel_main->BeginMainFrameAbortedOnImpl(
697 CommitEarlyOutReason::FINISHED_NO_UPDATES); 675 CommitEarlyOutReason::FINISHED_NO_UPDATES);
698 676
699 // Although the commit is internally aborted, this is because it has been 677 // Although the commit is internally aborted, this is because it has been
700 // detected to be a no-op. From the perspective of an embedder, this commit 678 // detected to be a no-op. From the perspective of an embedder, this commit
701 // went through, and input should no longer be throttled, etc. 679 // went through, and input should no longer be throttled, etc.
702 main().current_pipeline_stage = NO_PIPELINE_STAGE; 680 main().current_pipeline_stage = NO_PIPELINE_STAGE;
703 layer_tree_host()->CommitComplete(); 681 main().layer_tree_host->CommitComplete();
704 layer_tree_host()->DidBeginMainFrame(); 682 main().layer_tree_host->DidBeginMainFrame();
705 layer_tree_host()->BreakSwapPromises(SwapPromise::COMMIT_NO_UPDATE); 683 main().layer_tree_host->BreakSwapPromises(SwapPromise::COMMIT_NO_UPDATE);
706 return; 684 return;
707 } 685 }
708 686
709 // Notify the impl thread that the main thread is ready to commit. This will 687 // Notify the impl thread that the main thread is ready to commit. This will
710 // begin the commit process, which is blocking from the main thread's 688 // begin the commit process, which is blocking from the main thread's
711 // point of view, but asynchronously performed on the impl thread, 689 // point of view, but asynchronously performed on the impl thread,
712 // coordinated by the Scheduler. 690 // coordinated by the Scheduler.
713 { 691 {
714 TRACE_EVENT0("cc", "ThreadProxy::BeginMainFrame::commit"); 692 TRACE_EVENT0("cc", "ThreadProxy::BeginMainFrame::commit");
715 693
716 DebugScopedSetMainThreadBlocked main_thread_blocked(this); 694 DebugScopedSetMainThreadBlocked main_thread_blocked(this);
717 695
718 // This CapturePostTasks should be destroyed before CommitComplete() is 696 // This CapturePostTasks should be destroyed before CommitComplete() is
719 // called since that goes out to the embedder, and we want the embedder 697 // called since that goes out to the embedder, and we want the embedder
720 // to receive its callbacks before that. 698 // to receive its callbacks before that.
721 BlockingTaskRunner::CapturePostTasks blocked( 699 BlockingTaskRunner::CapturePostTasks blocked(
722 blocking_main_thread_task_runner()); 700 blocking_main_thread_task_runner());
723 701
724 CompletionEvent completion; 702 CompletionEvent completion;
725 main().channel_main->StartCommitOnImpl(&completion); 703 main().channel_main->StartCommitOnImpl(&completion, main().layer_tree_host,
704 main().commit_waits_for_activation);
726 completion.Wait(); 705 completion.Wait();
706 main().commit_waits_for_activation = false;
727 } 707 }
728 708
729 main().current_pipeline_stage = NO_PIPELINE_STAGE; 709 main().current_pipeline_stage = NO_PIPELINE_STAGE;
730 layer_tree_host()->CommitComplete(); 710 main().layer_tree_host->CommitComplete();
731 layer_tree_host()->DidBeginMainFrame(); 711 main().layer_tree_host->DidBeginMainFrame();
732 } 712 }
733 713
734 void ThreadProxy::BeginMainFrameNotExpectedSoon() { 714 void ThreadProxy::BeginMainFrameNotExpectedSoon() {
735 TRACE_EVENT0("cc", "ThreadProxy::BeginMainFrameNotExpectedSoon"); 715 TRACE_EVENT0("cc", "ThreadProxy::BeginMainFrameNotExpectedSoon");
736 DCHECK(IsMainThread()); 716 DCHECK(IsMainThread());
737 layer_tree_host()->BeginMainFrameNotExpectedSoon(); 717 main().layer_tree_host->BeginMainFrameNotExpectedSoon();
738 } 718 }
739 719
740 void ThreadProxy::StartCommitOnImpl(CompletionEvent* completion) { 720 void ThreadProxy::StartCommitOnImpl(CompletionEvent* completion,
721 LayerTreeHost* layer_tree_host,
722 bool hold_commit_for_activation) {
741 TRACE_EVENT0("cc", "ThreadProxy::StartCommitOnImplThread"); 723 TRACE_EVENT0("cc", "ThreadProxy::StartCommitOnImplThread");
742 DCHECK(!impl().commit_completion_event); 724 DCHECK(!impl().commit_completion_event);
743 DCHECK(IsImplThread() && IsMainThreadBlocked()); 725 DCHECK(IsImplThread() && IsMainThreadBlocked());
744 DCHECK(impl().scheduler); 726 DCHECK(impl().scheduler);
745 DCHECK(impl().scheduler->CommitPending()); 727 DCHECK(impl().scheduler->CommitPending());
746 728
729 if (hold_commit_for_activation) {
730 // This commit may be aborted. Store the value for
731 // hold_commit_for_activation so that whenever the next commit is started,
732 // the main thread will be unblocked only after pending tree activation.
733 impl().next_commit_waits_for_activation = hold_commit_for_activation;
734 }
735
747 if (!impl().layer_tree_host_impl) { 736 if (!impl().layer_tree_host_impl) {
748 TRACE_EVENT_INSTANT0( 737 TRACE_EVENT_INSTANT0(
749 "cc", "EarlyOut_NoLayerTree", TRACE_EVENT_SCOPE_THREAD); 738 "cc", "EarlyOut_NoLayerTree", TRACE_EVENT_SCOPE_THREAD);
750 completion->Signal(); 739 completion->Signal();
751 return; 740 return;
752 } 741 }
753 742
754 // Ideally, we should inform to impl thread when BeginMainFrame is started. 743 // Ideally, we should inform to impl thread when BeginMainFrame is started.
755 // But, we can avoid a PostTask in here. 744 // But, we can avoid a PostTask in here.
756 impl().scheduler->NotifyBeginMainFrameStarted(); 745 impl().scheduler->NotifyBeginMainFrameStarted();
757 impl().commit_completion_event = completion; 746 impl().commit_completion_event = completion;
747 DCHECK(!blocked_main_commit().layer_tree_host);
748 blocked_main_commit().layer_tree_host = layer_tree_host;
758 impl().scheduler->NotifyReadyToCommit(); 749 impl().scheduler->NotifyReadyToCommit();
759 } 750 }
760 751
761 void ThreadProxy::BeginMainFrameAbortedOnImpl(CommitEarlyOutReason reason) { 752 void ThreadProxy::BeginMainFrameAbortedOnImpl(CommitEarlyOutReason reason) {
762 TRACE_EVENT1("cc", "ThreadProxy::BeginMainFrameAbortedOnImplThread", "reason", 753 TRACE_EVENT1("cc", "ThreadProxy::BeginMainFrameAbortedOnImplThread", "reason",
763 CommitEarlyOutReasonToString(reason)); 754 CommitEarlyOutReasonToString(reason));
764 DCHECK(IsImplThread()); 755 DCHECK(IsImplThread());
765 DCHECK(impl().scheduler); 756 DCHECK(impl().scheduler);
766 DCHECK(impl().scheduler->CommitPending()); 757 DCHECK(impl().scheduler->CommitPending());
767 DCHECK(!impl().layer_tree_host_impl->pending_tree()); 758 DCHECK(!impl().layer_tree_host_impl->pending_tree());
(...skipping 12 matching lines...) Expand all
780 DCHECK(IsImplThread()); 771 DCHECK(IsImplThread());
781 772
782 impl().layer_tree_host_impl->Animate(); 773 impl().layer_tree_host_impl->Animate();
783 } 774 }
784 775
785 void ThreadProxy::ScheduledActionCommit() { 776 void ThreadProxy::ScheduledActionCommit() {
786 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionCommit"); 777 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionCommit");
787 DCHECK(IsImplThread()); 778 DCHECK(IsImplThread());
788 DCHECK(IsMainThreadBlocked()); 779 DCHECK(IsMainThreadBlocked());
789 DCHECK(impl().commit_completion_event); 780 DCHECK(impl().commit_completion_event);
781 DCHECK(blocked_main_commit().layer_tree_host);
790 782
791 blocked_main().main_thread_inside_commit = true;
792 impl().layer_tree_host_impl->BeginCommit(); 783 impl().layer_tree_host_impl->BeginCommit();
793 layer_tree_host()->FinishCommitOnImplThread( 784 blocked_main_commit().layer_tree_host->FinishCommitOnImplThread(
794 impl().layer_tree_host_impl.get()); 785 impl().layer_tree_host_impl.get());
795 blocked_main().main_thread_inside_commit = false;
796 786
797 bool hold_commit = blocked_main().commit_waits_for_activation; 787 // Remove the LayerTreeHost reference before the completion event is signaled
798 blocked_main().commit_waits_for_activation = false; 788 // and cleared. This is necessary since blocked_main_commit() allows access
789 // only while we have the completion event to ensure the main thread is
790 // blocked for a commit.
791 blocked_main_commit().layer_tree_host = nullptr;
799 792
800 if (hold_commit) { 793 if (impl().next_commit_waits_for_activation) {
801 // For some layer types in impl-side painting, the commit is held until 794 // For some layer types in impl-side painting, the commit is held until
802 // the sync tree is activated. It's also possible that the 795 // the sync tree is activated. It's also possible that the
803 // sync tree has already activated if there was no work to be done. 796 // sync tree has already activated if there was no work to be done.
804 TRACE_EVENT_INSTANT0("cc", "HoldCommit", TRACE_EVENT_SCOPE_THREAD); 797 TRACE_EVENT_INSTANT0("cc", "HoldCommit", TRACE_EVENT_SCOPE_THREAD);
805 impl().completion_event_for_commit_held_on_tree_activation =
806 impl().commit_completion_event;
807 impl().commit_completion_event = nullptr;
808 } else { 798 } else {
809 impl().commit_completion_event->Signal(); 799 impl().commit_completion_event->Signal();
810 impl().commit_completion_event = nullptr; 800 impl().commit_completion_event = nullptr;
811 } 801 }
812 802
813 impl().scheduler->DidCommit(); 803 impl().scheduler->DidCommit();
814 804
815 // Delay this step until afer the main thread has been released as it's 805 // Delay this step until afer the main thread has been released as it's
816 // often a good bit of work to update the tree and prepare the new frame. 806 // often a good bit of work to update the tree and prepare the new frame.
817 impl().layer_tree_host_impl->CommitComplete(); 807 impl().layer_tree_host_impl->CommitComplete();
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
930 NOTREACHED() << "Only used by SingleThreadProxy"; 920 NOTREACHED() << "Only used by SingleThreadProxy";
931 } 921 }
932 922
933 void ThreadProxy::SetAuthoritativeVSyncInterval( 923 void ThreadProxy::SetAuthoritativeVSyncInterval(
934 const base::TimeDelta& interval) { 924 const base::TimeDelta& interval) {
935 NOTREACHED() << "Only used by SingleThreadProxy"; 925 NOTREACHED() << "Only used by SingleThreadProxy";
936 } 926 }
937 927
938 void ThreadProxy::DidCommitAndDrawFrame() { 928 void ThreadProxy::DidCommitAndDrawFrame() {
939 DCHECK(IsMainThread()); 929 DCHECK(IsMainThread());
940 layer_tree_host()->DidCommitAndDrawFrame(); 930 main().layer_tree_host->DidCommitAndDrawFrame();
941 } 931 }
942 932
943 void ThreadProxy::DidCompleteSwapBuffers() { 933 void ThreadProxy::DidCompleteSwapBuffers() {
944 DCHECK(IsMainThread()); 934 DCHECK(IsMainThread());
945 layer_tree_host()->DidCompleteSwapBuffers(); 935 main().layer_tree_host->DidCompleteSwapBuffers();
946 } 936 }
947 937
948 void ThreadProxy::SetAnimationEvents(scoped_ptr<AnimationEventsVector> events) { 938 void ThreadProxy::SetAnimationEvents(scoped_ptr<AnimationEventsVector> events) {
949 TRACE_EVENT0("cc", "ThreadProxy::SetAnimationEvents"); 939 TRACE_EVENT0("cc", "ThreadProxy::SetAnimationEvents");
950 DCHECK(IsMainThread()); 940 DCHECK(IsMainThread());
951 layer_tree_host()->SetAnimationEvents(events.Pass()); 941 main().layer_tree_host->SetAnimationEvents(events.Pass());
952 } 942 }
953 943
954 void ThreadProxy::InitializeImplOnImplThread(CompletionEvent* completion) { 944 void ThreadProxy::InitializeImplOnImpl(CompletionEvent* completion,
945 LayerTreeHost* layer_tree_host) {
955 TRACE_EVENT0("cc", "ThreadProxy::InitializeImplOnImplThread"); 946 TRACE_EVENT0("cc", "ThreadProxy::InitializeImplOnImplThread");
956 DCHECK(IsImplThread()); 947 DCHECK(IsImplThread());
948 DCHECK(IsMainThreadBlocked());
949 DCHECK(layer_tree_host);
957 950
958 // TODO(khushalsagar): ThreadedChannel will create ProxyImpl here and pass a 951 // TODO(khushalsagar): ThreadedChannel will create ProxyImpl here and pass a
959 // reference to itself. 952 // reference to itself.
960 impl().channel_impl = threaded_channel_.get(); 953 impl().channel_impl = threaded_channel_.get();
961 954
962 impl().layer_tree_host_impl = 955 impl().layer_tree_host_impl = layer_tree_host->CreateLayerTreeHostImpl(this);
brianderson 2015/11/03 22:14:44 Can this be created on the main thread, then passe
Khushal 2015/11/03 23:07:52 The thread boundary separation for other channel i
963 layer_tree_host()->CreateLayerTreeHostImpl(this);
964 956
965 SchedulerSettings scheduler_settings( 957 SchedulerSettings scheduler_settings(
966 layer_tree_host()->settings().ToSchedulerSettings()); 958 layer_tree_host->settings().ToSchedulerSettings());
967 959
968 scoped_ptr<CompositorTimingHistory> compositor_timing_history( 960 scoped_ptr<CompositorTimingHistory> compositor_timing_history(
969 new CompositorTimingHistory(CompositorTimingHistory::RENDERER_UMA, 961 new CompositorTimingHistory(CompositorTimingHistory::RENDERER_UMA,
970 impl().rendering_stats_instrumentation)); 962 impl().rendering_stats_instrumentation));
971 963
972 impl().scheduler = Scheduler::Create( 964 impl().scheduler = Scheduler::Create(
973 this, scheduler_settings, impl().layer_tree_host_id, 965 this, scheduler_settings, impl().layer_tree_host_id,
974 ImplThreadTaskRunner(), impl().external_begin_frame_source.get(), 966 ImplThreadTaskRunner(), impl().external_begin_frame_source.get(),
975 compositor_timing_history.Pass()); 967 compositor_timing_history.Pass());
976 968
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1013 DCHECK(IsImplThread()); 1005 DCHECK(IsImplThread());
1014 if (impl().layer_tree_host_impl->output_surface()) { 1006 if (impl().layer_tree_host_impl->output_surface()) {
1015 ContextProvider* context_provider = 1007 ContextProvider* context_provider =
1016 impl().layer_tree_host_impl->output_surface()->context_provider(); 1008 impl().layer_tree_host_impl->output_surface()->context_provider();
1017 if (context_provider) 1009 if (context_provider)
1018 context_provider->ContextGL()->Finish(); 1010 context_provider->ContextGL()->Finish();
1019 } 1011 }
1020 completion->Signal(); 1012 completion->Signal();
1021 } 1013 }
1022 1014
1023 void ThreadProxy::LayerTreeHostClosedOnImplThread(CompletionEvent* completion) { 1015 void ThreadProxy::LayerTreeHostClosedOnImpl(CompletionEvent* completion) {
1024 TRACE_EVENT0("cc", "ThreadProxy::LayerTreeHostClosedOnImplThread"); 1016 TRACE_EVENT0("cc", "ThreadProxy::LayerTreeHostClosedOnImplThread");
1025 DCHECK(IsImplThread()); 1017 DCHECK(IsImplThread());
1026 DCHECK(IsMainThreadBlocked()); 1018 DCHECK(IsMainThreadBlocked());
1027 impl().scheduler = nullptr; 1019 impl().scheduler = nullptr;
1028 impl().external_begin_frame_source = nullptr; 1020 impl().external_begin_frame_source = nullptr;
1029 impl().layer_tree_host_impl = nullptr; 1021 impl().layer_tree_host_impl = nullptr;
1030 impl().weak_factory.InvalidateWeakPtrs(); 1022 impl().weak_factory.InvalidateWeakPtrs();
1031 // We need to explicitly shutdown the notifier to destroy any weakptrs it is 1023 // We need to explicitly shutdown the notifier to destroy any weakptrs it is
1032 // holding while still on the compositor thread. This also ensures any 1024 // holding while still on the compositor thread. This also ensures any
1033 // callbacks holding a ThreadProxy pointer are cancelled. 1025 // callbacks holding a ThreadProxy pointer are cancelled.
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
1117 void ThreadProxy::PostDelayedAnimationTaskOnImplThread( 1109 void ThreadProxy::PostDelayedAnimationTaskOnImplThread(
1118 const base::Closure& task, 1110 const base::Closure& task,
1119 base::TimeDelta delay) { 1111 base::TimeDelta delay) {
1120 Proxy::ImplThreadTaskRunner()->PostDelayedTask(FROM_HERE, task, delay); 1112 Proxy::ImplThreadTaskRunner()->PostDelayedTask(FROM_HERE, task, delay);
1121 } 1113 }
1122 1114
1123 void ThreadProxy::DidActivateSyncTree() { 1115 void ThreadProxy::DidActivateSyncTree() {
1124 TRACE_EVENT0("cc", "ThreadProxy::DidActivateSyncTreeOnImplThread"); 1116 TRACE_EVENT0("cc", "ThreadProxy::DidActivateSyncTreeOnImplThread");
1125 DCHECK(IsImplThread()); 1117 DCHECK(IsImplThread());
1126 1118
1127 if (impl().completion_event_for_commit_held_on_tree_activation) { 1119 if (impl().next_commit_waits_for_activation) {
1128 TRACE_EVENT_INSTANT0( 1120 TRACE_EVENT_INSTANT0(
1129 "cc", "ReleaseCommitbyActivation", TRACE_EVENT_SCOPE_THREAD); 1121 "cc", "ReleaseCommitbyActivation", TRACE_EVENT_SCOPE_THREAD);
1130 impl().completion_event_for_commit_held_on_tree_activation->Signal(); 1122 DCHECK(impl().commit_completion_event);
1131 impl().completion_event_for_commit_held_on_tree_activation = nullptr; 1123 impl().commit_completion_event->Signal();
1124 impl().commit_completion_event = nullptr;
1125 impl().next_commit_waits_for_activation = false;
1132 } 1126 }
1133 1127
1134 impl().last_processed_begin_main_frame_args = 1128 impl().last_processed_begin_main_frame_args =
1135 impl().last_begin_main_frame_args; 1129 impl().last_begin_main_frame_args;
1136 } 1130 }
1137 1131
1138 void ThreadProxy::WillPrepareTiles() { 1132 void ThreadProxy::WillPrepareTiles() {
1139 DCHECK(IsImplThread()); 1133 DCHECK(IsImplThread());
1140 impl().scheduler->WillPrepareTiles(); 1134 impl().scheduler->WillPrepareTiles();
1141 } 1135 }
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1175 scoped_ptr<FrameTimingTracker::MainFrameTimingSet> main_frame_events) { 1169 scoped_ptr<FrameTimingTracker::MainFrameTimingSet> main_frame_events) {
1176 DCHECK(IsImplThread()); 1170 DCHECK(IsImplThread());
1177 impl().channel_impl->PostFrameTimingEventsOnMain(composite_events.Pass(), 1171 impl().channel_impl->PostFrameTimingEventsOnMain(composite_events.Pass(),
1178 main_frame_events.Pass()); 1172 main_frame_events.Pass());
1179 } 1173 }
1180 1174
1181 void ThreadProxy::PostFrameTimingEventsOnMain( 1175 void ThreadProxy::PostFrameTimingEventsOnMain(
1182 scoped_ptr<FrameTimingTracker::CompositeTimingSet> composite_events, 1176 scoped_ptr<FrameTimingTracker::CompositeTimingSet> composite_events,
1183 scoped_ptr<FrameTimingTracker::MainFrameTimingSet> main_frame_events) { 1177 scoped_ptr<FrameTimingTracker::MainFrameTimingSet> main_frame_events) {
1184 DCHECK(IsMainThread()); 1178 DCHECK(IsMainThread());
1185 layer_tree_host()->RecordFrameTimingEvents(composite_events.Pass(), 1179 main().layer_tree_host->RecordFrameTimingEvents(composite_events.Pass(),
1186 main_frame_events.Pass()); 1180 main_frame_events.Pass());
1187 } 1181 }
1188 1182
1189 base::WeakPtr<ProxyMain> ThreadProxy::GetMainWeakPtr() { 1183 base::WeakPtr<ProxyMain> ThreadProxy::GetMainWeakPtr() {
1190 return main_thread_weak_ptr_; 1184 return main_thread_weak_ptr_;
1191 } 1185 }
1192 1186
1193 base::WeakPtr<ProxyImpl> ThreadProxy::GetImplWeakPtr() { 1187 base::WeakPtr<ProxyImpl> ThreadProxy::GetImplWeakPtr() {
1194 return impl_thread_weak_ptr_; 1188 return impl_thread_weak_ptr_;
1195 } 1189 }
1196 1190
1197 } // namespace cc 1191 } // 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