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 869 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
880 surface_memory_placeholder_->SetTextureManager( | 880 surface_memory_placeholder_->SetTextureManager( |
881 contents_texture_manager_.get()); | 881 contents_texture_manager_.get()); |
882 surface_memory_placeholder_->set_request_priority( | 882 surface_memory_placeholder_->set_request_priority( |
883 PriorityCalculator::RenderSurfacePriority()); | 883 PriorityCalculator::RenderSurfacePriority()); |
884 surface_memory_placeholder_->SetToSelfManagedMemoryPlaceholder( | 884 surface_memory_placeholder_->SetToSelfManagedMemoryPlaceholder( |
885 surface_memory_bytes); | 885 surface_memory_bytes); |
886 } | 886 } |
887 | 887 |
888 void LayerTreeHost::SetPrioritiesForLayers( | 888 void LayerTreeHost::SetPrioritiesForLayers( |
889 const RenderSurfaceLayerList& update_list) { | 889 const RenderSurfaceLayerList& update_list) { |
890 typedef LayerIterator<Layer, | |
891 RenderSurfaceLayerList, | |
892 RenderSurface, | |
893 LayerIteratorActions::FrontToBack> LayerIteratorType; | |
894 | |
895 PriorityCalculator calculator; | 890 PriorityCalculator calculator; |
| 891 typedef LayerIterator<Layer> LayerIteratorType; |
896 LayerIteratorType end = LayerIteratorType::End(&update_list); | 892 LayerIteratorType end = LayerIteratorType::End(&update_list); |
897 for (LayerIteratorType it = LayerIteratorType::Begin(&update_list); | 893 for (LayerIteratorType it = LayerIteratorType::Begin(&update_list); |
898 it != end; | 894 it != end; |
899 ++it) { | 895 ++it) { |
900 if (it.represents_itself()) { | 896 if (it.represents_itself()) { |
901 it->SetTexturePriorities(calculator); | 897 it->SetTexturePriorities(calculator); |
902 } else if (it.represents_target_render_surface()) { | 898 } else if (it.represents_target_render_surface()) { |
903 if (it->mask_layer()) | 899 if (it->mask_layer()) |
904 it->mask_layer()->SetTexturePriorities(calculator); | 900 it->mask_layer()->SetTexturePriorities(calculator); |
905 if (it->replica_layer() && it->replica_layer()->mask_layer()) | 901 if (it->replica_layer() && it->replica_layer()->mask_layer()) |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
982 *did_paint_content |= replica_mask_layer->Update(queue, NULL); | 978 *did_paint_content |= replica_mask_layer->Update(queue, NULL); |
983 *need_more_updates |= replica_mask_layer->NeedMoreUpdates(); | 979 *need_more_updates |= replica_mask_layer->NeedMoreUpdates(); |
984 } | 980 } |
985 } | 981 } |
986 | 982 |
987 void LayerTreeHost::PaintLayerContents( | 983 void LayerTreeHost::PaintLayerContents( |
988 const RenderSurfaceLayerList& render_surface_layer_list, | 984 const RenderSurfaceLayerList& render_surface_layer_list, |
989 ResourceUpdateQueue* queue, | 985 ResourceUpdateQueue* queue, |
990 bool* did_paint_content, | 986 bool* did_paint_content, |
991 bool* need_more_updates) { | 987 bool* need_more_updates) { |
992 // Use FrontToBack to allow for testing occlusion and performing culling | |
993 // during the tree walk. | |
994 typedef LayerIterator<Layer, | |
995 RenderSurfaceLayerList, | |
996 RenderSurface, | |
997 LayerIteratorActions::FrontToBack> LayerIteratorType; | |
998 | |
999 bool record_metrics_for_frame = | 988 bool record_metrics_for_frame = |
1000 settings_.show_overdraw_in_tracing && | 989 settings_.show_overdraw_in_tracing && |
1001 base::debug::TraceLog::GetInstance() && | 990 base::debug::TraceLog::GetInstance() && |
1002 base::debug::TraceLog::GetInstance()->IsEnabled(); | 991 base::debug::TraceLog::GetInstance()->IsEnabled(); |
1003 OcclusionTracker occlusion_tracker( | 992 OcclusionTracker occlusion_tracker( |
1004 root_layer_->render_surface()->content_rect(), record_metrics_for_frame); | 993 root_layer_->render_surface()->content_rect(), record_metrics_for_frame); |
1005 occlusion_tracker.set_minimum_tracking_size( | 994 occlusion_tracker.set_minimum_tracking_size( |
1006 settings_.minimum_occlusion_tracking_size); | 995 settings_.minimum_occlusion_tracking_size); |
1007 | 996 |
1008 PrioritizeTextures(render_surface_layer_list, | 997 PrioritizeTextures(render_surface_layer_list, |
1009 occlusion_tracker.overdraw_metrics()); | 998 occlusion_tracker.overdraw_metrics()); |
1010 | 999 |
1011 in_paint_layer_contents_ = true; | 1000 in_paint_layer_contents_ = true; |
1012 | 1001 |
| 1002 // Iterates front-to-back to allow for testing occlusion and performing |
| 1003 // culling during the tree walk. |
| 1004 typedef LayerIterator<Layer> LayerIteratorType; |
1013 LayerIteratorType end = LayerIteratorType::End(&render_surface_layer_list); | 1005 LayerIteratorType end = LayerIteratorType::End(&render_surface_layer_list); |
1014 for (LayerIteratorType it = | 1006 for (LayerIteratorType it = |
1015 LayerIteratorType::Begin(&render_surface_layer_list); | 1007 LayerIteratorType::Begin(&render_surface_layer_list); |
1016 it != end; | 1008 it != end; |
1017 ++it) { | 1009 ++it) { |
1018 occlusion_tracker.EnterLayer(it); | 1010 occlusion_tracker.EnterLayer(it); |
1019 | 1011 |
1020 if (it.represents_target_render_surface()) { | 1012 if (it.represents_target_render_surface()) { |
1021 PaintMasksForRenderSurface( | 1013 PaintMasksForRenderSurface( |
1022 *it, queue, did_paint_content, need_more_updates); | 1014 *it, queue, did_paint_content, need_more_updates); |
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1320 swap_promise_list_.push_back(swap_promise.Pass()); | 1312 swap_promise_list_.push_back(swap_promise.Pass()); |
1321 } | 1313 } |
1322 | 1314 |
1323 void LayerTreeHost::BreakSwapPromises(SwapPromise::DidNotSwapReason reason) { | 1315 void LayerTreeHost::BreakSwapPromises(SwapPromise::DidNotSwapReason reason) { |
1324 for (size_t i = 0; i < swap_promise_list_.size(); i++) | 1316 for (size_t i = 0; i < swap_promise_list_.size(); i++) |
1325 swap_promise_list_[i]->DidNotSwap(reason); | 1317 swap_promise_list_[i]->DidNotSwap(reason); |
1326 swap_promise_list_.clear(); | 1318 swap_promise_list_.clear(); |
1327 } | 1319 } |
1328 | 1320 |
1329 } // namespace cc | 1321 } // namespace cc |
OLD | NEW |