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