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/message_loop/message_loop.h" | 14 #include "base/message_loop/message_loop.h" |
15 #include "base/metrics/histogram.h" | 15 #include "base/metrics/histogram.h" |
16 #include "base/stl_util.h" | 16 #include "base/stl_util.h" |
17 #include "base/strings/string_number_conversions.h" | 17 #include "base/strings/string_number_conversions.h" |
18 #include "base/trace_event/trace_event.h" | 18 #include "base/trace_event/trace_event.h" |
19 #include "base/trace_event/trace_event_argument.h" | 19 #include "base/trace_event/trace_event_argument.h" |
20 #include "cc/animation/animation_registrar.h" | 20 #include "cc/animation/animation_registrar.h" |
| 21 #include "cc/animation/animation_timeline.h" |
21 #include "cc/animation/layer_animation_controller.h" | 22 #include "cc/animation/layer_animation_controller.h" |
22 #include "cc/base/math_util.h" | 23 #include "cc/base/math_util.h" |
23 #include "cc/debug/devtools_instrumentation.h" | 24 #include "cc/debug/devtools_instrumentation.h" |
24 #include "cc/debug/rendering_stats_instrumentation.h" | 25 #include "cc/debug/rendering_stats_instrumentation.h" |
25 #include "cc/input/layer_selection_bound.h" | 26 #include "cc/input/layer_selection_bound.h" |
26 #include "cc/input/page_scale_animation.h" | 27 #include "cc/input/page_scale_animation.h" |
27 #include "cc/input/top_controls_manager.h" | 28 #include "cc/input/top_controls_manager.h" |
28 #include "cc/layers/heads_up_display_layer.h" | 29 #include "cc/layers/heads_up_display_layer.h" |
29 #include "cc/layers/heads_up_display_layer_impl.h" | 30 #include "cc/layers/heads_up_display_layer_impl.h" |
30 #include "cc/layers/layer.h" | 31 #include "cc/layers/layer.h" |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
288 LayerTreeImpl* sync_tree = host_impl->sync_tree(); | 289 LayerTreeImpl* sync_tree = host_impl->sync_tree(); |
289 | 290 |
290 if (next_commit_forces_redraw_) { | 291 if (next_commit_forces_redraw_) { |
291 sync_tree->ForceRedrawNextActivation(); | 292 sync_tree->ForceRedrawNextActivation(); |
292 next_commit_forces_redraw_ = false; | 293 next_commit_forces_redraw_ = false; |
293 } | 294 } |
294 | 295 |
295 sync_tree->set_source_frame_number(source_frame_number()); | 296 sync_tree->set_source_frame_number(source_frame_number()); |
296 | 297 |
297 if (needs_full_tree_sync_) { | 298 if (needs_full_tree_sync_) { |
| 299 scoped_refptr<AnimationTimeline> timeline_impl; |
| 300 if (animation_timeline_) { |
| 301 timeline_impl = host_impl->animation_timeline(); |
| 302 if (!timeline_impl) |
| 303 timeline_impl = AnimationTimeline::Create(); |
| 304 } |
| 305 host_impl->SetAnimationTimeline(timeline_impl); |
| 306 |
298 sync_tree->SetRootLayer(TreeSynchronizer::SynchronizeTrees( | 307 sync_tree->SetRootLayer(TreeSynchronizer::SynchronizeTrees( |
299 root_layer(), sync_tree->DetachLayerTree(), sync_tree)); | 308 root_layer(), sync_tree->DetachLayerTree(), sync_tree)); |
300 } | 309 } |
301 sync_tree->set_needs_full_tree_sync(needs_full_tree_sync_); | 310 sync_tree->set_needs_full_tree_sync(needs_full_tree_sync_); |
302 needs_full_tree_sync_ = false; | 311 needs_full_tree_sync_ = false; |
303 | 312 |
304 if (hud_layer_.get()) { | 313 if (hud_layer_.get()) { |
305 LayerImpl* hud_impl = LayerTreeHostCommon::FindLayerInSubtree( | 314 LayerImpl* hud_impl = LayerTreeHostCommon::FindLayerInSubtree( |
306 sync_tree->root_layer(), hud_layer_->id()); | 315 sync_tree->root_layer(), hud_layer_->id()); |
307 sync_tree->set_hud_layer(static_cast<HeadsUpDisplayLayerImpl*>(hud_impl)); | 316 sync_tree->set_hud_layer(static_cast<HeadsUpDisplayLayerImpl*>(hud_impl)); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
361 if (new_impl_tree_has_no_evicted_resources) { | 370 if (new_impl_tree_has_no_evicted_resources) { |
362 if (sync_tree->ContentsTexturesPurged()) | 371 if (sync_tree->ContentsTexturesPurged()) |
363 sync_tree->ResetContentsTexturesPurged(); | 372 sync_tree->ResetContentsTexturesPurged(); |
364 } | 373 } |
365 | 374 |
366 sync_tree->set_has_ever_been_drawn(false); | 375 sync_tree->set_has_ever_been_drawn(false); |
367 | 376 |
368 { | 377 { |
369 TRACE_EVENT0("cc", "LayerTreeHost::PushProperties"); | 378 TRACE_EVENT0("cc", "LayerTreeHost::PushProperties"); |
370 TreeSynchronizer::PushProperties(root_layer(), sync_tree->root_layer()); | 379 TreeSynchronizer::PushProperties(root_layer(), sync_tree->root_layer()); |
| 380 |
| 381 if (animation_timeline_) { |
| 382 DCHECK(host_impl->animation_timeline()); |
| 383 animation_timeline_->PushPropertiesTo(host_impl->animation_timeline()); |
| 384 } |
371 } | 385 } |
372 | 386 |
373 micro_benchmark_controller_.ScheduleImplBenchmarks(host_impl); | 387 micro_benchmark_controller_.ScheduleImplBenchmarks(host_impl); |
374 } | 388 } |
375 | 389 |
376 void LayerTreeHost::WillCommit() { | 390 void LayerTreeHost::WillCommit() { |
377 client_->WillCommit(); | 391 client_->WillCommit(); |
378 } | 392 } |
379 | 393 |
380 void LayerTreeHost::UpdateHudLayer() { | 394 void LayerTreeHost::UpdateHudLayer() { |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
543 void LayerTreeHost::SetNextCommitForcesRedraw() { | 557 void LayerTreeHost::SetNextCommitForcesRedraw() { |
544 next_commit_forces_redraw_ = true; | 558 next_commit_forces_redraw_ = true; |
545 } | 559 } |
546 | 560 |
547 void LayerTreeHost::SetAnimationEvents( | 561 void LayerTreeHost::SetAnimationEvents( |
548 scoped_ptr<AnimationEventsVector> events) { | 562 scoped_ptr<AnimationEventsVector> events) { |
549 DCHECK(proxy_->IsMainThread()); | 563 DCHECK(proxy_->IsMainThread()); |
550 animation_registrar_->SetAnimationEvents(events.Pass()); | 564 animation_registrar_->SetAnimationEvents(events.Pass()); |
551 } | 565 } |
552 | 566 |
| 567 void LayerTreeHost::SetAnimationTimeline( |
| 568 scoped_refptr<AnimationTimeline> timeline) { |
| 569 if (animation_timeline_.get() == timeline.get()) |
| 570 return; |
| 571 |
| 572 if (animation_timeline_.get()) |
| 573 animation_timeline_->SetLayerTreeMutatorsClient(nullptr); |
| 574 animation_timeline_ = timeline; |
| 575 if (animation_timeline_.get()) |
| 576 animation_timeline_->SetLayerTreeMutatorsClient(this); |
| 577 } |
| 578 |
553 void LayerTreeHost::SetRootLayer(scoped_refptr<Layer> root_layer) { | 579 void LayerTreeHost::SetRootLayer(scoped_refptr<Layer> root_layer) { |
554 if (root_layer_.get() == root_layer.get()) | 580 if (root_layer_.get() == root_layer.get()) |
555 return; | 581 return; |
556 | 582 |
557 if (root_layer_.get()) | 583 if (root_layer_.get()) |
558 root_layer_->SetLayerTreeHost(NULL); | 584 root_layer_->SetLayerTreeHost(NULL); |
559 root_layer_ = root_layer; | 585 root_layer_ = root_layer; |
560 if (root_layer_.get()) { | 586 if (root_layer_.get()) { |
561 DCHECK(!root_layer_->parent()); | 587 DCHECK(!root_layer_->parent()); |
562 root_layer_->SetLayerTreeHost(this); | 588 root_layer_->SetLayerTreeHost(this); |
(...skipping 719 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1282 void LayerTreeHost::SetChildrenNeedBeginFrames( | 1308 void LayerTreeHost::SetChildrenNeedBeginFrames( |
1283 bool children_need_begin_frames) const { | 1309 bool children_need_begin_frames) const { |
1284 proxy_->SetChildrenNeedBeginFrames(children_need_begin_frames); | 1310 proxy_->SetChildrenNeedBeginFrames(children_need_begin_frames); |
1285 } | 1311 } |
1286 | 1312 |
1287 void LayerTreeHost::SendBeginFramesToChildren( | 1313 void LayerTreeHost::SendBeginFramesToChildren( |
1288 const BeginFrameArgs& args) const { | 1314 const BeginFrameArgs& args) const { |
1289 client_->SendBeginFramesToChildren(args); | 1315 client_->SendBeginFramesToChildren(args); |
1290 } | 1316 } |
1291 | 1317 |
| 1318 Layer* LayerTreeHost::LayerById(int id) const { |
| 1319 LayerIdMap::const_iterator iter = layer_id_map_.find(id); |
| 1320 return iter != layer_id_map_.end() ? iter->second : NULL; |
| 1321 } |
| 1322 |
| 1323 void LayerTreeHost::RegisterLayer(Layer* layer) { |
| 1324 DCHECK(!LayerById(layer->id())); |
| 1325 layer_id_map_[layer->id()] = layer; |
| 1326 } |
| 1327 |
| 1328 void LayerTreeHost::UnregisterLayer(Layer* layer) { |
| 1329 DCHECK(LayerById(layer->id())); |
| 1330 layer_id_map_.erase(layer->id()); |
| 1331 } |
| 1332 |
| 1333 AnimationRegistrar* LayerTreeHost::GetAnimationRegistrar() const { |
| 1334 return animation_registrar_.get(); |
| 1335 } |
| 1336 |
| 1337 bool LayerTreeHost::IsLayerInActiveTree(int layer_id) const { |
| 1338 return true; |
| 1339 } |
| 1340 |
| 1341 bool LayerTreeHost::IsLayerInPendingTree(int layer_id) const { |
| 1342 return false; |
| 1343 } |
| 1344 |
| 1345 void LayerTreeHost::SetMutatorsNeedCommit() { |
| 1346 SetNeedsCommit(); |
| 1347 } |
| 1348 |
| 1349 void LayerTreeHost::SetLayerFilterMutated(int layer_id, |
| 1350 bool active_tree, |
| 1351 const FilterOperations& filters) { |
| 1352 LayerAnimationValueObserver* layer = LayerById(layer_id); |
| 1353 DCHECK(layer); |
| 1354 layer->OnFilterAnimated(filters); |
| 1355 } |
| 1356 |
| 1357 void LayerTreeHost::SetLayerOpacityMutated(int layer_id, |
| 1358 bool active_tree, |
| 1359 float opacity) { |
| 1360 LayerAnimationValueObserver* layer = LayerById(layer_id); |
| 1361 DCHECK(layer); |
| 1362 layer->OnOpacityAnimated(opacity); |
| 1363 } |
| 1364 |
| 1365 void LayerTreeHost::SetLayerTransformMutated(int layer_id, |
| 1366 bool active_tree, |
| 1367 const gfx::Transform& transform) { |
| 1368 LayerAnimationValueObserver* layer = LayerById(layer_id); |
| 1369 DCHECK(layer); |
| 1370 layer->OnTransformAnimated(transform); |
| 1371 } |
| 1372 |
1292 } // namespace cc | 1373 } // namespace cc |
OLD | NEW |