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

Side by Side Diff: cc/trees/layer_tree_host_common.cc

Issue 465853004: Moving RenderSurface creation outside of CalcDrawProps (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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 unified diff | Download patch
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/trees/layer_tree_host_common.h" 5 #include "cc/trees/layer_tree_host_common.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/debug/trace_event.h" 9 #include "base/debug/trace_event.h"
10 #include "cc/base/math_util.h" 10 #include "cc/base/math_util.h"
(...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after
541 541
542 static inline void SavePaintPropertiesLayer(Layer* layer) { 542 static inline void SavePaintPropertiesLayer(Layer* layer) {
543 layer->SavePaintProperties(); 543 layer->SavePaintProperties();
544 544
545 if (layer->mask_layer()) 545 if (layer->mask_layer())
546 layer->mask_layer()->SavePaintProperties(); 546 layer->mask_layer()->SavePaintProperties();
547 if (layer->replica_layer() && layer->replica_layer()->mask_layer()) 547 if (layer->replica_layer() && layer->replica_layer()->mask_layer())
548 layer->replica_layer()->mask_layer()->SavePaintProperties(); 548 layer->replica_layer()->mask_layer()->SavePaintProperties();
549 } 549 }
550 550
551 template <typename LayerType>
552 static bool SubtreeShouldRenderToSeparateSurface( 551 static bool SubtreeShouldRenderToSeparateSurface(
553 LayerType* layer, 552 Layer* layer,
554 bool axis_aligned_with_respect_to_parent) { 553 bool axis_aligned_with_respect_to_parent) {
555 // 554 //
556 // A layer and its descendants should render onto a new RenderSurfaceImpl if 555 // A layer and its descendants should render onto a new RenderSurfaceImpl if
557 // any of these rules hold: 556 // any of these rules hold:
558 // 557 //
559 558
560 // The root layer owns a render surface, but it never acts as a contributing 559 // The root layer owns a render surface, but it never acts as a contributing
561 // surface to another render target. Compositor features that are applied via 560 // surface to another render target. Compositor features that are applied via
562 // a contributing surface can not be applied to the root layer. In order to 561 // a contributing surface can not be applied to the root layer. In order to
563 // use these effects, another child of the root would need to be introduced 562 // use these effects, another child of the root would need to be introduced
(...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after
1099 *combined_maximum_animation_contents_scale = 0.f; 1098 *combined_maximum_animation_contents_scale = 0.f;
1100 return; 1099 return;
1101 } 1100 }
1102 gfx::Vector2dF ancestor_transform_scales = 1101 gfx::Vector2dF ancestor_transform_scales =
1103 MathUtil::ComputeTransform2dScaleComponents(ancestor_transform, 0.f); 1102 MathUtil::ComputeTransform2dScaleComponents(ancestor_transform, 0.f);
1104 *combined_maximum_animation_contents_scale = 1103 *combined_maximum_animation_contents_scale =
1105 layer_maximum_animated_scale * 1104 layer_maximum_animated_scale *
1106 std::max(ancestor_transform_scales.x(), ancestor_transform_scales.y()); 1105 std::max(ancestor_transform_scales.x(), ancestor_transform_scales.y());
1107 } 1106 }
1108 1107
1109 template <typename LayerType>
1110 static inline typename LayerType::RenderSurfaceType* CreateOrReuseRenderSurface(
1111 LayerType* layer) {
1112 if (!layer->render_surface()) {
1113 layer->CreateRenderSurface();
1114 return layer->render_surface();
1115 }
1116
1117 layer->render_surface()->ClearLayerLists();
1118 return layer->render_surface();
1119 }
1120
1121 template <typename LayerTypePtr> 1108 template <typename LayerTypePtr>
1122 static inline void MarkLayerWithRenderSurfaceLayerListId( 1109 static inline void MarkLayerWithRenderSurfaceLayerListId(
1123 LayerTypePtr layer, 1110 LayerTypePtr layer,
1124 int current_render_surface_layer_list_id) { 1111 int current_render_surface_layer_list_id) {
1125 layer->draw_properties().last_drawn_render_surface_layer_list_id = 1112 layer->draw_properties().last_drawn_render_surface_layer_list_id =
1126 current_render_surface_layer_list_id; 1113 current_render_surface_layer_list_id;
1127 } 1114 }
1128 1115
1129 template <typename LayerTypePtr> 1116 template <typename LayerTypePtr>
1130 static inline void MarkMasksWithRenderSurfaceLayerListId( 1117 static inline void MarkMasksWithRenderSurfaceLayerListId(
(...skipping 675 matching lines...) Expand 10 before | Expand all | Expand 10 after
1806 data_from_ancestor.full_hierarchy_matrix; 1793 data_from_ancestor.full_hierarchy_matrix;
1807 1794
1808 // If the subtree will scale layer contents by the transform hierarchy, then 1795 // If the subtree will scale layer contents by the transform hierarchy, then
1809 // we should scale things into the render surface by the transform hierarchy 1796 // we should scale things into the render surface by the transform hierarchy
1810 // to take advantage of that. 1797 // to take advantage of that.
1811 gfx::Vector2dF render_surface_sublayer_scale = 1798 gfx::Vector2dF render_surface_sublayer_scale =
1812 globals.can_adjust_raster_scales 1799 globals.can_adjust_raster_scales
1813 ? combined_transform_scales 1800 ? combined_transform_scales
1814 : gfx::Vector2dF(layer_scale_factors, layer_scale_factors); 1801 : gfx::Vector2dF(layer_scale_factors, layer_scale_factors);
1815 1802
1816 bool render_to_separate_surface; 1803 bool render_to_separate_surface =
1817 if (globals.can_render_to_separate_surface) { 1804 IsRootLayer(layer) ||
1818 render_to_separate_surface = SubtreeShouldRenderToSeparateSurface( 1805 (globals.can_render_to_separate_surface && layer->render_surface());
1819 layer, combined_transform.Preserves2dAxisAlignment()); 1806
1820 } else {
1821 render_to_separate_surface = IsRootLayer(layer);
1822 }
1823 if (render_to_separate_surface) { 1807 if (render_to_separate_surface) {
1808 DCHECK(layer->render_surface());
1824 // Check back-face visibility before continuing with this surface and its 1809 // Check back-face visibility before continuing with this surface and its
1825 // subtree 1810 // subtree
1826 if (!layer->double_sided() && TransformToParentIsKnown(layer) && 1811 if (!layer->double_sided() && TransformToParentIsKnown(layer) &&
1827 IsSurfaceBackFaceVisible(layer, combined_transform)) { 1812 IsSurfaceBackFaceVisible(layer, combined_transform)) {
1828 layer->ClearRenderSurfaceLayerList(); 1813 layer->ClearRenderSurfaceLayerList();
1829 return; 1814 return;
1830 } 1815 }
1831 1816
1832 typename LayerType::RenderSurfaceType* render_surface = 1817 typename LayerType::RenderSurfaceType* render_surface =
1833 CreateOrReuseRenderSurface(layer); 1818 layer->render_surface();
1819 layer->ClearRenderSurfaceLayerList();
1834 1820
1821 layer_draw_properties.render_target = layer;
1835 if (IsRootLayer(layer)) { 1822 if (IsRootLayer(layer)) {
1836 // The root layer's render surface size is predetermined and so the root 1823 // The root layer's render surface size is predetermined and so the root
1837 // layer can't directly support non-identity transforms. It should just 1824 // layer can't directly support non-identity transforms. It should just
1838 // forward top-level transforms to the rest of the tree. 1825 // forward top-level transforms to the rest of the tree.
1839 data_for_children.parent_matrix = combined_transform; 1826 data_for_children.parent_matrix = combined_transform;
1840 1827
1841 // The root surface does not contribute to any other surface, it has no 1828 // The root surface does not contribute to any other surface, it has no
1842 // target. 1829 // target.
1843 layer->render_surface()->set_contributes_to_drawn_surface(false); 1830 layer->render_surface()->set_contributes_to_drawn_surface(false);
1844 } else { 1831 } else {
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
1999 layer_draw_properties.target_space_transform_is_animating = 1986 layer_draw_properties.target_space_transform_is_animating =
2000 animating_transform_to_target; 1987 animating_transform_to_target;
2001 layer_draw_properties.screen_space_transform_is_animating = 1988 layer_draw_properties.screen_space_transform_is_animating =
2002 animating_transform_to_screen; 1989 animating_transform_to_screen;
2003 layer_draw_properties.opacity = accumulated_draw_opacity; 1990 layer_draw_properties.opacity = accumulated_draw_opacity;
2004 layer_draw_properties.opacity_is_animating = animating_opacity_to_target; 1991 layer_draw_properties.opacity_is_animating = animating_opacity_to_target;
2005 layer_draw_properties.screen_space_opacity_is_animating = 1992 layer_draw_properties.screen_space_opacity_is_animating =
2006 animating_opacity_to_screen; 1993 animating_opacity_to_screen;
2007 data_for_children.parent_matrix = combined_transform; 1994 data_for_children.parent_matrix = combined_transform;
2008 1995
2009 layer->ClearRenderSurface();
2010
2011 // Layers without render_surfaces directly inherit the ancestor's clip 1996 // Layers without render_surfaces directly inherit the ancestor's clip
2012 // status. 1997 // status.
2013 layer_or_ancestor_clips_descendants = ancestor_clips_subtree; 1998 layer_or_ancestor_clips_descendants = ancestor_clips_subtree;
2014 if (ancestor_clips_subtree) { 1999 if (ancestor_clips_subtree) {
2015 clip_rect_in_target_space = 2000 clip_rect_in_target_space =
2016 ancestor_clip_rect_in_target_space; 2001 ancestor_clip_rect_in_target_space;
2017 } 2002 }
2018 2003
2019 // The surface's cached clip rect value propagates regardless of what 2004 // The surface's cached clip rect value propagates regardless of what
2020 // clipping goes on between layers here. 2005 // clipping goes on between layers here.
2021 clip_rect_of_target_surface_in_target_space = 2006 clip_rect_of_target_surface_in_target_space =
2022 data_from_ancestor.clip_rect_of_target_surface_in_target_space; 2007 data_from_ancestor.clip_rect_of_target_surface_in_target_space;
2023 2008
2024 // Layers that are not their own render_target will render into the target 2009 // Layers that are not their own render_target will render into the target
2025 // of their nearest ancestor. 2010 // of their nearest ancestor.
2026 layer_draw_properties.render_target = layer->parent()->render_target(); 2011 layer_draw_properties.render_target = layer->parent()->render_target();
2027 } 2012 }
2028 2013
2029 if (adjust_text_aa) 2014 if (adjust_text_aa)
2030 layer_draw_properties.can_use_lcd_text = layer_can_use_lcd_text; 2015 layer_draw_properties.can_use_lcd_text = layer_can_use_lcd_text;
2031 2016
2032 gfx::Rect rect_in_target_space = 2017 gfx::Rect rect_in_target_space =
2033 MathUtil::MapEnclosingClippedRect(layer->draw_transform(), content_rect); 2018 MathUtil::MapEnclosingClippedRect(layer->draw_transform(), content_rect);
2034 2019
2035 if (LayerClipsSubtree(layer)) { 2020 if (LayerClipsSubtree(layer)) {
2036 layer_or_ancestor_clips_descendants = true; 2021 layer_or_ancestor_clips_descendants = true;
2037 if (ancestor_clips_subtree && !layer->render_surface()) { 2022 if (ancestor_clips_subtree && !render_to_separate_surface) {
2038 // A layer without render surface shares the same target as its ancestor. 2023 // A layer without render surface shares the same target as its ancestor.
2039 clip_rect_in_target_space = 2024 clip_rect_in_target_space =
2040 ancestor_clip_rect_in_target_space; 2025 ancestor_clip_rect_in_target_space;
2041 clip_rect_in_target_space.Intersect(rect_in_target_space); 2026 clip_rect_in_target_space.Intersect(rect_in_target_space);
2042 } else { 2027 } else {
2043 clip_rect_in_target_space = rect_in_target_space; 2028 clip_rect_in_target_space = rect_in_target_space;
2044 } 2029 }
2045 } 2030 }
2046 2031
2047 // Tell the layer the rect that it's clipped by. In theory we could use a 2032 // Tell the layer the rect that it's clipped by. In theory we could use a
2048 // tighter clip rect here (drawable_content_rect), but that actually does not 2033 // tighter clip rect here (drawable_content_rect), but that actually does not
2049 // reduce how much would be drawn, and instead it would create unnecessary 2034 // reduce how much would be drawn, and instead it would create unnecessary
2050 // changes to scissor state affecting GPU performance. Our clip information 2035 // changes to scissor state affecting GPU performance. Our clip information
2051 // is used in the recursion below, so we must set it beforehand. 2036 // is used in the recursion below, so we must set it beforehand.
2052 layer_draw_properties.is_clipped = layer_or_ancestor_clips_descendants; 2037 layer_draw_properties.is_clipped = layer_or_ancestor_clips_descendants;
2053 if (layer_or_ancestor_clips_descendants) { 2038 if (layer_or_ancestor_clips_descendants) {
2054 layer_draw_properties.clip_rect = clip_rect_in_target_space; 2039 layer_draw_properties.clip_rect = clip_rect_in_target_space;
2055 } else { 2040 } else {
2056 // Initialize the clip rect to a safe value that will not clip the 2041 // Initialize the clip rect to a safe value that will not clip the
2057 // layer, just in case clipping is still accidentally used. 2042 // layer, just in case clipping is still accidentally used.
2058 layer_draw_properties.clip_rect = rect_in_target_space; 2043 layer_draw_properties.clip_rect = rect_in_target_space;
2059 } 2044 }
2060 2045
2061 typename LayerType::LayerListType& descendants = 2046 typename LayerType::LayerListType& descendants =
2062 (layer->render_surface() ? layer->render_surface()->layer_list() 2047 (render_to_separate_surface ? layer->render_surface()->layer_list()
2063 : *layer_list); 2048 : *layer_list);
2064 2049
2065 // Any layers that are appended after this point are in the layer's subtree 2050 // Any layers that are appended after this point are in the layer's subtree
2066 // and should be included in the sorting process. 2051 // and should be included in the sorting process.
2067 size_t sorting_start_index = descendants.size(); 2052 size_t sorting_start_index = descendants.size();
2068 2053
2069 if (!LayerShouldBeSkipped(layer, layer_is_drawn)) { 2054 if (!LayerShouldBeSkipped(layer, layer_is_drawn)) {
2070 MarkLayerWithRenderSurfaceLayerListId(layer, 2055 MarkLayerWithRenderSurfaceLayerListId(layer,
2071 current_render_surface_layer_list_id); 2056 current_render_surface_layer_list_id);
2072 descendants.push_back(layer); 2057 descendants.push_back(layer);
2073 } 2058 }
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
2131 render_surface_layer_list->size(); 2116 render_surface_layer_list->size();
2132 2117
2133 CalculateDrawPropertiesInternal<LayerType>( 2118 CalculateDrawPropertiesInternal<LayerType>(
2134 child, 2119 child,
2135 globals, 2120 globals,
2136 data_for_children, 2121 data_for_children,
2137 render_surface_layer_list, 2122 render_surface_layer_list,
2138 &descendants, 2123 &descendants,
2139 accumulated_surface_state, 2124 accumulated_surface_state,
2140 current_render_surface_layer_list_id); 2125 current_render_surface_layer_list_id);
2141 if (child->render_surface() && 2126 // If the child is its own render target, then it has a render surface.
2127 if (child->render_target() == child &&
2142 !child->render_surface()->layer_list().empty() && 2128 !child->render_surface()->layer_list().empty() &&
2143 !child->render_surface()->content_rect().IsEmpty()) { 2129 !child->render_surface()->content_rect().IsEmpty()) {
2144 // This child will contribute its render surface, which means 2130 // This child will contribute its render surface, which means
2145 // we need to mark just the mask layer (and replica mask layer) 2131 // we need to mark just the mask layer (and replica mask layer)
2146 // with the id. 2132 // with the id.
2147 MarkMasksWithRenderSurfaceLayerListId( 2133 MarkMasksWithRenderSurfaceLayerListId(
2148 child, current_render_surface_layer_list_id); 2134 child, current_render_surface_layer_list_id);
2149 descendants.push_back(child); 2135 descendants.push_back(child);
2150 } 2136 }
2151 2137
(...skipping 18 matching lines...) Expand all
2170 *layer, 2156 *layer,
2171 &descendants, 2157 &descendants,
2172 layer_list_child_sorting_start_index, 2158 layer_list_child_sorting_start_index,
2173 &GetNewDescendantsStartIndexAndCount<LayerType>); 2159 &GetNewDescendantsStartIndexAndCount<LayerType>);
2174 } 2160 }
2175 2161
2176 // Compute the total drawable_content_rect for this subtree (the rect is in 2162 // Compute the total drawable_content_rect for this subtree (the rect is in
2177 // target surface space). 2163 // target surface space).
2178 gfx::Rect local_drawable_content_rect_of_subtree = 2164 gfx::Rect local_drawable_content_rect_of_subtree =
2179 accumulated_surface_state->back().drawable_content_rect; 2165 accumulated_surface_state->back().drawable_content_rect;
2180 if (layer->render_surface()) { 2166 if (render_to_separate_surface) {
2181 DCHECK(accumulated_surface_state->back().render_target == layer); 2167 DCHECK(accumulated_surface_state->back().render_target == layer);
2182 accumulated_surface_state->pop_back(); 2168 accumulated_surface_state->pop_back();
2183 } 2169 }
2184 2170
2185 if (layer->render_surface() && !IsRootLayer(layer) && 2171 if (render_to_separate_surface && !IsRootLayer(layer) &&
2186 layer->render_surface()->layer_list().empty()) { 2172 layer->render_surface()->layer_list().empty()) {
2187 RemoveSurfaceForEarlyExit(layer, render_surface_layer_list); 2173 RemoveSurfaceForEarlyExit(layer, render_surface_layer_list);
2188 return; 2174 return;
2189 } 2175 }
2190 2176
2191 // Compute the layer's drawable content rect (the rect is in target surface 2177 // Compute the layer's drawable content rect (the rect is in target surface
2192 // space). 2178 // space).
2193 layer_draw_properties.drawable_content_rect = rect_in_target_space; 2179 layer_draw_properties.drawable_content_rect = rect_in_target_space;
2194 if (layer_or_ancestor_clips_descendants) { 2180 if (layer_or_ancestor_clips_descendants) {
2195 layer_draw_properties.drawable_content_rect.Intersect( 2181 layer_draw_properties.drawable_content_rect.Intersect(
2196 clip_rect_in_target_space); 2182 clip_rect_in_target_space);
2197 } 2183 }
2198 if (layer->DrawsContent()) { 2184 if (layer->DrawsContent()) {
2199 local_drawable_content_rect_of_subtree.Union( 2185 local_drawable_content_rect_of_subtree.Union(
2200 layer_draw_properties.drawable_content_rect); 2186 layer_draw_properties.drawable_content_rect);
2201 } 2187 }
2202 2188
2203 // Compute the layer's visible content rect (the rect is in content space). 2189 // Compute the layer's visible content rect (the rect is in content space).
2204 layer_draw_properties.visible_content_rect = CalculateVisibleContentRect( 2190 layer_draw_properties.visible_content_rect = CalculateVisibleContentRect(
2205 layer, clip_rect_of_target_surface_in_target_space, rect_in_target_space); 2191 layer, clip_rect_of_target_surface_in_target_space, rect_in_target_space);
2206 2192
2207 // Compute the remaining properties for the render surface, if the layer has 2193 // Compute the remaining properties for the render surface, if the layer has
2208 // one. 2194 // one.
2209 if (IsRootLayer(layer)) { 2195 if (IsRootLayer(layer)) {
2210 // The root layer's surface's content_rect is always the entire viewport. 2196 // The root layer's surface's content_rect is always the entire viewport.
2211 DCHECK(layer->render_surface()); 2197 DCHECK(render_to_separate_surface);
2212 layer->render_surface()->SetContentRect( 2198 layer->render_surface()->SetContentRect(
2213 ancestor_clip_rect_in_target_space); 2199 ancestor_clip_rect_in_target_space);
2214 } else if (layer->render_surface()) { 2200 } else if (render_to_separate_surface) {
2215 typename LayerType::RenderSurfaceType* render_surface = 2201 typename LayerType::RenderSurfaceType* render_surface =
2216 layer->render_surface(); 2202 layer->render_surface();
2217 gfx::Rect clipped_content_rect = local_drawable_content_rect_of_subtree; 2203 gfx::Rect clipped_content_rect = local_drawable_content_rect_of_subtree;
2218 2204
2219 // Don't clip if the layer is reflected as the reflection shouldn't be 2205 // Don't clip if the layer is reflected as the reflection shouldn't be
2220 // clipped. If the layer is animating, then the surface's transform to 2206 // clipped. If the layer is animating, then the surface's transform to
2221 // its target is not known on the main thread, and we should not use it 2207 // its target is not known on the main thread, and we should not use it
2222 // to clip. 2208 // to clip.
2223 if (!layer->replica_layer() && TransformToParentIsKnown(layer)) { 2209 if (!layer->replica_layer() && TransformToParentIsKnown(layer)) {
2224 // Note, it is correct to use data_from_ancestor.ancestor_clips_subtree 2210 // Note, it is correct to use data_from_ancestor.ancestor_clips_subtree
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
2298 surface_origin_to_replica_origin_transform; 2284 surface_origin_to_replica_origin_transform;
2299 render_surface->SetReplicaScreenSpaceTransform( 2285 render_surface->SetReplicaScreenSpaceTransform(
2300 replica_screen_space_transform); 2286 replica_screen_space_transform);
2301 } 2287 }
2302 } 2288 }
2303 2289
2304 SavePaintPropertiesLayer(layer); 2290 SavePaintPropertiesLayer(layer);
2305 2291
2306 // If neither this layer nor any of its children were added, early out. 2292 // If neither this layer nor any of its children were added, early out.
2307 if (sorting_start_index == descendants.size()) { 2293 if (sorting_start_index == descendants.size()) {
2308 DCHECK(!layer->render_surface() || IsRootLayer(layer)); 2294 DCHECK(!render_to_separate_surface || IsRootLayer(layer));
2309 return; 2295 return;
2310 } 2296 }
2311 2297
2312 // If preserves-3d then sort all the descendants in 3D so that they can be 2298 // If preserves-3d then sort all the descendants in 3D so that they can be
2313 // drawn from back to front. If the preserves-3d property is also set on the 2299 // drawn from back to front. If the preserves-3d property is also set on the
2314 // parent then skip the sorting as the parent will sort all the descendants 2300 // parent then skip the sorting as the parent will sort all the descendants
2315 // anyway. 2301 // anyway.
2316 if (globals.layer_sorter && descendants.size() && layer->Is3dSorted() && 2302 if (globals.layer_sorter && descendants.size() && layer->Is3dSorted() &&
2317 !LayerIsInExisting3DRenderingContext(layer)) { 2303 !LayerIsInExisting3DRenderingContext(layer)) {
2318 SortLayers(descendants.begin() + sorting_start_index, 2304 SortLayers(descendants.begin() + sorting_start_index,
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
2376 device_viewport_rect; 2362 device_viewport_rect;
2377 data_for_recursion->maximum_animation_contents_scale = 0.f; 2363 data_for_recursion->maximum_animation_contents_scale = 0.f;
2378 data_for_recursion->ancestor_is_animating_scale = false; 2364 data_for_recursion->ancestor_is_animating_scale = false;
2379 data_for_recursion->ancestor_clips_subtree = true; 2365 data_for_recursion->ancestor_clips_subtree = true;
2380 data_for_recursion->nearest_occlusion_immune_ancestor_surface = NULL; 2366 data_for_recursion->nearest_occlusion_immune_ancestor_surface = NULL;
2381 data_for_recursion->in_subtree_of_page_scale_application_layer = false; 2367 data_for_recursion->in_subtree_of_page_scale_application_layer = false;
2382 data_for_recursion->subtree_can_use_lcd_text = inputs.can_use_lcd_text; 2368 data_for_recursion->subtree_can_use_lcd_text = inputs.can_use_lcd_text;
2383 data_for_recursion->subtree_is_visible_from_ancestor = true; 2369 data_for_recursion->subtree_is_visible_from_ancestor = true;
2384 } 2370 }
2385 2371
2372 void CreateOrDestroyRenderSurface(Layer* layer,
2373 bool can_render_to_separate_surface,
2374 gfx::Transform* transform) {
2375 if (IsRootLayer(layer) ||
2376 (can_render_to_separate_surface &&
2377 SubtreeShouldRenderToSeparateSurface(
2378 layer, transform->Preserves2dAxisAlignment()))) {
2379 transform->MakeIdentity();
danakj 2014/09/25 16:02:12 Please add a thorough comment explaining this Make
awoloszyn 2014/11/25 15:48:46 Done.
2380 if (!layer->render_surface()) {
danakj 2014/09/25 16:02:12 since we always clear them on the main thread, can
awoloszyn 2014/11/25 15:48:46 If we had a render surface and then it was cleaned
2381 layer->CreateRenderSurface();
2382 }
2383 layer->SetHasRenderSurface(true);
2384 return;
2385 }
2386 layer->SetHasRenderSurface(false);
2387 if (layer->render_surface())
danakj 2014/09/25 16:02:12 can this also DCHECK instead and drop the Clear?
awoloszyn 2014/11/25 15:48:46 Same as above.
2388 layer->ClearRenderSurface();
2389 }
2390
2391 static void CreateRenderSurfaces(Layer* layer,
2392 bool can_render_to_separate_surface,
2393 const gfx::Transform& parent_transform) {
2394 if (!layer)
danakj 2014/09/25 16:02:12 why is this needed, you can't call CDP() with a nu
awoloszyn 2014/11/25 15:48:46 Was done for a unit-test originally, but no longer
2395 return;
2396 gfx::Transform transformForChildren = layer->transform();
2397 transformForChildren *= parent_transform;
2398 CreateOrDestroyRenderSurface(
2399 layer, can_render_to_separate_surface, &transformForChildren);
2400
2401 for (size_t i = 0; i < layer->children().size(); ++i) {
2402 CreateRenderSurfaces(layer->children()[i].get(),
2403 can_render_to_separate_surface,
2404 transformForChildren);
2405 }
2406 }
2407
2386 void LayerTreeHostCommon::CalculateDrawProperties( 2408 void LayerTreeHostCommon::CalculateDrawProperties(
2387 CalcDrawPropsMainInputs* inputs) { 2409 CalcDrawPropsMainInputs* inputs) {
2410 CreateRenderSurfaces(inputs->root_layer,
2411 inputs->can_render_to_separate_surface,
2412 gfx::Transform());
2388 LayerList dummy_layer_list; 2413 LayerList dummy_layer_list;
2389 SubtreeGlobals<Layer> globals; 2414 SubtreeGlobals<Layer> globals;
2390 DataForRecursion<Layer> data_for_recursion; 2415 DataForRecursion<Layer> data_for_recursion;
2391 ProcessCalcDrawPropsInputs(*inputs, &globals, &data_for_recursion); 2416 ProcessCalcDrawPropsInputs(*inputs, &globals, &data_for_recursion);
2392 2417
2393 PreCalculateMetaInformationRecursiveData recursive_data; 2418 PreCalculateMetaInformationRecursiveData recursive_data;
2394 PreCalculateMetaInformation(inputs->root_layer, &recursive_data); 2419 PreCalculateMetaInformation(inputs->root_layer, &recursive_data);
2395 std::vector<AccumulatedSurfaceState<Layer> > accumulated_surface_state; 2420 std::vector<AccumulatedSurfaceState<Layer> > accumulated_surface_state;
2396 CalculateDrawPropertiesInternal<Layer>( 2421 CalculateDrawPropertiesInternal<Layer>(
2397 inputs->root_layer, 2422 inputs->root_layer,
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
2433 inputs->current_render_surface_layer_list_id); 2458 inputs->current_render_surface_layer_list_id);
2434 2459
2435 // The dummy layer list should not have been used. 2460 // The dummy layer list should not have been used.
2436 DCHECK_EQ(0u, dummy_layer_list.size()); 2461 DCHECK_EQ(0u, dummy_layer_list.size());
2437 // A root layer render_surface should always exist after 2462 // A root layer render_surface should always exist after
2438 // CalculateDrawProperties. 2463 // CalculateDrawProperties.
2439 DCHECK(inputs->root_layer->render_surface()); 2464 DCHECK(inputs->root_layer->render_surface());
2440 } 2465 }
2441 2466
2442 } // namespace cc 2467 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698