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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 gpu_rasterization_histogram_recorded_(false), | 111 gpu_rasterization_histogram_recorded_(false), |
112 background_color_(SK_ColorWHITE), | 112 background_color_(SK_ColorWHITE), |
113 has_transparent_background_(false), | 113 has_transparent_background_(false), |
114 did_complete_scale_animation_(false), | 114 did_complete_scale_animation_(false), |
115 in_paint_layer_contents_(false), | 115 in_paint_layer_contents_(false), |
116 id_(s_layer_tree_host_sequence_number.GetNext() + 1), | 116 id_(s_layer_tree_host_sequence_number.GetNext() + 1), |
117 next_commit_forces_redraw_(false), | 117 next_commit_forces_redraw_(false), |
118 shared_bitmap_manager_(params->shared_bitmap_manager), | 118 shared_bitmap_manager_(params->shared_bitmap_manager), |
119 gpu_memory_buffer_manager_(params->gpu_memory_buffer_manager), | 119 gpu_memory_buffer_manager_(params->gpu_memory_buffer_manager), |
120 task_graph_runner_(params->task_graph_runner), | 120 task_graph_runner_(params->task_graph_runner), |
| 121 in_update_(false), |
121 surface_id_namespace_(0u), | 122 surface_id_namespace_(0u), |
122 next_surface_sequence_(1u) { | 123 next_surface_sequence_(1u) { |
123 DCHECK(task_graph_runner_); | 124 DCHECK(task_graph_runner_); |
124 | 125 |
125 if (settings_.accelerated_animation_enabled) { | 126 if (settings_.accelerated_animation_enabled) { |
126 if (settings_.use_compositor_animation_timelines) { | 127 if (settings_.use_compositor_animation_timelines) { |
127 animation_host_ = AnimationHost::Create(ThreadInstance::MAIN); | 128 animation_host_ = AnimationHost::Create(ThreadInstance::MAIN); |
128 animation_host_->SetMutatorHostClient(this); | 129 animation_host_->SetMutatorHostClient(this); |
129 } else { | 130 } else { |
130 animation_registrar_ = AnimationRegistrar::Create(); | 131 animation_registrar_ = AnimationRegistrar::Create(); |
(...skipping 658 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
789 BuildPropertyTreesAndComputeVisibleRects( | 790 BuildPropertyTreesAndComputeVisibleRects( |
790 root_layer, page_scale_layer, inner_viewport_scroll_layer_.get(), | 791 root_layer, page_scale_layer, inner_viewport_scroll_layer_.get(), |
791 outer_viewport_scroll_layer_.get(), page_scale_factor_, | 792 outer_viewport_scroll_layer_.get(), page_scale_factor_, |
792 device_scale_factor_, gfx::Rect(device_viewport_size_), | 793 device_scale_factor_, gfx::Rect(device_viewport_size_), |
793 identity_transform, &property_trees_, &update_layer_list); | 794 identity_transform, &property_trees_, &update_layer_list); |
794 } | 795 } |
795 | 796 |
796 for (const auto& layer : update_layer_list) | 797 for (const auto& layer : update_layer_list) |
797 layer->SavePaintProperties(); | 798 layer->SavePaintProperties(); |
798 | 799 |
| 800 in_update_ = true; |
799 base::AutoReset<bool> painting(&in_paint_layer_contents_, true); | 801 base::AutoReset<bool> painting(&in_paint_layer_contents_, true); |
800 bool did_paint_content = false; | 802 bool did_paint_content = false; |
801 for (const auto& layer : update_layer_list) { | 803 for (const auto& layer : update_layer_list) { |
802 // TODO(enne): temporarily clobber draw properties visible rect. | 804 // TODO(enne): temporarily clobber draw properties visible rect. |
803 layer->draw_properties().visible_layer_rect = | 805 layer->draw_properties().visible_layer_rect = |
804 layer->visible_rect_from_property_trees(); | 806 layer->visible_rect_from_property_trees(); |
805 did_paint_content |= layer->Update(); | 807 did_paint_content |= layer->Update(); |
806 content_is_suitable_for_gpu_rasterization_ &= | 808 content_is_suitable_for_gpu_rasterization_ &= |
807 layer->IsSuitableForGpuRasterization(); | 809 layer->IsSuitableForGpuRasterization(); |
808 } | 810 } |
| 811 in_update_ = false; |
809 return did_paint_content; | 812 return did_paint_content; |
810 } | 813 } |
811 | 814 |
812 void LayerTreeHost::ReduceMemoryUsage() { | 815 void LayerTreeHost::ReduceMemoryUsage() { |
813 if (!root_layer()) | 816 if (!root_layer()) |
814 return; | 817 return; |
815 | 818 |
816 LayerTreeHostCommon::CallFunctionForSubtree( | 819 LayerTreeHostCommon::CallFunctionForSubtree( |
817 root_layer(), [](Layer* layer) { layer->ReduceMemoryUsage(); }); | 820 root_layer(), [](Layer* layer) { layer->ReduceMemoryUsage(); }); |
818 } | 821 } |
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1207 return animation_host_ ? animation_host_->HasAnyAnimation(layer->id()) | 1210 return animation_host_ ? animation_host_->HasAnyAnimation(layer->id()) |
1208 : false; | 1211 : false; |
1209 } | 1212 } |
1210 | 1213 |
1211 bool LayerTreeHost::HasActiveAnimation(const Layer* layer) const { | 1214 bool LayerTreeHost::HasActiveAnimation(const Layer* layer) const { |
1212 return animation_host_ ? animation_host_->HasActiveAnimation(layer->id()) | 1215 return animation_host_ ? animation_host_->HasActiveAnimation(layer->id()) |
1213 : false; | 1216 : false; |
1214 } | 1217 } |
1215 | 1218 |
1216 } // namespace cc | 1219 } // namespace cc |
OLD | NEW |