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

Unified Diff: cc/trees/layer_tree_impl.cc

Issue 2690753002: cc: Move render surface ownership from layers to the effect tree (Closed)
Patch Set: Replace repeated calls to LayerImpl::render_surface Created 3 years, 10 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
Index: cc/trees/layer_tree_impl.cc
diff --git a/cc/trees/layer_tree_impl.cc b/cc/trees/layer_tree_impl.cc
index ca0f8587a82bc6c479ad0066a2876913db19e478..6db5db888dff93554f330a24f831e092603bbf00 100644
--- a/cc/trees/layer_tree_impl.cc
+++ b/cc/trees/layer_tree_impl.cc
@@ -380,15 +380,13 @@ static void UpdateClipTreeForBoundsDeltaOnLayer(LayerImpl* layer,
}
void LayerTreeImpl::SetPropertyTrees(PropertyTrees* property_trees) {
- EffectTree::StableIdRenderSurfaceList stable_id_render_surface_list =
- property_trees_.effect_tree.CreateStableIdRenderSurfaceList();
property_trees_ = *property_trees;
- property_trees_.effect_tree.UpdateRenderSurfaceEffectIds(
- stable_id_render_surface_list, this);
property_trees->effect_tree.PushCopyRequestsTo(&property_trees_.effect_tree);
property_trees_.is_main_thread = false;
property_trees_.is_active = IsActiveTree();
property_trees_.transform_tree.set_source_to_parent_updates_allowed(false);
+ if (property_trees_.effect_tree.needs_update_render_surfaces())
+ set_needs_update_draw_properties();
// The value of some effect node properties (like is_drawn) depends on
// whether we are on the active tree or not. So, we need to update the
// effect tree.
@@ -504,9 +502,13 @@ void LayerTreeImpl::MoveChangeTrackingToLayers() {
for (auto* layer : *this) {
if (layer->LayerPropertyChanged())
layer->NoteLayerPropertyChanged();
- if (layer->render_surface() &&
- layer->render_surface()->AncestorPropertyChanged())
- layer->render_surface()->NoteAncestorPropertyChanged();
+ }
+ EffectTree& effect_tree = property_trees_.effect_tree;
+ for (int id = EffectTree::kContentsRootNodeId;
+ id < static_cast<int>(effect_tree.size()); ++id) {
+ RenderSurfaceImpl* render_surface = effect_tree.GetRenderSurface(id);
+ if (render_surface && render_surface->AncestorPropertyChanged())
+ render_surface->NoteAncestorPropertyChanged();
}
}
@@ -1048,15 +1050,16 @@ bool LayerTreeImpl::UpdateDrawProperties(
const RenderSurfaceImpl* occlusion_surface =
occlusion_tracker.OcclusionSurfaceForContributingSurface();
gfx::Transform draw_transform;
+ RenderSurfaceImpl* render_surface = it->render_surface();
if (occlusion_surface) {
// We are calculating transform between two render surfaces. So, we
// need to apply the surface contents scale at target and remove the
// surface contents scale at source.
- property_trees()->GetToTarget(
- it->render_surface()->TransformTreeIndex(),
- occlusion_surface->EffectTreeIndex(), &draw_transform);
+ property_trees()->GetToTarget(render_surface->TransformTreeIndex(),
+ occlusion_surface->EffectTreeIndex(),
+ &draw_transform);
const EffectNode* effect_node = property_trees()->effect_tree.Node(
- it->render_surface()->EffectTreeIndex());
+ render_surface->EffectTreeIndex());
draw_property_utils::ConcatInverseSurfaceContentsScale(
effect_node, &draw_transform);
}
@@ -1064,11 +1067,11 @@ bool LayerTreeImpl::UpdateDrawProperties(
Occlusion occlusion =
occlusion_tracker.GetCurrentOcclusionForContributingSurface(
draw_transform);
- it->render_surface()->set_occlusion_in_content_space(occlusion);
+ render_surface->set_occlusion_in_content_space(occlusion);
// Masks are used to draw the contributing surface, so should have
// the same occlusion as the surface (nothing inside the surface
// occludes them).
- if (LayerImpl* mask = it->render_surface()->MaskLayer()) {
+ if (LayerImpl* mask = render_surface->MaskLayer()) {
mask->draw_properties().occlusion_in_content_space =
occlusion_tracker.GetCurrentOcclusionForContributingSurface(
draw_transform * it->DrawTransform());
@@ -1768,13 +1771,14 @@ static const gfx::Transform SurfaceScreenSpaceTransform(
const LayerImpl* layer) {
const PropertyTrees* property_trees =
layer->layer_tree_impl()->property_trees();
- DCHECK(layer->render_surface());
+ RenderSurfaceImpl* render_surface = layer->render_surface();
+ DCHECK(render_surface);
return layer->is_drawn_render_surface_layer_list_member()
- ? layer->render_surface()->screen_space_transform()
+ ? render_surface->screen_space_transform()
: property_trees
->ToScreenSpaceTransformWithoutSurfaceContentsScale(
- layer->render_surface()->TransformTreeIndex(),
- layer->render_surface()->EffectTreeIndex());
+ render_surface->TransformTreeIndex(),
+ render_surface->EffectTreeIndex());
}
static bool PointIsClippedByAncestorClipNode(
@@ -1812,10 +1816,11 @@ static bool PointIsClippedByAncestorClipNode(
}
const LayerImpl* clip_node_owner =
layer->layer_tree_impl()->LayerById(clip_node->owning_layer_id);
- if (clip_node_owner->render_surface() &&
- !PointHitsRect(
- screen_space_point, SurfaceScreenSpaceTransform(clip_node_owner),
- clip_node_owner->render_surface()->content_rect(), NULL)) {
+ RenderSurfaceImpl* render_surface = clip_node_owner->render_surface();
+ if (render_surface &&
+ !PointHitsRect(screen_space_point,
+ SurfaceScreenSpaceTransform(clip_node_owner),
+ render_surface->content_rect(), NULL)) {
return true;
}
}

Powered by Google App Engine
This is Rietveld 408576698