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