Chromium Code Reviews| 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 676 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1809 data_from_ancestor.full_hierarchy_matrix; | 1796 data_from_ancestor.full_hierarchy_matrix; |
| 1810 | 1797 |
| 1811 // If the subtree will scale layer contents by the transform hierarchy, then | 1798 // If the subtree will scale layer contents by the transform hierarchy, then |
| 1812 // we should scale things into the render surface by the transform hierarchy | 1799 // we should scale things into the render surface by the transform hierarchy |
| 1813 // to take advantage of that. | 1800 // to take advantage of that. |
| 1814 gfx::Vector2dF render_surface_sublayer_scale = | 1801 gfx::Vector2dF render_surface_sublayer_scale = |
| 1815 globals.can_adjust_raster_scales | 1802 globals.can_adjust_raster_scales |
| 1816 ? combined_transform_scales | 1803 ? combined_transform_scales |
| 1817 : gfx::Vector2dF(layer_scale_factors, layer_scale_factors); | 1804 : gfx::Vector2dF(layer_scale_factors, layer_scale_factors); |
| 1818 | 1805 |
| 1819 bool render_to_separate_surface; | 1806 bool render_to_separate_surface = |
| 1820 if (globals.can_render_to_separate_surface) { | 1807 IsRootLayer(layer) || |
| 1821 render_to_separate_surface = SubtreeShouldRenderToSeparateSurface( | 1808 (globals.can_render_to_separate_surface && layer->render_surface()); |
| 1822 layer, combined_transform.Preserves2dAxisAlignment()); | 1809 |
| 1823 } else { | |
| 1824 render_to_separate_surface = IsRootLayer(layer); | |
| 1825 } | |
| 1826 if (render_to_separate_surface) { | 1810 if (render_to_separate_surface) { |
| 1811 DCHECK(layer->render_surface()); | |
| 1827 // Check back-face visibility before continuing with this surface and its | 1812 // Check back-face visibility before continuing with this surface and its |
| 1828 // subtree | 1813 // subtree |
| 1829 if (!layer->double_sided() && TransformToParentIsKnown(layer) && | 1814 if (!layer->double_sided() && TransformToParentIsKnown(layer) && |
| 1830 IsSurfaceBackFaceVisible(layer, combined_transform)) { | 1815 IsSurfaceBackFaceVisible(layer, combined_transform)) { |
| 1831 layer->ClearRenderSurfaceLayerList(); | 1816 layer->ClearRenderSurfaceLayerList(); |
| 1832 return; | 1817 return; |
| 1833 } | 1818 } |
| 1834 | 1819 |
| 1835 typename LayerType::RenderSurfaceType* render_surface = | 1820 typename LayerType::RenderSurfaceType* render_surface = |
| 1836 CreateOrReuseRenderSurface(layer); | 1821 layer->render_surface(); |
| 1822 layer->ClearRenderSurfaceLayerList(); | |
| 1837 | 1823 |
| 1824 layer_draw_properties.render_target = layer; | |
| 1838 if (IsRootLayer(layer)) { | 1825 if (IsRootLayer(layer)) { |
| 1839 // The root layer's render surface size is predetermined and so the root | 1826 // The root layer's render surface size is predetermined and so the root |
| 1840 // layer can't directly support non-identity transforms. It should just | 1827 // layer can't directly support non-identity transforms. It should just |
| 1841 // forward top-level transforms to the rest of the tree. | 1828 // forward top-level transforms to the rest of the tree. |
| 1842 data_for_children.parent_matrix = combined_transform; | 1829 data_for_children.parent_matrix = combined_transform; |
| 1843 | 1830 |
| 1844 // The root surface does not contribute to any other surface, it has no | 1831 // The root surface does not contribute to any other surface, it has no |
| 1845 // target. | 1832 // target. |
| 1846 layer->render_surface()->set_contributes_to_drawn_surface(false); | 1833 layer->render_surface()->set_contributes_to_drawn_surface(false); |
| 1847 } else { | 1834 } else { |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2007 animating_transform_to_target; | 1994 animating_transform_to_target; |
| 2008 layer_draw_properties.screen_space_transform_is_animating = | 1995 layer_draw_properties.screen_space_transform_is_animating = |
| 2009 animating_transform_to_screen; | 1996 animating_transform_to_screen; |
| 2010 layer_draw_properties.opacity = accumulated_draw_opacity; | 1997 layer_draw_properties.opacity = accumulated_draw_opacity; |
| 2011 layer_draw_properties.blend_mode = layer->blend_mode(); | 1998 layer_draw_properties.blend_mode = layer->blend_mode(); |
| 2012 layer_draw_properties.opacity_is_animating = animating_opacity_to_target; | 1999 layer_draw_properties.opacity_is_animating = animating_opacity_to_target; |
| 2013 layer_draw_properties.screen_space_opacity_is_animating = | 2000 layer_draw_properties.screen_space_opacity_is_animating = |
| 2014 animating_opacity_to_screen; | 2001 animating_opacity_to_screen; |
| 2015 data_for_children.parent_matrix = combined_transform; | 2002 data_for_children.parent_matrix = combined_transform; |
| 2016 | 2003 |
| 2017 layer->ClearRenderSurface(); | |
| 2018 | |
| 2019 // Layers without render_surfaces directly inherit the ancestor's clip | 2004 // Layers without render_surfaces directly inherit the ancestor's clip |
| 2020 // status. | 2005 // status. |
| 2021 layer_or_ancestor_clips_descendants = ancestor_clips_subtree; | 2006 layer_or_ancestor_clips_descendants = ancestor_clips_subtree; |
| 2022 if (ancestor_clips_subtree) { | 2007 if (ancestor_clips_subtree) { |
| 2023 clip_rect_in_target_space = | 2008 clip_rect_in_target_space = |
| 2024 ancestor_clip_rect_in_target_space; | 2009 ancestor_clip_rect_in_target_space; |
| 2025 } | 2010 } |
| 2026 | 2011 |
| 2027 // The surface's cached clip rect value propagates regardless of what | 2012 // The surface's cached clip rect value propagates regardless of what |
| 2028 // clipping goes on between layers here. | 2013 // clipping goes on between layers here. |
| 2029 clip_rect_of_target_surface_in_target_space = | 2014 clip_rect_of_target_surface_in_target_space = |
| 2030 data_from_ancestor.clip_rect_of_target_surface_in_target_space; | 2015 data_from_ancestor.clip_rect_of_target_surface_in_target_space; |
| 2031 | 2016 |
| 2032 // Layers that are not their own render_target will render into the target | 2017 // Layers that are not their own render_target will render into the target |
| 2033 // of their nearest ancestor. | 2018 // of their nearest ancestor. |
| 2034 layer_draw_properties.render_target = layer->parent()->render_target(); | 2019 layer_draw_properties.render_target = layer->parent()->render_target(); |
| 2035 } | 2020 } |
| 2036 | 2021 |
| 2037 if (adjust_text_aa) | 2022 if (adjust_text_aa) |
| 2038 layer_draw_properties.can_use_lcd_text = layer_can_use_lcd_text; | 2023 layer_draw_properties.can_use_lcd_text = layer_can_use_lcd_text; |
| 2039 | 2024 |
| 2040 gfx::Rect rect_in_target_space = | 2025 gfx::Rect rect_in_target_space = |
| 2041 MathUtil::MapEnclosingClippedRect(layer->draw_transform(), content_rect); | 2026 MathUtil::MapEnclosingClippedRect(layer->draw_transform(), content_rect); |
| 2042 | 2027 |
| 2043 if (LayerClipsSubtree(layer)) { | 2028 if (LayerClipsSubtree(layer)) { |
| 2044 layer_or_ancestor_clips_descendants = true; | 2029 layer_or_ancestor_clips_descendants = true; |
| 2045 if (ancestor_clips_subtree && !layer->render_surface()) { | 2030 if (ancestor_clips_subtree && !render_to_separate_surface) { |
| 2046 // A layer without render surface shares the same target as its ancestor. | 2031 // A layer without render surface shares the same target as its ancestor. |
| 2047 clip_rect_in_target_space = | 2032 clip_rect_in_target_space = |
| 2048 ancestor_clip_rect_in_target_space; | 2033 ancestor_clip_rect_in_target_space; |
| 2049 clip_rect_in_target_space.Intersect(rect_in_target_space); | 2034 clip_rect_in_target_space.Intersect(rect_in_target_space); |
| 2050 } else { | 2035 } else { |
| 2051 clip_rect_in_target_space = rect_in_target_space; | 2036 clip_rect_in_target_space = rect_in_target_space; |
| 2052 } | 2037 } |
| 2053 } | 2038 } |
| 2054 | 2039 |
| 2055 // Tell the layer the rect that it's clipped by. In theory we could use a | 2040 // Tell the layer the rect that it's clipped by. In theory we could use a |
| 2056 // tighter clip rect here (drawable_content_rect), but that actually does not | 2041 // tighter clip rect here (drawable_content_rect), but that actually does not |
| 2057 // reduce how much would be drawn, and instead it would create unnecessary | 2042 // reduce how much would be drawn, and instead it would create unnecessary |
| 2058 // changes to scissor state affecting GPU performance. Our clip information | 2043 // changes to scissor state affecting GPU performance. Our clip information |
| 2059 // is used in the recursion below, so we must set it beforehand. | 2044 // is used in the recursion below, so we must set it beforehand. |
| 2060 layer_draw_properties.is_clipped = layer_or_ancestor_clips_descendants; | 2045 layer_draw_properties.is_clipped = layer_or_ancestor_clips_descendants; |
| 2061 if (layer_or_ancestor_clips_descendants) { | 2046 if (layer_or_ancestor_clips_descendants) { |
| 2062 layer_draw_properties.clip_rect = clip_rect_in_target_space; | 2047 layer_draw_properties.clip_rect = clip_rect_in_target_space; |
| 2063 } else { | 2048 } else { |
| 2064 // Initialize the clip rect to a safe value that will not clip the | 2049 // Initialize the clip rect to a safe value that will not clip the |
| 2065 // layer, just in case clipping is still accidentally used. | 2050 // layer, just in case clipping is still accidentally used. |
| 2066 layer_draw_properties.clip_rect = rect_in_target_space; | 2051 layer_draw_properties.clip_rect = rect_in_target_space; |
| 2067 } | 2052 } |
| 2068 | 2053 |
| 2069 typename LayerType::LayerListType& descendants = | 2054 typename LayerType::LayerListType& descendants = |
| 2070 (layer->render_surface() ? layer->render_surface()->layer_list() | 2055 (render_to_separate_surface ? layer->render_surface()->layer_list() |
| 2071 : *layer_list); | 2056 : *layer_list); |
| 2072 | 2057 |
| 2073 // Any layers that are appended after this point are in the layer's subtree | 2058 // Any layers that are appended after this point are in the layer's subtree |
| 2074 // and should be included in the sorting process. | 2059 // and should be included in the sorting process. |
| 2075 size_t sorting_start_index = descendants.size(); | 2060 size_t sorting_start_index = descendants.size(); |
| 2076 | 2061 |
| 2077 if (!LayerShouldBeSkipped(layer, layer_is_drawn)) { | 2062 if (!LayerShouldBeSkipped(layer, layer_is_drawn)) { |
| 2078 MarkLayerWithRenderSurfaceLayerListId(layer, | 2063 MarkLayerWithRenderSurfaceLayerListId(layer, |
| 2079 current_render_surface_layer_list_id); | 2064 current_render_surface_layer_list_id); |
| 2080 descendants.push_back(layer); | 2065 descendants.push_back(layer); |
| 2081 } | 2066 } |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2139 render_surface_layer_list->size(); | 2124 render_surface_layer_list->size(); |
| 2140 | 2125 |
| 2141 CalculateDrawPropertiesInternal<LayerType>( | 2126 CalculateDrawPropertiesInternal<LayerType>( |
| 2142 child, | 2127 child, |
| 2143 globals, | 2128 globals, |
| 2144 data_for_children, | 2129 data_for_children, |
| 2145 render_surface_layer_list, | 2130 render_surface_layer_list, |
| 2146 &descendants, | 2131 &descendants, |
| 2147 accumulated_surface_state, | 2132 accumulated_surface_state, |
| 2148 current_render_surface_layer_list_id); | 2133 current_render_surface_layer_list_id); |
| 2149 if (child->render_surface() && | 2134 // If the child is its own render target, then it has a render surface. |
| 2135 if (child->render_target() == child && | |
| 2150 !child->render_surface()->layer_list().empty() && | 2136 !child->render_surface()->layer_list().empty() && |
| 2151 !child->render_surface()->content_rect().IsEmpty()) { | 2137 !child->render_surface()->content_rect().IsEmpty()) { |
| 2152 // This child will contribute its render surface, which means | 2138 // This child will contribute its render surface, which means |
| 2153 // we need to mark just the mask layer (and replica mask layer) | 2139 // we need to mark just the mask layer (and replica mask layer) |
| 2154 // with the id. | 2140 // with the id. |
| 2155 MarkMasksWithRenderSurfaceLayerListId( | 2141 MarkMasksWithRenderSurfaceLayerListId( |
| 2156 child, current_render_surface_layer_list_id); | 2142 child, current_render_surface_layer_list_id); |
| 2157 descendants.push_back(child); | 2143 descendants.push_back(child); |
| 2158 } | 2144 } |
| 2159 | 2145 |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 2178 *layer, | 2164 *layer, |
| 2179 &descendants, | 2165 &descendants, |
| 2180 layer_list_child_sorting_start_index, | 2166 layer_list_child_sorting_start_index, |
| 2181 &GetNewDescendantsStartIndexAndCount<LayerType>); | 2167 &GetNewDescendantsStartIndexAndCount<LayerType>); |
| 2182 } | 2168 } |
| 2183 | 2169 |
| 2184 // Compute the total drawable_content_rect for this subtree (the rect is in | 2170 // Compute the total drawable_content_rect for this subtree (the rect is in |
| 2185 // target surface space). | 2171 // target surface space). |
| 2186 gfx::Rect local_drawable_content_rect_of_subtree = | 2172 gfx::Rect local_drawable_content_rect_of_subtree = |
| 2187 accumulated_surface_state->back().drawable_content_rect; | 2173 accumulated_surface_state->back().drawable_content_rect; |
| 2188 if (layer->render_surface()) { | 2174 if (render_to_separate_surface) { |
| 2189 DCHECK(accumulated_surface_state->back().render_target == layer); | 2175 DCHECK(accumulated_surface_state->back().render_target == layer); |
| 2190 accumulated_surface_state->pop_back(); | 2176 accumulated_surface_state->pop_back(); |
| 2191 } | 2177 } |
| 2192 | 2178 |
| 2193 if (layer->render_surface() && !IsRootLayer(layer) && | 2179 if (render_to_separate_surface && !IsRootLayer(layer) && |
| 2194 layer->render_surface()->layer_list().empty()) { | 2180 layer->render_surface()->layer_list().empty()) { |
| 2195 RemoveSurfaceForEarlyExit(layer, render_surface_layer_list); | 2181 RemoveSurfaceForEarlyExit(layer, render_surface_layer_list); |
| 2196 return; | 2182 return; |
| 2197 } | 2183 } |
| 2198 | 2184 |
| 2199 // Compute the layer's drawable content rect (the rect is in target surface | 2185 // Compute the layer's drawable content rect (the rect is in target surface |
| 2200 // space). | 2186 // space). |
| 2201 layer_draw_properties.drawable_content_rect = rect_in_target_space; | 2187 layer_draw_properties.drawable_content_rect = rect_in_target_space; |
| 2202 if (layer_or_ancestor_clips_descendants) { | 2188 if (layer_or_ancestor_clips_descendants) { |
| 2203 layer_draw_properties.drawable_content_rect.Intersect( | 2189 layer_draw_properties.drawable_content_rect.Intersect( |
| 2204 clip_rect_in_target_space); | 2190 clip_rect_in_target_space); |
| 2205 } | 2191 } |
| 2206 if (layer->DrawsContent()) { | 2192 if (layer->DrawsContent()) { |
| 2207 local_drawable_content_rect_of_subtree.Union( | 2193 local_drawable_content_rect_of_subtree.Union( |
| 2208 layer_draw_properties.drawable_content_rect); | 2194 layer_draw_properties.drawable_content_rect); |
| 2209 } | 2195 } |
| 2210 | 2196 |
| 2211 // Compute the layer's visible content rect (the rect is in content space). | 2197 // Compute the layer's visible content rect (the rect is in content space). |
| 2212 layer_draw_properties.visible_content_rect = CalculateVisibleContentRect( | 2198 layer_draw_properties.visible_content_rect = CalculateVisibleContentRect( |
| 2213 layer, clip_rect_of_target_surface_in_target_space, rect_in_target_space); | 2199 layer, clip_rect_of_target_surface_in_target_space, rect_in_target_space); |
| 2214 | 2200 |
| 2215 // Compute the remaining properties for the render surface, if the layer has | 2201 // Compute the remaining properties for the render surface, if the layer has |
| 2216 // one. | 2202 // one. |
| 2217 if (IsRootLayer(layer)) { | 2203 if (IsRootLayer(layer)) { |
| 2218 // The root layer's surface's content_rect is always the entire viewport. | 2204 // The root layer's surface's content_rect is always the entire viewport. |
| 2219 DCHECK(layer->render_surface()); | 2205 DCHECK(render_to_separate_surface); |
| 2220 layer->render_surface()->SetContentRect( | 2206 layer->render_surface()->SetContentRect( |
| 2221 ancestor_clip_rect_in_target_space); | 2207 ancestor_clip_rect_in_target_space); |
| 2222 } else if (layer->render_surface()) { | 2208 } else if (render_to_separate_surface) { |
| 2223 typename LayerType::RenderSurfaceType* render_surface = | 2209 typename LayerType::RenderSurfaceType* render_surface = |
| 2224 layer->render_surface(); | 2210 layer->render_surface(); |
| 2225 gfx::Rect clipped_content_rect = local_drawable_content_rect_of_subtree; | 2211 gfx::Rect clipped_content_rect = local_drawable_content_rect_of_subtree; |
| 2226 | 2212 |
| 2227 // Don't clip if the layer is reflected as the reflection shouldn't be | 2213 // Don't clip if the layer is reflected as the reflection shouldn't be |
| 2228 // clipped. If the layer is animating, then the surface's transform to | 2214 // clipped. If the layer is animating, then the surface's transform to |
| 2229 // its target is not known on the main thread, and we should not use it | 2215 // its target is not known on the main thread, and we should not use it |
| 2230 // to clip. | 2216 // to clip. |
| 2231 if (!layer->replica_layer() && TransformToParentIsKnown(layer)) { | 2217 if (!layer->replica_layer() && TransformToParentIsKnown(layer)) { |
| 2232 // Note, it is correct to use data_from_ancestor.ancestor_clips_subtree | 2218 // 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... | |
| 2306 surface_origin_to_replica_origin_transform; | 2292 surface_origin_to_replica_origin_transform; |
| 2307 render_surface->SetReplicaScreenSpaceTransform( | 2293 render_surface->SetReplicaScreenSpaceTransform( |
| 2308 replica_screen_space_transform); | 2294 replica_screen_space_transform); |
| 2309 } | 2295 } |
| 2310 } | 2296 } |
| 2311 | 2297 |
| 2312 SavePaintPropertiesLayer(layer); | 2298 SavePaintPropertiesLayer(layer); |
| 2313 | 2299 |
| 2314 // If neither this layer nor any of its children were added, early out. | 2300 // If neither this layer nor any of its children were added, early out. |
| 2315 if (sorting_start_index == descendants.size()) { | 2301 if (sorting_start_index == descendants.size()) { |
| 2316 DCHECK(!layer->render_surface() || IsRootLayer(layer)); | 2302 DCHECK(!render_to_separate_surface || IsRootLayer(layer)); |
| 2317 return; | 2303 return; |
| 2318 } | 2304 } |
| 2319 | 2305 |
| 2320 // If preserves-3d then sort all the descendants in 3D so that they can be | 2306 // If preserves-3d then sort all the descendants in 3D so that they can be |
| 2321 // drawn from back to front. If the preserves-3d property is also set on the | 2307 // drawn from back to front. If the preserves-3d property is also set on the |
| 2322 // parent then skip the sorting as the parent will sort all the descendants | 2308 // parent then skip the sorting as the parent will sort all the descendants |
| 2323 // anyway. | 2309 // anyway. |
| 2324 if (globals.layer_sorter && descendants.size() && layer->Is3dSorted() && | 2310 if (globals.layer_sorter && descendants.size() && layer->Is3dSorted() && |
| 2325 !LayerIsInExisting3DRenderingContext(layer)) { | 2311 !LayerIsInExisting3DRenderingContext(layer)) { |
| 2326 SortLayers(descendants.begin() + sorting_start_index, | 2312 SortLayers(descendants.begin() + sorting_start_index, |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2384 device_viewport_rect; | 2370 device_viewport_rect; |
| 2385 data_for_recursion->maximum_animation_contents_scale = 0.f; | 2371 data_for_recursion->maximum_animation_contents_scale = 0.f; |
| 2386 data_for_recursion->ancestor_is_animating_scale = false; | 2372 data_for_recursion->ancestor_is_animating_scale = false; |
| 2387 data_for_recursion->ancestor_clips_subtree = true; | 2373 data_for_recursion->ancestor_clips_subtree = true; |
| 2388 data_for_recursion->nearest_occlusion_immune_ancestor_surface = NULL; | 2374 data_for_recursion->nearest_occlusion_immune_ancestor_surface = NULL; |
| 2389 data_for_recursion->in_subtree_of_page_scale_application_layer = false; | 2375 data_for_recursion->in_subtree_of_page_scale_application_layer = false; |
| 2390 data_for_recursion->subtree_can_use_lcd_text = inputs.can_use_lcd_text; | 2376 data_for_recursion->subtree_can_use_lcd_text = inputs.can_use_lcd_text; |
| 2391 data_for_recursion->subtree_is_visible_from_ancestor = true; | 2377 data_for_recursion->subtree_is_visible_from_ancestor = true; |
| 2392 } | 2378 } |
| 2393 | 2379 |
| 2380 void CreateOrDestroyRenderSurface(Layer* layer, | |
| 2381 bool can_render_to_separate_surface, | |
| 2382 gfx::Transform* transform, | |
| 2383 bool *non_aligned_animated_transform) { | |
| 2384 bool preserves_2d_axis_alignment = transform->Preserves2dAxisAlignment() && | |
| 2385 !*non_aligned_animated_transform; | |
| 2386 if (IsRootLayer(layer) || (can_render_to_separate_surface && | |
| 2387 SubtreeShouldRenderToSeparateSurface( | |
| 2388 layer, preserves_2d_axis_alignment))) { | |
| 2389 // We reset the transform here so that any axis-changing transforms | |
| 2390 // will now be relative to this Render Surface. | |
|
enne (OOO)
2014/12/12 21:26:32
nit: RenderSurface or "render surface", but not Re
awoloszyn
2014/12/15 20:24:53
Done.
| |
| 2391 transform->MakeIdentity(); | |
| 2392 *non_aligned_animated_transform = false; | |
|
enne (OOO)
2014/12/12 21:26:32
nit: What about draw_transform_is_axis_aligned? I
awoloszyn
2014/12/15 20:24:53
Done.
| |
| 2393 if (!layer->render_surface()) { | |
| 2394 layer->CreateRenderSurface(); | |
| 2395 } | |
| 2396 layer->SetHasRenderSurface(true); | |
| 2397 return; | |
| 2398 } | |
| 2399 layer->SetHasRenderSurface(false); | |
| 2400 if (layer->render_surface()) | |
| 2401 layer->ClearRenderSurface(); | |
| 2402 } | |
| 2403 | |
| 2404 static void CreateRenderSurfaces(Layer* layer, | |
|
enne (OOO)
2014/12/12 21:26:32
nit: Can you name these functions consistently? Cr
awoloszyn
2014/12/15 20:24:53
Done.
awoloszyn
2014/12/15 20:24:53
Done.
| |
| 2405 bool can_render_to_separate_surface, | |
| 2406 const gfx::Transform& parent_transform, | |
| 2407 bool non_aligned_animated_transform) { | |
| 2408 gfx::Transform transformForChildren = layer->transform(); | |
|
enne (OOO)
2014/12/12 21:26:32
transform_for_children
awoloszyn
2014/12/15 20:24:53
Done.
| |
| 2409 transformForChildren *= parent_transform; | |
| 2410 non_aligned_animated_transform |= | |
| 2411 layer->HasNotAxisAlignedTransformAnimation(); | |
| 2412 CreateOrDestroyRenderSurface(layer, can_render_to_separate_surface, | |
| 2413 &transformForChildren, | |
| 2414 &non_aligned_animated_transform); | |
| 2415 | |
| 2416 for (size_t i = 0; i < layer->children().size(); ++i) { | |
| 2417 CreateRenderSurfaces(layer->children()[i].get(), | |
| 2418 can_render_to_separate_surface, | |
| 2419 transformForChildren, | |
| 2420 non_aligned_animated_transform); | |
| 2421 } | |
| 2422 } | |
| 2423 | |
| 2394 void LayerTreeHostCommon::CalculateDrawProperties( | 2424 void LayerTreeHostCommon::CalculateDrawProperties( |
| 2395 CalcDrawPropsMainInputs* inputs) { | 2425 CalcDrawPropsMainInputs* inputs) { |
| 2426 CreateRenderSurfaces(inputs->root_layer, | |
| 2427 inputs->can_render_to_separate_surface, | |
| 2428 gfx::Transform(), | |
| 2429 false); | |
| 2396 LayerList dummy_layer_list; | 2430 LayerList dummy_layer_list; |
| 2397 SubtreeGlobals<Layer> globals; | 2431 SubtreeGlobals<Layer> globals; |
| 2398 DataForRecursion<Layer> data_for_recursion; | 2432 DataForRecursion<Layer> data_for_recursion; |
| 2399 ProcessCalcDrawPropsInputs(*inputs, &globals, &data_for_recursion); | 2433 ProcessCalcDrawPropsInputs(*inputs, &globals, &data_for_recursion); |
| 2400 | 2434 |
| 2401 PreCalculateMetaInformationRecursiveData recursive_data; | 2435 PreCalculateMetaInformationRecursiveData recursive_data; |
| 2402 PreCalculateMetaInformation(inputs->root_layer, &recursive_data); | 2436 PreCalculateMetaInformation(inputs->root_layer, &recursive_data); |
| 2403 std::vector<AccumulatedSurfaceState<Layer>> accumulated_surface_state; | 2437 std::vector<AccumulatedSurfaceState<Layer>> accumulated_surface_state; |
| 2404 CalculateDrawPropertiesInternal<Layer>( | 2438 CalculateDrawPropertiesInternal<Layer>( |
| 2405 inputs->root_layer, | 2439 inputs->root_layer, |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2440 inputs->current_render_surface_layer_list_id); | 2474 inputs->current_render_surface_layer_list_id); |
| 2441 | 2475 |
| 2442 // The dummy layer list should not have been used. | 2476 // The dummy layer list should not have been used. |
| 2443 DCHECK_EQ(0u, dummy_layer_list.size()); | 2477 DCHECK_EQ(0u, dummy_layer_list.size()); |
| 2444 // A root layer render_surface should always exist after | 2478 // A root layer render_surface should always exist after |
| 2445 // CalculateDrawProperties. | 2479 // CalculateDrawProperties. |
| 2446 DCHECK(inputs->root_layer->render_surface()); | 2480 DCHECK(inputs->root_layer->render_surface()); |
| 2447 } | 2481 } |
| 2448 | 2482 |
| 2449 } // namespace cc | 2483 } // namespace cc |
| OLD | NEW |