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

Unified Diff: cc/trees/draw_property_utils.cc

Issue 2693703010: cc: Remove support for disabling non-root render surfaces. (Closed)
Patch Set: softwaredraw-remove-no-surfaces: rebase 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
« no previous file with comments | « cc/trees/draw_property_utils.h ('k') | cc/trees/layer_tree_host.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/trees/draw_property_utils.cc
diff --git a/cc/trees/draw_property_utils.cc b/cc/trees/draw_property_utils.cc
index bd839f0937b4e7ec78a1a321b5e5fa597dd0d42a..89ae49d90d15780def158a3bd3a6bf2f03d28f3a 100644
--- a/cc/trees/draw_property_utils.cc
+++ b/cc/trees/draw_property_utils.cc
@@ -355,24 +355,14 @@ static gfx::RectF ComputeAccumulatedClipInRootSpaceForVisibleRect(
}
void CalculateClipRects(const std::vector<LayerImpl*>& visible_layer_list,
- const PropertyTrees* property_trees,
- bool non_root_surfaces_enabled) {
+ const PropertyTrees* property_trees) {
const ClipTree& clip_tree = property_trees->clip_tree;
for (auto* layer : visible_layer_list) {
const ClipNode* clip_node = clip_tree.Node(layer->clip_tree_index());
- bool layer_needs_clip_rect =
- non_root_surfaces_enabled
- ? clip_node->layers_are_clipped
- : clip_node->layers_are_clipped_when_surfaces_disabled;
- if (!layer_needs_clip_rect) {
+ if (!clip_node->layers_are_clipped) {
layer->set_clip_rect(gfx::Rect());
continue;
}
- if (!non_root_surfaces_enabled) {
- layer->set_clip_rect(
- gfx::ToEnclosingRect(clip_node->clip_in_target_space));
- continue;
- }
const TransformTree& transform_tree = property_trees->transform_tree;
const TransformNode* transform_node =
@@ -409,8 +399,7 @@ void CalculateClipRects(const std::vector<LayerImpl*>& visible_layer_list,
}
void CalculateVisibleRects(const LayerImplList& visible_layer_list,
- const PropertyTrees* property_trees,
- bool non_root_surfaces_enabled) {
+ const PropertyTrees* property_trees) {
const EffectTree& effect_tree = property_trees->effect_tree;
const TransformTree& transform_tree = property_trees->transform_tree;
const ClipTree& clip_tree = property_trees->clip_tree;
@@ -456,28 +445,6 @@ void CalculateVisibleRects(const LayerImplList& visible_layer_list,
const ClipNode* clip_node = clip_tree.Node(layer->clip_tree_index());
const TransformNode* transform_node =
transform_tree.Node(layer->transform_tree_index());
- if (!non_root_surfaces_enabled) {
- // When we only have a root surface, the clip node and the layer must
- // necessarily have the same target (the root).
- if (transform_node->ancestors_are_invertible) {
- gfx::RectF combined_clip_rect_in_target_space =
- clip_node->combined_clip_in_target_space;
- gfx::Transform target_to_content;
- target_to_content.Translate(-layer->offset_to_transform_parent().x(),
- -layer->offset_to_transform_parent().y());
- target_to_content.PreconcatTransform(
- transform_tree.FromScreen(transform_node->id));
-
- gfx::Rect visible_rect =
- gfx::ToEnclosingRect(MathUtil::ProjectClippedRect(
- target_to_content, combined_clip_rect_in_target_space));
- visible_rect.Intersect(gfx::Rect(layer_bounds));
- layer->set_visible_layer_rect(visible_rect);
- } else {
- layer->set_visible_layer_rect(gfx::Rect(layer_bounds));
- }
- continue;
- }
// When both the layer and the target are unclipped, we only have to apply
// the viewport clip.
@@ -716,13 +683,7 @@ void FindLayersThatNeedUpdates(LayerTreeImpl* layer_tree_impl,
}
void UpdateRenderSurfaceForLayer(EffectTree* effect_tree,
- bool non_root_surfaces_enabled,
LayerImpl* layer) {
- if (!non_root_surfaces_enabled) {
- layer->SetHasRenderSurface(IsRootLayer(layer));
- return;
- }
-
EffectNode* node = effect_tree->Node(layer->effect_tree_index());
if (node->owning_layer_id == layer->id() && node->has_render_surface)
@@ -815,8 +776,7 @@ void ConcatInverseSurfaceContentsScale(const EffectNode* effect_node,
1.0 / effect_node->surface_contents_scale.y());
}
-void ComputeClips(PropertyTrees* property_trees,
- bool non_root_surfaces_enabled) {
+void ComputeClips(PropertyTrees* property_trees) {
ClipTree* clip_tree = &property_trees->clip_tree;
if (!clip_tree->needs_update())
return;
@@ -859,8 +819,7 @@ void ComputeClips(PropertyTrees* property_trees,
gfx::RectF parent_clip_in_target_space =
parent_clip_node->clip_in_target_space;
if (parent_target_transform_node &&
- parent_target_transform_node->id != clip_node->target_transform_id &&
- non_root_surfaces_enabled) {
+ parent_target_transform_node->id != clip_node->target_transform_id) {
success &= property_trees->ComputeTransformFromTarget(
clip_node->target_transform_id, parent_clip_node->target_effect_id,
&parent_to_current);
@@ -892,7 +851,7 @@ void ComputeClips(PropertyTrees* property_trees,
// the combined clip to our children because if they are clipped, they may
// need to clip using our parent clip and if we don't propagate it here,
// it will be lost.
- if (clip_node->resets_clip && non_root_surfaces_enabled) {
+ if (clip_node->resets_clip) {
if (clip_node->clip_type == ClipNode::ClipType::APPLIES_LOCAL_CLIP) {
gfx::Transform to_target;
property_trees->GetToTarget(clip_node->transform_id,
@@ -917,10 +876,7 @@ void ComputeClips(PropertyTrees* property_trees,
if (use_only_parent_clip) {
clip_node->combined_clip_in_target_space =
parent_combined_clip_in_target_space;
- if (!non_root_surfaces_enabled) {
- clip_node->clip_in_target_space =
- parent_clip_node->clip_in_target_space;
- } else if (!target_is_clipped) {
+ if (!target_is_clipped) {
clip_node->clip_in_target_space = parent_clip_in_target_space;
} else {
// Render Surface applies clip and the owning layer itself applies
@@ -931,10 +887,8 @@ void ComputeClips(PropertyTrees* property_trees,
} else {
gfx::Transform source_to_target;
- if (!non_root_surfaces_enabled) {
- source_to_target = transform_tree.ToScreen(clip_node->transform_id);
- } else if (transform_tree.ContentTargetId(transform_node->id) ==
- clip_node->target_transform_id) {
+ if (transform_tree.ContentTargetId(transform_node->id) ==
+ clip_node->target_transform_id) {
property_trees->GetToTarget(clip_node->transform_id,
clip_node->target_effect_id,
&source_to_target);
@@ -953,9 +907,7 @@ void ComputeClips(PropertyTrees* property_trees,
// for layer clipping is the case where no non-viewport ancestor node
// applies a local clip.
bool layer_clipping_uses_only_local_clip =
- non_root_surfaces_enabled
- ? clip_node->layer_clipping_uses_only_local_clip
- : !parent_clip_node->layers_are_clipped_when_surfaces_disabled;
+ clip_node->layer_clipping_uses_only_local_clip;
if (!layer_clipping_uses_only_local_clip) {
clip_node->clip_in_target_space = gfx::IntersectRects(
parent_clip_in_target_space, source_clip_in_target_space);
@@ -981,16 +933,13 @@ void ComputeTransforms(TransformTree* transform_tree) {
transform_tree->set_needs_update(false);
}
-void UpdateRenderTarget(EffectTree* effect_tree,
- bool can_render_to_separate_surface) {
+void UpdateRenderTarget(EffectTree* effect_tree) {
for (int i = EffectTree::kContentsRootNodeId;
i < static_cast<int>(effect_tree->size()); ++i) {
EffectNode* node = effect_tree->Node(i);
if (i == EffectTree::kContentsRootNodeId) {
// Render target of the node corresponding to root is itself.
node->target_id = EffectTree::kContentsRootNodeId;
- } else if (!can_render_to_separate_surface) {
- node->target_id = EffectTree::kContentsRootNodeId;
} else if (effect_tree->parent(node)->has_render_surface) {
node->target_id = node->parent_id;
} else {
@@ -1052,22 +1001,13 @@ static void ComputeLayerClipRect(const PropertyTrees* property_trees,
effect_node->has_render_surface
? effect_node
: effect_tree->Node(effect_node->target_id);
- // TODO(weiliangc): When effect node has up to date render surface info on
- // compositor thread, no need to check for resourceless draw mode
- if (!property_trees->non_root_surfaces_enabled) {
- target_node = effect_tree->Node(1);
- }
-
bool include_viewport_clip = false;
bool include_expanding_clips = false;
ConditionalClip accumulated_clip_rect = ComputeAccumulatedClip(
property_trees, include_viewport_clip, include_expanding_clips,
layer->clip_tree_index(), target_node->id);
- bool is_clipped_from_clip_tree =
- property_trees->non_root_surfaces_enabled
- ? clip_node->layers_are_clipped
- : clip_node->layers_are_clipped_when_surfaces_disabled;
+ bool is_clipped_from_clip_tree = clip_node->layers_are_clipped;
DCHECK_EQ(is_clipped_from_clip_tree, accumulated_clip_rect.is_clipped);
gfx::RectF accumulated_clip = accumulated_clip_rect.clip_rect;
@@ -1083,40 +1023,25 @@ static void ComputeLayerClipRect(const PropertyTrees* property_trees,
static void ComputeVisibleRectsInternal(
LayerImpl* root_layer,
PropertyTrees* property_trees,
- bool can_render_to_separate_surface,
std::vector<LayerImpl*>* visible_layer_list) {
- if (property_trees->non_root_surfaces_enabled !=
- can_render_to_separate_surface) {
- property_trees->non_root_surfaces_enabled = can_render_to_separate_surface;
- property_trees->transform_tree.set_needs_update(true);
- }
if (property_trees->transform_tree.needs_update()) {
property_trees->clip_tree.set_needs_update(true);
property_trees->effect_tree.set_needs_update(true);
}
- UpdateRenderTarget(&property_trees->effect_tree,
- property_trees->non_root_surfaces_enabled);
+ UpdateRenderTarget(&property_trees->effect_tree);
ComputeTransforms(&property_trees->transform_tree);
// Computation of clips uses surface contents scale which is updated while
// computing effects. So, ComputeEffects should be before ComputeClips.
ComputeEffects(&property_trees->effect_tree);
- ComputeClips(property_trees, can_render_to_separate_surface);
+ ComputeClips(property_trees);
FindLayersThatNeedUpdates(root_layer->layer_tree_impl(), property_trees,
visible_layer_list);
- CalculateClipRects(*visible_layer_list, property_trees,
- can_render_to_separate_surface);
- CalculateVisibleRects(*visible_layer_list, property_trees,
- can_render_to_separate_surface);
-}
-
-void UpdatePropertyTrees(PropertyTrees* property_trees,
- bool can_render_to_separate_surface) {
- if (property_trees->non_root_surfaces_enabled !=
- can_render_to_separate_surface) {
- property_trees->non_root_surfaces_enabled = can_render_to_separate_surface;
- property_trees->transform_tree.set_needs_update(true);
- }
+ CalculateClipRects(*visible_layer_list, property_trees);
+ CalculateVisibleRects(*visible_layer_list, property_trees);
+}
+
+void UpdatePropertyTrees(PropertyTrees* property_trees) {
if (property_trees->transform_tree.needs_update()) {
property_trees->clip_tree.set_needs_update(true);
property_trees->effect_tree.set_needs_update(true);
@@ -1125,7 +1050,7 @@ void UpdatePropertyTrees(PropertyTrees* property_trees,
// Computation of clips uses surface contents scale which is updated while
// computing effects. So, ComputeEffects should be before ComputeClips.
ComputeEffects(&property_trees->effect_tree);
- ComputeClips(property_trees, can_render_to_separate_surface);
+ ComputeClips(property_trees);
}
void BuildPropertyTreesAndComputeVisibleRects(
@@ -1139,7 +1064,6 @@ void BuildPropertyTreesAndComputeVisibleRects(
float device_scale_factor,
const gfx::Rect& viewport,
const gfx::Transform& device_transform,
- bool can_render_to_separate_surface,
PropertyTrees* property_trees,
LayerImplList* visible_layer_list) {
PropertyTreeBuilder::BuildPropertyTrees(
@@ -1147,26 +1071,21 @@ void BuildPropertyTreesAndComputeVisibleRects(
outer_viewport_scroll_layer, overscroll_elasticity_layer,
elastic_overscroll, page_scale_factor, device_scale_factor, viewport,
device_transform, property_trees);
- ComputeVisibleRects(root_layer, property_trees,
- can_render_to_separate_surface, visible_layer_list);
+ ComputeVisibleRects(root_layer, property_trees, visible_layer_list);
}
void VerifyClipTreeCalculations(const LayerImplList& layer_list,
PropertyTrees* property_trees) {
- if (property_trees->non_root_surfaces_enabled) {
- ComputeClipsWithEffectTree(property_trees);
- }
+ ComputeClipsWithEffectTree(property_trees);
for (auto* layer : layer_list)
ComputeLayerClipRect(property_trees, layer);
}
void ComputeVisibleRects(LayerImpl* root_layer,
PropertyTrees* property_trees,
- bool can_render_to_separate_surface,
LayerImplList* visible_layer_list) {
for (auto* layer : *root_layer->layer_tree_impl()) {
- UpdateRenderSurfaceForLayer(&property_trees->effect_tree,
- can_render_to_separate_surface, layer);
+ UpdateRenderSurfaceForLayer(&property_trees->effect_tree, layer);
EffectNode* node =
property_trees->effect_tree.Node(layer->effect_tree_index());
if (node->owning_layer_id == layer->id()) {
@@ -1175,12 +1094,10 @@ void ComputeVisibleRects(LayerImpl* root_layer,
node->render_surface->set_effect_tree_index(node->id);
}
#if DCHECK_IS_ON()
- if (can_render_to_separate_surface)
- ValidateRenderSurfaceForLayer(layer);
+ ValidateRenderSurfaceForLayer(layer);
#endif
}
ComputeVisibleRectsInternal(root_layer, property_trees,
- can_render_to_separate_surface,
visible_layer_list);
}
@@ -1259,12 +1176,9 @@ gfx::Transform DrawTransform(const LayerImpl* layer,
// node and surface's transform node and scales it by the surface's content
// scale.
gfx::Transform xform;
- if (transform_tree.property_trees()->non_root_surfaces_enabled)
- transform_tree.property_trees()->GetToTarget(
- layer->transform_tree_index(), layer->render_target_effect_tree_index(),
- &xform);
- else
- xform = transform_tree.ToScreen(layer->transform_tree_index());
+ transform_tree.property_trees()->GetToTarget(
+ layer->transform_tree_index(), layer->render_target_effect_tree_index(),
+ &xform);
if (layer->should_flatten_transform_from_property_tree())
xform.FlattenTo2d();
xform.Translate(layer->offset_to_transform_parent().x(),
@@ -1421,12 +1335,7 @@ void ComputeLayerDrawProperties(LayerImpl* layer,
layer->draw_properties().opacity =
LayerDrawOpacity(layer, property_trees->effect_tree);
- if (property_trees->non_root_surfaces_enabled) {
- layer->draw_properties().is_clipped = clip_node->layers_are_clipped;
- } else {
- layer->draw_properties().is_clipped =
- clip_node->layers_are_clipped_when_surfaces_disabled;
- }
+ layer->draw_properties().is_clipped = clip_node->layers_are_clipped;
gfx::Rect bounds_in_target_space = MathUtil::MapEnclosingClippedRect(
layer->draw_properties().target_space_transform,
« no previous file with comments | « cc/trees/draw_property_utils.h ('k') | cc/trees/layer_tree_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698