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 25 matching lines...) Expand all Loading... |
36 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner) | 36 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner) |
37 : Proxy(main_task_runner, NULL), | 37 : Proxy(main_task_runner, NULL), |
38 layer_tree_host_(layer_tree_host), | 38 layer_tree_host_(layer_tree_host), |
39 client_(client), | 39 client_(client), |
40 timing_history_(layer_tree_host->rendering_stats_instrumentation()), | 40 timing_history_(layer_tree_host->rendering_stats_instrumentation()), |
41 next_frame_is_newly_committed_frame_(false), | 41 next_frame_is_newly_committed_frame_(false), |
42 inside_draw_(false), | 42 inside_draw_(false), |
43 defer_commits_(false), | 43 defer_commits_(false), |
44 commit_was_deferred_(false), | 44 commit_was_deferred_(false), |
45 commit_requested_(false), | 45 commit_requested_(false), |
| 46 host_client_finished_(false), |
46 weak_factory_(this) { | 47 weak_factory_(this) { |
47 TRACE_EVENT0("cc", "SingleThreadProxy::SingleThreadProxy"); | 48 TRACE_EVENT0("cc", "SingleThreadProxy::SingleThreadProxy"); |
48 DCHECK(Proxy::IsMainThread()); | 49 DCHECK(Proxy::IsMainThread()); |
49 DCHECK(layer_tree_host); | 50 DCHECK(layer_tree_host); |
50 | 51 |
51 // Impl-side painting not supported without threaded compositing. | 52 // Impl-side painting not supported without threaded compositing. |
52 CHECK(!layer_tree_host->settings().impl_side_painting) | 53 CHECK(!layer_tree_host->settings().impl_side_painting) |
53 << "Threaded compositing must be enabled to use impl-side painting."; | 54 << "Threaded compositing must be enabled to use impl-side painting."; |
54 } | 55 } |
55 | 56 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 SchedulerSettings scheduler_settings(layer_tree_host_->settings()); | 91 SchedulerSettings scheduler_settings(layer_tree_host_->settings()); |
91 scheduler_on_impl_thread_ = Scheduler::Create(this, | 92 scheduler_on_impl_thread_ = Scheduler::Create(this, |
92 scheduler_settings, | 93 scheduler_settings, |
93 layer_tree_host_->id(), | 94 layer_tree_host_->id(), |
94 MainThreadTaskRunner()); | 95 MainThreadTaskRunner()); |
95 scheduler_on_impl_thread_->SetCanStart(); | 96 scheduler_on_impl_thread_->SetCanStart(); |
96 scheduler_on_impl_thread_->SetVisible(layer_tree_host_impl_->visible()); | 97 scheduler_on_impl_thread_->SetVisible(layer_tree_host_impl_->visible()); |
97 } | 98 } |
98 } | 99 } |
99 | 100 |
| 101 void SingleThreadProxy::SetLayerTreeHostClientFinished() { |
| 102 DCHECK(Proxy::IsMainThread()); |
| 103 host_client_finished_ = true; |
| 104 } |
| 105 |
100 void SingleThreadProxy::SetVisible(bool visible) { | 106 void SingleThreadProxy::SetVisible(bool visible) { |
101 TRACE_EVENT0("cc", "SingleThreadProxy::SetVisible"); | 107 TRACE_EVENT0("cc", "SingleThreadProxy::SetVisible"); |
102 DebugScopedSetImplThread impl(this); | 108 DebugScopedSetImplThread impl(this); |
103 layer_tree_host_impl_->SetVisible(visible); | 109 layer_tree_host_impl_->SetVisible(visible); |
104 if (scheduler_on_impl_thread_) | 110 if (scheduler_on_impl_thread_) |
105 scheduler_on_impl_thread_->SetVisible(layer_tree_host_impl_->visible()); | 111 scheduler_on_impl_thread_->SetVisible(layer_tree_host_impl_->visible()); |
106 // Changing visibility could change ShouldComposite(). | 112 // Changing visibility could change ShouldComposite(). |
107 UpdateBackgroundAnimateTicking(); | 113 UpdateBackgroundAnimateTicking(); |
108 } | 114 } |
109 | 115 |
110 void SingleThreadProxy::CreateAndInitializeOutputSurface() { | 116 void SingleThreadProxy::CreateAndInitializeOutputSurface() { |
111 TRACE_EVENT0( | 117 TRACE_EVENT0( |
112 "cc", "SingleThreadProxy::CreateAndInitializeOutputSurface"); | 118 "cc", "SingleThreadProxy::CreateAndInitializeOutputSurface"); |
113 DCHECK(Proxy::IsMainThread()); | 119 DCHECK(Proxy::IsMainThread()); |
114 DCHECK(layer_tree_host_->output_surface_lost()); | 120 DCHECK(layer_tree_host_->output_surface_lost()); |
115 | 121 |
| 122 // TODO(enne): in the future this could get handled by asynchronous |
| 123 // output surface creation where the host client could just decline |
| 124 // to ever create a surface when shutting down. |
| 125 if (host_client_finished_) |
| 126 return; |
| 127 |
116 scoped_ptr<OutputSurface> output_surface = | 128 scoped_ptr<OutputSurface> output_surface = |
117 layer_tree_host_->CreateOutputSurface(); | 129 layer_tree_host_->CreateOutputSurface(); |
118 | 130 |
119 renderer_capabilities_for_main_thread_ = RendererCapabilities(); | 131 renderer_capabilities_for_main_thread_ = RendererCapabilities(); |
120 | 132 |
121 bool success = !!output_surface; | 133 bool success = !!output_surface; |
122 if (success) { | 134 if (success) { |
123 DebugScopedSetMainThreadBlocked main_thread_blocked(this); | 135 DebugScopedSetMainThreadBlocked main_thread_blocked(this); |
124 DebugScopedSetImplThread impl(this); | 136 DebugScopedSetImplThread impl(this); |
125 layer_tree_host_->DeleteContentsTexturesOnImplThread( | 137 layer_tree_host_->DeleteContentsTexturesOnImplThread( |
(...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
697 | 709 |
698 base::TimeDelta SingleThreadProxy::CommitToActivateDurationEstimate() { | 710 base::TimeDelta SingleThreadProxy::CommitToActivateDurationEstimate() { |
699 return timing_history_.CommitToActivateDurationEstimate(); | 711 return timing_history_.CommitToActivateDurationEstimate(); |
700 } | 712 } |
701 | 713 |
702 void SingleThreadProxy::DidBeginImplFrameDeadline() { | 714 void SingleThreadProxy::DidBeginImplFrameDeadline() { |
703 layer_tree_host_impl_->ResetCurrentBeginFrameArgsForNextFrame(); | 715 layer_tree_host_impl_->ResetCurrentBeginFrameArgsForNextFrame(); |
704 } | 716 } |
705 | 717 |
706 } // namespace cc | 718 } // namespace cc |
OLD | NEW |