| 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 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 // made a contract with our animation controllers that the registrar | 204 // made a contract with our animation controllers that the registrar |
| 205 // will outlive them, and we must make good. | 205 // will outlive them, and we must make good. |
| 206 root_layer_ = NULL; | 206 root_layer_ = NULL; |
| 207 } | 207 } |
| 208 } | 208 } |
| 209 | 209 |
| 210 void LayerTreeHost::SetLayerTreeHostClientReady() { | 210 void LayerTreeHost::SetLayerTreeHostClientReady() { |
| 211 proxy_->SetLayerTreeHostClientReady(); | 211 proxy_->SetLayerTreeHostClientReady(); |
| 212 } | 212 } |
| 213 | 213 |
| 214 static void LayerTreeHostOnOutputSurfaceCreatedCallback(Layer* layer) { | |
| 215 layer->OnOutputSurfaceCreated(); | |
| 216 } | |
| 217 | |
| 218 void LayerTreeHost::DeleteContentsTexturesOnImplThread( | 214 void LayerTreeHost::DeleteContentsTexturesOnImplThread( |
| 219 ResourceProvider* resource_provider) { | 215 ResourceProvider* resource_provider) { |
| 220 DCHECK(proxy_->IsImplThread()); | 216 DCHECK(proxy_->IsImplThread()); |
| 221 if (contents_texture_manager_) | 217 if (contents_texture_manager_) |
| 222 contents_texture_manager_->ClearAllMemory(resource_provider); | 218 contents_texture_manager_->ClearAllMemory(resource_provider); |
| 223 } | 219 } |
| 224 | 220 |
| 225 void LayerTreeHost::WillBeginMainFrame() { | 221 void LayerTreeHost::WillBeginMainFrame() { |
| 226 devtools_instrumentation::WillBeginMainThreadFrame(id(), | 222 devtools_instrumentation::WillBeginMainThreadFrame(id(), |
| 227 source_frame_number()); | 223 source_frame_number()); |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 420 | 416 |
| 421 if (!contents_texture_manager_ && !settings_.impl_side_painting) { | 417 if (!contents_texture_manager_ && !settings_.impl_side_painting) { |
| 422 contents_texture_manager_ = | 418 contents_texture_manager_ = |
| 423 PrioritizedResourceManager::Create(proxy_.get()); | 419 PrioritizedResourceManager::Create(proxy_.get()); |
| 424 surface_memory_placeholder_ = | 420 surface_memory_placeholder_ = |
| 425 contents_texture_manager_->CreateTexture(gfx::Size(), RGBA_8888); | 421 contents_texture_manager_->CreateTexture(gfx::Size(), RGBA_8888); |
| 426 } | 422 } |
| 427 | 423 |
| 428 if (root_layer()) { | 424 if (root_layer()) { |
| 429 LayerTreeHostCommon::CallFunctionForSubtree( | 425 LayerTreeHostCommon::CallFunctionForSubtree( |
| 430 root_layer(), base::Bind(&LayerTreeHostOnOutputSurfaceCreatedCallback)); | 426 root_layer(), [](Layer* layer) { layer->OnOutputSurfaceCreated(); }); |
| 431 } | 427 } |
| 432 | 428 |
| 433 client_->DidInitializeOutputSurface(); | 429 client_->DidInitializeOutputSurface(); |
| 434 } | 430 } |
| 435 | 431 |
| 436 void LayerTreeHost::DidFailToInitializeOutputSurface() { | 432 void LayerTreeHost::DidFailToInitializeOutputSurface() { |
| 437 DCHECK(output_surface_lost_); | 433 DCHECK(output_surface_lost_); |
| 438 client_->DidFailToInitializeOutputSurface(); | 434 client_->DidFailToInitializeOutputSurface(); |
| 439 } | 435 } |
| 440 | 436 |
| (...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 866 | 862 |
| 867 return did_paint_content; | 863 return did_paint_content; |
| 868 } | 864 } |
| 869 | 865 |
| 870 void LayerTreeHost::TriggerPrepaint() { | 866 void LayerTreeHost::TriggerPrepaint() { |
| 871 prepaint_callback_.Cancel(); | 867 prepaint_callback_.Cancel(); |
| 872 TRACE_EVENT0("cc", "LayerTreeHost::TriggerPrepaint"); | 868 TRACE_EVENT0("cc", "LayerTreeHost::TriggerPrepaint"); |
| 873 SetNeedsCommit(); | 869 SetNeedsCommit(); |
| 874 } | 870 } |
| 875 | 871 |
| 876 static void LayerTreeHostReduceMemoryCallback(Layer* layer) { | |
| 877 layer->ReduceMemoryUsage(); | |
| 878 } | |
| 879 | |
| 880 void LayerTreeHost::ReduceMemoryUsage() { | 872 void LayerTreeHost::ReduceMemoryUsage() { |
| 881 if (!root_layer()) | 873 if (!root_layer()) |
| 882 return; | 874 return; |
| 883 | 875 |
| 884 LayerTreeHostCommon::CallFunctionForSubtree( | 876 LayerTreeHostCommon::CallFunctionForSubtree( |
| 885 root_layer(), | 877 root_layer(), [](Layer* layer) { layer->ReduceMemoryUsage(); }); |
| 886 base::Bind(&LayerTreeHostReduceMemoryCallback)); | |
| 887 } | 878 } |
| 888 | 879 |
| 889 void LayerTreeHost::SetPrioritiesForSurfaces(size_t surface_memory_bytes) { | 880 void LayerTreeHost::SetPrioritiesForSurfaces(size_t surface_memory_bytes) { |
| 890 DCHECK(surface_memory_placeholder_); | 881 DCHECK(surface_memory_placeholder_); |
| 891 | 882 |
| 892 // Surfaces have a place holder for their memory since they are managed | 883 // Surfaces have a place holder for their memory since they are managed |
| 893 // independantly but should still be tracked and reduce other memory usage. | 884 // independantly but should still be tracked and reduce other memory usage. |
| 894 surface_memory_placeholder_->SetTextureManager( | 885 surface_memory_placeholder_->SetTextureManager( |
| 895 contents_texture_manager_.get()); | 886 contents_texture_manager_.get()); |
| 896 surface_memory_placeholder_->set_request_priority( | 887 surface_memory_placeholder_->set_request_priority( |
| (...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1327 bool children_need_begin_frames) const { | 1318 bool children_need_begin_frames) const { |
| 1328 proxy_->SetChildrenNeedBeginFrames(children_need_begin_frames); | 1319 proxy_->SetChildrenNeedBeginFrames(children_need_begin_frames); |
| 1329 } | 1320 } |
| 1330 | 1321 |
| 1331 void LayerTreeHost::SendBeginFramesToChildren( | 1322 void LayerTreeHost::SendBeginFramesToChildren( |
| 1332 const BeginFrameArgs& args) const { | 1323 const BeginFrameArgs& args) const { |
| 1333 client_->SendBeginFramesToChildren(args); | 1324 client_->SendBeginFramesToChildren(args); |
| 1334 } | 1325 } |
| 1335 | 1326 |
| 1336 } // namespace cc | 1327 } // namespace cc |
| OLD | NEW |