diff options
author | loyso <loyso@chromium.org> | 2015-05-27 21:10:18 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-05-28 04:10:44 +0000 |
commit | 5719778b3aa0a3acbc8202f8c689b6a25d0372c0 (patch) | |
tree | 3d65068ebad1f5b371ef9e817b17a79f8981c4ca /cc | |
parent | 37e26d0ef803a93a1c7578cc308ae6492fe50d3b (diff) | |
download | chromium_src-5719778b3aa0a3acbc8202f8c689b6a25d0372c0.zip chromium_src-5719778b3aa0a3acbc8202f8c689b6a25d0372c0.tar.gz chromium_src-5719778b3aa0a3acbc8202f8c689b6a25d0372c0.tar.bz2 |
CC Animations: Make LayerAnimationController creation optional
Don't call SetAnimationRegistrar directly - make RegisterForAnimations explicit.
Previous episodes:
https://codereview.chromium.org/1122393003/
https://codereview.chromium.org/1159633002/
This is a prerequisite to implement compositor animation timelines. Next episode:
https://codereview.chromium.org/947033002/
BUG=394777
R=ajuma@chromium.org
R=vollick@chromium.org
CQ_INCLUDE_TRYBOTS=tryserver.blink:linux_blink_rel
Review URL: https://codereview.chromium.org/1101823002
Cr-Commit-Position: refs/heads/master@{#331739}
Diffstat (limited to 'cc')
-rw-r--r-- | cc/blink/web_layer_impl.cc | 3 | ||||
-rw-r--r-- | cc/layers/layer.cc | 30 | ||||
-rw-r--r-- | cc/layers/layer.h | 3 | ||||
-rw-r--r-- | cc/layers/layer_unittest.cc | 2 |
4 files changed, 28 insertions, 10 deletions
diff --git a/cc/blink/web_layer_impl.cc b/cc/blink/web_layer_impl.cc index bfe4616..f0fd873 100644 --- a/cc/blink/web_layer_impl.cc +++ b/cc/blink/web_layer_impl.cc @@ -65,7 +65,8 @@ WebLayerImpl::WebLayerImpl(scoped_refptr<Layer> layer) : layer_(layer) { WebLayerImpl::~WebLayerImpl() { layer_->ClearRenderSurface(); - layer_->set_layer_animation_delegate(nullptr); + if (animation_delegate_adapter_.get()) + layer_->set_layer_animation_delegate(nullptr); web_layer_client_ = nullptr; } diff --git a/cc/layers/layer.cc b/cc/layers/layer.cc index c449c89..d795670 100644 --- a/cc/layers/layer.cc +++ b/cc/layers/layer.cc @@ -90,9 +90,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() { @@ -103,8 +105,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(); @@ -143,9 +147,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(); } @@ -1477,6 +1479,7 @@ bool Layer::IsActive() const { } bool Layer::AddAnimation(scoped_ptr <Animation> animation) { + DCHECK(layer_animation_controller_); if (!layer_animation_controller_->animation_registrar()) return false; @@ -1493,18 +1496,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(); } @@ -1518,16 +1524,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); } diff --git a/cc/layers/layer.h b/cc/layers/layer.h index 6a44ae9..89cdc6d 100644 --- a/cc/layers/layer.h +++ b/cc/layers/layer.h @@ -62,6 +62,7 @@ class LayerSettings; class LayerTreeHost; class LayerTreeHostCommon; class LayerTreeImpl; +class LayerTreeSettings; class PriorityCalculator; class RenderingStatsInstrumentation; class ResourceUpdateQueue; @@ -425,10 +426,12 @@ class CC_EXPORT Layer : public base::RefCounted<Layer>, scoped_refptr<LayerAnimationController> controller); void set_layer_animation_delegate(AnimationDelegate* delegate) { + DCHECK(layer_animation_controller_); layer_animation_controller_->set_layer_animation_delegate(delegate); } bool HasActiveAnimation() const; + void RegisterForAnimations(AnimationRegistrar* registrar); void AddLayerAnimationEventObserver( LayerAnimationEventObserver* animation_observer); diff --git a/cc/layers/layer_unittest.cc b/cc/layers/layer_unittest.cc index 16893a1..61d9333 100644 --- a/cc/layers/layer_unittest.cc +++ b/cc/layers/layer_unittest.cc @@ -1173,7 +1173,7 @@ TEST_F(LayerLayerTreeHostTest, ShouldNotAddAnimationWithoutAnimationRegistrar) { EXPECT_FALSE(AddTestAnimation(layer.get())); scoped_ptr<AnimationRegistrar> registrar = AnimationRegistrar::Create(); - layer->layer_animation_controller()->SetAnimationRegistrar(registrar.get()); + layer->RegisterForAnimations(registrar.get()); // Case 2: with an AnimationRegistrar, the animation should be accepted. EXPECT_TRUE(AddTestAnimation(layer.get())); |