| Index: cc/trees/layer_tree_impl.cc
|
| diff --git a/cc/trees/layer_tree_impl.cc b/cc/trees/layer_tree_impl.cc
|
| index 17c6bd8778a889862f7eb465c1a08b871d59953b..8b0277bb45eefa1303adb1005ced26c6afde5d80 100644
|
| --- a/cc/trees/layer_tree_impl.cc
|
| +++ b/cc/trees/layer_tree_impl.cc
|
| @@ -460,22 +460,28 @@ LayerListReverseIterator<LayerImpl> LayerTreeImpl::rend() {
|
| return LayerListReverseIterator<LayerImpl>(nullptr);
|
| }
|
|
|
| +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) {
|
| @@ -483,17 +489,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) {
|
| @@ -505,15 +509,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()
|
| @@ -812,6 +807,15 @@ 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() {
|
| + LayerTreeHostCommon::CallFunctionForEveryLayer(this, SetElementIdForTesting);
|
| +}
|
| +
|
| bool LayerTreeImpl::UpdateDrawProperties(bool update_lcd_text) {
|
| if (!needs_update_draw_properties_)
|
| return true;
|
| @@ -1044,16 +1048,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());
|
| DCHECK_NE(root_layer_, layer);
|
| }
|
| @@ -1935,21 +1933,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(
|
| @@ -1957,7 +1955,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(
|
| @@ -1965,7 +1963,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(
|
| @@ -1973,27 +1971,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,
|
| @@ -2002,7 +2000,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,
|
| @@ -2011,32 +2009,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,
|
| @@ -2044,7 +2042,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) {
|
|
|