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

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: 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/layers/layer.h ('k') | cc/layers/layer_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/layers/layer.cc
diff --git a/cc/layers/layer.cc b/cc/layers/layer.cc
index 361e2966951b5e1b50758d73511766e7705b2b08..23c725b124848ed384b60dc0586618b68f2f4332 100644
--- a/cc/layers/layer.cc
+++ b/cc/layers/layer.cc
@@ -86,9 +86,11 @@ Layer::Layer(const LayerSettings& settings)
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() {
@@ -99,8 +101,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();
@@ -139,9 +143,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();
}
@@ -1451,6 +1453,7 @@ bool Layer::IsActive() const {
}
bool Layer::AddAnimation(scoped_ptr <Animation> animation) {
+ DCHECK(layer_animation_controller_);
if (!layer_animation_controller_->animation_registrar())
return false;
@@ -1467,18 +1470,21 @@ bool Layer::AddAnimation(scoped_ptr <Animation> animation) {
}
void Layer::PauseAnimation(int animation_id, double time_offset) {
+ DCHECK(layer_animation_controller_);
layer_animation_controller_->PauseAnimation(
animation_id, base::TimeDelta::FromSecondsD(time_offset));
SetNeedsCommit();
}
void Layer::RemoveAnimation(int animation_id) {
+ DCHECK(layer_animation_controller_);
layer_animation_controller_->RemoveAnimation(animation_id);
SetNeedsCommit();
}
void Layer::RemoveAnimation(int animation_id,
Animation::TargetProperty property) {
+ DCHECK(layer_animation_controller_);
layer_animation_controller_->RemoveAnimation(animation_id, property);
SetNeedsCommit();
}
@@ -1492,16 +1498,24 @@ void Layer::SetLayerAnimationControllerForTest(
}
bool Layer::HasActiveAnimation() const {
+ DCHECK(layer_animation_controller_);
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);
}
« 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