diff options
author | ajuma <ajuma@chromium.org> | 2015-07-24 14:16:34 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-07-24 21:17:19 +0000 |
commit | 315a4784b0d26b99a053abd1b267fa49bc7116f9 (patch) | |
tree | 645875bc5262ab977bcb981f969bc3ba8c3159aa /cc/layers/layer_impl.cc | |
parent | a79c9467590b3aea6fa41d85f492c7883861537c (diff) | |
download | chromium_src-315a4784b0d26b99a053abd1b267fa49bc7116f9.zip chromium_src-315a4784b0d26b99a053abd1b267fa49bc7116f9.tar.gz chromium_src-315a4784b0d26b99a053abd1b267fa49bc7116f9.tar.bz2 |
cc: Clean up <Property>IsAnimating and related logic
Layers currently have two notions of having an animated property, such
as an animated transform. HasPotentiallyRunningTransformAnimation means
there's a transform animation that hasn't finished. TransformIsAnimating
is a stronger condition: it means there's a transform animation that
hasn't finished, and is currently "in effect". For animations without
start delays, these notions are equivalent, since unfinished animations
without a start delay are always "in effect". However, an animation
with a start delay can be unfinished without yet being "in effect"; this
is the case during the start delay, for animations that don't have a
"backwards" fill-mode. Animations that aren't yet in effect don't get
ticked.
CDP and property trees use <Property>IsAnimating when deciding whether a
property's value might change on the compositor thread. For example,
when a layer has opacity 0, its subtree is skipped unless
OpacityIsAnimating, and similar logic exists for uninvertible transforms
and TransformIsAnimating. However, this doesn't correctly account for
animations with start delays -- once the delay has finished, such
animations will cause changes on the compositor thread. This CL replaces
usage of <Property>IsAnimating with
HasPotentiallyRunning<Property>Animation wherever we're really trying to
check "will this value change on the compositor thread". In particular,
this includes the computation of screen_space_transform_is_animating.
A second problem with <Property>IsAnimating and
HasPotentiallyRunning<Property>Animation is that on the compositor
thread, they don't distinguish between animations that affect the
pending tree and those that affect the active tree. This means, for
example, that right after a commit that adds a transform animation to
a layer, the corresponding active layer's
screen_space_transform_is_animating value is true, even before
activation, and even though there isn't yet any animation that affects
it. This is unintuitive, and also awkward behavior to match when using
property trees, since property trees propagate through commit and
activation. This CL makes <Property>IsAnimating and
HasPotentiallyRunning<Property>Animation take into account whether
particular animations affect the active tree, the pending tree, or
both.
BUG=509673
CQ_INCLUDE_TRYBOTS=tryserver.blink:linux_blink_rel
Review URL: https://codereview.chromium.org/1239983006
Cr-Commit-Position: refs/heads/master@{#340338}
Diffstat (limited to 'cc/layers/layer_impl.cc')
-rw-r--r-- | cc/layers/layer_impl.cc | 63 |
1 files changed, 39 insertions, 24 deletions
diff --git a/cc/layers/layer_impl.cc b/cc/layers/layer_impl.cc index da8015c..5c20611 100644 --- a/cc/layers/layer_impl.cc +++ b/cc/layers/layer_impl.cc @@ -1030,12 +1030,25 @@ void LayerImpl::SetFilters(const FilterOperations& filters) { } bool LayerImpl::FilterIsAnimating() const { + LayerAnimationController::ObserverType observer_type = + IsActive() ? LayerAnimationController::ObserverType::ACTIVE + : LayerAnimationController::ObserverType::PENDING; return layer_animation_controller_ - ? layer_animation_controller_->IsAnimatingProperty( - Animation::FILTER) + ? layer_animation_controller_->IsCurrentlyAnimatingProperty( + Animation::FILTER, observer_type) : layer_tree_impl_->IsAnimatingFilterProperty(this); } +bool LayerImpl::HasPotentiallyRunningFilterAnimation() const { + LayerAnimationController::ObserverType observer_type = + IsActive() ? LayerAnimationController::ObserverType::ACTIVE + : LayerAnimationController::ObserverType::PENDING; + return layer_animation_controller_ + ? layer_animation_controller_->IsPotentiallyAnimatingProperty( + Animation::FILTER, observer_type) + : layer_tree_impl_->HasPotentiallyRunningFilterAnimation(this); +} + bool LayerImpl::FilterIsAnimatingOnImplOnly() const { if (!layer_animation_controller_) return layer_tree_impl_->FilterIsAnimatingOnImplOnly(this); @@ -1079,22 +1092,23 @@ void LayerImpl::SetOpacity(float opacity) { } bool LayerImpl::OpacityIsAnimating() const { + LayerAnimationController::ObserverType observer_type = + IsActive() ? LayerAnimationController::ObserverType::ACTIVE + : LayerAnimationController::ObserverType::PENDING; return layer_animation_controller_ - ? layer_animation_controller_->IsAnimatingProperty( - Animation::OPACITY) + ? layer_animation_controller_->IsCurrentlyAnimatingProperty( + Animation::OPACITY, observer_type) : layer_tree_impl_->IsAnimatingOpacityProperty(this); } bool LayerImpl::HasPotentiallyRunningOpacityAnimation() const { - if (layer_animation_controller_) { - if (Animation* animation = - layer_animation_controller()->GetAnimation(Animation::OPACITY)) { - return !animation->is_finished(); - } - return false; - } else { - return layer_tree_impl_->HasPotentiallyRunningOpacityAnimation(this); - } + LayerAnimationController::ObserverType observer_type = + IsActive() ? LayerAnimationController::ObserverType::ACTIVE + : LayerAnimationController::ObserverType::PENDING; + return layer_animation_controller_ + ? layer_animation_controller_->IsPotentiallyAnimatingProperty( + Animation::OPACITY, observer_type) + : layer_tree_impl_->HasPotentiallyRunningOpacityAnimation(this); } bool LayerImpl::OpacityIsAnimatingOnImplOnly() const { @@ -1179,22 +1193,23 @@ void LayerImpl::SetTransformAndInvertibility(const gfx::Transform& transform, } bool LayerImpl::TransformIsAnimating() const { + LayerAnimationController::ObserverType observer_type = + IsActive() ? LayerAnimationController::ObserverType::ACTIVE + : LayerAnimationController::ObserverType::PENDING; return layer_animation_controller_ - ? layer_animation_controller_->IsAnimatingProperty( - Animation::TRANSFORM) + ? layer_animation_controller_->IsCurrentlyAnimatingProperty( + Animation::TRANSFORM, observer_type) : layer_tree_impl_->IsAnimatingTransformProperty(this); } bool LayerImpl::HasPotentiallyRunningTransformAnimation() const { - if (layer_animation_controller_) { - if (Animation* animation = - layer_animation_controller()->GetAnimation(Animation::TRANSFORM)) { - return !animation->is_finished(); - } - return false; - } else { - return layer_tree_impl_->HasPotentiallyRunningTransformAnimation(this); - } + LayerAnimationController::ObserverType observer_type = + IsActive() ? LayerAnimationController::ObserverType::ACTIVE + : LayerAnimationController::ObserverType::PENDING; + return layer_animation_controller_ + ? layer_animation_controller_->IsPotentiallyAnimatingProperty( + Animation::TRANSFORM, observer_type) + : layer_tree_impl_->HasPotentiallyRunningTransformAnimation(this); } bool LayerImpl::TransformIsAnimatingOnImplOnly() const { |