Index: cc/layers/layer.cc |
diff --git a/cc/layers/layer.cc b/cc/layers/layer.cc |
index b7d6e316e600bc826de0586702e4d1d9f5be8468..92672ddf07d6a66d72e1c1bb38745dd66f56d1b5 100644 |
--- a/cc/layers/layer.cc |
+++ b/cc/layers/layer.cc |
@@ -83,6 +83,7 @@ Layer::Layer() |
raster_scale_(0.f), |
client_(nullptr), |
frame_timing_requests_dirty_(false) { |
+ // TODO(loyso): Do not create LayerAnimationController once systems migrated. |
layer_animation_controller_ = LayerAnimationController::Create(layer_id_); |
layer_animation_controller_->AddValueObserver(this); |
layer_animation_controller_->set_value_provider(this); |
@@ -96,8 +97,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(); |
@@ -137,14 +140,18 @@ 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(); |
} |
- if (host && layer_animation_controller_->has_any_animation()) |
+ bool has_any_animation = false; |
+ if (layer_animation_controller_) |
+ has_any_animation = layer_animation_controller_->has_any_animation(); |
+ else if (layer_tree_host_) |
+ has_any_animation = layer_tree_host_->HasAnyAnimation(this); |
+ |
+ if (host && has_any_animation) |
host->SetNeedsCommit(); |
} |
@@ -484,7 +491,11 @@ void Layer::SetFilters(const FilterOperations& filters) { |
} |
bool Layer::FilterIsAnimating() const { |
- return layer_animation_controller_->IsAnimatingProperty(Animation::FILTER); |
+ DCHECK(layer_tree_host_); |
+ return layer_animation_controller_ |
+ ? layer_animation_controller_->IsAnimatingProperty( |
+ Animation::FILTER) |
+ : layer_tree_host_->IsAnimatingFilterProperty(this); |
} |
void Layer::SetBackgroundFilters(const FilterOperations& filters) { |
@@ -504,7 +515,11 @@ void Layer::SetOpacity(float opacity) { |
} |
bool Layer::OpacityIsAnimating() const { |
- return layer_animation_controller_->IsAnimatingProperty(Animation::OPACITY); |
+ DCHECK(layer_tree_host_); |
+ return layer_animation_controller_ |
+ ? layer_animation_controller_->IsAnimatingProperty( |
+ Animation::OPACITY) |
+ : layer_tree_host_->IsAnimatingOpacityProperty(this); |
} |
bool Layer::OpacityCanAnimateOnImplThread() const { |
@@ -610,11 +625,18 @@ void Layer::SetTransformOrigin(const gfx::Point3F& transform_origin) { |
} |
bool Layer::AnimationsPreserveAxisAlignment() const { |
- return layer_animation_controller_->AnimationsPreserveAxisAlignment(); |
+ DCHECK(layer_tree_host_); |
+ return layer_animation_controller_ |
+ ? layer_animation_controller_->AnimationsPreserveAxisAlignment() |
+ : layer_tree_host_->AnimationsPreserveAxisAlignment(this); |
} |
bool Layer::TransformIsAnimating() const { |
- return layer_animation_controller_->IsAnimatingProperty(Animation::TRANSFORM); |
+ DCHECK(layer_tree_host_); |
+ return layer_animation_controller_ |
+ ? layer_animation_controller_->IsAnimatingProperty( |
+ Animation::TRANSFORM) |
+ : layer_tree_host_->IsAnimatingTransformProperty(this); |
} |
void Layer::SetScrollParent(Layer* parent) { |
@@ -1000,7 +1022,8 @@ void Layer::PushPropertiesTo(LayerImpl* layer) { |
// the pending tree will clobber any impl-side scrolling occuring on the |
// active tree. To do so, avoid scrolling the pending tree along with it |
// instead of trying to undo that scrolling later. |
- if (layer_animation_controller_->scroll_offset_animation_was_interrupted()) |
+ if (layer_animation_controller_ && |
+ layer_animation_controller_->scroll_offset_animation_was_interrupted()) |
ajuma
2015/04/21 17:57:57
This will need an equivalent in the new system.
loyso (OOO)
2015/04/22 01:08:11
Acknowledged.
loyso (OOO)
2015/04/30 07:06:01
Done.
|
layer->PushScrollOffsetFromMainThreadAndClobberActiveValue(scroll_offset_); |
else |
layer->PushScrollOffsetFromMainThread(scroll_offset_); |
@@ -1035,8 +1058,9 @@ void Layer::PushPropertiesTo(LayerImpl* layer) { |
layer->SetStackingOrderChanged(stacking_order_changed_); |
- layer_animation_controller_->PushAnimationUpdatesTo( |
- layer->layer_animation_controller()); |
+ if (layer->layer_animation_controller() && layer_animation_controller_) |
+ layer_animation_controller_->PushAnimationUpdatesTo( |
+ layer->layer_animation_controller()); |
if (frame_timing_requests_dirty_) { |
layer->PassFrameTimingRequests(&frame_timing_requests_); |
@@ -1186,7 +1210,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 && |
@@ -1202,24 +1227,28 @@ 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(); |
} |
void Layer::SetLayerAnimationControllerForTest( |
scoped_refptr<LayerAnimationController> controller) { |
+ DCHECK(layer_animation_controller_); |
layer_animation_controller_->RemoveValueObserver(this); |
layer_animation_controller_ = controller; |
layer_animation_controller_->AddValueObserver(this); |
@@ -1227,16 +1256,34 @@ void Layer::SetLayerAnimationControllerForTest( |
} |
bool Layer::HasActiveAnimation() const { |
- return layer_animation_controller_->HasActiveAnimation(); |
+ DCHECK(layer_tree_host_); |
+ return layer_animation_controller_ |
+ ? layer_animation_controller_->HasActiveAnimation() |
+ : layer_tree_host_->HasActiveAnimation(this); |
+} |
+ |
+void Layer::RegisterForAnimations(AnimationRegistrar* registrar, |
+ const LayerTreeSettings& settings) { |
+ if (!settings.use_compositor_animation_timelines && |
+ !layer_animation_controller_) { |
+ layer_animation_controller_ = LayerAnimationController::Create(layer_id_); |
+ layer_animation_controller_->AddValueObserver(this); |
+ layer_animation_controller_->set_value_provider(this); |
+ } |
+ |
+ if (layer_animation_controller_) |
ajuma
2015/04/21 17:57:57
This will always be true if we're constructing a c
loyso (OOO)
2015/04/22 01:08:11
Yes, that's correct statement. The problem is that
ajuma
2015/04/22 14:36:37
I think I'd prefer that the creation of LACs be mo
loyso (OOO)
2015/04/23 07:58:20
That's not that simple with ui::Layers. See the hi
|
+ 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); |
} |