OLD | NEW |
---|---|
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 Loading... | |
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, |
556 bool axis_aligned_with_respect_to_parent) { | 555 bool axis_aligned_with_respect_to_parent) { |
557 // | 556 // |
558 // A layer and its descendants should render onto a new RenderSurfaceImpl if | 557 // A layer and its descendants should render onto a new RenderSurfaceImpl if |
559 // any of these rules hold: | 558 // any of these rules hold: |
560 // | 559 // |
561 | 560 |
562 // The root layer owns a render surface, but it never acts as a contributing | 561 // 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 | 562 // 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 | 563 // 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 | 564 // 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 Loading... | |
1101 *combined_maximum_animation_contents_scale = 0.f; | 1100 *combined_maximum_animation_contents_scale = 0.f; |
1102 return; | 1101 return; |
1103 } | 1102 } |
1104 gfx::Vector2dF ancestor_transform_scales = | 1103 gfx::Vector2dF ancestor_transform_scales = |
1105 MathUtil::ComputeTransform2dScaleComponents(ancestor_transform, 0.f); | 1104 MathUtil::ComputeTransform2dScaleComponents(ancestor_transform, 0.f); |
1106 *combined_maximum_animation_contents_scale = | 1105 *combined_maximum_animation_contents_scale = |
1107 layer_maximum_animated_scale * | 1106 layer_maximum_animated_scale * |
1108 std::max(ancestor_transform_scales.x(), ancestor_transform_scales.y()); | 1107 std::max(ancestor_transform_scales.x(), ancestor_transform_scales.y()); |
1109 } | 1108 } |
1110 | 1109 |
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> | 1110 template <typename LayerTypePtr> |
1124 static inline void MarkLayerWithRenderSurfaceLayerListId( | 1111 static inline void MarkLayerWithRenderSurfaceLayerListId( |
1125 LayerTypePtr layer, | 1112 LayerTypePtr layer, |
1126 int current_render_surface_layer_list_id) { | 1113 int current_render_surface_layer_list_id) { |
1127 layer->draw_properties().last_drawn_render_surface_layer_list_id = | 1114 layer->draw_properties().last_drawn_render_surface_layer_list_id = |
1128 current_render_surface_layer_list_id; | 1115 current_render_surface_layer_list_id; |
1129 } | 1116 } |
1130 | 1117 |
1131 template <typename LayerTypePtr> | 1118 template <typename LayerTypePtr> |
1132 static inline void MarkMasksWithRenderSurfaceLayerListId( | 1119 static inline void MarkMasksWithRenderSurfaceLayerListId( |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1196 void Merge(const PreCalculateMetaInformationRecursiveData& data) { | 1183 void Merge(const PreCalculateMetaInformationRecursiveData& data) { |
1197 layer_or_descendant_has_copy_request |= | 1184 layer_or_descendant_has_copy_request |= |
1198 data.layer_or_descendant_has_copy_request; | 1185 data.layer_or_descendant_has_copy_request; |
1199 layer_or_descendant_has_input_handler |= | 1186 layer_or_descendant_has_input_handler |= |
1200 data.layer_or_descendant_has_input_handler; | 1187 data.layer_or_descendant_has_input_handler; |
1201 num_unclipped_descendants += | 1188 num_unclipped_descendants += |
1202 data.num_unclipped_descendants; | 1189 data.num_unclipped_descendants; |
1203 } | 1190 } |
1204 }; | 1191 }; |
1205 | 1192 |
1193 static bool ValidateLayer(LayerImpl* layer) { | |
enne (OOO)
2014/12/16 19:08:48
What about calling this ValidateRenderSurface? Als
awoloszyn
2014/12/16 21:54:29
Done.
| |
1194 return (layer->render_surface() || (layer->filters().IsEmpty() && | |
1195 layer->background_filters().IsEmpty())); | |
1196 } | |
1197 | |
1198 static bool ValidateLayer(Layer* layer) { | |
1199 return true; | |
1200 } | |
1201 | |
1206 // Recursively walks the layer tree to compute any information that is needed | 1202 // Recursively walks the layer tree to compute any information that is needed |
1207 // before doing the main recursion. | 1203 // before doing the main recursion. |
1208 template <typename LayerType> | 1204 template <typename LayerType> |
1209 static void PreCalculateMetaInformation( | 1205 static void PreCalculateMetaInformation( |
1210 LayerType* layer, | 1206 LayerType* layer, |
1211 PreCalculateMetaInformationRecursiveData* recursive_data) { | 1207 PreCalculateMetaInformationRecursiveData* recursive_data) { |
1208 DCHECK(ValidateLayer(layer)); | |
1212 | 1209 |
1213 layer->draw_properties().sorted_for_recursion = false; | 1210 layer->draw_properties().sorted_for_recursion = false; |
1214 layer->draw_properties().has_child_with_a_scroll_parent = false; | 1211 layer->draw_properties().has_child_with_a_scroll_parent = false; |
1215 | 1212 |
1216 if (!HasInvertibleOrAnimatedTransform(layer)) { | 1213 if (!HasInvertibleOrAnimatedTransform(layer)) { |
1217 // Layers with singular transforms should not be drawn, the whole subtree | 1214 // Layers with singular transforms should not be drawn, the whole subtree |
1218 // can be skipped. | 1215 // can be skipped. |
1219 return; | 1216 return; |
1220 } | 1217 } |
1221 | 1218 |
(...skipping 594 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1816 data_from_ancestor.full_hierarchy_matrix; | 1813 data_from_ancestor.full_hierarchy_matrix; |
1817 | 1814 |
1818 // If the subtree will scale layer contents by the transform hierarchy, then | 1815 // 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 | 1816 // we should scale things into the render surface by the transform hierarchy |
1820 // to take advantage of that. | 1817 // to take advantage of that. |
1821 gfx::Vector2dF render_surface_sublayer_scale = | 1818 gfx::Vector2dF render_surface_sublayer_scale = |
1822 globals.can_adjust_raster_scales | 1819 globals.can_adjust_raster_scales |
1823 ? combined_transform_scales | 1820 ? combined_transform_scales |
1824 : gfx::Vector2dF(layer_scale_factors, layer_scale_factors); | 1821 : gfx::Vector2dF(layer_scale_factors, layer_scale_factors); |
1825 | 1822 |
1826 bool render_to_separate_surface; | 1823 bool render_to_separate_surface = |
1827 if (globals.can_render_to_separate_surface) { | 1824 IsRootLayer(layer) || |
1828 render_to_separate_surface = SubtreeShouldRenderToSeparateSurface( | 1825 (globals.can_render_to_separate_surface && layer->render_surface()); |
1829 layer, combined_transform.Preserves2dAxisAlignment()); | 1826 |
1830 } else { | |
1831 render_to_separate_surface = IsRootLayer(layer); | |
1832 } | |
1833 if (render_to_separate_surface) { | 1827 if (render_to_separate_surface) { |
1828 DCHECK(layer->render_surface()); | |
1834 // Check back-face visibility before continuing with this surface and its | 1829 // Check back-face visibility before continuing with this surface and its |
1835 // subtree | 1830 // subtree |
1836 if (!layer->double_sided() && TransformToParentIsKnown(layer) && | 1831 if (!layer->double_sided() && TransformToParentIsKnown(layer) && |
1837 IsSurfaceBackFaceVisible(layer, combined_transform)) { | 1832 IsSurfaceBackFaceVisible(layer, combined_transform)) { |
1838 layer->ClearRenderSurfaceLayerList(); | 1833 layer->ClearRenderSurfaceLayerList(); |
1839 return; | 1834 return; |
1840 } | 1835 } |
1841 | 1836 |
1842 typename LayerType::RenderSurfaceType* render_surface = | 1837 typename LayerType::RenderSurfaceType* render_surface = |
1843 CreateOrReuseRenderSurface(layer); | 1838 layer->render_surface(); |
1839 layer->ClearRenderSurfaceLayerList(); | |
1844 | 1840 |
1841 layer_draw_properties.render_target = layer; | |
1845 if (IsRootLayer(layer)) { | 1842 if (IsRootLayer(layer)) { |
1846 // The root layer's render surface size is predetermined and so the root | 1843 // 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 | 1844 // layer can't directly support non-identity transforms. It should just |
1848 // forward top-level transforms to the rest of the tree. | 1845 // forward top-level transforms to the rest of the tree. |
1849 data_for_children.parent_matrix = combined_transform; | 1846 data_for_children.parent_matrix = combined_transform; |
1850 | 1847 |
1851 // The root surface does not contribute to any other surface, it has no | 1848 // The root surface does not contribute to any other surface, it has no |
1852 // target. | 1849 // target. |
1853 layer->render_surface()->set_contributes_to_drawn_surface(false); | 1850 layer->render_surface()->set_contributes_to_drawn_surface(false); |
1854 } else { | 1851 } else { |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2014 animating_transform_to_target; | 2011 animating_transform_to_target; |
2015 layer_draw_properties.screen_space_transform_is_animating = | 2012 layer_draw_properties.screen_space_transform_is_animating = |
2016 animating_transform_to_screen; | 2013 animating_transform_to_screen; |
2017 layer_draw_properties.opacity = accumulated_draw_opacity; | 2014 layer_draw_properties.opacity = accumulated_draw_opacity; |
2018 layer_draw_properties.blend_mode = layer->blend_mode(); | 2015 layer_draw_properties.blend_mode = layer->blend_mode(); |
2019 layer_draw_properties.opacity_is_animating = animating_opacity_to_target; | 2016 layer_draw_properties.opacity_is_animating = animating_opacity_to_target; |
2020 layer_draw_properties.screen_space_opacity_is_animating = | 2017 layer_draw_properties.screen_space_opacity_is_animating = |
2021 animating_opacity_to_screen; | 2018 animating_opacity_to_screen; |
2022 data_for_children.parent_matrix = combined_transform; | 2019 data_for_children.parent_matrix = combined_transform; |
2023 | 2020 |
2024 layer->ClearRenderSurface(); | |
2025 | |
2026 // Layers without render_surfaces directly inherit the ancestor's clip | 2021 // Layers without render_surfaces directly inherit the ancestor's clip |
2027 // status. | 2022 // status. |
2028 layer_or_ancestor_clips_descendants = ancestor_clips_subtree; | 2023 layer_or_ancestor_clips_descendants = ancestor_clips_subtree; |
2029 if (ancestor_clips_subtree) { | 2024 if (ancestor_clips_subtree) { |
2030 clip_rect_in_target_space = | 2025 clip_rect_in_target_space = |
2031 ancestor_clip_rect_in_target_space; | 2026 ancestor_clip_rect_in_target_space; |
2032 } | 2027 } |
2033 | 2028 |
2034 // The surface's cached clip rect value propagates regardless of what | 2029 // The surface's cached clip rect value propagates regardless of what |
2035 // clipping goes on between layers here. | 2030 // clipping goes on between layers here. |
2036 clip_rect_of_target_surface_in_target_space = | 2031 clip_rect_of_target_surface_in_target_space = |
2037 data_from_ancestor.clip_rect_of_target_surface_in_target_space; | 2032 data_from_ancestor.clip_rect_of_target_surface_in_target_space; |
2038 | 2033 |
2039 // Layers that are not their own render_target will render into the target | 2034 // Layers that are not their own render_target will render into the target |
2040 // of their nearest ancestor. | 2035 // of their nearest ancestor. |
2041 layer_draw_properties.render_target = layer->parent()->render_target(); | 2036 layer_draw_properties.render_target = layer->parent()->render_target(); |
2042 } | 2037 } |
2043 | 2038 |
2044 if (adjust_text_aa) | 2039 if (adjust_text_aa) |
2045 layer_draw_properties.can_use_lcd_text = layer_can_use_lcd_text; | 2040 layer_draw_properties.can_use_lcd_text = layer_can_use_lcd_text; |
2046 | 2041 |
2047 gfx::Rect rect_in_target_space = | 2042 gfx::Rect rect_in_target_space = |
2048 MathUtil::MapEnclosingClippedRect(layer->draw_transform(), content_rect); | 2043 MathUtil::MapEnclosingClippedRect(layer->draw_transform(), content_rect); |
2049 | 2044 |
2050 if (LayerClipsSubtree(layer)) { | 2045 if (LayerClipsSubtree(layer)) { |
2051 layer_or_ancestor_clips_descendants = true; | 2046 layer_or_ancestor_clips_descendants = true; |
2052 if (ancestor_clips_subtree && !layer->render_surface()) { | 2047 if (ancestor_clips_subtree && !render_to_separate_surface) { |
2053 // A layer without render surface shares the same target as its ancestor. | 2048 // A layer without render surface shares the same target as its ancestor. |
2054 clip_rect_in_target_space = | 2049 clip_rect_in_target_space = |
2055 ancestor_clip_rect_in_target_space; | 2050 ancestor_clip_rect_in_target_space; |
2056 clip_rect_in_target_space.Intersect(rect_in_target_space); | 2051 clip_rect_in_target_space.Intersect(rect_in_target_space); |
2057 } else { | 2052 } else { |
2058 clip_rect_in_target_space = rect_in_target_space; | 2053 clip_rect_in_target_space = rect_in_target_space; |
2059 } | 2054 } |
2060 } | 2055 } |
2061 | 2056 |
2062 // Tell the layer the rect that it's clipped by. In theory we could use a | 2057 // 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 | 2058 // 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 | 2059 // reduce how much would be drawn, and instead it would create unnecessary |
2065 // changes to scissor state affecting GPU performance. Our clip information | 2060 // changes to scissor state affecting GPU performance. Our clip information |
2066 // is used in the recursion below, so we must set it beforehand. | 2061 // is used in the recursion below, so we must set it beforehand. |
2067 layer_draw_properties.is_clipped = layer_or_ancestor_clips_descendants; | 2062 layer_draw_properties.is_clipped = layer_or_ancestor_clips_descendants; |
2068 if (layer_or_ancestor_clips_descendants) { | 2063 if (layer_or_ancestor_clips_descendants) { |
2069 layer_draw_properties.clip_rect = clip_rect_in_target_space; | 2064 layer_draw_properties.clip_rect = clip_rect_in_target_space; |
2070 } else { | 2065 } else { |
2071 // Initialize the clip rect to a safe value that will not clip the | 2066 // Initialize the clip rect to a safe value that will not clip the |
2072 // layer, just in case clipping is still accidentally used. | 2067 // layer, just in case clipping is still accidentally used. |
2073 layer_draw_properties.clip_rect = rect_in_target_space; | 2068 layer_draw_properties.clip_rect = rect_in_target_space; |
2074 } | 2069 } |
2075 | 2070 |
2076 typename LayerType::LayerListType& descendants = | 2071 typename LayerType::LayerListType& descendants = |
2077 (layer->render_surface() ? layer->render_surface()->layer_list() | 2072 (render_to_separate_surface ? layer->render_surface()->layer_list() |
2078 : *layer_list); | 2073 : *layer_list); |
2079 | 2074 |
2080 // Any layers that are appended after this point are in the layer's subtree | 2075 // Any layers that are appended after this point are in the layer's subtree |
2081 // and should be included in the sorting process. | 2076 // and should be included in the sorting process. |
2082 size_t sorting_start_index = descendants.size(); | 2077 size_t sorting_start_index = descendants.size(); |
2083 | 2078 |
2084 if (!LayerShouldBeSkipped(layer, layer_is_drawn)) { | 2079 if (!LayerShouldBeSkipped(layer, layer_is_drawn)) { |
2085 MarkLayerWithRenderSurfaceLayerListId(layer, | 2080 MarkLayerWithRenderSurfaceLayerListId(layer, |
2086 current_render_surface_layer_list_id); | 2081 current_render_surface_layer_list_id); |
2087 descendants.push_back(layer); | 2082 descendants.push_back(layer); |
2088 } | 2083 } |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2146 render_surface_layer_list->size(); | 2141 render_surface_layer_list->size(); |
2147 | 2142 |
2148 CalculateDrawPropertiesInternal<LayerType>( | 2143 CalculateDrawPropertiesInternal<LayerType>( |
2149 child, | 2144 child, |
2150 globals, | 2145 globals, |
2151 data_for_children, | 2146 data_for_children, |
2152 render_surface_layer_list, | 2147 render_surface_layer_list, |
2153 &descendants, | 2148 &descendants, |
2154 accumulated_surface_state, | 2149 accumulated_surface_state, |
2155 current_render_surface_layer_list_id); | 2150 current_render_surface_layer_list_id); |
2156 if (child->render_surface() && | 2151 // If the child is its own render target, then it has a render surface. |
2152 if (child->render_target() == child && | |
2157 !child->render_surface()->layer_list().empty() && | 2153 !child->render_surface()->layer_list().empty() && |
2158 !child->render_surface()->content_rect().IsEmpty()) { | 2154 !child->render_surface()->content_rect().IsEmpty()) { |
2159 // This child will contribute its render surface, which means | 2155 // This child will contribute its render surface, which means |
2160 // we need to mark just the mask layer (and replica mask layer) | 2156 // we need to mark just the mask layer (and replica mask layer) |
2161 // with the id. | 2157 // with the id. |
2162 MarkMasksWithRenderSurfaceLayerListId( | 2158 MarkMasksWithRenderSurfaceLayerListId( |
2163 child, current_render_surface_layer_list_id); | 2159 child, current_render_surface_layer_list_id); |
2164 descendants.push_back(child); | 2160 descendants.push_back(child); |
2165 } | 2161 } |
2166 | 2162 |
(...skipping 18 matching lines...) Expand all Loading... | |
2185 *layer, | 2181 *layer, |
2186 &descendants, | 2182 &descendants, |
2187 layer_list_child_sorting_start_index, | 2183 layer_list_child_sorting_start_index, |
2188 &GetNewDescendantsStartIndexAndCount<LayerType>); | 2184 &GetNewDescendantsStartIndexAndCount<LayerType>); |
2189 } | 2185 } |
2190 | 2186 |
2191 // Compute the total drawable_content_rect for this subtree (the rect is in | 2187 // Compute the total drawable_content_rect for this subtree (the rect is in |
2192 // target surface space). | 2188 // target surface space). |
2193 gfx::Rect local_drawable_content_rect_of_subtree = | 2189 gfx::Rect local_drawable_content_rect_of_subtree = |
2194 accumulated_surface_state->back().drawable_content_rect; | 2190 accumulated_surface_state->back().drawable_content_rect; |
2195 if (layer->render_surface()) { | 2191 if (render_to_separate_surface) { |
2196 DCHECK(accumulated_surface_state->back().render_target == layer); | 2192 DCHECK(accumulated_surface_state->back().render_target == layer); |
2197 accumulated_surface_state->pop_back(); | 2193 accumulated_surface_state->pop_back(); |
2198 } | 2194 } |
2199 | 2195 |
2200 if (layer->render_surface() && !IsRootLayer(layer) && | 2196 if (render_to_separate_surface && !IsRootLayer(layer) && |
2201 layer->render_surface()->layer_list().empty()) { | 2197 layer->render_surface()->layer_list().empty()) { |
2202 RemoveSurfaceForEarlyExit(layer, render_surface_layer_list); | 2198 RemoveSurfaceForEarlyExit(layer, render_surface_layer_list); |
2203 return; | 2199 return; |
2204 } | 2200 } |
2205 | 2201 |
2206 // Compute the layer's drawable content rect (the rect is in target surface | 2202 // Compute the layer's drawable content rect (the rect is in target surface |
2207 // space). | 2203 // space). |
2208 layer_draw_properties.drawable_content_rect = rect_in_target_space; | 2204 layer_draw_properties.drawable_content_rect = rect_in_target_space; |
2209 if (layer_or_ancestor_clips_descendants) { | 2205 if (layer_or_ancestor_clips_descendants) { |
2210 layer_draw_properties.drawable_content_rect.Intersect( | 2206 layer_draw_properties.drawable_content_rect.Intersect( |
2211 clip_rect_in_target_space); | 2207 clip_rect_in_target_space); |
2212 } | 2208 } |
2213 if (layer->DrawsContent()) { | 2209 if (layer->DrawsContent()) { |
2214 local_drawable_content_rect_of_subtree.Union( | 2210 local_drawable_content_rect_of_subtree.Union( |
2215 layer_draw_properties.drawable_content_rect); | 2211 layer_draw_properties.drawable_content_rect); |
2216 } | 2212 } |
2217 | 2213 |
2218 // Compute the layer's visible content rect (the rect is in content space). | 2214 // Compute the layer's visible content rect (the rect is in content space). |
2219 layer_draw_properties.visible_content_rect = CalculateVisibleContentRect( | 2215 layer_draw_properties.visible_content_rect = CalculateVisibleContentRect( |
2220 layer, clip_rect_of_target_surface_in_target_space, rect_in_target_space); | 2216 layer, clip_rect_of_target_surface_in_target_space, rect_in_target_space); |
2221 | 2217 |
2222 // Compute the remaining properties for the render surface, if the layer has | 2218 // Compute the remaining properties for the render surface, if the layer has |
2223 // one. | 2219 // one. |
2224 if (IsRootLayer(layer)) { | 2220 if (IsRootLayer(layer)) { |
2225 // The root layer's surface's content_rect is always the entire viewport. | 2221 // The root layer's surface's content_rect is always the entire viewport. |
2226 DCHECK(layer->render_surface()); | 2222 DCHECK(render_to_separate_surface); |
2227 layer->render_surface()->SetContentRect( | 2223 layer->render_surface()->SetContentRect( |
2228 ancestor_clip_rect_in_target_space); | 2224 ancestor_clip_rect_in_target_space); |
2229 } else if (layer->render_surface()) { | 2225 } else if (render_to_separate_surface) { |
2230 typename LayerType::RenderSurfaceType* render_surface = | 2226 typename LayerType::RenderSurfaceType* render_surface = |
2231 layer->render_surface(); | 2227 layer->render_surface(); |
2232 gfx::Rect clipped_content_rect = local_drawable_content_rect_of_subtree; | 2228 gfx::Rect clipped_content_rect = local_drawable_content_rect_of_subtree; |
2233 | 2229 |
2234 // Don't clip if the layer is reflected as the reflection shouldn't be | 2230 // 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 | 2231 // 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 | 2232 // its target is not known on the main thread, and we should not use it |
2237 // to clip. | 2233 // to clip. |
2238 if (!layer->replica_layer() && TransformToParentIsKnown(layer)) { | 2234 if (!layer->replica_layer() && TransformToParentIsKnown(layer)) { |
2239 // Note, it is correct to use data_from_ancestor.ancestor_clips_subtree | 2235 // Note, it is correct to use data_from_ancestor.ancestor_clips_subtree |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2313 surface_origin_to_replica_origin_transform; | 2309 surface_origin_to_replica_origin_transform; |
2314 render_surface->SetReplicaScreenSpaceTransform( | 2310 render_surface->SetReplicaScreenSpaceTransform( |
2315 replica_screen_space_transform); | 2311 replica_screen_space_transform); |
2316 } | 2312 } |
2317 } | 2313 } |
2318 | 2314 |
2319 SavePaintPropertiesLayer(layer); | 2315 SavePaintPropertiesLayer(layer); |
2320 | 2316 |
2321 // If neither this layer nor any of its children were added, early out. | 2317 // If neither this layer nor any of its children were added, early out. |
2322 if (sorting_start_index == descendants.size()) { | 2318 if (sorting_start_index == descendants.size()) { |
2323 DCHECK(!layer->render_surface() || IsRootLayer(layer)); | 2319 DCHECK(!render_to_separate_surface || IsRootLayer(layer)); |
2324 return; | 2320 return; |
2325 } | 2321 } |
2326 | 2322 |
2327 // If preserves-3d then sort all the descendants in 3D so that they can be | 2323 // 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 | 2324 // 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 | 2325 // parent then skip the sorting as the parent will sort all the descendants |
2330 // anyway. | 2326 // anyway. |
2331 if (globals.layer_sorter && descendants.size() && layer->Is3dSorted() && | 2327 if (globals.layer_sorter && descendants.size() && layer->Is3dSorted() && |
2332 !LayerIsInExisting3DRenderingContext(layer)) { | 2328 !LayerIsInExisting3DRenderingContext(layer)) { |
2333 SortLayers(descendants.begin() + sorting_start_index, | 2329 SortLayers(descendants.begin() + sorting_start_index, |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2393 device_viewport_rect; | 2389 device_viewport_rect; |
2394 data_for_recursion->maximum_animation_contents_scale = 0.f; | 2390 data_for_recursion->maximum_animation_contents_scale = 0.f; |
2395 data_for_recursion->ancestor_is_animating_scale = false; | 2391 data_for_recursion->ancestor_is_animating_scale = false; |
2396 data_for_recursion->ancestor_clips_subtree = true; | 2392 data_for_recursion->ancestor_clips_subtree = true; |
2397 data_for_recursion->nearest_occlusion_immune_ancestor_surface = NULL; | 2393 data_for_recursion->nearest_occlusion_immune_ancestor_surface = NULL; |
2398 data_for_recursion->in_subtree_of_page_scale_application_layer = false; | 2394 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; | 2395 data_for_recursion->subtree_can_use_lcd_text = inputs.can_use_lcd_text; |
2400 data_for_recursion->subtree_is_visible_from_ancestor = true; | 2396 data_for_recursion->subtree_is_visible_from_ancestor = true; |
2401 } | 2397 } |
2402 | 2398 |
2399 void LayerTreeHostCommon::UpdateRenderSurface( | |
2400 Layer* layer, | |
2401 bool can_render_to_separate_surface, | |
2402 gfx::Transform* transform, | |
2403 bool* draw_transform_is_axis_aligned) { | |
2404 bool preserves_2d_axis_alignment = | |
2405 transform->Preserves2dAxisAlignment() && *draw_transform_is_axis_aligned; | |
2406 if (IsRootLayer(layer) || (can_render_to_separate_surface && | |
2407 SubtreeShouldRenderToSeparateSurface( | |
2408 layer, preserves_2d_axis_alignment))) { | |
2409 // We reset the transform here so that any axis-changing transforms | |
2410 // will now be relative to this RenderSurface. | |
2411 transform->MakeIdentity(); | |
2412 *draw_transform_is_axis_aligned = true; | |
2413 if (!layer->render_surface()) { | |
2414 layer->CreateRenderSurface(); | |
2415 } | |
2416 layer->SetHasRenderSurface(true); | |
2417 return; | |
2418 } | |
2419 layer->SetHasRenderSurface(false); | |
2420 if (layer->render_surface()) | |
2421 layer->ClearRenderSurface(); | |
2422 } | |
2423 | |
2424 void LayerTreeHostCommon::UpdateRenderSurfaces( | |
2425 Layer* layer, | |
2426 bool can_render_to_separate_surface, | |
2427 const gfx::Transform& parent_transform, | |
2428 bool draw_transform_is_axis_aligned) { | |
2429 gfx::Transform transform_for_children = layer->transform(); | |
2430 transform_for_children *= parent_transform; | |
2431 draw_transform_is_axis_aligned &= layer->AnimationsPreserveAxisAlignment(); | |
2432 UpdateRenderSurface(layer, can_render_to_separate_surface, | |
2433 &transform_for_children, &draw_transform_is_axis_aligned); | |
2434 | |
2435 for (size_t i = 0; i < layer->children().size(); ++i) { | |
2436 UpdateRenderSurfaces(layer->children()[i].get(), | |
2437 can_render_to_separate_surface, transform_for_children, | |
2438 draw_transform_is_axis_aligned); | |
2439 } | |
2440 } | |
2441 | |
2403 void LayerTreeHostCommon::CalculateDrawProperties( | 2442 void LayerTreeHostCommon::CalculateDrawProperties( |
2404 CalcDrawPropsMainInputs* inputs) { | 2443 CalcDrawPropsMainInputs* inputs) { |
2444 UpdateRenderSurfaces(inputs->root_layer, | |
2445 inputs->can_render_to_separate_surface, gfx::Transform(), | |
2446 false); | |
2405 LayerList dummy_layer_list; | 2447 LayerList dummy_layer_list; |
2406 SubtreeGlobals<Layer> globals; | 2448 SubtreeGlobals<Layer> globals; |
2407 DataForRecursion<Layer> data_for_recursion; | 2449 DataForRecursion<Layer> data_for_recursion; |
2408 ProcessCalcDrawPropsInputs(*inputs, &globals, &data_for_recursion); | 2450 ProcessCalcDrawPropsInputs(*inputs, &globals, &data_for_recursion); |
2409 | 2451 |
2410 PreCalculateMetaInformationRecursiveData recursive_data; | 2452 PreCalculateMetaInformationRecursiveData recursive_data; |
2411 PreCalculateMetaInformation(inputs->root_layer, &recursive_data); | 2453 PreCalculateMetaInformation(inputs->root_layer, &recursive_data); |
2412 std::vector<AccumulatedSurfaceState<Layer>> accumulated_surface_state; | 2454 std::vector<AccumulatedSurfaceState<Layer>> accumulated_surface_state; |
2413 CalculateDrawPropertiesInternal<Layer>( | 2455 CalculateDrawPropertiesInternal<Layer>( |
2414 inputs->root_layer, | 2456 inputs->root_layer, |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2449 inputs->current_render_surface_layer_list_id); | 2491 inputs->current_render_surface_layer_list_id); |
2450 | 2492 |
2451 // The dummy layer list should not have been used. | 2493 // The dummy layer list should not have been used. |
2452 DCHECK_EQ(0u, dummy_layer_list.size()); | 2494 DCHECK_EQ(0u, dummy_layer_list.size()); |
2453 // A root layer render_surface should always exist after | 2495 // A root layer render_surface should always exist after |
2454 // CalculateDrawProperties. | 2496 // CalculateDrawProperties. |
2455 DCHECK(inputs->root_layer->render_surface()); | 2497 DCHECK(inputs->root_layer->render_surface()); |
2456 } | 2498 } |
2457 | 2499 |
2458 } // namespace cc | 2500 } // namespace cc |
OLD | NEW |