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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 | 60 |
61 RendererCapabilities::RendererCapabilities() | 61 RendererCapabilities::RendererCapabilities() |
62 : best_texture_format(RGBA_8888), | 62 : best_texture_format(RGBA_8888), |
63 allow_partial_texture_updates(false), | 63 allow_partial_texture_updates(false), |
64 using_offscreen_context3d(false), | 64 using_offscreen_context3d(false), |
65 max_texture_size(0), | 65 max_texture_size(0), |
66 using_shared_memory_resources(false) {} | 66 using_shared_memory_resources(false) {} |
67 | 67 |
68 RendererCapabilities::~RendererCapabilities() {} | 68 RendererCapabilities::~RendererCapabilities() {} |
69 | 69 |
| 70 bool RendererCapabilities::operator==(const RendererCapabilities& other) const { |
| 71 return best_texture_format == other.best_texture_format && |
| 72 allow_partial_texture_updates == other.allow_partial_texture_updates && |
| 73 using_offscreen_context3d == other.using_offscreen_context3d && |
| 74 max_texture_size == other.max_texture_size && |
| 75 using_shared_memory_resources == other.using_shared_memory_resources; |
| 76 } |
| 77 |
| 78 bool RendererCapabilities::operator!=(const RendererCapabilities& other) const { |
| 79 return !(*this == other); |
| 80 } |
| 81 |
70 scoped_ptr<LayerTreeHost> LayerTreeHost::CreateThreaded( | 82 scoped_ptr<LayerTreeHost> LayerTreeHost::CreateThreaded( |
71 LayerTreeHostClient* client, | 83 LayerTreeHostClient* client, |
72 SharedBitmapManager* manager, | 84 SharedBitmapManager* manager, |
73 const LayerTreeSettings& settings, | 85 const LayerTreeSettings& settings, |
74 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner) { | 86 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner) { |
75 DCHECK(impl_task_runner); | 87 DCHECK(impl_task_runner); |
76 scoped_ptr<LayerTreeHost> layer_tree_host( | 88 scoped_ptr<LayerTreeHost> layer_tree_host( |
77 new LayerTreeHost(client, manager, settings)); | 89 new LayerTreeHost(client, manager, settings)); |
78 layer_tree_host->InitializeThreaded(impl_task_runner); | 90 layer_tree_host->InitializeThreaded(impl_task_runner); |
79 return layer_tree_host.Pass(); | 91 return layer_tree_host.Pass(); |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 // made a contract with our animation controllers that the registrar | 183 // made a contract with our animation controllers that the registrar |
172 // will outlive them, and we must make good. | 184 // will outlive them, and we must make good. |
173 root_layer_ = NULL; | 185 root_layer_ = NULL; |
174 } | 186 } |
175 } | 187 } |
176 | 188 |
177 void LayerTreeHost::SetLayerTreeHostClientReady() { | 189 void LayerTreeHost::SetLayerTreeHostClientReady() { |
178 proxy_->SetLayerTreeHostClientReady(); | 190 proxy_->SetLayerTreeHostClientReady(); |
179 } | 191 } |
180 | 192 |
181 static void LayerTreeHostOnOutputSurfaceCreatedCallback(Layer* layer) { | 193 static void LayerTreeHostRendererCapabilitiesChanged(Layer* layer) { |
| 194 // TODO(boliu): Rename this to Layer::RendererCapabilitiesChanged. |
182 layer->OnOutputSurfaceCreated(); | 195 layer->OnOutputSurfaceCreated(); |
183 } | 196 } |
184 | 197 |
| 198 void LayerTreeHost::RendererCapabilitiesChanged() { |
| 199 if (root_layer()) { |
| 200 LayerTreeHostCommon::CallFunctionForSubtree( |
| 201 root_layer(), base::Bind(&LayerTreeHostRendererCapabilitiesChanged)); |
| 202 } |
| 203 } |
| 204 |
185 LayerTreeHost::CreateResult | 205 LayerTreeHost::CreateResult |
186 LayerTreeHost::OnCreateAndInitializeOutputSurfaceAttempted(bool success) { | 206 LayerTreeHost::OnCreateAndInitializeOutputSurfaceAttempted(bool success) { |
187 TRACE_EVENT1("cc", | 207 TRACE_EVENT1("cc", |
188 "LayerTreeHost::OnCreateAndInitializeOutputSurfaceAttempted", | 208 "LayerTreeHost::OnCreateAndInitializeOutputSurfaceAttempted", |
189 "success", | 209 "success", |
190 success); | 210 success); |
191 | 211 |
192 DCHECK(output_surface_lost_); | 212 DCHECK(output_surface_lost_); |
193 if (success) { | 213 if (success) { |
194 output_surface_lost_ = false; | 214 output_surface_lost_ = false; |
195 | 215 |
196 if (!contents_texture_manager_ && !settings_.impl_side_painting) { | 216 if (!contents_texture_manager_ && !settings_.impl_side_painting) { |
197 contents_texture_manager_ = | 217 contents_texture_manager_ = |
198 PrioritizedResourceManager::Create(proxy_.get()); | 218 PrioritizedResourceManager::Create(proxy_.get()); |
199 surface_memory_placeholder_ = | 219 surface_memory_placeholder_ = |
200 contents_texture_manager_->CreateTexture(gfx::Size(), RGBA_8888); | 220 contents_texture_manager_->CreateTexture(gfx::Size(), RGBA_8888); |
201 } | 221 } |
202 | 222 |
203 if (root_layer()) { | |
204 LayerTreeHostCommon::CallFunctionForSubtree( | |
205 root_layer(), | |
206 base::Bind(&LayerTreeHostOnOutputSurfaceCreatedCallback)); | |
207 } | |
208 | |
209 client_->DidInitializeOutputSurface(true); | 223 client_->DidInitializeOutputSurface(true); |
210 return CreateSucceeded; | 224 return CreateSucceeded; |
211 } | 225 } |
212 | 226 |
213 // Failure path. | 227 // Failure path. |
214 | 228 |
215 client_->DidFailToInitializeOutputSurface(); | 229 client_->DidFailToInitializeOutputSurface(); |
216 | 230 |
217 // Tolerate a certain number of recreation failures to work around races | 231 // Tolerate a certain number of recreation failures to work around races |
218 // in the output-surface-lost machinery. | 232 // in the output-surface-lost machinery. |
(...skipping 1093 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1312 swap_promise_list_.push_back(swap_promise.Pass()); | 1326 swap_promise_list_.push_back(swap_promise.Pass()); |
1313 } | 1327 } |
1314 | 1328 |
1315 void LayerTreeHost::BreakSwapPromises(SwapPromise::DidNotSwapReason reason) { | 1329 void LayerTreeHost::BreakSwapPromises(SwapPromise::DidNotSwapReason reason) { |
1316 for (size_t i = 0; i < swap_promise_list_.size(); i++) | 1330 for (size_t i = 0; i < swap_promise_list_.size(); i++) |
1317 swap_promise_list_[i]->DidNotSwap(reason); | 1331 swap_promise_list_[i]->DidNotSwap(reason); |
1318 swap_promise_list_.clear(); | 1332 swap_promise_list_.clear(); |
1319 } | 1333 } |
1320 | 1334 |
1321 } // namespace cc | 1335 } // namespace cc |
OLD | NEW |