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

Unified Diff: cc/trees/draw_property_utils.cc

Issue 1884613005: cc : Simplify layer skipping logic (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 | « no previous file | cc/trees/layer_tree_host_common_unittest.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 27ef742570cf0370b73c3065465b1c4e44630450..f86b3017a531a8624fb9f8bffd9e0e92614ef18a 100644
--- a/cc/trees/draw_property_utils.cc
+++ b/cc/trees/draw_property_utils.cc
@@ -378,88 +378,42 @@ void UpdateRenderSurfacesForLayersRecursive(EffectTree* effect_tree,
} // namespace
-static inline bool LayerShouldBeSkipped(Layer* layer,
- bool layer_is_drawn,
- const TransformTree& transform_tree,
- const EffectTree& effect_tree) {
+template <typename LayerType>
+static inline bool LayerShouldBeSkippedInternal(
+ LayerType* layer,
+ bool layer_is_drawn,
+ const TransformTree& transform_tree,
+ const EffectTree& effect_tree) {
const TransformNode* transform_node =
transform_tree.Node(layer->transform_tree_index());
const EffectNode* effect_node = effect_tree.Node(layer->effect_tree_index());
- // If the layer transform is not invertible, it should not be drawn.
- if (!transform_node->data.node_and_ancestors_are_animated_or_invertible)
- return true;
-
- // When we need to do a readback/copy of a layer's output, we can not skip
- // it or any of its ancestors.
- if (effect_node->data.num_copy_requests_in_subtree > 0)
- return false;
-
- // If the layer is not drawn, then skip it and its subtree.
- if (!effect_node->data.is_drawn)
- return true;
-
- if (!transform_node->data.to_screen_is_potentially_animated &&
- effect_node->data.hidden_by_backface_visibility)
- return true;
-
- // If layer has a background filter, don't skip the layer, even it the
- // opacity is 0.
- if (effect_node->data.node_or_ancestor_has_background_filters)
+ if (effect_node->data.has_render_surface &&
+ effect_node->data.num_copy_requests_in_subtree > 0)
return false;
-
- // If the opacity is being animated then the opacity on the main thread is
- // unreliable (since the impl thread may be using a different opacity), so it
- // should not be trusted.
- // In particular, it should not cause the subtree to be skipped.
- // Similarly, for layers that might animate opacity using an impl-only
- // animation, their subtree should also not be skipped.
- return !effect_node->data.screen_space_opacity &&
- !effect_node->data.to_screen_opacity_is_animated;
+ // If the layer transform is not invertible, it should be skipped.
+ // TODO(ajuma): Correctly process subtrees with singular transform for the
+ // case where we may animate to a non-singular transform and wish to
+ // pre-raster.
+ return !transform_node->data.node_and_ancestors_are_animated_or_invertible ||
+ effect_node->data.hidden_by_backface_visibility ||
+ !effect_node->data.is_drawn;
}
bool LayerShouldBeSkipped(LayerImpl* layer,
bool layer_is_drawn,
const TransformTree& transform_tree,
const EffectTree& effect_tree) {
- const TransformNode* transform_node =
- transform_tree.Node(layer->transform_tree_index());
- const EffectNode* effect_node = effect_tree.Node(layer->effect_tree_index());
- // If the layer transform is not invertible, it should not be drawn.
- // TODO(ajuma): Correctly process subtrees with singular transform for the
- // case where we may animate to a non-singular transform and wish to
- // pre-raster.
- if (!transform_node->data.node_and_ancestors_are_animated_or_invertible)
- return true;
-
- // When we need to do a readback/copy of a layer's output, we can not skip
- // it or any of its ancestors.
- if (effect_node->data.num_copy_requests_in_subtree > 0)
- return false;
-
- // If the layer is not drawn, then skip it and its subtree.
- if (!effect_node->data.is_drawn)
- return true;
-
- if (effect_node->data.hidden_by_backface_visibility)
- return true;
-
- // If layer is on the pending tree and opacity is being animated then
- // this subtree can't be skipped as we need to create, prioritize and
- // include tiles for this layer when deciding if tree can be activated.
- if (!transform_tree.property_trees()->is_active &&
- effect_node->data.to_screen_opacity_is_animated)
- return false;
-
- // If layer has a background filter, don't skip the layer, even it the
- // opacity is 0.
- if (effect_node->data.node_or_ancestor_has_background_filters)
- return false;
+ return LayerShouldBeSkippedInternal(layer, layer_is_drawn, transform_tree,
+ effect_tree);
+}
- // The opacity of a layer always applies to its children (either implicitly
- // via a render surface or explicitly if the parent preserves 3D), so the
- // entire subtree can be skipped if this layer is fully transparent.
- return !effect_node->data.screen_space_opacity;
+bool LayerShouldBeSkipped(Layer* layer,
+ bool layer_is_drawn,
+ const TransformTree& transform_tree,
+ const EffectTree& effect_tree) {
+ return LayerShouldBeSkippedInternal(layer, layer_is_drawn, transform_tree,
+ effect_tree);
}
void FindLayersThatNeedUpdates(LayerTreeHost* layer_tree_host,
« no previous file with comments | « no previous file | cc/trees/layer_tree_host_common_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698