Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4624)

Unified Diff: cc/trees/layer_tree_impl.cc

Issue 1973083002: Use element id's for animations (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/trees/layer_tree_impl.h ('k') | cc/trees/mutator_host_client.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/trees/layer_tree_impl.cc
diff --git a/cc/trees/layer_tree_impl.cc b/cc/trees/layer_tree_impl.cc
index 04c375d598d431b69dba359b1b3d450aee220575..0adf8745e1a6e80207f614dd9b878cbd973c8794 100644
--- a/cc/trees/layer_tree_impl.cc
+++ b/cc/trees/layer_tree_impl.cc
@@ -487,22 +487,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) {
@@ -510,17 +516,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) {
@@ -532,15 +536,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()
@@ -848,6 +843,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_testing_);
+ for (; it != LayerListIterator<LayerImpl>(nullptr); ++it) {
+ SetElementIdForTesting(*it);
+ }
+}
+
bool LayerTreeImpl::UpdateDrawProperties(bool update_lcd_text) {
if (!needs_update_draw_properties_)
return true;
@@ -1082,16 +1089,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());
}
@@ -1971,21 +1972,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(
@@ -1993,7 +1994,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(
@@ -2001,7 +2002,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(
@@ -2009,27 +2010,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,
@@ -2038,7 +2039,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,
@@ -2047,32 +2048,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,
@@ -2080,7 +2081,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) {
« no previous file with comments | « cc/trees/layer_tree_impl.h ('k') | cc/trees/mutator_host_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698