Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(123)

Side by Side Diff: cc/trees/layer_tree_host.cc

Issue 947033002: CC Animations: Establish AnimationHost, AnimationTimeline and AnimationPlayer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 LayerTreeImpl* sync_tree = host_impl->sync_tree(); 290 LayerTreeImpl* sync_tree = host_impl->sync_tree();
290 291
291 if (next_commit_forces_redraw_) { 292 if (next_commit_forces_redraw_) {
292 sync_tree->ForceRedrawNextActivation(); 293 sync_tree->ForceRedrawNextActivation();
293 next_commit_forces_redraw_ = false; 294 next_commit_forces_redraw_ = false;
294 } 295 }
295 296
296 sync_tree->set_source_frame_number(source_frame_number()); 297 sync_tree->set_source_frame_number(source_frame_number());
297 298
298 if (needs_full_tree_sync_) { 299 if (needs_full_tree_sync_) {
300 host_impl->SetAnimationTimeline(
301 animation_timeline_ ? AnimationTimeline::Create() : nullptr);
302
299 sync_tree->SetRootLayer(TreeSynchronizer::SynchronizeTrees( 303 sync_tree->SetRootLayer(TreeSynchronizer::SynchronizeTrees(
300 root_layer(), sync_tree->DetachLayerTree(), sync_tree)); 304 root_layer(), sync_tree->DetachLayerTree(), sync_tree));
301 } 305 }
302 sync_tree->set_needs_full_tree_sync(needs_full_tree_sync_); 306 sync_tree->set_needs_full_tree_sync(needs_full_tree_sync_);
303 needs_full_tree_sync_ = false; 307 needs_full_tree_sync_ = false;
304 308
305 if (hud_layer_.get()) { 309 if (hud_layer_.get()) {
306 LayerImpl* hud_impl = LayerTreeHostCommon::FindLayerInSubtree( 310 LayerImpl* hud_impl = LayerTreeHostCommon::FindLayerInSubtree(
307 sync_tree->root_layer(), hud_layer_->id()); 311 sync_tree->root_layer(), hud_layer_->id());
308 sync_tree->set_hud_layer(static_cast<HeadsUpDisplayLayerImpl*>(hud_impl)); 312 sync_tree->set_hud_layer(static_cast<HeadsUpDisplayLayerImpl*>(hud_impl));
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 if (new_impl_tree_has_no_evicted_resources) { 366 if (new_impl_tree_has_no_evicted_resources) {
363 if (sync_tree->ContentsTexturesPurged()) 367 if (sync_tree->ContentsTexturesPurged())
364 sync_tree->ResetContentsTexturesPurged(); 368 sync_tree->ResetContentsTexturesPurged();
365 } 369 }
366 370
367 sync_tree->set_has_ever_been_drawn(false); 371 sync_tree->set_has_ever_been_drawn(false);
368 372
369 { 373 {
370 TRACE_EVENT0("cc", "LayerTreeHost::PushProperties"); 374 TRACE_EVENT0("cc", "LayerTreeHost::PushProperties");
371 TreeSynchronizer::PushProperties(root_layer(), sync_tree->root_layer()); 375 TreeSynchronizer::PushProperties(root_layer(), sync_tree->root_layer());
376
377 if (animation_timeline_) {
378 DCHECK(host_impl->animation_timeline());
379 animation_timeline_->PushPropertiesTo(host_impl->animation_timeline());
380 }
372 } 381 }
373 382
374 micro_benchmark_controller_.ScheduleImplBenchmarks(host_impl); 383 micro_benchmark_controller_.ScheduleImplBenchmarks(host_impl);
375 } 384 }
376 385
377 void LayerTreeHost::WillCommit() { 386 void LayerTreeHost::WillCommit() {
378 client_->WillCommit(); 387 client_->WillCommit();
379 } 388 }
380 389
381 void LayerTreeHost::UpdateHudLayer() { 390 void LayerTreeHost::UpdateHudLayer() {
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
572 break; 581 break;
573 582
574 case AnimationEvent::PropertyUpdate: 583 case AnimationEvent::PropertyUpdate:
575 (*iter).second->NotifyAnimationPropertyUpdate((*events)[event_index]); 584 (*iter).second->NotifyAnimationPropertyUpdate((*events)[event_index]);
576 break; 585 break;
577 } 586 }
578 } 587 }
579 } 588 }
580 } 589 }
581 590
591 void LayerTreeHost::SetAnimationTimeline(
592 scoped_refptr<AnimationTimeline> timeline) {
593 if (animation_timeline_.get() == timeline.get())
594 return;
595
596 if (animation_timeline_.get())
597 animation_timeline_->SetLayerTreeMutatorsClient(nullptr);
598 animation_timeline_ = timeline;
599 if (animation_timeline_.get())
600 animation_timeline_->SetLayerTreeMutatorsClient(this);
601 }
602
582 void LayerTreeHost::SetRootLayer(scoped_refptr<Layer> root_layer) { 603 void LayerTreeHost::SetRootLayer(scoped_refptr<Layer> root_layer) {
583 if (root_layer_.get() == root_layer.get()) 604 if (root_layer_.get() == root_layer.get())
584 return; 605 return;
585 606
586 if (root_layer_.get()) 607 if (root_layer_.get())
587 root_layer_->SetLayerTreeHost(NULL); 608 root_layer_->SetLayerTreeHost(NULL);
588 root_layer_ = root_layer; 609 root_layer_ = root_layer;
589 if (root_layer_.get()) { 610 if (root_layer_.get()) {
590 DCHECK(!root_layer_->parent()); 611 DCHECK(!root_layer_->parent());
591 root_layer_->SetLayerTreeHost(this); 612 root_layer_->SetLayerTreeHost(this);
(...skipping 777 matching lines...) Expand 10 before | Expand all | Expand 10 after
1369 void LayerTreeHost::SetChildrenNeedBeginFrames( 1390 void LayerTreeHost::SetChildrenNeedBeginFrames(
1370 bool children_need_begin_frames) const { 1391 bool children_need_begin_frames) const {
1371 proxy_->SetChildrenNeedBeginFrames(children_need_begin_frames); 1392 proxy_->SetChildrenNeedBeginFrames(children_need_begin_frames);
1372 } 1393 }
1373 1394
1374 void LayerTreeHost::SendBeginFramesToChildren( 1395 void LayerTreeHost::SendBeginFramesToChildren(
1375 const BeginFrameArgs& args) const { 1396 const BeginFrameArgs& args) const {
1376 client_->SendBeginFramesToChildren(args); 1397 client_->SendBeginFramesToChildren(args);
1377 } 1398 }
1378 1399
1400 Layer* LayerTreeHost::LayerById(int id) const {
1401 LayerIdMap::const_iterator iter = layer_id_map_.find(id);
1402 return iter != layer_id_map_.end() ? iter->second : NULL;
1403 }
1404
1405 void LayerTreeHost::RegisterLayer(Layer* layer) {
1406 DCHECK(!LayerById(layer->id()));
1407 layer_id_map_[layer->id()] = layer;
1408 }
1409
1410 void LayerTreeHost::UnregisterLayer(Layer* layer) {
1411 DCHECK(LayerById(layer->id()));
1412 layer_id_map_.erase(layer->id());
1413 }
1414
1415 AnimationRegistrar* LayerTreeHost::GetAnimationRegistrar() const {
1416 return animation_registrar_.get();
1417 }
1418
1419 void LayerTreeHost::SetMutatorsNeedCommit() {
1420 SetNeedsCommit();
1421 }
1422
1423 void LayerTreeHost::SetLayerFilterMutated(int layer_id,
1424 bool active_tree,
1425 const FilterOperations& filters) {
1426 LayerAnimationValueObserver* layer = LayerById(layer_id);
1427 if (layer)
ajuma 2015/02/23 16:36:44 In what situation would |layer| be null here? Shou
loyso (OOO) 2015/02/25 04:37:03 Active tree is a 'passive' view of pending tree. O
ajuma 2015/02/25 14:57:25 I'm not sure I follow. LayerTreeHost is the main-t
loyso (OOO) 2015/02/26 03:04:45 Oh, sorry. I was commenting with LayerTreeHostImpl
ajuma 2015/02/26 14:16:31 needs_synchronized_start_time means "use the compo
loyso (OOO) 2015/02/27 02:45:17 Thank you so much Ali for pointing out that import
1428 layer->OnFilterAnimated(filters);
1429 }
1430
1431 void LayerTreeHost::SetLayerOpacityMutated(int layer_id,
1432 bool active_tree,
1433 float opacity) {
1434 LayerAnimationValueObserver* layer = LayerById(layer_id);
1435 if (layer)
1436 layer->OnOpacityAnimated(opacity);
1437 }
1438
1439 void LayerTreeHost::SetLayerTransformMutated(int layer_id,
1440 bool active_tree,
1441 const gfx::Transform& transform) {
1442 LayerAnimationValueObserver* layer = LayerById(layer_id);
1443 if (layer)
1444 layer->OnTransformAnimated(transform);
1445 }
1446
1379 } // namespace cc 1447 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698