diff options
45 files changed, 658 insertions, 507 deletions
diff --git a/cc/BUILD.gn b/cc/BUILD.gn index ce1a7c5..ed92c8d 100644 --- a/cc/BUILD.gn +++ b/cc/BUILD.gn @@ -133,6 +133,8 @@ component("cc") { "layers/layer_impl.cc", "layers/layer_impl.h", "layers/layer_iterator.h", + "layers/layer_list_impl.cc", + "layers/layer_list_impl.h", "layers/layer_lists.h", "layers/layer_position_constraint.cc", "layers/layer_position_constraint.h", diff --git a/cc/animation/animation_host.cc b/cc/animation/animation_host.cc index 2165fe0..6803f6c 100644 --- a/cc/animation/animation_host.cc +++ b/cc/animation/animation_host.cc @@ -201,18 +201,18 @@ void AnimationHost::RemoveAnimationTimeline( } } -void AnimationHost::RegisterLayer(int layer_id, LayerTreeType tree_type) { +void AnimationHost::RegisterLayer(int layer_id, LayerListType list_type) { ElementAnimations* element_animations = GetElementAnimationsForLayerId(layer_id); if (element_animations) - element_animations->LayerRegistered(layer_id, tree_type); + element_animations->LayerRegistered(layer_id, list_type); } -void AnimationHost::UnregisterLayer(int layer_id, LayerTreeType tree_type) { +void AnimationHost::UnregisterLayer(int layer_id, LayerListType list_type) { ElementAnimations* element_animations = GetElementAnimationsForLayerId(layer_id); if (element_animations) - element_animations->LayerUnregistered(layer_id, tree_type); + element_animations->LayerUnregistered(layer_id, list_type); } void AnimationHost::RegisterPlayerForLayer(int layer_id, @@ -382,69 +382,69 @@ bool AnimationHost::ScrollOffsetAnimationWasInterrupted(int layer_id) const { } static LayerAnimationController::ObserverType ObserverTypeFromTreeType( - LayerTreeType tree_type) { - return tree_type == LayerTreeType::ACTIVE + LayerListType list_type) { + return list_type == LayerListType::ACTIVE ? LayerAnimationController::ObserverType::ACTIVE : LayerAnimationController::ObserverType::PENDING; } bool AnimationHost::IsAnimatingFilterProperty(int layer_id, - LayerTreeType tree_type) const { + LayerListType list_type) const { LayerAnimationController* controller = GetControllerForLayerId(layer_id); return controller ? controller->IsCurrentlyAnimatingProperty( - TargetProperty::FILTER, ObserverTypeFromTreeType(tree_type)) + TargetProperty::FILTER, ObserverTypeFromTreeType(list_type)) : false; } bool AnimationHost::IsAnimatingOpacityProperty(int layer_id, - LayerTreeType tree_type) const { + LayerListType list_type) const { LayerAnimationController* controller = GetControllerForLayerId(layer_id); return controller ? controller->IsCurrentlyAnimatingProperty( - TargetProperty::OPACITY, ObserverTypeFromTreeType(tree_type)) + TargetProperty::OPACITY, ObserverTypeFromTreeType(list_type)) : false; } bool AnimationHost::IsAnimatingTransformProperty( int layer_id, - LayerTreeType tree_type) const { + LayerListType list_type) const { LayerAnimationController* controller = GetControllerForLayerId(layer_id); return controller ? controller->IsCurrentlyAnimatingProperty( TargetProperty::TRANSFORM, - ObserverTypeFromTreeType(tree_type)) + ObserverTypeFromTreeType(list_type)) : false; } bool AnimationHost::HasPotentiallyRunningFilterAnimation( int layer_id, - LayerTreeType tree_type) const { + LayerListType list_type) const { LayerAnimationController* controller = GetControllerForLayerId(layer_id); return controller ? controller->IsPotentiallyAnimatingProperty( - TargetProperty::FILTER, ObserverTypeFromTreeType(tree_type)) + TargetProperty::FILTER, ObserverTypeFromTreeType(list_type)) : false; } bool AnimationHost::HasPotentiallyRunningOpacityAnimation( int layer_id, - LayerTreeType tree_type) const { + LayerListType list_type) const { LayerAnimationController* controller = GetControllerForLayerId(layer_id); return controller ? controller->IsPotentiallyAnimatingProperty( - TargetProperty::OPACITY, ObserverTypeFromTreeType(tree_type)) + TargetProperty::OPACITY, ObserverTypeFromTreeType(list_type)) : false; } bool AnimationHost::HasPotentiallyRunningTransformAnimation( int layer_id, - LayerTreeType tree_type) const { + LayerListType list_type) const { LayerAnimationController* controller = GetControllerForLayerId(layer_id); return controller ? controller->IsPotentiallyAnimatingProperty( TargetProperty::TRANSFORM, - ObserverTypeFromTreeType(tree_type)) + ObserverTypeFromTreeType(list_type)) : false; } @@ -522,11 +522,11 @@ bool AnimationHost::TransformAnimationBoundsForBox(int layer_id, bool AnimationHost::HasOnlyTranslationTransforms( int layer_id, - LayerTreeType tree_type) const { + LayerListType list_type) const { LayerAnimationController* controller = GetControllerForLayerId(layer_id); return controller ? controller->HasOnlyTranslationTransforms( - ObserverTypeFromTreeType(tree_type)) + ObserverTypeFromTreeType(list_type)) : true; } @@ -536,24 +536,24 @@ bool AnimationHost::AnimationsPreserveAxisAlignment(int layer_id) const { } bool AnimationHost::MaximumTargetScale(int layer_id, - LayerTreeType tree_type, + LayerListType list_type, float* max_scale) const { *max_scale = 0.f; LayerAnimationController* controller = GetControllerForLayerId(layer_id); return controller ? controller->MaximumTargetScale( - ObserverTypeFromTreeType(tree_type), max_scale) + ObserverTypeFromTreeType(list_type), max_scale) : true; } bool AnimationHost::AnimationStartScale(int layer_id, - LayerTreeType tree_type, + LayerListType list_type, float* start_scale) const { *start_scale = 0.f; LayerAnimationController* controller = GetControllerForLayerId(layer_id); return controller ? controller->AnimationStartScale( - ObserverTypeFromTreeType(tree_type), start_scale) + ObserverTypeFromTreeType(list_type), start_scale) : true; } diff --git a/cc/animation/animation_host.h b/cc/animation/animation_host.h index 445209f..64f82be 100644 --- a/cc/animation/animation_host.h +++ b/cc/animation/animation_host.h @@ -57,8 +57,8 @@ class CC_EXPORT AnimationHost { void ClearTimelines(); - void RegisterLayer(int layer_id, LayerTreeType tree_type); - void UnregisterLayer(int layer_id, LayerTreeType tree_type); + void RegisterLayer(int layer_id, LayerListType list_type); + void UnregisterLayer(int layer_id, LayerListType list_type); void RegisterPlayerForLayer(int layer_id, AnimationPlayer* player); void UnregisterPlayerForLayer(int layer_id, AnimationPlayer* player); @@ -98,17 +98,17 @@ class CC_EXPORT AnimationHost { bool ScrollOffsetAnimationWasInterrupted(int layer_id) const; - bool IsAnimatingFilterProperty(int layer_id, LayerTreeType tree_type) const; - bool IsAnimatingOpacityProperty(int layer_id, LayerTreeType tree_type) const; + bool IsAnimatingFilterProperty(int layer_id, LayerListType list_type) const; + bool IsAnimatingOpacityProperty(int layer_id, LayerListType list_type) const; bool IsAnimatingTransformProperty(int layer_id, - LayerTreeType tree_type) const; + LayerListType list_type) const; bool HasPotentiallyRunningFilterAnimation(int layer_id, - LayerTreeType tree_type) const; + LayerListType list_type) const; bool HasPotentiallyRunningOpacityAnimation(int layer_id, - LayerTreeType tree_type) const; + LayerListType list_type) const; bool HasPotentiallyRunningTransformAnimation(int layer_id, - LayerTreeType tree_type) const; + LayerListType list_type) const; bool HasAnyAnimationTargetingProperty(int layer_id, TargetProperty::Type property) const; @@ -129,14 +129,14 @@ class CC_EXPORT AnimationHost { gfx::BoxF* bounds) const; bool HasOnlyTranslationTransforms(int layer_id, - LayerTreeType tree_type) const; + LayerListType list_type) const; bool AnimationsPreserveAxisAlignment(int layer_id) const; bool MaximumTargetScale(int layer_id, - LayerTreeType tree_type, + LayerListType list_type, float* max_scale) const; bool AnimationStartScale(int layer_id, - LayerTreeType tree_type, + LayerListType list_type, float* start_scale) const; bool HasAnyAnimation(int layer_id) const; diff --git a/cc/animation/animation_host_unittest.cc b/cc/animation/animation_host_unittest.cc index cf828f6..0cd6ab2 100644 --- a/cc/animation/animation_host_unittest.cc +++ b/cc/animation/animation_host_unittest.cc @@ -79,8 +79,8 @@ TEST_F(AnimationHostTest, ImplOnlyTimeline) { } TEST_F(AnimationHostTest, ImplOnlyScrollAnimationUpdateTargetIfDetached) { - client_.RegisterLayer(layer_id_, LayerTreeType::ACTIVE); - client_impl_.RegisterLayer(layer_id_, LayerTreeType::PENDING); + client_.RegisterLayer(layer_id_, LayerListType::ACTIVE); + client_impl_.RegisterLayer(layer_id_, LayerListType::PENDING); gfx::ScrollOffset target_offset(0., 2.); gfx::ScrollOffset current_offset(0., 1.); diff --git a/cc/animation/animation_player.h b/cc/animation/animation_player.h index 97883ac..1276c93 100644 --- a/cc/animation/animation_player.h +++ b/cc/animation/animation_player.h @@ -21,7 +21,7 @@ class AnimationHost; class AnimationTimeline; class ElementAnimations; class LayerAnimationController; -enum class LayerTreeType; +enum class LayerListType; // An AnimationPlayer owns all animations to be run on particular CC Layer. // Multiple AnimationPlayers can be attached to one layer. In this case, diff --git a/cc/animation/animation_player_unittest.cc b/cc/animation/animation_player_unittest.cc index 6e165fd..01e72f8 100644 --- a/cc/animation/animation_player_unittest.cc +++ b/cc/animation/animation_player_unittest.cc @@ -94,9 +94,9 @@ TEST_F(AnimationPlayerTest, AttachDetachTimelineIfLayerAttached) { } TEST_F(AnimationPlayerTest, PropertiesMutate) { - client_.RegisterLayer(layer_id_, LayerTreeType::ACTIVE); - client_impl_.RegisterLayer(layer_id_, LayerTreeType::PENDING); - client_impl_.RegisterLayer(layer_id_, LayerTreeType::ACTIVE); + client_.RegisterLayer(layer_id_, LayerListType::ACTIVE); + client_impl_.RegisterLayer(layer_id_, LayerListType::PENDING); + client_impl_.RegisterLayer(layer_id_, LayerListType::ACTIVE); host_->AddAnimationTimeline(timeline_); timeline_->AttachPlayer(player_); @@ -122,18 +122,18 @@ TEST_F(AnimationPlayerTest, PropertiesMutate) { host_->PushPropertiesTo(host_impl_); - EXPECT_FALSE(client_.IsPropertyMutated(layer_id_, LayerTreeType::ACTIVE, + EXPECT_FALSE(client_.IsPropertyMutated(layer_id_, LayerListType::ACTIVE, TargetProperty::OPACITY)); - EXPECT_FALSE(client_.IsPropertyMutated(layer_id_, LayerTreeType::ACTIVE, + EXPECT_FALSE(client_.IsPropertyMutated(layer_id_, LayerListType::ACTIVE, TargetProperty::TRANSFORM)); - EXPECT_FALSE(client_.IsPropertyMutated(layer_id_, LayerTreeType::ACTIVE, + EXPECT_FALSE(client_.IsPropertyMutated(layer_id_, LayerListType::ACTIVE, TargetProperty::FILTER)); - EXPECT_FALSE(client_impl_.IsPropertyMutated(layer_id_, LayerTreeType::ACTIVE, + EXPECT_FALSE(client_impl_.IsPropertyMutated(layer_id_, LayerListType::ACTIVE, TargetProperty::OPACITY)); - EXPECT_FALSE(client_impl_.IsPropertyMutated(layer_id_, LayerTreeType::ACTIVE, + EXPECT_FALSE(client_impl_.IsPropertyMutated(layer_id_, LayerListType::ACTIVE, TargetProperty::TRANSFORM)); - EXPECT_FALSE(client_impl_.IsPropertyMutated(layer_id_, LayerTreeType::ACTIVE, + EXPECT_FALSE(client_impl_.IsPropertyMutated(layer_id_, LayerListType::ACTIVE, TargetProperty::FILTER)); host_impl_->animation_registrar()->ActivateAnimations(); @@ -145,25 +145,25 @@ TEST_F(AnimationPlayerTest, PropertiesMutate) { time += base::TimeDelta::FromSecondsD(duration); AnimateLayersTransferEvents(time, 3u); - client_.ExpectOpacityPropertyMutated(layer_id_, LayerTreeType::ACTIVE, + client_.ExpectOpacityPropertyMutated(layer_id_, LayerListType::ACTIVE, end_opacity); - client_.ExpectTransformPropertyMutated(layer_id_, LayerTreeType::ACTIVE, + client_.ExpectTransformPropertyMutated(layer_id_, LayerListType::ACTIVE, transform_x, transform_y); - client_.ExpectFilterPropertyMutated(layer_id_, LayerTreeType::ACTIVE, + client_.ExpectFilterPropertyMutated(layer_id_, LayerListType::ACTIVE, end_brightness); - client_impl_.ExpectOpacityPropertyMutated(layer_id_, LayerTreeType::ACTIVE, + client_impl_.ExpectOpacityPropertyMutated(layer_id_, LayerListType::ACTIVE, end_opacity); - client_impl_.ExpectTransformPropertyMutated(layer_id_, LayerTreeType::ACTIVE, + client_impl_.ExpectTransformPropertyMutated(layer_id_, LayerListType::ACTIVE, transform_x, transform_y); - client_impl_.ExpectFilterPropertyMutated(layer_id_, LayerTreeType::ACTIVE, + client_impl_.ExpectFilterPropertyMutated(layer_id_, LayerListType::ACTIVE, end_brightness); - client_impl_.ExpectOpacityPropertyMutated(layer_id_, LayerTreeType::PENDING, + client_impl_.ExpectOpacityPropertyMutated(layer_id_, LayerListType::PENDING, end_opacity); - client_impl_.ExpectTransformPropertyMutated(layer_id_, LayerTreeType::PENDING, + client_impl_.ExpectTransformPropertyMutated(layer_id_, LayerListType::PENDING, transform_x, transform_y); - client_impl_.ExpectFilterPropertyMutated(layer_id_, LayerTreeType::PENDING, + client_impl_.ExpectFilterPropertyMutated(layer_id_, LayerListType::PENDING, end_brightness); } @@ -171,9 +171,9 @@ TEST_F(AnimationPlayerTest, AttachTwoPlayersToOneLayer) { TestAnimationDelegate delegate1; TestAnimationDelegate delegate2; - client_.RegisterLayer(layer_id_, LayerTreeType::ACTIVE); - client_impl_.RegisterLayer(layer_id_, LayerTreeType::PENDING); - client_impl_.RegisterLayer(layer_id_, LayerTreeType::ACTIVE); + client_.RegisterLayer(layer_id_, LayerListType::ACTIVE); + client_impl_.RegisterLayer(layer_id_, LayerListType::PENDING); + client_impl_.RegisterLayer(layer_id_, LayerListType::ACTIVE); scoped_refptr<AnimationPlayer> player1 = AnimationPlayer::Create(AnimationIdProvider::NextPlayerId()); @@ -229,26 +229,26 @@ TEST_F(AnimationPlayerTest, AttachTwoPlayersToOneLayer) { EXPECT_TRUE(delegate1.finished_); EXPECT_TRUE(delegate2.finished_); - client_.ExpectOpacityPropertyMutated(layer_id_, LayerTreeType::ACTIVE, + client_.ExpectOpacityPropertyMutated(layer_id_, LayerListType::ACTIVE, end_opacity); - client_.ExpectTransformPropertyMutated(layer_id_, LayerTreeType::ACTIVE, + client_.ExpectTransformPropertyMutated(layer_id_, LayerListType::ACTIVE, transform_x, transform_y); - client_impl_.ExpectOpacityPropertyMutated(layer_id_, LayerTreeType::ACTIVE, + client_impl_.ExpectOpacityPropertyMutated(layer_id_, LayerListType::ACTIVE, end_opacity); - client_impl_.ExpectTransformPropertyMutated(layer_id_, LayerTreeType::ACTIVE, + client_impl_.ExpectTransformPropertyMutated(layer_id_, LayerListType::ACTIVE, transform_x, transform_y); - client_impl_.ExpectOpacityPropertyMutated(layer_id_, LayerTreeType::PENDING, + client_impl_.ExpectOpacityPropertyMutated(layer_id_, LayerListType::PENDING, end_opacity); - client_impl_.ExpectTransformPropertyMutated(layer_id_, LayerTreeType::PENDING, + client_impl_.ExpectTransformPropertyMutated(layer_id_, LayerListType::PENDING, transform_x, transform_y); } TEST_F(AnimationPlayerTest, AddRemoveAnimationToNonAttachedPlayer) { - client_.RegisterLayer(layer_id_, LayerTreeType::ACTIVE); - client_impl_.RegisterLayer(layer_id_, LayerTreeType::PENDING); - client_impl_.RegisterLayer(layer_id_, LayerTreeType::ACTIVE); + client_.RegisterLayer(layer_id_, LayerListType::ACTIVE); + client_impl_.RegisterLayer(layer_id_, LayerListType::PENDING); + client_impl_.RegisterLayer(layer_id_, LayerListType::ACTIVE); const double duration = 1.; const float start_opacity = .7f; @@ -277,14 +277,14 @@ TEST_F(AnimationPlayerTest, AddRemoveAnimationToNonAttachedPlayer) { host_->PushPropertiesTo(host_impl_); - EXPECT_FALSE(client_.IsPropertyMutated(layer_id_, LayerTreeType::ACTIVE, + EXPECT_FALSE(client_.IsPropertyMutated(layer_id_, LayerListType::ACTIVE, TargetProperty::OPACITY)); - EXPECT_FALSE(client_impl_.IsPropertyMutated(layer_id_, LayerTreeType::ACTIVE, + EXPECT_FALSE(client_impl_.IsPropertyMutated(layer_id_, LayerListType::ACTIVE, TargetProperty::OPACITY)); - EXPECT_FALSE(client_.IsPropertyMutated(layer_id_, LayerTreeType::ACTIVE, + EXPECT_FALSE(client_.IsPropertyMutated(layer_id_, LayerListType::ACTIVE, TargetProperty::FILTER)); - EXPECT_FALSE(client_impl_.IsPropertyMutated(layer_id_, LayerTreeType::ACTIVE, + EXPECT_FALSE(client_impl_.IsPropertyMutated(layer_id_, LayerListType::ACTIVE, TargetProperty::FILTER)); host_impl_->animation_registrar()->ActivateAnimations(); @@ -296,21 +296,21 @@ TEST_F(AnimationPlayerTest, AddRemoveAnimationToNonAttachedPlayer) { time += base::TimeDelta::FromSecondsD(duration); AnimateLayersTransferEvents(time, 1u); - client_.ExpectOpacityPropertyMutated(layer_id_, LayerTreeType::ACTIVE, + client_.ExpectOpacityPropertyMutated(layer_id_, LayerListType::ACTIVE, end_opacity); - client_impl_.ExpectOpacityPropertyMutated(layer_id_, LayerTreeType::ACTIVE, + client_impl_.ExpectOpacityPropertyMutated(layer_id_, LayerListType::ACTIVE, end_opacity); - client_impl_.ExpectOpacityPropertyMutated(layer_id_, LayerTreeType::PENDING, + client_impl_.ExpectOpacityPropertyMutated(layer_id_, LayerListType::PENDING, end_opacity); - EXPECT_FALSE(client_.IsPropertyMutated(layer_id_, LayerTreeType::ACTIVE, + EXPECT_FALSE(client_.IsPropertyMutated(layer_id_, LayerListType::ACTIVE, TargetProperty::FILTER)); - EXPECT_FALSE(client_impl_.IsPropertyMutated(layer_id_, LayerTreeType::ACTIVE, + EXPECT_FALSE(client_impl_.IsPropertyMutated(layer_id_, LayerListType::ACTIVE, TargetProperty::FILTER)); } TEST_F(AnimationPlayerTest, AddRemoveAnimationCausesSetNeedsCommit) { - client_.RegisterLayer(layer_id_, LayerTreeType::ACTIVE); + client_.RegisterLayer(layer_id_, LayerListType::ACTIVE); host_->AddAnimationTimeline(timeline_); timeline_->AttachPlayer(player_); player_->AttachLayer(layer_id_); diff --git a/cc/animation/element_animations.cc b/cc/animation/element_animations.cc index e3c2224..cded26a 100644 --- a/cc/animation/element_animations.cc +++ b/cc/animation/element_animations.cc @@ -15,26 +15,26 @@ namespace cc { class ElementAnimations::ValueObserver : public LayerAnimationValueObserver { public: - ValueObserver(ElementAnimations* element_animation, LayerTreeType tree_type) - : element_animations_(element_animation), tree_type_(tree_type) { + ValueObserver(ElementAnimations* element_animation, LayerListType list_type) + : element_animations_(element_animation), list_type_(list_type) { DCHECK(element_animations_); } // LayerAnimationValueObserver implementation. void OnFilterAnimated(const FilterOperations& filters) override { - element_animations_->SetFilterMutated(tree_type_, filters); + element_animations_->SetFilterMutated(list_type_, filters); } void OnOpacityAnimated(float opacity) override { - element_animations_->SetOpacityMutated(tree_type_, opacity); + element_animations_->SetOpacityMutated(list_type_, opacity); } void OnTransformAnimated(const gfx::Transform& transform) override { - element_animations_->SetTransformMutated(tree_type_, transform); + element_animations_->SetTransformMutated(list_type_, transform); } void OnScrollOffsetAnimated(const gfx::ScrollOffset& scroll_offset) override { - element_animations_->SetScrollOffsetMutated(tree_type_, scroll_offset); + element_animations_->SetScrollOffsetMutated(list_type_, scroll_offset); } void OnAnimationWaitingForDeletion() override { @@ -44,14 +44,14 @@ class ElementAnimations::ValueObserver : public LayerAnimationValueObserver { void OnTransformIsPotentiallyAnimatingChanged(bool is_animating) override { element_animations_->SetTransformIsPotentiallyAnimatingChanged( - tree_type_, is_animating); + list_type_, is_animating); } - bool IsActive() const override { return tree_type_ == LayerTreeType::ACTIVE; } + bool IsActive() const override { return list_type_ == LayerListType::ACTIVE; } private: ElementAnimations* element_animations_; - const LayerTreeType tree_type_; + const LayerListType list_type_; DISALLOW_COPY_AND_ASSIGN(ValueObserver); }; @@ -85,10 +85,10 @@ void ElementAnimations::CreateLayerAnimationController(int layer_id) { DCHECK(animation_host_->mutator_host_client()); if (animation_host_->mutator_host_client()->IsLayerInTree( - layer_id, LayerTreeType::ACTIVE)) + layer_id, LayerListType::ACTIVE)) CreateActiveValueObserver(); if (animation_host_->mutator_host_client()->IsLayerInTree( - layer_id, LayerTreeType::PENDING)) + layer_id, LayerListType::PENDING)) CreatePendingValueObserver(); } @@ -96,9 +96,9 @@ void ElementAnimations::DestroyLayerAnimationController() { DCHECK(animation_host_); if (active_value_observer_) - SetTransformIsPotentiallyAnimatingChanged(LayerTreeType::ACTIVE, false); + SetTransformIsPotentiallyAnimatingChanged(LayerListType::ACTIVE, false); if (pending_value_observer_) - SetTransformIsPotentiallyAnimatingChanged(LayerTreeType::PENDING, false); + SetTransformIsPotentiallyAnimatingChanged(LayerListType::PENDING, false); DestroyPendingValueObserver(); DestroyActiveValueObserver(); @@ -111,11 +111,11 @@ void ElementAnimations::DestroyLayerAnimationController() { } } -void ElementAnimations::LayerRegistered(int layer_id, LayerTreeType tree_type) { +void ElementAnimations::LayerRegistered(int layer_id, LayerListType list_type) { DCHECK(layer_animation_controller_); DCHECK_EQ(layer_animation_controller_->id(), layer_id); - if (tree_type == LayerTreeType::ACTIVE) { + if (list_type == LayerListType::ACTIVE) { if (!active_value_observer_) CreateActiveValueObserver(); } else { @@ -125,9 +125,9 @@ void ElementAnimations::LayerRegistered(int layer_id, LayerTreeType tree_type) { } void ElementAnimations::LayerUnregistered(int layer_id, - LayerTreeType tree_type) { + LayerListType list_type) { DCHECK_EQ(this->layer_id(), layer_id); - tree_type == LayerTreeType::ACTIVE ? DestroyActiveValueObserver() + list_type == LayerListType::ACTIVE ? DestroyActiveValueObserver() : DestroyPendingValueObserver(); } @@ -158,52 +158,52 @@ void ElementAnimations::PushPropertiesTo( element_animations_impl->layer_animation_controller()); } -void ElementAnimations::SetFilterMutated(LayerTreeType tree_type, +void ElementAnimations::SetFilterMutated(LayerListType list_type, const FilterOperations& filters) { DCHECK(layer_id()); DCHECK(animation_host()); DCHECK(animation_host()->mutator_host_client()); animation_host()->mutator_host_client()->SetLayerFilterMutated( - layer_id(), tree_type, filters); + layer_id(), list_type, filters); } -void ElementAnimations::SetOpacityMutated(LayerTreeType tree_type, +void ElementAnimations::SetOpacityMutated(LayerListType list_type, float opacity) { DCHECK(layer_id()); DCHECK(animation_host()); DCHECK(animation_host()->mutator_host_client()); animation_host()->mutator_host_client()->SetLayerOpacityMutated( - layer_id(), tree_type, opacity); + layer_id(), list_type, opacity); } -void ElementAnimations::SetTransformMutated(LayerTreeType tree_type, +void ElementAnimations::SetTransformMutated(LayerListType list_type, const gfx::Transform& transform) { DCHECK(layer_id()); DCHECK(animation_host()); DCHECK(animation_host()->mutator_host_client()); animation_host()->mutator_host_client()->SetLayerTransformMutated( - layer_id(), tree_type, transform); + layer_id(), list_type, transform); } void ElementAnimations::SetScrollOffsetMutated( - LayerTreeType tree_type, + LayerListType list_type, const gfx::ScrollOffset& scroll_offset) { DCHECK(layer_id()); DCHECK(animation_host()); DCHECK(animation_host()->mutator_host_client()); animation_host()->mutator_host_client()->SetLayerScrollOffsetMutated( - layer_id(), tree_type, scroll_offset); + layer_id(), list_type, scroll_offset); } void ElementAnimations::SetTransformIsPotentiallyAnimatingChanged( - LayerTreeType tree_type, + LayerListType list_type, bool is_animating) { DCHECK(layer_id()); DCHECK(animation_host()); DCHECK(animation_host()->mutator_host_client()); animation_host() ->mutator_host_client() - ->LayerTransformIsPotentiallyAnimatingChanged(layer_id(), tree_type, + ->LayerTransformIsPotentiallyAnimatingChanged(layer_id(), list_type, is_animating); } @@ -211,7 +211,7 @@ void ElementAnimations::CreateActiveValueObserver() { DCHECK(layer_animation_controller_); DCHECK(!active_value_observer_); active_value_observer_ = - make_scoped_ptr(new ValueObserver(this, LayerTreeType::ACTIVE)); + make_scoped_ptr(new ValueObserver(this, LayerListType::ACTIVE)); layer_animation_controller_->AddValueObserver(active_value_observer_.get()); } @@ -226,7 +226,7 @@ void ElementAnimations::CreatePendingValueObserver() { DCHECK(layer_animation_controller_); DCHECK(!pending_value_observer_); pending_value_observer_ = - make_scoped_ptr(new ValueObserver(this, LayerTreeType::PENDING)); + make_scoped_ptr(new ValueObserver(this, LayerListType::PENDING)); layer_animation_controller_->AddValueObserver(pending_value_observer_.get()); } diff --git a/cc/animation/element_animations.h b/cc/animation/element_animations.h index 1c5ecc3..61b85aa 100644 --- a/cc/animation/element_animations.h +++ b/cc/animation/element_animations.h @@ -24,7 +24,7 @@ class AnimationHost; class AnimationPlayer; class FilterOperations; class LayerAnimationController; -enum class LayerTreeType; +enum class LayerListType; // An ElementAnimations owns a list of all AnimationPlayers, attached to // the layer. Also, it owns LayerAnimationController instance (1:1 @@ -54,8 +54,8 @@ class CC_EXPORT ElementAnimations : public AnimationDelegate, void CreateLayerAnimationController(int layer_id); void DestroyLayerAnimationController(); - void LayerRegistered(int layer_id, LayerTreeType tree_type); - void LayerUnregistered(int layer_id, LayerTreeType tree_type); + void LayerRegistered(int layer_id, LayerListType list_type); + void LayerUnregistered(int layer_id, LayerListType list_type); bool has_active_value_observer_for_testing() const { return !!active_value_observer_; @@ -77,14 +77,14 @@ class CC_EXPORT ElementAnimations : public AnimationDelegate, private: explicit ElementAnimations(AnimationHost* host); - void SetFilterMutated(LayerTreeType tree_type, + void SetFilterMutated(LayerListType list_type, const FilterOperations& filters); - void SetOpacityMutated(LayerTreeType tree_type, float opacity); - void SetTransformMutated(LayerTreeType tree_type, + void SetOpacityMutated(LayerListType list_type, float opacity); + void SetTransformMutated(LayerListType list_type, const gfx::Transform& transform); - void SetScrollOffsetMutated(LayerTreeType tree_type, + void SetScrollOffsetMutated(LayerListType list_type, const gfx::ScrollOffset& scroll_offset); - void SetTransformIsPotentiallyAnimatingChanged(LayerTreeType tree_type, + void SetTransformIsPotentiallyAnimatingChanged(LayerListType list_type, bool is_animating); void CreateActiveValueObserver(); diff --git a/cc/animation/element_animations_unittest.cc b/cc/animation/element_animations_unittest.cc index b676906..94f6792 100644 --- a/cc/animation/element_animations_unittest.cc +++ b/cc/animation/element_animations_unittest.cc @@ -27,11 +27,11 @@ class ElementAnimationsTest : public AnimationTimelinesTest { TEST_F(ElementAnimationsTest, AttachToLayerInActiveTree) { // Set up the layer which is in active tree for main thread and not // yet passed onto the impl thread. - client_.RegisterLayer(layer_id_, LayerTreeType::ACTIVE); - client_impl_.RegisterLayer(layer_id_, LayerTreeType::PENDING); + client_.RegisterLayer(layer_id_, LayerListType::ACTIVE); + client_impl_.RegisterLayer(layer_id_, LayerListType::PENDING); - EXPECT_TRUE(client_.IsLayerInTree(layer_id_, LayerTreeType::ACTIVE)); - EXPECT_FALSE(client_.IsLayerInTree(layer_id_, LayerTreeType::PENDING)); + EXPECT_TRUE(client_.IsLayerInTree(layer_id_, LayerListType::ACTIVE)); + EXPECT_FALSE(client_.IsLayerInTree(layer_id_, LayerListType::PENDING)); host_->AddAnimationTimeline(timeline_); @@ -58,16 +58,16 @@ TEST_F(ElementAnimationsTest, AttachToLayerInActiveTree) { element_animations_impl->has_pending_value_observer_for_testing()); // Create the layer in the impl active tree. - client_impl_.RegisterLayer(layer_id_, LayerTreeType::ACTIVE); + client_impl_.RegisterLayer(layer_id_, LayerListType::ACTIVE); EXPECT_TRUE(element_animations_impl->has_active_value_observer_for_testing()); EXPECT_TRUE( element_animations_impl->has_pending_value_observer_for_testing()); - EXPECT_TRUE(client_impl_.IsLayerInTree(layer_id_, LayerTreeType::ACTIVE)); - EXPECT_TRUE(client_impl_.IsLayerInTree(layer_id_, LayerTreeType::PENDING)); + EXPECT_TRUE(client_impl_.IsLayerInTree(layer_id_, LayerListType::ACTIVE)); + EXPECT_TRUE(client_impl_.IsLayerInTree(layer_id_, LayerListType::PENDING)); // kill layer on main thread. - client_.UnregisterLayer(layer_id_, LayerTreeType::ACTIVE); + client_.UnregisterLayer(layer_id_, LayerListType::ACTIVE); EXPECT_EQ(element_animations, player_->element_animations()); EXPECT_FALSE(element_animations->has_active_value_observer_for_testing()); EXPECT_FALSE(element_animations->has_pending_value_observer_for_testing()); @@ -80,14 +80,14 @@ TEST_F(ElementAnimationsTest, AttachToLayerInActiveTree) { element_animations_impl->has_pending_value_observer_for_testing()); // Kill layer on impl thread in pending tree. - client_impl_.UnregisterLayer(layer_id_, LayerTreeType::PENDING); + client_impl_.UnregisterLayer(layer_id_, LayerListType::PENDING); EXPECT_EQ(element_animations_impl, player_impl_->element_animations()); EXPECT_TRUE(element_animations_impl->has_active_value_observer_for_testing()); EXPECT_FALSE( element_animations_impl->has_pending_value_observer_for_testing()); // Kill layer on impl thread in active tree. - client_impl_.UnregisterLayer(layer_id_, LayerTreeType::ACTIVE); + client_impl_.UnregisterLayer(layer_id_, LayerListType::ACTIVE); EXPECT_EQ(element_animations_impl, player_impl_->element_animations()); EXPECT_FALSE( element_animations_impl->has_active_value_observer_for_testing()); @@ -137,17 +137,17 @@ TEST_F(ElementAnimationsTest, AttachToNotYetCreatedLayer) { element_animations_impl->has_pending_value_observer_for_testing()); // Create layer. - client_.RegisterLayer(layer_id_, LayerTreeType::ACTIVE); + client_.RegisterLayer(layer_id_, LayerListType::ACTIVE); EXPECT_TRUE(element_animations->has_active_value_observer_for_testing()); EXPECT_FALSE(element_animations->has_pending_value_observer_for_testing()); - client_impl_.RegisterLayer(layer_id_, LayerTreeType::PENDING); + client_impl_.RegisterLayer(layer_id_, LayerListType::PENDING); EXPECT_FALSE( element_animations_impl->has_active_value_observer_for_testing()); EXPECT_TRUE( element_animations_impl->has_pending_value_observer_for_testing()); - client_impl_.RegisterLayer(layer_id_, LayerTreeType::ACTIVE); + client_impl_.RegisterLayer(layer_id_, LayerListType::ACTIVE); EXPECT_TRUE(element_animations_impl->has_active_value_observer_for_testing()); EXPECT_TRUE( element_animations_impl->has_pending_value_observer_for_testing()); @@ -195,6 +195,8 @@ 'layers/layer_impl.cc', 'layers/layer_impl.h', 'layers/layer_iterator.h', + 'layers/layer_list_impl.cc', + 'layers/layer_list_impl.h', 'layers/layer_lists.h', 'layers/layer_position_constraint.cc', 'layers/layer_position_constraint.h', diff --git a/cc/input/scroll_state.cc b/cc/input/scroll_state.cc index aa0baf1..f0e7751 100644 --- a/cc/input/scroll_state.cc +++ b/cc/input/scroll_state.cc @@ -28,7 +28,7 @@ void ScrollState::DistributeToScrollChainDescendant() { if (!scroll_chain_.empty()) { const ScrollNode* next = scroll_chain_.front(); scroll_chain_.pop_front(); - layer_tree_impl_->LayerById(next->owner_id)->DistributeScroll(this); + layer_tree_impl_->list()->LayerById(next->owner_id)->DistributeScroll(this); } } diff --git a/cc/input/scrollbar_animation_controller_linear_fade_unittest.cc b/cc/input/scrollbar_animation_controller_linear_fade_unittest.cc index 35eacb5..20cf0b8 100644 --- a/cc/input/scrollbar_animation_controller_linear_fade_unittest.cc +++ b/cc/input/scrollbar_animation_controller_linear_fade_unittest.cc @@ -131,7 +131,7 @@ TEST_F(ScrollbarAnimationControllerLinearFadeTest, } TEST_F(ScrollbarAnimationControllerLinearFadeTest, HideOnResize) { - LayerImpl* scroll_layer = host_impl_.active_tree()->LayerById(1); + LayerImpl* scroll_layer = host_impl_.active_tree()->list()->LayerById(1); ASSERT_TRUE(scroll_layer); EXPECT_EQ(gfx::Size(200, 200), scroll_layer->bounds()); @@ -162,7 +162,7 @@ TEST_F(ScrollbarAnimationControllerLinearFadeTest, HideOnResize) { } TEST_F(VerticalScrollbarAnimationControllerLinearFadeTest, HideOnResize) { - LayerImpl* scroll_layer = host_impl_.active_tree()->LayerById(1); + LayerImpl* scroll_layer = host_impl_.active_tree()->list()->LayerById(1); ASSERT_TRUE(scroll_layer); EXPECT_EQ(gfx::Size(200, 200), scroll_layer->bounds()); @@ -195,7 +195,7 @@ TEST_F(ScrollbarAnimationControllerLinearFadeTest, HideOnUserNonScrollableHorz) { EXPECT_EQ(HORIZONTAL, scrollbar_layer_->orientation()); - LayerImpl* scroll_layer = host_impl_.active_tree()->LayerById(1); + LayerImpl* scroll_layer = host_impl_.active_tree()->list()->LayerById(1); ASSERT_TRUE(scroll_layer); scroll_layer->set_user_scrollable_horizontal(false); @@ -211,7 +211,7 @@ TEST_F(ScrollbarAnimationControllerLinearFadeTest, ShowOnUserNonScrollableVert) { EXPECT_EQ(HORIZONTAL, scrollbar_layer_->orientation()); - LayerImpl* scroll_layer = host_impl_.active_tree()->LayerById(1); + LayerImpl* scroll_layer = host_impl_.active_tree()->list()->LayerById(1); ASSERT_TRUE(scroll_layer); scroll_layer->set_user_scrollable_vertical(false); @@ -227,7 +227,7 @@ TEST_F(VerticalScrollbarAnimationControllerLinearFadeTest, HideOnUserNonScrollableVert) { EXPECT_EQ(VERTICAL, scrollbar_layer_->orientation()); - LayerImpl* scroll_layer = host_impl_.active_tree()->LayerById(1); + LayerImpl* scroll_layer = host_impl_.active_tree()->list()->LayerById(1); ASSERT_TRUE(scroll_layer); scroll_layer->set_user_scrollable_vertical(false); @@ -243,7 +243,7 @@ TEST_F(VerticalScrollbarAnimationControllerLinearFadeTest, ShowOnUserNonScrollableHorz) { EXPECT_EQ(VERTICAL, scrollbar_layer_->orientation()); - LayerImpl* scroll_layer = host_impl_.active_tree()->LayerById(1); + LayerImpl* scroll_layer = host_impl_.active_tree()->list()->LayerById(1); ASSERT_TRUE(scroll_layer); scroll_layer->set_user_scrollable_horizontal(false); diff --git a/cc/input/scrollbar_animation_controller_thinning_unittest.cc b/cc/input/scrollbar_animation_controller_thinning_unittest.cc index da5d625..12b2d84 100644 --- a/cc/input/scrollbar_animation_controller_thinning_unittest.cc +++ b/cc/input/scrollbar_animation_controller_thinning_unittest.cc @@ -90,7 +90,7 @@ TEST_F(ScrollbarAnimationControllerThinningTest, Idle) { // Check that scrollbar disappears when the layer becomes non-scrollable. TEST_F(ScrollbarAnimationControllerThinningTest, HideOnResize) { - LayerImpl* scroll_layer = host_impl_.active_tree()->LayerById(1); + LayerImpl* scroll_layer = host_impl_.active_tree()->list()->LayerById(1); ASSERT_TRUE(scroll_layer); EXPECT_EQ(gfx::Size(200, 200), scroll_layer->bounds()); diff --git a/cc/layers/layer.cc b/cc/layers/layer.cc index 3842741..1441ccd 100644 --- a/cc/layers/layer.cc +++ b/cc/layers/layer.cc @@ -1289,7 +1289,8 @@ void Layer::PushPropertiesTo(LayerImpl* layer) { LayerImpl* scroll_parent = nullptr; if (scroll_parent_) { - scroll_parent = layer->layer_tree_impl()->LayerById(scroll_parent_->id()); + scroll_parent = + layer->layer_tree_impl()->list()->LayerById(scroll_parent_->id()); DCHECK(scroll_parent); } @@ -1301,7 +1302,7 @@ void Layer::PushPropertiesTo(LayerImpl* layer) { ++it) { DCHECK_EQ((*it)->scroll_parent(), this); LayerImpl* scroll_child = - layer->layer_tree_impl()->LayerById((*it)->id()); + layer->layer_tree_impl()->list()->LayerById((*it)->id()); DCHECK(scroll_child); scroll_children->insert(scroll_child); } @@ -1313,7 +1314,7 @@ void Layer::PushPropertiesTo(LayerImpl* layer) { LayerImpl* clip_parent = nullptr; if (clip_parent_) { clip_parent = - layer->layer_tree_impl()->LayerById(clip_parent_->id()); + layer->layer_tree_impl()->list()->LayerById(clip_parent_->id()); DCHECK(clip_parent); } @@ -1323,7 +1324,8 @@ void Layer::PushPropertiesTo(LayerImpl* layer) { for (std::set<Layer*>::iterator it = clip_children_->begin(); it != clip_children_->end(); ++it) { DCHECK_EQ((*it)->clip_parent(), this); - LayerImpl* clip_child = layer->layer_tree_impl()->LayerById((*it)->id()); + LayerImpl* clip_child = + layer->layer_tree_impl()->list()->LayerById((*it)->id()); DCHECK(clip_child); clip_children->insert(clip_child); } diff --git a/cc/layers/layer_impl.cc b/cc/layers/layer_impl.cc index ae14d9c..3f14de8 100644 --- a/cc/layers/layer_impl.cc +++ b/cc/layers/layer_impl.cc @@ -56,6 +56,7 @@ LayerImpl::LayerImpl(LayerTreeImpl* tree_impl, replica_layer_id_(-1), layer_id_(id), layer_tree_impl_(tree_impl), + layer_list_impl_(tree_impl->list()), scroll_offset_(scroll_offset), scroll_clip_layer_id_(Layer::INVALID_ID), main_thread_scrolling_reasons_( @@ -102,11 +103,10 @@ LayerImpl::LayerImpl(LayerTreeImpl* tree_impl, 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); + layer_list_impl_->RegisterLayer(this); if (!layer_tree_impl_->settings().use_compositor_animation_timelines) { - AnimationRegistrar* registrar = layer_tree_impl_->GetAnimationRegistrar(); + AnimationRegistrar* registrar = layer_list_impl_->GetAnimationRegistrar(); layer_animation_controller_ = registrar->GetAnimationControllerForId(layer_id_); layer_animation_controller_->AddValueObserver(this); @@ -116,7 +116,7 @@ LayerImpl::LayerImpl(LayerTreeImpl* tree_impl, } } - layer_tree_impl_->AddToElementMap(this); + layer_list_impl_->AddToElementMap(this); SetNeedsPushProperties(); } @@ -133,9 +133,9 @@ LayerImpl::~LayerImpl() { if (!copy_requests_.empty() && layer_tree_impl_->IsActiveTree()) layer_tree_impl()->RemoveLayerWithCopyOutputRequest(this); layer_tree_impl_->UnregisterScrollLayer(this); - layer_tree_impl_->UnregisterLayer(this); + layer_list_impl_->UnregisterLayer(this); - layer_tree_impl_->RemoveFromElementMap(this); + layer_list_impl_->RemoveFromElementMap(this); TRACE_EVENT_OBJECT_DELETED_WITH_ID( TRACE_DISABLED_BY_DEFAULT("cc.debug"), "cc::LayerImpl", this); @@ -197,7 +197,7 @@ void LayerImpl::SetScrollParent(LayerImpl* parent) { return; if (parent) - DCHECK_EQ(layer_tree_impl()->LayerById(parent->id()), parent); + DCHECK_EQ(layer_list_impl_->LayerById(parent->id()), parent); scroll_parent_ = parent; SetNeedsPushProperties(); @@ -470,13 +470,13 @@ void LayerImpl::SetScrollClipLayer(int scroll_clip_layer_id) { if (scroll_clip_layer_id_ == scroll_clip_layer_id) return; - layer_tree_impl()->UnregisterScrollLayer(this); + layer_tree_impl_->UnregisterScrollLayer(this); scroll_clip_layer_id_ = scroll_clip_layer_id; - layer_tree_impl()->RegisterScrollLayer(this); + layer_tree_impl_->RegisterScrollLayer(this); } LayerImpl* LayerImpl::scroll_clip_layer() const { - return layer_tree_impl()->LayerById(scroll_clip_layer_id_); + return layer_list_impl_->LayerById(scroll_clip_layer_id_); } bool LayerImpl::scrollable() const { @@ -563,7 +563,7 @@ void LayerImpl::PushPropertiesTo(LayerImpl* layer) { LayerImpl* scroll_parent = nullptr; if (scroll_parent_) { - scroll_parent = layer->layer_tree_impl()->LayerById(scroll_parent_->id()); + scroll_parent = layer->layer_list_impl_->LayerById(scroll_parent_->id()); DCHECK(scroll_parent); } @@ -574,8 +574,7 @@ void LayerImpl::PushPropertiesTo(LayerImpl* layer) { it != scroll_children_->end(); ++it) { DCHECK_EQ((*it)->scroll_parent(), this); - LayerImpl* scroll_child = - layer->layer_tree_impl()->LayerById((*it)->id()); + LayerImpl* scroll_child = layer->layer_list_impl_->LayerById((*it)->id()); DCHECK(scroll_child); scroll_children->insert(scroll_child); } @@ -586,8 +585,7 @@ void LayerImpl::PushPropertiesTo(LayerImpl* layer) { LayerImpl* clip_parent = nullptr; if (clip_parent_) { - clip_parent = layer->layer_tree_impl()->LayerById( - clip_parent_->id()); + clip_parent = layer->layer_list_impl_->LayerById(clip_parent_->id()); DCHECK(clip_parent); } @@ -596,7 +594,7 @@ void LayerImpl::PushPropertiesTo(LayerImpl* layer) { std::set<LayerImpl*>* clip_children = new std::set<LayerImpl*>; for (std::set<LayerImpl*>::iterator it = clip_children_->begin(); it != clip_children_->end(); ++it) - clip_children->insert(layer->layer_tree_impl()->LayerById((*it)->id())); + clip_children->insert(layer->layer_list_impl_->LayerById((*it)->id())); layer->SetClipChildren(clip_children); } else { layer->SetClipChildren(nullptr); @@ -635,7 +633,7 @@ bool LayerImpl::IsAffectedByPageScale() const { gfx::Vector2dF LayerImpl::FixedContainerSizeDelta() const { LayerImpl* scroll_clip_layer = - layer_tree_impl()->LayerById(scroll_clip_layer_id_); + layer_list_impl_->LayerById(scroll_clip_layer_id_); if (!scroll_clip_layer) return gfx::Vector2dF(); @@ -1212,9 +1210,9 @@ void LayerImpl::SetElementId(uint64_t element_id) { TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("compositor-worker"), "LayerImpl::SetElementId", "id", element_id); - layer_tree_impl_->RemoveFromElementMap(this); + layer_list_impl_->RemoveFromElementMap(this); element_id_ = element_id; - layer_tree_impl_->AddToElementMap(this); + layer_list_impl_->AddToElementMap(this); SetNeedsPushProperties(); } @@ -1227,7 +1225,7 @@ void LayerImpl::SetMutableProperties(uint32_t properties) { mutable_properties_ = properties; // If this layer is already in the element map, update its properties. - layer_tree_impl_->AddToElementMap(this); + layer_list_impl_->AddToElementMap(this); SetNeedsPushProperties(); } @@ -1486,7 +1484,7 @@ void LayerImpl::PushScrollOffset(const gfx::ScrollOffset* scroll_offset) { DCHECK(scroll_offset || IsActive()); bool changed = false; if (scroll_offset) { - DCHECK(!IsActive() || !layer_tree_impl_->FindPendingTreeLayerById(id())); + DCHECK(!IsActive() || !layer_list_impl_->FindPendingLayerById(id())); changed |= scroll_offset_->PushFromMainThread(*scroll_offset); } if (IsActive()) { @@ -1523,7 +1521,7 @@ void LayerImpl::DidUpdateScrollOffset() { // Inform the pending twin that a property changed. if (layer_tree_impl()->IsActiveTree()) { - LayerImpl* pending_twin = layer_tree_impl()->FindPendingTreeLayerById(id()); + LayerImpl* pending_twin = layer_list_impl_->FindPendingLayerById(id()); if (pending_twin) pending_twin->DidUpdateScrollOffset(); } @@ -1601,11 +1599,8 @@ void LayerImpl::GetAllPrioritizedTilesForTracing( void LayerImpl::AsValueInto(base::trace_event::TracedValue* state) const { TracedValue::MakeDictIntoImplicitSnapshotWithCategory( - TRACE_DISABLED_BY_DEFAULT("cc.debug"), - state, - "cc::LayerImpl", - LayerTypeAsString(), - this); + TRACE_DISABLED_BY_DEFAULT("cc.debug"), state, "cc::LayerImpl", + LayerTypeAsString(), this); state->SetInteger("layer_id", id()); MathUtil::AddToTracedValue("bounds", bounds_, state); diff --git a/cc/layers/layer_impl.h b/cc/layers/layer_impl.h index 40bf810..c36dd9e0 100644 --- a/cc/layers/layer_impl.h +++ b/cc/layers/layer_impl.h @@ -27,6 +27,7 @@ #include "cc/debug/frame_timing_request.h" #include "cc/input/input_handler.h" #include "cc/layers/draw_properties.h" +#include "cc/layers/layer_list_impl.h" #include "cc/layers/layer_lists.h" #include "cc/layers/layer_position_constraint.h" #include "cc/layers/performance_properties.h" @@ -747,6 +748,7 @@ class CC_EXPORT LayerImpl : public LayerAnimationValueObserver, scoped_ptr<LayerImpl> replica_layer_; int layer_id_; LayerTreeImpl* layer_tree_impl_; + LayerListImpl* layer_list_impl_; // Properties dynamically changeable on active tree. scoped_refptr<SyncedScrollOffset> scroll_offset_; diff --git a/cc/layers/layer_list_host_impl.h b/cc/layers/layer_list_host_impl.h new file mode 100644 index 0000000..905c3e3 --- /dev/null +++ b/cc/layers/layer_list_host_impl.h @@ -0,0 +1,10 @@ +// Copyright 2016 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CC_LAYERS_LAYER_LIST_HOST_IMPL_H_ +#define CC_LAYERS_LAYER_LIST_HOST_IMPL_H_ + +#include "cc/trees/layer_tree_host_impl.h" + +#endif // CC_LAYERS_LAYER_LIST_HOST_IMPL_H_ diff --git a/cc/layers/layer_list_impl.cc b/cc/layers/layer_list_impl.cc new file mode 100644 index 0000000..8748f0fe --- /dev/null +++ b/cc/layers/layer_list_impl.cc @@ -0,0 +1,118 @@ +// Copyright 2016 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "cc/layers/layer_list_impl.h" + +#include "base/trace_event/trace_event.h" +#include "base/trace_event/trace_event_argument.h" +#include "cc/animation/animation_host.h" +#include "cc/layers/layer_impl.h" +#include "cc/layers/layer_list_host_impl.h" + +namespace cc { + +LayerListImpl::LayerListImpl(LayerListHostImpl* host_impl) + : layer_list_host_(host_impl) {} + +LayerListImpl::~LayerListImpl() {} + +AnimationRegistrar* LayerListImpl::GetAnimationRegistrar() const { + return layer_list_host_->animation_registrar(); +} + +LayerImpl* LayerListImpl::LayerById(int id) const { + LayerIdMap::const_iterator iter = layer_id_map_.find(id); + return iter != layer_id_map_.end() ? iter->second : NULL; +} + +void LayerListImpl::RegisterLayer(LayerImpl* layer) { + DCHECK(!LayerById(layer->id())); + layer_id_map_[layer->id()] = layer; + if (layer_list_host_->animation_host()) + layer_list_host_->animation_host()->RegisterLayer( + layer->id(), + IsActiveList() ? LayerListType::ACTIVE : LayerListType::PENDING); +} + +void LayerListImpl::UnregisterLayer(LayerImpl* layer) { + DCHECK(LayerById(layer->id())); + if (layer_list_host_->animation_host()) + layer_list_host_->animation_host()->UnregisterLayer( + layer->id(), + IsActiveList() ? LayerListType::ACTIVE : LayerListType::PENDING); + layer_id_map_.erase(layer->id()); +} + +size_t LayerListImpl::NumLayers() { + return layer_id_map_.size(); +} + +LayerImpl* LayerListImpl::FindActiveLayerById(int id) { + LayerListImpl* list = layer_list_host_->active_list(); + if (!list) + return nullptr; + return list->LayerById(id); +} + +LayerImpl* LayerListImpl::FindPendingLayerById(int id) { + LayerListImpl* list = layer_list_host_->pending_list(); + if (!list) + return nullptr; + return list->LayerById(id); +} + +void LayerListImpl::AddToElementMap(LayerImpl* layer) { + if (!layer->element_id() || !layer->mutable_properties()) + return; + + TRACE_EVENT2(TRACE_DISABLED_BY_DEFAULT("compositor-worker"), + "LayerListImpl::AddToElementMap", "element_id", + layer->element_id(), "layer_id", layer->id()); + + ElementLayers& layers = element_layers_map_[layer->element_id()]; + if ((!layers.main || layer->IsActive()) && !layer->scrollable()) { + layers.main = layer; + } else if ((!layers.scroll || layer->IsActive()) && layer->scrollable()) { + TRACE_EVENT2("compositor-worker", "LayerListImpl::AddToElementMap scroll", + "element_id", layer->element_id(), "layer_id", layer->id()); + layers.scroll = layer; + } +} + +void LayerListImpl::RemoveFromElementMap(LayerImpl* layer) { + if (!layer->element_id()) + return; + + TRACE_EVENT2(TRACE_DISABLED_BY_DEFAULT("compositor-worker"), + "LayerListImpl::RemoveFromElementMap", "element_id", + layer->element_id(), "layer_id", layer->id()); + + ElementLayers& layers = element_layers_map_[layer->element_id()]; + if (!layer->scrollable()) + layers.main = nullptr; + if (layer->scrollable()) + layers.scroll = nullptr; + + if (!layers.main && !layers.scroll) + element_layers_map_.erase(layer->element_id()); +} + +LayerListImpl::ElementLayers LayerListImpl::GetMutableLayers( + uint64_t element_id) { + auto iter = element_layers_map_.find(element_id); + if (iter == element_layers_map_.end()) + return ElementLayers(); + + return iter->second; +} + +bool LayerListImpl::IsActiveList() const { + return layer_list_host_->active_list() == this; +} + +bool LayerListImpl::IsPendingList() const { + return layer_list_host_->pending_list() == this; +} + +} // namespace cc diff --git a/cc/layers/layer_list_impl.h b/cc/layers/layer_list_impl.h new file mode 100644 index 0000000..befe59e --- /dev/null +++ b/cc/layers/layer_list_impl.h @@ -0,0 +1,81 @@ +// Copyright 2016 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CC_LAYERS_LAYER_LIST_IMPL_H_ +#define CC_LAYERS_LAYER_LIST_IMPL_H_ + +#include <stdint.h> +#include <unordered_map> + +#include "cc/base/cc_export.h" +#include "cc/layers/layer_lists.h" + +namespace cc { +class AnimationRegistrar; +class LayerTreeHostImpl; +typedef LayerTreeHostImpl LayerListHostImpl; + +// This class will eventually replace LayerTreeImpl. +// +// There is certainly some unfortunate ambiguity with LayerImplList and +// OwnedLayerImplList, but this should be temporary. OwnedLayerImplList is used +// solely for the children of a LayerImpl and this will cease to be a thing as +// we move away from the layer hierarchy. The LayerImplList, however, does get +// used a fair bit to describe a list of LayerImpl*'s. I.e., an unowned layer +// list. In the medium term, I'd like to rename this LayerImplPtrList and, in +// the fullness of time, a LayerPtrList once Layer disappears. +class CC_EXPORT LayerListImpl { + public: + explicit LayerListImpl(LayerListHostImpl* host_impl); + ~LayerListImpl(); + + AnimationRegistrar* GetAnimationRegistrar() const; + + LayerImpl* LayerById(int id) const; + + // These should be called by LayerImpl's ctor/dtor. + void RegisterLayer(LayerImpl* layer); + void UnregisterLayer(LayerImpl* layer); + + size_t NumLayers(); + + LayerImpl* FindActiveLayerById(int id); + LayerImpl* FindPendingLayerById(int id); + + // TODO(vollick): once we've built compositor worker on top of animations, + // then this association of id to element layers will not be necessary. The + // association will instead be maintained via the animation. + void AddToElementMap(LayerImpl* layer); + void RemoveFromElementMap(LayerImpl* layer); + + // TODO(thakis): Consider marking this CC_EXPORT once we understand + // http://crbug.com/575700 better. + struct ElementLayers { + // Transform and opacity mutations apply to this layer. + LayerImpl* main = nullptr; + // Scroll mutations apply to this layer. + LayerImpl* scroll = nullptr; + }; + + // TODO(vollick): this should be removed as well. + ElementLayers GetMutableLayers(uint64_t element_id); + + private: + bool IsActiveList() const; + bool IsPendingList() const; + + // TODO(vollick): Remove after compositor worker is built on animations. + using ElementLayersMap = std::unordered_map<uint64_t, ElementLayers>; + ElementLayersMap element_layers_map_; + + using LayerIdMap = std::unordered_map<int, LayerImpl*>; + LayerIdMap layer_id_map_; + + LayerListHostImpl* layer_list_host_; + scoped_ptr<OwnedLayerImplList> layer_; +}; + +} // namespace cc + +#endif // CC_LAYERS_LAYER_LIST_IMPL_H_ diff --git a/cc/layers/layer_position_constraint_unittest.cc b/cc/layers/layer_position_constraint_unittest.cc index 490ce8e..c603197 100644 --- a/cc/layers/layer_position_constraint_unittest.cc +++ b/cc/layers/layer_position_constraint_unittest.cc @@ -1095,7 +1095,8 @@ TEST_F(LayerPositionConstraintTest, CommitAndUpdateImplPointers(); LayerImpl* fixed_child_impl = - root_impl_->layer_tree_impl()->FindActiveTreeLayerById(fixed_child->id()); + root_impl_->layer_tree_impl()->list()->FindActiveLayerById( + fixed_child->id()); // Case 1: fixed-container size delta of 20, 20 scroll_layer_impl_->SetScrollDelta(gfx::Vector2d(10, 10)); @@ -1116,8 +1117,8 @@ TEST_F(LayerPositionConstraintTest, // Case 2: Bottom-right fixed-position layer. fixed_child->SetPositionConstraint(fixed_to_bottom_right_); CommitAndUpdateImplPointers(); - fixed_child_impl = - root_impl_->layer_tree_impl()->FindActiveTreeLayerById(fixed_child->id()); + fixed_child_impl = root_impl_->layer_tree_impl()->list()->FindActiveLayerById( + fixed_child->id()); scroll_layer_impl_->SetScrollDelta(gfx::Vector2d(10, 10)); SetFixedContainerSizeDelta(scroll_layer_impl_, gfx::Vector2d(20, 20)); diff --git a/cc/layers/layer_utils.cc b/cc/layers/layer_utils.cc index 0289e2a..6b1873e 100644 --- a/cc/layers/layer_utils.cc +++ b/cc/layers/layer_utils.cc @@ -86,7 +86,7 @@ bool LayerUtils::GetAnimationBounds(const LayerImpl& layer_in, gfx::BoxF* out) { for (; transform_tree.parent(transform_node); transform_node = transform_tree.parent(transform_node)) { LayerImpl* layer = - layer_in.layer_tree_impl()->LayerById(transform_node->owner_id); + layer_in.layer_tree_impl()->list()->LayerById(transform_node->owner_id); // Filter animation bounds are unimplemented, see function // HasAncestorFilterAnimation() for reference. diff --git a/cc/layers/picture_layer_impl_perftest.cc b/cc/layers/picture_layer_impl_perftest.cc index c38dd3e..c5d947d 100644 --- a/cc/layers/picture_layer_impl_perftest.cc +++ b/cc/layers/picture_layer_impl_perftest.cc @@ -72,7 +72,7 @@ class PictureLayerImplPerfTest : public testing::Test { pending_tree->BuildPropertyTreesForTesting(); pending_layer_ = static_cast<FakePictureLayerImpl*>( - host_impl_.pending_tree()->LayerById(7)); + host_impl_.pending_tree()->list()->LayerById(7)); } void RunRasterQueueConstructAndIterateTest(const std::string& test_name, diff --git a/cc/layers/picture_layer_impl_unittest.cc b/cc/layers/picture_layer_impl_unittest.cc index f132b3f..c4230c2 100644 --- a/cc/layers/picture_layer_impl_unittest.cc +++ b/cc/layers/picture_layer_impl_unittest.cc @@ -155,7 +155,7 @@ class PictureLayerImplTest : public testing::Test { old_pending_layer_ = pending_layer_; pending_layer_ = nullptr; active_layer_ = static_cast<FakePictureLayerImpl*>( - host_impl_.active_tree()->LayerById(id_)); + host_impl_.active_tree()->list()->LayerById(id_)); bool update_lcd_text = false; host_impl_.active_tree()->UpdateDrawProperties(update_lcd_text); @@ -258,7 +258,7 @@ class PictureLayerImplTest : public testing::Test { Layer::INVALID_ID); pending_layer_ = static_cast<FakePictureLayerImpl*>( - host_impl_.pending_tree()->LayerById(id_)); + host_impl_.pending_tree()->list()->LayerById(id_)); // Add tilings/tiles for the layer. bool update_lcd_text = false; @@ -2240,7 +2240,7 @@ TEST_F(PictureLayerImplTest, ActivateUninitializedLayer) { pending_tree->SetRootLayer(std::move(pending_layer)); pending_layer_ = static_cast<FakePictureLayerImpl*>( - host_impl_.pending_tree()->LayerById(id_)); + host_impl_.pending_tree()->list()->LayerById(id_)); // Set some state on the pending layer, make sure it is not clobbered // by a sync from the active layer. This could happen because if the @@ -2252,7 +2252,7 @@ TEST_F(PictureLayerImplTest, ActivateUninitializedLayer) { host_impl_.ActivateSyncTree(); active_layer_ = static_cast<FakePictureLayerImpl*>( - host_impl_.active_tree()->LayerById(id_)); + host_impl_.active_tree()->list()->LayerById(id_)); EXPECT_EQ(0u, active_layer_->num_tilings()); EXPECT_EQ(raster_page_scale, active_layer_->raster_page_scale()); diff --git a/cc/layers/scrollbar_layer_impl_base.cc b/cc/layers/scrollbar_layer_impl_base.cc index e8e0f80..66e64a4 100644 --- a/cc/layers/scrollbar_layer_impl_base.cc +++ b/cc/layers/scrollbar_layer_impl_base.cc @@ -69,7 +69,8 @@ bool ScrollbarLayerImplBase::SetCurrentPos(float current_pos) { } bool ScrollbarLayerImplBase::CanScrollOrientation() const { - LayerImpl* scroll_layer = layer_tree_impl()->LayerById(scroll_layer_id_); + LayerImpl* scroll_layer = + layer_tree_impl()->list()->LayerById(scroll_layer_id_); if (!scroll_layer) return false; return scroll_layer->user_scrollable(orientation()) && diff --git a/cc/test/animation_timelines_test_common.cc b/cc/test/animation_timelines_test_common.cc index f941736..5c43ac0 100644 --- a/cc/test/animation_timelines_test_common.cc +++ b/cc/test/animation_timelines_test_common.cc @@ -54,8 +54,8 @@ void TestHostClient::ClearMutatedProperties() { } bool TestHostClient::IsLayerInTree(int layer_id, - LayerTreeType tree_type) const { - return tree_type == LayerTreeType::ACTIVE + LayerListType list_type) const { + return list_type == LayerListType::ACTIVE ? layers_in_active_tree_.count(layer_id) : layers_in_pending_tree_.count(layer_id); } @@ -67,37 +67,37 @@ void TestHostClient::SetMutatorsNeedCommit() { void TestHostClient::SetMutatorsNeedRebuildPropertyTrees() {} void TestHostClient::SetLayerFilterMutated(int layer_id, - LayerTreeType tree_type, + LayerListType list_type, const FilterOperations& filters) { for (unsigned i = 0; i < filters.size(); ++i) { const FilterOperation& filter = filters.at(i); if (filter.type() == FilterOperation::BRIGHTNESS) { - TestLayer* layer = FindTestLayer(layer_id, tree_type); + TestLayer* layer = FindTestLayer(layer_id, list_type); layer->set_brightness(filter.amount()); } } } void TestHostClient::SetLayerOpacityMutated(int layer_id, - LayerTreeType tree_type, + LayerListType list_type, float opacity) { - TestLayer* layer = FindTestLayer(layer_id, tree_type); + TestLayer* layer = FindTestLayer(layer_id, list_type); layer->set_opacity(opacity); } void TestHostClient::SetLayerTransformMutated(int layer_id, - LayerTreeType tree_type, + LayerListType list_type, const gfx::Transform& transform) { - TestLayer* layer = FindTestLayer(layer_id, tree_type); + TestLayer* layer = FindTestLayer(layer_id, list_type); gfx::Vector2dF vec = transform.To2dTranslation(); layer->set_transform(static_cast<int>(vec.x()), static_cast<int>(vec.y())); } void TestHostClient::SetLayerScrollOffsetMutated( int layer_id, - LayerTreeType tree_type, + LayerListType list_type, const gfx::ScrollOffset& scroll_offset) { - TestLayer* layer = FindTestLayer(layer_id, tree_type); + TestLayer* layer = FindTestLayer(layer_id, list_type); layer->set_scroll_offset(scroll_offset); } @@ -106,22 +106,22 @@ gfx::ScrollOffset TestHostClient::GetScrollOffsetForAnimation( return gfx::ScrollOffset(); } -void TestHostClient::RegisterLayer(int layer_id, LayerTreeType tree_type) { - LayerIdToTestLayer& layers_in_tree = tree_type == LayerTreeType::ACTIVE +void TestHostClient::RegisterLayer(int layer_id, LayerListType list_type) { + LayerIdToTestLayer& layers_in_tree = list_type == LayerListType::ACTIVE ? layers_in_active_tree_ : layers_in_pending_tree_; DCHECK(layers_in_tree.find(layer_id) == layers_in_tree.end()); layers_in_tree[layer_id] = TestLayer::Create(); DCHECK(host_); - host_->RegisterLayer(layer_id, tree_type); + host_->RegisterLayer(layer_id, list_type); } -void TestHostClient::UnregisterLayer(int layer_id, LayerTreeType tree_type) { +void TestHostClient::UnregisterLayer(int layer_id, LayerListType list_type) { DCHECK(host_); - host_->UnregisterLayer(layer_id, tree_type); + host_->UnregisterLayer(layer_id, list_type); - LayerIdToTestLayer& layers_in_tree = tree_type == LayerTreeType::ACTIVE + LayerIdToTestLayer& layers_in_tree = list_type == LayerListType::ACTIVE ? layers_in_active_tree_ : layers_in_pending_tree_; auto kv = layers_in_tree.find(layer_id); @@ -130,41 +130,41 @@ void TestHostClient::UnregisterLayer(int layer_id, LayerTreeType tree_type) { } bool TestHostClient::IsPropertyMutated(int layer_id, - LayerTreeType tree_type, + LayerListType list_type, TargetProperty::Type property) const { - TestLayer* layer = FindTestLayer(layer_id, tree_type); + TestLayer* layer = FindTestLayer(layer_id, list_type); return layer->is_property_mutated(property); } void TestHostClient::ExpectFilterPropertyMutated(int layer_id, - LayerTreeType tree_type, + LayerListType list_type, float brightness) const { - TestLayer* layer = FindTestLayer(layer_id, tree_type); + TestLayer* layer = FindTestLayer(layer_id, list_type); EXPECT_TRUE(layer->is_property_mutated(TargetProperty::OPACITY)); EXPECT_EQ(brightness, layer->brightness()); } void TestHostClient::ExpectOpacityPropertyMutated(int layer_id, - LayerTreeType tree_type, + LayerListType list_type, float opacity) const { - TestLayer* layer = FindTestLayer(layer_id, tree_type); + TestLayer* layer = FindTestLayer(layer_id, list_type); EXPECT_TRUE(layer->is_property_mutated(TargetProperty::OPACITY)); EXPECT_EQ(opacity, layer->opacity()); } void TestHostClient::ExpectTransformPropertyMutated(int layer_id, - LayerTreeType tree_type, + LayerListType list_type, int transform_x, int transform_y) const { - TestLayer* layer = FindTestLayer(layer_id, tree_type); + TestLayer* layer = FindTestLayer(layer_id, list_type); EXPECT_TRUE(layer->is_property_mutated(TargetProperty::OPACITY)); EXPECT_EQ(transform_x, layer->transform_x()); EXPECT_EQ(transform_y, layer->transform_y()); } TestLayer* TestHostClient::FindTestLayer(int layer_id, - LayerTreeType tree_type) const { - const LayerIdToTestLayer& layers_in_tree = tree_type == LayerTreeType::ACTIVE + LayerListType list_type) const { + const LayerIdToTestLayer& layers_in_tree = list_type == LayerListType::ACTIVE ? layers_in_active_tree_ : layers_in_pending_tree_; auto kv = layers_in_tree.find(layer_id); diff --git a/cc/test/animation_timelines_test_common.h b/cc/test/animation_timelines_test_common.h index 0d041b5..9fdd451 100644 --- a/cc/test/animation_timelines_test_common.h +++ b/cc/test/animation_timelines_test_common.h @@ -74,30 +74,30 @@ class TestHostClient : public MutatorHostClient { void ClearMutatedProperties(); - bool IsLayerInTree(int layer_id, LayerTreeType tree_type) const override; + bool IsLayerInTree(int layer_id, LayerListType list_type) const override; void SetMutatorsNeedCommit() override; void SetMutatorsNeedRebuildPropertyTrees() override; void SetLayerFilterMutated(int layer_id, - LayerTreeType tree_type, + LayerListType list_type, const FilterOperations& filters) override; void SetLayerOpacityMutated(int layer_id, - LayerTreeType tree_type, + LayerListType list_type, float opacity) override; void SetLayerTransformMutated(int layer_id, - LayerTreeType tree_type, + LayerListType list_type, const gfx::Transform& transform) override; void SetLayerScrollOffsetMutated( int layer_id, - LayerTreeType tree_type, + LayerListType list_type, const gfx::ScrollOffset& scroll_offset) override; void LayerTransformIsPotentiallyAnimatingChanged(int layer_id, - LayerTreeType tree_type, + LayerListType list_type, bool is_animating) override { } @@ -107,8 +107,8 @@ class TestHostClient : public MutatorHostClient { bool mutators_need_commit() const { return mutators_need_commit_; } void set_mutators_need_commit(bool need) { mutators_need_commit_ = need; } - void RegisterLayer(int layer_id, LayerTreeType tree_type); - void UnregisterLayer(int layer_id, LayerTreeType tree_type); + void RegisterLayer(int layer_id, LayerListType list_type); + void UnregisterLayer(int layer_id, LayerListType list_type); AnimationHost* host() { DCHECK(host_); @@ -116,21 +116,21 @@ class TestHostClient : public MutatorHostClient { } bool IsPropertyMutated(int layer_id, - LayerTreeType tree_type, + LayerListType list_type, TargetProperty::Type property) const; void ExpectFilterPropertyMutated(int layer_id, - LayerTreeType tree_type, + LayerListType list_type, float brightness) const; void ExpectOpacityPropertyMutated(int layer_id, - LayerTreeType tree_type, + LayerListType list_type, float opacity) const; void ExpectTransformPropertyMutated(int layer_id, - LayerTreeType tree_type, + LayerListType list_type, int transform_x, int transform_y) const; - TestLayer* FindTestLayer(int layer_id, LayerTreeType tree_type) const; + TestLayer* FindTestLayer(int layer_id, LayerListType list_type) const; private: scoped_ptr<AnimationHost> host_; diff --git a/cc/tiles/tile_manager_perftest.cc b/cc/tiles/tile_manager_perftest.cc index 53b7ba8..648ebf1 100644 --- a/cc/tiles/tile_manager_perftest.cc +++ b/cc/tiles/tile_manager_perftest.cc @@ -144,7 +144,7 @@ class TileManagerPerfTest : public testing::Test { CHECK(!host_impl_.pending_tree()); pending_root_layer_ = NULL; active_root_layer_ = static_cast<FakePictureLayerImpl*>( - host_impl_.active_tree()->LayerById(id_)); + host_impl_.active_tree()->list()->LayerById(id_)); } void SetupDefaultTreesWithFixedTileSize(const gfx::Size& layer_bounds, @@ -176,7 +176,7 @@ class TileManagerPerfTest : public testing::Test { pending_tree->BuildPropertyTreesForTesting(); pending_root_layer_ = static_cast<FakePictureLayerImpl*>( - host_impl_.pending_tree()->LayerById(id_)); + host_impl_.pending_tree()->list()->LayerById(id_)); } void RunRasterQueueConstructTest(const std::string& test_name, diff --git a/cc/tiles/tile_manager_unittest.cc b/cc/tiles/tile_manager_unittest.cc index 3dd1453..5a3f5eb 100644 --- a/cc/tiles/tile_manager_unittest.cc +++ b/cc/tiles/tile_manager_unittest.cc @@ -103,7 +103,7 @@ class TileManagerTilePriorityQueueTest : public testing::Test { CHECK(!host_impl_.pending_tree()); pending_layer_ = NULL; active_layer_ = static_cast<FakePictureLayerImpl*>( - host_impl_.active_tree()->LayerById(id_)); + host_impl_.active_tree()->list()->LayerById(id_)); bool update_lcd_text = false; host_impl_.active_tree()->UpdateDrawProperties(update_lcd_text); } @@ -146,7 +146,7 @@ class TileManagerTilePriorityQueueTest : public testing::Test { pending_tree->SetRootLayer(std::move(pending_layer)); pending_layer_ = static_cast<FakePictureLayerImpl*>( - host_impl_.pending_tree()->LayerById(id_)); + host_impl_.pending_tree()->list()->LayerById(id_)); // Add tilings/tiles for the layer. bool update_lcd_text = false; diff --git a/cc/trees/layer_tree_host.cc b/cc/trees/layer_tree_host.cc index c940d22..102d392 100644 --- a/cc/trees/layer_tree_host.cc +++ b/cc/trees/layer_tree_host.cc @@ -1257,19 +1257,19 @@ void LayerTreeHost::RegisterLayer(Layer* layer) { DCHECK(!in_paint_layer_contents_); layer_id_map_[layer->id()] = layer; if (animation_host_) - animation_host_->RegisterLayer(layer->id(), LayerTreeType::ACTIVE); + animation_host_->RegisterLayer(layer->id(), LayerListType::ACTIVE); } void LayerTreeHost::UnregisterLayer(Layer* layer) { DCHECK(LayerById(layer->id())); DCHECK(!in_paint_layer_contents_); if (animation_host_) - animation_host_->UnregisterLayer(layer->id(), LayerTreeType::ACTIVE); + animation_host_->UnregisterLayer(layer->id(), LayerListType::ACTIVE); layer_id_map_.erase(layer->id()); } -bool LayerTreeHost::IsLayerInTree(int layer_id, LayerTreeType tree_type) const { - return tree_type == LayerTreeType::ACTIVE && LayerById(layer_id); +bool LayerTreeHost::IsLayerInTree(int layer_id, LayerListType list_type) const { + return list_type == LayerListType::ACTIVE && LayerById(layer_id); } void LayerTreeHost::SetMutatorsNeedCommit() { @@ -1281,7 +1281,7 @@ void LayerTreeHost::SetMutatorsNeedRebuildPropertyTrees() { } void LayerTreeHost::SetLayerFilterMutated(int layer_id, - LayerTreeType tree_type, + LayerListType list_type, const FilterOperations& filters) { LayerAnimationValueObserver* layer = LayerById(layer_id); DCHECK(layer); @@ -1289,7 +1289,7 @@ void LayerTreeHost::SetLayerFilterMutated(int layer_id, } void LayerTreeHost::SetLayerOpacityMutated(int layer_id, - LayerTreeType tree_type, + LayerListType list_type, float opacity) { LayerAnimationValueObserver* layer = LayerById(layer_id); DCHECK(layer); @@ -1297,7 +1297,7 @@ void LayerTreeHost::SetLayerOpacityMutated(int layer_id, } void LayerTreeHost::SetLayerTransformMutated(int layer_id, - LayerTreeType tree_type, + LayerListType list_type, const gfx::Transform& transform) { LayerAnimationValueObserver* layer = LayerById(layer_id); DCHECK(layer); @@ -1306,7 +1306,7 @@ void LayerTreeHost::SetLayerTransformMutated(int layer_id, void LayerTreeHost::SetLayerScrollOffsetMutated( int layer_id, - LayerTreeType tree_type, + LayerListType list_type, const gfx::ScrollOffset& scroll_offset) { LayerAnimationValueObserver* layer = LayerById(layer_id); DCHECK(layer); @@ -1315,7 +1315,7 @@ void LayerTreeHost::SetLayerScrollOffsetMutated( void LayerTreeHost::LayerTransformIsPotentiallyAnimatingChanged( int layer_id, - LayerTreeType tree_type, + LayerListType list_type, bool is_animating) { LayerAnimationValueObserver* layer = LayerById(layer_id); DCHECK(layer); @@ -1339,21 +1339,21 @@ bool LayerTreeHost::ScrollOffsetAnimationWasInterrupted( bool LayerTreeHost::IsAnimatingFilterProperty(const Layer* layer) const { return animation_host_ ? animation_host_->IsAnimatingFilterProperty(layer->id(), - LayerTreeType::ACTIVE) + LayerListType::ACTIVE) : false; } bool LayerTreeHost::IsAnimatingOpacityProperty(const Layer* layer) const { return animation_host_ ? animation_host_->IsAnimatingOpacityProperty( - layer->id(), LayerTreeType::ACTIVE) + layer->id(), LayerListType::ACTIVE) : false; } bool LayerTreeHost::IsAnimatingTransformProperty(const Layer* layer) const { return animation_host_ ? animation_host_->IsAnimatingTransformProperty( - layer->id(), LayerTreeType::ACTIVE) + layer->id(), LayerListType::ACTIVE) : false; } @@ -1361,7 +1361,7 @@ bool LayerTreeHost::HasPotentiallyRunningFilterAnimation( const Layer* layer) const { return animation_host_ ? animation_host_->HasPotentiallyRunningFilterAnimation( - layer->id(), LayerTreeType::ACTIVE) + layer->id(), LayerListType::ACTIVE) : false; } @@ -1369,7 +1369,7 @@ bool LayerTreeHost::HasPotentiallyRunningOpacityAnimation( const Layer* layer) const { return animation_host_ ? animation_host_->HasPotentiallyRunningOpacityAnimation( - layer->id(), LayerTreeType::ACTIVE) + layer->id(), LayerListType::ACTIVE) : false; } @@ -1377,14 +1377,14 @@ bool LayerTreeHost::HasPotentiallyRunningTransformAnimation( const Layer* layer) const { return animation_host_ ? animation_host_->HasPotentiallyRunningTransformAnimation( - layer->id(), LayerTreeType::ACTIVE) + layer->id(), LayerListType::ACTIVE) : false; } bool LayerTreeHost::HasOnlyTranslationTransforms(const Layer* layer) const { return animation_host_ ? animation_host_->HasOnlyTranslationTransforms( - layer->id(), LayerTreeType::ACTIVE) + layer->id(), LayerListType::ACTIVE) : false; } @@ -1392,7 +1392,7 @@ bool LayerTreeHost::MaximumTargetScale(const Layer* layer, float* max_scale) const { return animation_host_ ? animation_host_->MaximumTargetScale( - layer->id(), LayerTreeType::ACTIVE, max_scale) + layer->id(), LayerListType::ACTIVE, max_scale) : false; } @@ -1400,7 +1400,7 @@ bool LayerTreeHost::AnimationStartScale(const Layer* layer, float* start_scale) const { return animation_host_ ? animation_host_->AnimationStartScale( - layer->id(), LayerTreeType::ACTIVE, start_scale) + layer->id(), LayerListType::ACTIVE, start_scale) : false; } diff --git a/cc/trees/layer_tree_host.h b/cc/trees/layer_tree_host.h index c985002..38b8d5d 100644 --- a/cc/trees/layer_tree_host.h +++ b/cc/trees/layer_tree_host.h @@ -365,24 +365,24 @@ class CC_EXPORT LayerTreeHost : public MutatorHostClient { void RegisterLayer(Layer* layer); void UnregisterLayer(Layer* layer); // LayerTreeMutatorsClient implementation. - bool IsLayerInTree(int layer_id, LayerTreeType tree_type) const override; + bool IsLayerInTree(int layer_id, LayerListType list_type) const override; void SetMutatorsNeedCommit() override; void SetMutatorsNeedRebuildPropertyTrees() override; void SetLayerFilterMutated(int layer_id, - LayerTreeType tree_type, + LayerListType list_type, const FilterOperations& filters) override; void SetLayerOpacityMutated(int layer_id, - LayerTreeType tree_type, + LayerListType list_type, float opacity) override; void SetLayerTransformMutated(int layer_id, - LayerTreeType tree_type, + LayerListType list_type, const gfx::Transform& transform) override; void SetLayerScrollOffsetMutated( int layer_id, - LayerTreeType tree_type, + LayerListType list_type, const gfx::ScrollOffset& scroll_offset) override; void LayerTransformIsPotentiallyAnimatingChanged(int layer_id, - LayerTreeType tree_type, + LayerListType list_type, bool is_animating) override; void ScrollOffsetAnimationFinished() override {} gfx::ScrollOffset GetScrollOffsetForAnimation(int layer_id) const override; diff --git a/cc/trees/layer_tree_host_common.cc b/cc/trees/layer_tree_host_common.cc index c8baceb..ba55171 100644 --- a/cc/trees/layer_tree_host_common.cc +++ b/cc/trees/layer_tree_host_common.cc @@ -1099,7 +1099,7 @@ static float TranslationFromActiveTreeLayerScreenSpaceTransform( LayerTreeImpl* layer_tree_impl = pending_tree_layer->layer_tree_impl(); if (layer_tree_impl) { LayerImpl* active_tree_layer = - layer_tree_impl->FindActiveTreeLayerById(pending_tree_layer->id()); + layer_tree_impl->list()->FindActiveLayerById(pending_tree_layer->id()); if (active_tree_layer) { gfx::Transform active_tree_screen_space_transform = active_tree_layer->draw_properties().screen_space_transform; @@ -1606,10 +1606,11 @@ void LayerTreeHostCommon::CalculateDrawProperties( if (layer_tree_impl->IsPendingTree() && layer_tree_impl->is_first_frame_after_commit()) { LayerImpl* active_tree_root = - layer_tree_impl->FindActiveTreeLayerById(inputs->root_layer->id()); + layer_tree_impl->list()->FindActiveLayerById( + inputs->root_layer->id()); float jitter = 0.f; if (active_tree_root) { - LayerImpl* last_scrolled_layer = layer_tree_impl->LayerById( + LayerImpl* last_scrolled_layer = layer_tree_impl->list()->LayerById( active_tree_root->layer_tree_impl()->LastScrolledLayerId()); jitter = CalculateFrameJitter(last_scrolled_layer); } diff --git a/cc/trees/layer_tree_host_common_unittest.cc b/cc/trees/layer_tree_host_common_unittest.cc index 69a8ce7..cfcc1ec 100644 --- a/cc/trees/layer_tree_host_common_unittest.cc +++ b/cc/trees/layer_tree_host_common_unittest.cc @@ -5232,7 +5232,7 @@ TEST_F(LayerTreeHostCommonTest, OpacityAnimatingOnPendingTree) { inputs2.can_adjust_raster_scales = true; LayerTreeHostCommon::CalculateDrawProperties(&inputs2); - LayerImpl* child_ptr = root->layer_tree_impl()->LayerById(2); + LayerImpl* child_ptr = root->layer_tree_impl()->list()->LayerById(2); EffectTree tree = root->layer_tree_impl()->property_trees()->effect_tree; EffectNode* node = tree.Node(child_ptr->effect_tree_index()); EXPECT_FALSE(node->data.is_drawn); @@ -5250,7 +5250,7 @@ TEST_F(LayerTreeHostCommonTest, OpacityAnimatingOnPendingTree) { inputs3.can_adjust_raster_scales = true; LayerTreeHostCommon::CalculateDrawProperties(&inputs3); - child_ptr = root->layer_tree_impl()->LayerById(2); + child_ptr = root->layer_tree_impl()->list()->LayerById(2); tree = root->layer_tree_impl()->property_trees()->effect_tree; node = tree.Node(child_ptr->effect_tree_index()); EXPECT_TRUE(node->data.is_drawn); diff --git a/cc/trees/layer_tree_host_impl.cc b/cc/trees/layer_tree_host_impl.cc index 6a9fee0..26dba53 100644 --- a/cc/trees/layer_tree_host_impl.cc +++ b/cc/trees/layer_tree_host_impl.cc @@ -1068,7 +1068,7 @@ DrawResult LayerTreeHostImpl::PrepareToDraw(FrameData* frame) { UMA_HISTOGRAM_CUSTOM_COUNTS( "Compositing.NumActiveLayers", - base::saturated_cast<int>(active_tree_->NumLayers()), 1, 400, 20); + base::saturated_cast<int>(active_tree_->list()->NumLayers()), 1, 400, 20); if (const char* client_name = GetClientNameForMetrics()) { size_t total_picture_memory = 0; @@ -1281,6 +1281,22 @@ scoped_ptr<RasterTilePriorityQueue> LayerTreeHostImpl::BuildRasterQueue( tree_priority, type); } +LayerListImpl* LayerTreeHostImpl::active_list() { + return active_tree_.get() ? active_tree_->list() : nullptr; +} + +const LayerListImpl* LayerTreeHostImpl::active_list() const { + return active_tree_.get() ? active_tree_->list() : nullptr; +} + +LayerListImpl* LayerTreeHostImpl::pending_list() { + return pending_tree_.get() ? pending_tree_->list() : nullptr; +} + +const LayerListImpl* LayerTreeHostImpl::pending_list() const { + return pending_tree_.get() ? pending_tree_->list() : nullptr; +} + scoped_ptr<EvictionTilePriorityQueue> LayerTreeHostImpl::BuildEvictionQueue( TreePriority tree_priority) { TRACE_EVENT0("disabled-by-default-cc.debug", @@ -1330,14 +1346,14 @@ void LayerTreeHostImpl::NotifyTileStateChanged(const Tile* tile) { if (active_tree_) { LayerImpl* layer_impl = - active_tree_->FindActiveTreeLayerById(tile->layer_id()); + active_tree_->list()->FindActiveLayerById(tile->layer_id()); if (layer_impl) layer_impl->NotifyTileStateChanged(tile); } if (pending_tree_) { LayerImpl* layer_impl = - pending_tree_->FindPendingTreeLayerById(tile->layer_id()); + pending_tree_->list()->FindPendingLayerById(tile->layer_id()); if (layer_impl) layer_impl->NotifyTileStateChanged(tile); } @@ -2456,6 +2472,7 @@ InputHandler::ScrollStatus LayerTreeHostImpl::TryScroll( inverse_screen_space_transform, screen_space_point, &clipped); if (!clipped && active_tree() + ->list() ->LayerById(scroll_node->owner_id) ->non_fast_scrollable_region() .Contains(gfx::ToRoundedPoint(hit_test_point_in_layer_space))) { @@ -2547,7 +2564,7 @@ LayerImpl* LayerTreeHostImpl::FindScrollLayerForDeviceViewportPoint( if (status.thread == InputHandler::SCROLL_ON_IMPL_THREAD && !potentially_scrolling_layer_impl) { potentially_scrolling_layer_impl = - active_tree_->LayerById(scroll_node->owner_id); + active_tree_->list()->LayerById(scroll_node->owner_id); } } } @@ -2730,7 +2747,8 @@ InputHandler::ScrollStatus LayerTreeHostImpl::ScrollAnimated( if (!scroll_node->data.scrollable) continue; - LayerImpl* layer_impl = active_tree_->LayerById(scroll_node->owner_id); + LayerImpl* layer_impl = + active_tree_->list()->LayerById(scroll_node->owner_id); gfx::ScrollOffset current_offset = layer_impl->CurrentScrollOffset(); gfx::ScrollOffset target_offset = ScrollOffsetWithDelta(current_offset, pending_delta); @@ -2975,7 +2993,7 @@ InputHandlerScrollResult LayerTreeHostImpl::ScrollBy( DistributeScrollDelta(scroll_state); - active_tree_->SetCurrentlyScrollingLayer(active_tree_->LayerById( + active_tree_->SetCurrentlyScrollingLayer(active_tree_->list()->LayerById( scroll_state->current_native_scrolling_node()->owner_id)); did_lock_scrolling_layer_ = scroll_state->delta_consumed_for_scroll_sequence(); @@ -3042,7 +3060,8 @@ bool LayerTreeHostImpl::ScrollVerticallyByPage(const gfx::Point& viewport_point, if (scroll_node) { for (; scroll_tree.parent(scroll_node); scroll_node = scroll_tree.parent(scroll_node)) { - LayerImpl* layer_impl = active_tree_->LayerById(scroll_node->owner_id); + LayerImpl* layer_impl = + active_tree_->list()->LayerById(scroll_node->owner_id); // The inner viewport layer represents the viewport. if (!scroll_node->data.scrollable || scroll_node->data.is_outer_viewport_scroll_layer) @@ -3743,7 +3762,8 @@ void LayerTreeHostImpl::ScrollAnimationCreate( return animation_host_->ImplOnlyScrollAnimationCreate( scroll_node->owner_id, target_offset, current_offset); - LayerImpl* layer_impl = active_tree_->LayerById(scroll_node->owner_id); + LayerImpl* layer_impl = + active_tree_->list()->LayerById(scroll_node->owner_id); scoped_ptr<ScrollOffsetAnimationCurve> curve = ScrollOffsetAnimationCurve::Create( @@ -3769,7 +3789,8 @@ bool LayerTreeHostImpl::ScrollAnimationUpdateTarget( scroll_node->id), CurrentBeginFrameArgs().frame_time); - LayerImpl* layer_impl = active_tree_->LayerById(scroll_node->owner_id); + LayerImpl* layer_impl = + active_tree_->list()->LayerById(scroll_node->owner_id); Animation* animation = layer_impl->layer_animation_controller() @@ -3796,14 +3817,14 @@ bool LayerTreeHostImpl::ScrollAnimationUpdateTarget( } bool LayerTreeHostImpl::IsLayerInTree(int layer_id, - LayerTreeType tree_type) const { - if (tree_type == LayerTreeType::ACTIVE) { - return active_tree() ? active_tree()->LayerById(layer_id) != nullptr + LayerListType list_type) const { + if (list_type == LayerListType::ACTIVE) { + return active_tree() ? active_tree()->list()->LayerById(layer_id) != nullptr : false; } else { - if (pending_tree() && pending_tree()->LayerById(layer_id)) + if (pending_tree() && pending_tree()->list()->LayerById(layer_id)) return true; - if (recycle_tree() && recycle_tree()->LayerById(layer_id)) + if (recycle_tree() && recycle_tree()->list()->LayerById(layer_id)) return true; return false; @@ -3821,7 +3842,7 @@ void LayerTreeHostImpl::SetTreeLayerFilterMutated( if (!tree) return; - LayerAnimationValueObserver* layer = tree->LayerById(layer_id); + LayerAnimationValueObserver* layer = tree->list()->LayerById(layer_id); if (layer) layer->OnFilterAnimated(filters); } @@ -3832,7 +3853,7 @@ void LayerTreeHostImpl::SetTreeLayerOpacityMutated(int layer_id, if (!tree) return; - LayerAnimationValueObserver* layer = tree->LayerById(layer_id); + LayerAnimationValueObserver* layer = tree->list()->LayerById(layer_id); if (layer) layer->OnOpacityAnimated(opacity); } @@ -3844,7 +3865,7 @@ void LayerTreeHostImpl::SetTreeLayerTransformMutated( if (!tree) return; - LayerAnimationValueObserver* layer = tree->LayerById(layer_id); + LayerAnimationValueObserver* layer = tree->list()->LayerById(layer_id); if (layer) layer->OnTransformAnimated(transform); } @@ -3856,7 +3877,7 @@ void LayerTreeHostImpl::SetTreeLayerScrollOffsetMutated( if (!tree) return; - LayerAnimationValueObserver* layer = tree->LayerById(layer_id); + LayerAnimationValueObserver* layer = tree->list()->LayerById(layer_id); if (layer) layer->OnScrollOffsetAnimated(scroll_offset); } @@ -3868,7 +3889,7 @@ void LayerTreeHostImpl::TreeLayerTransformIsPotentiallyAnimatingChanged( if (!tree) return; - LayerAnimationValueObserver* layer = tree->LayerById(layer_id); + LayerAnimationValueObserver* layer = tree->list()->LayerById(layer_id); if (layer) layer->OnTransformIsPotentiallyAnimatingChanged(is_animating); } @@ -3881,9 +3902,9 @@ bool LayerTreeHostImpl::AnimationsPreserveAxisAlignment( } void LayerTreeHostImpl::SetLayerFilterMutated(int layer_id, - LayerTreeType tree_type, + LayerListType list_type, const FilterOperations& filters) { - if (tree_type == LayerTreeType::ACTIVE) { + if (list_type == LayerListType::ACTIVE) { SetTreeLayerFilterMutated(layer_id, active_tree(), filters); } else { SetTreeLayerFilterMutated(layer_id, pending_tree(), filters); @@ -3892,9 +3913,9 @@ void LayerTreeHostImpl::SetLayerFilterMutated(int layer_id, } void LayerTreeHostImpl::SetLayerOpacityMutated(int layer_id, - LayerTreeType tree_type, + LayerListType list_type, float opacity) { - if (tree_type == LayerTreeType::ACTIVE) { + if (list_type == LayerListType::ACTIVE) { SetTreeLayerOpacityMutated(layer_id, active_tree(), opacity); } else { SetTreeLayerOpacityMutated(layer_id, pending_tree(), opacity); @@ -3904,9 +3925,9 @@ void LayerTreeHostImpl::SetLayerOpacityMutated(int layer_id, void LayerTreeHostImpl::SetLayerTransformMutated( int layer_id, - LayerTreeType tree_type, + LayerListType list_type, const gfx::Transform& transform) { - if (tree_type == LayerTreeType::ACTIVE) { + if (list_type == LayerListType::ACTIVE) { SetTreeLayerTransformMutated(layer_id, active_tree(), transform); } else { SetTreeLayerTransformMutated(layer_id, pending_tree(), transform); @@ -3916,9 +3937,9 @@ void LayerTreeHostImpl::SetLayerTransformMutated( void LayerTreeHostImpl::SetLayerScrollOffsetMutated( int layer_id, - LayerTreeType tree_type, + LayerListType list_type, const gfx::ScrollOffset& scroll_offset) { - if (tree_type == LayerTreeType::ACTIVE) { + if (list_type == LayerListType::ACTIVE) { SetTreeLayerScrollOffsetMutated(layer_id, active_tree(), scroll_offset); } else { SetTreeLayerScrollOffsetMutated(layer_id, pending_tree(), scroll_offset); @@ -3928,9 +3949,9 @@ void LayerTreeHostImpl::SetLayerScrollOffsetMutated( void LayerTreeHostImpl::LayerTransformIsPotentiallyAnimatingChanged( int layer_id, - LayerTreeType tree_type, + LayerListType list_type, bool is_animating) { - if (tree_type == LayerTreeType::ACTIVE) { + if (list_type == LayerListType::ACTIVE) { TreeLayerTransformIsPotentiallyAnimatingChanged(layer_id, active_tree(), is_animating); } else { @@ -3949,7 +3970,8 @@ void LayerTreeHostImpl::ScrollOffsetAnimationFinished() { gfx::ScrollOffset LayerTreeHostImpl::GetScrollOffsetForAnimation( int layer_id) const { if (active_tree()) { - LayerAnimationValueProvider* layer = active_tree()->LayerById(layer_id); + LayerAnimationValueProvider* layer = + active_tree()->list()->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 9c2e58e..a2520fb 100644 --- a/cc/trees/layer_tree_host_impl.h +++ b/cc/trees/layer_tree_host_impl.h @@ -257,24 +257,24 @@ class CC_EXPORT LayerTreeHostImpl bool AnimationsPreserveAxisAlignment(const LayerImpl* layer) const; // LayerTreeMutatorsClient implementation. - bool IsLayerInTree(int layer_id, LayerTreeType tree_type) const override; + bool IsLayerInTree(int layer_id, LayerListType list_type) const override; void SetMutatorsNeedCommit() override; void SetMutatorsNeedRebuildPropertyTrees() override; void SetLayerFilterMutated(int layer_id, - LayerTreeType tree_type, + LayerListType list_type, const FilterOperations& filters) override; void SetLayerOpacityMutated(int layer_id, - LayerTreeType tree_type, + LayerListType list_type, float opacity) override; void SetLayerTransformMutated(int layer_id, - LayerTreeType tree_type, + LayerListType list_type, const gfx::Transform& transform) override; void SetLayerScrollOffsetMutated( int layer_id, - LayerTreeType tree_type, + LayerListType list_type, const gfx::ScrollOffset& scroll_offset) override; void LayerTransformIsPotentiallyAnimatingChanged(int layer_id, - LayerTreeType tree_type, + LayerListType list_type, bool is_animating) override; void ScrollOffsetAnimationFinished() override; gfx::ScrollOffset GetScrollOffsetForAnimation(int layer_id) const override; @@ -409,6 +409,14 @@ class CC_EXPORT LayerTreeHostImpl virtual void DidFinishImplFrame(); void DidModifyTilePriorities(); + // TODO(vollick): we will retain both the _tree() and _list() accessors while + // we migrate to layer lists, but the plan is to eventually remove the _tree() + // ones. + LayerListImpl* active_list(); + const LayerListImpl* active_list() const; + LayerListImpl* pending_list(); + const LayerListImpl* pending_list() const; + LayerTreeImpl* active_tree() { return active_tree_.get(); } const LayerTreeImpl* active_tree() const { return active_tree_.get(); } LayerTreeImpl* pending_tree() { return pending_tree_.get(); } @@ -841,6 +849,8 @@ class CC_EXPORT LayerTreeHostImpl DISALLOW_COPY_AND_ASSIGN(LayerTreeHostImpl); }; +typedef LayerTreeHostImpl LayerListHostImpl; + } // namespace cc #endif // CC_TREES_LAYER_TREE_HOST_IMPL_H_ diff --git a/cc/trees/layer_tree_host_impl_unittest.cc b/cc/trees/layer_tree_host_impl_unittest.cc index c44a851..2f543e9 100644 --- a/cc/trees/layer_tree_host_impl_unittest.cc +++ b/cc/trees/layer_tree_host_impl_unittest.cc @@ -2743,7 +2743,8 @@ class LayerTreeHostImplTestScrollbarOpacity : public LayerTreeHostImplTest { host_impl_->pending_tree()->BuildPropertyTreesForTesting(); host_impl_->ActivateSyncTree(); - LayerImpl* scrollbar_layer = host_impl_->active_tree()->LayerById(400); + LayerImpl* scrollbar_layer = + host_impl_->active_tree()->list()->LayerById(400); EffectNode* active_tree_node = host_impl_->active_tree()->property_trees()->effect_tree.Node( @@ -7739,12 +7740,12 @@ TEST_F(LayerTreeHostImplTest, ScrollUnknownNotOnAncestorChain) { int scroll_layer_id = 2; LayerImpl* scroll_layer = - host_impl_->active_tree()->LayerById(scroll_layer_id); + host_impl_->active_tree()->list()->LayerById(scroll_layer_id); scroll_layer->SetDrawsContent(true); int page_scale_layer_id = 5; LayerImpl* page_scale_layer = - host_impl_->active_tree()->LayerById(page_scale_layer_id); + host_impl_->active_tree()->list()->LayerById(page_scale_layer_id); int occluder_layer_id = 6; scoped_ptr<LayerImpl> occluder_layer = @@ -7775,7 +7776,7 @@ TEST_F(LayerTreeHostImplTest, ScrollUnknownScrollAncestorMismatch) { int scroll_layer_id = 2; LayerImpl* scroll_layer = - host_impl_->active_tree()->LayerById(scroll_layer_id); + host_impl_->active_tree()->list()->LayerById(scroll_layer_id); scroll_layer->SetDrawsContent(true); int occluder_layer_id = 6; @@ -7813,11 +7814,11 @@ TEST_F(LayerTreeHostImplTest, NotScrollInvisibleScroller) { gfx::Size content_size(100, 100); SetupScrollAndContentsLayers(content_size); - LayerImpl* root = host_impl_->active_tree()->LayerById(1); + LayerImpl* root = host_impl_->active_tree()->list()->LayerById(1); int scroll_layer_id = 2; LayerImpl* scroll_layer = - host_impl_->active_tree()->LayerById(scroll_layer_id); + host_impl_->active_tree()->list()->LayerById(scroll_layer_id); int child_scroll_layer_id = 7; scoped_ptr<LayerImpl> child_scroll = @@ -7847,8 +7848,9 @@ TEST_F(LayerTreeHostImplTest, ScrollInvisibleScrollerWithVisibleDescendent) { gfx::Size content_size(100, 100); SetupScrollAndContentsLayers(content_size); - LayerImpl* root = host_impl_->active_tree()->LayerById(1); - LayerImpl* root_scroll_layer = host_impl_->active_tree()->LayerById(2); + LayerImpl* root = host_impl_->active_tree()->list()->LayerById(1); + LayerImpl* root_scroll_layer = + host_impl_->active_tree()->list()->LayerById(2); scoped_ptr<LayerImpl> invisible_scroll_layer = CreateScrollableLayer(7, content_size, root); @@ -7890,11 +7892,11 @@ TEST_F(LayerTreeHostImplTest, ScrollInvisibleScrollerWithVisibleScrollChild) { gfx::Size content_size(100, 100); SetupScrollAndContentsLayers(content_size); - LayerImpl* root = host_impl_->active_tree()->LayerById(1); + LayerImpl* root = host_impl_->active_tree()->list()->LayerById(1); int scroll_layer_id = 2; LayerImpl* scroll_layer = - host_impl_->active_tree()->LayerById(scroll_layer_id); + host_impl_->active_tree()->list()->LayerById(scroll_layer_id); int scroll_child_id = 6; scoped_ptr<LayerImpl> scroll_child = @@ -9270,7 +9272,7 @@ TEST_F(LayerTreeHostImplTest, ExternalTransformAffectsSublayerScaleFactor) { ->children()[0] .get(); content_layer->AddChild(LayerImpl::Create(host_impl_->active_tree(), 100)); - LayerImpl* test_layer = host_impl_->active_tree()->LayerById(100); + LayerImpl* test_layer = host_impl_->active_tree()->list()->LayerById(100); test_layer->SetForceRenderSurface(true); test_layer->SetDrawsContent(true); test_layer->SetBounds(layer_size); @@ -10081,7 +10083,7 @@ TEST_F(LayerTreeHostImplTest, SubLayerScaleForNodeInSubtreeOfPageScaleLayer) { page_scale_layer->AddChild(LayerImpl::Create(host_impl_->active_tree(), 100)); LayerImpl* in_subtree_of_page_scale_layer = - host_impl_->active_tree()->LayerById(100); + host_impl_->active_tree()->list()->LayerById(100); in_subtree_of_page_scale_layer->SetForceRenderSurface(true); SetNeedsRebuildPropertyTrees(); RebuildPropertyTrees(); @@ -10093,7 +10095,8 @@ TEST_F(LayerTreeHostImplTest, SubLayerScaleForNodeInSubtreeOfPageScaleLayer) { host_impl_->active_tree()->SetPageScaleOnActiveTree(2.f); DrawFrame(); - in_subtree_of_page_scale_layer = host_impl_->active_tree()->LayerById(100); + in_subtree_of_page_scale_layer = + host_impl_->active_tree()->list()->LayerById(100); node = host_impl_->active_tree()->property_trees()->transform_tree.Node( in_subtree_of_page_scale_layer->transform_tree_index()); EXPECT_EQ(node->data.sublayer_scale, gfx::Vector2dF(2.f, 2.f)); @@ -10138,7 +10141,7 @@ TEST_F(LayerTreeHostImplTest, JitterTest) { pending_tree->BuildPropertyTreesForTesting(); pending_tree->set_needs_update_draw_properties(); pending_tree->UpdateDrawProperties(false); - LayerImpl* last_scrolled_layer = pending_tree->LayerById( + LayerImpl* last_scrolled_layer = pending_tree->list()->LayerById( host_impl_->active_tree()->LastScrolledLayerId()); float jitter = LayerTreeHostCommon::CalculateFrameJitter(last_scrolled_layer); diff --git a/cc/trees/layer_tree_host_unittest.cc b/cc/trees/layer_tree_host_unittest.cc index 33fd49f..6f8727f 100644 --- a/cc/trees/layer_tree_host_unittest.cc +++ b/cc/trees/layer_tree_host_unittest.cc @@ -1287,7 +1287,7 @@ class LayerTreeHostTestDamageWithScale : public LayerTreeHostTest { // cleanup. AddTilingUntilNextDraw ensures that it remains there during // damage calculation. FakePictureLayerImpl* child_layer_impl = static_cast<FakePictureLayerImpl*>( - host_impl->active_tree()->LayerById(child_layer_->id())); + host_impl->active_tree()->list()->LayerById(child_layer_->id())); child_layer_impl->AddTilingUntilNextDraw(1.3f); } @@ -1314,7 +1314,8 @@ class LayerTreeHostTestDamageWithScale : public LayerTreeHostTest { case 1: { FakePictureLayerImpl* child_layer_impl = static_cast<FakePictureLayerImpl*>( - host_impl->active_tree()->LayerById(child_layer_->id())); + host_impl->active_tree()->list()->LayerById( + child_layer_->id())); // We remove tilings pretty aggressively if they are not ideal. Add this // back in so that we can compare // child_layer_impl->GetEnclosingRectInTargetSpace to the damage. diff --git a/cc/trees/layer_tree_host_unittest_scroll.cc b/cc/trees/layer_tree_host_unittest_scroll.cc index c3dc752..d75ff4f 100644 --- a/cc/trees/layer_tree_host_unittest_scroll.cc +++ b/cc/trees/layer_tree_host_unittest_scroll.cc @@ -179,7 +179,7 @@ class LayerTreeHostScrollTestScrollMultipleRedraw void DrawLayersOnThread(LayerTreeHostImpl* impl) override { LayerImpl* scroll_layer = - impl->active_tree()->LayerById(scroll_layer_->id()); + impl->active_tree()->list()->LayerById(scroll_layer_->id()); if (impl->active_tree()->source_frame_number() == 0 && impl->SourceAnimationFrameNumberForTesting() == 1) { // First draw after first commit. @@ -832,7 +832,7 @@ class LayerTreeHostScrollTestSimple : public LayerTreeHostScrollTest { LayerImpl* root = impl->active_tree()->root_layer(); LayerImpl* scroll_layer = impl->OuterViewportScrollLayer(); LayerImpl* pending_root = - impl->active_tree()->FindPendingTreeLayerById(root->id()); + impl->active_tree()->list()->FindPendingLayerById(root->id()); switch (impl->active_tree()->source_frame_number()) { case 0: diff --git a/cc/trees/layer_tree_impl.cc b/cc/trees/layer_tree_impl.cc index 254f253..d595b77 100644 --- a/cc/trees/layer_tree_impl.cc +++ b/cc/trees/layer_tree_impl.cc @@ -79,7 +79,9 @@ LayerTreeImpl::LayerTreeImpl( event_listener_properties_(), top_controls_shrink_blink_size_(false), top_controls_height_(0), - top_controls_shown_ratio_(top_controls_shown_ratio) {} + top_controls_shown_ratio_(top_controls_shown_ratio) { + layer_list_.reset(new LayerListImpl(layer_tree_host_impl_)); +} LayerTreeImpl::~LayerTreeImpl() { BreakSwapPromises(IsActiveTree() ? SwapPromise::SWAP_FAILS @@ -164,7 +166,8 @@ void LayerTreeImpl::DidUpdateScrollState(int layer_id) { clip_layer_id = layer_id; } else { scroll_layer_id = layer_id; - clip_layer_id = LayerById(scroll_layer_id)->scroll_clip_layer_id(); + clip_layer_id = + layer_list_->LayerById(scroll_layer_id)->scroll_clip_layer_id(); } } UpdateScrollbars(scroll_layer_id, clip_layer_id); @@ -173,8 +176,8 @@ void LayerTreeImpl::DidUpdateScrollState(int layer_id) { void LayerTreeImpl::UpdateScrollbars(int scroll_layer_id, int clip_layer_id) { DCHECK(IsActiveTree()); - LayerImpl* clip_layer = LayerById(clip_layer_id); - LayerImpl* scroll_layer = LayerById(scroll_layer_id); + LayerImpl* clip_layer = layer_list_->LayerById(clip_layer_id); + LayerImpl* scroll_layer = layer_list_->LayerById(scroll_layer_id); if (!clip_layer || !scroll_layer) return; @@ -235,11 +238,11 @@ void LayerTreeImpl::SetRootLayer(scoped_ptr<LayerImpl> layer) { } LayerImpl* LayerTreeImpl::InnerViewportScrollLayer() const { - return LayerById(inner_viewport_scroll_layer_id_); + return layer_list_->LayerById(inner_viewport_scroll_layer_id_); } LayerImpl* LayerTreeImpl::OuterViewportScrollLayer() const { - return LayerById(outer_viewport_scroll_layer_id_); + return layer_list_->LayerById(outer_viewport_scroll_layer_id_); } gfx::ScrollOffset LayerTreeImpl::TotalScrollOffset() const { @@ -368,57 +371,13 @@ void LayerTreeImpl::PushPropertiesTo(LayerTreeImpl* target_tree) { if (hud_layer()) target_tree->set_hud_layer(static_cast<HeadsUpDisplayLayerImpl*>( - LayerTreeHostCommon::FindLayerInSubtree( - target_tree->root_layer(), hud_layer()->id()))); + LayerTreeHostCommon::FindLayerInSubtree(target_tree->root_layer(), + hud_layer()->id()))); else target_tree->set_hud_layer(NULL); target_tree->has_ever_been_drawn_ = false; } -void LayerTreeImpl::AddToElementMap(LayerImpl* layer) { - if (!layer->element_id() || !layer->mutable_properties()) - return; - - TRACE_EVENT2(TRACE_DISABLED_BY_DEFAULT("compositor-worker"), - "LayerTreeImpl::AddToElementMap", "element_id", - layer->element_id(), "layer_id", layer->id()); - - ElementLayers& layers = element_layers_map_[layer->element_id()]; - if ((!layers.main || layer->IsActive()) && !layer->scrollable()) { - layers.main = layer; - } else if ((!layers.scroll || layer->IsActive()) && layer->scrollable()) { - TRACE_EVENT2("compositor-worker", "LayerTreeImpl::AddToElementMap scroll", - "element_id", layer->element_id(), "layer_id", layer->id()); - layers.scroll = layer; - } -} - -void LayerTreeImpl::RemoveFromElementMap(LayerImpl* layer) { - if (!layer->element_id()) - return; - - TRACE_EVENT2(TRACE_DISABLED_BY_DEFAULT("compositor-worker"), - "LayerTreeImpl::RemoveFromElementMap", "element_id", - layer->element_id(), "layer_id", layer->id()); - - ElementLayers& layers = element_layers_map_[layer->element_id()]; - if (!layer->scrollable()) - layers.main = nullptr; - if (layer->scrollable()) - layers.scroll = nullptr; - - if (!layers.main && !layers.scroll) - element_layers_map_.erase(layer->element_id()); -} - -LayerTreeImpl::ElementLayers LayerTreeImpl::GetMutableLayers( - uint64_t element_id) { - auto iter = element_layers_map_.find(element_id); - if (iter == element_layers_map_.end()) - return ElementLayers(); - - return iter->second; -} LayerImpl* LayerTreeImpl::InnerViewportContainerLayer() const { return InnerViewportScrollLayer() @@ -436,7 +395,8 @@ LayerImpl* LayerTreeImpl::CurrentlyScrollingLayer() const { DCHECK(IsActiveTree()); const ScrollNode* scroll_node = property_trees_.scroll_tree.CurrentlyScrollingNode(); - return LayerById(scroll_node ? scroll_node->owner_id : Layer::INVALID_ID); + return layer_list_->LayerById(scroll_node ? scroll_node->owner_id + : Layer::INVALID_ID); } int LayerTreeImpl::LastScrolledLayerId() const { @@ -692,6 +652,13 @@ void LayerTreeImpl::ClearViewportLayers() { outer_viewport_scroll_layer_id_ = Layer::INVALID_ID; } +LayerImpl* LayerTreeImpl::OverscrollElasticityLayer() { + return layer_list_->LayerById(overscroll_elasticity_layer_id_); +} +LayerImpl* LayerTreeImpl::PageScaleLayer() { + return layer_list_->LayerById(page_scale_layer_id_); +} + #if DCHECK_IS_ON() int SanityCheckCopyRequestCounts(LayerImpl* layer) { int count = layer->HasCopyRequest() ? 1 : 0; @@ -885,8 +852,8 @@ bool LayerTreeImpl::UpdateDrawProperties(bool update_lcd_text) { "layers_updated_count", layers_updated_count); } - DCHECK(!needs_update_draw_properties_) << - "CalcDrawProperties should not set_needs_update_draw_properties()"; + DCHECK(!needs_update_draw_properties_) + << "CalcDrawProperties should not set_needs_update_draw_properties()"; return true; } @@ -934,33 +901,6 @@ gfx::SizeF LayerTreeImpl::ScrollableSize() const { return content_size; } -LayerImpl* LayerTreeImpl::LayerById(int id) const { - LayerIdMap::const_iterator iter = layer_id_map_.find(id); - return iter != layer_id_map_.end() ? iter->second : NULL; -} - -void LayerTreeImpl::RegisterLayer(LayerImpl* layer) { - DCHECK(!LayerById(layer->id())); - layer_id_map_[layer->id()] = layer; - if (layer_tree_host_impl_->animation_host()) - layer_tree_host_impl_->animation_host()->RegisterLayer( - layer->id(), - IsActiveTree() ? LayerTreeType::ACTIVE : LayerTreeType::PENDING); -} - -void LayerTreeImpl::UnregisterLayer(LayerImpl* layer) { - DCHECK(LayerById(layer->id())); - if (layer_tree_host_impl_->animation_host()) - layer_tree_host_impl_->animation_host()->UnregisterLayer( - layer->id(), - IsActiveTree() ? LayerTreeType::ACTIVE : LayerTreeType::PENDING); - layer_id_map_.erase(layer->id()); -} - -size_t LayerTreeImpl::NumLayers() { - return layer_id_map_.size(); -} - void LayerTreeImpl::DidBecomeActive() { if (next_activation_forces_redraw_) { layer_tree_host_impl_->SetFullRootLayerDamage(); @@ -1064,20 +1004,6 @@ bool LayerTreeImpl::IsSyncTree() const { return layer_tree_host_impl_->sync_tree() == this; } -LayerImpl* LayerTreeImpl::FindActiveTreeLayerById(int id) { - LayerTreeImpl* tree = layer_tree_host_impl_->active_tree(); - if (!tree) - return NULL; - return tree->LayerById(id); -} - -LayerImpl* LayerTreeImpl::FindPendingTreeLayerById(int id) { - LayerTreeImpl* tree = layer_tree_host_impl_->pending_tree(); - if (!tree) - return NULL; - return tree->LayerById(id); -} - bool LayerTreeImpl::PinchGestureActive() const { return layer_tree_host_impl_->pinch_gesture_active(); } @@ -1150,10 +1076,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_); @@ -1352,7 +1274,7 @@ ScrollbarSet LayerTreeImpl::ScrollbarsFor(int scroll_layer_id) const { ScrollbarSet scrollbars; auto scrollbar_range = scrollbar_map_.equal_range(scroll_layer_id); for (auto i = scrollbar_range.first; i != scrollbar_range.second; ++i) - scrollbars.insert(LayerById(i->second)->ToScrollbarLayer()); + scrollbars.insert(layer_list_->LayerById(i->second)->ToScrollbarLayer()); return scrollbars; } @@ -1394,10 +1316,9 @@ void LayerTreeImpl::RemoveLayerWithCopyOutputRequest(LayerImpl* layer) { // they are aborted if not serviced during draw. DCHECK(IsActiveTree()); - std::vector<LayerImpl*>::iterator it = std::find( - layers_with_copy_output_request_.begin(), - layers_with_copy_output_request_.end(), - layer); + std::vector<LayerImpl*>::iterator it = + std::find(layers_with_copy_output_request_.begin(), + layers_with_copy_output_request_.end(), layer); DCHECK(it != layers_with_copy_output_request_.end()); layers_with_copy_output_request_.erase(it); @@ -1430,8 +1351,8 @@ const std::vector<LayerImpl*>& LayerTreeImpl::LayersWithCopyOutputRequest() return layers_with_copy_output_request_; } -template <typename LayerType> -static inline bool LayerClipsSubtree(LayerType* layer) { +template <typename LayerListType> +static inline bool LayerClipsSubtree(LayerListType* layer) { return layer->masks_to_bounds() || layer->mask_layer(); } @@ -1545,7 +1466,7 @@ static bool PointIsClippedByAncestorClipNode( return true; } const LayerImpl* clip_node_owner = - layer->layer_tree_impl()->LayerById(clip_node->owner_id); + layer->layer_tree_impl()->list()->LayerById(clip_node->owner_id); if (clip_node_owner->render_surface() && !PointHitsRect( screen_space_point, @@ -1656,8 +1577,7 @@ static bool ScrollsAnyDrawnRenderSurfaceLayerListMember(LayerImpl* layer) { return false; for (std::set<LayerImpl*>::const_iterator it = layer->scroll_children()->begin(); - it != layer->scroll_children()->end(); - ++it) { + it != layer->scroll_children()->end(); ++it) { if ((*it)->layer_or_descendant_is_drawn()) return true; } @@ -1817,8 +1737,9 @@ void LayerTreeImpl::GetViewportSelection(ViewportSelection* selection) { DCHECK(selection); selection->start = ComputeViewportSelectionBound( - selection_.start, - selection_.start.layer_id ? LayerById(selection_.start.layer_id) : NULL, + selection_.start, selection_.start.layer_id + ? layer_list_->LayerById(selection_.start.layer_id) + : NULL, device_scale_factor(), property_trees_.transform_tree, property_trees_.clip_tree); selection->is_editable = selection_.is_editable; @@ -1828,8 +1749,9 @@ void LayerTreeImpl::GetViewportSelection(ViewportSelection* selection) { selection->end = selection->start; } else { selection->end = ComputeViewportSelectionBound( - selection_.end, - selection_.end.layer_id ? LayerById(selection_.end.layer_id) : NULL, + selection_.end, selection_.end.layer_id + ? layer_list_->LayerById(selection_.end.layer_id) + : NULL, device_scale_factor(), property_trees_.transform_tree, property_trees_.clip_tree); } @@ -1857,67 +1779,67 @@ void LayerTreeImpl::SetPendingPageScaleAnimation( } scoped_ptr<PendingPageScaleAnimation> - LayerTreeImpl::TakePendingPageScaleAnimation() { +LayerTreeImpl::TakePendingPageScaleAnimation() { return std::move(pending_page_scale_animation_); } bool LayerTreeImpl::IsAnimatingFilterProperty(const LayerImpl* layer) const { - LayerTreeType tree_type = - IsActiveTree() ? LayerTreeType::ACTIVE : LayerTreeType::PENDING; + LayerListType list_type = + IsActiveTree() ? LayerListType::ACTIVE : LayerListType::PENDING; return layer_tree_host_impl_->animation_host() ? layer_tree_host_impl_->animation_host() - ->IsAnimatingFilterProperty(layer->id(), tree_type) + ->IsAnimatingFilterProperty(layer->id(), list_type) : false; } bool LayerTreeImpl::IsAnimatingOpacityProperty(const LayerImpl* layer) const { - LayerTreeType tree_type = - IsActiveTree() ? LayerTreeType::ACTIVE : LayerTreeType::PENDING; + LayerListType list_type = + IsActiveTree() ? LayerListType::ACTIVE : LayerListType::PENDING; return layer_tree_host_impl_->animation_host() ? layer_tree_host_impl_->animation_host() - ->IsAnimatingOpacityProperty(layer->id(), tree_type) + ->IsAnimatingOpacityProperty(layer->id(), list_type) : false; } bool LayerTreeImpl::IsAnimatingTransformProperty(const LayerImpl* layer) const { - LayerTreeType tree_type = - IsActiveTree() ? LayerTreeType::ACTIVE : LayerTreeType::PENDING; + LayerListType list_type = + IsActiveTree() ? LayerListType::ACTIVE : LayerListType::PENDING; return layer_tree_host_impl_->animation_host() ? layer_tree_host_impl_->animation_host() - ->IsAnimatingTransformProperty(layer->id(), tree_type) + ->IsAnimatingTransformProperty(layer->id(), list_type) : false; } bool LayerTreeImpl::HasPotentiallyRunningFilterAnimation( const LayerImpl* layer) const { - LayerTreeType tree_type = - IsActiveTree() ? LayerTreeType::ACTIVE : LayerTreeType::PENDING; + LayerListType list_type = + IsActiveTree() ? LayerListType::ACTIVE : LayerListType::PENDING; return layer_tree_host_impl_->animation_host() ? layer_tree_host_impl_->animation_host() ->HasPotentiallyRunningFilterAnimation(layer->id(), - tree_type) + list_type) : false; } bool LayerTreeImpl::HasPotentiallyRunningOpacityAnimation( const LayerImpl* layer) const { - LayerTreeType tree_type = - IsActiveTree() ? LayerTreeType::ACTIVE : LayerTreeType::PENDING; + LayerListType list_type = + IsActiveTree() ? LayerListType::ACTIVE : LayerListType::PENDING; return layer_tree_host_impl_->animation_host() ? layer_tree_host_impl_->animation_host() ->HasPotentiallyRunningOpacityAnimation(layer->id(), - tree_type) + list_type) : false; } bool LayerTreeImpl::HasPotentiallyRunningTransformAnimation( const LayerImpl* layer) const { - LayerTreeType tree_type = - IsActiveTree() ? LayerTreeType::ACTIVE : LayerTreeType::PENDING; + LayerListType list_type = + IsActiveTree() ? LayerListType::ACTIVE : LayerListType::PENDING; return layer_tree_host_impl_->animation_host() ? layer_tree_host_impl_->animation_host() ->HasPotentiallyRunningTransformAnimation(layer->id(), - tree_type) + list_type) : false; } @@ -1961,33 +1883,33 @@ bool LayerTreeImpl::AnimationsPreserveAxisAlignment( } bool LayerTreeImpl::HasOnlyTranslationTransforms(const LayerImpl* layer) const { - LayerTreeType tree_type = - IsActiveTree() ? LayerTreeType::ACTIVE : LayerTreeType::PENDING; + LayerListType list_type = + IsActiveTree() ? LayerListType::ACTIVE : LayerListType::PENDING; return layer_tree_host_impl_->animation_host() ? layer_tree_host_impl_->animation_host() - ->HasOnlyTranslationTransforms(layer->id(), tree_type) + ->HasOnlyTranslationTransforms(layer->id(), list_type) : true; } bool LayerTreeImpl::MaximumTargetScale(const LayerImpl* layer, float* max_scale) const { *max_scale = 0.f; - LayerTreeType tree_type = - IsActiveTree() ? LayerTreeType::ACTIVE : LayerTreeType::PENDING; + LayerListType list_type = + IsActiveTree() ? LayerListType::ACTIVE : LayerListType::PENDING; return layer_tree_host_impl_->animation_host() ? layer_tree_host_impl_->animation_host()->MaximumTargetScale( - layer->id(), tree_type, max_scale) + layer->id(), list_type, max_scale) : true; } bool LayerTreeImpl::AnimationStartScale(const LayerImpl* layer, float* start_scale) const { *start_scale = 0.f; - LayerTreeType tree_type = - IsActiveTree() ? LayerTreeType::ACTIVE : LayerTreeType::PENDING; + LayerListType list_type = + IsActiveTree() ? LayerListType::ACTIVE : LayerListType::PENDING; return layer_tree_host_impl_->animation_host() ? layer_tree_host_impl_->animation_host()->AnimationStartScale( - layer->id(), tree_type, start_scale) + layer->id(), list_type, start_scale) : true; } diff --git a/cc/trees/layer_tree_impl.h b/cc/trees/layer_tree_impl.h index f9f1ba1..4b8a401 100644 --- a/cc/trees/layer_tree_impl.h +++ b/cc/trees/layer_tree_impl.h @@ -8,7 +8,6 @@ #include <map> #include <set> #include <string> -#include <unordered_map> #include <vector> #include "base/macros.h" @@ -17,6 +16,7 @@ #include "cc/input/event_listener_properties.h" #include "cc/input/layer_selection_bound.h" #include "cc/layers/layer_impl.h" +#include "cc/layers/layer_list_impl.h" #include "cc/output/begin_frame_args.h" #include "cc/output/renderer.h" #include "cc/output/swap_promise.h" @@ -39,7 +39,6 @@ class HeadsUpDisplayLayerImpl; class LayerExternalScrollOffsetListener; class LayerScrollOffsetDelegate; class LayerTreeDebugState; -class LayerTreeImpl; class LayerTreeSettings; class MemoryHistory; class OutputSurface; @@ -94,8 +93,6 @@ class CC_EXPORT LayerTreeImpl { bool IsPendingTree() const; bool IsRecycleTree() const; bool IsSyncTree() const; - LayerImpl* FindActiveTreeLayerById(int id); - LayerImpl* FindPendingTreeLayerById(int id); bool PinchGestureActive() const; BeginFrameArgs CurrentBeginFrameArgs() const; base::TimeDelta CurrentBeginFrameInterval() const; @@ -139,18 +136,6 @@ class CC_EXPORT LayerTreeImpl { void PushPropertiesTo(LayerTreeImpl* tree_impl); - // TODO(thakis): Consider marking this CC_EXPORT once we understand - // http://crbug.com/575700 better. - struct ElementLayers { - // Transform and opacity mutations apply to this layer. - LayerImpl* main = nullptr; - // Scroll mutations apply to this layer. - LayerImpl* scroll = nullptr; - }; - - void AddToElementMap(LayerImpl* layer); - void RemoveFromElementMap(LayerImpl* layer); - ElementLayers GetMutableLayers(uint64_t element_id); int source_frame_number() const { return source_frame_number_; } void set_source_frame_number(int frame_number) { source_frame_number_ = frame_number; @@ -188,10 +173,8 @@ class CC_EXPORT LayerTreeImpl { int inner_viewport_scroll_layer_id, int outer_viewport_scroll_layer_id); void ClearViewportLayers(); - LayerImpl* OverscrollElasticityLayer() { - return LayerById(overscroll_elasticity_layer_id_); - } - LayerImpl* PageScaleLayer() { return LayerById(page_scale_layer_id_); } + LayerImpl* OverscrollElasticityLayer(); + LayerImpl* PageScaleLayer(); void ApplySentScrollAndScaleDeltasFromAbortedCommit(); SkColor background_color() const { return background_color_; } @@ -280,16 +263,6 @@ class CC_EXPORT LayerTreeImpl { gfx::Rect RootScrollLayerDeviceViewportBounds() const; - LayerImpl* LayerById(int id) const; - - // These should be called by LayerImpl's ctor/dtor. - void RegisterLayer(LayerImpl* layer); - void UnregisterLayer(LayerImpl* layer); - - size_t NumLayers(); - - AnimationRegistrar* GetAnimationRegistrar() const; - void DidBecomeActive(); // Set on the active tree when the viewport size recently changed @@ -453,12 +426,16 @@ class CC_EXPORT LayerTreeImpl { event_properties; } + // TODO(vollick): every consumer of list() needs to be taught how to operate + // on a LayerListImpl directly. + LayerListImpl* list() { return layer_list_.get(); } + const LayerListImpl* list() const { return layer_list_.get(); } + protected: - explicit LayerTreeImpl( - LayerTreeHostImpl* layer_tree_host_impl, - scoped_refptr<SyncedProperty<ScaleGroup>> page_scale_factor, - scoped_refptr<SyncedTopControls> top_controls_shown_ratio, - scoped_refptr<SyncedElasticOverscroll> elastic_overscroll); + LayerTreeImpl(LayerTreeHostImpl* layer_tree_host_impl, + scoped_refptr<SyncedProperty<ScaleGroup>> page_scale_factor, + scoped_refptr<SyncedTopControls> top_controls_shown_ratio, + scoped_refptr<SyncedElasticOverscroll> elastic_overscroll); float ClampPageScaleFactorToLimits(float page_scale_factor) const; void PushPageScaleFactorAndLimits(const float* page_scale_factor, float min_page_scale_factor, @@ -495,11 +472,6 @@ class CC_EXPORT LayerTreeImpl { scoped_refptr<SyncedElasticOverscroll> elastic_overscroll_; - using LayerIdMap = std::unordered_map<int, LayerImpl*>; - LayerIdMap layer_id_map_; - - std::unordered_map<uint64_t, ElementLayers> element_layers_map_; - // Maps from clip layer ids to scroll layer ids. Note that this only includes // the subset of clip layers that act as scrolling containers. (This is // derived from LayerImpl::scroll_clip_layer_ and exists to avoid O(n) walks.) @@ -554,6 +526,12 @@ class CC_EXPORT LayerTreeImpl { scoped_ptr<PendingPageScaleAnimation> pending_page_scale_animation_; + // We will eventually replace layer tree impl with the a layer list. To + // minimize changes to plumbing, we will keep the layer list internal to the + // LayerTreeImpl and teach clients to make use of the layer list rather than + // the layer tree. + scoped_ptr<LayerListImpl> layer_list_; + private: DISALLOW_COPY_AND_ASSIGN(LayerTreeImpl); }; diff --git a/cc/trees/layer_tree_impl_unittest.cc b/cc/trees/layer_tree_impl_unittest.cc index 9f4b473..bc10de0 100644 --- a/cc/trees/layer_tree_impl_unittest.cc +++ b/cc/trees/layer_tree_impl_unittest.cc @@ -1929,7 +1929,7 @@ TEST_F(LayerTreeImplTest, HitCheckingTouchHandlerOverlappingRegions) { // behind it. EXPECT_TRUE(result_layer); - host_impl().active_tree()->LayerById(1234)->SetContentsOpaque(true); + host_impl().active_tree()->list()->LayerById(1234)->SetContentsOpaque(true); result_layer = host_impl().active_tree()->FindLayerThatIsHitByPointInTouchHandlerRegion( test_point); @@ -2358,18 +2358,18 @@ TEST_F(LayerTreeImplTest, SelectionBoundsWithLargeTransforms) { } TEST_F(LayerTreeImplTest, NumLayersTestOne) { - EXPECT_EQ(0u, host_impl().active_tree()->NumLayers()); + EXPECT_EQ(0u, host_impl().active_tree()->list()->NumLayers()); scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 1); - EXPECT_EQ(1u, host_impl().active_tree()->NumLayers()); + EXPECT_EQ(1u, host_impl().active_tree()->list()->NumLayers()); } TEST_F(LayerTreeImplTest, NumLayersSmallTree) { - EXPECT_EQ(0u, host_impl().active_tree()->NumLayers()); + EXPECT_EQ(0u, host_impl().active_tree()->list()->NumLayers()); scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl().active_tree(), 1); root->AddChild(LayerImpl::Create(host_impl().active_tree(), 2)); root->AddChild(LayerImpl::Create(host_impl().active_tree(), 3)); root->child_at(1)->AddChild(LayerImpl::Create(host_impl().active_tree(), 4)); - EXPECT_EQ(4u, host_impl().active_tree()->NumLayers()); + EXPECT_EQ(4u, host_impl().active_tree()->list()->NumLayers()); } TEST_F(LayerTreeImplTest, DeviceScaleFactorNeedsDrawPropertiesUpdate) { diff --git a/cc/trees/mutator_host_client.h b/cc/trees/mutator_host_client.h index c90af7e..a976102 100644 --- a/cc/trees/mutator_host_client.h +++ b/cc/trees/mutator_host_client.h @@ -15,31 +15,31 @@ namespace cc { class FilterOperations; class Layer; -enum class LayerTreeType { ACTIVE, PENDING }; +enum class LayerListType { ACTIVE, PENDING }; class MutatorHostClient { public: - virtual bool IsLayerInTree(int layer_id, LayerTreeType tree_type) const = 0; + virtual bool IsLayerInTree(int layer_id, LayerListType list_type) const = 0; virtual void SetMutatorsNeedCommit() = 0; virtual void SetMutatorsNeedRebuildPropertyTrees() = 0; virtual void SetLayerFilterMutated(int layer_id, - LayerTreeType tree_type, + LayerListType list_type, const FilterOperations& filters) = 0; virtual void SetLayerOpacityMutated(int layer_id, - LayerTreeType tree_type, + LayerListType list_type, float opacity) = 0; virtual void SetLayerTransformMutated(int layer_id, - LayerTreeType tree_type, + LayerListType list_type, const gfx::Transform& transform) = 0; virtual void SetLayerScrollOffsetMutated( int layer_id, - LayerTreeType tree_type, + LayerListType list_type, const gfx::ScrollOffset& scroll_offset) = 0; virtual void LayerTransformIsPotentiallyAnimatingChanged( int layer_id, - LayerTreeType tree_type, + LayerListType list_type, bool is_animating) = 0; virtual void ScrollOffsetAnimationFinished() = 0; diff --git a/cc/trees/tree_synchronizer_unittest.cc b/cc/trees/tree_synchronizer_unittest.cc index 95f5f9c..6059a32 100644 --- a/cc/trees/tree_synchronizer_unittest.cc +++ b/cc/trees/tree_synchronizer_unittest.cc @@ -788,7 +788,7 @@ TEST_F(TreeSynchronizerTest, SynchronizeCurrentlyScrollingNode) { host_impl->active_tree()); host_impl->active_tree()->SetCurrentlyScrollingLayer( - host_impl->active_tree()->LayerById(scroll_layer->id())); + host_impl->active_tree()->list()->LayerById(scroll_layer->id())); transient_scroll_layer->SetScrollClipLayerId(Layer::INVALID_ID); host_->BuildPropertyTreesForTesting(); diff --git a/third_party/WebKit/Source/platform/graphics/CompositorMutableStateProvider.cpp b/third_party/WebKit/Source/platform/graphics/CompositorMutableStateProvider.cpp index cb2d9b1..e9eedb7 100644 --- a/third_party/WebKit/Source/platform/graphics/CompositorMutableStateProvider.cpp +++ b/third_party/WebKit/Source/platform/graphics/CompositorMutableStateProvider.cpp @@ -5,14 +5,14 @@ #include "platform/graphics/CompositorMutableStateProvider.h" #include "cc/layers/layer_impl.h" -#include "cc/trees/layer_tree_impl.h" +#include "cc/layers/layer_list_impl.h" #include "platform/graphics/CompositorMutableState.h" #include "platform/graphics/CompositorMutation.h" #include "wtf/PassOwnPtr.h" namespace blink { -CompositorMutableStateProvider::CompositorMutableStateProvider(cc::LayerTreeImpl* state, CompositorMutations* mutations) +CompositorMutableStateProvider::CompositorMutableStateProvider(cc::LayerListImpl* state, CompositorMutations* mutations) : m_state(state) , m_mutations(mutations) { @@ -23,7 +23,7 @@ CompositorMutableStateProvider::~CompositorMutableStateProvider() {} PassOwnPtr<CompositorMutableState> CompositorMutableStateProvider::getMutableStateFor(uint64_t element_id) { - cc::LayerTreeImpl::ElementLayers layers = m_state->GetMutableLayers(element_id); + cc::LayerListImpl::ElementLayers layers = m_state->GetMutableLayers(element_id); if (!layers.main && !layers.scroll) return nullptr; diff --git a/third_party/WebKit/Source/platform/graphics/CompositorMutableStateProvider.h b/third_party/WebKit/Source/platform/graphics/CompositorMutableStateProvider.h index 3f1b8fc..f55a959 100644 --- a/third_party/WebKit/Source/platform/graphics/CompositorMutableStateProvider.h +++ b/third_party/WebKit/Source/platform/graphics/CompositorMutableStateProvider.h @@ -11,7 +11,7 @@ #include <cstdint> namespace cc { -class LayerTreeImpl; +class LayerListImpl; } // namespace cc namespace blink { @@ -23,12 +23,12 @@ struct CompositorMutations; // around per-element bits of this state. class PLATFORM_EXPORT CompositorMutableStateProvider { public: - CompositorMutableStateProvider(cc::LayerTreeImpl*, CompositorMutations*); + CompositorMutableStateProvider(cc::LayerListImpl*, CompositorMutations*); ~CompositorMutableStateProvider(); PassOwnPtr<CompositorMutableState> getMutableStateFor(uint64_t elementId); private: - cc::LayerTreeImpl* m_state; + cc::LayerListImpl* m_state; CompositorMutations* m_mutations; }; diff --git a/third_party/WebKit/Source/platform/graphics/CompositorMutableStateTest.cpp b/third_party/WebKit/Source/platform/graphics/CompositorMutableStateTest.cpp index ec33486..424829e 100644 --- a/third_party/WebKit/Source/platform/graphics/CompositorMutableStateTest.cpp +++ b/third_party/WebKit/Source/platform/graphics/CompositorMutableStateTest.cpp @@ -81,7 +81,7 @@ TEST_F(CompositorMutableStateTest, NoMutableState) hostImpl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); CompositorMutations mutations; - CompositorMutableStateProvider provider(hostImpl().active_tree(), &mutations); + CompositorMutableStateProvider provider(hostImpl().active_tree()->list(), &mutations); OwnPtr<CompositorMutableState> state(provider.getMutableStateFor(42)); EXPECT_FALSE(state); } @@ -99,7 +99,7 @@ TEST_F(CompositorMutableStateTest, MutableStateNoMutableProperties) hostImpl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); CompositorMutations mutations; - CompositorMutableStateProvider provider(hostImpl().active_tree(), &mutations); + CompositorMutableStateProvider provider(hostImpl().active_tree()->list(), &mutations); OwnPtr<CompositorMutableState> state(provider.getMutableStateFor(42)); EXPECT_FALSE(state); } @@ -130,7 +130,7 @@ TEST_F(CompositorMutableStateTest, MutableStateMutableProperties) hostImpl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); CompositorMutations mutations; - CompositorMutableStateProvider provider(hostImpl().active_tree(), &mutations); + CompositorMutableStateProvider provider(hostImpl().active_tree()->list(), &mutations); OwnPtr<CompositorMutableState> state(provider.getMutableStateFor(layer->element_id())); EXPECT_TRUE(state.get()); |