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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 scoped_ptr<LayerTreeHost> layer_tree_host(new LayerTreeHost(params)); | 80 scoped_ptr<LayerTreeHost> layer_tree_host(new LayerTreeHost(params)); |
81 layer_tree_host->InitializeSingleThreaded( | 81 layer_tree_host->InitializeSingleThreaded( |
82 single_thread_client, params->main_task_runner, | 82 single_thread_client, params->main_task_runner, |
83 params->external_begin_frame_source.Pass()); | 83 params->external_begin_frame_source.Pass()); |
84 return layer_tree_host.Pass(); | 84 return layer_tree_host.Pass(); |
85 } | 85 } |
86 | 86 |
87 LayerTreeHost::LayerTreeHost(InitParams* params) | 87 LayerTreeHost::LayerTreeHost(InitParams* params) |
88 : micro_benchmark_controller_(this), | 88 : micro_benchmark_controller_(this), |
89 next_ui_resource_id_(1), | 89 next_ui_resource_id_(1), |
90 inside_begin_main_frame_(false), | |
91 needs_full_tree_sync_(true), | 90 needs_full_tree_sync_(true), |
92 needs_meta_info_recomputation_(true), | 91 needs_meta_info_recomputation_(true), |
93 client_(params->client), | 92 client_(params->client), |
94 source_frame_number_(0), | 93 source_frame_number_(0), |
95 meta_information_sequence_number_(1), | 94 meta_information_sequence_number_(1), |
96 rendering_stats_instrumentation_(RenderingStatsInstrumentation::Create()), | 95 rendering_stats_instrumentation_(RenderingStatsInstrumentation::Create()), |
97 output_surface_lost_(true), | 96 output_surface_lost_(true), |
98 settings_(*params->settings), | 97 settings_(*params->settings), |
99 debug_state_(settings_.initial_debug_state), | 98 debug_state_(settings_.initial_debug_state), |
100 top_controls_shrink_blink_size_(false), | 99 top_controls_shrink_blink_size_(false), |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 | 215 |
217 void LayerTreeHost::DidBeginMainFrame() { | 216 void LayerTreeHost::DidBeginMainFrame() { |
218 client_->DidBeginMainFrame(); | 217 client_->DidBeginMainFrame(); |
219 } | 218 } |
220 | 219 |
221 void LayerTreeHost::BeginMainFrameNotExpectedSoon() { | 220 void LayerTreeHost::BeginMainFrameNotExpectedSoon() { |
222 client_->BeginMainFrameNotExpectedSoon(); | 221 client_->BeginMainFrameNotExpectedSoon(); |
223 } | 222 } |
224 | 223 |
225 void LayerTreeHost::BeginMainFrame(const BeginFrameArgs& args) { | 224 void LayerTreeHost::BeginMainFrame(const BeginFrameArgs& args) { |
226 inside_begin_main_frame_ = true; | |
227 client_->BeginMainFrame(args); | 225 client_->BeginMainFrame(args); |
228 inside_begin_main_frame_ = false; | |
229 } | 226 } |
230 | 227 |
231 void LayerTreeHost::DidStopFlinging() { | 228 void LayerTreeHost::DidStopFlinging() { |
232 proxy_->MainThreadHasStoppedFlinging(); | 229 proxy_->MainThreadHasStoppedFlinging(); |
233 } | 230 } |
234 | 231 |
235 void LayerTreeHost::Layout() { | 232 void LayerTreeHost::Layout() { |
236 client_->Layout(); | 233 client_->Layout(); |
237 } | 234 } |
238 | 235 |
(...skipping 617 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
856 // TODO(ccameron): pass the elastic overscroll here so that input events | 853 // TODO(ccameron): pass the elastic overscroll here so that input events |
857 // may be translated appropriately. | 854 // may be translated appropriately. |
858 client_->ApplyViewportDeltas( | 855 client_->ApplyViewportDeltas( |
859 inner_viewport_scroll_delta, outer_viewport_scroll_delta, | 856 inner_viewport_scroll_delta, outer_viewport_scroll_delta, |
860 info->elastic_overscroll_delta, info->page_scale_delta, | 857 info->elastic_overscroll_delta, info->page_scale_delta, |
861 info->top_controls_delta); | 858 info->top_controls_delta); |
862 SetNeedsUpdateLayers(); | 859 SetNeedsUpdateLayers(); |
863 } | 860 } |
864 } | 861 } |
865 | 862 |
866 void LayerTreeHost::StartRateLimiter() { | |
867 if (inside_begin_main_frame_) | |
868 return; | |
869 | |
870 if (!rate_limit_timer_.IsRunning()) { | |
871 rate_limit_timer_.Start(FROM_HERE, | |
872 base::TimeDelta(), | |
873 this, | |
874 &LayerTreeHost::RateLimit); | |
875 } | |
876 } | |
877 | |
878 void LayerTreeHost::StopRateLimiter() { | |
879 rate_limit_timer_.Stop(); | |
880 } | |
881 | |
882 void LayerTreeHost::RateLimit() { | |
883 // Force a no-op command on the compositor context, so that any ratelimiting | |
884 // commands will wait for the compositing context, and therefore for the | |
885 // SwapBuffers. | |
886 proxy_->ForceSerializeOnSwapBuffers(); | |
887 client_->RateLimitSharedMainThreadContext(); | |
888 } | |
889 | |
890 void LayerTreeHost::SetDeviceScaleFactor(float device_scale_factor) { | 863 void LayerTreeHost::SetDeviceScaleFactor(float device_scale_factor) { |
891 if (device_scale_factor == device_scale_factor_) | 864 if (device_scale_factor == device_scale_factor_) |
892 return; | 865 return; |
893 device_scale_factor_ = device_scale_factor; | 866 device_scale_factor_ = device_scale_factor; |
894 | 867 |
895 property_trees_.needs_rebuild = true; | 868 property_trees_.needs_rebuild = true; |
896 SetNeedsCommit(); | 869 SetNeedsCommit(); |
897 } | 870 } |
898 | 871 |
899 void LayerTreeHost::UpdateTopControlsState(TopControlsState constraints, | 872 void LayerTreeHost::UpdateTopControlsState(TopControlsState constraints, |
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1244 return animation_host_ ? animation_host_->HasAnyAnimation(layer->id()) | 1217 return animation_host_ ? animation_host_->HasAnyAnimation(layer->id()) |
1245 : false; | 1218 : false; |
1246 } | 1219 } |
1247 | 1220 |
1248 bool LayerTreeHost::HasActiveAnimation(const Layer* layer) const { | 1221 bool LayerTreeHost::HasActiveAnimation(const Layer* layer) const { |
1249 return animation_host_ ? animation_host_->HasActiveAnimation(layer->id()) | 1222 return animation_host_ ? animation_host_->HasActiveAnimation(layer->id()) |
1250 : false; | 1223 : false; |
1251 } | 1224 } |
1252 | 1225 |
1253 } // namespace cc | 1226 } // namespace cc |
OLD | NEW |