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

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: Use per-process global variable to create LAC 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..c605e0dc9e1ec5da2c69f9ede347e6f103df8066 100644
--- a/cc/layers/layer.cc
+++ b/cc/layers/layer.cc
@@ -34,6 +34,8 @@ namespace cc {
base::StaticAtomicSequenceNumber g_next_layer_id;
+bool g_compositor_animation_timelines_enabled = false;
+
scoped_refptr<Layer> Layer::Create() {
return make_scoped_refptr(new Layer());
}
@@ -83,9 +85,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 (!g_compositor_animation_timelines_enabled) {
+ layer_animation_controller_ = LayerAnimationController::Create(layer_id_);
+ layer_animation_controller_->AddValueObserver(this);
+ layer_animation_controller_->set_value_provider(this);
+ }
}
Layer::~Layer() {
@@ -96,8 +100,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 +142,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());
danakj 2015/05/08 18:21:40 if (layer_animation_controller_)?
loyso (OOO) 2015/05/11 06:59:42 Done in RegisterForAnimations.
if (host->settings().layer_transforms_should_scale_layer_contents)
reset_raster_scale_to_unknown();
}
@@ -1349,7 +1353,13 @@ bool Layer::IsActive() const {
return true;
}
+// static
+void Layer::SetCompositorAnimationTimelinesEnabled(bool enabled) {
+ g_compositor_animation_timelines_enabled = enabled;
+}
+
bool Layer::AddAnimation(scoped_ptr <Animation> animation) {
+ DCHECK(layer_animation_controller_);
if (!layer_animation_controller_->animation_registrar())
return false;
@@ -1394,13 +1404,20 @@ bool Layer::HasActiveAnimation() const {
return layer_animation_controller_->HasActiveAnimation();
}
+void Layer::RegisterForAnimations(AnimationRegistrar* registrar,
+ const LayerTreeSettings& settings) {
danakj 2015/05/08 18:21:40 why are settings coming here but not being used?
loyso (OOO) 2015/05/11 06:59:43 Sorry, the CL was in inconsistent state (while pro
+ 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);
}
« cc/layers/layer.h ('K') | « 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