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

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

Issue 2757373002: Fixing flakiness of TextureLayerChangeInvisibleMailboxTest (Closed)
Patch Set: Invalidate on DidLose 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_impl.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 compositor_frame_sink_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 compositor_frame_sink_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
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 scheduler_on_impl_thread_->DidPrepareTiles(); 398 scheduler_on_impl_thread_->DidPrepareTiles();
397 } 399 }
398 400
399 void SingleThreadProxy::DidCompletePageScaleAnimationOnImplThread() { 401 void SingleThreadProxy::DidCompletePageScaleAnimationOnImplThread() {
400 layer_tree_host_->DidCompletePageScaleAnimation(); 402 layer_tree_host_->DidCompletePageScaleAnimation();
401 } 403 }
402 404
403 void SingleThreadProxy::DidLoseCompositorFrameSinkOnImplThread() { 405 void SingleThreadProxy::DidLoseCompositorFrameSinkOnImplThread() {
404 TRACE_EVENT0("cc", 406 TRACE_EVENT0("cc",
405 "SingleThreadProxy::DidLoseCompositorFrameSinkOnImplThread"); 407 "SingleThreadProxy::DidLoseCompositorFrameSinkOnImplThread");
408 compositor_frame_sink_weak_factory_.InvalidateWeakPtrs();
406 { 409 {
407 DebugScopedSetMainThread main(task_runner_provider_); 410 DebugScopedSetMainThread main(task_runner_provider_);
408 // This must happen before we notify the scheduler as it may try to recreate 411 // 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. 412 // the output surface if already in BEGIN_IMPL_FRAME_STATE_IDLE.
410 layer_tree_host_->DidLoseCompositorFrameSink(); 413 layer_tree_host_->DidLoseCompositorFrameSink();
411 } 414 }
412 single_thread_client_->DidLoseCompositorFrameSink(); 415 single_thread_client_->DidLoseCompositorFrameSink();
413 if (scheduler_on_impl_thread_) 416 if (scheduler_on_impl_thread_)
414 scheduler_on_impl_thread_->DidLoseCompositorFrameSink(); 417 scheduler_on_impl_thread_->DidLoseCompositorFrameSink();
415 compositor_frame_sink_lost_ = true; 418 compositor_frame_sink_lost_ = true;
416 } 419 }
417 420
418 void SingleThreadProxy::SetBeginFrameSource(BeginFrameSource* source) { 421 void SingleThreadProxy::SetBeginFrameSource(BeginFrameSource* source) {
419 if (scheduler_on_impl_thread_) 422 if (scheduler_on_impl_thread_)
420 scheduler_on_impl_thread_->SetBeginFrameSource(source); 423 scheduler_on_impl_thread_->SetBeginFrameSource(source);
421 } 424 }
422 425
423 void SingleThreadProxy::DidReceiveCompositorFrameAckOnImplThread() { 426 void SingleThreadProxy::DidReceiveCompositorFrameAckOnImplThread() {
424 TRACE_EVENT0("cc,benchmark", 427 TRACE_EVENT0("cc,benchmark",
425 "SingleThreadProxy::DidReceiveCompositorFrameAckOnImplThread"); 428 "SingleThreadProxy::DidReceiveCompositorFrameAckOnImplThread");
426 if (scheduler_on_impl_thread_) 429 if (scheduler_on_impl_thread_)
427 scheduler_on_impl_thread_->DidReceiveCompositorFrameAck(); 430 scheduler_on_impl_thread_->DidReceiveCompositorFrameAck();
428 layer_tree_host_->DidReceiveCompositorFrameAck(); 431 // We do a PostTask here because freeing resources in some cases (such as in
432 // TextureLayer) is PostTasked and we want to make sure ack is received after
433 // resources are returned.
434 task_runner_provider_->MainThreadTaskRunner()->PostTask(
435 FROM_HERE, base::Bind(&SingleThreadProxy::DidReceiveCompositorFrameAck,
436 compositor_frame_sink_weak_factory_.GetWeakPtr()));
429 } 437 }
430 438
431 void SingleThreadProxy::OnDrawForCompositorFrameSink( 439 void SingleThreadProxy::OnDrawForCompositorFrameSink(
432 bool resourceless_software_draw) { 440 bool resourceless_software_draw) {
433 NOTREACHED() << "Implemented by ThreadProxy for synchronous compositor."; 441 NOTREACHED() << "Implemented by ThreadProxy for synchronous compositor.";
434 } 442 }
435 443
436 void SingleThreadProxy::NeedsImplSideInvalidation() { 444 void SingleThreadProxy::NeedsImplSideInvalidation() {
437 DCHECK(scheduler_on_impl_thread_); 445 DCHECK(scheduler_on_impl_thread_);
438 scheduler_on_impl_thread_->SetNeedsImplSideInvalidation(); 446 scheduler_on_impl_thread_->SetNeedsImplSideInvalidation();
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
787 795
788 void SingleThreadProxy::DidFinishImplFrame() { 796 void SingleThreadProxy::DidFinishImplFrame() {
789 layer_tree_host_impl_->DidFinishImplFrame(); 797 layer_tree_host_impl_->DidFinishImplFrame();
790 #if DCHECK_IS_ON() 798 #if DCHECK_IS_ON()
791 DCHECK(inside_impl_frame_) 799 DCHECK(inside_impl_frame_)
792 << "DidFinishImplFrame called while not inside an impl frame!"; 800 << "DidFinishImplFrame called while not inside an impl frame!";
793 inside_impl_frame_ = false; 801 inside_impl_frame_ = false;
794 #endif 802 #endif
795 } 803 }
796 804
805 void SingleThreadProxy::DidReceiveCompositorFrameAck() {
806 layer_tree_host_->DidReceiveCompositorFrameAck();
807 }
808
797 } // namespace cc 809 } // namespace cc
OLDNEW
« cc/trees/proxy_impl.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