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 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 } | 170 } |
171 | 171 |
172 void LayerTreeHost::SetLayerTreeHostClientReady() { | 172 void LayerTreeHost::SetLayerTreeHostClientReady() { |
173 proxy_->SetLayerTreeHostClientReady(); | 173 proxy_->SetLayerTreeHostClientReady(); |
174 } | 174 } |
175 | 175 |
176 static void LayerTreeHostOnOutputSurfaceCreatedCallback(Layer* layer) { | 176 static void LayerTreeHostOnOutputSurfaceCreatedCallback(Layer* layer) { |
177 layer->OnOutputSurfaceCreated(); | 177 layer->OnOutputSurfaceCreated(); |
178 } | 178 } |
179 | 179 |
180 LayerTreeHost::CreateResult | 180 void LayerTreeHost::OnCreateAndInitializeOutputSurfaceAttempted(bool success) { |
181 LayerTreeHost::OnCreateAndInitializeOutputSurfaceAttempted(bool success) { | 181 DCHECK(output_surface_lost_); |
182 TRACE_EVENT1("cc", | 182 TRACE_EVENT1("cc", |
183 "LayerTreeHost::OnCreateAndInitializeOutputSurfaceAttempted", | 183 "LayerTreeHost::OnCreateAndInitializeOutputSurfaceAttempted", |
184 "success", | 184 "success", |
185 success); | 185 success); |
186 | 186 |
187 DCHECK(output_surface_lost_); | 187 if (!success) { |
188 if (success) { | 188 // Tolerate a certain number of recreation failures to work around races |
189 output_surface_lost_ = false; | 189 // in the output-surface-lost machinery. |
190 | 190 ++num_failed_recreate_attempts_; |
191 if (!contents_texture_manager_ && !settings_.impl_side_painting) { | 191 if (num_failed_recreate_attempts_ >= 5) |
192 contents_texture_manager_ = | 192 LOG(FATAL) << "Failed to create a fallback OutputSurface."; |
193 PrioritizedResourceManager::Create(proxy_.get()); | 193 client_->DidFailToInitializeOutputSurface(); |
194 surface_memory_placeholder_ = | 194 return; |
195 contents_texture_manager_->CreateTexture(gfx::Size(), RGBA_8888); | |
196 } | |
197 | |
198 if (root_layer()) { | |
199 LayerTreeHostCommon::CallFunctionForSubtree( | |
200 root_layer(), | |
201 base::Bind(&LayerTreeHostOnOutputSurfaceCreatedCallback)); | |
202 } | |
203 | |
204 client_->DidInitializeOutputSurface(true); | |
205 return CreateSucceeded; | |
206 } | 195 } |
207 | 196 |
208 // Failure path. | 197 output_surface_lost_ = false; |
209 | 198 |
210 client_->DidFailToInitializeOutputSurface(); | 199 if (!contents_texture_manager_ && !settings_.impl_side_painting) { |
211 | 200 contents_texture_manager_ = |
212 // Tolerate a certain number of recreation failures to work around races | 201 PrioritizedResourceManager::Create(proxy_.get()); |
213 // in the output-surface-lost machinery. | 202 surface_memory_placeholder_ = |
214 ++num_failed_recreate_attempts_; | 203 contents_texture_manager_->CreateTexture(gfx::Size(), RGBA_8888); |
215 if (num_failed_recreate_attempts_ >= 5) { | |
216 // We have tried too many times to recreate the output surface. Tell the | |
217 // host to fall back to software rendering. | |
218 output_surface_can_be_initialized_ = false; | |
219 client_->DidInitializeOutputSurface(false); | |
220 return CreateFailedAndGaveUp; | |
221 } | 204 } |
222 | 205 |
223 return CreateFailedButTryAgain; | 206 if (root_layer()) { |
| 207 LayerTreeHostCommon::CallFunctionForSubtree( |
| 208 root_layer(), base::Bind(&LayerTreeHostOnOutputSurfaceCreatedCallback)); |
| 209 } |
| 210 |
| 211 client_->DidInitializeOutputSurface(); |
224 } | 212 } |
225 | 213 |
226 void LayerTreeHost::DeleteContentsTexturesOnImplThread( | 214 void LayerTreeHost::DeleteContentsTexturesOnImplThread( |
227 ResourceProvider* resource_provider) { | 215 ResourceProvider* resource_provider) { |
228 DCHECK(proxy_->IsImplThread()); | 216 DCHECK(proxy_->IsImplThread()); |
229 if (contents_texture_manager_) | 217 if (contents_texture_manager_) |
230 contents_texture_manager_->ClearAllMemory(resource_provider); | 218 contents_texture_manager_->ClearAllMemory(resource_provider); |
231 } | 219 } |
232 | 220 |
233 void LayerTreeHost::DidBeginMainFrame() { | 221 void LayerTreeHost::DidBeginMainFrame() { |
(...skipping 1010 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1244 swap_promise_list_.push_back(swap_promise.Pass()); | 1232 swap_promise_list_.push_back(swap_promise.Pass()); |
1245 } | 1233 } |
1246 | 1234 |
1247 void LayerTreeHost::BreakSwapPromises(SwapPromise::DidNotSwapReason reason) { | 1235 void LayerTreeHost::BreakSwapPromises(SwapPromise::DidNotSwapReason reason) { |
1248 for (size_t i = 0; i < swap_promise_list_.size(); i++) | 1236 for (size_t i = 0; i < swap_promise_list_.size(); i++) |
1249 swap_promise_list_[i]->DidNotSwap(reason); | 1237 swap_promise_list_[i]->DidNotSwap(reason); |
1250 swap_promise_list_.clear(); | 1238 swap_promise_list_.clear(); |
1251 } | 1239 } |
1252 | 1240 |
1253 } // namespace cc | 1241 } // namespace cc |
OLD | NEW |