diff options
author | loyso <loyso@chromium.org> | 2016-03-10 23:54:58 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-03-11 07:56:32 +0000 |
commit | 9556c73c3d89db2226920a295e3a579dc6a1eaa3 (patch) | |
tree | 305701d312ce0b6c6d7c237bdfaedefed4163401 /cc/layers | |
parent | ecae0ae5f672a04579ab563462531889f6c0fab9 (diff) | |
download | chromium_src-9556c73c3d89db2226920a295e3a579dc6a1eaa3.zip chromium_src-9556c73c3d89db2226920a295e3a579dc6a1eaa3.tar.gz chromium_src-9556c73c3d89db2226920a295e3a579dc6a1eaa3.tar.bz2 |
CC Animation: Erase old animation system.
Basically, specialize all the code as if:
- use_compositor_animation_timelines is always true.
- Layer::layer_animation_controller_ is always nullptr.
- LayerImpl::layer_animation_controller_ is always nullptr.
- LayerTreeHost::animation_registrar_ is always nullptr.
- LayerTreeHostImpl::animation_registrar_ is always nullptr.
Next CL: Erase cc::LayerSettings everywhere.
BUG=575041
CQ_INCLUDE_TRYBOTS=tryserver.blink:linux_blink_rel
Review URL: https://codereview.chromium.org/1782433002
Cr-Commit-Position: refs/heads/master@{#380576}
Diffstat (limited to 'cc/layers')
-rw-r--r-- | cc/layers/layer.cc | 155 | ||||
-rw-r--r-- | cc/layers/layer.h | 56 | ||||
-rw-r--r-- | cc/layers/layer_impl.cc | 170 | ||||
-rw-r--r-- | cc/layers/layer_impl.h | 56 | ||||
-rw-r--r-- | cc/layers/layer_unittest.cc | 43 | ||||
-rw-r--r-- | cc/layers/layer_utils_unittest.cc | 129 |
6 files changed, 84 insertions, 525 deletions
diff --git a/cc/layers/layer.cc b/cc/layers/layer.cc index 7f51dc0..854effe 100644 --- a/cc/layers/layer.cc +++ b/cc/layers/layer.cc @@ -15,10 +15,6 @@ #include "base/single_thread_task_runner.h" #include "base/time/time.h" #include "base/trace_event/trace_event.h" -#include "cc/animation/animation.h" -#include "cc/animation/animation_registrar.h" -#include "cc/animation/keyframed_animation_curve.h" -#include "cc/animation/layer_animation_controller.h" #include "cc/animation/mutable_properties.h" #include "cc/base/simple_enclosed_region.h" #include "cc/debug/frame_viewer_instrumentation.h" @@ -102,11 +98,6 @@ Layer::Layer(const LayerSettings& settings) client_(nullptr), num_unclipped_descendants_(0), frame_timing_requests_dirty_(false) { - 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() { @@ -117,11 +108,6 @@ Layer::~Layer() { // reference to us. DCHECK(!layer_tree_host()); - if (layer_animation_controller_) { - layer_animation_controller_->RemoveValueObserver(this); - layer_animation_controller_->remove_value_provider(this); - } - RemoveFromScrollTree(); RemoveFromClipTree(); @@ -166,14 +152,8 @@ void Layer::SetLayerTreeHost(LayerTreeHost* host) { if (replica_layer_.get()) replica_layer_->SetLayerTreeHost(host); - if (host) - RegisterForAnimations(host->animation_registrar()); - - 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); + const bool has_any_animation = + layer_tree_host_ ? layer_tree_host_->HasAnyAnimation(this) : false; if (host && has_any_animation) host->SetNeedsCommit(); @@ -505,18 +485,10 @@ void Layer::SetFilters(const FilterOperations& filters) { bool Layer::FilterIsAnimating() const { DCHECK(layer_tree_host_); - return layer_animation_controller_ - ? layer_animation_controller_->IsCurrentlyAnimatingProperty( - TargetProperty::FILTER, - LayerAnimationController::ObserverType::ACTIVE) - : layer_tree_host_->IsAnimatingFilterProperty(this); + return layer_tree_host_->IsAnimatingFilterProperty(this); } bool Layer::HasPotentiallyRunningFilterAnimation() const { - if (layer_animation_controller_) { - return layer_animation_controller_->IsPotentiallyAnimatingProperty( - TargetProperty::FILTER, LayerAnimationController::ObserverType::ACTIVE); - } return layer_tree_host_->HasPotentiallyRunningFilterAnimation(this); } @@ -543,19 +515,10 @@ float Layer::EffectiveOpacity() const { bool Layer::OpacityIsAnimating() const { DCHECK(layer_tree_host_); - return layer_animation_controller_ - ? layer_animation_controller_->IsCurrentlyAnimatingProperty( - TargetProperty::OPACITY, - LayerAnimationController::ObserverType::ACTIVE) - : layer_tree_host_->IsAnimatingOpacityProperty(this); + return layer_tree_host_->IsAnimatingOpacityProperty(this); } bool Layer::HasPotentiallyRunningOpacityAnimation() const { - if (layer_animation_controller_) { - return layer_animation_controller_->IsPotentiallyAnimatingProperty( - TargetProperty::OPACITY, - LayerAnimationController::ObserverType::ACTIVE); - } return layer_tree_host_->HasPotentiallyRunningOpacityAnimation(this); } @@ -749,67 +712,38 @@ void Layer::SetTransformOrigin(const gfx::Point3F& transform_origin) { bool Layer::AnimationsPreserveAxisAlignment() const { DCHECK(layer_tree_host_); - return layer_animation_controller_ - ? layer_animation_controller_->AnimationsPreserveAxisAlignment() - : layer_tree_host_->AnimationsPreserveAxisAlignment(this); + return layer_tree_host_->AnimationsPreserveAxisAlignment(this); } bool Layer::TransformIsAnimating() const { DCHECK(layer_tree_host_); - return layer_animation_controller_ - ? layer_animation_controller_->IsCurrentlyAnimatingProperty( - TargetProperty::TRANSFORM, - LayerAnimationController::ObserverType::ACTIVE) - : layer_tree_host_->IsAnimatingTransformProperty(this); + return layer_tree_host_->IsAnimatingTransformProperty(this); } bool Layer::HasPotentiallyRunningTransformAnimation() const { - if (layer_animation_controller_) { - return layer_animation_controller_->IsPotentiallyAnimatingProperty( - TargetProperty::TRANSFORM, - LayerAnimationController::ObserverType::ACTIVE); - } return layer_tree_host_->HasPotentiallyRunningTransformAnimation(this); } bool Layer::HasOnlyTranslationTransforms() const { - if (layer_animation_controller_) { - return layer_animation_controller_->HasOnlyTranslationTransforms( - LayerAnimationController::ObserverType::ACTIVE); - } return layer_tree_host_->HasOnlyTranslationTransforms(this); } bool Layer::MaximumTargetScale(float* max_scale) const { - if (layer_animation_controller_) { - return layer_animation_controller_->MaximumTargetScale( - LayerAnimationController::ObserverType::ACTIVE, max_scale); - } return layer_tree_host_->MaximumTargetScale(this, max_scale); } bool Layer::AnimationStartScale(float* start_scale) const { - if (layer_animation_controller_) { - return layer_animation_controller_->AnimationStartScale( - LayerAnimationController::ObserverType::ACTIVE, start_scale); - } return layer_tree_host_->AnimationStartScale(this, start_scale); } bool Layer::HasAnyAnimationTargetingProperty( TargetProperty::Type property) const { - if (layer_animation_controller_) - return !!layer_animation_controller_->GetAnimation(property); - return layer_tree_host_->HasAnyAnimationTargetingProperty(this, property); } 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); + return layer_tree_host_->ScrollOffsetAnimationWasInterrupted(this); } void Layer::SetScrollParent(Layer* parent) { @@ -1383,10 +1317,6 @@ void Layer::PushPropertiesTo(LayerImpl* layer) { update_rect_.Union(layer->update_rect()); layer->SetUpdateRect(update_rect_); - if (layer->layer_animation_controller() && layer_animation_controller_) - layer_animation_controller_->PushAnimationUpdatesTo( - layer->layer_animation_controller()); - if (frame_timing_requests_dirty_) { layer->SetFrameTimingRequests(frame_timing_requests_); frame_timing_requests_dirty_ = false; @@ -1845,11 +1775,6 @@ void Layer::OnScrollOffsetAnimated(const gfx::ScrollOffset& scroll_offset) { // compositor-driven scrolling. } -void Layer::OnAnimationWaitingForDeletion() { - // Animations are only deleted during PushProperties. - SetNeedsPushProperties(); -} - void Layer::OnTransformIsPotentiallyAnimatingChanged(bool is_animating) { if (!layer_tree_host_) return; @@ -1888,73 +1813,9 @@ bool Layer::IsActive() const { return true; } -bool Layer::AddAnimation(scoped_ptr <Animation> animation) { - DCHECK(layer_animation_controller_); - if (!layer_animation_controller_->animation_registrar()) - return false; - - if (animation->target_property() == TargetProperty::SCROLL_OFFSET && - !layer_animation_controller_->animation_registrar() - ->supports_scroll_animations()) - return false; - - UMA_HISTOGRAM_BOOLEAN("Renderer.AnimationAddedToOrphanLayer", - !layer_tree_host_); - layer_animation_controller_->AddAnimation(std::move(animation)); - SetNeedsCommit(); - return true; -} - -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::AbortAnimation(int animation_id) { - DCHECK(layer_animation_controller_); - layer_animation_controller_->AbortAnimation(animation_id); - 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); - SetNeedsCommit(); -} - bool Layer::HasActiveAnimation() const { DCHECK(layer_tree_host_); - return layer_animation_controller_ - ? layer_animation_controller_->HasActiveAnimation() - : layer_tree_host_->HasActiveAnimation(this); -} - -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); + return layer_tree_host_->HasActiveAnimation(this); } ScrollbarLayerInterface* Layer::ToScrollbarLayer() { diff --git a/cc/layers/layer.h b/cc/layers/layer.h index edd0eaaae9..c14f14d 100644 --- a/cc/layers/layer.h +++ b/cc/layers/layer.h @@ -17,9 +17,7 @@ #include "base/macros.h" #include "base/memory/ref_counted.h" #include "base/observer_list.h" -#include "cc/animation/layer_animation_controller.h" -#include "cc/animation/layer_animation_value_observer.h" -#include "cc/animation/layer_animation_value_provider.h" +#include "cc/animation/target_property.h" #include "cc/base/cc_export.h" #include "cc/base/region.h" #include "cc/debug/frame_timing_request.h" @@ -53,9 +51,6 @@ class ConvertableToTraceFormat; namespace cc { -class Animation; -class AnimationDelegate; -struct AnimationEvent; class CopyOutputRequest; class LayerAnimationEventObserver; class LayerClient; @@ -69,7 +64,6 @@ class RenderingStatsInstrumentation; class ResourceUpdateQueue; class ScrollbarLayerInterface; class SimpleEnclosedRegion; -struct AnimationEvent; namespace proto { class LayerNode; @@ -79,9 +73,7 @@ class LayerUpdate; // Base class for composited layers. Special layer types are derived from // this class. -class CC_EXPORT Layer : public base::RefCounted<Layer>, - public LayerAnimationValueObserver, - public LayerAnimationValueProvider { +class CC_EXPORT Layer : public base::RefCounted<Layer> { public: using LayerListType = LayerList; using LayerIdMap = std::unordered_map<int, scoped_refptr<Layer>>; @@ -414,28 +406,7 @@ class CC_EXPORT Layer : public base::RefCounted<Layer>, LayerTreeHost* layer_tree_host() { return layer_tree_host_; } const LayerTreeHost* layer_tree_host() const { return layer_tree_host_; } - bool AddAnimation(scoped_ptr<Animation> animation); - void PauseAnimation(int animation_id, double time_offset); - void RemoveAnimation(int animation_id); - void AbortAnimation(int animation_id); - LayerAnimationController* layer_animation_controller() const { - return layer_animation_controller_.get(); - } - void SetLayerAnimationControllerForTest( - 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); - void RemoveLayerAnimationEventObserver( - LayerAnimationEventObserver* animation_observer); virtual ScrollbarLayerInterface* ToScrollbarLayer(); @@ -550,22 +521,19 @@ class CC_EXPORT Layer : public base::RefCounted<Layer>, void set_sorted_for_recursion(bool sorted_for_recursion); bool sorted_for_recursion(); - // LayerAnimationValueProvider implementation. - gfx::ScrollOffset ScrollOffsetForAnimation() const override; - - // LayerAnimationValueObserver implementation. - void OnFilterAnimated(const FilterOperations& filters) override; - void OnOpacityAnimated(float opacity) override; - void OnTransformAnimated(const gfx::Transform& transform) override; - void OnScrollOffsetAnimated(const gfx::ScrollOffset& scroll_offset) override; - void OnAnimationWaitingForDeletion() override; - void OnTransformIsPotentiallyAnimatingChanged(bool is_animating) override; - bool IsActive() const override; + // Interactions with attached animations. + gfx::ScrollOffset ScrollOffsetForAnimation() const; + void OnFilterAnimated(const FilterOperations& filters); + void OnOpacityAnimated(float opacity); + void OnTransformAnimated(const gfx::Transform& transform); + void OnScrollOffsetAnimated(const gfx::ScrollOffset& scroll_offset); + void OnTransformIsPotentiallyAnimatingChanged(bool is_animating); + bool IsActive() const; protected: friend class LayerImpl; friend class TreeSynchronizer; - ~Layer() override; + virtual ~Layer(); explicit Layer(const LayerSettings& settings); @@ -685,8 +653,6 @@ class CC_EXPORT Layer : public base::RefCounted<Layer>, // updated via SetLayerTreeHost() if a layer moves between trees. LayerTreeHost* layer_tree_host_; - scoped_refptr<LayerAnimationController> layer_animation_controller_; - // Layer properties. gfx::Size bounds_; diff --git a/cc/layers/layer_impl.cc b/cc/layers/layer_impl.cc index b10ab7e..08167ef 100644 --- a/cc/layers/layer_impl.cc +++ b/cc/layers/layer_impl.cc @@ -15,7 +15,6 @@ #include "base/trace_event/trace_event.h" #include "base/trace_event/trace_event_argument.h" #include "cc/animation/animation_host.h" -#include "cc/animation/animation_registrar.h" #include "cc/animation/mutable_properties.h" #include "cc/base/math_util.h" #include "cc/base/simple_enclosed_region.h" @@ -95,20 +94,9 @@ LayerImpl::LayerImpl(LayerTreeImpl* tree_impl, int id) layer_or_descendant_has_touch_handler_(false), sorted_for_recursion_(false) { DCHECK_GT(layer_id_, 0); + DCHECK(layer_tree_impl_); layer_tree_impl_->RegisterLayer(this); - - if (!layer_tree_impl_->settings().use_compositor_animation_timelines) { - AnimationRegistrar* registrar = layer_tree_impl_->GetAnimationRegistrar(); - layer_animation_controller_ = - registrar->GetAnimationControllerForId(layer_id_); - layer_animation_controller_->AddValueObserver(this); - if (IsActive()) { - layer_animation_controller_->set_value_provider(this); - layer_animation_controller_->set_layer_animation_delegate(this); - } - } - layer_tree_impl_->AddToElementMap(this); SetNeedsPushProperties(); @@ -117,12 +105,6 @@ LayerImpl::LayerImpl(LayerTreeImpl* tree_impl, int id) LayerImpl::~LayerImpl() { DCHECK_EQ(DRAW_MODE_NONE, current_draw_mode_); - if (layer_animation_controller_) { - layer_animation_controller_->RemoveValueObserver(this); - layer_animation_controller_->remove_value_provider(this); - layer_animation_controller_->remove_layer_animation_delegate(this); - } - if (!copy_requests_.empty() && layer_tree_impl_->IsActiveTree()) layer_tree_impl()->RemoveLayerWithCopyOutputRequest(this); layer_tree_impl_->UnregisterScrollLayer(this); @@ -503,9 +485,6 @@ void LayerImpl::set_main_thread_scrolling_reasons( if (layer_tree_impl()->ScrollOffsetIsAnimatingOnImplOnly(this)) { layer_tree_impl()->animation_host()->ScrollAnimationAbort( true /* needs_completion */); - } else if (layer_animation_controller()) { - layer_animation_controller()->AbortAnimations( - TargetProperty::SCROLL_OFFSET); } } @@ -960,8 +939,6 @@ void LayerImpl::OnScrollOffsetAnimated(const gfx::ScrollOffset& scroll_offset) { layer_tree_impl_->DidAnimateScrollOffset(); } -void LayerImpl::OnAnimationWaitingForDeletion() {} - void LayerImpl::OnTransformIsPotentiallyAnimatingChanged(bool is_animating) { UpdatePropertyTreeTransformIsAnimated(is_animating); was_ever_ready_since_last_transform_animation_ = false; @@ -1126,32 +1103,15 @@ 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_->IsCurrentlyAnimatingProperty( - TargetProperty::FILTER, observer_type) - : layer_tree_impl_->IsAnimatingFilterProperty(this); + return 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( - TargetProperty::FILTER, observer_type) - : layer_tree_impl_->HasPotentiallyRunningFilterAnimation(this); + return layer_tree_impl_->HasPotentiallyRunningFilterAnimation(this); } bool LayerImpl::FilterIsAnimatingOnImplOnly() const { - if (!layer_animation_controller_) - return layer_tree_impl_->FilterIsAnimatingOnImplOnly(this); - - Animation* filter_animation = - layer_animation_controller_->GetAnimation(TargetProperty::FILTER); - return filter_animation && filter_animation->is_impl_only(); + return layer_tree_impl_->FilterIsAnimatingOnImplOnly(this); } void LayerImpl::SetBackgroundFilters( @@ -1189,32 +1149,15 @@ float LayerImpl::EffectiveOpacity() const { } bool LayerImpl::OpacityIsAnimating() const { - LayerAnimationController::ObserverType observer_type = - IsActive() ? LayerAnimationController::ObserverType::ACTIVE - : LayerAnimationController::ObserverType::PENDING; - return layer_animation_controller_ - ? layer_animation_controller_->IsCurrentlyAnimatingProperty( - TargetProperty::OPACITY, observer_type) - : layer_tree_impl_->IsAnimatingOpacityProperty(this); + return layer_tree_impl_->IsAnimatingOpacityProperty(this); } bool LayerImpl::HasPotentiallyRunningOpacityAnimation() const { - LayerAnimationController::ObserverType observer_type = - IsActive() ? LayerAnimationController::ObserverType::ACTIVE - : LayerAnimationController::ObserverType::PENDING; - return layer_animation_controller_ - ? layer_animation_controller_->IsPotentiallyAnimatingProperty( - TargetProperty::OPACITY, observer_type) - : layer_tree_impl_->HasPotentiallyRunningOpacityAnimation(this); + return layer_tree_impl_->HasPotentiallyRunningOpacityAnimation(this); } bool LayerImpl::OpacityIsAnimatingOnImplOnly() const { - if (!layer_animation_controller_) - return layer_tree_impl_->OpacityIsAnimatingOnImplOnly(this); - - Animation* opacity_animation = - layer_animation_controller_->GetAnimation(TargetProperty::OPACITY); - return opacity_animation && opacity_animation->is_impl_only(); + return layer_tree_impl_->OpacityIsAnimatingOnImplOnly(this); } void LayerImpl::SetElementId(uint64_t element_id) { @@ -1320,117 +1263,58 @@ 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_->IsCurrentlyAnimatingProperty( - TargetProperty::TRANSFORM, observer_type) - : layer_tree_impl_->IsAnimatingTransformProperty(this); + return layer_tree_impl_->IsAnimatingTransformProperty(this); } bool LayerImpl::HasPotentiallyRunningTransformAnimation() const { - LayerAnimationController::ObserverType observer_type = - IsActive() ? LayerAnimationController::ObserverType::ACTIVE - : LayerAnimationController::ObserverType::PENDING; - return layer_animation_controller_ - ? layer_animation_controller_->IsPotentiallyAnimatingProperty( - TargetProperty::TRANSFORM, observer_type) - : layer_tree_impl_->HasPotentiallyRunningTransformAnimation(this); + return layer_tree_impl_->HasPotentiallyRunningTransformAnimation(this); } bool LayerImpl::TransformIsAnimatingOnImplOnly() const { - if (!layer_animation_controller_) - return layer_tree_impl_->TransformIsAnimatingOnImplOnly(this); - - Animation* transform_animation = - layer_animation_controller_->GetAnimation(TargetProperty::TRANSFORM); - return transform_animation && transform_animation->is_impl_only(); + return layer_tree_impl_->TransformIsAnimatingOnImplOnly(this); } bool LayerImpl::HasOnlyTranslationTransforms() const { - if (!layer_animation_controller_) - return layer_tree_impl_->HasOnlyTranslationTransforms(this); - - LayerAnimationController::ObserverType observer_type = - IsActive() ? LayerAnimationController::ObserverType::ACTIVE - : LayerAnimationController::ObserverType::PENDING; - return layer_animation_controller_->HasOnlyTranslationTransforms( - observer_type); + return layer_tree_impl_->HasOnlyTranslationTransforms(this); } bool LayerImpl::AnimationsPreserveAxisAlignment() const { - return layer_animation_controller_ - ? layer_animation_controller_->AnimationsPreserveAxisAlignment() - : layer_tree_impl_->AnimationsPreserveAxisAlignment(this); + return layer_tree_impl_->AnimationsPreserveAxisAlignment(this); } bool LayerImpl::MaximumTargetScale(float* max_scale) const { - if (!layer_animation_controller_) - return layer_tree_impl_->MaximumTargetScale(this, max_scale); - - LayerAnimationController::ObserverType observer_type = - IsActive() ? LayerAnimationController::ObserverType::ACTIVE - : LayerAnimationController::ObserverType::PENDING; - return layer_animation_controller_->MaximumTargetScale(observer_type, - max_scale); + return layer_tree_impl_->MaximumTargetScale(this, max_scale); } bool LayerImpl::AnimationStartScale(float* start_scale) const { - if (!layer_animation_controller_) - return layer_tree_impl_->AnimationStartScale(this, start_scale); - - LayerAnimationController::ObserverType observer_type = - IsActive() ? LayerAnimationController::ObserverType::ACTIVE - : LayerAnimationController::ObserverType::PENDING; - return layer_animation_controller_->AnimationStartScale(observer_type, - start_scale); + return layer_tree_impl_->AnimationStartScale(this, start_scale); } bool LayerImpl::HasAnyAnimationTargetingProperty( TargetProperty::Type property) const { - if (!layer_animation_controller_) - return layer_tree_impl_->HasAnyAnimationTargetingProperty(this, property); - - return !!layer_animation_controller_->GetAnimation(property); + return layer_tree_impl_->HasAnyAnimationTargetingProperty(this, property); } bool LayerImpl::HasFilterAnimationThatInflatesBounds() const { - if (!layer_animation_controller_) - return layer_tree_impl_->HasFilterAnimationThatInflatesBounds(this); - - return layer_animation_controller_->HasFilterAnimationThatInflatesBounds(); + return layer_tree_impl_->HasFilterAnimationThatInflatesBounds(this); } bool LayerImpl::HasTransformAnimationThatInflatesBounds() const { - if (!layer_animation_controller_) - return layer_tree_impl_->HasTransformAnimationThatInflatesBounds(this); - - return layer_animation_controller_->HasTransformAnimationThatInflatesBounds(); + return layer_tree_impl_->HasTransformAnimationThatInflatesBounds(this); } bool LayerImpl::HasAnimationThatInflatesBounds() const { - if (!layer_animation_controller_) - return layer_tree_impl_->HasAnimationThatInflatesBounds(this); - - return layer_animation_controller_->HasAnimationThatInflatesBounds(); + return layer_tree_impl_->HasAnimationThatInflatesBounds(this); } bool LayerImpl::FilterAnimationBoundsForBox(const gfx::BoxF& box, gfx::BoxF* bounds) const { - if (!layer_animation_controller_) - return layer_tree_impl_->FilterAnimationBoundsForBox(this, box, bounds); - - return layer_animation_controller_->FilterAnimationBoundsForBox(box, bounds); + return layer_tree_impl_->FilterAnimationBoundsForBox(this, box, bounds); } bool LayerImpl::TransformAnimationBoundsForBox(const gfx::BoxF& box, gfx::BoxF* bounds) const { - if (!layer_animation_controller_) - return layer_tree_impl_->TransformAnimationBoundsForBox(this, box, bounds); - - return layer_animation_controller_->TransformAnimationBoundsForBox(box, - bounds); + return layer_tree_impl_->TransformAnimationBoundsForBox(this, box, bounds); } void LayerImpl::SetUpdateRect(const gfx::Rect& update_rect) { @@ -1614,11 +1498,8 @@ void LayerImpl::AsValueInto(base::trace_event::TracedValue* state) const { state->SetBoolean("can_use_lcd_text", can_use_lcd_text()); state->SetBoolean("contents_opaque", contents_opaque()); - state->SetBoolean( - "has_animation_bounds", - layer_animation_controller_ - ? layer_animation_controller_->HasAnimationThatInflatesBounds() - : layer_tree_impl_->HasAnimationThatInflatesBounds(this)); + state->SetBoolean("has_animation_bounds", + layer_tree_impl_->HasAnimationThatInflatesBounds(this)); gfx::BoxF box; if (LayerUtils::GetAnimationBounds(*this, &box)) @@ -1671,13 +1552,6 @@ int LayerImpl::NumDescendantsThatDrawContent() const { return num_descendants_that_draw_content_; } -void LayerImpl::NotifyAnimationFinished(base::TimeTicks monotonic_time, - TargetProperty::Type target_property, - int group) { - if (target_property == TargetProperty::SCROLL_OFFSET) - layer_tree_impl_->InputScrollAnimationFinished(); -} - void LayerImpl::SetHasRenderSurface(bool should_have_render_surface) { if (!!render_surface() == should_have_render_surface) return; diff --git a/cc/layers/layer_impl.h b/cc/layers/layer_impl.h index 7cb5a41..5accffa 100644 --- a/cc/layers/layer_impl.h +++ b/cc/layers/layer_impl.h @@ -17,10 +17,7 @@ #include "base/macros.h" #include "base/memory/scoped_ptr.h" #include "base/values.h" -#include "cc/animation/animation_delegate.h" -#include "cc/animation/layer_animation_controller.h" -#include "cc/animation/layer_animation_value_observer.h" -#include "cc/animation/layer_animation_value_provider.h" +#include "cc/animation/target_property.h" #include "cc/base/cc_export.h" #include "cc/base/region.h" #include "cc/base/synced_property.h" @@ -79,9 +76,7 @@ enum DrawMode { DRAW_MODE_RESOURCELESS_SOFTWARE }; -class CC_EXPORT LayerImpl : public LayerAnimationValueObserver, - public LayerAnimationValueProvider, - public AnimationDelegate { +class CC_EXPORT LayerImpl { public: typedef LayerImplList RenderSurfaceListType; typedef LayerImplList LayerListType; @@ -93,36 +88,18 @@ class CC_EXPORT LayerImpl : public LayerAnimationValueObserver, return make_scoped_ptr(new LayerImpl(tree_impl, id)); } - ~LayerImpl() override; + virtual ~LayerImpl(); int id() const { return layer_id_; } - // LayerAnimationValueProvider implementation. - gfx::ScrollOffset ScrollOffsetForAnimation() const override; - - // LayerAnimationValueObserver implementation. - void OnFilterAnimated(const FilterOperations& filters) override; - void OnOpacityAnimated(float opacity) override; - void OnTransformAnimated(const gfx::Transform& transform) override; - void OnScrollOffsetAnimated(const gfx::ScrollOffset& scroll_offset) override; - void OnAnimationWaitingForDeletion() override; - void OnTransformIsPotentiallyAnimatingChanged(bool is_animating) override; - bool IsActive() const override; - - // AnimationDelegate implementation. - void NotifyAnimationStarted(base::TimeTicks monotonic_time, - TargetProperty::Type target_property, - int group) override{}; - void NotifyAnimationFinished(base::TimeTicks monotonic_time, - TargetProperty::Type target_property, - int group) override; - void NotifyAnimationAborted(base::TimeTicks monotonic_time, - TargetProperty::Type target_property, - int group) override{}; - void NotifyAnimationTakeover(base::TimeTicks monotonic_time, - TargetProperty::Type target_property, - double animation_start_time, - scoped_ptr<AnimationCurve> curve) override {} + // Interactions with attached animations. + gfx::ScrollOffset ScrollOffsetForAnimation() const; + void OnFilterAnimated(const FilterOperations& filters); + void OnOpacityAnimated(float opacity); + void OnTransformAnimated(const gfx::Transform& transform); + void OnScrollOffsetAnimated(const gfx::ScrollOffset& scroll_offset); + void OnTransformIsPotentiallyAnimatingChanged(bool is_animating); + bool IsActive() const; // Tree structure. LayerImpl* parent() { return parent_; } @@ -549,14 +526,6 @@ class CC_EXPORT LayerImpl : public LayerAnimationValueObserver, void ResetAllChangeTrackingForSubtree(); - LayerAnimationController* layer_animation_controller() { - return layer_animation_controller_.get(); - } - - const LayerAnimationController* layer_animation_controller() const { - return layer_animation_controller_.get(); - } - virtual SimpleEnclosedRegion VisibleOpaqueRegion() const; virtual void DidBecomeActive() {} @@ -806,9 +775,6 @@ class CC_EXPORT LayerImpl : public LayerAnimationValueObserver, // space. gfx::Rect damage_rect_; - // Manages animations for this layer. - scoped_refptr<LayerAnimationController> layer_animation_controller_; - std::vector<scoped_ptr<CopyOutputRequest>> copy_requests_; // Group of properties that need to be computed based on the layer tree diff --git a/cc/layers/layer_unittest.cc b/cc/layers/layer_unittest.cc index a09295e..b9fe4a8 100644 --- a/cc/layers/layer_unittest.cc +++ b/cc/layers/layer_unittest.cc @@ -2049,49 +2049,6 @@ TEST_F(LayerLayerTreeHostTest, DestroyHostWithNonNullRootLayer) { layer_tree_host->SetRootLayer(root); } -static bool AddTestAnimation(Layer* layer) { - scoped_ptr<KeyframedFloatAnimationCurve> curve = - KeyframedFloatAnimationCurve::Create(); - curve->AddKeyframe(FloatKeyframe::Create(base::TimeDelta(), 0.3f, nullptr)); - curve->AddKeyframe( - FloatKeyframe::Create(base::TimeDelta::FromSecondsD(1.0), 0.7f, nullptr)); - scoped_ptr<Animation> animation = - Animation::Create(std::move(curve), 0, 0, TargetProperty::OPACITY); - - return layer->AddAnimation(std::move(animation)); -} - -TEST_F(LayerLayerTreeHostTest, ShouldNotAddAnimationWithoutAnimationRegistrar) { - // This tests isn't needed in new use_compositor_animation_timelines mode. - if (layer_settings_.use_compositor_animation_timelines) - return; - - scoped_refptr<Layer> layer = Layer::Create(layer_settings_); - - // Case 1: without a LayerTreeHost and without an AnimationRegistrar, the - // animation should not be accepted. - EXPECT_FALSE(AddTestAnimation(layer.get())); - - scoped_ptr<AnimationRegistrar> registrar = AnimationRegistrar::Create(); - layer->RegisterForAnimations(registrar.get()); - - // Case 2: with an AnimationRegistrar, the animation should be accepted. - EXPECT_TRUE(AddTestAnimation(layer.get())); - - LayerTreeSettings settings; - settings.accelerated_animation_enabled = false; - settings.use_compositor_animation_timelines = - layer_settings_.use_compositor_animation_timelines; - LayerTreeHostFactory factory; - scoped_ptr<LayerTreeHost> layer_tree_host = factory.Create(settings); - layer_tree_host->SetRootLayer(layer); - AssertLayerTreeHostMatchesForSubtree(layer.get(), layer_tree_host.get()); - - // Case 3: with a LayerTreeHost where accelerated animation is disabled, the - // animation should be rejected. - EXPECT_FALSE(AddTestAnimation(layer.get())); -} - TEST_F(LayerTest, SafeOpaqueBackgroundColor) { LayerTreeHostFactory factory; scoped_ptr<LayerTreeHost> layer_tree_host = factory.Create(); diff --git a/cc/layers/layer_utils_unittest.cc b/cc/layers/layer_utils_unittest.cc index 396d02a..6d16c5c 100644 --- a/cc/layers/layer_utils_unittest.cc +++ b/cc/layers/layer_utils_unittest.cc @@ -46,11 +46,9 @@ class LayerUtilsGetAnimationBoundsTest : public testing::Test { child2_(parent2_->children()[0].get()), grand_child_(child2_->children()[0].get()), great_grand_child_(grand_child_->children()[0].get()) { - if (host_impl_.settings().use_compositor_animation_timelines) { - timeline_ = - AnimationTimeline::Create(AnimationIdProvider::NextTimelineId()); - host_impl_.animation_host()->AddAnimationTimeline(timeline_); - } + timeline_ = + AnimationTimeline::Create(AnimationIdProvider::NextTimelineId()); + host_impl_.animation_host()->AddAnimationTimeline(timeline_); } LayerImpl* root() { return root_; } @@ -103,12 +101,8 @@ TEST_F(LayerUtilsGetAnimationBoundsTest, ScaleRoot) { start.AppendScale(1.f, 1.f, 1.f); TransformOperations end; end.AppendScale(2.f, 2.f, 1.f); - if (host_impl().settings().use_compositor_animation_timelines) { - AddAnimatedTransformToLayerWithPlayer(root()->id(), timeline(), duration, - start, end); - } else { - AddAnimatedTransformToLayer(root(), duration, start, end); - } + AddAnimatedTransformToLayerWithPlayer(root()->id(), timeline(), duration, + start, end); root()->SetPosition(gfx::PointF()); parent1()->SetPosition(gfx::PointF()); @@ -134,12 +128,8 @@ TEST_F(LayerUtilsGetAnimationBoundsTest, TranslateParentLayer) { start.AppendTranslate(0.f, 0.f, 0.f); TransformOperations end; end.AppendTranslate(50.f, 50.f, 0.f); - if (host_impl().settings().use_compositor_animation_timelines) { - AddAnimatedTransformToLayerWithPlayer(parent1()->id(), timeline(), duration, - start, end); - } else { - AddAnimatedTransformToLayer(parent1(), duration, start, end); - } + AddAnimatedTransformToLayerWithPlayer(parent1()->id(), timeline(), duration, + start, end); parent1()->SetBounds(gfx::Size(350, 200)); @@ -163,13 +153,8 @@ TEST_F(LayerUtilsGetAnimationBoundsTest, TranslateChildLayer) { start.AppendTranslate(0.f, 0.f, 0.f); TransformOperations end; end.AppendTranslate(50.f, 50.f, 0.f); - if (host_impl().settings().use_compositor_animation_timelines) { - AddAnimatedTransformToLayerWithPlayer(child1()->id(), timeline(), duration, - start, end); - } else { - AddAnimatedTransformToLayer(child1(), duration, start, end); - } - + AddAnimatedTransformToLayerWithPlayer(child1()->id(), timeline(), duration, + start, end); parent1()->SetBounds(gfx::Size(350, 200)); child1()->SetDrawsContent(true); @@ -192,21 +177,13 @@ TEST_F(LayerUtilsGetAnimationBoundsTest, TranslateBothLayers) { start.AppendTranslate(0.f, 0.f, 0.f); TransformOperations child_end; child_end.AppendTranslate(50.f, 0.f, 0.f); - if (host_impl().settings().use_compositor_animation_timelines) { - AddAnimatedTransformToLayerWithPlayer(parent1()->id(), timeline(), duration, - start, child_end); - } else { - AddAnimatedTransformToLayer(parent1(), duration, start, child_end); - } + AddAnimatedTransformToLayerWithPlayer(parent1()->id(), timeline(), duration, + start, child_end); TransformOperations grand_child_end; grand_child_end.AppendTranslate(0.f, 50.f, 0.f); - if (host_impl().settings().use_compositor_animation_timelines) { - AddAnimatedTransformToLayerWithPlayer(child1()->id(), timeline(), duration, - start, grand_child_end); - } else { - AddAnimatedTransformToLayer(child1(), duration, start, grand_child_end); - } + AddAnimatedTransformToLayerWithPlayer(child1()->id(), timeline(), duration, + start, grand_child_end); parent1()->SetBounds(gfx::Size(350, 200)); @@ -230,12 +207,9 @@ TEST_F(LayerUtilsGetAnimationBoundsTest, RotateXNoPerspective) { start.AppendRotate(1.f, 0.f, 0.f, 0.f); TransformOperations end; end.AppendRotate(1.f, 0.f, 0.f, 90.f); - if (host_impl().settings().use_compositor_animation_timelines) { - AddAnimatedTransformToLayerWithPlayer(child1()->id(), timeline(), duration, - start, end); - } else { - AddAnimatedTransformToLayer(child1(), duration, start, end); - } + + AddAnimatedTransformToLayerWithPlayer(child1()->id(), timeline(), duration, + start, end); parent1()->SetBounds(gfx::Size(350, 200)); @@ -263,12 +237,8 @@ TEST_F(LayerUtilsGetAnimationBoundsTest, RotateXWithPerspective) { TransformOperations end; end.AppendRotate(1.f, 0.f, 0.f, 90.f); - if (host_impl().settings().use_compositor_animation_timelines) { - AddAnimatedTransformToLayerWithPlayer(child1()->id(), timeline(), duration, - start, end); - } else { - AddAnimatedTransformToLayer(child1(), duration, start, end); - } + AddAnimatedTransformToLayerWithPlayer(child1()->id(), timeline(), duration, + start, end); // Make the anchor point not the default 0.5 value and line up with the // child center to make the math easier. @@ -308,12 +278,8 @@ TEST_F(LayerUtilsGetAnimationBoundsTest, RotateXWithPerspectiveOnSameLayer) { TransformOperations end; end.AppendRotate(1.f, 0.f, 0.f, 90.f); - if (host_impl().settings().use_compositor_animation_timelines) { - AddAnimatedTransformToLayerWithPlayer(parent1()->id(), timeline(), duration, - start, end); - } else { - AddAnimatedTransformToLayer(parent1(), duration, start, end); - } + AddAnimatedTransformToLayerWithPlayer(parent1()->id(), timeline(), duration, + start, end); // Make the anchor point not the default 0.5 value and line up // with the child center to make the math easier. @@ -348,12 +314,8 @@ TEST_F(LayerUtilsGetAnimationBoundsTest, RotateZ) { start.AppendRotate(0.f, 0.f, 1.f, 0.f); TransformOperations end; end.AppendRotate(0.f, 0.f, 1.f, 90.f); - if (host_impl().settings().use_compositor_animation_timelines) { - AddAnimatedTransformToLayerWithPlayer(child1()->id(), timeline(), duration, - start, end); - } else { - AddAnimatedTransformToLayer(child1(), duration, start, end); - } + AddAnimatedTransformToLayerWithPlayer(child1()->id(), timeline(), duration, + start, end); parent1()->SetBounds(gfx::Size(350, 200)); @@ -386,12 +348,8 @@ TEST_F(LayerUtilsGetAnimationBoundsTest, MismatchedTransforms) { start.AppendTranslate(5, 6, 7); TransformOperations end; end.AppendRotate(0.f, 0.f, 1.f, 90.f); - if (host_impl().settings().use_compositor_animation_timelines) { - AddAnimatedTransformToLayerWithPlayer(child1()->id(), timeline(), duration, - start, end); - } else { - AddAnimatedTransformToLayer(child1(), duration, start, end); - } + AddAnimatedTransformToLayerWithPlayer(child1()->id(), timeline(), duration, + start, end); parent1()->SetBounds(gfx::Size(350, 200)); @@ -425,14 +383,8 @@ TEST_F(LayerUtilsGetAnimationBoundsTest, start.AppendTranslate(0.f, 0.f, 0.f); TransformOperations great_grand_child_end; great_grand_child_end.AppendTranslate(50.f, 0.f, 0.f); - if (host_impl().settings().use_compositor_animation_timelines) { - AddAnimatedTransformToLayerWithPlayer(grand_child()->id(), timeline(), - duration, start, - great_grand_child_end); - } else { - AddAnimatedTransformToLayer(grand_child(), duration, start, - great_grand_child_end); - } + AddAnimatedTransformToLayerWithPlayer(grand_child()->id(), timeline(), + duration, start, great_grand_child_end); gfx::Transform translate_2d_transform; translate_2d_transform.Translate(80.f, 60.f); @@ -459,14 +411,8 @@ TEST_F(LayerUtilsGetAnimationBoundsTest, start.AppendRotate(0.f, 0.f, 1.f, 0.f); TransformOperations great_grand_child_end; great_grand_child_end.AppendRotate(0.f, 0.f, 1.f, 90.f); - if (host_impl().settings().use_compositor_animation_timelines) { - AddAnimatedTransformToLayerWithPlayer(grand_child()->id(), timeline(), - duration, start, - great_grand_child_end); - } else { - AddAnimatedTransformToLayer(grand_child(), duration, start, - great_grand_child_end); - } + AddAnimatedTransformToLayerWithPlayer(grand_child()->id(), timeline(), + duration, start, great_grand_child_end); gfx::Transform translate_2d_transform; translate_2d_transform.Translate(80.f, 60.f); @@ -512,14 +458,8 @@ TEST_F(LayerUtilsGetAnimationBoundsTest, start.AppendRotate(1.f, 0.f, 0.f, 0.f); TransformOperations great_grand_child_end; great_grand_child_end.AppendRotate(1.f, 0.f, 0.f, 90.f); - if (host_impl().settings().use_compositor_animation_timelines) { - AddAnimatedTransformToLayerWithPlayer(great_grand_child()->id(), timeline(), - duration, start, - great_grand_child_end); - } else { - AddAnimatedTransformToLayer(great_grand_child(), duration, start, - great_grand_child_end); - } + AddAnimatedTransformToLayerWithPlayer(great_grand_child()->id(), timeline(), + duration, start, great_grand_child_end); gfx::Transform translate_2d_transform; translate_2d_transform.Translate(80.f, 60.f); @@ -599,13 +539,8 @@ TEST_F(LayerUtilsGetAnimationBoundsTest, start.AppendRotate(1.f, 0.f, 0.f, 0.f); TransformOperations rotate_x_end; rotate_x_end.AppendRotate(1.f, 0.f, 0.f, 90.f); - if (host_impl().settings().use_compositor_animation_timelines) { - AddAnimatedTransformToLayerWithPlayer(great_grand_child()->id(), timeline(), - duration, start, rotate_x_end); - } else { - AddAnimatedTransformToLayer(great_grand_child(), duration, start, - rotate_x_end); - } + AddAnimatedTransformToLayerWithPlayer(great_grand_child()->id(), timeline(), + duration, start, rotate_x_end); gfx::Transform translate_2d_transform; translate_2d_transform.Translate(80.f, 60.f); |