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

Unified Diff: cc/layers/layer.cc

Issue 1010663002: CC Animations: Redirect all compositor animation requests to AnimationHost. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@introduce
Patch Set: Rebase and fix conflicts (HasPotentiallyRunningTransformAnimation) 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
« no previous file with comments | « cc/layers/layer.h ('k') | cc/layers/layer_impl.h » ('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 fc7d0da5fb76fe249c2993df59b9c75885e041d3..95e93ade3eaf5a77c405733c1947a07f694cc51c 100644
--- a/cc/layers/layer.cc
+++ b/cc/layers/layer.cc
@@ -143,7 +143,13 @@ void Layer::SetLayerTreeHost(LayerTreeHost* host) {
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();
}
@@ -507,7 +513,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) {
@@ -527,7 +537,24 @@ 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::HasPotentiallyRunningOpacityAnimation() const {
+ if (layer_animation_controller_) {
+ if (Animation* animation =
+ layer_animation_controller()->GetAnimation(Animation::OPACITY)) {
+ return !animation->is_finished();
+ }
+ return false;
+ } else {
+ DCHECK(layer_tree_host_);
+ return layer_tree_host_->HasPotentiallyRunningOpacityAnimation(this);
+ }
}
bool Layer::OpacityCanAnimateOnImplThread() const {
@@ -711,11 +738,39 @@ 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);
+}
+
+bool Layer::HasPotentiallyRunningTransformAnimation() const {
+ if (layer_animation_controller_) {
+ if (Animation* animation =
+ layer_animation_controller()->GetAnimation(Animation::TRANSFORM)) {
+ return !animation->is_finished();
+ }
+ return false;
+ } else {
+ DCHECK(layer_tree_host_);
+ return layer_tree_host_->HasPotentiallyRunningTransformAnimation(this);
+ }
+}
+
+bool Layer::ScrollOffsetAnimationWasInterrupted() const {
+ DCHECK(layer_tree_host_);
+ return layer_animation_controller_
+ ? layer_animation_controller_
+ ->scroll_offset_animation_was_interrupted()
+ : layer_tree_host_->ScrollOffsetAnimationWasInterrupted(this);
}
void Layer::SetScrollParent(Layer* parent) {
@@ -1141,7 +1196,7 @@ 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 (ScrollOffsetAnimationWasInterrupted())
layer->PushScrollOffsetFromMainThreadAndClobberActiveValue(scroll_offset_);
else
layer->PushScrollOffsetFromMainThread(scroll_offset_);
@@ -1178,8 +1233,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_);
@@ -1367,24 +1423,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);
@@ -1392,18 +1452,23 @@ 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 (!layer_animation_controller_) {
+ 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);
}
- layer_animation_controller_->SetAnimationRegistrar(registrar);
+ if (layer_animation_controller_)
+ layer_animation_controller_->SetAnimationRegistrar(registrar);
}
void Layer::AddLayerAnimationEventObserver(
« no previous file with comments | « cc/layers/layer.h ('k') | cc/layers/layer_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698