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

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 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 532 matching lines...) Expand 10 before | Expand all | Expand 10 after
543 543
544 static inline void SavePaintPropertiesLayer(Layer* layer) { 544 static inline void SavePaintPropertiesLayer(Layer* layer) {
545 layer->SavePaintProperties(); 545 layer->SavePaintProperties();
546 546
547 if (layer->mask_layer()) 547 if (layer->mask_layer())
548 layer->mask_layer()->SavePaintProperties(); 548 layer->mask_layer()->SavePaintProperties();
549 if (layer->replica_layer() && layer->replica_layer()->mask_layer()) 549 if (layer->replica_layer() && layer->replica_layer()->mask_layer())
550 layer->replica_layer()->mask_layer()->SavePaintProperties(); 550 layer->replica_layer()->mask_layer()->SavePaintProperties();
551 } 551 }
552 552
553 template <typename LayerType>
554 static bool SubtreeShouldRenderToSeparateSurface( 553 static bool SubtreeShouldRenderToSeparateSurface(
555 LayerType* layer, 554 Layer* layer, bool axis_aligned_with_respect_to_parent) {
556 bool axis_aligned_with_respect_to_parent) {
557 // 555 //
558 // A layer and its descendants should render onto a new RenderSurfaceImpl if 556 // A layer and its descendants should render onto a new RenderSurfaceImpl if
559 // any of these rules hold: 557 // any of these rules hold:
560 // 558 //
561 559
562 // The root layer owns a render surface, but it never acts as a contributing 560 // The root layer owns a render surface, but it never acts as a contributing
563 // surface to another render target. Compositor features that are applied via 561 // surface to another render target. Compositor features that are applied via
564 // a contributing surface can not be applied to the root layer. In order to 562 // a contributing surface can not be applied to the root layer. In order to
565 // use these effects, another child of the root would need to be introduced 563 // use these effects, another child of the root would need to be introduced
566 // in order to act as a contributing surface to the root layer's surface. 564 // in order to act as a contributing surface to the root layer's surface.
(...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after
1101 *combined_maximum_animation_contents_scale = 0.f; 1099 *combined_maximum_animation_contents_scale = 0.f;
1102 return; 1100 return;
1103 } 1101 }
1104 gfx::Vector2dF ancestor_transform_scales = 1102 gfx::Vector2dF ancestor_transform_scales =
1105 MathUtil::ComputeTransform2dScaleComponents(ancestor_transform, 0.f); 1103 MathUtil::ComputeTransform2dScaleComponents(ancestor_transform, 0.f);
1106 *combined_maximum_animation_contents_scale = 1104 *combined_maximum_animation_contents_scale =
1107 layer_maximum_animated_scale * 1105 layer_maximum_animated_scale *
1108 std::max(ancestor_transform_scales.x(), ancestor_transform_scales.y()); 1106 std::max(ancestor_transform_scales.x(), ancestor_transform_scales.y());
1109 } 1107 }
1110 1108
1111 template <typename LayerType>
1112 static inline typename LayerType::RenderSurfaceType* CreateOrReuseRenderSurface(
1113 LayerType* layer) {
1114 if (!layer->render_surface()) {
1115 layer->CreateRenderSurface();
1116 return layer->render_surface();
1117 }
1118
1119 layer->render_surface()->ClearLayerLists();
1120 return layer->render_surface();
1121 }
1122
1123 template <typename LayerTypePtr> 1109 template <typename LayerTypePtr>
1124 static inline void MarkLayerWithRenderSurfaceLayerListId( 1110 static inline void MarkLayerWithRenderSurfaceLayerListId(
1125 LayerTypePtr layer, 1111 LayerTypePtr layer,
1126 int current_render_surface_layer_list_id) { 1112 int current_render_surface_layer_list_id) {
1127 layer->draw_properties().last_drawn_render_surface_layer_list_id = 1113 layer->draw_properties().last_drawn_render_surface_layer_list_id =
1128 current_render_surface_layer_list_id; 1114 current_render_surface_layer_list_id;
1129 } 1115 }
1130 1116
1131 template <typename LayerTypePtr> 1117 template <typename LayerTypePtr>
1132 static inline void MarkMasksWithRenderSurfaceLayerListId( 1118 static inline void MarkMasksWithRenderSurfaceLayerListId(
(...skipping 683 matching lines...) Expand 10 before | Expand all | Expand 10 after
1816 data_from_ancestor.full_hierarchy_matrix; 1802 data_from_ancestor.full_hierarchy_matrix;
1817 1803
1818 // If the subtree will scale layer contents by the transform hierarchy, then 1804 // If the subtree will scale layer contents by the transform hierarchy, then
1819 // we should scale things into the render surface by the transform hierarchy 1805 // we should scale things into the render surface by the transform hierarchy
1820 // to take advantage of that. 1806 // to take advantage of that.
1821 gfx::Vector2dF render_surface_sublayer_scale = 1807 gfx::Vector2dF render_surface_sublayer_scale =
1822 globals.can_adjust_raster_scales 1808 globals.can_adjust_raster_scales
1823 ? combined_transform_scales 1809 ? combined_transform_scales
1824 : gfx::Vector2dF(layer_scale_factors, layer_scale_factors); 1810 : gfx::Vector2dF(layer_scale_factors, layer_scale_factors);
1825 1811
1826 bool render_to_separate_surface; 1812 bool render_to_separate_surface =
1827 if (globals.can_render_to_separate_surface) { 1813 IsRootLayer(layer) ||
1828 render_to_separate_surface = SubtreeShouldRenderToSeparateSurface( 1814 (globals.can_render_to_separate_surface && layer->render_surface());
1829 layer, combined_transform.Preserves2dAxisAlignment()); 1815
1830 } else {
1831 render_to_separate_surface = IsRootLayer(layer);
1832 }
1833 if (render_to_separate_surface) { 1816 if (render_to_separate_surface) {
1817 DCHECK(layer->render_surface());
1834 // Check back-face visibility before continuing with this surface and its 1818 // Check back-face visibility before continuing with this surface and its
1835 // subtree 1819 // subtree
1836 if (!layer->double_sided() && TransformToParentIsKnown(layer) && 1820 if (!layer->double_sided() && TransformToParentIsKnown(layer) &&
1837 IsSurfaceBackFaceVisible(layer, combined_transform)) { 1821 IsSurfaceBackFaceVisible(layer, combined_transform)) {
1838 layer->ClearRenderSurfaceLayerList(); 1822 layer->ClearRenderSurfaceLayerList();
1839 return; 1823 return;
1840 } 1824 }
1841 1825
1842 typename LayerType::RenderSurfaceType* render_surface = 1826 typename LayerType::RenderSurfaceType* render_surface =
1843 CreateOrReuseRenderSurface(layer); 1827 layer->render_surface();
1828 layer->ClearRenderSurfaceLayerList();
1844 1829
1830 layer_draw_properties.render_target = layer;
1845 if (IsRootLayer(layer)) { 1831 if (IsRootLayer(layer)) {
1846 // The root layer's render surface size is predetermined and so the root 1832 // The root layer's render surface size is predetermined and so the root
1847 // layer can't directly support non-identity transforms. It should just 1833 // layer can't directly support non-identity transforms. It should just
1848 // forward top-level transforms to the rest of the tree. 1834 // forward top-level transforms to the rest of the tree.
1849 data_for_children.parent_matrix = combined_transform; 1835 data_for_children.parent_matrix = combined_transform;
1850 1836
1851 // The root surface does not contribute to any other surface, it has no 1837 // The root surface does not contribute to any other surface, it has no
1852 // target. 1838 // target.
1853 layer->render_surface()->set_contributes_to_drawn_surface(false); 1839 layer->render_surface()->set_contributes_to_drawn_surface(false);
1854 } else { 1840 } else {
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
2014 animating_transform_to_target; 2000 animating_transform_to_target;
2015 layer_draw_properties.screen_space_transform_is_animating = 2001 layer_draw_properties.screen_space_transform_is_animating =
2016 animating_transform_to_screen; 2002 animating_transform_to_screen;
2017 layer_draw_properties.opacity = accumulated_draw_opacity; 2003 layer_draw_properties.opacity = accumulated_draw_opacity;
2018 layer_draw_properties.blend_mode = layer->blend_mode(); 2004 layer_draw_properties.blend_mode = layer->blend_mode();
2019 layer_draw_properties.opacity_is_animating = animating_opacity_to_target; 2005 layer_draw_properties.opacity_is_animating = animating_opacity_to_target;
2020 layer_draw_properties.screen_space_opacity_is_animating = 2006 layer_draw_properties.screen_space_opacity_is_animating =
2021 animating_opacity_to_screen; 2007 animating_opacity_to_screen;
2022 data_for_children.parent_matrix = combined_transform; 2008 data_for_children.parent_matrix = combined_transform;
2023 2009
2024 layer->ClearRenderSurface();
2025
2026 // Layers without render_surfaces directly inherit the ancestor's clip 2010 // Layers without render_surfaces directly inherit the ancestor's clip
2027 // status. 2011 // status.
2028 layer_or_ancestor_clips_descendants = ancestor_clips_subtree; 2012 layer_or_ancestor_clips_descendants = ancestor_clips_subtree;
2029 if (ancestor_clips_subtree) { 2013 if (ancestor_clips_subtree) {
2030 clip_rect_in_target_space = 2014 clip_rect_in_target_space =
2031 ancestor_clip_rect_in_target_space; 2015 ancestor_clip_rect_in_target_space;
2032 } 2016 }
2033 2017
2034 // The surface's cached clip rect value propagates regardless of what 2018 // The surface's cached clip rect value propagates regardless of what
2035 // clipping goes on between layers here. 2019 // clipping goes on between layers here.
2036 clip_rect_of_target_surface_in_target_space = 2020 clip_rect_of_target_surface_in_target_space =
2037 data_from_ancestor.clip_rect_of_target_surface_in_target_space; 2021 data_from_ancestor.clip_rect_of_target_surface_in_target_space;
2038 2022
2039 // Layers that are not their own render_target will render into the target 2023 // Layers that are not their own render_target will render into the target
2040 // of their nearest ancestor. 2024 // of their nearest ancestor.
2041 layer_draw_properties.render_target = layer->parent()->render_target(); 2025 layer_draw_properties.render_target = layer->parent()->render_target();
2042 } 2026 }
2043 2027
2044 if (adjust_text_aa) 2028 if (adjust_text_aa)
2045 layer_draw_properties.can_use_lcd_text = layer_can_use_lcd_text; 2029 layer_draw_properties.can_use_lcd_text = layer_can_use_lcd_text;
2046 2030
2047 gfx::Rect rect_in_target_space = 2031 gfx::Rect rect_in_target_space =
2048 MathUtil::MapEnclosingClippedRect(layer->draw_transform(), content_rect); 2032 MathUtil::MapEnclosingClippedRect(layer->draw_transform(), content_rect);
2049 2033
2050 if (LayerClipsSubtree(layer)) { 2034 if (LayerClipsSubtree(layer)) {
2051 layer_or_ancestor_clips_descendants = true; 2035 layer_or_ancestor_clips_descendants = true;
2052 if (ancestor_clips_subtree && !layer->render_surface()) { 2036 if (ancestor_clips_subtree && !render_to_separate_surface) {
2053 // A layer without render surface shares the same target as its ancestor. 2037 // A layer without render surface shares the same target as its ancestor.
2054 clip_rect_in_target_space = 2038 clip_rect_in_target_space =
2055 ancestor_clip_rect_in_target_space; 2039 ancestor_clip_rect_in_target_space;
2056 clip_rect_in_target_space.Intersect(rect_in_target_space); 2040 clip_rect_in_target_space.Intersect(rect_in_target_space);
2057 } else { 2041 } else {
2058 clip_rect_in_target_space = rect_in_target_space; 2042 clip_rect_in_target_space = rect_in_target_space;
2059 } 2043 }
2060 } 2044 }
2061 2045
2062 // Tell the layer the rect that it's clipped by. In theory we could use a 2046 // Tell the layer the rect that it's clipped by. In theory we could use a
2063 // tighter clip rect here (drawable_content_rect), but that actually does not 2047 // tighter clip rect here (drawable_content_rect), but that actually does not
2064 // reduce how much would be drawn, and instead it would create unnecessary 2048 // reduce how much would be drawn, and instead it would create unnecessary
2065 // changes to scissor state affecting GPU performance. Our clip information 2049 // changes to scissor state affecting GPU performance. Our clip information
2066 // is used in the recursion below, so we must set it beforehand. 2050 // is used in the recursion below, so we must set it beforehand.
2067 layer_draw_properties.is_clipped = layer_or_ancestor_clips_descendants; 2051 layer_draw_properties.is_clipped = layer_or_ancestor_clips_descendants;
2068 if (layer_or_ancestor_clips_descendants) { 2052 if (layer_or_ancestor_clips_descendants) {
2069 layer_draw_properties.clip_rect = clip_rect_in_target_space; 2053 layer_draw_properties.clip_rect = clip_rect_in_target_space;
2070 } else { 2054 } else {
2071 // Initialize the clip rect to a safe value that will not clip the 2055 // Initialize the clip rect to a safe value that will not clip the
2072 // layer, just in case clipping is still accidentally used. 2056 // layer, just in case clipping is still accidentally used.
2073 layer_draw_properties.clip_rect = rect_in_target_space; 2057 layer_draw_properties.clip_rect = rect_in_target_space;
2074 } 2058 }
2075 2059
2076 typename LayerType::LayerListType& descendants = 2060 typename LayerType::LayerListType& descendants =
2077 (layer->render_surface() ? layer->render_surface()->layer_list() 2061 (render_to_separate_surface ? layer->render_surface()->layer_list()
2078 : *layer_list); 2062 : *layer_list);
2079 2063
2080 // Any layers that are appended after this point are in the layer's subtree 2064 // Any layers that are appended after this point are in the layer's subtree
2081 // and should be included in the sorting process. 2065 // and should be included in the sorting process.
2082 size_t sorting_start_index = descendants.size(); 2066 size_t sorting_start_index = descendants.size();
2083 2067
2084 if (!LayerShouldBeSkipped(layer, layer_is_drawn)) { 2068 if (!LayerShouldBeSkipped(layer, layer_is_drawn)) {
2085 MarkLayerWithRenderSurfaceLayerListId(layer, 2069 MarkLayerWithRenderSurfaceLayerListId(layer,
2086 current_render_surface_layer_list_id); 2070 current_render_surface_layer_list_id);
2087 descendants.push_back(layer); 2071 descendants.push_back(layer);
2088 } 2072 }
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
2146 render_surface_layer_list->size(); 2130 render_surface_layer_list->size();
2147 2131
2148 CalculateDrawPropertiesInternal<LayerType>( 2132 CalculateDrawPropertiesInternal<LayerType>(
2149 child, 2133 child,
2150 globals, 2134 globals,
2151 data_for_children, 2135 data_for_children,
2152 render_surface_layer_list, 2136 render_surface_layer_list,
2153 &descendants, 2137 &descendants,
2154 accumulated_surface_state, 2138 accumulated_surface_state,
2155 current_render_surface_layer_list_id); 2139 current_render_surface_layer_list_id);
2156 if (child->render_surface() && 2140 // If the child is its own render target, then it has a render surface.
2141 if (child->render_target() == child &&
2157 !child->render_surface()->layer_list().empty() && 2142 !child->render_surface()->layer_list().empty() &&
2158 !child->render_surface()->content_rect().IsEmpty()) { 2143 !child->render_surface()->content_rect().IsEmpty()) {
2159 // This child will contribute its render surface, which means 2144 // This child will contribute its render surface, which means
2160 // we need to mark just the mask layer (and replica mask layer) 2145 // we need to mark just the mask layer (and replica mask layer)
2161 // with the id. 2146 // with the id.
2162 MarkMasksWithRenderSurfaceLayerListId( 2147 MarkMasksWithRenderSurfaceLayerListId(
2163 child, current_render_surface_layer_list_id); 2148 child, current_render_surface_layer_list_id);
2164 descendants.push_back(child); 2149 descendants.push_back(child);
2165 } 2150 }
2166 2151
(...skipping 18 matching lines...) Expand all
2185 *layer, 2170 *layer,
2186 &descendants, 2171 &descendants,
2187 layer_list_child_sorting_start_index, 2172 layer_list_child_sorting_start_index,
2188 &GetNewDescendantsStartIndexAndCount<LayerType>); 2173 &GetNewDescendantsStartIndexAndCount<LayerType>);
2189 } 2174 }
2190 2175
2191 // Compute the total drawable_content_rect for this subtree (the rect is in 2176 // Compute the total drawable_content_rect for this subtree (the rect is in
2192 // target surface space). 2177 // target surface space).
2193 gfx::Rect local_drawable_content_rect_of_subtree = 2178 gfx::Rect local_drawable_content_rect_of_subtree =
2194 accumulated_surface_state->back().drawable_content_rect; 2179 accumulated_surface_state->back().drawable_content_rect;
2195 if (layer->render_surface()) { 2180 if (render_to_separate_surface) {
2196 DCHECK(accumulated_surface_state->back().render_target == layer); 2181 DCHECK(accumulated_surface_state->back().render_target == layer);
2197 accumulated_surface_state->pop_back(); 2182 accumulated_surface_state->pop_back();
2198 } 2183 }
2199 2184
2200 if (layer->render_surface() && !IsRootLayer(layer) && 2185 if (render_to_separate_surface && !IsRootLayer(layer) &&
2201 layer->render_surface()->layer_list().empty()) { 2186 layer->render_surface()->layer_list().empty()) {
2202 RemoveSurfaceForEarlyExit(layer, render_surface_layer_list); 2187 RemoveSurfaceForEarlyExit(layer, render_surface_layer_list);
2203 return; 2188 return;
2204 } 2189 }
2205 2190
2206 // Compute the layer's drawable content rect (the rect is in target surface 2191 // Compute the layer's drawable content rect (the rect is in target surface
2207 // space). 2192 // space).
2208 layer_draw_properties.drawable_content_rect = rect_in_target_space; 2193 layer_draw_properties.drawable_content_rect = rect_in_target_space;
2209 if (layer_or_ancestor_clips_descendants) { 2194 if (layer_or_ancestor_clips_descendants) {
2210 layer_draw_properties.drawable_content_rect.Intersect( 2195 layer_draw_properties.drawable_content_rect.Intersect(
2211 clip_rect_in_target_space); 2196 clip_rect_in_target_space);
2212 } 2197 }
2213 if (layer->DrawsContent()) { 2198 if (layer->DrawsContent()) {
2214 local_drawable_content_rect_of_subtree.Union( 2199 local_drawable_content_rect_of_subtree.Union(
2215 layer_draw_properties.drawable_content_rect); 2200 layer_draw_properties.drawable_content_rect);
2216 } 2201 }
2217 2202
2218 // Compute the layer's visible content rect (the rect is in content space). 2203 // Compute the layer's visible content rect (the rect is in content space).
2219 layer_draw_properties.visible_content_rect = CalculateVisibleContentRect( 2204 layer_draw_properties.visible_content_rect = CalculateVisibleContentRect(
2220 layer, clip_rect_of_target_surface_in_target_space, rect_in_target_space); 2205 layer, clip_rect_of_target_surface_in_target_space, rect_in_target_space);
2221 2206
2222 // Compute the remaining properties for the render surface, if the layer has 2207 // Compute the remaining properties for the render surface, if the layer has
2223 // one. 2208 // one.
2224 if (IsRootLayer(layer)) { 2209 if (IsRootLayer(layer)) {
2225 // The root layer's surface's content_rect is always the entire viewport. 2210 // The root layer's surface's content_rect is always the entire viewport.
2226 DCHECK(layer->render_surface()); 2211 DCHECK(render_to_separate_surface);
2227 layer->render_surface()->SetContentRect( 2212 layer->render_surface()->SetContentRect(
2228 ancestor_clip_rect_in_target_space); 2213 ancestor_clip_rect_in_target_space);
2229 } else if (layer->render_surface()) { 2214 } else if (render_to_separate_surface) {
2230 typename LayerType::RenderSurfaceType* render_surface = 2215 typename LayerType::RenderSurfaceType* render_surface =
2231 layer->render_surface(); 2216 layer->render_surface();
2232 gfx::Rect clipped_content_rect = local_drawable_content_rect_of_subtree; 2217 gfx::Rect clipped_content_rect = local_drawable_content_rect_of_subtree;
2233 2218
2234 // Don't clip if the layer is reflected as the reflection shouldn't be 2219 // Don't clip if the layer is reflected as the reflection shouldn't be
2235 // clipped. If the layer is animating, then the surface's transform to 2220 // clipped. If the layer is animating, then the surface's transform to
2236 // its target is not known on the main thread, and we should not use it 2221 // its target is not known on the main thread, and we should not use it
2237 // to clip. 2222 // to clip.
2238 if (!layer->replica_layer() && TransformToParentIsKnown(layer)) { 2223 if (!layer->replica_layer() && TransformToParentIsKnown(layer)) {
2239 // Note, it is correct to use data_from_ancestor.ancestor_clips_subtree 2224 // Note, it is correct to use data_from_ancestor.ancestor_clips_subtree
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
2313 surface_origin_to_replica_origin_transform; 2298 surface_origin_to_replica_origin_transform;
2314 render_surface->SetReplicaScreenSpaceTransform( 2299 render_surface->SetReplicaScreenSpaceTransform(
2315 replica_screen_space_transform); 2300 replica_screen_space_transform);
2316 } 2301 }
2317 } 2302 }
2318 2303
2319 SavePaintPropertiesLayer(layer); 2304 SavePaintPropertiesLayer(layer);
2320 2305
2321 // If neither this layer nor any of its children were added, early out. 2306 // If neither this layer nor any of its children were added, early out.
2322 if (sorting_start_index == descendants.size()) { 2307 if (sorting_start_index == descendants.size()) {
2323 DCHECK(!layer->render_surface() || IsRootLayer(layer)); 2308 DCHECK(!render_to_separate_surface || IsRootLayer(layer));
2324 return; 2309 return;
2325 } 2310 }
2326 2311
2327 // If preserves-3d then sort all the descendants in 3D so that they can be 2312 // If preserves-3d then sort all the descendants in 3D so that they can be
2328 // drawn from back to front. If the preserves-3d property is also set on the 2313 // drawn from back to front. If the preserves-3d property is also set on the
2329 // parent then skip the sorting as the parent will sort all the descendants 2314 // parent then skip the sorting as the parent will sort all the descendants
2330 // anyway. 2315 // anyway.
2331 if (globals.layer_sorter && descendants.size() && layer->Is3dSorted() && 2316 if (globals.layer_sorter && descendants.size() && layer->Is3dSorted() &&
2332 !LayerIsInExisting3DRenderingContext(layer)) { 2317 !LayerIsInExisting3DRenderingContext(layer)) {
2333 SortLayers(descendants.begin() + sorting_start_index, 2318 SortLayers(descendants.begin() + sorting_start_index,
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
2393 device_viewport_rect; 2378 device_viewport_rect;
2394 data_for_recursion->maximum_animation_contents_scale = 0.f; 2379 data_for_recursion->maximum_animation_contents_scale = 0.f;
2395 data_for_recursion->ancestor_is_animating_scale = false; 2380 data_for_recursion->ancestor_is_animating_scale = false;
2396 data_for_recursion->ancestor_clips_subtree = true; 2381 data_for_recursion->ancestor_clips_subtree = true;
2397 data_for_recursion->nearest_occlusion_immune_ancestor_surface = NULL; 2382 data_for_recursion->nearest_occlusion_immune_ancestor_surface = NULL;
2398 data_for_recursion->in_subtree_of_page_scale_application_layer = false; 2383 data_for_recursion->in_subtree_of_page_scale_application_layer = false;
2399 data_for_recursion->subtree_can_use_lcd_text = inputs.can_use_lcd_text; 2384 data_for_recursion->subtree_can_use_lcd_text = inputs.can_use_lcd_text;
2400 data_for_recursion->subtree_is_visible_from_ancestor = true; 2385 data_for_recursion->subtree_is_visible_from_ancestor = true;
2401 } 2386 }
2402 2387
2388 void LayerTreeHostCommon::UpdateRenderSurface(
2389 Layer* layer, bool can_render_to_separate_surface,
2390 gfx::Transform* transform, bool* draw_transform_is_axis_aligned) {
2391 bool preserves_2d_axis_alignment =
2392 transform->Preserves2dAxisAlignment() && *draw_transform_is_axis_aligned;
2393 if (IsRootLayer(layer) || (can_render_to_separate_surface &&
2394 SubtreeShouldRenderToSeparateSurface(
2395 layer, preserves_2d_axis_alignment))) {
2396 // We reset the transform here so that any axis-changing transforms
2397 // will now be relative to this RenderSurface.
2398 transform->MakeIdentity();
2399 *draw_transform_is_axis_aligned = true;
2400 if (!layer->render_surface()) {
2401 layer->CreateRenderSurface();
2402 }
2403 layer->SetHasRenderSurface(true);
2404 return;
2405 }
2406 layer->SetHasRenderSurface(false);
2407 if (layer->render_surface()) layer->ClearRenderSurface();
2408 }
2409
2410 void LayerTreeHostCommon::UpdateRenderSurfaces(
2411 Layer* layer, bool can_render_to_separate_surface,
2412 const gfx::Transform& parent_transform,
2413 bool draw_transform_is_axis_aligned) {
2414 gfx::Transform transform_for_children = layer->transform();
2415 transform_for_children *= parent_transform;
2416 draw_transform_is_axis_aligned &= layer->AnimationsPreserveAxisAlignment();
2417 UpdateRenderSurface(layer, can_render_to_separate_surface,
2418 &transform_for_children, &draw_transform_is_axis_aligned);
2419
2420 for (size_t i = 0; i < layer->children().size(); ++i) {
2421 UpdateRenderSurfaces(layer->children()[i].get(),
2422 can_render_to_separate_surface, transform_for_children,
2423 draw_transform_is_axis_aligned);
2424 }
2425 }
2426
2403 void LayerTreeHostCommon::CalculateDrawProperties( 2427 void LayerTreeHostCommon::CalculateDrawProperties(
2404 CalcDrawPropsMainInputs* inputs) { 2428 CalcDrawPropsMainInputs* inputs) {
2429 UpdateRenderSurfaces(inputs->root_layer,
2430 inputs->can_render_to_separate_surface, gfx::Transform(),
2431 false);
2405 LayerList dummy_layer_list; 2432 LayerList dummy_layer_list;
2406 SubtreeGlobals<Layer> globals; 2433 SubtreeGlobals<Layer> globals;
2407 DataForRecursion<Layer> data_for_recursion; 2434 DataForRecursion<Layer> data_for_recursion;
2408 ProcessCalcDrawPropsInputs(*inputs, &globals, &data_for_recursion); 2435 ProcessCalcDrawPropsInputs(*inputs, &globals, &data_for_recursion);
2409 2436
2410 PreCalculateMetaInformationRecursiveData recursive_data; 2437 PreCalculateMetaInformationRecursiveData recursive_data;
2411 PreCalculateMetaInformation(inputs->root_layer, &recursive_data); 2438 PreCalculateMetaInformation(inputs->root_layer, &recursive_data);
2412 std::vector<AccumulatedSurfaceState<Layer>> accumulated_surface_state; 2439 std::vector<AccumulatedSurfaceState<Layer>> accumulated_surface_state;
2413 CalculateDrawPropertiesInternal<Layer>( 2440 CalculateDrawPropertiesInternal<Layer>(
2414 inputs->root_layer, 2441 inputs->root_layer,
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
2449 inputs->current_render_surface_layer_list_id); 2476 inputs->current_render_surface_layer_list_id);
2450 2477
2451 // The dummy layer list should not have been used. 2478 // The dummy layer list should not have been used.
2452 DCHECK_EQ(0u, dummy_layer_list.size()); 2479 DCHECK_EQ(0u, dummy_layer_list.size());
2453 // A root layer render_surface should always exist after 2480 // A root layer render_surface should always exist after
2454 // CalculateDrawProperties. 2481 // CalculateDrawProperties.
2455 DCHECK(inputs->root_layer->render_surface()); 2482 DCHECK(inputs->root_layer->render_surface());
2456 } 2483 }
2457 2484
2458 } // namespace cc 2485 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698