Chromium Code Reviews| Index: cc/trees/layer_tree_impl.cc |
| diff --git a/cc/trees/layer_tree_impl.cc b/cc/trees/layer_tree_impl.cc |
| index c39359ae73e2cd33bd8fcf55b94150afc51c9069..82899e824bd8f2b4a31253febdf333a4a4a002c3 100644 |
| --- a/cc/trees/layer_tree_impl.cc |
| +++ b/cc/trees/layer_tree_impl.cc |
| @@ -483,22 +483,28 @@ LayerImplList::reverse_iterator LayerTreeImpl::rend() { |
| return layer_list_.rend(); |
| } |
| +LayerImpl* LayerTreeImpl::LayerByElementId(ElementId element_id) const { |
| + auto iter = element_layers_map_.find(element_id); |
| + if (iter == element_layers_map_.end()) |
| + return nullptr; |
| + |
| + return iter->second; |
| +} |
| + |
| void LayerTreeImpl::AddToElementMap(LayerImpl* layer) { |
| - if (!layer->element_id() || !layer->mutable_properties()) |
| + if (!layer->element_id()) |
| 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; |
| - } |
| + "LayerTreeImpl::AddToElementMap", "element", |
| + layer->element_id().AsValue().release(), "layer_id", |
| + layer->id()); |
| + |
| + element_layers_map_[layer->element_id()] = layer; |
| + |
| + layer_tree_host_impl_->animation_host()->RegisterElement( |
| + layer->element_id(), |
| + IsActiveTree() ? ElementListType::ACTIVE : ElementListType::PENDING); |
| } |
| void LayerTreeImpl::RemoveFromElementMap(LayerImpl* layer) { |
| @@ -506,17 +512,15 @@ void LayerTreeImpl::RemoveFromElementMap(LayerImpl* layer) { |
| return; |
| TRACE_EVENT2(TRACE_DISABLED_BY_DEFAULT("compositor-worker"), |
| - "LayerTreeImpl::RemoveFromElementMap", "element_id", |
| - layer->element_id(), "layer_id", layer->id()); |
| + "LayerTreeImpl::RemoveFromElementMap", "element", |
| + layer->element_id().AsValue().release(), "layer_id", |
| + layer->id()); |
| - ElementLayers& layers = element_layers_map_[layer->element_id()]; |
| - if (!layer->scrollable()) |
| - layers.main = nullptr; |
| - if (layer->scrollable()) |
| - layers.scroll = nullptr; |
| + layer_tree_host_impl_->animation_host()->UnregisterElement( |
| + layer->element_id(), |
| + IsActiveTree() ? ElementListType::ACTIVE : ElementListType::PENDING); |
| - if (!layers.main && !layers.scroll) |
| - element_layers_map_.erase(layer->element_id()); |
| + element_layers_map_.erase(layer->element_id()); |
| } |
| void LayerTreeImpl::AddToOpacityAnimationsMap(int id, float opacity) { |
| @@ -528,15 +532,6 @@ void LayerTreeImpl::AddToTransformAnimationsMap(int id, |
| transform_animations_map_[id] = transform; |
| } |
| -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() |
| ? InnerViewportScrollLayer()->scroll_clip_layer() |
| @@ -844,6 +839,18 @@ void LayerTreeImpl::ClearViewportLayers() { |
| outer_viewport_scroll_layer_id_ = Layer::INVALID_ID; |
| } |
| +// For unit tests, we use the layer's id as its element id. |
| +static void SetElementIdForTesting(LayerImpl* layer) { |
| + layer->SetElementId(LayerIdToElementIdForTesting(layer->id())); |
| +} |
| + |
| +void LayerTreeImpl::SetElementIdsForTesting() { |
| + LayerListIterator<LayerImpl> it(root_layer_); |
| + for (; it != LayerListIterator<LayerImpl>(nullptr); ++it) { |
|
Ian Vollick
2016/06/29 15:22:11
This is another noteworthy change. Now that "call
|
| + SetElementIdForTesting(*it); |
| + } |
| +} |
| + |
| bool LayerTreeImpl::UpdateDrawProperties(bool update_lcd_text) { |
| if (!needs_update_draw_properties_) |
| return true; |
| @@ -1077,16 +1084,10 @@ bool LayerTreeImpl::LayerNeedsPushPropertiesForTesting(LayerImpl* layer) { |
| void LayerTreeImpl::RegisterLayer(LayerImpl* layer) { |
| DCHECK(!LayerById(layer->id())); |
| layer_id_map_[layer->id()] = layer; |
| - layer_tree_host_impl_->animation_host()->RegisterElement( |
| - layer->id(), |
| - IsActiveTree() ? ElementListType::ACTIVE : ElementListType::PENDING); |
| } |
| void LayerTreeImpl::UnregisterLayer(LayerImpl* layer) { |
| DCHECK(LayerById(layer->id())); |
| - layer_tree_host_impl_->animation_host()->UnregisterElement( |
| - layer->id(), |
| - IsActiveTree() ? ElementListType::ACTIVE : ElementListType::PENDING); |
| layer_id_map_.erase(layer->id()); |
| } |
| @@ -1968,21 +1969,21 @@ bool LayerTreeImpl::IsAnimatingFilterProperty(const LayerImpl* layer) const { |
| ElementListType list_type = |
| IsActiveTree() ? ElementListType::ACTIVE : ElementListType::PENDING; |
| return layer_tree_host_impl_->animation_host()->IsAnimatingFilterProperty( |
| - layer->id(), list_type); |
| + layer->element_id(), list_type); |
| } |
| bool LayerTreeImpl::IsAnimatingOpacityProperty(const LayerImpl* layer) const { |
| ElementListType list_type = |
| IsActiveTree() ? ElementListType::ACTIVE : ElementListType::PENDING; |
| return layer_tree_host_impl_->animation_host()->IsAnimatingOpacityProperty( |
| - layer->id(), list_type); |
| + layer->element_id(), list_type); |
| } |
| bool LayerTreeImpl::IsAnimatingTransformProperty(const LayerImpl* layer) const { |
| ElementListType list_type = |
| IsActiveTree() ? ElementListType::ACTIVE : ElementListType::PENDING; |
| return layer_tree_host_impl_->animation_host()->IsAnimatingTransformProperty( |
| - layer->id(), list_type); |
| + layer->element_id(), list_type); |
| } |
| bool LayerTreeImpl::HasPotentiallyRunningFilterAnimation( |
| @@ -1990,7 +1991,7 @@ bool LayerTreeImpl::HasPotentiallyRunningFilterAnimation( |
| ElementListType list_type = |
| IsActiveTree() ? ElementListType::ACTIVE : ElementListType::PENDING; |
| return layer_tree_host_impl_->animation_host() |
| - ->HasPotentiallyRunningFilterAnimation(layer->id(), list_type); |
| + ->HasPotentiallyRunningFilterAnimation(layer->element_id(), list_type); |
| } |
| bool LayerTreeImpl::HasPotentiallyRunningOpacityAnimation( |
| @@ -1998,7 +1999,7 @@ bool LayerTreeImpl::HasPotentiallyRunningOpacityAnimation( |
| ElementListType list_type = |
| IsActiveTree() ? ElementListType::ACTIVE : ElementListType::PENDING; |
| return layer_tree_host_impl_->animation_host() |
| - ->HasPotentiallyRunningOpacityAnimation(layer->id(), list_type); |
| + ->HasPotentiallyRunningOpacityAnimation(layer->element_id(), list_type); |
| } |
| bool LayerTreeImpl::HasPotentiallyRunningTransformAnimation( |
| @@ -2006,27 +2007,27 @@ bool LayerTreeImpl::HasPotentiallyRunningTransformAnimation( |
| ElementListType list_type = |
| IsActiveTree() ? ElementListType::ACTIVE : ElementListType::PENDING; |
| return layer_tree_host_impl_->animation_host() |
| - ->HasPotentiallyRunningTransformAnimation(layer->id(), list_type); |
| + ->HasPotentiallyRunningTransformAnimation(layer->element_id(), list_type); |
| } |
| bool LayerTreeImpl::HasAnyAnimationTargetingProperty( |
| const LayerImpl* layer, |
| TargetProperty::Type property) const { |
| return layer_tree_host_impl_->animation_host() |
| - ->HasAnyAnimationTargetingProperty(layer->id(), property); |
| + ->HasAnyAnimationTargetingProperty(layer->element_id(), property); |
| } |
| bool LayerTreeImpl::AnimationsPreserveAxisAlignment( |
| const LayerImpl* layer) const { |
| return layer_tree_host_impl_->animation_host() |
| - ->AnimationsPreserveAxisAlignment(layer->id()); |
| + ->AnimationsPreserveAxisAlignment(layer->element_id()); |
| } |
| bool LayerTreeImpl::HasOnlyTranslationTransforms(const LayerImpl* layer) const { |
| ElementListType list_type = |
| IsActiveTree() ? ElementListType::ACTIVE : ElementListType::PENDING; |
| return layer_tree_host_impl_->animation_host()->HasOnlyTranslationTransforms( |
| - layer->id(), list_type); |
| + layer->element_id(), list_type); |
| } |
| bool LayerTreeImpl::MaximumTargetScale(const LayerImpl* layer, |
| @@ -2035,7 +2036,7 @@ bool LayerTreeImpl::MaximumTargetScale(const LayerImpl* layer, |
| ElementListType list_type = |
| IsActiveTree() ? ElementListType::ACTIVE : ElementListType::PENDING; |
| return layer_tree_host_impl_->animation_host()->MaximumTargetScale( |
| - layer->id(), list_type, max_scale); |
| + layer->element_id(), list_type, max_scale); |
| } |
| bool LayerTreeImpl::AnimationStartScale(const LayerImpl* layer, |
| @@ -2044,32 +2045,32 @@ bool LayerTreeImpl::AnimationStartScale(const LayerImpl* layer, |
| ElementListType list_type = |
| IsActiveTree() ? ElementListType::ACTIVE : ElementListType::PENDING; |
| return layer_tree_host_impl_->animation_host()->AnimationStartScale( |
| - layer->id(), list_type, start_scale); |
| + layer->element_id(), list_type, start_scale); |
| } |
| bool LayerTreeImpl::HasFilterAnimationThatInflatesBounds( |
| const LayerImpl* layer) const { |
| return layer_tree_host_impl_->animation_host() |
| - ->HasFilterAnimationThatInflatesBounds(layer->id()); |
| + ->HasFilterAnimationThatInflatesBounds(layer->element_id()); |
| } |
| bool LayerTreeImpl::HasTransformAnimationThatInflatesBounds( |
| const LayerImpl* layer) const { |
| return layer_tree_host_impl_->animation_host() |
| - ->HasTransformAnimationThatInflatesBounds(layer->id()); |
| + ->HasTransformAnimationThatInflatesBounds(layer->element_id()); |
| } |
| bool LayerTreeImpl::HasAnimationThatInflatesBounds( |
| const LayerImpl* layer) const { |
| return layer_tree_host_impl_->animation_host() |
| - ->HasAnimationThatInflatesBounds(layer->id()); |
| + ->HasAnimationThatInflatesBounds(layer->element_id()); |
| } |
| bool LayerTreeImpl::FilterAnimationBoundsForBox(const LayerImpl* layer, |
| const gfx::BoxF& box, |
| gfx::BoxF* bounds) const { |
| return layer_tree_host_impl_->animation_host()->FilterAnimationBoundsForBox( |
| - layer->id(), box, bounds); |
| + layer->element_id(), box, bounds); |
| } |
| bool LayerTreeImpl::TransformAnimationBoundsForBox(const LayerImpl* layer, |
| @@ -2077,7 +2078,7 @@ bool LayerTreeImpl::TransformAnimationBoundsForBox(const LayerImpl* layer, |
| gfx::BoxF* bounds) const { |
| *bounds = gfx::BoxF(); |
| return layer_tree_host_impl_->animation_host() |
| - ->TransformAnimationBoundsForBox(layer->id(), box, bounds); |
| + ->TransformAnimationBoundsForBox(layer->element_id(), box, bounds); |
| } |
| void LayerTreeImpl::ScrollAnimationAbort(bool needs_completion) { |