From cb3f6b13ff8f814e10d67cc548a1cdde69b386db Mon Sep 17 00:00:00 2001 From: vollick Date: Tue, 1 Mar 2016 15:44:10 -0800 Subject: Revert of Introduce LayerListImpl (patchset #11 id:200001 of https://codereview.chromium.org/1746603002/ ) Reason for revert: I'm going to try another, less code churny approach to the layer list refactor. Original issue's description: > Introduce LayerListImpl > > In this cl, the LayerTreeImpl constructs a LayerListImpl. > The idea being that most plumbing won't need to change at > first to get the list to where it needs to be. The first > consumer of the LayerTreeImpl that I'm attempting to > teach to speak LayerListImpl-ese is the LayerImpl. That > has not been completely finished in this cl so that it > doesn't become too big and difficult to review. > > NB: since the actual storage of the LayerImpls doesn't > change in this cl (they're still in the LayerTreeImpl), > there's no need to guard this work behind a flag. > > BUG=557194 > CQ_INCLUDE_TRYBOTS=tryserver.blink:linux_blink_rel > > Committed: https://crrev.com/299bf1f63b8253c77530b904874f3435f9bde6d3 > Cr-Commit-Position: refs/heads/master@{#378398} TBR=weiliangc@chromium.org,ajuma@chromium.org # Skipping CQ checks because original CL landed less than 1 days ago. NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=557194 Review URL: https://codereview.chromium.org/1751243002 Cr-Commit-Position: refs/heads/master@{#378608} --- cc/BUILD.gn | 2 - cc/animation/animation_host.cc | 48 ++--- cc/animation/animation_host.h | 22 +-- cc/animation/animation_host_unittest.cc | 4 +- cc/animation/animation_player.h | 2 +- cc/animation/animation_player_unittest.cc | 80 ++++---- cc/animation/element_animations.cc | 58 +++--- cc/animation/element_animations.h | 16 +- cc/animation/element_animations_unittest.cc | 26 +-- cc/cc.gyp | 2 - cc/input/scroll_state.cc | 2 +- ...ar_animation_controller_linear_fade_unittest.cc | 12 +- ...llbar_animation_controller_thinning_unittest.cc | 2 +- cc/layers/layer.cc | 10 +- cc/layers/layer_impl.cc | 49 ++--- cc/layers/layer_impl.h | 2 - cc/layers/layer_list_host_impl.h | 10 - cc/layers/layer_list_impl.cc | 118 ------------ cc/layers/layer_list_impl.h | 81 -------- cc/layers/layer_position_constraint_unittest.cc | 7 +- cc/layers/layer_utils.cc | 2 +- cc/layers/picture_layer_impl_perftest.cc | 2 +- cc/layers/picture_layer_impl_unittest.cc | 8 +- cc/layers/scrollbar_layer_impl_base.cc | 3 +- cc/test/animation_timelines_test_common.cc | 52 +++--- cc/test/animation_timelines_test_common.h | 26 +-- cc/tiles/tile_manager_perftest.cc | 4 +- cc/tiles/tile_manager_unittest.cc | 4 +- cc/trees/layer_tree_host.cc | 36 ++-- cc/trees/layer_tree_host.h | 12 +- cc/trees/layer_tree_host_common.cc | 7 +- cc/trees/layer_tree_host_common_unittest.cc | 4 +- cc/trees/layer_tree_host_impl.cc | 82 +++----- cc/trees/layer_tree_host_impl.h | 22 +-- cc/trees/layer_tree_host_impl_unittest.cc | 31 ++-- cc/trees/layer_tree_host_unittest.cc | 5 +- cc/trees/layer_tree_host_unittest_scroll.cc | 4 +- cc/trees/layer_tree_impl.cc | 206 ++++++++++++++------- cc/trees/layer_tree_impl.h | 58 ++++-- cc/trees/layer_tree_impl_unittest.cc | 10 +- cc/trees/mutator_host_client.h | 14 +- cc/trees/tree_synchronizer_unittest.cc | 2 +- 42 files changed, 498 insertions(+), 649 deletions(-) delete mode 100644 cc/layers/layer_list_host_impl.h delete mode 100644 cc/layers/layer_list_impl.cc delete mode 100644 cc/layers/layer_list_impl.h (limited to 'cc') diff --git a/cc/BUILD.gn b/cc/BUILD.gn index ed92c8d..ce1a7c5 100644 --- a/cc/BUILD.gn +++ b/cc/BUILD.gn @@ -133,8 +133,6 @@ 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 a4264b0..7baf43c 100644 --- a/cc/animation/animation_host.cc +++ b/cc/animation/animation_host.cc @@ -205,18 +205,18 @@ void AnimationHost::RemoveAnimationTimeline( } } -void AnimationHost::RegisterLayer(int layer_id, LayerListType list_type) { +void AnimationHost::RegisterLayer(int layer_id, LayerTreeType tree_type) { ElementAnimations* element_animations = GetElementAnimationsForLayerId(layer_id); if (element_animations) - element_animations->LayerRegistered(layer_id, list_type); + element_animations->LayerRegistered(layer_id, tree_type); } -void AnimationHost::UnregisterLayer(int layer_id, LayerListType list_type) { +void AnimationHost::UnregisterLayer(int layer_id, LayerTreeType tree_type) { ElementAnimations* element_animations = GetElementAnimationsForLayerId(layer_id); if (element_animations) - element_animations->LayerUnregistered(layer_id, list_type); + element_animations->LayerUnregistered(layer_id, tree_type); } void AnimationHost::RegisterPlayerForLayer(int layer_id, @@ -386,69 +386,69 @@ bool AnimationHost::ScrollOffsetAnimationWasInterrupted(int layer_id) const { } static LayerAnimationController::ObserverType ObserverTypeFromTreeType( - LayerListType list_type) { - return list_type == LayerListType::ACTIVE + LayerTreeType tree_type) { + return tree_type == LayerTreeType::ACTIVE ? LayerAnimationController::ObserverType::ACTIVE : LayerAnimationController::ObserverType::PENDING; } bool AnimationHost::IsAnimatingFilterProperty(int layer_id, - LayerListType list_type) const { + LayerTreeType tree_type) const { LayerAnimationController* controller = GetControllerForLayerId(layer_id); return controller ? controller->IsCurrentlyAnimatingProperty( - TargetProperty::FILTER, ObserverTypeFromTreeType(list_type)) + TargetProperty::FILTER, ObserverTypeFromTreeType(tree_type)) : false; } bool AnimationHost::IsAnimatingOpacityProperty(int layer_id, - LayerListType list_type) const { + LayerTreeType tree_type) const { LayerAnimationController* controller = GetControllerForLayerId(layer_id); return controller ? controller->IsCurrentlyAnimatingProperty( - TargetProperty::OPACITY, ObserverTypeFromTreeType(list_type)) + TargetProperty::OPACITY, ObserverTypeFromTreeType(tree_type)) : false; } bool AnimationHost::IsAnimatingTransformProperty( int layer_id, - LayerListType list_type) const { + LayerTreeType tree_type) const { LayerAnimationController* controller = GetControllerForLayerId(layer_id); return controller ? controller->IsCurrentlyAnimatingProperty( TargetProperty::TRANSFORM, - ObserverTypeFromTreeType(list_type)) + ObserverTypeFromTreeType(tree_type)) : false; } bool AnimationHost::HasPotentiallyRunningFilterAnimation( int layer_id, - LayerListType list_type) const { + LayerTreeType tree_type) const { LayerAnimationController* controller = GetControllerForLayerId(layer_id); return controller ? controller->IsPotentiallyAnimatingProperty( - TargetProperty::FILTER, ObserverTypeFromTreeType(list_type)) + TargetProperty::FILTER, ObserverTypeFromTreeType(tree_type)) : false; } bool AnimationHost::HasPotentiallyRunningOpacityAnimation( int layer_id, - LayerListType list_type) const { + LayerTreeType tree_type) const { LayerAnimationController* controller = GetControllerForLayerId(layer_id); return controller ? controller->IsPotentiallyAnimatingProperty( - TargetProperty::OPACITY, ObserverTypeFromTreeType(list_type)) + TargetProperty::OPACITY, ObserverTypeFromTreeType(tree_type)) : false; } bool AnimationHost::HasPotentiallyRunningTransformAnimation( int layer_id, - LayerListType list_type) const { + LayerTreeType tree_type) const { LayerAnimationController* controller = GetControllerForLayerId(layer_id); return controller ? controller->IsPotentiallyAnimatingProperty( TargetProperty::TRANSFORM, - ObserverTypeFromTreeType(list_type)) + ObserverTypeFromTreeType(tree_type)) : false; } @@ -536,11 +536,11 @@ bool AnimationHost::TransformAnimationBoundsForBox(int layer_id, bool AnimationHost::HasOnlyTranslationTransforms( int layer_id, - LayerListType list_type) const { + LayerTreeType tree_type) const { LayerAnimationController* controller = GetControllerForLayerId(layer_id); return controller ? controller->HasOnlyTranslationTransforms( - ObserverTypeFromTreeType(list_type)) + ObserverTypeFromTreeType(tree_type)) : true; } @@ -550,24 +550,24 @@ bool AnimationHost::AnimationsPreserveAxisAlignment(int layer_id) const { } bool AnimationHost::MaximumTargetScale(int layer_id, - LayerListType list_type, + LayerTreeType tree_type, float* max_scale) const { *max_scale = 0.f; LayerAnimationController* controller = GetControllerForLayerId(layer_id); return controller ? controller->MaximumTargetScale( - ObserverTypeFromTreeType(list_type), max_scale) + ObserverTypeFromTreeType(tree_type), max_scale) : true; } bool AnimationHost::AnimationStartScale(int layer_id, - LayerListType list_type, + LayerTreeType tree_type, float* start_scale) const { *start_scale = 0.f; LayerAnimationController* controller = GetControllerForLayerId(layer_id); return controller ? controller->AnimationStartScale( - ObserverTypeFromTreeType(list_type), start_scale) + ObserverTypeFromTreeType(tree_type), start_scale) : true; } diff --git a/cc/animation/animation_host.h b/cc/animation/animation_host.h index e8ea9ae..4fa1019 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, LayerListType list_type); - void UnregisterLayer(int layer_id, LayerListType list_type); + void RegisterLayer(int layer_id, LayerTreeType tree_type); + void UnregisterLayer(int layer_id, LayerTreeType tree_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, LayerListType list_type) const; - bool IsAnimatingOpacityProperty(int layer_id, LayerListType list_type) const; + bool IsAnimatingFilterProperty(int layer_id, LayerTreeType tree_type) const; + bool IsAnimatingOpacityProperty(int layer_id, LayerTreeType tree_type) const; bool IsAnimatingTransformProperty(int layer_id, - LayerListType list_type) const; + LayerTreeType tree_type) const; bool HasPotentiallyRunningFilterAnimation(int layer_id, - LayerListType list_type) const; + LayerTreeType tree_type) const; bool HasPotentiallyRunningOpacityAnimation(int layer_id, - LayerListType list_type) const; + LayerTreeType tree_type) const; bool HasPotentiallyRunningTransformAnimation(int layer_id, - LayerListType list_type) const; + LayerTreeType tree_type) const; bool HasAnyAnimationTargetingProperty(int layer_id, TargetProperty::Type property) const; @@ -130,14 +130,14 @@ class CC_EXPORT AnimationHost { gfx::BoxF* bounds) const; bool HasOnlyTranslationTransforms(int layer_id, - LayerListType list_type) const; + LayerTreeType tree_type) const; bool AnimationsPreserveAxisAlignment(int layer_id) const; bool MaximumTargetScale(int layer_id, - LayerListType list_type, + LayerTreeType tree_type, float* max_scale) const; bool AnimationStartScale(int layer_id, - LayerListType list_type, + LayerTreeType tree_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 0cd6ab2..cf828f6 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_, LayerListType::ACTIVE); - client_impl_.RegisterLayer(layer_id_, LayerListType::PENDING); + client_.RegisterLayer(layer_id_, LayerTreeType::ACTIVE); + client_impl_.RegisterLayer(layer_id_, LayerTreeType::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 a81b498..ddd303b 100644 --- a/cc/animation/animation_player.h +++ b/cc/animation/animation_player.h @@ -22,7 +22,7 @@ class AnimationHost; class AnimationTimeline; class ElementAnimations; class LayerAnimationController; -enum class LayerListType; +enum class LayerTreeType; // 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 01e72f8..6e165fd 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_, LayerListType::ACTIVE); - client_impl_.RegisterLayer(layer_id_, LayerListType::PENDING); - client_impl_.RegisterLayer(layer_id_, LayerListType::ACTIVE); + client_.RegisterLayer(layer_id_, LayerTreeType::ACTIVE); + client_impl_.RegisterLayer(layer_id_, LayerTreeType::PENDING); + client_impl_.RegisterLayer(layer_id_, LayerTreeType::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_, LayerListType::ACTIVE, + EXPECT_FALSE(client_.IsPropertyMutated(layer_id_, LayerTreeType::ACTIVE, TargetProperty::OPACITY)); - EXPECT_FALSE(client_.IsPropertyMutated(layer_id_, LayerListType::ACTIVE, + EXPECT_FALSE(client_.IsPropertyMutated(layer_id_, LayerTreeType::ACTIVE, TargetProperty::TRANSFORM)); - EXPECT_FALSE(client_.IsPropertyMutated(layer_id_, LayerListType::ACTIVE, + EXPECT_FALSE(client_.IsPropertyMutated(layer_id_, LayerTreeType::ACTIVE, TargetProperty::FILTER)); - EXPECT_FALSE(client_impl_.IsPropertyMutated(layer_id_, LayerListType::ACTIVE, + EXPECT_FALSE(client_impl_.IsPropertyMutated(layer_id_, LayerTreeType::ACTIVE, TargetProperty::OPACITY)); - EXPECT_FALSE(client_impl_.IsPropertyMutated(layer_id_, LayerListType::ACTIVE, + EXPECT_FALSE(client_impl_.IsPropertyMutated(layer_id_, LayerTreeType::ACTIVE, TargetProperty::TRANSFORM)); - EXPECT_FALSE(client_impl_.IsPropertyMutated(layer_id_, LayerListType::ACTIVE, + EXPECT_FALSE(client_impl_.IsPropertyMutated(layer_id_, LayerTreeType::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_, LayerListType::ACTIVE, + client_.ExpectOpacityPropertyMutated(layer_id_, LayerTreeType::ACTIVE, end_opacity); - client_.ExpectTransformPropertyMutated(layer_id_, LayerListType::ACTIVE, + client_.ExpectTransformPropertyMutated(layer_id_, LayerTreeType::ACTIVE, transform_x, transform_y); - client_.ExpectFilterPropertyMutated(layer_id_, LayerListType::ACTIVE, + client_.ExpectFilterPropertyMutated(layer_id_, LayerTreeType::ACTIVE, end_brightness); - client_impl_.ExpectOpacityPropertyMutated(layer_id_, LayerListType::ACTIVE, + client_impl_.ExpectOpacityPropertyMutated(layer_id_, LayerTreeType::ACTIVE, end_opacity); - client_impl_.ExpectTransformPropertyMutated(layer_id_, LayerListType::ACTIVE, + client_impl_.ExpectTransformPropertyMutated(layer_id_, LayerTreeType::ACTIVE, transform_x, transform_y); - client_impl_.ExpectFilterPropertyMutated(layer_id_, LayerListType::ACTIVE, + client_impl_.ExpectFilterPropertyMutated(layer_id_, LayerTreeType::ACTIVE, end_brightness); - client_impl_.ExpectOpacityPropertyMutated(layer_id_, LayerListType::PENDING, + client_impl_.ExpectOpacityPropertyMutated(layer_id_, LayerTreeType::PENDING, end_opacity); - client_impl_.ExpectTransformPropertyMutated(layer_id_, LayerListType::PENDING, + client_impl_.ExpectTransformPropertyMutated(layer_id_, LayerTreeType::PENDING, transform_x, transform_y); - client_impl_.ExpectFilterPropertyMutated(layer_id_, LayerListType::PENDING, + client_impl_.ExpectFilterPropertyMutated(layer_id_, LayerTreeType::PENDING, end_brightness); } @@ -171,9 +171,9 @@ TEST_F(AnimationPlayerTest, AttachTwoPlayersToOneLayer) { TestAnimationDelegate delegate1; TestAnimationDelegate delegate2; - client_.RegisterLayer(layer_id_, LayerListType::ACTIVE); - client_impl_.RegisterLayer(layer_id_, LayerListType::PENDING); - client_impl_.RegisterLayer(layer_id_, LayerListType::ACTIVE); + client_.RegisterLayer(layer_id_, LayerTreeType::ACTIVE); + client_impl_.RegisterLayer(layer_id_, LayerTreeType::PENDING); + client_impl_.RegisterLayer(layer_id_, LayerTreeType::ACTIVE); scoped_refptr 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_, LayerListType::ACTIVE, + client_.ExpectOpacityPropertyMutated(layer_id_, LayerTreeType::ACTIVE, end_opacity); - client_.ExpectTransformPropertyMutated(layer_id_, LayerListType::ACTIVE, + client_.ExpectTransformPropertyMutated(layer_id_, LayerTreeType::ACTIVE, transform_x, transform_y); - client_impl_.ExpectOpacityPropertyMutated(layer_id_, LayerListType::ACTIVE, + client_impl_.ExpectOpacityPropertyMutated(layer_id_, LayerTreeType::ACTIVE, end_opacity); - client_impl_.ExpectTransformPropertyMutated(layer_id_, LayerListType::ACTIVE, + client_impl_.ExpectTransformPropertyMutated(layer_id_, LayerTreeType::ACTIVE, transform_x, transform_y); - client_impl_.ExpectOpacityPropertyMutated(layer_id_, LayerListType::PENDING, + client_impl_.ExpectOpacityPropertyMutated(layer_id_, LayerTreeType::PENDING, end_opacity); - client_impl_.ExpectTransformPropertyMutated(layer_id_, LayerListType::PENDING, + client_impl_.ExpectTransformPropertyMutated(layer_id_, LayerTreeType::PENDING, transform_x, transform_y); } TEST_F(AnimationPlayerTest, AddRemoveAnimationToNonAttachedPlayer) { - client_.RegisterLayer(layer_id_, LayerListType::ACTIVE); - client_impl_.RegisterLayer(layer_id_, LayerListType::PENDING); - client_impl_.RegisterLayer(layer_id_, LayerListType::ACTIVE); + client_.RegisterLayer(layer_id_, LayerTreeType::ACTIVE); + client_impl_.RegisterLayer(layer_id_, LayerTreeType::PENDING); + client_impl_.RegisterLayer(layer_id_, LayerTreeType::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_, LayerListType::ACTIVE, + EXPECT_FALSE(client_.IsPropertyMutated(layer_id_, LayerTreeType::ACTIVE, TargetProperty::OPACITY)); - EXPECT_FALSE(client_impl_.IsPropertyMutated(layer_id_, LayerListType::ACTIVE, + EXPECT_FALSE(client_impl_.IsPropertyMutated(layer_id_, LayerTreeType::ACTIVE, TargetProperty::OPACITY)); - EXPECT_FALSE(client_.IsPropertyMutated(layer_id_, LayerListType::ACTIVE, + EXPECT_FALSE(client_.IsPropertyMutated(layer_id_, LayerTreeType::ACTIVE, TargetProperty::FILTER)); - EXPECT_FALSE(client_impl_.IsPropertyMutated(layer_id_, LayerListType::ACTIVE, + EXPECT_FALSE(client_impl_.IsPropertyMutated(layer_id_, LayerTreeType::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_, LayerListType::ACTIVE, + client_.ExpectOpacityPropertyMutated(layer_id_, LayerTreeType::ACTIVE, end_opacity); - client_impl_.ExpectOpacityPropertyMutated(layer_id_, LayerListType::ACTIVE, + client_impl_.ExpectOpacityPropertyMutated(layer_id_, LayerTreeType::ACTIVE, end_opacity); - client_impl_.ExpectOpacityPropertyMutated(layer_id_, LayerListType::PENDING, + client_impl_.ExpectOpacityPropertyMutated(layer_id_, LayerTreeType::PENDING, end_opacity); - EXPECT_FALSE(client_.IsPropertyMutated(layer_id_, LayerListType::ACTIVE, + EXPECT_FALSE(client_.IsPropertyMutated(layer_id_, LayerTreeType::ACTIVE, TargetProperty::FILTER)); - EXPECT_FALSE(client_impl_.IsPropertyMutated(layer_id_, LayerListType::ACTIVE, + EXPECT_FALSE(client_impl_.IsPropertyMutated(layer_id_, LayerTreeType::ACTIVE, TargetProperty::FILTER)); } TEST_F(AnimationPlayerTest, AddRemoveAnimationCausesSetNeedsCommit) { - client_.RegisterLayer(layer_id_, LayerListType::ACTIVE); + client_.RegisterLayer(layer_id_, LayerTreeType::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 485f3fd..6a9dc33 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, LayerListType list_type) - : element_animations_(element_animation), list_type_(list_type) { + ValueObserver(ElementAnimations* element_animation, LayerTreeType tree_type) + : element_animations_(element_animation), tree_type_(tree_type) { DCHECK(element_animations_); } // LayerAnimationValueObserver implementation. void OnFilterAnimated(const FilterOperations& filters) override { - element_animations_->SetFilterMutated(list_type_, filters); + element_animations_->SetFilterMutated(tree_type_, filters); } void OnOpacityAnimated(float opacity) override { - element_animations_->SetOpacityMutated(list_type_, opacity); + element_animations_->SetOpacityMutated(tree_type_, opacity); } void OnTransformAnimated(const gfx::Transform& transform) override { - element_animations_->SetTransformMutated(list_type_, transform); + element_animations_->SetTransformMutated(tree_type_, transform); } void OnScrollOffsetAnimated(const gfx::ScrollOffset& scroll_offset) override { - element_animations_->SetScrollOffsetMutated(list_type_, scroll_offset); + element_animations_->SetScrollOffsetMutated(tree_type_, scroll_offset); } void OnAnimationWaitingForDeletion() override { @@ -44,14 +44,14 @@ class ElementAnimations::ValueObserver : public LayerAnimationValueObserver { void OnTransformIsPotentiallyAnimatingChanged(bool is_animating) override { element_animations_->SetTransformIsPotentiallyAnimatingChanged( - list_type_, is_animating); + tree_type_, is_animating); } - bool IsActive() const override { return list_type_ == LayerListType::ACTIVE; } + bool IsActive() const override { return tree_type_ == LayerTreeType::ACTIVE; } private: ElementAnimations* element_animations_; - const LayerListType list_type_; + const LayerTreeType tree_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, LayerListType::ACTIVE)) + layer_id, LayerTreeType::ACTIVE)) CreateActiveValueObserver(); if (animation_host_->mutator_host_client()->IsLayerInTree( - layer_id, LayerListType::PENDING)) + layer_id, LayerTreeType::PENDING)) CreatePendingValueObserver(); } @@ -96,9 +96,9 @@ void ElementAnimations::DestroyLayerAnimationController() { DCHECK(animation_host_); if (active_value_observer_) - SetTransformIsPotentiallyAnimatingChanged(LayerListType::ACTIVE, false); + SetTransformIsPotentiallyAnimatingChanged(LayerTreeType::ACTIVE, false); if (pending_value_observer_) - SetTransformIsPotentiallyAnimatingChanged(LayerListType::PENDING, false); + SetTransformIsPotentiallyAnimatingChanged(LayerTreeType::PENDING, false); DestroyPendingValueObserver(); DestroyActiveValueObserver(); @@ -111,11 +111,11 @@ void ElementAnimations::DestroyLayerAnimationController() { } } -void ElementAnimations::LayerRegistered(int layer_id, LayerListType list_type) { +void ElementAnimations::LayerRegistered(int layer_id, LayerTreeType tree_type) { DCHECK(layer_animation_controller_); DCHECK_EQ(layer_animation_controller_->id(), layer_id); - if (list_type == LayerListType::ACTIVE) { + if (tree_type == LayerTreeType::ACTIVE) { if (!active_value_observer_) CreateActiveValueObserver(); } else { @@ -125,9 +125,9 @@ void ElementAnimations::LayerRegistered(int layer_id, LayerListType list_type) { } void ElementAnimations::LayerUnregistered(int layer_id, - LayerListType list_type) { + LayerTreeType tree_type) { DCHECK_EQ(this->layer_id(), layer_id); - list_type == LayerListType::ACTIVE ? DestroyActiveValueObserver() + tree_type == LayerTreeType::ACTIVE ? DestroyActiveValueObserver() : DestroyPendingValueObserver(); } @@ -158,52 +158,52 @@ void ElementAnimations::PushPropertiesTo( element_animations_impl->layer_animation_controller()); } -void ElementAnimations::SetFilterMutated(LayerListType list_type, +void ElementAnimations::SetFilterMutated(LayerTreeType tree_type, const FilterOperations& filters) { DCHECK(layer_id()); DCHECK(animation_host()); DCHECK(animation_host()->mutator_host_client()); animation_host()->mutator_host_client()->SetLayerFilterMutated( - layer_id(), list_type, filters); + layer_id(), tree_type, filters); } -void ElementAnimations::SetOpacityMutated(LayerListType list_type, +void ElementAnimations::SetOpacityMutated(LayerTreeType tree_type, float opacity) { DCHECK(layer_id()); DCHECK(animation_host()); DCHECK(animation_host()->mutator_host_client()); animation_host()->mutator_host_client()->SetLayerOpacityMutated( - layer_id(), list_type, opacity); + layer_id(), tree_type, opacity); } -void ElementAnimations::SetTransformMutated(LayerListType list_type, +void ElementAnimations::SetTransformMutated(LayerTreeType tree_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(), list_type, transform); + layer_id(), tree_type, transform); } void ElementAnimations::SetScrollOffsetMutated( - LayerListType list_type, + LayerTreeType tree_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(), list_type, scroll_offset); + layer_id(), tree_type, scroll_offset); } void ElementAnimations::SetTransformIsPotentiallyAnimatingChanged( - LayerListType list_type, + LayerTreeType tree_type, bool is_animating) { DCHECK(layer_id()); DCHECK(animation_host()); DCHECK(animation_host()->mutator_host_client()); animation_host() ->mutator_host_client() - ->LayerTransformIsPotentiallyAnimatingChanged(layer_id(), list_type, + ->LayerTransformIsPotentiallyAnimatingChanged(layer_id(), tree_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, LayerListType::ACTIVE)); + make_scoped_ptr(new ValueObserver(this, LayerTreeType::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, LayerListType::PENDING)); + make_scoped_ptr(new ValueObserver(this, LayerTreeType::PENDING)); layer_animation_controller_->AddValueObserver(pending_value_observer_.get()); } diff --git a/cc/animation/element_animations.h b/cc/animation/element_animations.h index ea33813..17dfbd0 100644 --- a/cc/animation/element_animations.h +++ b/cc/animation/element_animations.h @@ -26,7 +26,7 @@ class AnimationHost; class AnimationPlayer; class FilterOperations; class LayerAnimationController; -enum class LayerListType; +enum class LayerTreeType; // An ElementAnimations owns a list of all AnimationPlayers, attached to // the layer. Also, it owns LayerAnimationController instance (1:1 @@ -56,8 +56,8 @@ class CC_EXPORT ElementAnimations : public AnimationDelegate, void CreateLayerAnimationController(int layer_id); void DestroyLayerAnimationController(); - void LayerRegistered(int layer_id, LayerListType list_type); - void LayerUnregistered(int layer_id, LayerListType list_type); + void LayerRegistered(int layer_id, LayerTreeType tree_type); + void LayerUnregistered(int layer_id, LayerTreeType tree_type); bool has_active_value_observer_for_testing() const { return !!active_value_observer_; @@ -79,14 +79,14 @@ class CC_EXPORT ElementAnimations : public AnimationDelegate, private: explicit ElementAnimations(AnimationHost* host); - void SetFilterMutated(LayerListType list_type, + void SetFilterMutated(LayerTreeType tree_type, const FilterOperations& filters); - void SetOpacityMutated(LayerListType list_type, float opacity); - void SetTransformMutated(LayerListType list_type, + void SetOpacityMutated(LayerTreeType tree_type, float opacity); + void SetTransformMutated(LayerTreeType tree_type, const gfx::Transform& transform); - void SetScrollOffsetMutated(LayerListType list_type, + void SetScrollOffsetMutated(LayerTreeType tree_type, const gfx::ScrollOffset& scroll_offset); - void SetTransformIsPotentiallyAnimatingChanged(LayerListType list_type, + void SetTransformIsPotentiallyAnimatingChanged(LayerTreeType tree_type, bool is_animating); void CreateActiveValueObserver(); diff --git a/cc/animation/element_animations_unittest.cc b/cc/animation/element_animations_unittest.cc index 94f6792..b676906 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_, LayerListType::ACTIVE); - client_impl_.RegisterLayer(layer_id_, LayerListType::PENDING); + client_.RegisterLayer(layer_id_, LayerTreeType::ACTIVE); + client_impl_.RegisterLayer(layer_id_, LayerTreeType::PENDING); - EXPECT_TRUE(client_.IsLayerInTree(layer_id_, LayerListType::ACTIVE)); - EXPECT_FALSE(client_.IsLayerInTree(layer_id_, LayerListType::PENDING)); + EXPECT_TRUE(client_.IsLayerInTree(layer_id_, LayerTreeType::ACTIVE)); + EXPECT_FALSE(client_.IsLayerInTree(layer_id_, LayerTreeType::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_, LayerListType::ACTIVE); + client_impl_.RegisterLayer(layer_id_, LayerTreeType::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_, LayerListType::ACTIVE)); - EXPECT_TRUE(client_impl_.IsLayerInTree(layer_id_, LayerListType::PENDING)); + EXPECT_TRUE(client_impl_.IsLayerInTree(layer_id_, LayerTreeType::ACTIVE)); + EXPECT_TRUE(client_impl_.IsLayerInTree(layer_id_, LayerTreeType::PENDING)); // kill layer on main thread. - client_.UnregisterLayer(layer_id_, LayerListType::ACTIVE); + client_.UnregisterLayer(layer_id_, LayerTreeType::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_, LayerListType::PENDING); + client_impl_.UnregisterLayer(layer_id_, LayerTreeType::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_, LayerListType::ACTIVE); + client_impl_.UnregisterLayer(layer_id_, LayerTreeType::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_, LayerListType::ACTIVE); + client_.RegisterLayer(layer_id_, LayerTreeType::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_, LayerListType::PENDING); + client_impl_.RegisterLayer(layer_id_, LayerTreeType::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_, LayerListType::ACTIVE); + client_impl_.RegisterLayer(layer_id_, LayerTreeType::ACTIVE); EXPECT_TRUE(element_animations_impl->has_active_value_observer_for_testing()); EXPECT_TRUE( element_animations_impl->has_pending_value_observer_for_testing()); diff --git a/cc/cc.gyp b/cc/cc.gyp index a8f991e..62afc29 100644 --- a/cc/cc.gyp +++ b/cc/cc.gyp @@ -195,8 +195,6 @@ '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 f0e7751..aa0baf1 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_->list()->LayerById(next->owner_id)->DistributeScroll(this); + layer_tree_impl_->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 20cf0b8..35eacb5 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()->list()->LayerById(1); + LayerImpl* scroll_layer = host_impl_.active_tree()->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()->list()->LayerById(1); + LayerImpl* scroll_layer = host_impl_.active_tree()->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()->list()->LayerById(1); + LayerImpl* scroll_layer = host_impl_.active_tree()->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()->list()->LayerById(1); + LayerImpl* scroll_layer = host_impl_.active_tree()->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()->list()->LayerById(1); + LayerImpl* scroll_layer = host_impl_.active_tree()->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()->list()->LayerById(1); + LayerImpl* scroll_layer = host_impl_.active_tree()->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 12b2d84..da5d625 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()->list()->LayerById(1); + LayerImpl* scroll_layer = host_impl_.active_tree()->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 1441ccd..3842741 100644 --- a/cc/layers/layer.cc +++ b/cc/layers/layer.cc @@ -1289,8 +1289,7 @@ void Layer::PushPropertiesTo(LayerImpl* layer) { LayerImpl* scroll_parent = nullptr; if (scroll_parent_) { - scroll_parent = - layer->layer_tree_impl()->list()->LayerById(scroll_parent_->id()); + scroll_parent = layer->layer_tree_impl()->LayerById(scroll_parent_->id()); DCHECK(scroll_parent); } @@ -1302,7 +1301,7 @@ void Layer::PushPropertiesTo(LayerImpl* layer) { ++it) { DCHECK_EQ((*it)->scroll_parent(), this); LayerImpl* scroll_child = - layer->layer_tree_impl()->list()->LayerById((*it)->id()); + layer->layer_tree_impl()->LayerById((*it)->id()); DCHECK(scroll_child); scroll_children->insert(scroll_child); } @@ -1314,7 +1313,7 @@ void Layer::PushPropertiesTo(LayerImpl* layer) { LayerImpl* clip_parent = nullptr; if (clip_parent_) { clip_parent = - layer->layer_tree_impl()->list()->LayerById(clip_parent_->id()); + layer->layer_tree_impl()->LayerById(clip_parent_->id()); DCHECK(clip_parent); } @@ -1324,8 +1323,7 @@ void Layer::PushPropertiesTo(LayerImpl* layer) { for (std::set::iterator it = clip_children_->begin(); it != clip_children_->end(); ++it) { DCHECK_EQ((*it)->clip_parent(), this); - LayerImpl* clip_child = - layer->layer_tree_impl()->list()->LayerById((*it)->id()); + LayerImpl* clip_child = layer->layer_tree_impl()->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 3c2d6b4..4b114294 100644 --- a/cc/layers/layer_impl.cc +++ b/cc/layers/layer_impl.cc @@ -57,7 +57,6 @@ 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_( @@ -104,10 +103,11 @@ LayerImpl::LayerImpl(LayerTreeImpl* tree_impl, layer_or_descendant_has_touch_handler_(false), sorted_for_recursion_(false) { DCHECK_GT(layer_id_, 0); - layer_list_impl_->RegisterLayer(this); + DCHECK(layer_tree_impl_); + layer_tree_impl_->RegisterLayer(this); if (!layer_tree_impl_->settings().use_compositor_animation_timelines) { - AnimationRegistrar* registrar = layer_list_impl_->GetAnimationRegistrar(); + AnimationRegistrar* registrar = layer_tree_impl_->GetAnimationRegistrar(); layer_animation_controller_ = registrar->GetAnimationControllerForId(layer_id_); layer_animation_controller_->AddValueObserver(this); @@ -117,7 +117,7 @@ LayerImpl::LayerImpl(LayerTreeImpl* tree_impl, } } - layer_list_impl_->AddToElementMap(this); + layer_tree_impl_->AddToElementMap(this); SetNeedsPushProperties(); } @@ -134,9 +134,9 @@ LayerImpl::~LayerImpl() { if (!copy_requests_.empty() && layer_tree_impl_->IsActiveTree()) layer_tree_impl()->RemoveLayerWithCopyOutputRequest(this); layer_tree_impl_->UnregisterScrollLayer(this); - layer_list_impl_->UnregisterLayer(this); + layer_tree_impl_->UnregisterLayer(this); - layer_list_impl_->RemoveFromElementMap(this); + layer_tree_impl_->RemoveFromElementMap(this); TRACE_EVENT_OBJECT_DELETED_WITH_ID( TRACE_DISABLED_BY_DEFAULT("cc.debug"), "cc::LayerImpl", this); @@ -198,7 +198,7 @@ void LayerImpl::SetScrollParent(LayerImpl* parent) { return; if (parent) - DCHECK_EQ(layer_list_impl_->LayerById(parent->id()), parent); + DCHECK_EQ(layer_tree_impl()->LayerById(parent->id()), parent); scroll_parent_ = parent; SetNeedsPushProperties(); @@ -471,13 +471,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_list_impl_->LayerById(scroll_clip_layer_id_); + return layer_tree_impl()->LayerById(scroll_clip_layer_id_); } bool LayerImpl::scrollable() const { @@ -584,7 +584,7 @@ void LayerImpl::PushPropertiesTo(LayerImpl* layer) { LayerImpl* scroll_parent = nullptr; if (scroll_parent_) { - scroll_parent = layer->layer_list_impl_->LayerById(scroll_parent_->id()); + scroll_parent = layer->layer_tree_impl()->LayerById(scroll_parent_->id()); DCHECK(scroll_parent); } @@ -595,7 +595,8 @@ void LayerImpl::PushPropertiesTo(LayerImpl* layer) { it != scroll_children_->end(); ++it) { DCHECK_EQ((*it)->scroll_parent(), this); - LayerImpl* scroll_child = layer->layer_list_impl_->LayerById((*it)->id()); + LayerImpl* scroll_child = + layer->layer_tree_impl()->LayerById((*it)->id()); DCHECK(scroll_child); scroll_children->insert(scroll_child); } @@ -606,7 +607,8 @@ void LayerImpl::PushPropertiesTo(LayerImpl* layer) { LayerImpl* clip_parent = nullptr; if (clip_parent_) { - clip_parent = layer->layer_list_impl_->LayerById(clip_parent_->id()); + clip_parent = layer->layer_tree_impl()->LayerById( + clip_parent_->id()); DCHECK(clip_parent); } @@ -615,7 +617,7 @@ void LayerImpl::PushPropertiesTo(LayerImpl* layer) { std::set* clip_children = new std::set; for (std::set::iterator it = clip_children_->begin(); it != clip_children_->end(); ++it) - clip_children->insert(layer->layer_list_impl_->LayerById((*it)->id())); + clip_children->insert(layer->layer_tree_impl()->LayerById((*it)->id())); layer->SetClipChildren(clip_children); } else { layer->SetClipChildren(nullptr); @@ -654,7 +656,7 @@ bool LayerImpl::IsAffectedByPageScale() const { gfx::Vector2dF LayerImpl::FixedContainerSizeDelta() const { LayerImpl* scroll_clip_layer = - layer_list_impl_->LayerById(scroll_clip_layer_id_); + layer_tree_impl()->LayerById(scroll_clip_layer_id_); if (!scroll_clip_layer) return gfx::Vector2dF(); @@ -1245,9 +1247,9 @@ void LayerImpl::SetElementId(uint64_t element_id) { TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("compositor-worker"), "LayerImpl::SetElementId", "id", element_id); - layer_list_impl_->RemoveFromElementMap(this); + layer_tree_impl_->RemoveFromElementMap(this); element_id_ = element_id; - layer_list_impl_->AddToElementMap(this); + layer_tree_impl_->AddToElementMap(this); SetNeedsPushProperties(); } @@ -1260,7 +1262,7 @@ void LayerImpl::SetMutableProperties(uint32_t properties) { mutable_properties_ = properties; // If this layer is already in the element map, update its properties. - layer_list_impl_->AddToElementMap(this); + layer_tree_impl_->AddToElementMap(this); SetNeedsPushProperties(); } @@ -1518,7 +1520,7 @@ void LayerImpl::PushScrollOffset(const gfx::ScrollOffset* scroll_offset) { DCHECK(scroll_offset || IsActive()); bool changed = false; if (scroll_offset) { - DCHECK(!IsActive() || !layer_list_impl_->FindPendingLayerById(id())); + DCHECK(!IsActive() || !layer_tree_impl_->FindPendingTreeLayerById(id())); changed |= scroll_offset_->PushFromMainThread(*scroll_offset); } if (IsActive()) { @@ -1555,7 +1557,7 @@ void LayerImpl::DidUpdateScrollOffset() { // Inform the pending twin that a property changed. if (layer_tree_impl()->IsActiveTree()) { - LayerImpl* pending_twin = layer_list_impl_->FindPendingLayerById(id()); + LayerImpl* pending_twin = layer_tree_impl()->FindPendingTreeLayerById(id()); if (pending_twin) pending_twin->DidUpdateScrollOffset(); } @@ -1633,8 +1635,11 @@ 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 7f4f922..fdc5261e 100644 --- a/cc/layers/layer_impl.h +++ b/cc/layers/layer_impl.h @@ -27,7 +27,6 @@ #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" @@ -750,7 +749,6 @@ class CC_EXPORT LayerImpl : public LayerAnimationValueObserver, scoped_ptr replica_layer_; int layer_id_; LayerTreeImpl* layer_tree_impl_; - LayerListImpl* layer_list_impl_; // Properties dynamically changeable on active tree. scoped_refptr scroll_offset_; diff --git a/cc/layers/layer_list_host_impl.h b/cc/layers/layer_list_host_impl.h deleted file mode 100644 index 905c3e3..0000000 --- a/cc/layers/layer_list_host_impl.h +++ /dev/null @@ -1,10 +0,0 @@ -// 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 deleted file mode 100644 index 8748f0fe..0000000 --- a/cc/layers/layer_list_impl.cc +++ /dev/null @@ -1,118 +0,0 @@ -// 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 deleted file mode 100644 index befe59e..0000000 --- a/cc/layers/layer_list_impl.h +++ /dev/null @@ -1,81 +0,0 @@ -// 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 -#include - -#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; - ElementLayersMap element_layers_map_; - - using LayerIdMap = std::unordered_map; - LayerIdMap layer_id_map_; - - LayerListHostImpl* layer_list_host_; - scoped_ptr 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 c603197..490ce8e 100644 --- a/cc/layers/layer_position_constraint_unittest.cc +++ b/cc/layers/layer_position_constraint_unittest.cc @@ -1095,8 +1095,7 @@ TEST_F(LayerPositionConstraintTest, CommitAndUpdateImplPointers(); LayerImpl* fixed_child_impl = - root_impl_->layer_tree_impl()->list()->FindActiveLayerById( - fixed_child->id()); + root_impl_->layer_tree_impl()->FindActiveTreeLayerById(fixed_child->id()); // Case 1: fixed-container size delta of 20, 20 scroll_layer_impl_->SetScrollDelta(gfx::Vector2d(10, 10)); @@ -1117,8 +1116,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()->list()->FindActiveLayerById( - fixed_child->id()); + fixed_child_impl = + root_impl_->layer_tree_impl()->FindActiveTreeLayerById(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 6b1873e..0289e2a 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()->list()->LayerById(transform_node->owner_id); + layer_in.layer_tree_impl()->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 c5d947d..c38dd3e 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( - host_impl_.pending_tree()->list()->LayerById(7)); + host_impl_.pending_tree()->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 c4230c2..f132b3f 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( - host_impl_.active_tree()->list()->LayerById(id_)); + host_impl_.active_tree()->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( - host_impl_.pending_tree()->list()->LayerById(id_)); + host_impl_.pending_tree()->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( - host_impl_.pending_tree()->list()->LayerById(id_)); + host_impl_.pending_tree()->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( - host_impl_.active_tree()->list()->LayerById(id_)); + host_impl_.active_tree()->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 66e64a4..e8e0f80 100644 --- a/cc/layers/scrollbar_layer_impl_base.cc +++ b/cc/layers/scrollbar_layer_impl_base.cc @@ -69,8 +69,7 @@ bool ScrollbarLayerImplBase::SetCurrentPos(float current_pos) { } bool ScrollbarLayerImplBase::CanScrollOrientation() const { - LayerImpl* scroll_layer = - layer_tree_impl()->list()->LayerById(scroll_layer_id_); + LayerImpl* scroll_layer = layer_tree_impl()->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 5c43ac0..f941736 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, - LayerListType list_type) const { - return list_type == LayerListType::ACTIVE + LayerTreeType tree_type) const { + return tree_type == LayerTreeType::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, - LayerListType list_type, + LayerTreeType tree_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, list_type); + TestLayer* layer = FindTestLayer(layer_id, tree_type); layer->set_brightness(filter.amount()); } } } void TestHostClient::SetLayerOpacityMutated(int layer_id, - LayerListType list_type, + LayerTreeType tree_type, float opacity) { - TestLayer* layer = FindTestLayer(layer_id, list_type); + TestLayer* layer = FindTestLayer(layer_id, tree_type); layer->set_opacity(opacity); } void TestHostClient::SetLayerTransformMutated(int layer_id, - LayerListType list_type, + LayerTreeType tree_type, const gfx::Transform& transform) { - TestLayer* layer = FindTestLayer(layer_id, list_type); + TestLayer* layer = FindTestLayer(layer_id, tree_type); gfx::Vector2dF vec = transform.To2dTranslation(); layer->set_transform(static_cast(vec.x()), static_cast(vec.y())); } void TestHostClient::SetLayerScrollOffsetMutated( int layer_id, - LayerListType list_type, + LayerTreeType tree_type, const gfx::ScrollOffset& scroll_offset) { - TestLayer* layer = FindTestLayer(layer_id, list_type); + TestLayer* layer = FindTestLayer(layer_id, tree_type); layer->set_scroll_offset(scroll_offset); } @@ -106,22 +106,22 @@ gfx::ScrollOffset TestHostClient::GetScrollOffsetForAnimation( return gfx::ScrollOffset(); } -void TestHostClient::RegisterLayer(int layer_id, LayerListType list_type) { - LayerIdToTestLayer& layers_in_tree = list_type == LayerListType::ACTIVE +void TestHostClient::RegisterLayer(int layer_id, LayerTreeType tree_type) { + LayerIdToTestLayer& layers_in_tree = tree_type == LayerTreeType::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, list_type); + host_->RegisterLayer(layer_id, tree_type); } -void TestHostClient::UnregisterLayer(int layer_id, LayerListType list_type) { +void TestHostClient::UnregisterLayer(int layer_id, LayerTreeType tree_type) { DCHECK(host_); - host_->UnregisterLayer(layer_id, list_type); + host_->UnregisterLayer(layer_id, tree_type); - LayerIdToTestLayer& layers_in_tree = list_type == LayerListType::ACTIVE + LayerIdToTestLayer& layers_in_tree = tree_type == LayerTreeType::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, LayerListType list_type) { } bool TestHostClient::IsPropertyMutated(int layer_id, - LayerListType list_type, + LayerTreeType tree_type, TargetProperty::Type property) const { - TestLayer* layer = FindTestLayer(layer_id, list_type); + TestLayer* layer = FindTestLayer(layer_id, tree_type); return layer->is_property_mutated(property); } void TestHostClient::ExpectFilterPropertyMutated(int layer_id, - LayerListType list_type, + LayerTreeType tree_type, float brightness) const { - TestLayer* layer = FindTestLayer(layer_id, list_type); + TestLayer* layer = FindTestLayer(layer_id, tree_type); EXPECT_TRUE(layer->is_property_mutated(TargetProperty::OPACITY)); EXPECT_EQ(brightness, layer->brightness()); } void TestHostClient::ExpectOpacityPropertyMutated(int layer_id, - LayerListType list_type, + LayerTreeType tree_type, float opacity) const { - TestLayer* layer = FindTestLayer(layer_id, list_type); + TestLayer* layer = FindTestLayer(layer_id, tree_type); EXPECT_TRUE(layer->is_property_mutated(TargetProperty::OPACITY)); EXPECT_EQ(opacity, layer->opacity()); } void TestHostClient::ExpectTransformPropertyMutated(int layer_id, - LayerListType list_type, + LayerTreeType tree_type, int transform_x, int transform_y) const { - TestLayer* layer = FindTestLayer(layer_id, list_type); + TestLayer* layer = FindTestLayer(layer_id, tree_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, - LayerListType list_type) const { - const LayerIdToTestLayer& layers_in_tree = list_type == LayerListType::ACTIVE + LayerTreeType tree_type) const { + const LayerIdToTestLayer& layers_in_tree = tree_type == LayerTreeType::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 e7b74915..bb40979 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, LayerListType list_type) const override; + bool IsLayerInTree(int layer_id, LayerTreeType tree_type) const override; void SetMutatorsNeedCommit() override; void SetMutatorsNeedRebuildPropertyTrees() override; void SetLayerFilterMutated(int layer_id, - LayerListType list_type, + LayerTreeType tree_type, const FilterOperations& filters) override; void SetLayerOpacityMutated(int layer_id, - LayerListType list_type, + LayerTreeType tree_type, float opacity) override; void SetLayerTransformMutated(int layer_id, - LayerListType list_type, + LayerTreeType tree_type, const gfx::Transform& transform) override; void SetLayerScrollOffsetMutated( int layer_id, - LayerListType list_type, + LayerTreeType tree_type, const gfx::ScrollOffset& scroll_offset) override; void LayerTransformIsPotentiallyAnimatingChanged(int layer_id, - LayerListType list_type, + LayerTreeType tree_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, LayerListType list_type); - void UnregisterLayer(int layer_id, LayerListType list_type); + void RegisterLayer(int layer_id, LayerTreeType tree_type); + void UnregisterLayer(int layer_id, LayerTreeType tree_type); AnimationHost* host() { DCHECK(host_); @@ -116,21 +116,21 @@ class TestHostClient : public MutatorHostClient { } bool IsPropertyMutated(int layer_id, - LayerListType list_type, + LayerTreeType tree_type, TargetProperty::Type property) const; void ExpectFilterPropertyMutated(int layer_id, - LayerListType list_type, + LayerTreeType tree_type, float brightness) const; void ExpectOpacityPropertyMutated(int layer_id, - LayerListType list_type, + LayerTreeType tree_type, float opacity) const; void ExpectTransformPropertyMutated(int layer_id, - LayerListType list_type, + LayerTreeType tree_type, int transform_x, int transform_y) const; - TestLayer* FindTestLayer(int layer_id, LayerListType list_type) const; + TestLayer* FindTestLayer(int layer_id, LayerTreeType tree_type) const; private: scoped_ptr host_; diff --git a/cc/tiles/tile_manager_perftest.cc b/cc/tiles/tile_manager_perftest.cc index 648ebf1..53b7ba8 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( - host_impl_.active_tree()->list()->LayerById(id_)); + host_impl_.active_tree()->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( - host_impl_.pending_tree()->list()->LayerById(id_)); + host_impl_.pending_tree()->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 5a3f5eb..3dd1453 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( - host_impl_.active_tree()->list()->LayerById(id_)); + host_impl_.active_tree()->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( - host_impl_.pending_tree()->list()->LayerById(id_)); + host_impl_.pending_tree()->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 102d392..c940d22 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(), LayerListType::ACTIVE); + animation_host_->RegisterLayer(layer->id(), LayerTreeType::ACTIVE); } void LayerTreeHost::UnregisterLayer(Layer* layer) { DCHECK(LayerById(layer->id())); DCHECK(!in_paint_layer_contents_); if (animation_host_) - animation_host_->UnregisterLayer(layer->id(), LayerListType::ACTIVE); + animation_host_->UnregisterLayer(layer->id(), LayerTreeType::ACTIVE); layer_id_map_.erase(layer->id()); } -bool LayerTreeHost::IsLayerInTree(int layer_id, LayerListType list_type) const { - return list_type == LayerListType::ACTIVE && LayerById(layer_id); +bool LayerTreeHost::IsLayerInTree(int layer_id, LayerTreeType tree_type) const { + return tree_type == LayerTreeType::ACTIVE && LayerById(layer_id); } void LayerTreeHost::SetMutatorsNeedCommit() { @@ -1281,7 +1281,7 @@ void LayerTreeHost::SetMutatorsNeedRebuildPropertyTrees() { } void LayerTreeHost::SetLayerFilterMutated(int layer_id, - LayerListType list_type, + LayerTreeType tree_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, - LayerListType list_type, + LayerTreeType tree_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, - LayerListType list_type, + LayerTreeType tree_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, - LayerListType list_type, + LayerTreeType tree_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, - LayerListType list_type, + LayerTreeType tree_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(), - LayerListType::ACTIVE) + LayerTreeType::ACTIVE) : false; } bool LayerTreeHost::IsAnimatingOpacityProperty(const Layer* layer) const { return animation_host_ ? animation_host_->IsAnimatingOpacityProperty( - layer->id(), LayerListType::ACTIVE) + layer->id(), LayerTreeType::ACTIVE) : false; } bool LayerTreeHost::IsAnimatingTransformProperty(const Layer* layer) const { return animation_host_ ? animation_host_->IsAnimatingTransformProperty( - layer->id(), LayerListType::ACTIVE) + layer->id(), LayerTreeType::ACTIVE) : false; } @@ -1361,7 +1361,7 @@ bool LayerTreeHost::HasPotentiallyRunningFilterAnimation( const Layer* layer) const { return animation_host_ ? animation_host_->HasPotentiallyRunningFilterAnimation( - layer->id(), LayerListType::ACTIVE) + layer->id(), LayerTreeType::ACTIVE) : false; } @@ -1369,7 +1369,7 @@ bool LayerTreeHost::HasPotentiallyRunningOpacityAnimation( const Layer* layer) const { return animation_host_ ? animation_host_->HasPotentiallyRunningOpacityAnimation( - layer->id(), LayerListType::ACTIVE) + layer->id(), LayerTreeType::ACTIVE) : false; } @@ -1377,14 +1377,14 @@ bool LayerTreeHost::HasPotentiallyRunningTransformAnimation( const Layer* layer) const { return animation_host_ ? animation_host_->HasPotentiallyRunningTransformAnimation( - layer->id(), LayerListType::ACTIVE) + layer->id(), LayerTreeType::ACTIVE) : false; } bool LayerTreeHost::HasOnlyTranslationTransforms(const Layer* layer) const { return animation_host_ ? animation_host_->HasOnlyTranslationTransforms( - layer->id(), LayerListType::ACTIVE) + layer->id(), LayerTreeType::ACTIVE) : false; } @@ -1392,7 +1392,7 @@ bool LayerTreeHost::MaximumTargetScale(const Layer* layer, float* max_scale) const { return animation_host_ ? animation_host_->MaximumTargetScale( - layer->id(), LayerListType::ACTIVE, max_scale) + layer->id(), LayerTreeType::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(), LayerListType::ACTIVE, start_scale) + layer->id(), LayerTreeType::ACTIVE, start_scale) : false; } diff --git a/cc/trees/layer_tree_host.h b/cc/trees/layer_tree_host.h index 38b8d5d..c985002 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, LayerListType list_type) const override; + bool IsLayerInTree(int layer_id, LayerTreeType tree_type) const override; void SetMutatorsNeedCommit() override; void SetMutatorsNeedRebuildPropertyTrees() override; void SetLayerFilterMutated(int layer_id, - LayerListType list_type, + LayerTreeType tree_type, const FilterOperations& filters) override; void SetLayerOpacityMutated(int layer_id, - LayerListType list_type, + LayerTreeType tree_type, float opacity) override; void SetLayerTransformMutated(int layer_id, - LayerListType list_type, + LayerTreeType tree_type, const gfx::Transform& transform) override; void SetLayerScrollOffsetMutated( int layer_id, - LayerListType list_type, + LayerTreeType tree_type, const gfx::ScrollOffset& scroll_offset) override; void LayerTransformIsPotentiallyAnimatingChanged(int layer_id, - LayerListType list_type, + LayerTreeType tree_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 ba55171..c8baceb 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->list()->FindActiveLayerById(pending_tree_layer->id()); + layer_tree_impl->FindActiveTreeLayerById(pending_tree_layer->id()); if (active_tree_layer) { gfx::Transform active_tree_screen_space_transform = active_tree_layer->draw_properties().screen_space_transform; @@ -1606,11 +1606,10 @@ void LayerTreeHostCommon::CalculateDrawProperties( if (layer_tree_impl->IsPendingTree() && layer_tree_impl->is_first_frame_after_commit()) { LayerImpl* active_tree_root = - layer_tree_impl->list()->FindActiveLayerById( - inputs->root_layer->id()); + layer_tree_impl->FindActiveTreeLayerById(inputs->root_layer->id()); float jitter = 0.f; if (active_tree_root) { - LayerImpl* last_scrolled_layer = layer_tree_impl->list()->LayerById( + LayerImpl* last_scrolled_layer = layer_tree_impl->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 cfcc1ec..69a8ce7 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()->list()->LayerById(2); + LayerImpl* child_ptr = root->layer_tree_impl()->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()->list()->LayerById(2); + child_ptr = root->layer_tree_impl()->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 da79b67..16b7401 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(active_tree_->list()->NumLayers()), 1, 400, 20); + base::saturated_cast(active_tree_->NumLayers()), 1, 400, 20); if (const char* client_name = GetClientNameForMetrics()) { size_t total_picture_memory = 0; @@ -1281,22 +1281,6 @@ scoped_ptr 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 LayerTreeHostImpl::BuildEvictionQueue( TreePriority tree_priority) { TRACE_EVENT0("disabled-by-default-cc.debug", @@ -1346,14 +1330,14 @@ void LayerTreeHostImpl::NotifyTileStateChanged(const Tile* tile) { if (active_tree_) { LayerImpl* layer_impl = - active_tree_->list()->FindActiveLayerById(tile->layer_id()); + active_tree_->FindActiveTreeLayerById(tile->layer_id()); if (layer_impl) layer_impl->NotifyTileStateChanged(tile); } if (pending_tree_) { LayerImpl* layer_impl = - pending_tree_->list()->FindPendingLayerById(tile->layer_id()); + pending_tree_->FindPendingTreeLayerById(tile->layer_id()); if (layer_impl) layer_impl->NotifyTileStateChanged(tile); } @@ -2472,7 +2456,6 @@ 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))) { @@ -2564,7 +2547,7 @@ LayerImpl* LayerTreeHostImpl::FindScrollLayerForDeviceViewportPoint( if (status.thread == InputHandler::SCROLL_ON_IMPL_THREAD && !potentially_scrolling_layer_impl) { potentially_scrolling_layer_impl = - active_tree_->list()->LayerById(scroll_node->owner_id); + active_tree_->LayerById(scroll_node->owner_id); } } } @@ -2747,8 +2730,7 @@ InputHandler::ScrollStatus LayerTreeHostImpl::ScrollAnimated( if (!scroll_node->data.scrollable) continue; - LayerImpl* layer_impl = - active_tree_->list()->LayerById(scroll_node->owner_id); + LayerImpl* layer_impl = active_tree_->LayerById(scroll_node->owner_id); gfx::ScrollOffset current_offset = layer_impl->CurrentScrollOffset(); gfx::ScrollOffset target_offset = ScrollOffsetWithDelta(current_offset, pending_delta); @@ -2993,7 +2975,7 @@ InputHandlerScrollResult LayerTreeHostImpl::ScrollBy( DistributeScrollDelta(scroll_state); - active_tree_->SetCurrentlyScrollingLayer(active_tree_->list()->LayerById( + active_tree_->SetCurrentlyScrollingLayer(active_tree_->LayerById( scroll_state->current_native_scrolling_node()->owner_id)); did_lock_scrolling_layer_ = scroll_state->delta_consumed_for_scroll_sequence(); @@ -3060,8 +3042,7 @@ 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_->list()->LayerById(scroll_node->owner_id); + LayerImpl* layer_impl = active_tree_->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) @@ -3762,8 +3743,7 @@ void LayerTreeHostImpl::ScrollAnimationCreate( return animation_host_->ImplOnlyScrollAnimationCreate( scroll_node->owner_id, target_offset, current_offset); - LayerImpl* layer_impl = - active_tree_->list()->LayerById(scroll_node->owner_id); + LayerImpl* layer_impl = active_tree_->LayerById(scroll_node->owner_id); scoped_ptr curve = ScrollOffsetAnimationCurve::Create( @@ -3789,8 +3769,7 @@ bool LayerTreeHostImpl::ScrollAnimationUpdateTarget( scroll_node->id), CurrentBeginFrameArgs().frame_time); - LayerImpl* layer_impl = - active_tree_->list()->LayerById(scroll_node->owner_id); + LayerImpl* layer_impl = active_tree_->LayerById(scroll_node->owner_id); Animation* animation = layer_impl->layer_animation_controller() @@ -3817,14 +3796,14 @@ bool LayerTreeHostImpl::ScrollAnimationUpdateTarget( } bool LayerTreeHostImpl::IsLayerInTree(int layer_id, - LayerListType list_type) const { - if (list_type == LayerListType::ACTIVE) { - return active_tree() ? active_tree()->list()->LayerById(layer_id) != nullptr + LayerTreeType tree_type) const { + if (tree_type == LayerTreeType::ACTIVE) { + return active_tree() ? active_tree()->LayerById(layer_id) != nullptr : false; } else { - if (pending_tree() && pending_tree()->list()->LayerById(layer_id)) + if (pending_tree() && pending_tree()->LayerById(layer_id)) return true; - if (recycle_tree() && recycle_tree()->list()->LayerById(layer_id)) + if (recycle_tree() && recycle_tree()->LayerById(layer_id)) return true; return false; @@ -3842,7 +3821,7 @@ void LayerTreeHostImpl::SetTreeLayerFilterMutated( if (!tree) return; - LayerAnimationValueObserver* layer = tree->list()->LayerById(layer_id); + LayerAnimationValueObserver* layer = tree->LayerById(layer_id); if (layer) layer->OnFilterAnimated(filters); } @@ -3853,7 +3832,7 @@ void LayerTreeHostImpl::SetTreeLayerOpacityMutated(int layer_id, if (!tree) return; - LayerAnimationValueObserver* layer = tree->list()->LayerById(layer_id); + LayerAnimationValueObserver* layer = tree->LayerById(layer_id); if (layer) layer->OnOpacityAnimated(opacity); } @@ -3865,7 +3844,7 @@ void LayerTreeHostImpl::SetTreeLayerTransformMutated( if (!tree) return; - LayerAnimationValueObserver* layer = tree->list()->LayerById(layer_id); + LayerAnimationValueObserver* layer = tree->LayerById(layer_id); if (layer) layer->OnTransformAnimated(transform); } @@ -3877,7 +3856,7 @@ void LayerTreeHostImpl::SetTreeLayerScrollOffsetMutated( if (!tree) return; - LayerAnimationValueObserver* layer = tree->list()->LayerById(layer_id); + LayerAnimationValueObserver* layer = tree->LayerById(layer_id); if (layer) layer->OnScrollOffsetAnimated(scroll_offset); } @@ -3889,7 +3868,7 @@ void LayerTreeHostImpl::TreeLayerTransformIsPotentiallyAnimatingChanged( if (!tree) return; - LayerAnimationValueObserver* layer = tree->list()->LayerById(layer_id); + LayerAnimationValueObserver* layer = tree->LayerById(layer_id); if (layer) layer->OnTransformIsPotentiallyAnimatingChanged(is_animating); } @@ -3902,9 +3881,9 @@ bool LayerTreeHostImpl::AnimationsPreserveAxisAlignment( } void LayerTreeHostImpl::SetLayerFilterMutated(int layer_id, - LayerListType list_type, + LayerTreeType tree_type, const FilterOperations& filters) { - if (list_type == LayerListType::ACTIVE) { + if (tree_type == LayerTreeType::ACTIVE) { SetTreeLayerFilterMutated(layer_id, active_tree(), filters); } else { SetTreeLayerFilterMutated(layer_id, pending_tree(), filters); @@ -3913,9 +3892,9 @@ void LayerTreeHostImpl::SetLayerFilterMutated(int layer_id, } void LayerTreeHostImpl::SetLayerOpacityMutated(int layer_id, - LayerListType list_type, + LayerTreeType tree_type, float opacity) { - if (list_type == LayerListType::ACTIVE) { + if (tree_type == LayerTreeType::ACTIVE) { SetTreeLayerOpacityMutated(layer_id, active_tree(), opacity); } else { SetTreeLayerOpacityMutated(layer_id, pending_tree(), opacity); @@ -3925,9 +3904,9 @@ void LayerTreeHostImpl::SetLayerOpacityMutated(int layer_id, void LayerTreeHostImpl::SetLayerTransformMutated( int layer_id, - LayerListType list_type, + LayerTreeType tree_type, const gfx::Transform& transform) { - if (list_type == LayerListType::ACTIVE) { + if (tree_type == LayerTreeType::ACTIVE) { SetTreeLayerTransformMutated(layer_id, active_tree(), transform); } else { SetTreeLayerTransformMutated(layer_id, pending_tree(), transform); @@ -3937,9 +3916,9 @@ void LayerTreeHostImpl::SetLayerTransformMutated( void LayerTreeHostImpl::SetLayerScrollOffsetMutated( int layer_id, - LayerListType list_type, + LayerTreeType tree_type, const gfx::ScrollOffset& scroll_offset) { - if (list_type == LayerListType::ACTIVE) { + if (tree_type == LayerTreeType::ACTIVE) { SetTreeLayerScrollOffsetMutated(layer_id, active_tree(), scroll_offset); } else { SetTreeLayerScrollOffsetMutated(layer_id, pending_tree(), scroll_offset); @@ -3949,9 +3928,9 @@ void LayerTreeHostImpl::SetLayerScrollOffsetMutated( void LayerTreeHostImpl::LayerTransformIsPotentiallyAnimatingChanged( int layer_id, - LayerListType list_type, + LayerTreeType tree_type, bool is_animating) { - if (list_type == LayerListType::ACTIVE) { + if (tree_type == LayerTreeType::ACTIVE) { TreeLayerTransformIsPotentiallyAnimatingChanged(layer_id, active_tree(), is_animating); } else { @@ -3970,8 +3949,7 @@ void LayerTreeHostImpl::ScrollOffsetAnimationFinished() { gfx::ScrollOffset LayerTreeHostImpl::GetScrollOffsetForAnimation( int layer_id) const { if (active_tree()) { - LayerAnimationValueProvider* layer = - active_tree()->list()->LayerById(layer_id); + LayerAnimationValueProvider* layer = active_tree()->LayerById(layer_id); if (layer) return layer->ScrollOffsetForAnimation(); } diff --git a/cc/trees/layer_tree_host_impl.h b/cc/trees/layer_tree_host_impl.h index a2520fb..9c2e58e 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, LayerListType list_type) const override; + bool IsLayerInTree(int layer_id, LayerTreeType tree_type) const override; void SetMutatorsNeedCommit() override; void SetMutatorsNeedRebuildPropertyTrees() override; void SetLayerFilterMutated(int layer_id, - LayerListType list_type, + LayerTreeType tree_type, const FilterOperations& filters) override; void SetLayerOpacityMutated(int layer_id, - LayerListType list_type, + LayerTreeType tree_type, float opacity) override; void SetLayerTransformMutated(int layer_id, - LayerListType list_type, + LayerTreeType tree_type, const gfx::Transform& transform) override; void SetLayerScrollOffsetMutated( int layer_id, - LayerListType list_type, + LayerTreeType tree_type, const gfx::ScrollOffset& scroll_offset) override; void LayerTransformIsPotentiallyAnimatingChanged(int layer_id, - LayerListType list_type, + LayerTreeType tree_type, bool is_animating) override; void ScrollOffsetAnimationFinished() override; gfx::ScrollOffset GetScrollOffsetForAnimation(int layer_id) const override; @@ -409,14 +409,6 @@ 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(); } @@ -849,8 +841,6 @@ 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 25b066c..32e461186 100644 --- a/cc/trees/layer_tree_host_impl_unittest.cc +++ b/cc/trees/layer_tree_host_impl_unittest.cc @@ -2743,8 +2743,7 @@ class LayerTreeHostImplTestScrollbarOpacity : public LayerTreeHostImplTest { host_impl_->pending_tree()->BuildPropertyTreesForTesting(); host_impl_->ActivateSyncTree(); - LayerImpl* scrollbar_layer = - host_impl_->active_tree()->list()->LayerById(400); + LayerImpl* scrollbar_layer = host_impl_->active_tree()->LayerById(400); EffectNode* active_tree_node = host_impl_->active_tree()->property_trees()->effect_tree.Node( @@ -7740,12 +7739,12 @@ TEST_F(LayerTreeHostImplTest, ScrollUnknownNotOnAncestorChain) { int scroll_layer_id = 2; LayerImpl* scroll_layer = - host_impl_->active_tree()->list()->LayerById(scroll_layer_id); + host_impl_->active_tree()->LayerById(scroll_layer_id); scroll_layer->SetDrawsContent(true); int page_scale_layer_id = 5; LayerImpl* page_scale_layer = - host_impl_->active_tree()->list()->LayerById(page_scale_layer_id); + host_impl_->active_tree()->LayerById(page_scale_layer_id); int occluder_layer_id = 6; scoped_ptr occluder_layer = @@ -7776,7 +7775,7 @@ TEST_F(LayerTreeHostImplTest, ScrollUnknownScrollAncestorMismatch) { int scroll_layer_id = 2; LayerImpl* scroll_layer = - host_impl_->active_tree()->list()->LayerById(scroll_layer_id); + host_impl_->active_tree()->LayerById(scroll_layer_id); scroll_layer->SetDrawsContent(true); int occluder_layer_id = 6; @@ -7814,11 +7813,11 @@ TEST_F(LayerTreeHostImplTest, NotScrollInvisibleScroller) { gfx::Size content_size(100, 100); SetupScrollAndContentsLayers(content_size); - LayerImpl* root = host_impl_->active_tree()->list()->LayerById(1); + LayerImpl* root = host_impl_->active_tree()->LayerById(1); int scroll_layer_id = 2; LayerImpl* scroll_layer = - host_impl_->active_tree()->list()->LayerById(scroll_layer_id); + host_impl_->active_tree()->LayerById(scroll_layer_id); int child_scroll_layer_id = 7; scoped_ptr child_scroll = @@ -7848,9 +7847,8 @@ TEST_F(LayerTreeHostImplTest, ScrollInvisibleScrollerWithVisibleDescendent) { gfx::Size content_size(100, 100); SetupScrollAndContentsLayers(content_size); - LayerImpl* root = host_impl_->active_tree()->list()->LayerById(1); - LayerImpl* root_scroll_layer = - host_impl_->active_tree()->list()->LayerById(2); + LayerImpl* root = host_impl_->active_tree()->LayerById(1); + LayerImpl* root_scroll_layer = host_impl_->active_tree()->LayerById(2); scoped_ptr invisible_scroll_layer = CreateScrollableLayer(7, content_size, root); @@ -7892,11 +7890,11 @@ TEST_F(LayerTreeHostImplTest, ScrollInvisibleScrollerWithVisibleScrollChild) { gfx::Size content_size(100, 100); SetupScrollAndContentsLayers(content_size); - LayerImpl* root = host_impl_->active_tree()->list()->LayerById(1); + LayerImpl* root = host_impl_->active_tree()->LayerById(1); int scroll_layer_id = 2; LayerImpl* scroll_layer = - host_impl_->active_tree()->list()->LayerById(scroll_layer_id); + host_impl_->active_tree()->LayerById(scroll_layer_id); int scroll_child_id = 6; scoped_ptr scroll_child = @@ -9272,7 +9270,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()->list()->LayerById(100); + LayerImpl* test_layer = host_impl_->active_tree()->LayerById(100); test_layer->SetForceRenderSurface(true); test_layer->SetDrawsContent(true); test_layer->SetBounds(layer_size); @@ -10141,7 +10139,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()->list()->LayerById(100); + host_impl_->active_tree()->LayerById(100); in_subtree_of_page_scale_layer->SetForceRenderSurface(true); SetNeedsRebuildPropertyTrees(); RebuildPropertyTrees(); @@ -10153,8 +10151,7 @@ TEST_F(LayerTreeHostImplTest, SubLayerScaleForNodeInSubtreeOfPageScaleLayer) { host_impl_->active_tree()->SetPageScaleOnActiveTree(2.f); DrawFrame(); - in_subtree_of_page_scale_layer = - host_impl_->active_tree()->list()->LayerById(100); + in_subtree_of_page_scale_layer = host_impl_->active_tree()->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)); @@ -10199,7 +10196,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->list()->LayerById( + LayerImpl* last_scrolled_layer = pending_tree->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 7d8002a..32cc2f0 100644 --- a/cc/trees/layer_tree_host_unittest.cc +++ b/cc/trees/layer_tree_host_unittest.cc @@ -1306,7 +1306,7 @@ class LayerTreeHostTestDamageWithScale : public LayerTreeHostTest { // cleanup. AddTilingUntilNextDraw ensures that it remains there during // damage calculation. FakePictureLayerImpl* child_layer_impl = static_cast( - host_impl->active_tree()->list()->LayerById(child_layer_->id())); + host_impl->active_tree()->LayerById(child_layer_->id())); child_layer_impl->AddTilingUntilNextDraw(1.3f); } @@ -1333,8 +1333,7 @@ class LayerTreeHostTestDamageWithScale : public LayerTreeHostTest { case 1: { FakePictureLayerImpl* child_layer_impl = static_cast( - host_impl->active_tree()->list()->LayerById( - child_layer_->id())); + host_impl->active_tree()->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 d75ff4f..c3dc752 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()->list()->LayerById(scroll_layer_->id()); + impl->active_tree()->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()->list()->FindPendingLayerById(root->id()); + impl->active_tree()->FindPendingTreeLayerById(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 3d608f1..9699555 100644 --- a/cc/trees/layer_tree_impl.cc +++ b/cc/trees/layer_tree_impl.cc @@ -79,9 +79,7 @@ LayerTreeImpl::LayerTreeImpl( event_listener_properties_(), top_controls_shrink_blink_size_(false), top_controls_height_(0), - top_controls_shown_ratio_(top_controls_shown_ratio) { - layer_list_.reset(new LayerListImpl(layer_tree_host_impl_)); -} + top_controls_shown_ratio_(top_controls_shown_ratio) {} LayerTreeImpl::~LayerTreeImpl() { BreakSwapPromises(IsActiveTree() ? SwapPromise::SWAP_FAILS @@ -166,8 +164,7 @@ void LayerTreeImpl::DidUpdateScrollState(int layer_id) { clip_layer_id = layer_id; } else { scroll_layer_id = layer_id; - clip_layer_id = - layer_list_->LayerById(scroll_layer_id)->scroll_clip_layer_id(); + clip_layer_id = LayerById(scroll_layer_id)->scroll_clip_layer_id(); } } UpdateScrollbars(scroll_layer_id, clip_layer_id); @@ -176,8 +173,8 @@ void LayerTreeImpl::DidUpdateScrollState(int layer_id) { void LayerTreeImpl::UpdateScrollbars(int scroll_layer_id, int clip_layer_id) { DCHECK(IsActiveTree()); - LayerImpl* clip_layer = layer_list_->LayerById(clip_layer_id); - LayerImpl* scroll_layer = layer_list_->LayerById(scroll_layer_id); + LayerImpl* clip_layer = LayerById(clip_layer_id); + LayerImpl* scroll_layer = LayerById(scroll_layer_id); if (!clip_layer || !scroll_layer) return; @@ -238,11 +235,11 @@ void LayerTreeImpl::SetRootLayer(scoped_ptr layer) { } LayerImpl* LayerTreeImpl::InnerViewportScrollLayer() const { - return layer_list_->LayerById(inner_viewport_scroll_layer_id_); + return LayerById(inner_viewport_scroll_layer_id_); } LayerImpl* LayerTreeImpl::OuterViewportScrollLayer() const { - return layer_list_->LayerById(outer_viewport_scroll_layer_id_); + return LayerById(outer_viewport_scroll_layer_id_); } gfx::ScrollOffset LayerTreeImpl::TotalScrollOffset() const { @@ -371,13 +368,57 @@ void LayerTreeImpl::PushPropertiesTo(LayerTreeImpl* target_tree) { if (hud_layer()) target_tree->set_hud_layer(static_cast( - 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() @@ -395,8 +436,7 @@ LayerImpl* LayerTreeImpl::CurrentlyScrollingLayer() const { DCHECK(IsActiveTree()); const ScrollNode* scroll_node = property_trees_.scroll_tree.CurrentlyScrollingNode(); - return layer_list_->LayerById(scroll_node ? scroll_node->owner_id - : Layer::INVALID_ID); + return LayerById(scroll_node ? scroll_node->owner_id : Layer::INVALID_ID); } int LayerTreeImpl::LastScrolledLayerId() const { @@ -652,13 +692,6 @@ 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; @@ -852,8 +885,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; } @@ -901,6 +934,33 @@ 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(); @@ -1004,6 +1064,20 @@ 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(); } @@ -1076,6 +1150,10 @@ void LayerTreeImpl::SetNeedsRedraw() { layer_tree_host_impl_->SetNeedsRedraw(); } +AnimationRegistrar* LayerTreeImpl::GetAnimationRegistrar() const { + return layer_tree_host_impl_->animation_registrar(); +} + void LayerTreeImpl::GetAllPrioritizedTilesForTracing( std::vector* prioritized_tiles) const { LayerIterator end = LayerIterator::End(&render_surface_layer_list_); @@ -1274,7 +1352,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(layer_list_->LayerById(i->second)->ToScrollbarLayer()); + scrollbars.insert(LayerById(i->second)->ToScrollbarLayer()); return scrollbars; } @@ -1316,9 +1394,10 @@ void LayerTreeImpl::RemoveLayerWithCopyOutputRequest(LayerImpl* layer) { // they are aborted if not serviced during draw. DCHECK(IsActiveTree()); - std::vector::iterator it = - std::find(layers_with_copy_output_request_.begin(), - layers_with_copy_output_request_.end(), layer); + std::vector::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); @@ -1351,8 +1430,8 @@ const std::vector& LayerTreeImpl::LayersWithCopyOutputRequest() return layers_with_copy_output_request_; } -template -static inline bool LayerClipsSubtree(LayerListType* layer) { +template +static inline bool LayerClipsSubtree(LayerType* layer) { return layer->masks_to_bounds() || layer->mask_layer(); } @@ -1466,7 +1545,7 @@ static bool PointIsClippedByAncestorClipNode( return true; } const LayerImpl* clip_node_owner = - layer->layer_tree_impl()->list()->LayerById(clip_node->owner_id); + layer->layer_tree_impl()->LayerById(clip_node->owner_id); if (clip_node_owner->render_surface() && !PointHitsRect( screen_space_point, @@ -1577,7 +1656,8 @@ static bool ScrollsAnyDrawnRenderSurfaceLayerListMember(LayerImpl* layer) { return false; for (std::set::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; } @@ -1737,9 +1817,8 @@ void LayerTreeImpl::GetViewportSelection(ViewportSelection* selection) { DCHECK(selection); selection->start = ComputeViewportSelectionBound( - selection_.start, selection_.start.layer_id - ? layer_list_->LayerById(selection_.start.layer_id) - : NULL, + selection_.start, + selection_.start.layer_id ? LayerById(selection_.start.layer_id) : NULL, device_scale_factor(), property_trees_.transform_tree, property_trees_.clip_tree); selection->is_editable = selection_.is_editable; @@ -1749,9 +1828,8 @@ void LayerTreeImpl::GetViewportSelection(ViewportSelection* selection) { selection->end = selection->start; } else { selection->end = ComputeViewportSelectionBound( - selection_.end, selection_.end.layer_id - ? layer_list_->LayerById(selection_.end.layer_id) - : NULL, + selection_.end, + selection_.end.layer_id ? LayerById(selection_.end.layer_id) : NULL, device_scale_factor(), property_trees_.transform_tree, property_trees_.clip_tree); } @@ -1779,67 +1857,67 @@ void LayerTreeImpl::SetPendingPageScaleAnimation( } scoped_ptr -LayerTreeImpl::TakePendingPageScaleAnimation() { + LayerTreeImpl::TakePendingPageScaleAnimation() { return std::move(pending_page_scale_animation_); } bool LayerTreeImpl::IsAnimatingFilterProperty(const LayerImpl* layer) const { - LayerListType list_type = - IsActiveTree() ? LayerListType::ACTIVE : LayerListType::PENDING; + LayerTreeType tree_type = + IsActiveTree() ? LayerTreeType::ACTIVE : LayerTreeType::PENDING; return layer_tree_host_impl_->animation_host() ? layer_tree_host_impl_->animation_host() - ->IsAnimatingFilterProperty(layer->id(), list_type) + ->IsAnimatingFilterProperty(layer->id(), tree_type) : false; } bool LayerTreeImpl::IsAnimatingOpacityProperty(const LayerImpl* layer) const { - LayerListType list_type = - IsActiveTree() ? LayerListType::ACTIVE : LayerListType::PENDING; + LayerTreeType tree_type = + IsActiveTree() ? LayerTreeType::ACTIVE : LayerTreeType::PENDING; return layer_tree_host_impl_->animation_host() ? layer_tree_host_impl_->animation_host() - ->IsAnimatingOpacityProperty(layer->id(), list_type) + ->IsAnimatingOpacityProperty(layer->id(), tree_type) : false; } bool LayerTreeImpl::IsAnimatingTransformProperty(const LayerImpl* layer) const { - LayerListType list_type = - IsActiveTree() ? LayerListType::ACTIVE : LayerListType::PENDING; + LayerTreeType tree_type = + IsActiveTree() ? LayerTreeType::ACTIVE : LayerTreeType::PENDING; return layer_tree_host_impl_->animation_host() ? layer_tree_host_impl_->animation_host() - ->IsAnimatingTransformProperty(layer->id(), list_type) + ->IsAnimatingTransformProperty(layer->id(), tree_type) : false; } bool LayerTreeImpl::HasPotentiallyRunningFilterAnimation( const LayerImpl* layer) const { - LayerListType list_type = - IsActiveTree() ? LayerListType::ACTIVE : LayerListType::PENDING; + LayerTreeType tree_type = + IsActiveTree() ? LayerTreeType::ACTIVE : LayerTreeType::PENDING; return layer_tree_host_impl_->animation_host() ? layer_tree_host_impl_->animation_host() ->HasPotentiallyRunningFilterAnimation(layer->id(), - list_type) + tree_type) : false; } bool LayerTreeImpl::HasPotentiallyRunningOpacityAnimation( const LayerImpl* layer) const { - LayerListType list_type = - IsActiveTree() ? LayerListType::ACTIVE : LayerListType::PENDING; + LayerTreeType tree_type = + IsActiveTree() ? LayerTreeType::ACTIVE : LayerTreeType::PENDING; return layer_tree_host_impl_->animation_host() ? layer_tree_host_impl_->animation_host() ->HasPotentiallyRunningOpacityAnimation(layer->id(), - list_type) + tree_type) : false; } bool LayerTreeImpl::HasPotentiallyRunningTransformAnimation( const LayerImpl* layer) const { - LayerListType list_type = - IsActiveTree() ? LayerListType::ACTIVE : LayerListType::PENDING; + LayerTreeType tree_type = + IsActiveTree() ? LayerTreeType::ACTIVE : LayerTreeType::PENDING; return layer_tree_host_impl_->animation_host() ? layer_tree_host_impl_->animation_host() ->HasPotentiallyRunningTransformAnimation(layer->id(), - list_type) + tree_type) : false; } @@ -1891,33 +1969,33 @@ bool LayerTreeImpl::AnimationsPreserveAxisAlignment( } bool LayerTreeImpl::HasOnlyTranslationTransforms(const LayerImpl* layer) const { - LayerListType list_type = - IsActiveTree() ? LayerListType::ACTIVE : LayerListType::PENDING; + LayerTreeType tree_type = + IsActiveTree() ? LayerTreeType::ACTIVE : LayerTreeType::PENDING; return layer_tree_host_impl_->animation_host() ? layer_tree_host_impl_->animation_host() - ->HasOnlyTranslationTransforms(layer->id(), list_type) + ->HasOnlyTranslationTransforms(layer->id(), tree_type) : true; } bool LayerTreeImpl::MaximumTargetScale(const LayerImpl* layer, float* max_scale) const { *max_scale = 0.f; - LayerListType list_type = - IsActiveTree() ? LayerListType::ACTIVE : LayerListType::PENDING; + LayerTreeType tree_type = + IsActiveTree() ? LayerTreeType::ACTIVE : LayerTreeType::PENDING; return layer_tree_host_impl_->animation_host() ? layer_tree_host_impl_->animation_host()->MaximumTargetScale( - layer->id(), list_type, max_scale) + layer->id(), tree_type, max_scale) : true; } bool LayerTreeImpl::AnimationStartScale(const LayerImpl* layer, float* start_scale) const { *start_scale = 0.f; - LayerListType list_type = - IsActiveTree() ? LayerListType::ACTIVE : LayerListType::PENDING; + LayerTreeType tree_type = + IsActiveTree() ? LayerTreeType::ACTIVE : LayerTreeType::PENDING; return layer_tree_host_impl_->animation_host() ? layer_tree_host_impl_->animation_host()->AnimationStartScale( - layer->id(), list_type, start_scale) + layer->id(), tree_type, start_scale) : true; } diff --git a/cc/trees/layer_tree_impl.h b/cc/trees/layer_tree_impl.h index 1332f54..87c1429 100644 --- a/cc/trees/layer_tree_impl.h +++ b/cc/trees/layer_tree_impl.h @@ -8,6 +8,7 @@ #include #include #include +#include #include #include "base/macros.h" @@ -16,7 +17,6 @@ #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,6 +39,7 @@ class HeadsUpDisplayLayerImpl; class LayerExternalScrollOffsetListener; class LayerScrollOffsetDelegate; class LayerTreeDebugState; +class LayerTreeImpl; class LayerTreeSettings; class MemoryHistory; class OutputSurface; @@ -93,6 +94,8 @@ 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,6 +142,18 @@ 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; @@ -176,8 +191,10 @@ class CC_EXPORT LayerTreeImpl { int inner_viewport_scroll_layer_id, int outer_viewport_scroll_layer_id); void ClearViewportLayers(); - LayerImpl* OverscrollElasticityLayer(); - LayerImpl* PageScaleLayer(); + LayerImpl* OverscrollElasticityLayer() { + return LayerById(overscroll_elasticity_layer_id_); + } + LayerImpl* PageScaleLayer() { return LayerById(page_scale_layer_id_); } void ApplySentScrollAndScaleDeltasFromAbortedCommit(); SkColor background_color() const { return background_color_; } @@ -266,6 +283,16 @@ 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 @@ -430,16 +457,12 @@ 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: - LayerTreeImpl(LayerTreeHostImpl* layer_tree_host_impl, - scoped_refptr> page_scale_factor, - scoped_refptr top_controls_shown_ratio, - scoped_refptr elastic_overscroll); + explicit LayerTreeImpl( + LayerTreeHostImpl* layer_tree_host_impl, + scoped_refptr> page_scale_factor, + scoped_refptr top_controls_shown_ratio, + scoped_refptr elastic_overscroll); float ClampPageScaleFactorToLimits(float page_scale_factor) const; void PushPageScaleFactorAndLimits(const float* page_scale_factor, float min_page_scale_factor, @@ -476,6 +499,11 @@ class CC_EXPORT LayerTreeImpl { scoped_refptr elastic_overscroll_; + using LayerIdMap = std::unordered_map; + LayerIdMap layer_id_map_; + + std::unordered_map 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.) @@ -530,12 +558,6 @@ class CC_EXPORT LayerTreeImpl { scoped_ptr 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 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 bc10de0..9f4b473 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()->list()->LayerById(1234)->SetContentsOpaque(true); + host_impl().active_tree()->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()->list()->NumLayers()); + EXPECT_EQ(0u, host_impl().active_tree()->NumLayers()); scoped_ptr root = LayerImpl::Create(host_impl().active_tree(), 1); - EXPECT_EQ(1u, host_impl().active_tree()->list()->NumLayers()); + EXPECT_EQ(1u, host_impl().active_tree()->NumLayers()); } TEST_F(LayerTreeImplTest, NumLayersSmallTree) { - EXPECT_EQ(0u, host_impl().active_tree()->list()->NumLayers()); + EXPECT_EQ(0u, host_impl().active_tree()->NumLayers()); scoped_ptr 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()->list()->NumLayers()); + EXPECT_EQ(4u, host_impl().active_tree()->NumLayers()); } TEST_F(LayerTreeImplTest, DeviceScaleFactorNeedsDrawPropertiesUpdate) { diff --git a/cc/trees/mutator_host_client.h b/cc/trees/mutator_host_client.h index a976102..c90af7e 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 LayerListType { ACTIVE, PENDING }; +enum class LayerTreeType { ACTIVE, PENDING }; class MutatorHostClient { public: - virtual bool IsLayerInTree(int layer_id, LayerListType list_type) const = 0; + virtual bool IsLayerInTree(int layer_id, LayerTreeType tree_type) const = 0; virtual void SetMutatorsNeedCommit() = 0; virtual void SetMutatorsNeedRebuildPropertyTrees() = 0; virtual void SetLayerFilterMutated(int layer_id, - LayerListType list_type, + LayerTreeType tree_type, const FilterOperations& filters) = 0; virtual void SetLayerOpacityMutated(int layer_id, - LayerListType list_type, + LayerTreeType tree_type, float opacity) = 0; virtual void SetLayerTransformMutated(int layer_id, - LayerListType list_type, + LayerTreeType tree_type, const gfx::Transform& transform) = 0; virtual void SetLayerScrollOffsetMutated( int layer_id, - LayerListType list_type, + LayerTreeType tree_type, const gfx::ScrollOffset& scroll_offset) = 0; virtual void LayerTransformIsPotentiallyAnimatingChanged( int layer_id, - LayerListType list_type, + LayerTreeType tree_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 6059a32..95f5f9c 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()->list()->LayerById(scroll_layer->id())); + host_impl->active_tree()->LayerById(scroll_layer->id())); transient_scroll_layer->SetScrollClipLayerId(Layer::INVALID_ID); host_->BuildPropertyTreesForTesting(); -- cgit v1.1