OLD | NEW |
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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 void SingleThreadProxy::SetVisible(bool visible) { | 100 void SingleThreadProxy::SetVisible(bool visible) { |
101 TRACE_EVENT0("cc", "SingleThreadProxy::SetVisible"); | 101 TRACE_EVENT0("cc", "SingleThreadProxy::SetVisible"); |
102 DebugScopedSetImplThread impl(this); | 102 DebugScopedSetImplThread impl(this); |
103 layer_tree_host_impl_->SetVisible(visible); | 103 layer_tree_host_impl_->SetVisible(visible); |
104 if (scheduler_on_impl_thread_) | 104 if (scheduler_on_impl_thread_) |
105 scheduler_on_impl_thread_->SetVisible(layer_tree_host_impl_->visible()); | 105 scheduler_on_impl_thread_->SetVisible(layer_tree_host_impl_->visible()); |
106 // Changing visibility could change ShouldComposite(). | 106 // Changing visibility could change ShouldComposite(). |
107 UpdateBackgroundAnimateTicking(); | 107 UpdateBackgroundAnimateTicking(); |
108 } | 108 } |
109 | 109 |
110 void SingleThreadProxy::RequestNewOutputSurface() { | 110 void SingleThreadProxy::CreateAndInitializeOutputSurface() { |
| 111 TRACE_EVENT0( |
| 112 "cc", "SingleThreadProxy::CreateAndInitializeOutputSurface"); |
111 DCHECK(Proxy::IsMainThread()); | 113 DCHECK(Proxy::IsMainThread()); |
112 DCHECK(layer_tree_host_->output_surface_lost()); | 114 DCHECK(layer_tree_host_->output_surface_lost()); |
113 layer_tree_host_->RequestNewOutputSurface(); | |
114 } | |
115 | 115 |
116 void SingleThreadProxy::SetOutputSurface( | 116 scoped_ptr<OutputSurface> output_surface = |
117 scoped_ptr<OutputSurface> output_surface) { | 117 layer_tree_host_->CreateOutputSurface(); |
118 DCHECK(Proxy::IsMainThread()); | 118 |
119 DCHECK(layer_tree_host_->output_surface_lost()); | |
120 renderer_capabilities_for_main_thread_ = RendererCapabilities(); | 119 renderer_capabilities_for_main_thread_ = RendererCapabilities(); |
121 | 120 |
122 bool success = !!output_surface; | 121 bool success = !!output_surface; |
123 if (success) { | 122 if (success) { |
124 DebugScopedSetMainThreadBlocked main_thread_blocked(this); | 123 DebugScopedSetMainThreadBlocked main_thread_blocked(this); |
125 DebugScopedSetImplThread impl(this); | 124 DebugScopedSetImplThread impl(this); |
126 layer_tree_host_->DeleteContentsTexturesOnImplThread( | 125 layer_tree_host_->DeleteContentsTexturesOnImplThread( |
127 layer_tree_host_impl_->resource_provider()); | 126 layer_tree_host_impl_->resource_provider()); |
128 success = layer_tree_host_impl_->InitializeRenderer(output_surface.Pass()); | 127 success = layer_tree_host_impl_->InitializeRenderer(output_surface.Pass()); |
129 } | 128 } |
130 | 129 |
131 layer_tree_host_->OnCreateAndInitializeOutputSurfaceAttempted(success); | 130 layer_tree_host_->OnCreateAndInitializeOutputSurfaceAttempted(success); |
132 | 131 |
133 if (success) { | 132 if (success) { |
134 if (scheduler_on_impl_thread_) | 133 if (scheduler_on_impl_thread_) |
135 scheduler_on_impl_thread_->DidCreateAndInitializeOutputSurface(); | 134 scheduler_on_impl_thread_->DidCreateAndInitializeOutputSurface(); |
136 } else if (Proxy::MainThreadTaskRunner()) { | 135 } else if (Proxy::MainThreadTaskRunner()) { |
137 MainThreadTaskRunner()->PostTask( | 136 MainThreadTaskRunner()->PostTask( |
138 FROM_HERE, | 137 FROM_HERE, |
139 base::Bind(&SingleThreadProxy::RequestNewOutputSurface, | 138 base::Bind(&SingleThreadProxy::CreateAndInitializeOutputSurface, |
140 weak_factory_.GetWeakPtr())); | 139 weak_factory_.GetWeakPtr())); |
141 } | 140 } |
142 } | 141 } |
143 | 142 |
144 const RendererCapabilities& SingleThreadProxy::GetRendererCapabilities() const { | 143 const RendererCapabilities& SingleThreadProxy::GetRendererCapabilities() const { |
145 DCHECK(Proxy::IsMainThread()); | 144 DCHECK(Proxy::IsMainThread()); |
146 DCHECK(!layer_tree_host_->output_surface_lost()); | 145 DCHECK(!layer_tree_host_->output_surface_lost()); |
147 return renderer_capabilities_for_main_thread_; | 146 return renderer_capabilities_for_main_thread_; |
148 } | 147 } |
149 | 148 |
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
658 void SingleThreadProxy::ScheduledActionBeginOutputSurfaceCreation() { | 657 void SingleThreadProxy::ScheduledActionBeginOutputSurfaceCreation() { |
659 DebugScopedSetMainThread main(this); | 658 DebugScopedSetMainThread main(this); |
660 DCHECK(scheduler_on_impl_thread_); | 659 DCHECK(scheduler_on_impl_thread_); |
661 // If possible, create the output surface in a post task. Synchronously | 660 // If possible, create the output surface in a post task. Synchronously |
662 // creating the output surface makes tests more awkward since this differs | 661 // creating the output surface makes tests more awkward since this differs |
663 // from the ThreadProxy behavior. However, sometimes there is no | 662 // from the ThreadProxy behavior. However, sometimes there is no |
664 // task runner. | 663 // task runner. |
665 if (Proxy::MainThreadTaskRunner()) { | 664 if (Proxy::MainThreadTaskRunner()) { |
666 MainThreadTaskRunner()->PostTask( | 665 MainThreadTaskRunner()->PostTask( |
667 FROM_HERE, | 666 FROM_HERE, |
668 base::Bind(&SingleThreadProxy::RequestNewOutputSurface, | 667 base::Bind(&SingleThreadProxy::CreateAndInitializeOutputSurface, |
669 weak_factory_.GetWeakPtr())); | 668 weak_factory_.GetWeakPtr())); |
670 } else { | 669 } else { |
671 RequestNewOutputSurface(); | 670 CreateAndInitializeOutputSurface(); |
672 } | 671 } |
673 } | 672 } |
674 | 673 |
675 void SingleThreadProxy::ScheduledActionManageTiles() { | 674 void SingleThreadProxy::ScheduledActionManageTiles() { |
676 // Impl-side painting only. | 675 // Impl-side painting only. |
677 NOTREACHED(); | 676 NOTREACHED(); |
678 } | 677 } |
679 | 678 |
680 void SingleThreadProxy::DidAnticipatedDrawTimeChange(base::TimeTicks time) { | 679 void SingleThreadProxy::DidAnticipatedDrawTimeChange(base::TimeTicks time) { |
681 } | 680 } |
682 | 681 |
683 base::TimeDelta SingleThreadProxy::DrawDurationEstimate() { | 682 base::TimeDelta SingleThreadProxy::DrawDurationEstimate() { |
684 return timing_history_.DrawDurationEstimate(); | 683 return timing_history_.DrawDurationEstimate(); |
685 } | 684 } |
686 | 685 |
687 base::TimeDelta SingleThreadProxy::BeginMainFrameToCommitDurationEstimate() { | 686 base::TimeDelta SingleThreadProxy::BeginMainFrameToCommitDurationEstimate() { |
688 return timing_history_.BeginMainFrameToCommitDurationEstimate(); | 687 return timing_history_.BeginMainFrameToCommitDurationEstimate(); |
689 } | 688 } |
690 | 689 |
691 base::TimeDelta SingleThreadProxy::CommitToActivateDurationEstimate() { | 690 base::TimeDelta SingleThreadProxy::CommitToActivateDurationEstimate() { |
692 return timing_history_.CommitToActivateDurationEstimate(); | 691 return timing_history_.CommitToActivateDurationEstimate(); |
693 } | 692 } |
694 | 693 |
695 void SingleThreadProxy::DidBeginImplFrameDeadline() { | 694 void SingleThreadProxy::DidBeginImplFrameDeadline() { |
696 layer_tree_host_impl_->ResetCurrentBeginFrameArgsForNextFrame(); | 695 layer_tree_host_impl_->ResetCurrentBeginFrameArgsForNextFrame(); |
697 } | 696 } |
698 | 697 |
699 } // namespace cc | 698 } // namespace cc |
OLD | NEW |