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 | |
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')
-rw-r--r-- | cc/animation/layer_animation_controller.h | 10 | ||||
-rw-r--r-- | cc/blink/web_layer_impl.cc | 1 | ||||
-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 | ||||
-rw-r--r-- | cc/test/animation_test_common.cc | 75 | ||||
-rw-r--r-- | cc/test/animation_test_common.h | 42 | ||||
-rw-r--r-- | cc/test/layer_tree_test.cc | 42 | ||||
-rw-r--r-- | cc/test/layer_tree_test.h | 5 | ||||
-rw-r--r-- | cc/trees/layer_tree_host.cc | 47 | ||||
-rw-r--r-- | cc/trees/layer_tree_host.h | 6 | ||||
-rw-r--r-- | cc/trees/layer_tree_host_common_unittest.cc | 310 | ||||
-rw-r--r-- | cc/trees/layer_tree_host_impl.cc | 127 | ||||
-rw-r--r-- | cc/trees/layer_tree_host_impl.h | 5 | ||||
-rw-r--r-- | cc/trees/layer_tree_host_impl_unittest.cc | 57 | ||||
-rw-r--r-- | cc/trees/layer_tree_host_unittest_animation.cc | 1 | ||||
-rw-r--r-- | cc/trees/layer_tree_impl.cc | 11 | ||||
-rw-r--r-- | cc/trees/layer_tree_impl.h | 3 | ||||
-rw-r--r-- | cc/trees/tree_synchronizer_unittest.cc | 62 |
22 files changed, 228 insertions, 1185 deletions
diff --git a/cc/animation/layer_animation_controller.h b/cc/animation/layer_animation_controller.h index 28a4523..c6cc506 100644 --- a/cc/animation/layer_animation_controller.h +++ b/cc/animation/layer_animation_controller.h @@ -52,9 +52,8 @@ class CC_EXPORT LayerAnimationController // Ensures that the list of active animations on the main thread and the impl // thread are kept in sync. This function does not take ownership of the impl - // thread controller. This method is virtual for testing. - virtual void PushAnimationUpdatesTo( - LayerAnimationController* controller_impl); + // thread controller. + void PushAnimationUpdatesTo(LayerAnimationController* controller_impl); void Animate(base::TimeTicks monotonic_time); void AccumulatePropertyUpdates(base::TimeTicks monotonic_time, @@ -170,13 +169,12 @@ class CC_EXPORT LayerAnimationController return needs_to_start_animations_; } - protected: + private: friend class base::RefCounted<LayerAnimationController>; explicit LayerAnimationController(int id); - virtual ~LayerAnimationController(); + ~LayerAnimationController(); - private: using TargetProperties = std::unordered_set<int>; void PushNewAnimationsToImplThread( diff --git a/cc/blink/web_layer_impl.cc b/cc/blink/web_layer_impl.cc index 0512cf5..2d578fc 100644 --- a/cc/blink/web_layer_impl.cc +++ b/cc/blink/web_layer_impl.cc @@ -30,7 +30,6 @@ #include "ui/gfx/geometry/rect_conversions.h" #include "ui/gfx/geometry/vector2d_conversions.h" -using cc::Animation; using cc::Layer; using blink::WebLayer; using blink::WebFloatPoint; 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); diff --git a/cc/test/animation_test_common.cc b/cc/test/animation_test_common.cc index cc02e63..8bed0ee 100644 --- a/cc/test/animation_test_common.cc +++ b/cc/test/animation_test_common.cc @@ -292,81 +292,6 @@ int AddAnimatedFilterToController(LayerAnimationController* controller, controller, duration, start_brightness, end_brightness); } -int AddOpacityTransitionToLayer(Layer* layer, - double duration, - float start_opacity, - float end_opacity, - bool use_timing_function) { - return AddOpacityTransition(layer, - duration, - start_opacity, - end_opacity, - use_timing_function); -} - -int AddOpacityTransitionToLayer(LayerImpl* layer, - double duration, - float start_opacity, - float end_opacity, - bool use_timing_function) { - return AddOpacityTransition(layer->layer_animation_controller(), - duration, - start_opacity, - end_opacity, - use_timing_function); -} - -int AddAnimatedTransformToLayer(Layer* layer, - double duration, - int delta_x, - int delta_y) { - return AddAnimatedTransform(layer, duration, delta_x, delta_y); -} - -int AddAnimatedTransformToLayer(LayerImpl* layer, - double duration, - int delta_x, - int delta_y) { - return AddAnimatedTransform(layer->layer_animation_controller(), - duration, - delta_x, - delta_y); -} - -int AddAnimatedTransformToLayer(Layer* layer, - double duration, - TransformOperations start_operations, - TransformOperations operations) { - return AddAnimatedTransform(layer, duration, start_operations, operations); -} - -int AddAnimatedTransformToLayer(LayerImpl* layer, - double duration, - TransformOperations start_operations, - TransformOperations operations) { - return AddAnimatedTransform(layer->layer_animation_controller(), - duration, - start_operations, - operations); -} - -int AddAnimatedFilterToLayer(Layer* layer, - double duration, - float start_brightness, - float end_brightness) { - return AddAnimatedFilter(layer, duration, start_brightness, end_brightness); -} - -int AddAnimatedFilterToLayer(LayerImpl* layer, - double duration, - float start_brightness, - float end_brightness) { - return AddAnimatedFilter(layer->layer_animation_controller(), - duration, - start_brightness, - end_brightness); -} - int AddAnimatedTransformToPlayer(AnimationPlayer* player, double duration, int delta_x, diff --git a/cc/test/animation_test_common.h b/cc/test/animation_test_common.h index 7a6fe0d..2d47e6d 100644 --- a/cc/test/animation_test_common.h +++ b/cc/test/animation_test_common.h @@ -144,48 +144,6 @@ int AddAnimatedFilterToController(LayerAnimationController* controller, float start_brightness, float end_brightness); -int AddOpacityTransitionToLayer(Layer* layer, - double duration, - float start_opacity, - float end_opacity, - bool use_timing_function); - -int AddOpacityTransitionToLayer(LayerImpl* layer, - double duration, - float start_opacity, - float end_opacity, - bool use_timing_function); - -int AddAnimatedTransformToLayer(Layer* layer, - double duration, - int delta_x, - int delta_y); - -int AddAnimatedTransformToLayer(LayerImpl* layer, - double duration, - int delta_x, - int delta_y); - -int AddAnimatedTransformToLayer(Layer* layer, - double duration, - TransformOperations start_operations, - TransformOperations operations); - -int AddAnimatedTransformToLayer(LayerImpl* layer, - double duration, - TransformOperations start_operations, - TransformOperations operations); - -int AddAnimatedFilterToLayer(Layer* layer, - double duration, - float start_brightness, - float end_brightness); - -int AddAnimatedFilterToLayer(LayerImpl* layer, - double duration, - float start_brightness, - float end_brightness); - int AddAnimatedTransformToPlayer(AnimationPlayer* player, double duration, int delta_x, diff --git a/cc/test/layer_tree_test.cc b/cc/test/layer_tree_test.cc index 0887cc5..9503c42 100644 --- a/cc/test/layer_tree_test.cc +++ b/cc/test/layer_tree_test.cc @@ -320,9 +320,7 @@ class LayerTreeHostImplForTesting : public LayerTreeHostImpl { void UpdateAnimationState(bool start_ready_animations) override { LayerTreeHostImpl::UpdateAnimationState(start_ready_animations); bool has_unfinished_animation = false; - AnimationRegistrar* registrar = - animation_registrar() ? animation_registrar() - : animation_host()->animation_registrar(); + AnimationRegistrar* registrar = animation_host()->animation_registrar(); for (const auto& it : registrar->active_animation_controllers_for_testing()) { if (it.second->HasActiveAnimation()) { @@ -576,34 +574,6 @@ void LayerTreeTest::EndTestAfterDelayMs(int delay_milliseconds) { base::TimeDelta::FromMilliseconds(delay_milliseconds)); } -void LayerTreeTest::PostAddAnimationToMainThread( - Layer* layer_to_receive_animation) { - main_task_runner_->PostTask( - FROM_HERE, - base::Bind(&LayerTreeTest::DispatchAddAnimation, main_thread_weak_ptr_, - base::Unretained(layer_to_receive_animation), 0.000004)); -} - -void LayerTreeTest::PostAddInstantAnimationToMainThread( - Layer* layer_to_receive_animation) { - main_task_runner_->PostTask( - FROM_HERE, - base::Bind(&LayerTreeTest::DispatchAddAnimation, - main_thread_weak_ptr_, - base::Unretained(layer_to_receive_animation), - 0.0)); -} - -void LayerTreeTest::PostAddLongAnimationToMainThread( - Layer* layer_to_receive_animation) { - main_task_runner_->PostTask( - FROM_HERE, - base::Bind(&LayerTreeTest::DispatchAddAnimation, - main_thread_weak_ptr_, - base::Unretained(layer_to_receive_animation), - 1.0)); -} - void LayerTreeTest::PostAddAnimationToMainThreadPlayer( AnimationPlayer* player_to_receive_animation) { main_task_runner_->PostTask( @@ -816,16 +786,6 @@ void LayerTreeTest::RealEndTest() { base::MessageLoop::current()->QuitWhenIdle(); } -void LayerTreeTest::DispatchAddAnimation(Layer* layer_to_receive_animation, - double animation_duration) { - DCHECK(!task_runner_provider() || task_runner_provider()->IsMainThread()); - - if (layer_to_receive_animation) { - AddOpacityTransitionToLayer( - layer_to_receive_animation, animation_duration, 0, 0.5, true); - } -} - void LayerTreeTest::DispatchAddAnimationToPlayer( AnimationPlayer* player_to_receive_animation, double animation_duration) { diff --git a/cc/test/layer_tree_test.h b/cc/test/layer_tree_test.h index 2b9a91a..36a882c 100644 --- a/cc/test/layer_tree_test.h +++ b/cc/test/layer_tree_test.h @@ -77,9 +77,6 @@ class LayerTreeTest : public testing::Test, public TestHooks { virtual void EndTest(); void EndTestAfterDelayMs(int delay_milliseconds); - void PostAddAnimationToMainThread(Layer* layer_to_receive_animation); - void PostAddInstantAnimationToMainThread(Layer* layer_to_receive_animation); - void PostAddLongAnimationToMainThread(Layer* layer_to_receive_animation); void PostAddAnimationToMainThreadPlayer( AnimationPlayer* player_to_receive_animation); void PostAddInstantAnimationToMainThreadPlayer( @@ -109,8 +106,6 @@ class LayerTreeTest : public testing::Test, public TestHooks { void RealEndTest(); - virtual void DispatchAddAnimation(Layer* layer_to_receive_animation, - double animation_duration); virtual void DispatchAddAnimationToPlayer( AnimationPlayer* player_to_receive_animation, double animation_duration); diff --git a/cc/trees/layer_tree_host.cc b/cc/trees/layer_tree_host.cc index 6e9d689..5f21e91 100644 --- a/cc/trees/layer_tree_host.cc +++ b/cc/trees/layer_tree_host.cc @@ -26,8 +26,6 @@ #include "base/trace_event/trace_event_argument.h" #include "cc/animation/animation_events.h" #include "cc/animation/animation_host.h" -#include "cc/animation/animation_registrar.h" -#include "cc/animation/layer_animation_controller.h" #include "cc/base/math_util.h" #include "cc/debug/devtools_instrumentation.h" #include "cc/debug/frame_viewer_instrumentation.h" @@ -201,12 +199,8 @@ LayerTreeHost::LayerTreeHost(InitParams* params, CompositorMode mode) DCHECK(task_graph_runner_); if (settings_.accelerated_animation_enabled) { - if (settings_.use_compositor_animation_timelines) { - animation_host_ = AnimationHost::Create(ThreadInstance::MAIN); - animation_host_->SetMutatorHostClient(this); - } else { - animation_registrar_ = AnimationRegistrar::Create(); - } + animation_host_ = AnimationHost::Create(ThreadInstance::MAIN); + animation_host_->SetMutatorHostClient(this); } rendering_stats_instrumentation_->set_record_rendering_stats( @@ -293,12 +287,8 @@ void LayerTreeHost::InitializeProxy( proxy_ = std::move(proxy); proxy_->Start(std::move(external_begin_frame_source)); if (settings_.accelerated_animation_enabled) { - if (animation_host_) - animation_host_->SetSupportsScrollAnimations( - proxy_->SupportsImplScrolling()); - else - animation_registrar_->set_supports_scroll_animations( - proxy_->SupportsImplScrolling()); + animation_host_->SetSupportsScrollAnimations( + proxy_->SupportsImplScrolling()); } } @@ -698,10 +688,7 @@ void LayerTreeHost::SetNextCommitForcesRedraw() { void LayerTreeHost::SetAnimationEvents(scoped_ptr<AnimationEvents> events) { DCHECK(task_runner_provider_->IsMainThread()); - if (animation_host_) - animation_host_->SetAnimationEvents(std::move(events)); - else - animation_registrar_->SetAnimationEvents(std::move(events)); + animation_host_->SetAnimationEvents(std::move(events)); } void LayerTreeHost::SetRootLayer(scoped_refptr<Layer> root_layer) { @@ -1069,15 +1056,9 @@ void LayerTreeHost::AnimateLayers(base::TimeTicks monotonic_time) { return; scoped_ptr<AnimationEvents> events; - if (animation_host_) { - events = animation_host_->CreateEvents(); - if (animation_host_->AnimateLayers(monotonic_time)) - animation_host_->UpdateAnimationState(true, events.get()); - } else { - events = animation_registrar_->CreateEvents(); - if (animation_registrar_->AnimateLayers(monotonic_time)) - animation_registrar_->UpdateAnimationState(true, events.get()); - } + events = animation_host_->CreateEvents(); + if (animation_host_->AnimateLayers(monotonic_time)) + animation_host_->UpdateAnimationState(true, events.get()); if (!events->events_.empty()) property_trees_.needs_rebuild = true; @@ -1286,7 +1267,7 @@ void LayerTreeHost::SetMutatorsNeedRebuildPropertyTrees() { void LayerTreeHost::SetLayerFilterMutated(int layer_id, LayerTreeType tree_type, const FilterOperations& filters) { - LayerAnimationValueObserver* layer = LayerById(layer_id); + Layer* layer = LayerById(layer_id); DCHECK(layer); layer->OnFilterAnimated(filters); } @@ -1294,7 +1275,7 @@ void LayerTreeHost::SetLayerFilterMutated(int layer_id, void LayerTreeHost::SetLayerOpacityMutated(int layer_id, LayerTreeType tree_type, float opacity) { - LayerAnimationValueObserver* layer = LayerById(layer_id); + Layer* layer = LayerById(layer_id); DCHECK(layer); layer->OnOpacityAnimated(opacity); } @@ -1302,7 +1283,7 @@ void LayerTreeHost::SetLayerOpacityMutated(int layer_id, void LayerTreeHost::SetLayerTransformMutated(int layer_id, LayerTreeType tree_type, const gfx::Transform& transform) { - LayerAnimationValueObserver* layer = LayerById(layer_id); + Layer* layer = LayerById(layer_id); DCHECK(layer); layer->OnTransformAnimated(transform); } @@ -1311,7 +1292,7 @@ void LayerTreeHost::SetLayerScrollOffsetMutated( int layer_id, LayerTreeType tree_type, const gfx::ScrollOffset& scroll_offset) { - LayerAnimationValueObserver* layer = LayerById(layer_id); + Layer* layer = LayerById(layer_id); DCHECK(layer); layer->OnScrollOffsetAnimated(scroll_offset); } @@ -1320,14 +1301,14 @@ void LayerTreeHost::LayerTransformIsPotentiallyAnimatingChanged( int layer_id, LayerTreeType tree_type, bool is_animating) { - LayerAnimationValueObserver* layer = LayerById(layer_id); + Layer* layer = LayerById(layer_id); DCHECK(layer); layer->OnTransformIsPotentiallyAnimatingChanged(is_animating); } gfx::ScrollOffset LayerTreeHost::GetScrollOffsetForAnimation( int layer_id) const { - LayerAnimationValueProvider* layer = LayerById(layer_id); + Layer* layer = LayerById(layer_id); DCHECK(layer); return layer->ScrollOffsetForAnimation(); } diff --git a/cc/trees/layer_tree_host.h b/cc/trees/layer_tree_host.h index 056326b..b13be32 100644 --- a/cc/trees/layer_tree_host.h +++ b/cc/trees/layer_tree_host.h @@ -20,7 +20,7 @@ #include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" #include "base/time/time.h" -#include "cc/animation/animation.h" +#include "cc/animation/target_property.h" #include "cc/base/cc_export.h" #include "cc/debug/frame_timing_tracker.h" #include "cc/debug/micro_benchmark.h" @@ -295,9 +295,6 @@ class CC_EXPORT LayerTreeHost : public MutatorHostClient { TaskRunnerProvider* task_runner_provider() const { return task_runner_provider_.get(); } - AnimationRegistrar* animation_registrar() const { - return animation_registrar_.get(); - } AnimationHost* animation_host() const { return animation_host_.get(); } bool in_paint_layer_contents() const { return in_paint_layer_contents_; } @@ -550,7 +547,6 @@ class CC_EXPORT LayerTreeHost : public MutatorHostClient { EventListenerProperties event_listener_properties_[static_cast<size_t>( EventListenerClass::kNumClasses)]; - scoped_ptr<AnimationRegistrar> animation_registrar_; scoped_ptr<AnimationHost> animation_host_; scoped_ptr<PendingPageScaleAnimation> pending_page_scale_animation_; diff --git a/cc/trees/layer_tree_host_common_unittest.cc b/cc/trees/layer_tree_host_common_unittest.cc index c0786df..4377c2f 100644 --- a/cc/trees/layer_tree_host_common_unittest.cc +++ b/cc/trees/layer_tree_host_common_unittest.cc @@ -2514,46 +2514,24 @@ TEST_F(LayerTreeHostCommonTest, AnimationsForRenderSurfaceHierarchy) { grand_child_of_rs2, layer_transform, gfx::Point3F(0.25f, 0.f, 0.f), gfx::PointF(2.5f, 0.f), gfx::Size(10, 10), true, false, false); - if (layer_settings().use_compositor_animation_timelines) { - // Put an animated opacity on the render surface. - AddOpacityTransitionToLayerWithPlayer( - render_surface1->id(), timeline_impl(), 10.0, 1.f, 0.f, false); - - // Also put an animated opacity on a layer without descendants. - AddOpacityTransitionToLayerWithPlayer( - grand_child_of_root->id(), timeline_impl(), 10.0, 1.f, 0.f, false); - - // Put a transform animation on the render surface. - AddAnimatedTransformToLayerWithPlayer(render_surface2->id(), - timeline_impl(), 10.0, 30, 0); - - // Also put transform animations on grand_child_of_root, and - // grand_child_of_rs2 - AddAnimatedTransformToLayerWithPlayer(grand_child_of_root->id(), - timeline_impl(), 10.0, 30, 0); - AddAnimatedTransformToLayerWithPlayer(grand_child_of_rs2->id(), - timeline_impl(), 10.0, 30, 0); - } else { - // Put an animated opacity on the render surface. - AddOpacityTransitionToController( - render_surface1->layer_animation_controller(), 10.0, 1.f, 0.f, false); - - // Also put an animated opacity on a layer without descendants. - AddOpacityTransitionToController( - grand_child_of_root->layer_animation_controller(), 10.0, 1.f, 0.f, - false); - - // Put a transform animation on the render surface. - AddAnimatedTransformToController( - render_surface2->layer_animation_controller(), 10.0, 30, 0); - - // Also put transform animations on grand_child_of_root, and - // grand_child_of_rs2 - AddAnimatedTransformToController( - grand_child_of_root->layer_animation_controller(), 10.0, 30, 0); - AddAnimatedTransformToController( - grand_child_of_rs2->layer_animation_controller(), 10.0, 30, 0); - } + // Put an animated opacity on the render surface. + AddOpacityTransitionToLayerWithPlayer(render_surface1->id(), timeline_impl(), + 10.0, 1.f, 0.f, false); + + // Also put an animated opacity on a layer without descendants. + AddOpacityTransitionToLayerWithPlayer(grand_child_of_root->id(), + timeline_impl(), 10.0, 1.f, 0.f, false); + + // Put a transform animation on the render surface. + AddAnimatedTransformToLayerWithPlayer(render_surface2->id(), timeline_impl(), + 10.0, 30, 0); + + // Also put transform animations on grand_child_of_root, and + // grand_child_of_rs2 + AddAnimatedTransformToLayerWithPlayer(grand_child_of_root->id(), + timeline_impl(), 10.0, 30, 0); + AddAnimatedTransformToLayerWithPlayer(grand_child_of_rs2->id(), + timeline_impl(), 10.0, 30, 0); ExecuteCalculateDrawProperties(parent); @@ -2673,13 +2651,8 @@ TEST_F(LayerTreeHostCommonTest, TargetProperty::TRANSFORM); animation->set_fill_mode(Animation::FILL_MODE_NONE); animation->set_time_offset(base::TimeDelta::FromMilliseconds(-1000)); - if (layer_settings().use_compositor_animation_timelines) { - AddAnimationToLayerWithPlayer(grand_child->id(), timeline_impl(), - std::move(animation)); - } else { - grand_child->layer_animation_controller()->AddAnimation( - std::move(animation)); - } + AddAnimationToLayerWithPlayer(grand_child->id(), timeline_impl(), + std::move(animation)); ExecuteCalculateDrawProperties(parent); EXPECT_FALSE(parent->screen_space_transform_is_animating()); @@ -3621,14 +3594,9 @@ TEST_F(LayerTreeHostCommonTest, TransformOperations end_transform_operations; end_transform_operations.AppendScale(1.f, 1.f, 0.f); - if (layer_settings().use_compositor_animation_timelines) { - AddAnimatedTransformToLayerWithPlayer(root->id(), timeline(), 10.0, - start_transform_operations, - end_transform_operations); - } else { - AddAnimatedTransformToLayer(root.get(), 10.0, start_transform_operations, - end_transform_operations); - } + AddAnimatedTransformToLayerWithPlayer(root->id(), timeline(), 10.0, + start_transform_operations, + end_transform_operations); EXPECT_TRUE(root->TransformIsAnimating()); ExecuteCalculateDrawProperties(root.get()); @@ -4536,21 +4504,12 @@ TEST_F(LayerTreeHostCommonTest, BackFaceCullingWithAnimatingTransforms) { // Make our render surface. animating_surface->SetForceRenderSurface(true); - if (layer_settings().use_compositor_animation_timelines) { - // Animate the transform on the render surface. - AddAnimatedTransformToLayerWithPlayer(animating_surface->id(), timeline(), - 10.0, 30, 0); - // This is just an animating layer, not a surface. - AddAnimatedTransformToLayerWithPlayer(animating_child->id(), timeline(), - 10.0, 30, 0); - } else { - // Animate the transform on the render surface. - AddAnimatedTransformToController( - animating_surface->layer_animation_controller(), 10.0, 30, 0); - // This is just an animating layer, not a surface. - AddAnimatedTransformToController( - animating_child->layer_animation_controller(), 10.0, 30, 0); - } + // Animate the transform on the render surface. + AddAnimatedTransformToLayerWithPlayer(animating_surface->id(), timeline(), + 10.0, 30, 0); + // This is just an animating layer, not a surface. + AddAnimatedTransformToLayerWithPlayer(animating_child->id(), timeline(), 10.0, + 30, 0); SetLayerPropertiesForTesting(parent.get(), identity_matrix, @@ -5236,17 +5195,12 @@ TEST_F(LayerTreeHostCommonTest, OpacityAnimatingOnPendingTree) { child->SetOpacity(0.0f); // Add opacity animation. - if (layer_settings().use_compositor_animation_timelines) { - scoped_refptr<AnimationTimeline> timeline = - AnimationTimeline::Create(AnimationIdProvider::NextTimelineId()); - host_impl.animation_host()->AddAnimationTimeline(timeline); + scoped_refptr<AnimationTimeline> timeline = + AnimationTimeline::Create(AnimationIdProvider::NextTimelineId()); + host_impl.animation_host()->AddAnimationTimeline(timeline); - AddOpacityTransitionToLayerWithPlayer(child->id(), timeline, 10.0, 0.0f, - 1.0f, false); - } else { - AddOpacityTransitionToController(child->layer_animation_controller(), 10.0, - 0.0f, 1.0f, false); - } + AddOpacityTransitionToLayerWithPlayer(child->id(), timeline, 10.0, 0.0f, 1.0f, + false); root->AddChild(std::move(child)); root->SetHasRenderSurface(true); @@ -5326,11 +5280,9 @@ class LCDTextTest : public LayerTreeHostCommonTestBase, protected: void SetUp() override { - if (layer_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_); can_use_lcd_text_ = std::tr1::get<0>(GetParam()); layers_always_allowed_lcd_text_ = std::tr1::get<1>(GetParam()); @@ -5503,13 +5455,8 @@ TEST_P(LCDTextTest, CanUseLCDTextWithAnimation) { // Add opacity animation. child_->SetOpacity(0.9f); child_->layer_tree_impl()->property_trees()->needs_rebuild = true; - if (layer_settings().use_compositor_animation_timelines) { - AddOpacityTransitionToLayerWithPlayer(child_->id(), timeline(), 10.0, 0.9f, - 0.1f, false); - } else { - AddOpacityTransitionToController(child_->layer_animation_controller(), 10.0, - 0.9f, 0.1f, false); - } + AddOpacityTransitionToLayerWithPlayer(child_->id(), timeline(), 10.0, 0.9f, + 0.1f, false); ExecuteCalculateDrawProperties(root_, 1.f, 1.f, NULL, can_use_lcd_text_, layers_always_allowed_lcd_text_); // Text LCD should be adjusted while animation is active. @@ -5531,13 +5478,8 @@ TEST_P(LCDTextTest, CanUseLCDTextWithAnimationContentsOpaque) { // Mark contents non-opaque within the first animation frame. child_->SetContentsOpaque(false); - if (layer_settings().use_compositor_animation_timelines) { - AddOpacityTransitionToLayerWithPlayer(child_->id(), timeline(), 10.0, 0.9f, - 0.1f, false); - } else { - AddOpacityTransitionToController(child_->layer_animation_controller(), 10.0, - 0.9f, 0.1f, false); - } + AddOpacityTransitionToLayerWithPlayer(child_->id(), timeline(), 10.0, 0.9f, + 0.1f, false); ExecuteCalculateDrawProperties(root_, 1.f, 1.f, NULL, can_use_lcd_text_, layers_always_allowed_lcd_text_); // LCD text should be disabled for non-opaque layers even during animations. @@ -7393,14 +7335,8 @@ TEST_F(LayerTreeHostCommonTest, start_operations.AppendMatrix(start_scale); TransformOperations end_operations; end_operations.AppendMatrix(end_scale); - if (layer_settings().use_compositor_animation_timelines) { - AddAnimatedTransformToLayerWithPlayer(animated_layer->id(), timeline_impl(), - 1.0, start_operations, - end_operations); - } else { - AddAnimatedTransformToLayer(animated_layer, 1.0, start_operations, - end_operations); - } + AddAnimatedTransformToLayerWithPlayer(animated_layer->id(), timeline_impl(), + 1.0, start_operations, end_operations); gfx::Vector2dF scroll_delta(5.f, 9.f); SetScrollOffsetDelta(scroller, scroll_delta); @@ -7495,16 +7431,11 @@ TEST_F(LayerTreeHostCommonTest, MaximumAnimationScaleFactor) { translation.AppendTranslate(1.f, 2.f, 3.f); scoped_refptr<AnimationTimeline> timeline; - if (layer_settings().use_compositor_animation_timelines) { - timeline = AnimationTimeline::Create(AnimationIdProvider::NextTimelineId()); - host_impl.animation_host()->AddAnimationTimeline(timeline); - - AddAnimatedTransformToLayerWithPlayer(parent_raw->id(), timeline, 1.0, - TransformOperations(), translation); - } else { - AddAnimatedTransformToLayer(parent_raw, 1.0, TransformOperations(), - translation); - } + timeline = AnimationTimeline::Create(AnimationIdProvider::NextTimelineId()); + host_impl.animation_host()->AddAnimationTimeline(timeline); + + AddAnimatedTransformToLayerWithPlayer(parent_raw->id(), timeline, 1.0, + TransformOperations(), translation); // No layers have scale-affecting animations. EXPECT_EQ(0.f, @@ -7528,12 +7459,8 @@ TEST_F(LayerTreeHostCommonTest, MaximumAnimationScaleFactor) { TransformOperations scale; scale.AppendScale(5.f, 4.f, 3.f); - if (layer_settings().use_compositor_animation_timelines) { - AddAnimatedTransformToLayerWithPlayer(child_raw->id(), timeline, 1.0, - TransformOperations(), scale); - } else { - AddAnimatedTransformToLayer(child_raw, 1.0, TransformOperations(), scale); - } + AddAnimatedTransformToLayerWithPlayer(child_raw->id(), timeline, 1.0, + TransformOperations(), scale); child_raw->layer_tree_impl()->property_trees()->needs_rebuild = true; ExecuteCalculateDrawProperties(grand_parent.get()); @@ -7556,13 +7483,8 @@ TEST_F(LayerTreeHostCommonTest, MaximumAnimationScaleFactor) { 1.f, grand_child_raw->draw_properties().starting_animation_contents_scale); - if (layer_settings().use_compositor_animation_timelines) { - AddAnimatedTransformToLayerWithPlayer(grand_parent->id(), timeline, 1.0, - TransformOperations(), scale); - } else { - AddAnimatedTransformToLayer(grand_parent.get(), 1.0, TransformOperations(), - scale); - } + AddAnimatedTransformToLayerWithPlayer(grand_parent->id(), timeline, 1.0, + TransformOperations(), scale); grand_parent->layer_tree_impl()->property_trees()->needs_rebuild = true; ExecuteCalculateDrawProperties(grand_parent.get()); @@ -7587,12 +7509,8 @@ TEST_F(LayerTreeHostCommonTest, MaximumAnimationScaleFactor) { 0.f, grand_child_raw->draw_properties().starting_animation_contents_scale); - if (layer_settings().use_compositor_animation_timelines) { - AddAnimatedTransformToLayerWithPlayer(parent_raw->id(), timeline, 1.0, - TransformOperations(), scale); - } else { - AddAnimatedTransformToLayer(parent_raw, 1.0, TransformOperations(), scale); - } + AddAnimatedTransformToLayerWithPlayer(parent_raw->id(), timeline, 1.0, + TransformOperations(), scale); parent_raw->layer_tree_impl()->property_trees()->needs_rebuild = true; ExecuteCalculateDrawProperties(grand_parent.get()); @@ -7615,32 +7533,18 @@ TEST_F(LayerTreeHostCommonTest, MaximumAnimationScaleFactor) { 0.f, grand_child_raw->draw_properties().starting_animation_contents_scale); - if (layer_settings().use_compositor_animation_timelines) { - AbortAnimationsOnLayerWithPlayer(grand_parent->id(), timeline, - TargetProperty::TRANSFORM); - AbortAnimationsOnLayerWithPlayer(parent_raw->id(), timeline, - TargetProperty::TRANSFORM); - AbortAnimationsOnLayerWithPlayer(child_raw->id(), timeline, - TargetProperty::TRANSFORM); - } else { - grand_parent->layer_animation_controller()->AbortAnimations( - TargetProperty::TRANSFORM); - parent_raw->layer_animation_controller()->AbortAnimations( - TargetProperty::TRANSFORM); - child_raw->layer_animation_controller()->AbortAnimations( - TargetProperty::TRANSFORM); - } + AbortAnimationsOnLayerWithPlayer(grand_parent->id(), timeline, + TargetProperty::TRANSFORM); + AbortAnimationsOnLayerWithPlayer(parent_raw->id(), timeline, + TargetProperty::TRANSFORM); + AbortAnimationsOnLayerWithPlayer(child_raw->id(), timeline, + TargetProperty::TRANSFORM); TransformOperations perspective; perspective.AppendPerspective(10.f); - if (layer_settings().use_compositor_animation_timelines) { - AddAnimatedTransformToLayerWithPlayer(child_raw->id(), timeline, 1.0, - TransformOperations(), perspective); - } else { - AddAnimatedTransformToLayer(child_raw, 1.0, TransformOperations(), - perspective); - } + AddAnimatedTransformToLayerWithPlayer(child_raw->id(), timeline, 1.0, + TransformOperations(), perspective); child_raw->layer_tree_impl()->property_trees()->needs_rebuild = true; ExecuteCalculateDrawProperties(grand_parent.get()); @@ -7664,25 +7568,16 @@ TEST_F(LayerTreeHostCommonTest, MaximumAnimationScaleFactor) { 0.f, grand_child_raw->draw_properties().starting_animation_contents_scale); - if (layer_settings().use_compositor_animation_timelines) { - AbortAnimationsOnLayerWithPlayer(child_raw->id(), timeline, - TargetProperty::TRANSFORM); - } else { - child_raw->layer_animation_controller()->AbortAnimations( - TargetProperty::TRANSFORM); - } + AbortAnimationsOnLayerWithPlayer(child_raw->id(), timeline, + TargetProperty::TRANSFORM); gfx::Transform scale_matrix; scale_matrix.Scale(1.f, 2.f); grand_parent->SetTransform(scale_matrix); parent_raw->SetTransform(scale_matrix); grand_parent->layer_tree_impl()->property_trees()->needs_rebuild = true; - if (layer_settings().use_compositor_animation_timelines) { - AddAnimatedTransformToLayerWithPlayer(parent_raw->id(), timeline, 1.0, - TransformOperations(), scale); - } else { - AddAnimatedTransformToLayer(parent_raw, 1.0, TransformOperations(), scale); - } + AddAnimatedTransformToLayerWithPlayer(parent_raw->id(), timeline, 1.0, + TransformOperations(), scale); ExecuteCalculateDrawProperties(grand_parent.get()); // |grand_parent| and |parent| each have scale 2.f. |parent| has a scale @@ -8103,17 +7998,12 @@ TEST_F(LayerTreeHostCommonTest, DrawPropertyScales) { TransformOperations scale; scale.AppendScale(5.f, 8.f, 3.f); - if (layer_settings().use_compositor_animation_timelines) { - scoped_refptr<AnimationTimeline> timeline = - AnimationTimeline::Create(AnimationIdProvider::NextTimelineId()); - host_impl.animation_host()->AddAnimationTimeline(timeline); + scoped_refptr<AnimationTimeline> timeline = + AnimationTimeline::Create(AnimationIdProvider::NextTimelineId()); + host_impl.animation_host()->AddAnimationTimeline(timeline); - AddAnimatedTransformToLayerWithPlayer(child2_layer->id(), timeline, 1.0, - TransformOperations(), scale); - } else { - AddAnimatedTransformToLayer(child2_layer, 1.0, TransformOperations(), - scale); - } + AddAnimatedTransformToLayerWithPlayer(child2_layer->id(), timeline, 1.0, + TransformOperations(), scale); SetLayerPropertiesForTesting(child2_layer, scale_transform_child2, gfx::Point3F(), gfx::PointF(), gfx::Size(1, 1), @@ -8420,13 +8310,8 @@ TEST_F(LayerTreeHostCommonTest, VisibleContentRectForAnimatedLayer) { root->SetForceRenderSurface(true); animated->SetOpacity(0.f); - if (layer_settings().use_compositor_animation_timelines) { - AddOpacityTransitionToLayerWithPlayer(animated->id(), timeline(), 10.0, 0.f, - 1.f, false); - } else { - AddOpacityTransitionToController(animated->layer_animation_controller(), - 10.0, 0.f, 1.f, false); - } + AddOpacityTransitionToLayerWithPlayer(animated->id(), timeline(), 10.0, 0.f, + 1.f, false); ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); EXPECT_FALSE(animated->visible_layer_rect().IsEmpty()); @@ -8474,15 +8359,9 @@ TEST_F(LayerTreeHostCommonTest, start_transform_operations.AppendMatrix(uninvertible_matrix); TransformOperations end_transform_operations; - if (layer_settings().use_compositor_animation_timelines) { - AddAnimatedTransformToLayerWithPlayer(animated->id(), timeline(), 10.0, - start_transform_operations, - end_transform_operations); - } else { - AddAnimatedTransformToLayer(animated.get(), 10.0, - start_transform_operations, - end_transform_operations); - } + AddAnimatedTransformToLayerWithPlayer(animated->id(), timeline(), 10.0, + start_transform_operations, + end_transform_operations); ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); // The animated layer has a singular transform and maps to a non-empty rect in @@ -8531,12 +8410,7 @@ TEST_F(LayerTreeHostCommonTest, AnimatedFilterCreatesRenderSurface) { true, false); host()->SetRootLayer(root); - if (layer_settings().use_compositor_animation_timelines) { - AddAnimatedFilterToLayerWithPlayer(child->id(), timeline(), 10.0, 0.1f, - 0.2f); - } else { - AddAnimatedFilterToLayer(child.get(), 10.0, 0.1f, 0.2f); - } + AddAnimatedFilterToLayerWithPlayer(child->id(), timeline(), 10.0, 0.1f, 0.2f); ExecuteCalculateDrawProperties(root.get()); EXPECT_TRUE(root->has_render_surface()); @@ -8586,12 +8460,7 @@ TEST_F(LayerTreeHostCommonTest, DelayedFilterAnimationCreatesRenderSurface) { animation->set_fill_mode(Animation::FILL_MODE_NONE); animation->set_time_offset(base::TimeDelta::FromMilliseconds(-1000)); - if (layer_settings().use_compositor_animation_timelines) { - AddAnimationToLayerWithPlayer(child->id(), timeline(), - std::move(animation)); - } else { - child->layer_animation_controller()->AddAnimation(std::move(animation)); - } + AddAnimationToLayerWithPlayer(child->id(), timeline(), std::move(animation)); ExecuteCalculateDrawProperties(root.get()); EXPECT_TRUE(root->has_render_surface()); @@ -9062,22 +8931,13 @@ TEST_F(LayerTreeHostCommonTest, SkippingSubtreeMain) { animation_id, 1, TargetProperty::TRANSFORM); animation->set_fill_mode(Animation::FILL_MODE_NONE); animation->set_time_offset(base::TimeDelta::FromMilliseconds(-1000)); - if (layer_settings().use_compositor_animation_timelines) { - AddAnimationToLayerWithPlayer(child->id(), timeline(), - std::move(animation)); - } else { - child->AddAnimation(std::move(animation)); - } + AddAnimationToLayerWithPlayer(child->id(), timeline(), std::move(animation)); ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); EXPECT_EQ(gfx::Rect(10, 10), grandchild->visible_layer_rect()); grandchild->set_visible_layer_rect(gfx::Rect()); - if (layer_settings().use_compositor_animation_timelines) { - RemoveAnimationFromLayerWithExistingPlayer(child->id(), timeline(), - animation_id); - } else { - child->RemoveAnimation(animation_id); - } + RemoveAnimationFromLayerWithExistingPlayer(child->id(), timeline(), + animation_id); child->SetTransform(identity); child->SetOpacity(0.f); ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); @@ -9099,12 +8959,8 @@ TEST_F(LayerTreeHostCommonTest, SkippingSubtreeMain) { animation_id, 1, TargetProperty::OPACITY); animation->set_fill_mode(Animation::FILL_MODE_NONE); animation->set_time_offset(base::TimeDelta::FromMilliseconds(-1000)); - if (layer_settings().use_compositor_animation_timelines) { - AddAnimationToLayerWithExistingPlayer(child->id(), timeline(), - std::move(animation)); - } else { - child->AddAnimation(std::move(animation)); - } + AddAnimationToLayerWithExistingPlayer(child->id(), timeline(), + std::move(animation)); ExecuteCalculateDrawPropertiesWithPropertyTrees(root.get()); EXPECT_EQ(gfx::Rect(10, 10), grandchild->visible_layer_rect()); } diff --git a/cc/trees/layer_tree_host_impl.cc b/cc/trees/layer_tree_host_impl.cc index 19febba..7bda114 100644 --- a/cc/trees/layer_tree_host_impl.cc +++ b/cc/trees/layer_tree_host_impl.cc @@ -24,8 +24,6 @@ #include "base/trace_event/trace_event_argument.h" #include "cc/animation/animation_events.h" #include "cc/animation/animation_host.h" -#include "cc/animation/animation_id_provider.h" -#include "cc/animation/scroll_offset_animation_curve.h" #include "cc/animation/timing_function.h" #include "cc/base/histograms.h" #include "cc/base/math_util.h" @@ -224,7 +222,7 @@ LayerTreeHostImpl::LayerTreeHostImpl( texture_mailbox_deleter_(new TextureMailboxDeleter(GetTaskRunner())), max_memory_needed_bytes_(0), resourceless_software_draw_(false), - animation_registrar_(), + animation_host_(), rendering_stats_instrumentation_(rendering_stats_instrumentation), micro_benchmark_controller_(this), shared_bitmap_manager_(shared_bitmap_manager), @@ -234,16 +232,10 @@ LayerTreeHostImpl::LayerTreeHostImpl( requires_high_res_to_draw_(false), is_likely_to_require_a_draw_(false), frame_timing_tracker_(FrameTimingTracker::Create(this)) { - if (settings.use_compositor_animation_timelines) { - if (settings.accelerated_animation_enabled) { - animation_host_ = AnimationHost::Create(ThreadInstance::IMPL); - animation_host_->SetMutatorHostClient(this); - animation_host_->SetSupportsScrollAnimations(SupportsImplScrolling()); - } - } else { - animation_registrar_ = AnimationRegistrar::Create(); - animation_registrar_->set_supports_scroll_animations( - SupportsImplScrolling()); + if (settings.accelerated_animation_enabled) { + animation_host_ = AnimationHost::Create(ThreadInstance::IMPL); + animation_host_->SetMutatorHostClient(this); + animation_host_->SetSupportsScrollAnimations(SupportsImplScrolling()); } DCHECK(task_runner_provider_->IsImplThread()); @@ -1661,9 +1653,7 @@ void LayerTreeHostImpl::DrawLayers(FrameData* frame) { if (draw_mode == DRAW_MODE_RESOURCELESS_SOFTWARE) { bool disable_picture_quad_image_filtering = - IsActivelyScrolling() || - (animation_host_ ? animation_host_->NeedsAnimateLayers() - : animation_registrar_->needs_animate_layers()); + IsActivelyScrolling() || animation_host_->NeedsAnimateLayers(); scoped_ptr<SoftwareRenderer> temp_software_renderer = SoftwareRenderer::Create(this, &settings_.renderer_settings, @@ -3363,13 +3353,8 @@ bool LayerTreeHostImpl::AnimateLayers(base::TimeTicks monotonic_time) { return false; bool animated = false; - if (animation_host_) { - if (animation_host_->AnimateLayers(monotonic_time)) - animated = true; - } else { - if (animation_registrar_->AnimateLayers(monotonic_time)) - animated = true; - } + if (animation_host_->AnimateLayers(monotonic_time)) + animated = true; // TODO(crbug.com/551134): Only do this if the animations are on the active // tree, or if they are on the pending tree waiting for some future time to @@ -3392,15 +3377,9 @@ void LayerTreeHostImpl::UpdateAnimationState(bool start_ready_animations) { bool has_active_animations = false; scoped_ptr<AnimationEvents> events; - if (animation_host_) { - events = animation_host_->CreateEvents(); - has_active_animations = animation_host_->UpdateAnimationState( - start_ready_animations, events.get()); - } else { - events = animation_registrar_->CreateEvents(); - has_active_animations = animation_registrar_->UpdateAnimationState( - start_ready_animations, events.get()); - } + events = animation_host_->CreateEvents(); + has_active_animations = animation_host_->UpdateAnimationState( + start_ready_animations, events.get()); if (!events->events_.empty()) client_->PostAnimationEventsToMainThreadOnImplThread(std::move(events)); @@ -3413,15 +3392,7 @@ void LayerTreeHostImpl::ActivateAnimations() { if (!settings_.accelerated_animation_enabled) return; - bool activated = false; - if (animation_host_) { - if (animation_host_->ActivateAnimations()) - activated = true; - } else { - if (animation_registrar_->ActivateAnimations()) - activated = true; - } - + const bool activated = animation_host_->ActivateAnimations(); if (activated) { // Activating an animation changes layer draw properties, such as // screen_space_transform_is_animating. So when we see a new animation get @@ -3737,71 +3708,25 @@ void LayerTreeHostImpl::UpdateRootLayerStateForSynchronousInputHandler() { } void LayerTreeHostImpl::ScrollAnimationAbort(LayerImpl* layer_impl) { - if (animation_host_) - return animation_host_->ScrollAnimationAbort(false /* needs_completion */); - - layer_impl->layer_animation_controller()->AbortAnimations( - TargetProperty::SCROLL_OFFSET); + return animation_host_->ScrollAnimationAbort(false /* needs_completion */); } void LayerTreeHostImpl::ScrollAnimationCreate( ScrollNode* scroll_node, const gfx::ScrollOffset& target_offset, const gfx::ScrollOffset& current_offset) { - if (animation_host_) - return animation_host_->ImplOnlyScrollAnimationCreate( - scroll_node->owner_id, target_offset, current_offset); - - LayerImpl* layer_impl = active_tree_->LayerById(scroll_node->owner_id); - - scoped_ptr<ScrollOffsetAnimationCurve> curve = - ScrollOffsetAnimationCurve::Create( - target_offset, EaseInOutTimingFunction::Create(), - ScrollOffsetAnimationCurve::DurationBehavior::INVERSE_DELTA); - curve->SetInitialValue(current_offset); - - scoped_ptr<Animation> animation = Animation::Create( - std::move(curve), AnimationIdProvider::NextAnimationId(), - AnimationIdProvider::NextGroupId(), TargetProperty::SCROLL_OFFSET); - animation->set_is_impl_only(true); - - layer_impl->layer_animation_controller()->AddAnimation(std::move(animation)); + return animation_host_->ImplOnlyScrollAnimationCreate( + scroll_node->owner_id, target_offset, current_offset); } bool LayerTreeHostImpl::ScrollAnimationUpdateTarget( ScrollNode* scroll_node, const gfx::Vector2dF& scroll_delta) { - if (animation_host_) - return animation_host_->ImplOnlyScrollAnimationUpdateTarget( - scroll_node->owner_id, scroll_delta, - active_tree_->property_trees()->scroll_tree.MaxScrollOffset( - scroll_node->id), - CurrentBeginFrameArgs().frame_time); - - LayerImpl* layer_impl = active_tree_->LayerById(scroll_node->owner_id); - - Animation* animation = - layer_impl->layer_animation_controller() - ? layer_impl->layer_animation_controller()->GetAnimation( - TargetProperty::SCROLL_OFFSET) - : nullptr; - if (!animation) - return false; - - ScrollOffsetAnimationCurve* curve = - animation->curve()->ToScrollOffsetAnimationCurve(); - - gfx::ScrollOffset new_target = - gfx::ScrollOffsetWithDelta(curve->target_value(), scroll_delta); - new_target.SetToMax(gfx::ScrollOffset()); - new_target.SetToMin(layer_impl->MaxScrollOffset()); - - curve->UpdateTarget( - animation->TrimTimeToCurrentIteration(CurrentBeginFrameArgs().frame_time) - .InSecondsF(), - new_target); - - return true; + return animation_host_->ImplOnlyScrollAnimationUpdateTarget( + scroll_node->owner_id, scroll_delta, + active_tree_->property_trees()->scroll_tree.MaxScrollOffset( + scroll_node->id), + CurrentBeginFrameArgs().frame_time); } bool LayerTreeHostImpl::IsLayerInTree(int layer_id, @@ -3830,7 +3755,7 @@ void LayerTreeHostImpl::SetTreeLayerFilterMutated( if (!tree) return; - LayerAnimationValueObserver* layer = tree->LayerById(layer_id); + LayerImpl* layer = tree->LayerById(layer_id); if (layer) layer->OnFilterAnimated(filters); } @@ -3841,7 +3766,7 @@ void LayerTreeHostImpl::SetTreeLayerOpacityMutated(int layer_id, if (!tree) return; - LayerAnimationValueObserver* layer = tree->LayerById(layer_id); + LayerImpl* layer = tree->LayerById(layer_id); if (layer) layer->OnOpacityAnimated(opacity); } @@ -3853,7 +3778,7 @@ void LayerTreeHostImpl::SetTreeLayerTransformMutated( if (!tree) return; - LayerAnimationValueObserver* layer = tree->LayerById(layer_id); + LayerImpl* layer = tree->LayerById(layer_id); if (layer) layer->OnTransformAnimated(transform); } @@ -3865,7 +3790,7 @@ void LayerTreeHostImpl::SetTreeLayerScrollOffsetMutated( if (!tree) return; - LayerAnimationValueObserver* layer = tree->LayerById(layer_id); + LayerImpl* layer = tree->LayerById(layer_id); if (layer) layer->OnScrollOffsetAnimated(scroll_offset); } @@ -3877,7 +3802,7 @@ void LayerTreeHostImpl::TreeLayerTransformIsPotentiallyAnimatingChanged( if (!tree) return; - LayerAnimationValueObserver* layer = tree->LayerById(layer_id); + LayerImpl* layer = tree->LayerById(layer_id); if (layer) layer->OnTransformIsPotentiallyAnimatingChanged(is_animating); } @@ -3958,7 +3883,7 @@ void LayerTreeHostImpl::ScrollOffsetAnimationFinished() { gfx::ScrollOffset LayerTreeHostImpl::GetScrollOffsetForAnimation( int layer_id) const { if (active_tree()) { - LayerAnimationValueProvider* layer = active_tree()->LayerById(layer_id); + LayerImpl* layer = active_tree()->LayerById(layer_id); if (layer) return layer->ScrollOffsetForAnimation(); } diff --git a/cc/trees/layer_tree_host_impl.h b/cc/trees/layer_tree_host_impl.h index 6d1212f..359a436 100644 --- a/cc/trees/layer_tree_host_impl.h +++ b/cc/trees/layer_tree_host_impl.h @@ -15,7 +15,6 @@ #include "base/macros.h" #include "base/memory/scoped_ptr.h" #include "base/time/time.h" -#include "cc/animation/animation_registrar.h" #include "cc/base/cc_export.h" #include "cc/base/synced_property.h" #include "cc/debug/frame_timing_tracker.h" @@ -490,9 +489,6 @@ class CC_EXPORT LayerTreeHostImpl return task_runner_provider_; } - AnimationRegistrar* animation_registrar() const { - return animation_registrar_.get(); - } AnimationHost* animation_host() const { return animation_host_.get(); } void SetDebugState(const LayerTreeDebugState& new_debug_state); @@ -812,7 +808,6 @@ class CC_EXPORT LayerTreeHostImpl gfx::Rect viewport_damage_rect_; - scoped_ptr<AnimationRegistrar> animation_registrar_; scoped_ptr<AnimationHost> animation_host_; std::set<VideoFrameController*> video_frame_controllers_; diff --git a/cc/trees/layer_tree_host_impl_unittest.cc b/cc/trees/layer_tree_host_impl_unittest.cc index 46b98cf..370c1b2 100644 --- a/cc/trees/layer_tree_host_impl_unittest.cc +++ b/cc/trees/layer_tree_host_impl_unittest.cc @@ -209,11 +209,9 @@ class LayerTreeHostImplTest : public testing::Test, base::TimeTicks() + base::TimeDelta::FromMilliseconds(1))); host_impl_->DidFinishImplFrame(); - 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_); return init; } @@ -1227,11 +1225,7 @@ TEST_F(LayerTreeHostImplTest, AnimationSchedulingPendingTree) { child->SetBounds(gfx::Size(10, 10)); child->draw_properties().visible_layer_rect = gfx::Rect(10, 10); child->SetDrawsContent(true); - if (host_impl_->settings().use_compositor_animation_timelines) { - AddAnimatedTransformToLayerWithPlayer(child->id(), timeline(), 10.0, 3, 0); - } else { - AddAnimatedTransformToLayer(child, 10.0, 3, 0); - } + AddAnimatedTransformToLayerWithPlayer(child->id(), timeline(), 10.0, 3, 0); EXPECT_FALSE(did_request_next_frame_); EXPECT_FALSE(did_request_redraw_); @@ -1287,12 +1281,8 @@ TEST_F(LayerTreeHostImplTest, AnimationSchedulingActiveTree) { start.AppendTranslate(6.f, 7.f, 0.f); TransformOperations end; end.AppendTranslate(8.f, 9.f, 0.f); - if (host_impl_->settings().use_compositor_animation_timelines) { - AddAnimatedTransformToLayerWithPlayer(child->id(), timeline(), 4.0, start, - end); - } else { - AddAnimatedTransformToLayer(child, 4.0, start, end); - } + AddAnimatedTransformToLayerWithPlayer(child->id(), timeline(), 4.0, start, + end); base::TimeTicks now = base::TimeTicks::Now(); host_impl_->WillBeginImplFrame( @@ -1349,11 +1339,7 @@ TEST_F(LayerTreeHostImplTest, AnimationSchedulingCommitToActiveTree) { child->SetBounds(gfx::Size(10, 10)); child->draw_properties().visible_layer_rect = gfx::Rect(10, 10); child->SetDrawsContent(true); - if (host_impl_->settings().use_compositor_animation_timelines) { - AddAnimatedTransformToLayerWithPlayer(child->id(), timeline(), 10.0, 3, 0); - } else { - AddAnimatedTransformToLayer(child, 10.0, 3, 0); - } + AddAnimatedTransformToLayerWithPlayer(child->id(), timeline(), 10.0, 3, 0); // Set up the property trees so that UpdateDrawProperties will work in // CommitComplete below. @@ -1420,13 +1406,8 @@ TEST_F(LayerTreeHostImplTest, AnimationMarksLayerNotReady) { start.AppendTranslate(6.f, 7.f, 0.f); TransformOperations end; end.AppendTranslate(8.f, 9.f, 0.f); - int animation_id; - if (host_impl_->settings().use_compositor_animation_timelines) { - animation_id = AddAnimatedTransformToLayerWithPlayer( - child->id(), timeline(), 4.0, start, end); - } else { - animation_id = AddAnimatedTransformToLayer(child, 4.0, start, end); - } + int animation_id = AddAnimatedTransformToLayerWithPlayer( + child->id(), timeline(), 4.0, start, end); base::TimeTicks now = base::TimeTicks::Now(); host_impl_->WillBeginImplFrame( @@ -1457,12 +1438,8 @@ TEST_F(LayerTreeHostImplTest, AnimationMarksLayerNotReady) { // Remove the animation. child->set_has_missing_tiles(true); - if (host_impl_->settings().use_compositor_animation_timelines) { - RemoveAnimationFromLayerWithExistingPlayer(child->id(), timeline(), - animation_id); - } else { - child->layer_animation_controller()->RemoveAnimation(animation_id); - } + RemoveAnimationFromLayerWithExistingPlayer(child->id(), timeline(), + animation_id); child->draw_properties().screen_space_transform_is_animating = false; // Child layer doesn't have an animation, but was never ready since the last @@ -3458,13 +3435,8 @@ class MissingTextureAnimatingLayer : public DidDrawCheckLayer { : DidDrawCheckLayer(tree_impl, id), tile_missing_(tile_missing), had_incomplete_tile_(had_incomplete_tile) { - if (animating) { - if (tree_impl->settings().use_compositor_animation_timelines) { - AddAnimatedTransformToLayerWithPlayer(this->id(), timeline, 10.0, 3, 0); - } else { - AddAnimatedTransformToLayer(this, 10.0, 3, 0); - } - } + if (animating) + AddAnimatedTransformToLayerWithPlayer(this->id(), timeline, 10.0, 3, 0); } bool tile_missing_; @@ -3580,8 +3552,7 @@ TEST_F(LayerTreeHostImplTest, PrepareToDrawSucceedsAndFails) { to_remove.push_back(child.get()); for (auto* child : to_remove) root->RemoveChild(child); - if (host_impl_->settings().use_compositor_animation_timelines) - timeline()->ClearPlayers(); + timeline()->ClearPlayers(); std::ostringstream scope; scope << "Test case: " << i; diff --git a/cc/trees/layer_tree_host_unittest_animation.cc b/cc/trees/layer_tree_host_unittest_animation.cc index cff38e5..54088ee 100644 --- a/cc/trees/layer_tree_host_unittest_animation.cc +++ b/cc/trees/layer_tree_host_unittest_animation.cc @@ -10,6 +10,7 @@ #include "cc/animation/animation_host.h" #include "cc/animation/animation_id_provider.h" #include "cc/animation/animation_player.h" +#include "cc/animation/animation_registrar.h" #include "cc/animation/animation_timeline.h" #include "cc/animation/element_animations.h" #include "cc/animation/layer_animation_controller.h" diff --git a/cc/trees/layer_tree_impl.cc b/cc/trees/layer_tree_impl.cc index e9f11da..ec65108 100644 --- a/cc/trees/layer_tree_impl.cc +++ b/cc/trees/layer_tree_impl.cc @@ -1193,10 +1193,6 @@ void LayerTreeImpl::SetNeedsRedraw() { layer_tree_host_impl_->SetNeedsRedraw(); } -AnimationRegistrar* LayerTreeImpl::GetAnimationRegistrar() const { - return layer_tree_host_impl_->animation_registrar(); -} - void LayerTreeImpl::GetAllPrioritizedTilesForTracing( std::vector<PrioritizedTile>* prioritized_tiles) const { LayerIterator end = LayerIterator::End(&render_surface_layer_list_); @@ -1869,13 +1865,6 @@ void LayerTreeImpl::GetViewportSelection(ViewportSelection* selection) { } } -void LayerTreeImpl::InputScrollAnimationFinished() { - // TODO(majidvp): We should pass in the original starting scroll position here - ScrollStateData scroll_state_data; - ScrollState scroll_state(scroll_state_data); - layer_tree_host_impl_->ScrollEnd(&scroll_state); -} - bool LayerTreeImpl::SmoothnessTakesPriority() const { return layer_tree_host_impl_->GetTreePriority() == SMOOTHNESS_TAKES_PRIORITY; } diff --git a/cc/trees/layer_tree_impl.h b/cc/trees/layer_tree_impl.h index 57523f9..c6c1cae 100644 --- a/cc/trees/layer_tree_impl.h +++ b/cc/trees/layer_tree_impl.h @@ -108,7 +108,6 @@ class CC_EXPORT LayerTreeImpl { scoped_ptr<ScrollbarAnimationController> CreateScrollbarAnimationController( int scroll_layer_id); void DidAnimateScrollOffset(); - void InputScrollAnimationFinished(); bool use_gpu_rasterization() const; GpuRasterizationStatus GetGpuRasterizationStatus() const; bool create_low_res_tiling() const; @@ -310,8 +309,6 @@ class CC_EXPORT LayerTreeImpl { size_t NumLayers(); - AnimationRegistrar* GetAnimationRegistrar() const; - void DidBecomeActive(); // Set on the active tree when the viewport size recently changed diff --git a/cc/trees/tree_synchronizer_unittest.cc b/cc/trees/tree_synchronizer_unittest.cc index 417cda5..d35036d 100644 --- a/cc/trees/tree_synchronizer_unittest.cc +++ b/cc/trees/tree_synchronizer_unittest.cc @@ -82,31 +82,6 @@ class MockLayer : public Layer { std::vector<int>* layer_impl_destruction_list_; }; -class FakeLayerAnimationController : public LayerAnimationController { - public: - static scoped_refptr<LayerAnimationController> Create() { - return static_cast<LayerAnimationController*>( - new FakeLayerAnimationController); - } - - bool SynchronizedAnimations() const { return synchronized_animations_; } - - private: - FakeLayerAnimationController() - : LayerAnimationController(1), - synchronized_animations_(false) {} - - ~FakeLayerAnimationController() override {} - - void PushAnimationUpdatesTo( - LayerAnimationController* controller_impl) override { - LayerAnimationController::PushAnimationUpdatesTo(controller_impl); - synchronized_animations_ = true; - } - - bool synchronized_animations_; -}; - void ExpectTreesAreIdentical(Layer* layer, LayerImpl* layer_impl, LayerTreeImpl* tree_impl) { @@ -590,43 +565,6 @@ TEST_F(TreeSynchronizerTest, SyncMaskReplicaAndReplicaMaskLayers) { host_->active_tree()); } -TEST_F(TreeSynchronizerTest, SynchronizeAnimations) { - LayerTreeSettingsForTreeSynchronizerTest settings; - // This test is meaningless in new use_compositor_animation_timelines mode. - // TODO(loyso): Delete FakeLayerAnimationController and related stuff. - if (settings.use_compositor_animation_timelines) - return; - - FakeImplTaskRunnerProvider task_runner_provider; - FakeRenderingStatsInstrumentation stats_instrumentation; - TestSharedBitmapManager shared_bitmap_manager; - TestTaskGraphRunner task_graph_runner; - scoped_ptr<LayerTreeHostImpl> host_impl = LayerTreeHostImpl::Create( - settings, nullptr, &task_runner_provider, &stats_instrumentation, - &shared_bitmap_manager, nullptr, &task_graph_runner, 0); - - scoped_refptr<Layer> layer_tree_root = Layer::Create(layer_settings_); - host_->SetRootLayer(layer_tree_root); - - layer_tree_root->SetLayerAnimationControllerForTest( - FakeLayerAnimationController::Create()); - - EXPECT_FALSE(static_cast<FakeLayerAnimationController*>( - layer_tree_root->layer_animation_controller())->SynchronizedAnimations()); - - scoped_ptr<LayerImpl> layer_impl_tree_root = - TreeSynchronizer::SynchronizeTrees( - layer_tree_root.get(), nullptr, host_->active_tree()); - TreeSynchronizer::PushProperties(layer_tree_root.get(), - layer_impl_tree_root.get()); - layer_impl_tree_root = TreeSynchronizer::SynchronizeTrees( - layer_tree_root.get(), std::move(layer_impl_tree_root), - host_->active_tree()); - - EXPECT_TRUE(static_cast<FakeLayerAnimationController*>( - layer_tree_root->layer_animation_controller())->SynchronizedAnimations()); -} - TEST_F(TreeSynchronizerTest, SynchronizeScrollParent) { LayerTreeSettings settings; FakeImplTaskRunnerProvider task_runner_provider; |