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

Unified Diff: cc/trees/layer_tree_host_common.cc

Issue 250803013: Don't clear render surfaces unnecessarily. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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
Index: cc/trees/layer_tree_host_common.cc
diff --git a/cc/trees/layer_tree_host_common.cc b/cc/trees/layer_tree_host_common.cc
index 99923d0a7c79ed7f079163206a03ff1f3a61d1e7..5602a7669f00f6fae7c26a51718bdbdf505261f1 100644
--- a/cc/trees/layer_tree_host_common.cc
+++ b/cc/trees/layer_tree_host_common.cc
@@ -1112,16 +1112,9 @@ static inline void CalculateAnimationContentsScale(
std::max(ancestor_transform_scales.x(), ancestor_transform_scales.y());
}
-static inline RenderSurface* CreateOrReuseRenderSurface(Layer* layer) {
- // The render surface should always be new on the main thread, as the
- // RenderSurfaceLayerList should be a new empty list when given to
- // CalculateDrawProperties.
- DCHECK(!layer->render_surface());
- layer->CreateRenderSurface();
- return layer->render_surface();
-}
-
-static inline RenderSurfaceImpl* CreateOrReuseRenderSurface(LayerImpl* layer) {
+template <typename LayerType>
+static inline typename LayerType::RenderSurfaceType* CreateOrReuseRenderSurface(
+ LayerType* layer) {
if (!layer->render_surface()) {
layer->CreateRenderSurface();
return layer->render_surface();
@@ -1142,13 +1135,10 @@ static inline void RemoveSurfaceForEarlyExit(
// (https://bugs.webkit.org/show_bug.cgi?id=74147), but that causes
// things to crash. So here we proactively remove any additional
// layers from the end of the list.
- while (render_surface_layer_list->back() != layer_to_remove) {
- render_surface_layer_list->back()->ClearRenderSurface();
+ while (render_surface_layer_list->back() != layer_to_remove)
render_surface_layer_list->pop_back();
- }
DCHECK_EQ(render_surface_layer_list->back(), layer_to_remove);
render_surface_layer_list->pop_back();
- layer_to_remove->ClearRenderSurface();
}
struct PreCalculateMetaInformationRecursiveData {
@@ -1381,14 +1371,22 @@ static void GetNewRenderSurfacesStartIndexAndCount(LayerType* layer,
*count = layer->draw_properties().num_render_surfaces_added;
}
-template <typename LayerType,
- typename GetIndexAndCountType>
+// We need to extract a list from the the two flavors of RenderSurfaceListType
+// for use in the sorting function below.
+static LayerList* GetLayerListForSorting(RenderSurfaceLayerList* rsll) {
+ return rsll->layer_list();
+}
+
+static LayerImplList* GetLayerListForSorting(LayerImplList* layer_list) {
+ return layer_list;
+}
+
+template <typename LayerType, typename GetIndexAndCountType>
static void SortLayerListContributions(
const LayerType& parent,
- typename LayerType::RenderSurfaceListType* unsorted,
+ typename LayerType::LayerListType* unsorted,
size_t start_index_for_all_contributions,
GetIndexAndCountType get_index_and_count) {
-
typename LayerType::LayerListType buffer;
for (size_t i = 0; i < parent.children().size(); ++i) {
LayerType* child =
@@ -1416,7 +1414,7 @@ static void CalculateDrawPropertiesInternal(
const SubtreeGlobals<LayerType>& globals,
const DataForRecursion<LayerType>& data_from_ancestor,
typename LayerType::RenderSurfaceListType* render_surface_layer_list,
- typename LayerType::RenderSurfaceListType* layer_list,
+ typename LayerType::LayerListType* layer_list,
std::vector<AccumulatedSurfaceState<LayerType> >*
accumulated_surface_state) {
// This function computes the new matrix transformations recursively for this
@@ -1558,11 +1556,8 @@ static void CalculateDrawPropertiesInternal(
const bool layer_is_drawn = layer_is_visible || layer->HasCopyRequest();
// The root layer cannot skip CalcDrawProperties.
- if (!IsRootLayer(layer) && SubtreeShouldBeSkipped(layer, layer_is_drawn)) {
- if (layer->render_surface())
- layer->ClearRenderSurface();
+ if (!IsRootLayer(layer) && SubtreeShouldBeSkipped(layer, layer_is_drawn))
return;
- }
// We need to circumvent the normal recursive flow of information for clip
// children (they don't inherit their direct ancestor's clip information).
@@ -1763,10 +1758,8 @@ static void CalculateDrawPropertiesInternal(
// Check back-face visibility before continuing with this surface and its
// subtree
if (!layer->double_sided() && TransformToParentIsKnown(layer) &&
- IsSurfaceBackFaceVisible(layer, combined_transform)) {
- layer->ClearRenderSurface();
+ IsSurfaceBackFaceVisible(layer, combined_transform))
return;
- }
typename LayerType::RenderSurfaceType* render_surface =
CreateOrReuseRenderSurface(layer);
@@ -1997,7 +1990,7 @@ static void CalculateDrawPropertiesInternal(
layer_draw_properties.clip_rect = rect_in_target_space;
}
- typename LayerType::RenderSurfaceListType& descendants =
+ typename LayerType::LayerListType& descendants =
(layer->render_surface() ? layer->render_surface()->layer_list()
: *layer_list);
@@ -2090,7 +2083,7 @@ static void CalculateDrawPropertiesInternal(
if (child_order_changed) {
SortLayerListContributions(
*layer,
- render_surface_layer_list,
+ GetLayerListForSorting(render_surface_layer_list),
render_surface_layer_list_child_sorting_start_index,
&GetNewRenderSurfacesStartIndexAndCount<LayerType>);
@@ -2313,7 +2306,7 @@ static void ProcessCalcDrawPropsInputs(
void LayerTreeHostCommon::CalculateDrawProperties(
CalcDrawPropsMainInputs* inputs) {
- RenderSurfaceLayerList dummy_layer_list;
+ LayerList dummy_layer_list;
SubtreeGlobals<Layer> globals;
DataForRecursion<Layer> data_for_recursion;
ProcessCalcDrawPropsInputs(*inputs, &globals, &data_for_recursion);

Powered by Google App Engine
This is Rietveld 408576698