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 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 LayerTreeHost::OnCreateAndInitializeOutputSurfaceAttempted(bool success) { | 160 LayerTreeHost::OnCreateAndInitializeOutputSurfaceAttempted(bool success) { |
161 TRACE_EVENT1("cc", | 161 TRACE_EVENT1("cc", |
162 "LayerTreeHost::OnCreateAndInitializeOutputSurfaceAttempted", | 162 "LayerTreeHost::OnCreateAndInitializeOutputSurfaceAttempted", |
163 "success", | 163 "success", |
164 success); | 164 success); |
165 | 165 |
166 DCHECK(output_surface_lost_); | 166 DCHECK(output_surface_lost_); |
167 if (success) { | 167 if (success) { |
168 output_surface_lost_ = false; | 168 output_surface_lost_ = false; |
169 | 169 |
170 // Update settings_ based on capabilities that we got back from the | 170 DidUpdateCapabilities(); |
171 // renderer. | |
172 settings_.accelerate_painting = | |
173 proxy_->GetRendererCapabilities().using_accelerated_painting; | |
174 | |
175 // Update settings_ based on partial update capability. | |
176 size_t max_partial_texture_updates = 0; | |
177 if (proxy_->GetRendererCapabilities().allow_partial_texture_updates && | |
178 !settings_.impl_side_painting) { | |
179 max_partial_texture_updates = std::min( | |
180 settings_.max_partial_texture_updates, | |
181 proxy_->MaxPartialTextureUpdates()); | |
182 } | |
183 settings_.max_partial_texture_updates = max_partial_texture_updates; | |
184 | |
185 if (!contents_texture_manager_) { | 171 if (!contents_texture_manager_) { |
186 contents_texture_manager_ = | 172 contents_texture_manager_ = |
187 PrioritizedResourceManager::Create(proxy_.get()); | 173 PrioritizedResourceManager::Create(proxy_.get()); |
188 surface_memory_placeholder_ = | 174 surface_memory_placeholder_ = |
189 contents_texture_manager_->CreateTexture(gfx::Size(), GL_RGBA); | 175 contents_texture_manager_->CreateTexture(gfx::Size(), GL_RGBA); |
190 } | 176 } |
191 | 177 |
192 client_->DidInitializeOutputSurface(true); | 178 client_->DidInitializeOutputSurface(true); |
193 return CreateSucceeded; | 179 return CreateSucceeded; |
194 } | 180 } |
195 | 181 |
196 // Failure path. | 182 // Failure path. |
197 | 183 |
198 client_->DidFailToInitializeOutputSurface(); | 184 client_->DidFailToInitializeOutputSurface(); |
199 | 185 |
200 // Tolerate a certain number of recreation failures to work around races | 186 // Tolerate a certain number of recreation failures to work around races |
201 // in the output-surface-lost machinery. | 187 // in the output-surface-lost machinery. |
202 ++num_failed_recreate_attempts_; | 188 ++num_failed_recreate_attempts_; |
203 if (num_failed_recreate_attempts_ >= 5) { | 189 if (num_failed_recreate_attempts_ >= 5) { |
204 // We have tried too many times to recreate the output surface. Tell the | 190 // We have tried too many times to recreate the output surface. Tell the |
205 // host to fall back to software rendering. | 191 // host to fall back to software rendering. |
206 output_surface_can_be_initialized_ = false; | 192 output_surface_can_be_initialized_ = false; |
207 client_->DidInitializeOutputSurface(false); | 193 client_->DidInitializeOutputSurface(false); |
208 return CreateFailedAndGaveUp; | 194 return CreateFailedAndGaveUp; |
209 } | 195 } |
210 | 196 |
211 return CreateFailedButTryAgain; | 197 return CreateFailedButTryAgain; |
212 } | 198 } |
213 | 199 |
| 200 void LayerTreeHost::DidUpdateCapabilities() { |
| 201 // Update settings_ based on capabilities that we got back from the |
| 202 // renderer. |
| 203 settings_.accelerate_painting = |
| 204 proxy_->GetRendererCapabilities().using_accelerated_painting; |
| 205 // Update settings_ based on partial update capability. |
| 206 size_t max_partial_texture_updates = 0; |
| 207 if (proxy_->GetRendererCapabilities().allow_partial_texture_updates && |
| 208 !settings_.impl_side_painting) { |
| 209 max_partial_texture_updates = |
| 210 std::min(settings_.max_partial_texture_updates, |
| 211 proxy_->MaxPartialTextureUpdates()); |
| 212 } |
| 213 settings_.max_partial_texture_updates = max_partial_texture_updates; |
| 214 } |
| 215 |
214 void LayerTreeHost::DeleteContentsTexturesOnImplThread( | 216 void LayerTreeHost::DeleteContentsTexturesOnImplThread( |
215 ResourceProvider* resource_provider) { | 217 ResourceProvider* resource_provider) { |
216 DCHECK(proxy_->IsImplThread()); | 218 DCHECK(proxy_->IsImplThread()); |
217 if (contents_texture_manager_) | 219 if (contents_texture_manager_) |
218 contents_texture_manager_->ClearAllMemory(resource_provider); | 220 contents_texture_manager_->ClearAllMemory(resource_provider); |
219 } | 221 } |
220 | 222 |
221 void LayerTreeHost::AcquireLayerTextures() { | 223 void LayerTreeHost::AcquireLayerTextures() { |
222 DCHECK(proxy_->IsMainThread()); | 224 DCHECK(proxy_->IsMainThread()); |
223 proxy_->AcquireLayerTextures(); | 225 proxy_->AcquireLayerTextures(); |
(...skipping 794 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1018 bool start_ready_animations = true; | 1020 bool start_ready_animations = true; |
1019 (*iter).second->UpdateState(start_ready_animations, NULL); | 1021 (*iter).second->UpdateState(start_ready_animations, NULL); |
1020 } | 1022 } |
1021 } | 1023 } |
1022 | 1024 |
1023 skia::RefPtr<SkPicture> LayerTreeHost::CapturePicture() { | 1025 skia::RefPtr<SkPicture> LayerTreeHost::CapturePicture() { |
1024 return proxy_->CapturePicture(); | 1026 return proxy_->CapturePicture(); |
1025 } | 1027 } |
1026 | 1028 |
1027 } // namespace cc | 1029 } // namespace cc |
OLD | NEW |