| 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 |
| 11 #include "base/atomic_sequence_num.h" | 11 #include "base/atomic_sequence_num.h" |
| 12 #include "base/bind.h" | 12 #include "base/bind.h" |
| 13 #include "base/command_line.h" | 13 #include "base/command_line.h" |
| 14 #include "base/location.h" | 14 #include "base/location.h" |
| 15 #include "base/metrics/histogram.h" | 15 #include "base/metrics/histogram.h" |
| 16 #include "base/single_thread_task_runner.h" | 16 #include "base/single_thread_task_runner.h" |
| 17 #include "base/stl_util.h" | 17 #include "base/stl_util.h" |
| 18 #include "base/strings/string_number_conversions.h" | 18 #include "base/strings/string_number_conversions.h" |
| 19 #include "base/thread_task_runner_handle.h" | 19 #include "base/thread_task_runner_handle.h" |
| 20 #include "base/trace_event/trace_event.h" | 20 #include "base/trace_event/trace_event.h" |
| 21 #include "base/trace_event/trace_event_argument.h" | 21 #include "base/trace_event/trace_event_argument.h" |
| 22 #include "cc/animation/animation_host.h" |
| 22 #include "cc/animation/animation_registrar.h" | 23 #include "cc/animation/animation_registrar.h" |
| 23 #include "cc/animation/layer_animation_controller.h" | 24 #include "cc/animation/layer_animation_controller.h" |
| 24 #include "cc/base/math_util.h" | 25 #include "cc/base/math_util.h" |
| 25 #include "cc/debug/devtools_instrumentation.h" | 26 #include "cc/debug/devtools_instrumentation.h" |
| 26 #include "cc/debug/frame_viewer_instrumentation.h" | 27 #include "cc/debug/frame_viewer_instrumentation.h" |
| 27 #include "cc/debug/rendering_stats_instrumentation.h" | 28 #include "cc/debug/rendering_stats_instrumentation.h" |
| 28 #include "cc/input/layer_selection_bound.h" | 29 #include "cc/input/layer_selection_bound.h" |
| 29 #include "cc/input/page_scale_animation.h" | 30 #include "cc/input/page_scale_animation.h" |
| 30 #include "cc/input/top_controls_manager.h" | 31 #include "cc/input/top_controls_manager.h" |
| 31 #include "cc/layers/heads_up_display_layer.h" | 32 #include "cc/layers/heads_up_display_layer.h" |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 next_commit_forces_redraw_(false), | 129 next_commit_forces_redraw_(false), |
| 129 shared_bitmap_manager_(shared_bitmap_manager), | 130 shared_bitmap_manager_(shared_bitmap_manager), |
| 130 gpu_memory_buffer_manager_(gpu_memory_buffer_manager), | 131 gpu_memory_buffer_manager_(gpu_memory_buffer_manager), |
| 131 task_graph_runner_(task_graph_runner), | 132 task_graph_runner_(task_graph_runner), |
| 132 surface_id_namespace_(0u), | 133 surface_id_namespace_(0u), |
| 133 next_surface_sequence_(1u) { | 134 next_surface_sequence_(1u) { |
| 134 if (settings_.accelerated_animation_enabled) | 135 if (settings_.accelerated_animation_enabled) |
| 135 animation_registrar_ = AnimationRegistrar::Create(); | 136 animation_registrar_ = AnimationRegistrar::Create(); |
| 136 rendering_stats_instrumentation_->set_record_rendering_stats( | 137 rendering_stats_instrumentation_->set_record_rendering_stats( |
| 137 debug_state_.RecordRenderingStats()); | 138 debug_state_.RecordRenderingStats()); |
| 139 |
| 140 if (settings_.use_compositor_animation_timelines) { |
| 141 animation_host_ = AnimationHost::Create(false); |
| 142 animation_host_->SetLayerTreeMutatorsClient(this); |
| 143 } |
| 138 } | 144 } |
| 139 | 145 |
| 140 void LayerTreeHost::InitializeThreaded( | 146 void LayerTreeHost::InitializeThreaded( |
| 141 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, | 147 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
| 142 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner, | 148 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner, |
| 143 scoped_ptr<BeginFrameSource> external_begin_frame_source) { | 149 scoped_ptr<BeginFrameSource> external_begin_frame_source) { |
| 144 InitializeProxy(ThreadProxy::Create(this, | 150 InitializeProxy(ThreadProxy::Create(this, |
| 145 main_task_runner, | 151 main_task_runner, |
| 146 impl_task_runner, | 152 impl_task_runner, |
| 147 external_begin_frame_source.Pass())); | 153 external_begin_frame_source.Pass())); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 169 proxy_->Start(); | 175 proxy_->Start(); |
| 170 if (settings_.accelerated_animation_enabled) { | 176 if (settings_.accelerated_animation_enabled) { |
| 171 animation_registrar_->set_supports_scroll_animations( | 177 animation_registrar_->set_supports_scroll_animations( |
| 172 proxy_->SupportsImplScrolling()); | 178 proxy_->SupportsImplScrolling()); |
| 173 } | 179 } |
| 174 } | 180 } |
| 175 | 181 |
| 176 LayerTreeHost::~LayerTreeHost() { | 182 LayerTreeHost::~LayerTreeHost() { |
| 177 TRACE_EVENT0("cc", "LayerTreeHost::~LayerTreeHost"); | 183 TRACE_EVENT0("cc", "LayerTreeHost::~LayerTreeHost"); |
| 178 | 184 |
| 185 if (animation_host_) |
| 186 animation_host_->SetLayerTreeMutatorsClient(nullptr); |
| 187 |
| 179 if (root_layer_.get()) | 188 if (root_layer_.get()) |
| 180 root_layer_->SetLayerTreeHost(NULL); | 189 root_layer_->SetLayerTreeHost(NULL); |
| 181 | 190 |
| 182 DCHECK(swap_promise_monitor_.empty()); | 191 DCHECK(swap_promise_monitor_.empty()); |
| 183 | 192 |
| 184 BreakSwapPromises(SwapPromise::COMMIT_FAILS); | 193 BreakSwapPromises(SwapPromise::COMMIT_FAILS); |
| 185 | 194 |
| 186 if (proxy_) { | 195 if (proxy_) { |
| 187 DCHECK(proxy_->IsMainThread()); | 196 DCHECK(proxy_->IsMainThread()); |
| 188 proxy_->Stop(); | 197 proxy_->Stop(); |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 363 if (sync_tree->ContentsTexturesPurged()) | 372 if (sync_tree->ContentsTexturesPurged()) |
| 364 sync_tree->ResetContentsTexturesPurged(); | 373 sync_tree->ResetContentsTexturesPurged(); |
| 365 } | 374 } |
| 366 | 375 |
| 367 sync_tree->set_has_ever_been_drawn(false); | 376 sync_tree->set_has_ever_been_drawn(false); |
| 368 sync_tree->SetPropertyTrees(property_trees_); | 377 sync_tree->SetPropertyTrees(property_trees_); |
| 369 | 378 |
| 370 { | 379 { |
| 371 TRACE_EVENT0("cc", "LayerTreeHost::PushProperties"); | 380 TRACE_EVENT0("cc", "LayerTreeHost::PushProperties"); |
| 372 TreeSynchronizer::PushProperties(root_layer(), sync_tree->root_layer()); | 381 TreeSynchronizer::PushProperties(root_layer(), sync_tree->root_layer()); |
| 382 |
| 383 if (animation_host_) { |
| 384 DCHECK(host_impl->animation_host()); |
| 385 animation_host_->PushPropertiesTo(host_impl->animation_host()); |
| 386 } |
| 373 } | 387 } |
| 374 | 388 |
| 375 micro_benchmark_controller_.ScheduleImplBenchmarks(host_impl); | 389 micro_benchmark_controller_.ScheduleImplBenchmarks(host_impl); |
| 376 } | 390 } |
| 377 | 391 |
| 378 void LayerTreeHost::WillCommit() { | 392 void LayerTreeHost::WillCommit() { |
| 379 client_->WillCommit(); | 393 client_->WillCommit(); |
| 380 } | 394 } |
| 381 | 395 |
| 382 void LayerTreeHost::UpdateHudLayer() { | 396 void LayerTreeHost::UpdateHudLayer() { |
| (...skipping 901 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1284 void LayerTreeHost::SendBeginFramesToChildren( | 1298 void LayerTreeHost::SendBeginFramesToChildren( |
| 1285 const BeginFrameArgs& args) const { | 1299 const BeginFrameArgs& args) const { |
| 1286 client_->SendBeginFramesToChildren(args); | 1300 client_->SendBeginFramesToChildren(args); |
| 1287 } | 1301 } |
| 1288 | 1302 |
| 1289 void LayerTreeHost::SetAuthoritativeVSyncInterval( | 1303 void LayerTreeHost::SetAuthoritativeVSyncInterval( |
| 1290 const base::TimeDelta& interval) { | 1304 const base::TimeDelta& interval) { |
| 1291 proxy_->SetAuthoritativeVSyncInterval(interval); | 1305 proxy_->SetAuthoritativeVSyncInterval(interval); |
| 1292 } | 1306 } |
| 1293 | 1307 |
| 1308 Layer* LayerTreeHost::LayerById(int id) const { |
| 1309 LayerIdMap::const_iterator iter = layer_id_map_.find(id); |
| 1310 return iter != layer_id_map_.end() ? iter->second : NULL; |
| 1311 } |
| 1312 |
| 1313 void LayerTreeHost::RegisterLayer(Layer* layer) { |
| 1314 DCHECK(!LayerById(layer->id())); |
| 1315 layer_id_map_[layer->id()] = layer; |
| 1316 if (animation_host_) |
| 1317 animation_host_->RegisterLayer(layer->id(), true); |
| 1318 } |
| 1319 |
| 1320 void LayerTreeHost::UnregisterLayer(Layer* layer) { |
| 1321 DCHECK(LayerById(layer->id())); |
| 1322 if (animation_host_) |
| 1323 animation_host_->UnregisterLayer(layer->id(), true); |
| 1324 layer_id_map_.erase(layer->id()); |
| 1325 } |
| 1326 |
| 1327 bool LayerTreeHost::IsLayerInActiveTree(int layer_id) const { |
| 1328 return true; |
| 1329 } |
| 1330 |
| 1331 bool LayerTreeHost::IsLayerInPendingTree(int layer_id) const { |
| 1332 return false; |
| 1333 } |
| 1334 |
| 1335 void LayerTreeHost::SetMutatorsNeedCommit() { |
| 1336 SetNeedsCommit(); |
| 1337 } |
| 1338 |
| 1339 void LayerTreeHost::SetLayerFilterMutated(int layer_id, |
| 1340 bool active_tree, |
| 1341 const FilterOperations& filters) { |
| 1342 LayerAnimationValueObserver* layer = LayerById(layer_id); |
| 1343 DCHECK(layer); |
| 1344 layer->OnFilterAnimated(filters); |
| 1345 } |
| 1346 |
| 1347 void LayerTreeHost::SetLayerOpacityMutated(int layer_id, |
| 1348 bool active_tree, |
| 1349 float opacity) { |
| 1350 LayerAnimationValueObserver* layer = LayerById(layer_id); |
| 1351 DCHECK(layer); |
| 1352 layer->OnOpacityAnimated(opacity); |
| 1353 } |
| 1354 |
| 1355 void LayerTreeHost::SetLayerTransformMutated(int layer_id, |
| 1356 bool active_tree, |
| 1357 const gfx::Transform& transform) { |
| 1358 LayerAnimationValueObserver* layer = LayerById(layer_id); |
| 1359 DCHECK(layer); |
| 1360 layer->OnTransformAnimated(transform); |
| 1361 } |
| 1362 |
| 1363 void LayerTreeHost::SetLayerScrollOffsetMutated( |
| 1364 int layer_id, |
| 1365 bool active_tree, |
| 1366 const gfx::ScrollOffset& scroll_offset) { |
| 1367 LayerAnimationValueObserver* layer = LayerById(layer_id); |
| 1368 DCHECK(layer); |
| 1369 layer->OnScrollOffsetAnimated(scroll_offset); |
| 1370 } |
| 1371 |
| 1294 } // namespace cc | 1372 } // namespace cc |
| OLD | NEW |