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/trace_event/trace_event.h" | 9 #include "base/trace_event/trace_event.h" |
10 #include "cc/base/math_util.h" | 10 #include "cc/base/math_util.h" |
(...skipping 607 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
618 return false; | 618 return false; |
619 | 619 |
620 // The opacity of a layer always applies to its children (either implicitly | 620 // The opacity of a layer always applies to its children (either implicitly |
621 // via a render surface or explicitly if the parent preserves 3D), so the | 621 // via a render surface or explicitly if the parent preserves 3D), so the |
622 // entire subtree can be skipped if this layer is fully transparent. | 622 // entire subtree can be skipped if this layer is fully transparent. |
623 return !layer->opacity(); | 623 return !layer->opacity(); |
624 } | 624 } |
625 | 625 |
626 static inline void SavePaintPropertiesLayer(LayerImpl* layer) {} | 626 static inline void SavePaintPropertiesLayer(LayerImpl* layer) {} |
627 | 627 |
628 static bool SubtreeShouldRenderToSeparateSurface( | |
629 Layer* layer, | |
630 bool axis_aligned_with_respect_to_parent) { | |
631 // | |
632 // A layer and its descendants should render onto a new RenderSurfaceImpl if | |
633 // any of these rules hold: | |
634 // | |
635 | |
636 // The root layer owns a render surface, but it never acts as a contributing | |
637 // surface to another render target. Compositor features that are applied via | |
638 // a contributing surface can not be applied to the root layer. In order to | |
639 // use these effects, another child of the root would need to be introduced | |
640 // in order to act as a contributing surface to the root layer's surface. | |
641 bool is_root = IsRootLayer(layer); | |
642 | |
643 // If the layer uses a mask. | |
644 if (layer->mask_layer()) { | |
645 DCHECK(!is_root); | |
646 return true; | |
647 } | |
648 | |
649 // If the layer has a reflection. | |
650 if (layer->replica_layer()) { | |
651 DCHECK(!is_root); | |
652 return true; | |
653 } | |
654 | |
655 // If the layer uses a CSS filter. | |
656 if (!layer->filters().IsEmpty() || !layer->background_filters().IsEmpty()) { | |
657 DCHECK(!is_root); | |
658 return true; | |
659 } | |
660 | |
661 // If the layer will use a CSS filter. In this case, the animation | |
662 // will start and add a filter to this layer, so it needs a surface. | |
663 if (layer->HasPotentiallyRunningFilterAnimation()) { | |
664 DCHECK(!is_root); | |
665 return true; | |
666 } | |
667 | |
668 int num_descendants_that_draw_content = | |
669 layer->NumDescendantsThatDrawContent(); | |
670 | |
671 // If the layer flattens its subtree, but it is treated as a 3D object by its | |
672 // parent (i.e. parent participates in a 3D rendering context). | |
673 if (LayerIsInExisting3DRenderingContext(layer) && | |
674 layer->should_flatten_transform() && | |
675 num_descendants_that_draw_content > 0) { | |
676 TRACE_EVENT_INSTANT0( | |
677 "cc", | |
678 "LayerTreeHostCommon::SubtreeShouldRenderToSeparateSurface flattening", | |
679 TRACE_EVENT_SCOPE_THREAD); | |
680 DCHECK(!is_root); | |
681 return true; | |
682 } | |
683 | |
684 // If the layer has blending. | |
685 // TODO(rosca): this is temporary, until blending is implemented for other | |
686 // types of quads than RenderPassDrawQuad. Layers having descendants that draw | |
687 // content will still create a separate rendering surface. | |
688 if (!layer->uses_default_blend_mode()) { | |
689 TRACE_EVENT_INSTANT0( | |
690 "cc", | |
691 "LayerTreeHostCommon::SubtreeShouldRenderToSeparateSurface blending", | |
692 TRACE_EVENT_SCOPE_THREAD); | |
693 DCHECK(!is_root); | |
694 return true; | |
695 } | |
696 | |
697 // If the layer clips its descendants but it is not axis-aligned with respect | |
698 // to its parent. | |
699 bool layer_clips_external_content = | |
700 LayerClipsSubtree(layer) || layer->HasDelegatedContent(); | |
701 if (layer_clips_external_content && !axis_aligned_with_respect_to_parent && | |
702 num_descendants_that_draw_content > 0) { | |
703 TRACE_EVENT_INSTANT0( | |
704 "cc", | |
705 "LayerTreeHostCommon::SubtreeShouldRenderToSeparateSurface clipping", | |
706 TRACE_EVENT_SCOPE_THREAD); | |
707 DCHECK(!is_root); | |
708 return true; | |
709 } | |
710 | |
711 // If the layer has some translucency and does not have a preserves-3d | |
712 // transform style. This condition only needs a render surface if two or more | |
713 // layers in the subtree overlap. But checking layer overlaps is unnecessarily | |
714 // costly so instead we conservatively create a surface whenever at least two | |
715 // layers draw content for this subtree. | |
716 bool at_least_two_layers_in_subtree_draw_content = | |
717 num_descendants_that_draw_content > 0 && | |
718 (layer->DrawsContent() || num_descendants_that_draw_content > 1); | |
719 | |
720 if (layer->opacity() != 1.f && layer->should_flatten_transform() && | |
721 at_least_two_layers_in_subtree_draw_content) { | |
722 TRACE_EVENT_INSTANT0( | |
723 "cc", | |
724 "LayerTreeHostCommon::SubtreeShouldRenderToSeparateSurface opacity", | |
725 TRACE_EVENT_SCOPE_THREAD); | |
726 DCHECK(!is_root); | |
727 return true; | |
728 } | |
729 | |
730 // The root layer should always have a render_surface. | |
731 if (is_root) | |
732 return true; | |
733 | |
734 // | |
735 // These are allowed on the root surface, as they don't require the surface to | |
736 // be used as a contributing surface in order to apply correctly. | |
737 // | |
738 | |
739 // If the layer has isolation. | |
740 // TODO(rosca): to be optimized - create separate rendering surface only when | |
741 // the blending descendants might have access to the content behind this layer | |
742 // (layer has transparent background or descendants overflow). | |
743 // https://code.google.com/p/chromium/issues/detail?id=301738 | |
744 if (layer->is_root_for_isolated_group()) { | |
745 TRACE_EVENT_INSTANT0( | |
746 "cc", | |
747 "LayerTreeHostCommon::SubtreeShouldRenderToSeparateSurface isolation", | |
748 TRACE_EVENT_SCOPE_THREAD); | |
749 return true; | |
750 } | |
751 | |
752 // If we force it. | |
753 if (layer->force_render_surface()) | |
754 return true; | |
755 | |
756 // If we'll make a copy of the layer's contents. | |
757 if (layer->HasCopyRequest()) | |
758 return true; | |
759 | |
760 return false; | |
761 } | |
762 | |
763 // This function returns a translation matrix that can be applied on a vector | 628 // This function returns a translation matrix that can be applied on a vector |
764 // that's in the layer's target surface coordinate, while the position offset is | 629 // that's in the layer's target surface coordinate, while the position offset is |
765 // specified in some ancestor layer's coordinate. | 630 // specified in some ancestor layer's coordinate. |
766 gfx::Transform ComputeSizeDeltaCompensation( | 631 gfx::Transform ComputeSizeDeltaCompensation( |
767 LayerImpl* layer, | 632 LayerImpl* layer, |
768 LayerImpl* container, | 633 LayerImpl* container, |
769 const gfx::Vector2dF& position_offset) { | 634 const gfx::Vector2dF& position_offset) { |
770 gfx::Transform result_transform; | 635 gfx::Transform result_transform; |
771 | 636 |
772 // To apply a translate in the container's layer space, | 637 // To apply a translate in the container's layer space, |
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1139 &layer_to_remove->render_surface()->layer_list(), 0); | 1004 &layer_to_remove->render_surface()->layer_list(), 0); |
1140 MarkLayerWithRenderSurfaceLayerListId(layer_to_remove, 0); | 1005 MarkLayerWithRenderSurfaceLayerListId(layer_to_remove, 0); |
1141 render_surface_layer_list->pop_back(); | 1006 render_surface_layer_list->pop_back(); |
1142 layer_to_remove->ClearRenderSurfaceLayerList(); | 1007 layer_to_remove->ClearRenderSurfaceLayerList(); |
1143 } | 1008 } |
1144 | 1009 |
1145 struct PreCalculateMetaInformationRecursiveData { | 1010 struct PreCalculateMetaInformationRecursiveData { |
1146 size_t num_unclipped_descendants; | 1011 size_t num_unclipped_descendants; |
1147 int num_layer_or_descendants_with_copy_request; | 1012 int num_layer_or_descendants_with_copy_request; |
1148 int num_layer_or_descendants_with_input_handler; | 1013 int num_layer_or_descendants_with_input_handler; |
| 1014 int num_descendants_that_draw_content; |
1149 | 1015 |
1150 PreCalculateMetaInformationRecursiveData() | 1016 PreCalculateMetaInformationRecursiveData() |
1151 : num_unclipped_descendants(0), | 1017 : num_unclipped_descendants(0), |
1152 num_layer_or_descendants_with_copy_request(0), | 1018 num_layer_or_descendants_with_copy_request(0), |
1153 num_layer_or_descendants_with_input_handler(0) {} | 1019 num_layer_or_descendants_with_input_handler(0), |
| 1020 num_descendants_that_draw_content(0) {} |
1154 | 1021 |
1155 void Merge(const PreCalculateMetaInformationRecursiveData& data) { | 1022 void Merge(const PreCalculateMetaInformationRecursiveData& data) { |
1156 num_layer_or_descendants_with_copy_request += | 1023 num_layer_or_descendants_with_copy_request += |
1157 data.num_layer_or_descendants_with_copy_request; | 1024 data.num_layer_or_descendants_with_copy_request; |
1158 num_layer_or_descendants_with_input_handler += | 1025 num_layer_or_descendants_with_input_handler += |
1159 data.num_layer_or_descendants_with_input_handler; | 1026 data.num_layer_or_descendants_with_input_handler; |
1160 num_unclipped_descendants += data.num_unclipped_descendants; | 1027 num_unclipped_descendants += data.num_unclipped_descendants; |
| 1028 num_descendants_that_draw_content += data.num_descendants_that_draw_content; |
1161 } | 1029 } |
1162 }; | 1030 }; |
1163 | 1031 |
1164 static void ValidateRenderSurface(LayerImpl* layer) { | |
1165 // This test verifies that there are no cases where a LayerImpl needs | |
1166 // a render surface, but doesn't have one. | |
1167 if (layer->render_surface()) | |
1168 return; | |
1169 | |
1170 DCHECK(layer->filters().IsEmpty()) << "layer: " << layer->id(); | |
1171 DCHECK(layer->background_filters().IsEmpty()) << "layer: " << layer->id(); | |
1172 DCHECK(!layer->mask_layer()) << "layer: " << layer->id(); | |
1173 DCHECK(!layer->replica_layer()) << "layer: " << layer->id(); | |
1174 DCHECK(!IsRootLayer(layer)) << "layer: " << layer->id(); | |
1175 DCHECK(!layer->is_root_for_isolated_group()) << "layer: " << layer->id(); | |
1176 DCHECK(!layer->HasCopyRequest()) << "layer: " << layer->id(); | |
1177 } | |
1178 | |
1179 static void ValidateRenderSurface(Layer* layer) { | |
1180 } | |
1181 | |
1182 static bool IsMetaInformationRecomputationNeeded(Layer* layer) { | 1032 static bool IsMetaInformationRecomputationNeeded(Layer* layer) { |
1183 return layer->layer_tree_host()->needs_meta_info_recomputation(); | 1033 return layer->layer_tree_host()->needs_meta_info_recomputation(); |
1184 } | 1034 } |
1185 | 1035 |
1186 static void UpdateMetaInformationSequenceNumber(Layer* root_layer) { | 1036 static void UpdateMetaInformationSequenceNumber(Layer* root_layer) { |
1187 root_layer->layer_tree_host()->IncrementMetaInformationSequenceNumber(); | 1037 root_layer->layer_tree_host()->IncrementMetaInformationSequenceNumber(); |
1188 } | 1038 } |
1189 | 1039 |
1190 static void UpdateMetaInformationSequenceNumber(LayerImpl* root_layer) { | 1040 static void UpdateMetaInformationSequenceNumber(LayerImpl* root_layer) { |
1191 } | 1041 } |
1192 | 1042 |
1193 // Recursively walks the layer tree(if needed) to compute any information | 1043 // Recursively walks the layer tree(if needed) to compute any information |
1194 // that is needed before doing the main recursion. | 1044 // that is needed before doing the main recursion. |
1195 static void PreCalculateMetaInformationInternal( | 1045 static void PreCalculateMetaInformationInternal( |
1196 Layer* layer, | 1046 Layer* layer, |
1197 PreCalculateMetaInformationRecursiveData* recursive_data) { | 1047 PreCalculateMetaInformationRecursiveData* recursive_data) { |
1198 ValidateRenderSurface(layer); | |
1199 | |
1200 if (!IsMetaInformationRecomputationNeeded(layer)) { | 1048 if (!IsMetaInformationRecomputationNeeded(layer)) { |
1201 DCHECK(IsRootLayer(layer)); | 1049 DCHECK(IsRootLayer(layer)); |
1202 return; | 1050 return; |
1203 } | 1051 } |
1204 | 1052 |
1205 layer->set_sorted_for_recursion(false); | 1053 layer->set_sorted_for_recursion(false); |
1206 layer->set_layer_or_descendant_is_drawn(false); | 1054 layer->set_layer_or_descendant_is_drawn(false); |
1207 layer->set_visited(false); | 1055 layer->set_visited(false); |
1208 | 1056 |
1209 if (!HasInvertibleOrAnimatedTransform(layer)) { | 1057 if (!HasInvertibleOrAnimatedTransform(layer)) { |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1241 layer->set_num_layer_or_descendant_with_copy_request( | 1089 layer->set_num_layer_or_descendant_with_copy_request( |
1242 recursive_data->num_layer_or_descendants_with_copy_request); | 1090 recursive_data->num_layer_or_descendants_with_copy_request); |
1243 | 1091 |
1244 if (IsRootLayer(layer)) | 1092 if (IsRootLayer(layer)) |
1245 layer->layer_tree_host()->SetNeedsMetaInfoRecomputation(false); | 1093 layer->layer_tree_host()->SetNeedsMetaInfoRecomputation(false); |
1246 } | 1094 } |
1247 | 1095 |
1248 static void PreCalculateMetaInformationInternal( | 1096 static void PreCalculateMetaInformationInternal( |
1249 LayerImpl* layer, | 1097 LayerImpl* layer, |
1250 PreCalculateMetaInformationRecursiveData* recursive_data) { | 1098 PreCalculateMetaInformationRecursiveData* recursive_data) { |
1251 ValidateRenderSurface(layer); | |
1252 | |
1253 layer->set_sorted_for_recursion(false); | 1099 layer->set_sorted_for_recursion(false); |
1254 layer->draw_properties().has_child_with_a_scroll_parent = false; | 1100 layer->draw_properties().has_child_with_a_scroll_parent = false; |
1255 layer->set_layer_or_descendant_is_drawn(false); | 1101 layer->set_layer_or_descendant_is_drawn(false); |
1256 layer->set_visited(false); | 1102 layer->set_visited(false); |
1257 | 1103 |
1258 if (!HasInvertibleOrAnimatedTransform(layer)) { | 1104 if (!HasInvertibleOrAnimatedTransform(layer)) { |
1259 // Layers with singular transforms should not be drawn, the whole subtree | 1105 // Layers with singular transforms should not be drawn, the whole subtree |
1260 // can be skipped. | 1106 // can be skipped. |
1261 return; | 1107 return; |
1262 } | 1108 } |
(...skipping 26 matching lines...) Expand all Loading... |
1289 recursive_data->num_layer_or_descendants_with_input_handler++; | 1135 recursive_data->num_layer_or_descendants_with_input_handler++; |
1290 | 1136 |
1291 layer->draw_properties().num_unclipped_descendants = | 1137 layer->draw_properties().num_unclipped_descendants = |
1292 recursive_data->num_unclipped_descendants; | 1138 recursive_data->num_unclipped_descendants; |
1293 layer->set_layer_or_descendant_has_input_handler( | 1139 layer->set_layer_or_descendant_has_input_handler( |
1294 (recursive_data->num_layer_or_descendants_with_input_handler != 0)); | 1140 (recursive_data->num_layer_or_descendants_with_input_handler != 0)); |
1295 // TODO(enne): this should be synced from the main thread, so is only | 1141 // TODO(enne): this should be synced from the main thread, so is only |
1296 // for tests constructing layers on the compositor thread. | 1142 // for tests constructing layers on the compositor thread. |
1297 layer->set_num_layer_or_descendant_with_copy_request( | 1143 layer->set_num_layer_or_descendant_with_copy_request( |
1298 recursive_data->num_layer_or_descendants_with_copy_request); | 1144 recursive_data->num_layer_or_descendants_with_copy_request); |
| 1145 layer->SetNumDescendantsThatDrawContent( |
| 1146 recursive_data->num_descendants_that_draw_content); |
| 1147 |
| 1148 if (layer->DrawsContent()) |
| 1149 recursive_data->num_descendants_that_draw_content++; |
1299 } | 1150 } |
1300 | 1151 |
1301 void LayerTreeHostCommon::PreCalculateMetaInformation(Layer* root_layer) { | 1152 void LayerTreeHostCommon::PreCalculateMetaInformation(Layer* root_layer) { |
1302 PreCalculateMetaInformationRecursiveData recursive_data; | 1153 PreCalculateMetaInformationRecursiveData recursive_data; |
1303 PreCalculateMetaInformationInternal(root_layer, &recursive_data); | 1154 PreCalculateMetaInformationInternal(root_layer, &recursive_data); |
1304 } | 1155 } |
1305 | 1156 |
1306 void LayerTreeHostCommon::PreCalculateMetaInformationForTesting( | 1157 void LayerTreeHostCommon::PreCalculateMetaInformationForTesting( |
1307 LayerImpl* root_layer) { | 1158 LayerImpl* root_layer) { |
1308 PreCalculateMetaInformationRecursiveData recursive_data; | 1159 PreCalculateMetaInformationRecursiveData recursive_data; |
(...skipping 901 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2210 device_viewport_rect; | 2061 device_viewport_rect; |
2211 data_for_recursion->maximum_animation_contents_scale = 0.f; | 2062 data_for_recursion->maximum_animation_contents_scale = 0.f; |
2212 data_for_recursion->starting_animation_contents_scale = 0.f; | 2063 data_for_recursion->starting_animation_contents_scale = 0.f; |
2213 data_for_recursion->ancestor_is_animating_scale = false; | 2064 data_for_recursion->ancestor_is_animating_scale = false; |
2214 data_for_recursion->ancestor_clips_subtree = true; | 2065 data_for_recursion->ancestor_clips_subtree = true; |
2215 data_for_recursion->in_subtree_of_page_scale_layer = false; | 2066 data_for_recursion->in_subtree_of_page_scale_layer = false; |
2216 data_for_recursion->subtree_can_use_lcd_text = inputs.can_use_lcd_text; | 2067 data_for_recursion->subtree_can_use_lcd_text = inputs.can_use_lcd_text; |
2217 data_for_recursion->subtree_is_visible_from_ancestor = true; | 2068 data_for_recursion->subtree_is_visible_from_ancestor = true; |
2218 } | 2069 } |
2219 | 2070 |
2220 void LayerTreeHostCommon::UpdateRenderSurface( | |
2221 Layer* layer, | |
2222 bool can_render_to_separate_surface, | |
2223 gfx::Transform* transform, | |
2224 bool* draw_transform_is_axis_aligned) { | |
2225 bool preserves_2d_axis_alignment = | |
2226 transform->Preserves2dAxisAlignment() && *draw_transform_is_axis_aligned; | |
2227 if (IsRootLayer(layer) || (can_render_to_separate_surface && | |
2228 SubtreeShouldRenderToSeparateSurface( | |
2229 layer, preserves_2d_axis_alignment))) { | |
2230 // We reset the transform here so that any axis-changing transforms | |
2231 // will now be relative to this RenderSurface. | |
2232 transform->MakeIdentity(); | |
2233 *draw_transform_is_axis_aligned = true; | |
2234 layer->SetHasRenderSurface(true); | |
2235 return; | |
2236 } | |
2237 layer->SetHasRenderSurface(false); | |
2238 } | |
2239 | |
2240 void LayerTreeHostCommon::UpdateRenderSurfaces( | |
2241 Layer* layer, | |
2242 bool can_render_to_separate_surface, | |
2243 const gfx::Transform& parent_transform, | |
2244 bool draw_transform_is_axis_aligned) { | |
2245 gfx::Transform transform_for_children = layer->transform(); | |
2246 transform_for_children *= parent_transform; | |
2247 draw_transform_is_axis_aligned &= layer->AnimationsPreserveAxisAlignment(); | |
2248 UpdateRenderSurface(layer, can_render_to_separate_surface, | |
2249 &transform_for_children, &draw_transform_is_axis_aligned); | |
2250 | |
2251 for (size_t i = 0; i < layer->children().size(); ++i) { | |
2252 UpdateRenderSurfaces(layer->children()[i].get(), | |
2253 can_render_to_separate_surface, transform_for_children, | |
2254 draw_transform_is_axis_aligned); | |
2255 } | |
2256 } | |
2257 | 2071 |
2258 static bool ApproximatelyEqual(const gfx::Rect& r1, const gfx::Rect& r2) { | 2072 static bool ApproximatelyEqual(const gfx::Rect& r1, const gfx::Rect& r2) { |
2259 // TODO(vollick): This tolerance should be lower: crbug.com/471786 | 2073 // TODO(vollick): This tolerance should be lower: crbug.com/471786 |
2260 static const int tolerance = 1; | 2074 static const int tolerance = 1; |
2261 | 2075 |
2262 return std::abs(r1.x() - r2.x()) <= tolerance && | 2076 return std::abs(r1.x() - r2.x()) <= tolerance && |
2263 std::abs(r1.y() - r2.y()) <= tolerance && | 2077 std::abs(r1.y() - r2.y()) <= tolerance && |
2264 std::abs(r1.right() - r2.right()) <= tolerance && | 2078 std::abs(r1.right() - r2.right()) <= tolerance && |
2265 std::abs(r1.bottom() - r2.bottom()) <= tolerance; | 2079 std::abs(r1.bottom() - r2.bottom()) <= tolerance; |
2266 } | 2080 } |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2345 } | 2159 } |
2346 | 2160 |
2347 void VerifyPropertyTreeValuesForLayer(LayerImpl* current_layer, | 2161 void VerifyPropertyTreeValuesForLayer(LayerImpl* current_layer, |
2348 PropertyTrees* property_trees, | 2162 PropertyTrees* property_trees, |
2349 bool layers_always_allowed_lcd_text, | 2163 bool layers_always_allowed_lcd_text, |
2350 bool can_use_lcd_text) { | 2164 bool can_use_lcd_text) { |
2351 DrawProperties draw_properties; | 2165 DrawProperties draw_properties; |
2352 ComputeLayerDrawPropertiesUsingPropertyTrees( | 2166 ComputeLayerDrawPropertiesUsingPropertyTrees( |
2353 current_layer, property_trees, layers_always_allowed_lcd_text, | 2167 current_layer, property_trees, layers_always_allowed_lcd_text, |
2354 can_use_lcd_text, &draw_properties); | 2168 can_use_lcd_text, &draw_properties); |
2355 | |
2356 const bool visible_rects_match = ApproximatelyEqual( | 2169 const bool visible_rects_match = ApproximatelyEqual( |
2357 current_layer->visible_layer_rect(), draw_properties.visible_layer_rect); | 2170 current_layer->visible_layer_rect(), draw_properties.visible_layer_rect); |
2358 CHECK(visible_rects_match) | 2171 CHECK(visible_rects_match) |
2359 << "expected: " << current_layer->visible_layer_rect().ToString() | 2172 << "expected: " << current_layer->visible_layer_rect().ToString() |
2360 << " actual: " << draw_properties.visible_layer_rect.ToString(); | 2173 << " actual: " << draw_properties.visible_layer_rect.ToString(); |
2361 | 2174 |
2362 const bool draw_transforms_match = ApproximatelyEqual( | 2175 const bool draw_transforms_match = ApproximatelyEqual( |
2363 current_layer->draw_properties().target_space_transform, | 2176 current_layer->draw_properties().target_space_transform, |
2364 draw_properties.target_space_transform); | 2177 draw_properties.target_space_transform); |
2365 CHECK(draw_transforms_match) | 2178 CHECK(draw_transforms_match) |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2427 if (!IsRootLayer(layer) && SubtreeShouldBeSkipped(layer, layer_is_drawn)) { | 2240 if (!IsRootLayer(layer) && SubtreeShouldBeSkipped(layer, layer_is_drawn)) { |
2428 layer->draw_properties().render_target = nullptr; | 2241 layer->draw_properties().render_target = nullptr; |
2429 return; | 2242 return; |
2430 } | 2243 } |
2431 | 2244 |
2432 bool render_to_separate_surface = | 2245 bool render_to_separate_surface = |
2433 IsRootLayer(layer) || | 2246 IsRootLayer(layer) || |
2434 (can_render_to_separate_surface && layer->render_surface()); | 2247 (can_render_to_separate_surface && layer->render_surface()); |
2435 | 2248 |
2436 if (render_to_separate_surface) { | 2249 if (render_to_separate_surface) { |
2437 DCHECK(layer->render_surface()); | 2250 DCHECK(layer->render_surface()) << IsRootLayer(layer) |
| 2251 << can_render_to_separate_surface |
| 2252 << layer->has_render_surface(); |
2438 layer->draw_properties().render_target = layer; | 2253 layer->draw_properties().render_target = layer; |
2439 | 2254 |
2440 if (layer->mask_layer()) | 2255 if (layer->mask_layer()) |
2441 layer->mask_layer()->draw_properties().render_target = layer; | 2256 layer->mask_layer()->draw_properties().render_target = layer; |
2442 | 2257 |
2443 if (layer->replica_layer() && layer->replica_layer()->mask_layer()) | 2258 if (layer->replica_layer() && layer->replica_layer()->mask_layer()) |
2444 layer->replica_layer()->mask_layer()->draw_properties().render_target = | 2259 layer->replica_layer()->mask_layer()->draw_properties().render_target = |
2445 layer; | 2260 layer; |
2446 | 2261 |
2447 } else { | 2262 } else { |
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2738 } | 2553 } |
2739 | 2554 |
2740 void CalculateDrawPropertiesAndVerify( | 2555 void CalculateDrawPropertiesAndVerify( |
2741 LayerTreeHostCommon::CalcDrawPropsImplInputs* inputs, | 2556 LayerTreeHostCommon::CalcDrawPropsImplInputs* inputs, |
2742 PropertyTreeOption property_tree_option) { | 2557 PropertyTreeOption property_tree_option) { |
2743 inputs->render_surface_layer_list->clear(); | 2558 inputs->render_surface_layer_list->clear(); |
2744 | 2559 |
2745 UpdateMetaInformationSequenceNumber(inputs->root_layer); | 2560 UpdateMetaInformationSequenceNumber(inputs->root_layer); |
2746 PreCalculateMetaInformationRecursiveData recursive_data; | 2561 PreCalculateMetaInformationRecursiveData recursive_data; |
2747 PreCalculateMetaInformationInternal(inputs->root_layer, &recursive_data); | 2562 PreCalculateMetaInformationInternal(inputs->root_layer, &recursive_data); |
2748 | |
2749 const bool should_measure_property_tree_performance = | 2563 const bool should_measure_property_tree_performance = |
2750 inputs->verify_property_trees && | 2564 inputs->verify_property_trees && |
2751 (property_tree_option == BUILD_PROPERTY_TREES_IF_NEEDED); | 2565 (property_tree_option == BUILD_PROPERTY_TREES_IF_NEEDED); |
2752 | 2566 |
2753 LayerImplList visible_layer_list; | 2567 LayerImplList visible_layer_list; |
2754 if (inputs->verify_property_trees || inputs->use_property_trees) { | 2568 if (inputs->verify_property_trees || inputs->use_property_trees) { |
2755 switch (property_tree_option) { | 2569 switch (property_tree_option) { |
2756 case BUILD_PROPERTY_TREES_IF_NEEDED: { | 2570 case BUILD_PROPERTY_TREES_IF_NEEDED: { |
2757 // The translation from layer to property trees is an intermediate | 2571 // The translation from layer to property trees is an intermediate |
2758 // state. We will eventually get these data passed directly to the | 2572 // state. We will eventually get these data passed directly to the |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2814 } | 2628 } |
2815 } | 2629 } |
2816 } | 2630 } |
2817 | 2631 |
2818 if (should_measure_property_tree_performance) { | 2632 if (should_measure_property_tree_performance) { |
2819 TRACE_EVENT_BEGIN0(TRACE_DISABLED_BY_DEFAULT("cc.debug.cdp-perf"), | 2633 TRACE_EVENT_BEGIN0(TRACE_DISABLED_BY_DEFAULT("cc.debug.cdp-perf"), |
2820 "LayerTreeHostCommon::CalculateDrawProperties"); | 2634 "LayerTreeHostCommon::CalculateDrawProperties"); |
2821 } | 2635 } |
2822 | 2636 |
2823 std::vector<AccumulatedSurfaceState> accumulated_surface_state; | 2637 std::vector<AccumulatedSurfaceState> accumulated_surface_state; |
| 2638 DCHECK(inputs->can_render_to_separate_surface == |
| 2639 inputs->property_trees->non_root_surfaces_enabled); |
2824 CalculateRenderTarget(inputs); | 2640 CalculateRenderTarget(inputs); |
2825 if (inputs->use_property_trees) { | 2641 if (inputs->use_property_trees) { |
2826 for (LayerImpl* layer : visible_layer_list) { | 2642 for (LayerImpl* layer : visible_layer_list) { |
2827 ComputeLayerDrawPropertiesUsingPropertyTrees( | 2643 ComputeLayerDrawPropertiesUsingPropertyTrees( |
2828 layer, inputs->property_trees, inputs->layers_always_allowed_lcd_text, | 2644 layer, inputs->property_trees, inputs->layers_always_allowed_lcd_text, |
2829 inputs->can_use_lcd_text, &layer->draw_properties()); | 2645 inputs->can_use_lcd_text, &layer->draw_properties()); |
2830 if (layer->mask_layer()) | 2646 if (layer->mask_layer()) |
2831 ComputeMaskLayerDrawProperties(layer, layer->mask_layer()); | 2647 ComputeMaskLayerDrawProperties(layer, layer->mask_layer()); |
2832 LayerImpl* replica_mask_layer = layer->replica_layer() | 2648 LayerImpl* replica_mask_layer = layer->replica_layer() |
2833 ? layer->replica_layer()->mask_layer() | 2649 ? layer->replica_layer()->mask_layer() |
(...skipping 21 matching lines...) Expand all Loading... |
2855 | 2671 |
2856 // A root layer render_surface should always exist after | 2672 // A root layer render_surface should always exist after |
2857 // CalculateDrawProperties. | 2673 // CalculateDrawProperties. |
2858 DCHECK(inputs->root_layer->render_surface()); | 2674 DCHECK(inputs->root_layer->render_surface()); |
2859 } | 2675 } |
2860 | 2676 |
2861 void LayerTreeHostCommon::CalculateDrawProperties( | 2677 void LayerTreeHostCommon::CalculateDrawProperties( |
2862 CalcDrawPropsMainInputs* inputs) { | 2678 CalcDrawPropsMainInputs* inputs) { |
2863 LayerList update_layer_list; | 2679 LayerList update_layer_list; |
2864 bool can_render_to_separate_surface = true; | 2680 bool can_render_to_separate_surface = true; |
2865 UpdateRenderSurfaces(inputs->root_layer, can_render_to_separate_surface, | |
2866 gfx::Transform(), false); | |
2867 PropertyTrees* property_trees = | 2681 PropertyTrees* property_trees = |
2868 inputs->root_layer->layer_tree_host()->property_trees(); | 2682 inputs->root_layer->layer_tree_host()->property_trees(); |
2869 BuildPropertyTreesAndComputeVisibleRects( | 2683 BuildPropertyTreesAndComputeVisibleRects( |
2870 inputs->root_layer, inputs->page_scale_layer, | 2684 inputs->root_layer, inputs->page_scale_layer, |
2871 inputs->inner_viewport_scroll_layer, inputs->outer_viewport_scroll_layer, | 2685 inputs->inner_viewport_scroll_layer, inputs->outer_viewport_scroll_layer, |
2872 inputs->page_scale_factor, inputs->device_scale_factor, | 2686 inputs->page_scale_factor, inputs->device_scale_factor, |
2873 gfx::Rect(inputs->device_viewport_size), inputs->device_transform, | 2687 gfx::Rect(inputs->device_viewport_size), inputs->device_transform, |
2874 can_render_to_separate_surface, property_trees, &update_layer_list); | 2688 can_render_to_separate_surface, property_trees, &update_layer_list); |
2875 } | 2689 } |
2876 | 2690 |
2877 void LayerTreeHostCommon::CalculateDrawProperties( | 2691 void LayerTreeHostCommon::CalculateDrawProperties( |
2878 CalcDrawPropsImplInputs* inputs) { | 2692 CalcDrawPropsImplInputs* inputs) { |
2879 CalculateDrawPropertiesAndVerify(inputs, DONT_BUILD_PROPERTY_TREES); | 2693 CalculateDrawPropertiesAndVerify(inputs, DONT_BUILD_PROPERTY_TREES); |
2880 } | 2694 } |
2881 | 2695 |
2882 void LayerTreeHostCommon::CalculateDrawProperties( | 2696 void LayerTreeHostCommon::CalculateDrawProperties( |
2883 CalcDrawPropsImplInputsForTesting* inputs) { | 2697 CalcDrawPropsImplInputsForTesting* inputs) { |
2884 CalculateDrawPropertiesAndVerify(inputs, BUILD_PROPERTY_TREES_IF_NEEDED); | 2698 CalculateDrawPropertiesAndVerify(inputs, BUILD_PROPERTY_TREES_IF_NEEDED); |
2885 } | 2699 } |
2886 | 2700 |
2887 PropertyTrees* GetPropertyTrees(Layer* layer) { | 2701 PropertyTrees* GetPropertyTrees(Layer* layer) { |
2888 return layer->layer_tree_host()->property_trees(); | 2702 return layer->layer_tree_host()->property_trees(); |
2889 } | 2703 } |
2890 | 2704 |
2891 PropertyTrees* GetPropertyTrees(LayerImpl* layer) { | 2705 PropertyTrees* GetPropertyTrees(LayerImpl* layer) { |
2892 return layer->layer_tree_impl()->property_trees(); | 2706 return layer->layer_tree_impl()->property_trees(); |
2893 } | 2707 } |
2894 | 2708 |
2895 } // namespace cc | 2709 } // namespace cc |
OLD | NEW |