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

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

Issue 348093004: Make cc output surface creation async (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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 | Annotate | Revision Log
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/debug/trace_event.h" 8 #include "base/debug/trace_event.h"
9 #include "cc/debug/benchmark_instrumentation.h" 9 #include "cc/debug/benchmark_instrumentation.h"
10 #include "cc/output/context_provider.h" 10 #include "cc/output/context_provider.h"
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 void SingleThreadProxy::SetVisible(bool visible) { 94 void SingleThreadProxy::SetVisible(bool visible) {
95 TRACE_EVENT0("cc", "SingleThreadProxy::SetVisible"); 95 TRACE_EVENT0("cc", "SingleThreadProxy::SetVisible");
96 DebugScopedSetImplThread impl(this); 96 DebugScopedSetImplThread impl(this);
97 layer_tree_host_impl_->SetVisible(visible); 97 layer_tree_host_impl_->SetVisible(visible);
98 if (scheduler_on_impl_thread_) 98 if (scheduler_on_impl_thread_)
99 scheduler_on_impl_thread_->SetVisible(layer_tree_host_impl_->visible()); 99 scheduler_on_impl_thread_->SetVisible(layer_tree_host_impl_->visible());
100 // Changing visibility could change ShouldComposite(). 100 // Changing visibility could change ShouldComposite().
101 UpdateBackgroundAnimateTicking(); 101 UpdateBackgroundAnimateTicking();
102 } 102 }
103 103
104 void SingleThreadProxy::CreateAndInitializeOutputSurface() { 104 void SingleThreadProxy::RequestNewOutputSurface() {
105 TRACE_EVENT0(
106 "cc", "SingleThreadProxy::CreateAndInitializeOutputSurface");
107 DCHECK(Proxy::IsMainThread()); 105 DCHECK(Proxy::IsMainThread());
108 DCHECK(layer_tree_host_->output_surface_lost()); 106 DCHECK(layer_tree_host_->output_surface_lost());
107 layer_tree_host_->RequestNewOutputSurface();
108 }
109 109
110 scoped_ptr<OutputSurface> output_surface = 110 void SingleThreadProxy::SetOutputSurface(
111 layer_tree_host_->CreateOutputSurface(); 111 scoped_ptr<OutputSurface> output_surface) {
112 112 DCHECK(Proxy::IsMainThread());
113 DCHECK(layer_tree_host_->output_surface_lost());
113 renderer_capabilities_for_main_thread_ = RendererCapabilities(); 114 renderer_capabilities_for_main_thread_ = RendererCapabilities();
114 115
115 bool success = !!output_surface; 116 bool success = !!output_surface;
116 if (success) { 117 if (success) {
danakj 2014/06/20 23:36:34 Do we want the embedder to be able to call back wi
enne (OOO) 2014/06/23 16:57:39 I think the ultimate answer is no, but I don't kno
117 DebugScopedSetMainThreadBlocked main_thread_blocked(this); 118 DebugScopedSetMainThreadBlocked main_thread_blocked(this);
118 DebugScopedSetImplThread impl(this); 119 DebugScopedSetImplThread impl(this);
119 layer_tree_host_->DeleteContentsTexturesOnImplThread( 120 layer_tree_host_->DeleteContentsTexturesOnImplThread(
120 layer_tree_host_impl_->resource_provider()); 121 layer_tree_host_impl_->resource_provider());
121 success = layer_tree_host_impl_->InitializeRenderer(output_surface.Pass()); 122 success = layer_tree_host_impl_->InitializeRenderer(output_surface.Pass());
122 } 123 }
123 124
124 layer_tree_host_->OnCreateAndInitializeOutputSurfaceAttempted(success); 125 layer_tree_host_->OnCreateAndInitializeOutputSurfaceAttempted(success);
125 126
126 if (success) { 127 if (success) {
127 if (scheduler_on_impl_thread_) 128 if (scheduler_on_impl_thread_)
128 scheduler_on_impl_thread_->DidCreateAndInitializeOutputSurface(); 129 scheduler_on_impl_thread_->DidCreateAndInitializeOutputSurface();
129 } else if (Proxy::MainThreadTaskRunner()) { 130 } else if (Proxy::MainThreadTaskRunner()) {
130 Proxy::MainThreadTaskRunner()->PostTask( 131 Proxy::MainThreadTaskRunner()->PostTask(
131 FROM_HERE, 132 FROM_HERE,
132 base::Bind(&SingleThreadProxy::CreateAndInitializeOutputSurface, 133 base::Bind(&SingleThreadProxy::RequestNewOutputSurface,
133 weak_factory_.GetWeakPtr())); 134 weak_factory_.GetWeakPtr()));
134 } 135 }
135 } 136 }
136 137
137 const RendererCapabilities& SingleThreadProxy::GetRendererCapabilities() const { 138 const RendererCapabilities& SingleThreadProxy::GetRendererCapabilities() const {
138 DCHECK(Proxy::IsMainThread()); 139 DCHECK(Proxy::IsMainThread());
139 DCHECK(!layer_tree_host_->output_surface_lost()); 140 DCHECK(!layer_tree_host_->output_surface_lost());
140 return renderer_capabilities_for_main_thread_; 141 return renderer_capabilities_for_main_thread_;
141 } 142 }
142 143
(...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after
617 void SingleThreadProxy::ScheduledActionBeginOutputSurfaceCreation() { 618 void SingleThreadProxy::ScheduledActionBeginOutputSurfaceCreation() {
618 DebugScopedSetMainThread main(this); 619 DebugScopedSetMainThread main(this);
619 DCHECK(scheduler_on_impl_thread_); 620 DCHECK(scheduler_on_impl_thread_);
620 // If possible, create the output surface in a post task. Synchronously 621 // If possible, create the output surface in a post task. Synchronously
621 // creating the output surface makes tests more awkward since this differs 622 // creating the output surface makes tests more awkward since this differs
622 // from the ThreadProxy behavior. However, sometimes there is no 623 // from the ThreadProxy behavior. However, sometimes there is no
623 // task runner. 624 // task runner.
624 if (Proxy::MainThreadTaskRunner()) { 625 if (Proxy::MainThreadTaskRunner()) {
625 Proxy::MainThreadTaskRunner()->PostTask( 626 Proxy::MainThreadTaskRunner()->PostTask(
626 FROM_HERE, 627 FROM_HERE,
627 base::Bind(&SingleThreadProxy::CreateAndInitializeOutputSurface, 628 base::Bind(&SingleThreadProxy::RequestNewOutputSurface,
628 weak_factory_.GetWeakPtr())); 629 weak_factory_.GetWeakPtr()));
629 } else { 630 } else {
630 CreateAndInitializeOutputSurface(); 631 RequestNewOutputSurface();
631 } 632 }
632 } 633 }
633 634
634 void SingleThreadProxy::ScheduledActionManageTiles() { 635 void SingleThreadProxy::ScheduledActionManageTiles() {
635 // Impl-side painting only. 636 // Impl-side painting only.
636 NOTREACHED(); 637 NOTREACHED();
637 } 638 }
638 639
639 void SingleThreadProxy::DidAnticipatedDrawTimeChange(base::TimeTicks time) { 640 void SingleThreadProxy::DidAnticipatedDrawTimeChange(base::TimeTicks time) {
640 } 641 }
641 642
642 base::TimeDelta SingleThreadProxy::DrawDurationEstimate() { 643 base::TimeDelta SingleThreadProxy::DrawDurationEstimate() {
643 return timing_history_.DrawDurationEstimate(); 644 return timing_history_.DrawDurationEstimate();
644 } 645 }
645 646
646 base::TimeDelta SingleThreadProxy::BeginMainFrameToCommitDurationEstimate() { 647 base::TimeDelta SingleThreadProxy::BeginMainFrameToCommitDurationEstimate() {
647 return timing_history_.BeginMainFrameToCommitDurationEstimate(); 648 return timing_history_.BeginMainFrameToCommitDurationEstimate();
648 } 649 }
649 650
650 base::TimeDelta SingleThreadProxy::CommitToActivateDurationEstimate() { 651 base::TimeDelta SingleThreadProxy::CommitToActivateDurationEstimate() {
651 return timing_history_.CommitToActivateDurationEstimate(); 652 return timing_history_.CommitToActivateDurationEstimate();
652 } 653 }
653 654
654 void SingleThreadProxy::DidBeginImplFrameDeadline() { 655 void SingleThreadProxy::DidBeginImplFrameDeadline() {
655 layer_tree_host_impl_->ResetCurrentFrameTimeForNextFrame(); 656 layer_tree_host_impl_->ResetCurrentFrameTimeForNextFrame();
656 } 657 }
657 658
658 } // namespace cc 659 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698