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

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: Clean up. Rebase. Created 5 years, 8 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..4d03f565efefc9ba936722715815d3f6f67e4bbd 100644
--- a/cc/layers/layer.cc
+++ b/cc/layers/layer.cc
@@ -83,9 +83,6 @@ 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);
}
Layer::~Layer() {
@@ -96,8 +93,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 +135,7 @@ void Layer::SetLayerTreeHost(LayerTreeHost* host) {
replica_layer_->SetLayerTreeHost(host);
if (host) {
- layer_animation_controller_->SetAnimationRegistrar(
- host->animation_registrar());
-
+ RegisterForAnimations(host->animation_registrar(), host->settings());
if (host->settings().layer_transforms_should_scale_layer_contents)
reset_raster_scale_to_unknown();
}
@@ -1350,7 +1347,8 @@ bool Layer::IsActive() const {
}
bool Layer::AddAnimation(scoped_ptr <Animation> animation) {
- if (!layer_animation_controller_->animation_registrar())
+ if (!layer_animation_controller_ ||
+ !layer_animation_controller_->animation_registrar())
return false;
if (animation->target_property() == Animation::SCROLL_OFFSET &&
@@ -1394,13 +1392,26 @@ bool Layer::HasActiveAnimation() const {
return layer_animation_controller_->HasActiveAnimation();
}
+void Layer::RegisterForAnimations(AnimationRegistrar* registrar,
+ const LayerTreeSettings& settings) {
+ if (!layer_animation_controller_) {
+ layer_animation_controller_ = LayerAnimationController::Create(layer_id_);
+ layer_animation_controller_->AddValueObserver(this);
+ layer_animation_controller_->set_value_provider(this);
+ }
+
+ 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);
}
« no previous file with comments | « cc/layers/layer.h ('k') | cc/layers/layer_unittest.cc » ('j') | ui/compositor/layer.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698