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

Side by Side Diff: cc/trees/layer_tree_host_common.cc

Issue 1505243003: Revert of Create RenderSurface on Effect Tree (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@alwayspt
Patch Set: rebase Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/trees/layer_tree_host_common.h ('k') | cc/trees/layer_tree_host_common_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/trees/layer_tree_host_common.h" 5 #include "cc/trees/layer_tree_host_common.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/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
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
628 // This function returns a translation matrix that can be applied on a vector 763 // This function returns a translation matrix that can be applied on a vector
629 // that's in the layer's target surface coordinate, while the position offset is 764 // that's in the layer's target surface coordinate, while the position offset is
630 // specified in some ancestor layer's coordinate. 765 // specified in some ancestor layer's coordinate.
631 gfx::Transform ComputeSizeDeltaCompensation( 766 gfx::Transform ComputeSizeDeltaCompensation(
632 LayerImpl* layer, 767 LayerImpl* layer,
633 LayerImpl* container, 768 LayerImpl* container,
634 const gfx::Vector2dF& position_offset) { 769 const gfx::Vector2dF& position_offset) {
635 gfx::Transform result_transform; 770 gfx::Transform result_transform;
636 771
637 // To apply a translate in the container's layer space, 772 // To apply a translate in the container's layer space,
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after
1004 &layer_to_remove->render_surface()->layer_list(), 0); 1139 &layer_to_remove->render_surface()->layer_list(), 0);
1005 MarkLayerWithRenderSurfaceLayerListId(layer_to_remove, 0); 1140 MarkLayerWithRenderSurfaceLayerListId(layer_to_remove, 0);
1006 render_surface_layer_list->pop_back(); 1141 render_surface_layer_list->pop_back();
1007 layer_to_remove->ClearRenderSurfaceLayerList(); 1142 layer_to_remove->ClearRenderSurfaceLayerList();
1008 } 1143 }
1009 1144
1010 struct PreCalculateMetaInformationRecursiveData { 1145 struct PreCalculateMetaInformationRecursiveData {
1011 size_t num_unclipped_descendants; 1146 size_t num_unclipped_descendants;
1012 int num_layer_or_descendants_with_copy_request; 1147 int num_layer_or_descendants_with_copy_request;
1013 int num_layer_or_descendants_with_input_handler; 1148 int num_layer_or_descendants_with_input_handler;
1014 int num_descendants_that_draw_content;
1015 1149
1016 PreCalculateMetaInformationRecursiveData() 1150 PreCalculateMetaInformationRecursiveData()
1017 : num_unclipped_descendants(0), 1151 : num_unclipped_descendants(0),
1018 num_layer_or_descendants_with_copy_request(0), 1152 num_layer_or_descendants_with_copy_request(0),
1019 num_layer_or_descendants_with_input_handler(0), 1153 num_layer_or_descendants_with_input_handler(0) {}
1020 num_descendants_that_draw_content(0) {}
1021 1154
1022 void Merge(const PreCalculateMetaInformationRecursiveData& data) { 1155 void Merge(const PreCalculateMetaInformationRecursiveData& data) {
1023 num_layer_or_descendants_with_copy_request += 1156 num_layer_or_descendants_with_copy_request +=
1024 data.num_layer_or_descendants_with_copy_request; 1157 data.num_layer_or_descendants_with_copy_request;
1025 num_layer_or_descendants_with_input_handler += 1158 num_layer_or_descendants_with_input_handler +=
1026 data.num_layer_or_descendants_with_input_handler; 1159 data.num_layer_or_descendants_with_input_handler;
1027 num_unclipped_descendants += data.num_unclipped_descendants; 1160 num_unclipped_descendants += data.num_unclipped_descendants;
1028 num_descendants_that_draw_content += data.num_descendants_that_draw_content;
1029 } 1161 }
1030 }; 1162 };
1031 1163
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
1032 static bool IsMetaInformationRecomputationNeeded(Layer* layer) { 1181 static bool IsMetaInformationRecomputationNeeded(Layer* layer) {
1033 return layer->layer_tree_host()->needs_meta_info_recomputation(); 1182 return layer->layer_tree_host()->needs_meta_info_recomputation();
1034 } 1183 }
1035 1184
1036 static void UpdateMetaInformationSequenceNumber(Layer* root_layer) { 1185 static void UpdateMetaInformationSequenceNumber(Layer* root_layer) {
1037 root_layer->layer_tree_host()->IncrementMetaInformationSequenceNumber(); 1186 root_layer->layer_tree_host()->IncrementMetaInformationSequenceNumber();
1038 } 1187 }
1039 1188
1040 static void UpdateMetaInformationSequenceNumber(LayerImpl* root_layer) { 1189 static void UpdateMetaInformationSequenceNumber(LayerImpl* root_layer) {
1041 } 1190 }
1042 1191
1043 // Recursively walks the layer tree(if needed) to compute any information 1192 // Recursively walks the layer tree(if needed) to compute any information
1044 // that is needed before doing the main recursion. 1193 // that is needed before doing the main recursion.
1045 static void PreCalculateMetaInformationInternal( 1194 static void PreCalculateMetaInformationInternal(
1046 Layer* layer, 1195 Layer* layer,
1047 PreCalculateMetaInformationRecursiveData* recursive_data) { 1196 PreCalculateMetaInformationRecursiveData* recursive_data) {
1197 ValidateRenderSurface(layer);
1198
1048 if (!IsMetaInformationRecomputationNeeded(layer)) { 1199 if (!IsMetaInformationRecomputationNeeded(layer)) {
1049 DCHECK(IsRootLayer(layer)); 1200 DCHECK(IsRootLayer(layer));
1050 return; 1201 return;
1051 } 1202 }
1052 1203
1053 layer->set_sorted_for_recursion(false); 1204 layer->set_sorted_for_recursion(false);
1054 layer->set_layer_or_descendant_is_drawn(false); 1205 layer->set_layer_or_descendant_is_drawn(false);
1055 layer->set_visited(false); 1206 layer->set_visited(false);
1056 1207
1057 if (!HasInvertibleOrAnimatedTransform(layer)) { 1208 if (!HasInvertibleOrAnimatedTransform(layer)) {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1089 layer->set_num_layer_or_descendant_with_copy_request( 1240 layer->set_num_layer_or_descendant_with_copy_request(
1090 recursive_data->num_layer_or_descendants_with_copy_request); 1241 recursive_data->num_layer_or_descendants_with_copy_request);
1091 1242
1092 if (IsRootLayer(layer)) 1243 if (IsRootLayer(layer))
1093 layer->layer_tree_host()->SetNeedsMetaInfoRecomputation(false); 1244 layer->layer_tree_host()->SetNeedsMetaInfoRecomputation(false);
1094 } 1245 }
1095 1246
1096 static void PreCalculateMetaInformationInternal( 1247 static void PreCalculateMetaInformationInternal(
1097 LayerImpl* layer, 1248 LayerImpl* layer,
1098 PreCalculateMetaInformationRecursiveData* recursive_data) { 1249 PreCalculateMetaInformationRecursiveData* recursive_data) {
1250 ValidateRenderSurface(layer);
1251
1099 layer->set_sorted_for_recursion(false); 1252 layer->set_sorted_for_recursion(false);
1100 layer->draw_properties().has_child_with_a_scroll_parent = false; 1253 layer->draw_properties().has_child_with_a_scroll_parent = false;
1101 layer->set_layer_or_descendant_is_drawn(false); 1254 layer->set_layer_or_descendant_is_drawn(false);
1102 layer->set_visited(false); 1255 layer->set_visited(false);
1103 1256
1104 if (!HasInvertibleOrAnimatedTransform(layer)) { 1257 if (!HasInvertibleOrAnimatedTransform(layer)) {
1105 // Layers with singular transforms should not be drawn, the whole subtree 1258 // Layers with singular transforms should not be drawn, the whole subtree
1106 // can be skipped. 1259 // can be skipped.
1107 return; 1260 return;
1108 } 1261 }
(...skipping 26 matching lines...) Expand all
1135 recursive_data->num_layer_or_descendants_with_input_handler++; 1288 recursive_data->num_layer_or_descendants_with_input_handler++;
1136 1289
1137 layer->draw_properties().num_unclipped_descendants = 1290 layer->draw_properties().num_unclipped_descendants =
1138 recursive_data->num_unclipped_descendants; 1291 recursive_data->num_unclipped_descendants;
1139 layer->set_layer_or_descendant_has_input_handler( 1292 layer->set_layer_or_descendant_has_input_handler(
1140 (recursive_data->num_layer_or_descendants_with_input_handler != 0)); 1293 (recursive_data->num_layer_or_descendants_with_input_handler != 0));
1141 // TODO(enne): this should be synced from the main thread, so is only 1294 // TODO(enne): this should be synced from the main thread, so is only
1142 // for tests constructing layers on the compositor thread. 1295 // for tests constructing layers on the compositor thread.
1143 layer->set_num_layer_or_descendant_with_copy_request( 1296 layer->set_num_layer_or_descendant_with_copy_request(
1144 recursive_data->num_layer_or_descendants_with_copy_request); 1297 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++;
1150 } 1298 }
1151 1299
1152 void LayerTreeHostCommon::PreCalculateMetaInformation(Layer* root_layer) { 1300 void LayerTreeHostCommon::PreCalculateMetaInformation(Layer* root_layer) {
1153 PreCalculateMetaInformationRecursiveData recursive_data; 1301 PreCalculateMetaInformationRecursiveData recursive_data;
1154 PreCalculateMetaInformationInternal(root_layer, &recursive_data); 1302 PreCalculateMetaInformationInternal(root_layer, &recursive_data);
1155 } 1303 }
1156 1304
1157 void LayerTreeHostCommon::PreCalculateMetaInformationForTesting( 1305 void LayerTreeHostCommon::PreCalculateMetaInformationForTesting(
1158 LayerImpl* root_layer) { 1306 LayerImpl* root_layer) {
1159 PreCalculateMetaInformationRecursiveData recursive_data; 1307 PreCalculateMetaInformationRecursiveData recursive_data;
(...skipping 901 matching lines...) Expand 10 before | Expand all | Expand 10 after
2061 device_viewport_rect; 2209 device_viewport_rect;
2062 data_for_recursion->maximum_animation_contents_scale = 0.f; 2210 data_for_recursion->maximum_animation_contents_scale = 0.f;
2063 data_for_recursion->starting_animation_contents_scale = 0.f; 2211 data_for_recursion->starting_animation_contents_scale = 0.f;
2064 data_for_recursion->ancestor_is_animating_scale = false; 2212 data_for_recursion->ancestor_is_animating_scale = false;
2065 data_for_recursion->ancestor_clips_subtree = true; 2213 data_for_recursion->ancestor_clips_subtree = true;
2066 data_for_recursion->in_subtree_of_page_scale_layer = false; 2214 data_for_recursion->in_subtree_of_page_scale_layer = false;
2067 data_for_recursion->subtree_can_use_lcd_text = inputs.can_use_lcd_text; 2215 data_for_recursion->subtree_can_use_lcd_text = inputs.can_use_lcd_text;
2068 data_for_recursion->subtree_is_visible_from_ancestor = true; 2216 data_for_recursion->subtree_is_visible_from_ancestor = true;
2069 } 2217 }
2070 2218
2219 void LayerTreeHostCommon::UpdateRenderSurface(
2220 Layer* layer,
2221 bool can_render_to_separate_surface,
2222 gfx::Transform* transform,
2223 bool* draw_transform_is_axis_aligned) {
2224 bool preserves_2d_axis_alignment =
2225 transform->Preserves2dAxisAlignment() && *draw_transform_is_axis_aligned;
2226 if (IsRootLayer(layer) || (can_render_to_separate_surface &&
2227 SubtreeShouldRenderToSeparateSurface(
2228 layer, preserves_2d_axis_alignment))) {
2229 // We reset the transform here so that any axis-changing transforms
2230 // will now be relative to this RenderSurface.
2231 transform->MakeIdentity();
2232 *draw_transform_is_axis_aligned = true;
2233 layer->SetHasRenderSurface(true);
2234 return;
2235 }
2236 layer->SetHasRenderSurface(false);
2237 }
2238
2239 void LayerTreeHostCommon::UpdateRenderSurfaces(
2240 Layer* layer,
2241 bool can_render_to_separate_surface,
2242 const gfx::Transform& parent_transform,
2243 bool draw_transform_is_axis_aligned) {
2244 gfx::Transform transform_for_children = layer->transform();
2245 transform_for_children *= parent_transform;
2246 draw_transform_is_axis_aligned &= layer->AnimationsPreserveAxisAlignment();
2247 UpdateRenderSurface(layer, can_render_to_separate_surface,
2248 &transform_for_children, &draw_transform_is_axis_aligned);
2249
2250 for (size_t i = 0; i < layer->children().size(); ++i) {
2251 UpdateRenderSurfaces(layer->children()[i].get(),
2252 can_render_to_separate_surface, transform_for_children,
2253 draw_transform_is_axis_aligned);
2254 }
2255 }
2071 2256
2072 static bool ApproximatelyEqual(const gfx::Rect& r1, const gfx::Rect& r2) { 2257 static bool ApproximatelyEqual(const gfx::Rect& r1, const gfx::Rect& r2) {
2073 // TODO(vollick): This tolerance should be lower: crbug.com/471786 2258 // TODO(vollick): This tolerance should be lower: crbug.com/471786
2074 static const int tolerance = 1; 2259 static const int tolerance = 1;
2075 2260
2076 return std::abs(r1.x() - r2.x()) <= tolerance && 2261 return std::abs(r1.x() - r2.x()) <= tolerance &&
2077 std::abs(r1.y() - r2.y()) <= tolerance && 2262 std::abs(r1.y() - r2.y()) <= tolerance &&
2078 std::abs(r1.right() - r2.right()) <= tolerance && 2263 std::abs(r1.right() - r2.right()) <= tolerance &&
2079 std::abs(r1.bottom() - r2.bottom()) <= tolerance; 2264 std::abs(r1.bottom() - r2.bottom()) <= tolerance;
2080 } 2265 }
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
2159 } 2344 }
2160 2345
2161 void VerifyPropertyTreeValuesForLayer(LayerImpl* current_layer, 2346 void VerifyPropertyTreeValuesForLayer(LayerImpl* current_layer,
2162 PropertyTrees* property_trees, 2347 PropertyTrees* property_trees,
2163 bool layers_always_allowed_lcd_text, 2348 bool layers_always_allowed_lcd_text,
2164 bool can_use_lcd_text) { 2349 bool can_use_lcd_text) {
2165 DrawProperties draw_properties; 2350 DrawProperties draw_properties;
2166 ComputeLayerDrawPropertiesUsingPropertyTrees( 2351 ComputeLayerDrawPropertiesUsingPropertyTrees(
2167 current_layer, property_trees, layers_always_allowed_lcd_text, 2352 current_layer, property_trees, layers_always_allowed_lcd_text,
2168 can_use_lcd_text, &draw_properties); 2353 can_use_lcd_text, &draw_properties);
2354
2169 const bool visible_rects_match = ApproximatelyEqual( 2355 const bool visible_rects_match = ApproximatelyEqual(
2170 current_layer->visible_layer_rect(), draw_properties.visible_layer_rect); 2356 current_layer->visible_layer_rect(), draw_properties.visible_layer_rect);
2171 CHECK(visible_rects_match) 2357 CHECK(visible_rects_match)
2172 << "expected: " << current_layer->visible_layer_rect().ToString() 2358 << "expected: " << current_layer->visible_layer_rect().ToString()
2173 << " actual: " << draw_properties.visible_layer_rect.ToString(); 2359 << " actual: " << draw_properties.visible_layer_rect.ToString();
2174 2360
2175 const bool draw_transforms_match = ApproximatelyEqual( 2361 const bool draw_transforms_match = ApproximatelyEqual(
2176 current_layer->draw_properties().target_space_transform, 2362 current_layer->draw_properties().target_space_transform,
2177 draw_properties.target_space_transform); 2363 draw_properties.target_space_transform);
2178 CHECK(draw_transforms_match) 2364 CHECK(draw_transforms_match)
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
2240 if (!IsRootLayer(layer) && SubtreeShouldBeSkipped(layer, layer_is_drawn)) { 2426 if (!IsRootLayer(layer) && SubtreeShouldBeSkipped(layer, layer_is_drawn)) {
2241 layer->draw_properties().render_target = nullptr; 2427 layer->draw_properties().render_target = nullptr;
2242 return; 2428 return;
2243 } 2429 }
2244 2430
2245 bool render_to_separate_surface = 2431 bool render_to_separate_surface =
2246 IsRootLayer(layer) || 2432 IsRootLayer(layer) ||
2247 (can_render_to_separate_surface && layer->render_surface()); 2433 (can_render_to_separate_surface && layer->render_surface());
2248 2434
2249 if (render_to_separate_surface) { 2435 if (render_to_separate_surface) {
2250 DCHECK(layer->render_surface()) << IsRootLayer(layer) 2436 DCHECK(layer->render_surface());
2251 << can_render_to_separate_surface
2252 << layer->has_render_surface();
2253 layer->draw_properties().render_target = layer; 2437 layer->draw_properties().render_target = layer;
2254 2438
2255 if (layer->mask_layer()) 2439 if (layer->mask_layer())
2256 layer->mask_layer()->draw_properties().render_target = layer; 2440 layer->mask_layer()->draw_properties().render_target = layer;
2257 2441
2258 if (layer->replica_layer() && layer->replica_layer()->mask_layer()) 2442 if (layer->replica_layer() && layer->replica_layer()->mask_layer())
2259 layer->replica_layer()->mask_layer()->draw_properties().render_target = 2443 layer->replica_layer()->mask_layer()->draw_properties().render_target =
2260 layer; 2444 layer;
2261 2445
2262 } else { 2446 } else {
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
2553 } 2737 }
2554 2738
2555 void CalculateDrawPropertiesAndVerify( 2739 void CalculateDrawPropertiesAndVerify(
2556 LayerTreeHostCommon::CalcDrawPropsImplInputs* inputs, 2740 LayerTreeHostCommon::CalcDrawPropsImplInputs* inputs,
2557 PropertyTreeOption property_tree_option) { 2741 PropertyTreeOption property_tree_option) {
2558 inputs->render_surface_layer_list->clear(); 2742 inputs->render_surface_layer_list->clear();
2559 2743
2560 UpdateMetaInformationSequenceNumber(inputs->root_layer); 2744 UpdateMetaInformationSequenceNumber(inputs->root_layer);
2561 PreCalculateMetaInformationRecursiveData recursive_data; 2745 PreCalculateMetaInformationRecursiveData recursive_data;
2562 PreCalculateMetaInformationInternal(inputs->root_layer, &recursive_data); 2746 PreCalculateMetaInformationInternal(inputs->root_layer, &recursive_data);
2747
2563 const bool should_measure_property_tree_performance = 2748 const bool should_measure_property_tree_performance =
2564 inputs->verify_property_trees && 2749 inputs->verify_property_trees &&
2565 (property_tree_option == BUILD_PROPERTY_TREES_IF_NEEDED); 2750 (property_tree_option == BUILD_PROPERTY_TREES_IF_NEEDED);
2566 2751
2567 LayerImplList visible_layer_list; 2752 LayerImplList visible_layer_list;
2568 if (inputs->verify_property_trees || inputs->use_property_trees) { 2753 if (inputs->verify_property_trees || inputs->use_property_trees) {
2569 switch (property_tree_option) { 2754 switch (property_tree_option) {
2570 case BUILD_PROPERTY_TREES_IF_NEEDED: { 2755 case BUILD_PROPERTY_TREES_IF_NEEDED: {
2571 // The translation from layer to property trees is an intermediate 2756 // The translation from layer to property trees is an intermediate
2572 // state. We will eventually get these data passed directly to the 2757 // state. We will eventually get these data passed directly to the
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
2634 } 2819 }
2635 } 2820 }
2636 } 2821 }
2637 2822
2638 if (should_measure_property_tree_performance) { 2823 if (should_measure_property_tree_performance) {
2639 TRACE_EVENT_BEGIN0(TRACE_DISABLED_BY_DEFAULT("cc.debug.cdp-perf"), 2824 TRACE_EVENT_BEGIN0(TRACE_DISABLED_BY_DEFAULT("cc.debug.cdp-perf"),
2640 "LayerTreeHostCommon::CalculateDrawProperties"); 2825 "LayerTreeHostCommon::CalculateDrawProperties");
2641 } 2826 }
2642 2827
2643 std::vector<AccumulatedSurfaceState> accumulated_surface_state; 2828 std::vector<AccumulatedSurfaceState> accumulated_surface_state;
2644 DCHECK(inputs->can_render_to_separate_surface ==
2645 inputs->property_trees->non_root_surfaces_enabled);
2646 CalculateRenderTarget(inputs); 2829 CalculateRenderTarget(inputs);
2647 if (inputs->use_property_trees) { 2830 if (inputs->use_property_trees) {
2648 for (LayerImpl* layer : visible_layer_list) { 2831 for (LayerImpl* layer : visible_layer_list) {
2649 ComputeLayerDrawPropertiesUsingPropertyTrees( 2832 ComputeLayerDrawPropertiesUsingPropertyTrees(
2650 layer, inputs->property_trees, inputs->layers_always_allowed_lcd_text, 2833 layer, inputs->property_trees, inputs->layers_always_allowed_lcd_text,
2651 inputs->can_use_lcd_text, &layer->draw_properties()); 2834 inputs->can_use_lcd_text, &layer->draw_properties());
2652 if (layer->mask_layer()) 2835 if (layer->mask_layer())
2653 ComputeMaskLayerDrawProperties(layer, layer->mask_layer()); 2836 ComputeMaskLayerDrawProperties(layer, layer->mask_layer());
2654 LayerImpl* replica_mask_layer = layer->replica_layer() 2837 LayerImpl* replica_mask_layer = layer->replica_layer()
2655 ? layer->replica_layer()->mask_layer() 2838 ? layer->replica_layer()->mask_layer()
(...skipping 21 matching lines...) Expand all
2677 2860
2678 // A root layer render_surface should always exist after 2861 // A root layer render_surface should always exist after
2679 // CalculateDrawProperties. 2862 // CalculateDrawProperties.
2680 DCHECK(inputs->root_layer->render_surface()); 2863 DCHECK(inputs->root_layer->render_surface());
2681 } 2864 }
2682 2865
2683 void LayerTreeHostCommon::CalculateDrawProperties( 2866 void LayerTreeHostCommon::CalculateDrawProperties(
2684 CalcDrawPropsMainInputs* inputs) { 2867 CalcDrawPropsMainInputs* inputs) {
2685 LayerList update_layer_list; 2868 LayerList update_layer_list;
2686 bool can_render_to_separate_surface = true; 2869 bool can_render_to_separate_surface = true;
2870 UpdateRenderSurfaces(inputs->root_layer, can_render_to_separate_surface,
2871 gfx::Transform(), false);
2687 PropertyTrees* property_trees = 2872 PropertyTrees* property_trees =
2688 inputs->root_layer->layer_tree_host()->property_trees(); 2873 inputs->root_layer->layer_tree_host()->property_trees();
2689 Layer* overscroll_elasticity_layer = nullptr; 2874 Layer* overscroll_elasticity_layer = nullptr;
2690 gfx::Vector2dF elastic_overscroll; 2875 gfx::Vector2dF elastic_overscroll;
2691 BuildPropertyTreesAndComputeVisibleRects( 2876 BuildPropertyTreesAndComputeVisibleRects(
2692 inputs->root_layer, inputs->page_scale_layer, 2877 inputs->root_layer, inputs->page_scale_layer,
2693 inputs->inner_viewport_scroll_layer, inputs->outer_viewport_scroll_layer, 2878 inputs->inner_viewport_scroll_layer, inputs->outer_viewport_scroll_layer,
2694 overscroll_elasticity_layer, elastic_overscroll, 2879 overscroll_elasticity_layer, elastic_overscroll,
2695 inputs->page_scale_factor, inputs->device_scale_factor, 2880 inputs->page_scale_factor, inputs->device_scale_factor,
2696 gfx::Rect(inputs->device_viewport_size), inputs->device_transform, 2881 gfx::Rect(inputs->device_viewport_size), inputs->device_transform,
(...skipping 12 matching lines...) Expand all
2709 2894
2710 PropertyTrees* GetPropertyTrees(Layer* layer) { 2895 PropertyTrees* GetPropertyTrees(Layer* layer) {
2711 return layer->layer_tree_host()->property_trees(); 2896 return layer->layer_tree_host()->property_trees();
2712 } 2897 }
2713 2898
2714 PropertyTrees* GetPropertyTrees(LayerImpl* layer) { 2899 PropertyTrees* GetPropertyTrees(LayerImpl* layer) {
2715 return layer->layer_tree_impl()->property_trees(); 2900 return layer->layer_tree_impl()->property_trees();
2716 } 2901 }
2717 2902
2718 } // namespace cc 2903 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_common.h ('k') | cc/trees/layer_tree_host_common_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698