| 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 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 // made a contract with our animation controllers that the registrar | 205 // made a contract with our animation controllers that the registrar |
| 206 // will outlive them, and we must make good. | 206 // will outlive them, and we must make good. |
| 207 root_layer_ = NULL; | 207 root_layer_ = NULL; |
| 208 } | 208 } |
| 209 } | 209 } |
| 210 | 210 |
| 211 void LayerTreeHost::SetLayerTreeHostClientReady() { | 211 void LayerTreeHost::SetLayerTreeHostClientReady() { |
| 212 proxy_->SetLayerTreeHostClientReady(); | 212 proxy_->SetLayerTreeHostClientReady(); |
| 213 } | 213 } |
| 214 | 214 |
| 215 static void LayerTreeHostOnOutputSurfaceCreatedCallback(Layer* layer) { | |
| 216 layer->OnOutputSurfaceCreated(); | |
| 217 } | |
| 218 | |
| 219 void LayerTreeHost::DeleteContentsTexturesOnImplThread( | 215 void LayerTreeHost::DeleteContentsTexturesOnImplThread( |
| 220 ResourceProvider* resource_provider) { | 216 ResourceProvider* resource_provider) { |
| 221 DCHECK(proxy_->IsImplThread()); | 217 DCHECK(proxy_->IsImplThread()); |
| 222 if (contents_texture_manager_) | 218 if (contents_texture_manager_) |
| 223 contents_texture_manager_->ClearAllMemory(resource_provider); | 219 contents_texture_manager_->ClearAllMemory(resource_provider); |
| 224 } | 220 } |
| 225 | 221 |
| 226 void LayerTreeHost::WillBeginMainFrame() { | 222 void LayerTreeHost::WillBeginMainFrame() { |
| 227 devtools_instrumentation::WillBeginMainThreadFrame(id(), | 223 devtools_instrumentation::WillBeginMainThreadFrame(id(), |
| 228 source_frame_number()); | 224 source_frame_number()); |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 417 | 413 |
| 418 if (!contents_texture_manager_ && !settings_.impl_side_painting) { | 414 if (!contents_texture_manager_ && !settings_.impl_side_painting) { |
| 419 contents_texture_manager_ = | 415 contents_texture_manager_ = |
| 420 PrioritizedResourceManager::Create(proxy_.get()); | 416 PrioritizedResourceManager::Create(proxy_.get()); |
| 421 surface_memory_placeholder_ = | 417 surface_memory_placeholder_ = |
| 422 contents_texture_manager_->CreateTexture(gfx::Size(), RGBA_8888); | 418 contents_texture_manager_->CreateTexture(gfx::Size(), RGBA_8888); |
| 423 } | 419 } |
| 424 | 420 |
| 425 if (root_layer()) { | 421 if (root_layer()) { |
| 426 LayerTreeHostCommon::CallFunctionForSubtree( | 422 LayerTreeHostCommon::CallFunctionForSubtree( |
| 427 root_layer(), base::Bind(&LayerTreeHostOnOutputSurfaceCreatedCallback)); | 423 root_layer(), [](Layer* layer) { layer->OnOutputSurfaceCreated(); }); |
| 428 } | 424 } |
| 429 | 425 |
| 430 client_->DidInitializeOutputSurface(); | 426 client_->DidInitializeOutputSurface(); |
| 431 } | 427 } |
| 432 | 428 |
| 433 void LayerTreeHost::DidFailToInitializeOutputSurface() { | 429 void LayerTreeHost::DidFailToInitializeOutputSurface() { |
| 434 DCHECK(output_surface_lost_); | 430 DCHECK(output_surface_lost_); |
| 435 client_->DidFailToInitializeOutputSurface(); | 431 client_->DidFailToInitializeOutputSurface(); |
| 436 } | 432 } |
| 437 | 433 |
| (...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 859 can_render_to_separate_surface, | 855 can_render_to_separate_surface, |
| 860 settings_.layer_transforms_should_scale_layer_contents, | 856 settings_.layer_transforms_should_scale_layer_contents, |
| 861 settings_.verify_property_trees, &update_list, | 857 settings_.verify_property_trees, &update_list, |
| 862 render_surface_layer_list_id); | 858 render_surface_layer_list_id); |
| 863 LayerTreeHostCommon::CalculateDrawProperties(&inputs); | 859 LayerTreeHostCommon::CalculateDrawProperties(&inputs); |
| 864 | 860 |
| 865 if (total_frames_used_for_lcd_text_metrics_ <= | 861 if (total_frames_used_for_lcd_text_metrics_ <= |
| 866 kTotalFramesToUseForLCDTextMetrics) { | 862 kTotalFramesToUseForLCDTextMetrics) { |
| 867 LayerTreeHostCommon::CallFunctionForSubtree( | 863 LayerTreeHostCommon::CallFunctionForSubtree( |
| 868 root_layer, | 864 root_layer, |
| 869 base::Bind(&LayerTreeHost::CalculateLCDTextMetricsCallback, | 865 [this](Layer* layer) { CalculateLCDTextMetricsCallback(layer); }); |
| 870 base::Unretained(this))); | |
| 871 total_frames_used_for_lcd_text_metrics_++; | 866 total_frames_used_for_lcd_text_metrics_++; |
| 872 } | 867 } |
| 873 | 868 |
| 874 if (total_frames_used_for_lcd_text_metrics_ == | 869 if (total_frames_used_for_lcd_text_metrics_ == |
| 875 kTotalFramesToUseForLCDTextMetrics) { | 870 kTotalFramesToUseForLCDTextMetrics) { |
| 876 total_frames_used_for_lcd_text_metrics_++; | 871 total_frames_used_for_lcd_text_metrics_++; |
| 877 | 872 |
| 878 UMA_HISTOGRAM_PERCENTAGE( | 873 UMA_HISTOGRAM_PERCENTAGE( |
| 879 "Renderer4.LCDText.PercentageOfCandidateLayers", | 874 "Renderer4.LCDText.PercentageOfCandidateLayers", |
| 880 lcd_text_metrics_.total_num_cc_layers_can_use_lcd_text * 100.0 / | 875 lcd_text_metrics_.total_num_cc_layers_can_use_lcd_text * 100.0 / |
| (...skipping 24 matching lines...) Expand all Loading... |
| 905 | 900 |
| 906 return did_paint_content; | 901 return did_paint_content; |
| 907 } | 902 } |
| 908 | 903 |
| 909 void LayerTreeHost::TriggerPrepaint() { | 904 void LayerTreeHost::TriggerPrepaint() { |
| 910 prepaint_callback_.Cancel(); | 905 prepaint_callback_.Cancel(); |
| 911 TRACE_EVENT0("cc", "LayerTreeHost::TriggerPrepaint"); | 906 TRACE_EVENT0("cc", "LayerTreeHost::TriggerPrepaint"); |
| 912 SetNeedsCommit(); | 907 SetNeedsCommit(); |
| 913 } | 908 } |
| 914 | 909 |
| 915 static void LayerTreeHostReduceMemoryCallback(Layer* layer) { | |
| 916 layer->ReduceMemoryUsage(); | |
| 917 } | |
| 918 | |
| 919 void LayerTreeHost::ReduceMemoryUsage() { | 910 void LayerTreeHost::ReduceMemoryUsage() { |
| 920 if (!root_layer()) | 911 if (!root_layer()) |
| 921 return; | 912 return; |
| 922 | 913 |
| 923 LayerTreeHostCommon::CallFunctionForSubtree( | 914 LayerTreeHostCommon::CallFunctionForSubtree( |
| 924 root_layer(), | 915 root_layer(), [](Layer* layer) { layer->ReduceMemoryUsage(); }); |
| 925 base::Bind(&LayerTreeHostReduceMemoryCallback)); | |
| 926 } | 916 } |
| 927 | 917 |
| 928 void LayerTreeHost::SetPrioritiesForSurfaces(size_t surface_memory_bytes) { | 918 void LayerTreeHost::SetPrioritiesForSurfaces(size_t surface_memory_bytes) { |
| 929 DCHECK(surface_memory_placeholder_); | 919 DCHECK(surface_memory_placeholder_); |
| 930 | 920 |
| 931 // Surfaces have a place holder for their memory since they are managed | 921 // Surfaces have a place holder for their memory since they are managed |
| 932 // independantly but should still be tracked and reduce other memory usage. | 922 // independantly but should still be tracked and reduce other memory usage. |
| 933 surface_memory_placeholder_->SetTextureManager( | 923 surface_memory_placeholder_->SetTextureManager( |
| 934 contents_texture_manager_.get()); | 924 contents_texture_manager_.get()); |
| 935 surface_memory_placeholder_->set_request_priority( | 925 surface_memory_placeholder_->set_request_priority( |
| (...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1370 bool children_need_begin_frames) const { | 1360 bool children_need_begin_frames) const { |
| 1371 proxy_->SetChildrenNeedBeginFrames(children_need_begin_frames); | 1361 proxy_->SetChildrenNeedBeginFrames(children_need_begin_frames); |
| 1372 } | 1362 } |
| 1373 | 1363 |
| 1374 void LayerTreeHost::SendBeginFramesToChildren( | 1364 void LayerTreeHost::SendBeginFramesToChildren( |
| 1375 const BeginFrameArgs& args) const { | 1365 const BeginFrameArgs& args) const { |
| 1376 client_->SendBeginFramesToChildren(args); | 1366 client_->SendBeginFramesToChildren(args); |
| 1377 } | 1367 } |
| 1378 | 1368 |
| 1379 } // namespace cc | 1369 } // namespace cc |
| OLD | NEW |