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

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

Issue 2757373002: Fixing flakiness of TextureLayerChangeInvisibleMailboxTest (Closed)
Patch Set: Rename Created 3 years, 8 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
« cc/trees/proxy_main.cc ('K') | « cc/trees/single_thread_proxy.h ('k') | no next file » | 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/single_thread_proxy.h" 5 #include "cc/trees/single_thread_proxy.h"
6 6
7 #include "base/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "base/memory/ptr_util.h" 8 #include "base/memory/ptr_util.h"
9 #include "base/profiler/scoped_tracker.h" 9 #include "base/profiler/scoped_tracker.h"
10 #include "base/trace_event/trace_event.h" 10 #include "base/trace_event/trace_event.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 #if DCHECK_IS_ON() 45 #if DCHECK_IS_ON()
46 inside_impl_frame_(false), 46 inside_impl_frame_(false),
47 #endif 47 #endif
48 inside_draw_(false), 48 inside_draw_(false),
49 defer_commits_(false), 49 defer_commits_(false),
50 animate_requested_(false), 50 animate_requested_(false),
51 commit_requested_(false), 51 commit_requested_(false),
52 inside_synchronous_composite_(false), 52 inside_synchronous_composite_(false),
53 compositor_frame_sink_creation_requested_(false), 53 compositor_frame_sink_creation_requested_(false),
54 compositor_frame_sink_lost_(true), 54 compositor_frame_sink_lost_(true),
55 frame_sink_bound_weak_factory_(this),
55 weak_factory_(this) { 56 weak_factory_(this) {
56 TRACE_EVENT0("cc", "SingleThreadProxy::SingleThreadProxy"); 57 TRACE_EVENT0("cc", "SingleThreadProxy::SingleThreadProxy");
57 DCHECK(task_runner_provider_); 58 DCHECK(task_runner_provider_);
58 DCHECK(task_runner_provider_->IsMainThread()); 59 DCHECK(task_runner_provider_->IsMainThread());
59 DCHECK(layer_tree_host); 60 DCHECK(layer_tree_host);
60 } 61 }
61 62
62 void SingleThreadProxy::Start() { 63 void SingleThreadProxy::Start() {
63 DebugScopedSetImplThread impl(task_runner_provider_); 64 DebugScopedSetImplThread impl(task_runner_provider_);
64 65
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 DCHECK(task_runner_provider_->IsMainThread()); 117 DCHECK(task_runner_provider_->IsMainThread());
117 compositor_frame_sink_creation_callback_.Cancel(); 118 compositor_frame_sink_creation_callback_.Cancel();
118 if (compositor_frame_sink_creation_requested_) 119 if (compositor_frame_sink_creation_requested_)
119 return; 120 return;
120 compositor_frame_sink_creation_requested_ = true; 121 compositor_frame_sink_creation_requested_ = true;
121 layer_tree_host_->RequestNewCompositorFrameSink(); 122 layer_tree_host_->RequestNewCompositorFrameSink();
122 } 123 }
123 124
124 void SingleThreadProxy::ReleaseCompositorFrameSink() { 125 void SingleThreadProxy::ReleaseCompositorFrameSink() {
125 compositor_frame_sink_lost_ = true; 126 compositor_frame_sink_lost_ = true;
127 frame_sink_bound_weak_factory_.InvalidateWeakPtrs();
126 if (scheduler_on_impl_thread_) 128 if (scheduler_on_impl_thread_)
127 scheduler_on_impl_thread_->DidLoseCompositorFrameSink(); 129 scheduler_on_impl_thread_->DidLoseCompositorFrameSink();
128 return layer_tree_host_impl_->ReleaseCompositorFrameSink(); 130 return layer_tree_host_impl_->ReleaseCompositorFrameSink();
129 } 131 }
130 132
131 void SingleThreadProxy::SetCompositorFrameSink( 133 void SingleThreadProxy::SetCompositorFrameSink(
132 CompositorFrameSink* compositor_frame_sink) { 134 CompositorFrameSink* compositor_frame_sink) {
133 DCHECK(task_runner_provider_->IsMainThread()); 135 DCHECK(task_runner_provider_->IsMainThread());
134 DCHECK(compositor_frame_sink_creation_requested_); 136 DCHECK(compositor_frame_sink_creation_requested_);
135 137
136 bool success; 138 bool success;
137 { 139 {
138 DebugScopedSetMainThreadBlocked main_thread_blocked(task_runner_provider_); 140 DebugScopedSetMainThreadBlocked main_thread_blocked(task_runner_provider_);
139 DebugScopedSetImplThread impl(task_runner_provider_); 141 DebugScopedSetImplThread impl(task_runner_provider_);
140 success = layer_tree_host_impl_->InitializeRenderer(compositor_frame_sink); 142 success = layer_tree_host_impl_->InitializeRenderer(compositor_frame_sink);
141 } 143 }
142 144
143 if (success) { 145 if (success) {
146 frame_sink_bound_weak_ptr_ = frame_sink_bound_weak_factory_.GetWeakPtr();
144 layer_tree_host_->DidInitializeCompositorFrameSink(); 147 layer_tree_host_->DidInitializeCompositorFrameSink();
145 if (scheduler_on_impl_thread_) 148 if (scheduler_on_impl_thread_)
146 scheduler_on_impl_thread_->DidCreateAndInitializeCompositorFrameSink(); 149 scheduler_on_impl_thread_->DidCreateAndInitializeCompositorFrameSink();
147 else if (!inside_synchronous_composite_) 150 else if (!inside_synchronous_composite_)
148 SetNeedsCommit(); 151 SetNeedsCommit();
149 compositor_frame_sink_creation_requested_ = false; 152 compositor_frame_sink_creation_requested_ = false;
150 compositor_frame_sink_lost_ = false; 153 compositor_frame_sink_lost_ = false;
151 } else { 154 } else {
152 // DidFailToInitializeCompositorFrameSink is treated as a 155 // DidFailToInitializeCompositorFrameSink is treated as a
153 // RequestNewCompositorFrameSink, and so 156 // RequestNewCompositorFrameSink, and so
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 scheduler_on_impl_thread_->DidPrepareTiles(); 399 scheduler_on_impl_thread_->DidPrepareTiles();
397 } 400 }
398 401
399 void SingleThreadProxy::DidCompletePageScaleAnimationOnImplThread() { 402 void SingleThreadProxy::DidCompletePageScaleAnimationOnImplThread() {
400 layer_tree_host_->DidCompletePageScaleAnimation(); 403 layer_tree_host_->DidCompletePageScaleAnimation();
401 } 404 }
402 405
403 void SingleThreadProxy::DidLoseCompositorFrameSinkOnImplThread() { 406 void SingleThreadProxy::DidLoseCompositorFrameSinkOnImplThread() {
404 TRACE_EVENT0("cc", 407 TRACE_EVENT0("cc",
405 "SingleThreadProxy::DidLoseCompositorFrameSinkOnImplThread"); 408 "SingleThreadProxy::DidLoseCompositorFrameSinkOnImplThread");
409 frame_sink_bound_weak_factory_.InvalidateWeakPtrs();
danakj 2017/04/18 20:58:42 same here
Saman Sami 2017/04/18 21:37:13 Removed.
406 { 410 {
407 DebugScopedSetMainThread main(task_runner_provider_); 411 DebugScopedSetMainThread main(task_runner_provider_);
408 // This must happen before we notify the scheduler as it may try to recreate 412 // This must happen before we notify the scheduler as it may try to recreate
409 // the output surface if already in BEGIN_IMPL_FRAME_STATE_IDLE. 413 // the output surface if already in BEGIN_IMPL_FRAME_STATE_IDLE.
410 layer_tree_host_->DidLoseCompositorFrameSink(); 414 layer_tree_host_->DidLoseCompositorFrameSink();
411 } 415 }
412 single_thread_client_->DidLoseCompositorFrameSink(); 416 single_thread_client_->DidLoseCompositorFrameSink();
413 if (scheduler_on_impl_thread_) 417 if (scheduler_on_impl_thread_)
414 scheduler_on_impl_thread_->DidLoseCompositorFrameSink(); 418 scheduler_on_impl_thread_->DidLoseCompositorFrameSink();
415 compositor_frame_sink_lost_ = true; 419 compositor_frame_sink_lost_ = true;
416 } 420 }
417 421
418 void SingleThreadProxy::SetBeginFrameSource(BeginFrameSource* source) { 422 void SingleThreadProxy::SetBeginFrameSource(BeginFrameSource* source) {
419 if (scheduler_on_impl_thread_) 423 if (scheduler_on_impl_thread_)
420 scheduler_on_impl_thread_->SetBeginFrameSource(source); 424 scheduler_on_impl_thread_->SetBeginFrameSource(source);
421 } 425 }
422 426
423 void SingleThreadProxy::DidReceiveCompositorFrameAckOnImplThread() { 427 void SingleThreadProxy::DidReceiveCompositorFrameAckOnImplThread() {
424 TRACE_EVENT0("cc,benchmark", 428 TRACE_EVENT0("cc,benchmark",
425 "SingleThreadProxy::DidReceiveCompositorFrameAckOnImplThread"); 429 "SingleThreadProxy::DidReceiveCompositorFrameAckOnImplThread");
426 if (scheduler_on_impl_thread_) 430 if (scheduler_on_impl_thread_)
427 scheduler_on_impl_thread_->DidReceiveCompositorFrameAck(); 431 scheduler_on_impl_thread_->DidReceiveCompositorFrameAck();
428 layer_tree_host_->DidReceiveCompositorFrameAck(); 432 // We do a PostTask here because freeing resources in some cases (such as in
433 // TextureLayer) is PostTasked and we want to make sure ack is received after
434 // resources are returned.
435 task_runner_provider_->MainThreadTaskRunner()->PostTask(
436 FROM_HERE, base::Bind(&SingleThreadProxy::DidReceiveCompositorFrameAck,
437 frame_sink_bound_weak_ptr_));
429 } 438 }
430 439
431 void SingleThreadProxy::OnDrawForCompositorFrameSink( 440 void SingleThreadProxy::OnDrawForCompositorFrameSink(
432 bool resourceless_software_draw) { 441 bool resourceless_software_draw) {
433 NOTREACHED() << "Implemented by ThreadProxy for synchronous compositor."; 442 NOTREACHED() << "Implemented by ThreadProxy for synchronous compositor.";
434 } 443 }
435 444
436 void SingleThreadProxy::NeedsImplSideInvalidation() { 445 void SingleThreadProxy::NeedsImplSideInvalidation() {
437 DCHECK(scheduler_on_impl_thread_); 446 DCHECK(scheduler_on_impl_thread_);
438 scheduler_on_impl_thread_->SetNeedsImplSideInvalidation(); 447 scheduler_on_impl_thread_->SetNeedsImplSideInvalidation();
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
787 796
788 void SingleThreadProxy::DidFinishImplFrame() { 797 void SingleThreadProxy::DidFinishImplFrame() {
789 layer_tree_host_impl_->DidFinishImplFrame(); 798 layer_tree_host_impl_->DidFinishImplFrame();
790 #if DCHECK_IS_ON() 799 #if DCHECK_IS_ON()
791 DCHECK(inside_impl_frame_) 800 DCHECK(inside_impl_frame_)
792 << "DidFinishImplFrame called while not inside an impl frame!"; 801 << "DidFinishImplFrame called while not inside an impl frame!";
793 inside_impl_frame_ = false; 802 inside_impl_frame_ = false;
794 #endif 803 #endif
795 } 804 }
796 805
806 void SingleThreadProxy::DidReceiveCompositorFrameAck() {
807 layer_tree_host_->DidReceiveCompositorFrameAck();
808 }
809
797 } // namespace cc 810 } // namespace cc
OLDNEW
« cc/trees/proxy_main.cc ('K') | « cc/trees/single_thread_proxy.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698