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 <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 757 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
768 root_layer_->SetLayerTreeHost(this); | 768 root_layer_->SetLayerTreeHost(this); |
769 } | 769 } |
770 | 770 |
771 if (hud_layer_.get()) | 771 if (hud_layer_.get()) |
772 hud_layer_->RemoveFromParent(); | 772 hud_layer_->RemoveFromParent(); |
773 | 773 |
774 // Reset gpu rasterization flag. | 774 // Reset gpu rasterization flag. |
775 // This flag is sticky until a new tree comes along. | 775 // This flag is sticky until a new tree comes along. |
776 content_is_suitable_for_gpu_rasterization_ = true; | 776 content_is_suitable_for_gpu_rasterization_ = true; |
777 gpu_rasterization_histogram_recorded_ = false; | 777 gpu_rasterization_histogram_recorded_ = false; |
778 num_times_gpu_rasterization_reenabled_ = 0; | |
778 | 779 |
779 SetNeedsFullTreeSync(); | 780 SetNeedsFullTreeSync(); |
780 } | 781 } |
781 | 782 |
782 void LayerTreeHost::SetDebugState(const LayerTreeDebugState& debug_state) { | 783 void LayerTreeHost::SetDebugState(const LayerTreeDebugState& debug_state) { |
783 LayerTreeDebugState new_debug_state = | 784 LayerTreeDebugState new_debug_state = |
784 LayerTreeDebugState::Unite(settings_.initial_debug_state, debug_state); | 785 LayerTreeDebugState::Unite(settings_.initial_debug_state, debug_state); |
785 | 786 |
786 if (LayerTreeDebugState::Equal(debug_state_, new_debug_state)) | 787 if (LayerTreeDebugState::Equal(debug_state_, new_debug_state)) |
787 return; | 788 return; |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1043 draw_property_utils::FindLayersThatNeedUpdates( | 1044 draw_property_utils::FindLayersThatNeedUpdates( |
1044 this, property_trees_.transform_tree, property_trees_.effect_tree, | 1045 this, property_trees_.transform_tree, property_trees_.effect_tree, |
1045 &update_layer_list); | 1046 &update_layer_list); |
1046 } | 1047 } |
1047 | 1048 |
1048 for (const auto& layer : update_layer_list) | 1049 for (const auto& layer : update_layer_list) |
1049 layer->SavePaintProperties(); | 1050 layer->SavePaintProperties(); |
1050 | 1051 |
1051 base::AutoReset<bool> painting(&in_paint_layer_contents_, true); | 1052 base::AutoReset<bool> painting(&in_paint_layer_contents_, true); |
1052 bool did_paint_content = false; | 1053 bool did_paint_content = false; |
1054 bool old_content_is_suitable_for_gpu_rasterization = | |
1055 content_is_suitable_for_gpu_rasterization_; | |
1056 // Every |kFramePeriodToReeanbleGpuRasterization|, try to re-enable GPU | |
1057 // raserization. Only do this if we haven't re-enabled it too many times. | |
1058 if ((source_frame_number_ % kFramePeriodToReeanbleGpuRasterization) == 0 && | |
enne (OOO)
2016/06/30 01:02:24
I think it might be safer to say "if the last N fr
| |
1059 num_times_gpu_rasterization_reenabled_ < | |
1060 kMaxTimesToEnableGpuRasterization) { | |
1061 content_is_suitable_for_gpu_rasterization_ = true; | |
ericrk
2016/06/30 18:46:00
Can we always set this to true? Or do we want to c
| |
1062 } | |
1053 for (const auto& layer : update_layer_list) { | 1063 for (const auto& layer : update_layer_list) { |
1054 did_paint_content |= layer->Update(); | 1064 did_paint_content |= layer->Update(); |
1055 content_is_suitable_for_gpu_rasterization_ &= | 1065 content_is_suitable_for_gpu_rasterization_ &= |
1056 layer->IsSuitableForGpuRasterization(); | 1066 layer->IsSuitableForGpuRasterization(); |
1057 } | 1067 } |
1068 num_times_gpu_rasterization_reenabled_ += | |
1069 !old_content_is_suitable_for_gpu_rasterization && | |
1070 content_is_suitable_for_gpu_rasterization_; | |
1058 return did_paint_content; | 1071 return did_paint_content; |
1059 } | 1072 } |
1060 | 1073 |
1061 void LayerTreeHost::ApplyScrollAndScale(ScrollAndScaleSet* info) { | 1074 void LayerTreeHost::ApplyScrollAndScale(ScrollAndScaleSet* info) { |
1062 for (auto& swap_promise : info->swap_promises) { | 1075 for (auto& swap_promise : info->swap_promises) { |
1063 TRACE_EVENT_WITH_FLOW1("input,benchmark", | 1076 TRACE_EVENT_WITH_FLOW1("input,benchmark", |
1064 "LatencyInfo.Flow", | 1077 "LatencyInfo.Flow", |
1065 TRACE_ID_DONT_MANGLE(swap_promise->TraceId()), | 1078 TRACE_ID_DONT_MANGLE(swap_promise->TraceId()), |
1066 TRACE_EVENT_FLAG_FLOW_IN | TRACE_EVENT_FLAG_FLOW_OUT, | 1079 TRACE_EVENT_FLAG_FLOW_IN | TRACE_EVENT_FLAG_FLOW_OUT, |
1067 "step", "Main thread scroll update"); | 1080 "step", "Main thread scroll update"); |
(...skipping 694 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1762 int seq_num = property_trees_.sequence_number; | 1775 int seq_num = property_trees_.sequence_number; |
1763 LayerTreeHostCommon::CallFunctionForEveryLayer(this, [seq_num](Layer* layer) { | 1776 LayerTreeHostCommon::CallFunctionForEveryLayer(this, [seq_num](Layer* layer) { |
1764 layer->set_property_tree_sequence_number(seq_num); | 1777 layer->set_property_tree_sequence_number(seq_num); |
1765 }); | 1778 }); |
1766 | 1779 |
1767 surface_id_namespace_ = proto.surface_id_namespace(); | 1780 surface_id_namespace_ = proto.surface_id_namespace(); |
1768 next_surface_sequence_ = proto.next_surface_sequence(); | 1781 next_surface_sequence_ = proto.next_surface_sequence(); |
1769 } | 1782 } |
1770 | 1783 |
1771 } // namespace cc | 1784 } // namespace cc |
OLD | NEW |