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

Unified 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: Plumb LayerSettings parameter for cc::Layer construction. 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 side-by-side diff with in-line comments
Download patch
Index: cc/layers/layer.cc
diff --git a/cc/layers/layer.cc b/cc/layers/layer.cc
index 56b8c739e4f24004b59bf8a138f3cd3606cb7bf9..ff2a41ac37120c6c2227af1083f9c38cb35947d1 100644
--- a/cc/layers/layer.cc
+++ b/cc/layers/layer.cc
@@ -34,11 +34,11 @@ namespace cc {
base::StaticAtomicSequenceNumber g_next_layer_id;
-scoped_refptr<Layer> Layer::Create() {
- return make_scoped_refptr(new Layer());
+scoped_refptr<Layer> Layer::Create(const LayerSettings& settings) {
+ return make_scoped_refptr(new Layer(settings));
}
-Layer::Layer()
+Layer::Layer(const LayerSettings& settings)
: needs_push_properties_(false),
num_dependents_need_push_properties_(false),
stacking_order_changed_(false),
@@ -83,9 +83,11 @@ Layer::Layer()
raster_scale_(0.f),
client_(nullptr),
frame_timing_requests_dirty_(false) {
- layer_animation_controller_ = LayerAnimationController::Create(layer_id_);
- layer_animation_controller_->AddValueObserver(this);
- layer_animation_controller_->set_value_provider(this);
+ if (!settings.use_compositor_animation_timelines) {
+ layer_animation_controller_ = LayerAnimationController::Create(layer_id_);
+ layer_animation_controller_->AddValueObserver(this);
+ layer_animation_controller_->set_value_provider(this);
+ }
}
Layer::~Layer() {
@@ -96,8 +98,10 @@ Layer::~Layer() {
// reference to us.
DCHECK(!layer_tree_host());
- layer_animation_controller_->RemoveValueObserver(this);
- layer_animation_controller_->remove_value_provider(this);
+ if (layer_animation_controller_) {
+ layer_animation_controller_->RemoveValueObserver(this);
+ layer_animation_controller_->remove_value_provider(this);
+ }
RemoveFromScrollTree();
RemoveFromClipTree();
@@ -136,9 +140,7 @@ void Layer::SetLayerTreeHost(LayerTreeHost* host) {
replica_layer_->SetLayerTreeHost(host);
if (host) {
- layer_animation_controller_->SetAnimationRegistrar(
- host->animation_registrar());
-
+ RegisterForAnimations(host->animation_registrar());
if (host->settings().layer_transforms_should_scale_layer_contents)
reset_raster_scale_to_unknown();
}
@@ -1350,6 +1352,7 @@ bool Layer::IsActive() const {
}
bool Layer::AddAnimation(scoped_ptr <Animation> animation) {
+ DCHECK(layer_animation_controller_);
if (!layer_animation_controller_->animation_registrar())
return false;
@@ -1394,13 +1397,20 @@ bool Layer::HasActiveAnimation() const {
return layer_animation_controller_->HasActiveAnimation();
}
+void Layer::RegisterForAnimations(AnimationRegistrar* registrar) {
+ if (layer_animation_controller_)
+ layer_animation_controller_->SetAnimationRegistrar(registrar);
+}
+
void Layer::AddLayerAnimationEventObserver(
LayerAnimationEventObserver* animation_observer) {
+ DCHECK(layer_animation_controller_);
layer_animation_controller_->AddEventObserver(animation_observer);
}
void Layer::RemoveLayerAnimationEventObserver(
LayerAnimationEventObserver* animation_observer) {
+ DCHECK(layer_animation_controller_);
layer_animation_controller_->RemoveEventObserver(animation_observer);
}

Powered by Google App Engine
This is Rietveld 408576698