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/layer_tree_host.h" | 5 #include "cc/trees/layer_tree_host.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <stack> | 8 #include <stack> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 RendererCapabilities::~RendererCapabilities() {} | 62 RendererCapabilities::~RendererCapabilities() {} |
63 | 63 |
64 scoped_ptr<LayerTreeHost> LayerTreeHost::CreateThreaded( | 64 scoped_ptr<LayerTreeHost> LayerTreeHost::CreateThreaded( |
65 LayerTreeHostClient* client, | 65 LayerTreeHostClient* client, |
66 SharedBitmapManager* manager, | 66 SharedBitmapManager* manager, |
67 const LayerTreeSettings& settings, | 67 const LayerTreeSettings& settings, |
68 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner) { | 68 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner) { |
69 DCHECK(impl_task_runner); | 69 DCHECK(impl_task_runner); |
70 scoped_ptr<LayerTreeHost> layer_tree_host( | 70 scoped_ptr<LayerTreeHost> layer_tree_host( |
71 new LayerTreeHost(client, manager, settings)); | 71 new LayerTreeHost(client, manager, settings)); |
72 if (!layer_tree_host->InitializeThreaded(impl_task_runner)) | 72 layer_tree_host->InitializeThreaded(impl_task_runner); |
73 return scoped_ptr<LayerTreeHost>(); | |
74 return layer_tree_host.Pass(); | 73 return layer_tree_host.Pass(); |
75 } | 74 } |
76 | 75 |
77 scoped_ptr<LayerTreeHost> LayerTreeHost::CreateSingleThreaded( | 76 scoped_ptr<LayerTreeHost> LayerTreeHost::CreateSingleThreaded( |
78 LayerTreeHostClient* client, | 77 LayerTreeHostClient* client, |
79 LayerTreeHostSingleThreadClient* single_thread_client, | 78 LayerTreeHostSingleThreadClient* single_thread_client, |
80 SharedBitmapManager* manager, | 79 SharedBitmapManager* manager, |
81 const LayerTreeSettings& settings) { | 80 const LayerTreeSettings& settings) { |
82 scoped_ptr<LayerTreeHost> layer_tree_host( | 81 scoped_ptr<LayerTreeHost> layer_tree_host( |
83 new LayerTreeHost(client, manager, settings)); | 82 new LayerTreeHost(client, manager, settings)); |
84 if (!layer_tree_host->InitializeSingleThreaded(single_thread_client)) | 83 layer_tree_host->InitializeSingleThreaded(single_thread_client); |
85 return scoped_ptr<LayerTreeHost>(); | |
86 return layer_tree_host.Pass(); | 84 return layer_tree_host.Pass(); |
87 } | 85 } |
88 | 86 |
89 | 87 |
90 LayerTreeHost::LayerTreeHost( | 88 LayerTreeHost::LayerTreeHost( |
91 LayerTreeHostClient* client, | 89 LayerTreeHostClient* client, |
92 SharedBitmapManager* manager, | 90 SharedBitmapManager* manager, |
93 const LayerTreeSettings& settings) | 91 const LayerTreeSettings& settings) |
94 : micro_benchmark_controller_(this), | 92 : micro_benchmark_controller_(this), |
95 next_ui_resource_id_(1), | 93 next_ui_resource_id_(1), |
(...skipping 22 matching lines...) Expand all Loading... |
118 total_frames_used_for_lcd_text_metrics_(0), | 116 total_frames_used_for_lcd_text_metrics_(0), |
119 id_(s_layer_tree_host_sequence_number.GetNext() + 1), | 117 id_(s_layer_tree_host_sequence_number.GetNext() + 1), |
120 next_commit_forces_redraw_(false), | 118 next_commit_forces_redraw_(false), |
121 shared_bitmap_manager_(manager) { | 119 shared_bitmap_manager_(manager) { |
122 if (settings_.accelerated_animation_enabled) | 120 if (settings_.accelerated_animation_enabled) |
123 animation_registrar_ = AnimationRegistrar::Create(); | 121 animation_registrar_ = AnimationRegistrar::Create(); |
124 rendering_stats_instrumentation_->set_record_rendering_stats( | 122 rendering_stats_instrumentation_->set_record_rendering_stats( |
125 debug_state_.RecordRenderingStats()); | 123 debug_state_.RecordRenderingStats()); |
126 } | 124 } |
127 | 125 |
128 bool LayerTreeHost::InitializeThreaded( | 126 void LayerTreeHost::InitializeThreaded( |
129 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner) { | 127 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner) { |
130 return InitializeProxy(ThreadProxy::Create(this, impl_task_runner)); | 128 InitializeProxy(ThreadProxy::Create(this, impl_task_runner)); |
131 } | 129 } |
132 | 130 |
133 bool LayerTreeHost::InitializeSingleThreaded( | 131 void LayerTreeHost::InitializeSingleThreaded( |
134 LayerTreeHostSingleThreadClient* single_thread_client) { | 132 LayerTreeHostSingleThreadClient* single_thread_client) { |
135 return InitializeProxy( | 133 InitializeProxy(SingleThreadProxy::Create(this, single_thread_client)); |
136 SingleThreadProxy::Create(this, single_thread_client)); | |
137 } | 134 } |
138 | 135 |
139 bool LayerTreeHost::InitializeForTesting(scoped_ptr<Proxy> proxy_for_testing) { | 136 void LayerTreeHost::InitializeForTesting(scoped_ptr<Proxy> proxy_for_testing) { |
140 return InitializeProxy(proxy_for_testing.Pass()); | 137 InitializeProxy(proxy_for_testing.Pass()); |
141 } | 138 } |
142 | 139 |
143 bool LayerTreeHost::InitializeProxy(scoped_ptr<Proxy> proxy) { | 140 void LayerTreeHost::InitializeProxy(scoped_ptr<Proxy> proxy) { |
144 TRACE_EVENT0("cc", "LayerTreeHost::InitializeForReal"); | 141 TRACE_EVENT0("cc", "LayerTreeHost::InitializeForReal"); |
145 | 142 |
146 scoped_ptr<OutputSurface> output_surface(CreateOutputSurface()); | |
147 if (!output_surface) | |
148 return false; | |
149 | |
150 proxy_ = proxy.Pass(); | 143 proxy_ = proxy.Pass(); |
151 proxy_->Start(output_surface.Pass()); | 144 proxy_->Start(); |
152 return true; | |
153 } | 145 } |
154 | 146 |
155 LayerTreeHost::~LayerTreeHost() { | 147 LayerTreeHost::~LayerTreeHost() { |
156 TRACE_EVENT0("cc", "LayerTreeHost::~LayerTreeHost"); | 148 TRACE_EVENT0("cc", "LayerTreeHost::~LayerTreeHost"); |
157 | 149 |
158 overhang_ui_resource_.reset(); | 150 overhang_ui_resource_.reset(); |
159 | 151 |
160 if (root_layer_.get()) | 152 if (root_layer_.get()) |
161 root_layer_->SetLayerTreeHost(NULL); | 153 root_layer_->SetLayerTreeHost(NULL); |
162 | 154 |
(...skipping 1110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1273 swap_promise_list_.push_back(swap_promise.Pass()); | 1265 swap_promise_list_.push_back(swap_promise.Pass()); |
1274 } | 1266 } |
1275 | 1267 |
1276 void LayerTreeHost::BreakSwapPromises(SwapPromise::DidNotSwapReason reason) { | 1268 void LayerTreeHost::BreakSwapPromises(SwapPromise::DidNotSwapReason reason) { |
1277 for (size_t i = 0; i < swap_promise_list_.size(); i++) | 1269 for (size_t i = 0; i < swap_promise_list_.size(); i++) |
1278 swap_promise_list_[i]->DidNotSwap(reason); | 1270 swap_promise_list_[i]->DidNotSwap(reason); |
1279 swap_promise_list_.clear(); | 1271 swap_promise_list_.clear(); |
1280 } | 1272 } |
1281 | 1273 |
1282 } // namespace cc | 1274 } // namespace cc |
OLD | NEW |