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

Side by Side Diff: cc/layers/layer.cc

Issue 1101823002: CC Animations: Make LayerAnimationController creation optional (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase on top of extracted changes. Created 5 years, 7 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
« no previous file with comments | « cc/layers/layer.h ('k') | cc/layers/layer_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2010 The Chromium Authors. All rights reserved. 1 // Copyright 2010 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/layers/layer.h" 5 #include "cc/layers/layer.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/atomic_sequence_num.h" 9 #include "base/atomic_sequence_num.h"
10 #include "base/location.h" 10 #include "base/location.h"
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 scroll_blocks_on_(SCROLL_BLOCKS_ON_NONE), 79 scroll_blocks_on_(SCROLL_BLOCKS_ON_NONE),
80 background_color_(0), 80 background_color_(0),
81 opacity_(1.f), 81 opacity_(1.f),
82 blend_mode_(SkXfermode::kSrcOver_Mode), 82 blend_mode_(SkXfermode::kSrcOver_Mode),
83 scroll_parent_(nullptr), 83 scroll_parent_(nullptr),
84 clip_parent_(nullptr), 84 clip_parent_(nullptr),
85 replica_layer_(nullptr), 85 replica_layer_(nullptr),
86 raster_scale_(0.f), 86 raster_scale_(0.f),
87 client_(nullptr), 87 client_(nullptr),
88 frame_timing_requests_dirty_(false) { 88 frame_timing_requests_dirty_(false) {
89 layer_animation_controller_ = LayerAnimationController::Create(layer_id_); 89 if (!settings.use_compositor_animation_timelines) {
90 layer_animation_controller_->AddValueObserver(this); 90 layer_animation_controller_ = LayerAnimationController::Create(layer_id_);
91 layer_animation_controller_->set_value_provider(this); 91 layer_animation_controller_->AddValueObserver(this);
92 layer_animation_controller_->set_value_provider(this);
93 }
92 } 94 }
93 95
94 Layer::~Layer() { 96 Layer::~Layer() {
95 // Our parent should be holding a reference to us so there should be no 97 // Our parent should be holding a reference to us so there should be no
96 // way for us to be destroyed while we still have a parent. 98 // way for us to be destroyed while we still have a parent.
97 DCHECK(!parent()); 99 DCHECK(!parent());
98 // Similarly we shouldn't have a layer tree host since it also keeps a 100 // Similarly we shouldn't have a layer tree host since it also keeps a
99 // reference to us. 101 // reference to us.
100 DCHECK(!layer_tree_host()); 102 DCHECK(!layer_tree_host());
101 103
102 layer_animation_controller_->RemoveValueObserver(this); 104 if (layer_animation_controller_) {
103 layer_animation_controller_->remove_value_provider(this); 105 layer_animation_controller_->RemoveValueObserver(this);
106 layer_animation_controller_->remove_value_provider(this);
107 }
104 108
105 RemoveFromScrollTree(); 109 RemoveFromScrollTree();
106 RemoveFromClipTree(); 110 RemoveFromClipTree();
107 111
108 // Remove the parent reference from all children and dependents. 112 // Remove the parent reference from all children and dependents.
109 RemoveAllChildren(); 113 RemoveAllChildren();
110 if (mask_layer_.get()) { 114 if (mask_layer_.get()) {
111 DCHECK_EQ(this, mask_layer_->parent()); 115 DCHECK_EQ(this, mask_layer_->parent());
112 mask_layer_->RemoveFromParent(); 116 mask_layer_->RemoveFromParent();
113 } 117 }
(...skipping 18 matching lines...) Expand all
132 136
133 for (size_t i = 0; i < children_.size(); ++i) 137 for (size_t i = 0; i < children_.size(); ++i)
134 children_[i]->SetLayerTreeHost(host); 138 children_[i]->SetLayerTreeHost(host);
135 139
136 if (mask_layer_.get()) 140 if (mask_layer_.get())
137 mask_layer_->SetLayerTreeHost(host); 141 mask_layer_->SetLayerTreeHost(host);
138 if (replica_layer_.get()) 142 if (replica_layer_.get())
139 replica_layer_->SetLayerTreeHost(host); 143 replica_layer_->SetLayerTreeHost(host);
140 144
141 if (host) { 145 if (host) {
142 layer_animation_controller_->SetAnimationRegistrar( 146 RegisterForAnimations(host->animation_registrar());
143 host->animation_registrar());
144
145 if (host->settings().layer_transforms_should_scale_layer_contents) 147 if (host->settings().layer_transforms_should_scale_layer_contents)
146 reset_raster_scale_to_unknown(); 148 reset_raster_scale_to_unknown();
147 } 149 }
148 150
149 if (host && layer_animation_controller_->has_any_animation()) 151 if (host && layer_animation_controller_->has_any_animation())
150 host->SetNeedsCommit(); 152 host->SetNeedsCommit();
151 } 153 }
152 154
153 void Layer::SetNeedsUpdate() { 155 void Layer::SetNeedsUpdate() {
154 if (layer_tree_host_ && !ignore_set_needs_commit_) 156 if (layer_tree_host_ && !ignore_set_needs_commit_)
(...skipping 1289 matching lines...) Expand 10 before | Expand all | Expand 10 after
1444 void Layer::OnAnimationWaitingForDeletion() { 1446 void Layer::OnAnimationWaitingForDeletion() {
1445 // Animations are only deleted during PushProperties. 1447 // Animations are only deleted during PushProperties.
1446 SetNeedsPushProperties(); 1448 SetNeedsPushProperties();
1447 } 1449 }
1448 1450
1449 bool Layer::IsActive() const { 1451 bool Layer::IsActive() const {
1450 return true; 1452 return true;
1451 } 1453 }
1452 1454
1453 bool Layer::AddAnimation(scoped_ptr <Animation> animation) { 1455 bool Layer::AddAnimation(scoped_ptr <Animation> animation) {
1456 DCHECK(layer_animation_controller_);
1454 if (!layer_animation_controller_->animation_registrar()) 1457 if (!layer_animation_controller_->animation_registrar())
1455 return false; 1458 return false;
1456 1459
1457 if (animation->target_property() == Animation::SCROLL_OFFSET && 1460 if (animation->target_property() == Animation::SCROLL_OFFSET &&
1458 !layer_animation_controller_->animation_registrar() 1461 !layer_animation_controller_->animation_registrar()
1459 ->supports_scroll_animations()) 1462 ->supports_scroll_animations())
1460 return false; 1463 return false;
1461 1464
1462 UMA_HISTOGRAM_BOOLEAN("Renderer.AnimationAddedToOrphanLayer", 1465 UMA_HISTOGRAM_BOOLEAN("Renderer.AnimationAddedToOrphanLayer",
1463 !layer_tree_host_); 1466 !layer_tree_host_);
1464 layer_animation_controller_->AddAnimation(animation.Pass()); 1467 layer_animation_controller_->AddAnimation(animation.Pass());
1465 SetNeedsCommit(); 1468 SetNeedsCommit();
1466 return true; 1469 return true;
1467 } 1470 }
1468 1471
1469 void Layer::PauseAnimation(int animation_id, double time_offset) { 1472 void Layer::PauseAnimation(int animation_id, double time_offset) {
1473 DCHECK(layer_animation_controller_);
1470 layer_animation_controller_->PauseAnimation( 1474 layer_animation_controller_->PauseAnimation(
1471 animation_id, base::TimeDelta::FromSecondsD(time_offset)); 1475 animation_id, base::TimeDelta::FromSecondsD(time_offset));
1472 SetNeedsCommit(); 1476 SetNeedsCommit();
1473 } 1477 }
1474 1478
1475 void Layer::RemoveAnimation(int animation_id) { 1479 void Layer::RemoveAnimation(int animation_id) {
1480 DCHECK(layer_animation_controller_);
1476 layer_animation_controller_->RemoveAnimation(animation_id); 1481 layer_animation_controller_->RemoveAnimation(animation_id);
1477 SetNeedsCommit(); 1482 SetNeedsCommit();
1478 } 1483 }
1479 1484
1480 void Layer::RemoveAnimation(int animation_id, 1485 void Layer::RemoveAnimation(int animation_id,
1481 Animation::TargetProperty property) { 1486 Animation::TargetProperty property) {
1487 DCHECK(layer_animation_controller_);
1482 layer_animation_controller_->RemoveAnimation(animation_id, property); 1488 layer_animation_controller_->RemoveAnimation(animation_id, property);
1483 SetNeedsCommit(); 1489 SetNeedsCommit();
1484 } 1490 }
1485 1491
1486 void Layer::SetLayerAnimationControllerForTest( 1492 void Layer::SetLayerAnimationControllerForTest(
1487 scoped_refptr<LayerAnimationController> controller) { 1493 scoped_refptr<LayerAnimationController> controller) {
1488 layer_animation_controller_->RemoveValueObserver(this); 1494 layer_animation_controller_->RemoveValueObserver(this);
1489 layer_animation_controller_ = controller; 1495 layer_animation_controller_ = controller;
1490 layer_animation_controller_->AddValueObserver(this); 1496 layer_animation_controller_->AddValueObserver(this);
1491 SetNeedsCommit(); 1497 SetNeedsCommit();
1492 } 1498 }
1493 1499
1494 bool Layer::HasActiveAnimation() const { 1500 bool Layer::HasActiveAnimation() const {
1501 DCHECK(layer_animation_controller_);
1495 return layer_animation_controller_->HasActiveAnimation(); 1502 return layer_animation_controller_->HasActiveAnimation();
1496 } 1503 }
1497 1504
1505 void Layer::RegisterForAnimations(AnimationRegistrar* registrar) {
1506 if (layer_animation_controller_)
1507 layer_animation_controller_->SetAnimationRegistrar(registrar);
1508 }
1509
1498 void Layer::AddLayerAnimationEventObserver( 1510 void Layer::AddLayerAnimationEventObserver(
1499 LayerAnimationEventObserver* animation_observer) { 1511 LayerAnimationEventObserver* animation_observer) {
1512 DCHECK(layer_animation_controller_);
1500 layer_animation_controller_->AddEventObserver(animation_observer); 1513 layer_animation_controller_->AddEventObserver(animation_observer);
1501 } 1514 }
1502 1515
1503 void Layer::RemoveLayerAnimationEventObserver( 1516 void Layer::RemoveLayerAnimationEventObserver(
1504 LayerAnimationEventObserver* animation_observer) { 1517 LayerAnimationEventObserver* animation_observer) {
1518 DCHECK(layer_animation_controller_);
1505 layer_animation_controller_->RemoveEventObserver(animation_observer); 1519 layer_animation_controller_->RemoveEventObserver(animation_observer);
1506 } 1520 }
1507 1521
1508 SimpleEnclosedRegion Layer::VisibleContentOpaqueRegion() const { 1522 SimpleEnclosedRegion Layer::VisibleContentOpaqueRegion() const {
1509 if (contents_opaque()) 1523 if (contents_opaque())
1510 return SimpleEnclosedRegion(visible_content_rect()); 1524 return SimpleEnclosedRegion(visible_content_rect());
1511 return SimpleEnclosedRegion(); 1525 return SimpleEnclosedRegion();
1512 } 1526 }
1513 1527
1514 ScrollbarLayerInterface* Layer::ToScrollbarLayer() { 1528 ScrollbarLayerInterface* Layer::ToScrollbarLayer() {
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
1569 1583
1570 void Layer::DidBeginTracing() { 1584 void Layer::DidBeginTracing() {
1571 // We'll be dumping layer trees as part of trace, so make sure 1585 // We'll be dumping layer trees as part of trace, so make sure
1572 // PushPropertiesTo() propagates layer debug info to the impl 1586 // PushPropertiesTo() propagates layer debug info to the impl
1573 // side -- otherwise this won't happen for the the layers that 1587 // side -- otherwise this won't happen for the the layers that
1574 // remain unchanged since tracing started. 1588 // remain unchanged since tracing started.
1575 SetNeedsPushProperties(); 1589 SetNeedsPushProperties();
1576 } 1590 }
1577 1591
1578 } // namespace cc 1592 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/layer.h ('k') | cc/layers/layer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698