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" |
11 #include "cc/layers/heads_up_display_layer_impl.h" | 11 #include "cc/layers/heads_up_display_layer_impl.h" |
12 #include "cc/layers/layer.h" | 12 #include "cc/layers/layer.h" |
13 #include "cc/layers/layer_impl.h" | 13 #include "cc/layers/layer_impl.h" |
14 #include "cc/layers/layer_iterator.h" | 14 #include "cc/layers/layer_iterator.h" |
15 #include "cc/layers/render_surface.h" | 15 #include "cc/layers/render_surface.h" |
16 #include "cc/layers/render_surface_impl.h" | 16 #include "cc/layers/render_surface_impl.h" |
17 #include "cc/test/fake_layer_tree_host_impl.h" | |
danakj
2014/09/03 19:30:34
including cc/test from a non-test file, this looks
awoloszyn
2014/09/09 15:31:36
Done.
| |
17 #include "cc/trees/layer_sorter.h" | 18 #include "cc/trees/layer_sorter.h" |
19 #include "cc/trees/layer_tree_host.h" | |
danakj
2014/09/03 19:30:34
why?
awoloszyn
2014/09/09 15:31:36
This is no longer needed, was from earlier patch.
| |
18 #include "cc/trees/layer_tree_impl.h" | 20 #include "cc/trees/layer_tree_impl.h" |
19 #include "ui/gfx/rect_conversions.h" | 21 #include "ui/gfx/rect_conversions.h" |
20 #include "ui/gfx/transform.h" | 22 #include "ui/gfx/transform.h" |
21 | 23 |
22 namespace cc { | 24 namespace cc { |
23 | 25 |
24 ScrollAndScaleSet::ScrollAndScaleSet() {} | 26 ScrollAndScaleSet::ScrollAndScaleSet() {} |
25 | 27 |
26 ScrollAndScaleSet::~ScrollAndScaleSet() {} | 28 ScrollAndScaleSet::~ScrollAndScaleSet() {} |
27 | 29 |
(...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
541 | 543 |
542 static inline void SavePaintPropertiesLayer(Layer* layer) { | 544 static inline void SavePaintPropertiesLayer(Layer* layer) { |
543 layer->SavePaintProperties(); | 545 layer->SavePaintProperties(); |
544 | 546 |
545 if (layer->mask_layer()) | 547 if (layer->mask_layer()) |
546 layer->mask_layer()->SavePaintProperties(); | 548 layer->mask_layer()->SavePaintProperties(); |
547 if (layer->replica_layer() && layer->replica_layer()->mask_layer()) | 549 if (layer->replica_layer() && layer->replica_layer()->mask_layer()) |
548 layer->replica_layer()->mask_layer()->SavePaintProperties(); | 550 layer->replica_layer()->mask_layer()->SavePaintProperties(); |
549 } | 551 } |
550 | 552 |
551 template <typename LayerType> | |
552 static bool SubtreeShouldRenderToSeparateSurface( | 553 static bool SubtreeShouldRenderToSeparateSurface( |
553 LayerType* layer, | 554 Layer* layer, |
554 bool axis_aligned_with_respect_to_parent) { | 555 bool axis_aligned_with_respect_to_parent) { |
555 // | 556 // |
556 // 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 |
557 // any of these rules hold: | 558 // any of these rules hold: |
558 // | 559 // |
559 | 560 |
560 // 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 |
561 // surface to another render target. Compositor features that are applied via | 562 // 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 | 563 // 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 | 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... | |
1099 *combined_maximum_animation_contents_scale = 0.f; | 1100 *combined_maximum_animation_contents_scale = 0.f; |
1100 return; | 1101 return; |
1101 } | 1102 } |
1102 gfx::Vector2dF ancestor_transform_scales = | 1103 gfx::Vector2dF ancestor_transform_scales = |
1103 MathUtil::ComputeTransform2dScaleComponents(ancestor_transform, 0.f); | 1104 MathUtil::ComputeTransform2dScaleComponents(ancestor_transform, 0.f); |
1104 *combined_maximum_animation_contents_scale = | 1105 *combined_maximum_animation_contents_scale = |
1105 layer_maximum_animated_scale * | 1106 layer_maximum_animated_scale * |
1106 std::max(ancestor_transform_scales.x(), ancestor_transform_scales.y()); | 1107 std::max(ancestor_transform_scales.x(), ancestor_transform_scales.y()); |
1107 } | 1108 } |
1108 | 1109 |
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> | 1110 template <typename LayerTypePtr> |
1122 static inline void MarkLayerWithRenderSurfaceLayerListId( | 1111 static inline void MarkLayerWithRenderSurfaceLayerListId( |
1123 LayerTypePtr layer, | 1112 LayerTypePtr layer, |
1124 int current_render_surface_layer_list_id) { | 1113 int current_render_surface_layer_list_id) { |
1125 layer->draw_properties().last_drawn_render_surface_layer_list_id = | 1114 layer->draw_properties().last_drawn_render_surface_layer_list_id = |
1126 current_render_surface_layer_list_id; | 1115 current_render_surface_layer_list_id; |
1127 } | 1116 } |
1128 | 1117 |
1129 template <typename LayerTypePtr> | 1118 template <typename LayerTypePtr> |
1130 static inline void MarkMasksWithRenderSurfaceLayerListId( | 1119 static inline void MarkMasksWithRenderSurfaceLayerListId( |
(...skipping 675 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1806 data_from_ancestor.full_hierarchy_matrix; | 1795 data_from_ancestor.full_hierarchy_matrix; |
1807 | 1796 |
1808 // If the subtree will scale layer contents by the transform hierarchy, then | 1797 // 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 | 1798 // we should scale things into the render surface by the transform hierarchy |
1810 // to take advantage of that. | 1799 // to take advantage of that. |
1811 gfx::Vector2dF render_surface_sublayer_scale = | 1800 gfx::Vector2dF render_surface_sublayer_scale = |
1812 globals.can_adjust_raster_scales | 1801 globals.can_adjust_raster_scales |
1813 ? combined_transform_scales | 1802 ? combined_transform_scales |
1814 : gfx::Vector2dF(layer_scale_factors, layer_scale_factors); | 1803 : gfx::Vector2dF(layer_scale_factors, layer_scale_factors); |
1815 | 1804 |
1816 bool render_to_separate_surface; | 1805 bool render_to_separate_surface = |
1817 if (globals.can_render_to_separate_surface) { | 1806 IsRootLayer(layer) || |
1818 render_to_separate_surface = SubtreeShouldRenderToSeparateSurface( | 1807 (globals.can_render_to_separate_surface && layer->render_surface()); |
1819 layer, combined_transform.Preserves2dAxisAlignment()); | 1808 |
1820 } else { | 1809 DCHECK(globals.can_render_to_separate_surface || IsRootLayer(layer) || |
danakj
2014/09/03 19:30:34
this looks a bit awkward, like it's just repeating
awoloszyn
2014/09/09 15:31:37
Done.
| |
1821 render_to_separate_surface = IsRootLayer(layer); | 1810 !render_to_separate_surface); |
1822 } | 1811 |
1823 if (render_to_separate_surface) { | 1812 if (render_to_separate_surface) { |
1824 // Check back-face visibility before continuing with this surface and its | 1813 // Check back-face visibility before continuing with this surface and its |
danakj
2014/09/03 19:30:34
DCHECK(layer->render_surface()) here
awoloszyn
2014/09/09 15:31:36
Done.
| |
1825 // subtree | 1814 // subtree |
1826 if (!layer->double_sided() && TransformToParentIsKnown(layer) && | 1815 if (!layer->double_sided() && TransformToParentIsKnown(layer) && |
1827 IsSurfaceBackFaceVisible(layer, combined_transform)) { | 1816 IsSurfaceBackFaceVisible(layer, combined_transform)) { |
1828 layer->ClearRenderSurfaceLayerList(); | 1817 layer->ClearRenderSurfaceLayerList(); |
danakj
2014/09/03 19:30:34
I'm noticing all the ways we have to clear the RS
awoloszyn
2014/09/09 15:31:36
I will replace all with layer->ClearRenderSurfaceL
| |
1829 return; | 1818 return; |
1830 } | 1819 } |
1831 | 1820 |
1821 layer_draw_properties.render_target = layer; | |
danakj
2014/09/03 19:30:34
remove this, did this twice also on L1825
awoloszyn
2014/09/09 15:31:37
Done.
| |
1832 typename LayerType::RenderSurfaceType* render_surface = | 1822 typename LayerType::RenderSurfaceType* render_surface = |
1833 CreateOrReuseRenderSurface(layer); | 1823 layer->render_surface(); |
1834 | 1824 render_surface->ClearLayerLists(); |
1825 layer_draw_properties.render_target = layer; | |
1835 if (IsRootLayer(layer)) { | 1826 if (IsRootLayer(layer)) { |
1836 // The root layer's render surface size is predetermined and so the root | 1827 // 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 | 1828 // layer can't directly support non-identity transforms. It should just |
1838 // forward top-level transforms to the rest of the tree. | 1829 // forward top-level transforms to the rest of the tree. |
1839 data_for_children.parent_matrix = combined_transform; | 1830 data_for_children.parent_matrix = combined_transform; |
1840 | 1831 |
1841 // The root surface does not contribute to any other surface, it has no | 1832 // The root surface does not contribute to any other surface, it has no |
1842 // target. | 1833 // target. |
1843 layer->render_surface()->set_contributes_to_drawn_surface(false); | 1834 layer->render_surface()->set_contributes_to_drawn_surface(false); |
1844 } else { | 1835 } else { |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1999 layer_draw_properties.target_space_transform_is_animating = | 1990 layer_draw_properties.target_space_transform_is_animating = |
2000 animating_transform_to_target; | 1991 animating_transform_to_target; |
2001 layer_draw_properties.screen_space_transform_is_animating = | 1992 layer_draw_properties.screen_space_transform_is_animating = |
2002 animating_transform_to_screen; | 1993 animating_transform_to_screen; |
2003 layer_draw_properties.opacity = accumulated_draw_opacity; | 1994 layer_draw_properties.opacity = accumulated_draw_opacity; |
2004 layer_draw_properties.opacity_is_animating = animating_opacity_to_target; | 1995 layer_draw_properties.opacity_is_animating = animating_opacity_to_target; |
2005 layer_draw_properties.screen_space_opacity_is_animating = | 1996 layer_draw_properties.screen_space_opacity_is_animating = |
2006 animating_opacity_to_screen; | 1997 animating_opacity_to_screen; |
2007 data_for_children.parent_matrix = combined_transform; | 1998 data_for_children.parent_matrix = combined_transform; |
2008 | 1999 |
2009 layer->ClearRenderSurface(); | |
2010 | |
2011 // Layers without render_surfaces directly inherit the ancestor's clip | 2000 // Layers without render_surfaces directly inherit the ancestor's clip |
2012 // status. | 2001 // status. |
2013 layer_or_ancestor_clips_descendants = ancestor_clips_subtree; | 2002 layer_or_ancestor_clips_descendants = ancestor_clips_subtree; |
2014 if (ancestor_clips_subtree) { | 2003 if (ancestor_clips_subtree) { |
2015 clip_rect_in_target_space = | 2004 clip_rect_in_target_space = |
2016 ancestor_clip_rect_in_target_space; | 2005 ancestor_clip_rect_in_target_space; |
2017 } | 2006 } |
2018 | 2007 |
2019 // The surface's cached clip rect value propagates regardless of what | 2008 // The surface's cached clip rect value propagates regardless of what |
2020 // clipping goes on between layers here. | 2009 // clipping goes on between layers here. |
2021 clip_rect_of_target_surface_in_target_space = | 2010 clip_rect_of_target_surface_in_target_space = |
2022 data_from_ancestor.clip_rect_of_target_surface_in_target_space; | 2011 data_from_ancestor.clip_rect_of_target_surface_in_target_space; |
2023 | 2012 |
2024 // Layers that are not their own render_target will render into the target | 2013 // Layers that are not their own render_target will render into the target |
2025 // of their nearest ancestor. | 2014 // of their nearest ancestor. |
2026 layer_draw_properties.render_target = layer->parent()->render_target(); | 2015 layer_draw_properties.render_target = layer->parent()->render_target(); |
2027 } | 2016 } |
2028 | 2017 |
2029 if (adjust_text_aa) | 2018 if (adjust_text_aa) |
2030 layer_draw_properties.can_use_lcd_text = layer_can_use_lcd_text; | 2019 layer_draw_properties.can_use_lcd_text = layer_can_use_lcd_text; |
2031 | 2020 |
2032 gfx::Rect rect_in_target_space = | 2021 gfx::Rect rect_in_target_space = |
2033 MathUtil::MapEnclosingClippedRect(layer->draw_transform(), content_rect); | 2022 MathUtil::MapEnclosingClippedRect(layer->draw_transform(), content_rect); |
2034 | 2023 |
2035 if (LayerClipsSubtree(layer)) { | 2024 if (LayerClipsSubtree(layer)) { |
2036 layer_or_ancestor_clips_descendants = true; | 2025 layer_or_ancestor_clips_descendants = true; |
2037 if (ancestor_clips_subtree && !layer->render_surface()) { | 2026 if (ancestor_clips_subtree && !render_to_separate_surface) { |
2038 // A layer without render surface shares the same target as its ancestor. | 2027 // A layer without render surface shares the same target as its ancestor. |
2039 clip_rect_in_target_space = | 2028 clip_rect_in_target_space = |
2040 ancestor_clip_rect_in_target_space; | 2029 ancestor_clip_rect_in_target_space; |
2041 clip_rect_in_target_space.Intersect(rect_in_target_space); | 2030 clip_rect_in_target_space.Intersect(rect_in_target_space); |
2042 } else { | 2031 } else { |
2043 clip_rect_in_target_space = rect_in_target_space; | 2032 clip_rect_in_target_space = rect_in_target_space; |
2044 } | 2033 } |
2045 } | 2034 } |
2046 | 2035 |
2047 // Tell the layer the rect that it's clipped by. In theory we could use a | 2036 // 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 | 2037 // 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 | 2038 // reduce how much would be drawn, and instead it would create unnecessary |
2050 // changes to scissor state affecting GPU performance. Our clip information | 2039 // changes to scissor state affecting GPU performance. Our clip information |
2051 // is used in the recursion below, so we must set it beforehand. | 2040 // is used in the recursion below, so we must set it beforehand. |
2052 layer_draw_properties.is_clipped = layer_or_ancestor_clips_descendants; | 2041 layer_draw_properties.is_clipped = layer_or_ancestor_clips_descendants; |
2053 if (layer_or_ancestor_clips_descendants) { | 2042 if (layer_or_ancestor_clips_descendants) { |
2054 layer_draw_properties.clip_rect = clip_rect_in_target_space; | 2043 layer_draw_properties.clip_rect = clip_rect_in_target_space; |
2055 } else { | 2044 } else { |
2056 // Initialize the clip rect to a safe value that will not clip the | 2045 // Initialize the clip rect to a safe value that will not clip the |
2057 // layer, just in case clipping is still accidentally used. | 2046 // layer, just in case clipping is still accidentally used. |
2058 layer_draw_properties.clip_rect = rect_in_target_space; | 2047 layer_draw_properties.clip_rect = rect_in_target_space; |
2059 } | 2048 } |
2060 | 2049 |
2061 typename LayerType::LayerListType& descendants = | 2050 typename LayerType::LayerListType& descendants = |
2062 (layer->render_surface() ? layer->render_surface()->layer_list() | 2051 (render_to_separate_surface ? layer->render_surface()->layer_list() |
2063 : *layer_list); | 2052 : *layer_list); |
2064 | 2053 |
2065 // Any layers that are appended after this point are in the layer's subtree | 2054 // Any layers that are appended after this point are in the layer's subtree |
2066 // and should be included in the sorting process. | 2055 // and should be included in the sorting process. |
2067 size_t sorting_start_index = descendants.size(); | 2056 size_t sorting_start_index = descendants.size(); |
2068 | 2057 |
2069 if (!LayerShouldBeSkipped(layer, layer_is_drawn)) { | 2058 if (!LayerShouldBeSkipped(layer, layer_is_drawn)) { |
2070 MarkLayerWithRenderSurfaceLayerListId(layer, | 2059 MarkLayerWithRenderSurfaceLayerListId(layer, |
2071 current_render_surface_layer_list_id); | 2060 current_render_surface_layer_list_id); |
2072 descendants.push_back(layer); | 2061 descendants.push_back(layer); |
2073 } | 2062 } |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2131 render_surface_layer_list->size(); | 2120 render_surface_layer_list->size(); |
2132 | 2121 |
2133 CalculateDrawPropertiesInternal<LayerType>( | 2122 CalculateDrawPropertiesInternal<LayerType>( |
2134 child, | 2123 child, |
2135 globals, | 2124 globals, |
2136 data_for_children, | 2125 data_for_children, |
2137 render_surface_layer_list, | 2126 render_surface_layer_list, |
2138 &descendants, | 2127 &descendants, |
2139 accumulated_surface_state, | 2128 accumulated_surface_state, |
2140 current_render_surface_layer_list_id); | 2129 current_render_surface_layer_list_id); |
2141 if (child->render_surface() && | 2130 // If our child has a render_target that is not our render_target |
2131 // then it has it's own surface | |
danakj
2014/09/03 19:30:34
nit: period
awoloszyn
2014/09/09 15:31:36
Done.
| |
2132 if (child->render_target() != layer->render_target() && | |
2133 child->render_surface() && | |
danakj
2014/09/03 19:30:34
the render_surface() must be true in that case, so
awoloszyn
2014/09/09 15:31:36
I have re-worked this to be a bit more clear. A ch
| |
2142 !child->render_surface()->layer_list().empty() && | 2134 !child->render_surface()->layer_list().empty() && |
2143 !child->render_surface()->content_rect().IsEmpty()) { | 2135 !child->render_surface()->content_rect().IsEmpty()) { |
2144 // This child will contribute its render surface, which means | 2136 // This child will contribute its render surface, which means |
2145 // we need to mark just the mask layer (and replica mask layer) | 2137 // we need to mark just the mask layer (and replica mask layer) |
2146 // with the id. | 2138 // with the id. |
2147 MarkMasksWithRenderSurfaceLayerListId( | 2139 MarkMasksWithRenderSurfaceLayerListId( |
2148 child, current_render_surface_layer_list_id); | 2140 child, current_render_surface_layer_list_id); |
2149 descendants.push_back(child); | 2141 descendants.push_back(child); |
2150 } | 2142 } |
2151 | 2143 |
(...skipping 18 matching lines...) Expand all Loading... | |
2170 *layer, | 2162 *layer, |
2171 &descendants, | 2163 &descendants, |
2172 layer_list_child_sorting_start_index, | 2164 layer_list_child_sorting_start_index, |
2173 &GetNewDescendantsStartIndexAndCount<LayerType>); | 2165 &GetNewDescendantsStartIndexAndCount<LayerType>); |
2174 } | 2166 } |
2175 | 2167 |
2176 // Compute the total drawable_content_rect for this subtree (the rect is in | 2168 // Compute the total drawable_content_rect for this subtree (the rect is in |
2177 // target surface space). | 2169 // target surface space). |
2178 gfx::Rect local_drawable_content_rect_of_subtree = | 2170 gfx::Rect local_drawable_content_rect_of_subtree = |
2179 accumulated_surface_state->back().drawable_content_rect; | 2171 accumulated_surface_state->back().drawable_content_rect; |
2180 if (layer->render_surface()) { | 2172 if (render_to_separate_surface) { |
2181 DCHECK(accumulated_surface_state->back().render_target == layer); | 2173 DCHECK(accumulated_surface_state->back().render_target == layer); |
2182 accumulated_surface_state->pop_back(); | 2174 accumulated_surface_state->pop_back(); |
2183 } | 2175 } |
2184 | 2176 |
2185 if (layer->render_surface() && !IsRootLayer(layer) && | 2177 if (render_to_separate_surface && !IsRootLayer(layer) && |
2186 layer->render_surface()->layer_list().empty()) { | 2178 layer->render_surface()->layer_list().empty()) { |
2187 RemoveSurfaceForEarlyExit(layer, render_surface_layer_list); | 2179 RemoveSurfaceForEarlyExit(layer, render_surface_layer_list); |
2188 return; | 2180 return; |
2189 } | 2181 } |
2190 | 2182 |
2191 // Compute the layer's drawable content rect (the rect is in target surface | 2183 // Compute the layer's drawable content rect (the rect is in target surface |
2192 // space). | 2184 // space). |
2193 layer_draw_properties.drawable_content_rect = rect_in_target_space; | 2185 layer_draw_properties.drawable_content_rect = rect_in_target_space; |
2194 if (layer_or_ancestor_clips_descendants) { | 2186 if (layer_or_ancestor_clips_descendants) { |
2195 layer_draw_properties.drawable_content_rect.Intersect( | 2187 layer_draw_properties.drawable_content_rect.Intersect( |
2196 clip_rect_in_target_space); | 2188 clip_rect_in_target_space); |
2197 } | 2189 } |
2198 if (layer->DrawsContent()) { | 2190 if (layer->DrawsContent()) { |
2199 local_drawable_content_rect_of_subtree.Union( | 2191 local_drawable_content_rect_of_subtree.Union( |
2200 layer_draw_properties.drawable_content_rect); | 2192 layer_draw_properties.drawable_content_rect); |
2201 } | 2193 } |
2202 | 2194 |
2203 // Compute the layer's visible content rect (the rect is in content space). | 2195 // Compute the layer's visible content rect (the rect is in content space). |
2204 layer_draw_properties.visible_content_rect = CalculateVisibleContentRect( | 2196 layer_draw_properties.visible_content_rect = CalculateVisibleContentRect( |
2205 layer, clip_rect_of_target_surface_in_target_space, rect_in_target_space); | 2197 layer, clip_rect_of_target_surface_in_target_space, rect_in_target_space); |
2206 | 2198 |
2207 // Compute the remaining properties for the render surface, if the layer has | 2199 // Compute the remaining properties for the render surface, if the layer has |
2208 // one. | 2200 // one. |
2209 if (IsRootLayer(layer)) { | 2201 if (IsRootLayer(layer)) { |
2210 // The root layer's surface's content_rect is always the entire viewport. | 2202 // The root layer's surface's content_rect is always the entire viewport. |
2211 DCHECK(layer->render_surface()); | 2203 DCHECK(render_to_separate_surface); |
2212 layer->render_surface()->SetContentRect( | 2204 layer->render_surface()->SetContentRect( |
2213 ancestor_clip_rect_in_target_space); | 2205 ancestor_clip_rect_in_target_space); |
2214 } else if (layer->render_surface()) { | 2206 } else if (render_to_separate_surface) { |
2215 typename LayerType::RenderSurfaceType* render_surface = | 2207 typename LayerType::RenderSurfaceType* render_surface = |
2216 layer->render_surface(); | 2208 layer->render_surface(); |
2217 gfx::Rect clipped_content_rect = local_drawable_content_rect_of_subtree; | 2209 gfx::Rect clipped_content_rect = local_drawable_content_rect_of_subtree; |
2218 | 2210 |
2219 // Don't clip if the layer is reflected as the reflection shouldn't be | 2211 // 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 | 2212 // 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 | 2213 // its target is not known on the main thread, and we should not use it |
2222 // to clip. | 2214 // to clip. |
2223 if (!layer->replica_layer() && TransformToParentIsKnown(layer)) { | 2215 if (!layer->replica_layer() && TransformToParentIsKnown(layer)) { |
2224 // Note, it is correct to use data_from_ancestor.ancestor_clips_subtree | 2216 // 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... | |
2298 surface_origin_to_replica_origin_transform; | 2290 surface_origin_to_replica_origin_transform; |
2299 render_surface->SetReplicaScreenSpaceTransform( | 2291 render_surface->SetReplicaScreenSpaceTransform( |
2300 replica_screen_space_transform); | 2292 replica_screen_space_transform); |
2301 } | 2293 } |
2302 } | 2294 } |
2303 | 2295 |
2304 SavePaintPropertiesLayer(layer); | 2296 SavePaintPropertiesLayer(layer); |
2305 | 2297 |
2306 // If neither this layer nor any of its children were added, early out. | 2298 // If neither this layer nor any of its children were added, early out. |
2307 if (sorting_start_index == descendants.size()) { | 2299 if (sorting_start_index == descendants.size()) { |
2308 DCHECK(!layer->render_surface() || IsRootLayer(layer)); | 2300 DCHECK(!render_to_separate_surface || IsRootLayer(layer)); |
2309 return; | 2301 return; |
2310 } | 2302 } |
2311 | 2303 |
2312 // If preserves-3d then sort all the descendants in 3D so that they can be | 2304 // 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 | 2305 // 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 | 2306 // parent then skip the sorting as the parent will sort all the descendants |
2315 // anyway. | 2307 // anyway. |
2316 if (globals.layer_sorter && descendants.size() && layer->Is3dSorted() && | 2308 if (globals.layer_sorter && descendants.size() && layer->Is3dSorted() && |
2317 !LayerIsInExisting3DRenderingContext(layer)) { | 2309 !LayerIsInExisting3DRenderingContext(layer)) { |
2318 SortLayers(descendants.begin() + sorting_start_index, | 2310 SortLayers(descendants.begin() + sorting_start_index, |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2376 device_viewport_rect; | 2368 device_viewport_rect; |
2377 data_for_recursion->maximum_animation_contents_scale = 0.f; | 2369 data_for_recursion->maximum_animation_contents_scale = 0.f; |
2378 data_for_recursion->ancestor_is_animating_scale = false; | 2370 data_for_recursion->ancestor_is_animating_scale = false; |
2379 data_for_recursion->ancestor_clips_subtree = true; | 2371 data_for_recursion->ancestor_clips_subtree = true; |
2380 data_for_recursion->nearest_occlusion_immune_ancestor_surface = NULL; | 2372 data_for_recursion->nearest_occlusion_immune_ancestor_surface = NULL; |
2381 data_for_recursion->in_subtree_of_page_scale_application_layer = false; | 2373 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; | 2374 data_for_recursion->subtree_can_use_lcd_text = inputs.can_use_lcd_text; |
2383 data_for_recursion->subtree_is_visible_from_ancestor = true; | 2375 data_for_recursion->subtree_is_visible_from_ancestor = true; |
2384 } | 2376 } |
2385 | 2377 |
2378 void CreateOrDestroyRenderSurface(Layer* layer, | |
2379 bool can_render_to_separate_surface, | |
2380 gfx::Transform* transform) { | |
2381 if (IsRootLayer(layer) || | |
2382 (can_render_to_separate_surface && | |
2383 SubtreeShouldRenderToSeparateSurface( | |
2384 layer, | |
2385 transform->IsIdentity() || transform->Preserves2dAxisAlignment()))) { | |
danakj
2014/09/03 19:30:34
nit: Preserves2dAxisAlignment should already retur
awoloszyn
2014/09/09 15:31:37
It does already return true for Identity. transfor
| |
2386 transform->MakeIdentity(); | |
2387 if (!layer->render_surface()) { | |
2388 layer->CreateRenderSurface(); | |
2389 } | |
2390 layer->SetHasRenderSurface(true); | |
2391 return; | |
2392 } | |
2393 layer->SetHasRenderSurface(false); | |
2394 if (layer->render_surface()) | |
2395 layer->ClearRenderSurface(); | |
2396 } | |
2397 | |
2398 static void CreateRenderSurfaces(Layer* layer, | |
2399 bool can_render_to_separate_surface, | |
2400 const gfx::Transform& parent_transform) { | |
2401 if (!layer) | |
2402 return; | |
2403 gfx::Transform transformForChildren = layer->transform(); | |
2404 transformForChildren *= parent_transform; | |
danakj
2014/09/03 19:30:34
This is not really the same thing as checking the
awoloszyn
2014/09/09 15:31:36
2d offsets are not able to change the 2d axis alig
| |
2405 CreateOrDestroyRenderSurface( | |
2406 layer, can_render_to_separate_surface, &transformForChildren); | |
2407 | |
2408 for (size_t i = 0; i < layer->children().size(); ++i) { | |
2409 CreateRenderSurfaces(layer->children()[i], | |
2410 can_render_to_separate_surface, | |
2411 transformForChildren); | |
2412 } | |
2413 } | |
2414 | |
2386 void LayerTreeHostCommon::CalculateDrawProperties( | 2415 void LayerTreeHostCommon::CalculateDrawProperties( |
2387 CalcDrawPropsMainInputs* inputs) { | 2416 CalcDrawPropsMainInputs* inputs) { |
2417 CreateRenderSurfaces(inputs->root_layer, | |
2418 inputs->can_render_to_separate_surface, | |
2419 gfx::Transform()); | |
2388 LayerList dummy_layer_list; | 2420 LayerList dummy_layer_list; |
2389 SubtreeGlobals<Layer> globals; | 2421 SubtreeGlobals<Layer> globals; |
2390 DataForRecursion<Layer> data_for_recursion; | 2422 DataForRecursion<Layer> data_for_recursion; |
2391 ProcessCalcDrawPropsInputs(*inputs, &globals, &data_for_recursion); | 2423 ProcessCalcDrawPropsInputs(*inputs, &globals, &data_for_recursion); |
2392 | 2424 |
2393 PreCalculateMetaInformationRecursiveData recursive_data; | 2425 PreCalculateMetaInformationRecursiveData recursive_data; |
2394 PreCalculateMetaInformation(inputs->root_layer, &recursive_data); | 2426 PreCalculateMetaInformation(inputs->root_layer, &recursive_data); |
2395 std::vector<AccumulatedSurfaceState<Layer> > accumulated_surface_state; | 2427 std::vector<AccumulatedSurfaceState<Layer> > accumulated_surface_state; |
2396 CalculateDrawPropertiesInternal<Layer>( | 2428 CalculateDrawPropertiesInternal<Layer>( |
2397 inputs->root_layer, | 2429 inputs->root_layer, |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2433 inputs->current_render_surface_layer_list_id); | 2465 inputs->current_render_surface_layer_list_id); |
2434 | 2466 |
2435 // The dummy layer list should not have been used. | 2467 // The dummy layer list should not have been used. |
2436 DCHECK_EQ(0u, dummy_layer_list.size()); | 2468 DCHECK_EQ(0u, dummy_layer_list.size()); |
2437 // A root layer render_surface should always exist after | 2469 // A root layer render_surface should always exist after |
2438 // CalculateDrawProperties. | 2470 // CalculateDrawProperties. |
2439 DCHECK(inputs->root_layer->render_surface()); | 2471 DCHECK(inputs->root_layer->render_surface()); |
2440 } | 2472 } |
2441 | 2473 |
2442 } // namespace cc | 2474 } // namespace cc |
OLD | NEW |