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

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

Issue 1491033002: Create RenderSurface on Effect Tree (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@alwayspt
Patch Set: fix for crash 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
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
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 static bool IsMetaInformationRecomputationNeeded(Layer* layer) { 1032 static bool IsMetaInformationRecomputationNeeded(Layer* layer) {
1182 return layer->layer_tree_host()->needs_meta_info_recomputation(); 1033 return layer->layer_tree_host()->needs_meta_info_recomputation();
1183 } 1034 }
1184 1035
1185 static void UpdateMetaInformationSequenceNumber(Layer* root_layer) { 1036 static void UpdateMetaInformationSequenceNumber(Layer* root_layer) {
1186 root_layer->layer_tree_host()->IncrementMetaInformationSequenceNumber(); 1037 root_layer->layer_tree_host()->IncrementMetaInformationSequenceNumber();
1187 } 1038 }
1188 1039
1189 static void UpdateMetaInformationSequenceNumber(LayerImpl* root_layer) { 1040 static void UpdateMetaInformationSequenceNumber(LayerImpl* root_layer) {
1190 } 1041 }
1191 1042
1192 // Recursively walks the layer tree(if needed) to compute any information 1043 // Recursively walks the layer tree(if needed) to compute any information
1193 // that is needed before doing the main recursion. 1044 // that is needed before doing the main recursion.
1194 static void PreCalculateMetaInformationInternal( 1045 static void PreCalculateMetaInformationInternal(
1195 Layer* layer, 1046 Layer* layer,
1196 PreCalculateMetaInformationRecursiveData* recursive_data) { 1047 PreCalculateMetaInformationRecursiveData* recursive_data) {
1197 ValidateRenderSurface(layer);
1198
1199 if (!IsMetaInformationRecomputationNeeded(layer)) { 1048 if (!IsMetaInformationRecomputationNeeded(layer)) {
1200 DCHECK(IsRootLayer(layer)); 1049 DCHECK(IsRootLayer(layer));
1201 return; 1050 return;
1202 } 1051 }
1203 1052
1204 layer->set_sorted_for_recursion(false); 1053 layer->set_sorted_for_recursion(false);
1205 layer->set_layer_or_descendant_is_drawn(false); 1054 layer->set_layer_or_descendant_is_drawn(false);
1206 layer->set_visited(false); 1055 layer->set_visited(false);
1207 1056
1208 if (!HasInvertibleOrAnimatedTransform(layer)) { 1057 if (!HasInvertibleOrAnimatedTransform(layer)) {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1240 layer->set_num_layer_or_descendant_with_copy_request( 1089 layer->set_num_layer_or_descendant_with_copy_request(
1241 recursive_data->num_layer_or_descendants_with_copy_request); 1090 recursive_data->num_layer_or_descendants_with_copy_request);
1242 1091
1243 if (IsRootLayer(layer)) 1092 if (IsRootLayer(layer))
1244 layer->layer_tree_host()->SetNeedsMetaInfoRecomputation(false); 1093 layer->layer_tree_host()->SetNeedsMetaInfoRecomputation(false);
1245 } 1094 }
1246 1095
1247 static void PreCalculateMetaInformationInternal( 1096 static void PreCalculateMetaInformationInternal(
1248 LayerImpl* layer, 1097 LayerImpl* layer,
1249 PreCalculateMetaInformationRecursiveData* recursive_data) { 1098 PreCalculateMetaInformationRecursiveData* recursive_data) {
1250 ValidateRenderSurface(layer);
1251
1252 layer->set_sorted_for_recursion(false); 1099 layer->set_sorted_for_recursion(false);
1253 layer->draw_properties().has_child_with_a_scroll_parent = false; 1100 layer->draw_properties().has_child_with_a_scroll_parent = false;
1254 layer->set_layer_or_descendant_is_drawn(false); 1101 layer->set_layer_or_descendant_is_drawn(false);
1255 layer->set_visited(false); 1102 layer->set_visited(false);
1256 1103
1257 if (!HasInvertibleOrAnimatedTransform(layer)) { 1104 if (!HasInvertibleOrAnimatedTransform(layer)) {
1258 // Layers with singular transforms should not be drawn, the whole subtree 1105 // Layers with singular transforms should not be drawn, the whole subtree
1259 // can be skipped. 1106 // can be skipped.
1260 return; 1107 return;
1261 } 1108 }
(...skipping 26 matching lines...) Expand all
1288 recursive_data->num_layer_or_descendants_with_input_handler++; 1135 recursive_data->num_layer_or_descendants_with_input_handler++;
1289 1136
1290 layer->draw_properties().num_unclipped_descendants = 1137 layer->draw_properties().num_unclipped_descendants =
1291 recursive_data->num_unclipped_descendants; 1138 recursive_data->num_unclipped_descendants;
1292 layer->set_layer_or_descendant_has_input_handler( 1139 layer->set_layer_or_descendant_has_input_handler(
1293 (recursive_data->num_layer_or_descendants_with_input_handler != 0)); 1140 (recursive_data->num_layer_or_descendants_with_input_handler != 0));
1294 // 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
1295 // for tests constructing layers on the compositor thread. 1142 // for tests constructing layers on the compositor thread.
1296 layer->set_num_layer_or_descendant_with_copy_request( 1143 layer->set_num_layer_or_descendant_with_copy_request(
1297 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++;
1298 } 1150 }
1299 1151
1300 void LayerTreeHostCommon::PreCalculateMetaInformation(Layer* root_layer) { 1152 void LayerTreeHostCommon::PreCalculateMetaInformation(Layer* root_layer) {
1301 PreCalculateMetaInformationRecursiveData recursive_data; 1153 PreCalculateMetaInformationRecursiveData recursive_data;
1302 PreCalculateMetaInformationInternal(root_layer, &recursive_data); 1154 PreCalculateMetaInformationInternal(root_layer, &recursive_data);
1303 } 1155 }
1304 1156
1305 void LayerTreeHostCommon::PreCalculateMetaInformationForTesting( 1157 void LayerTreeHostCommon::PreCalculateMetaInformationForTesting(
1306 LayerImpl* root_layer) { 1158 LayerImpl* root_layer) {
1307 PreCalculateMetaInformationRecursiveData recursive_data; 1159 PreCalculateMetaInformationRecursiveData recursive_data;
(...skipping 901 matching lines...) Expand 10 before | Expand all | Expand 10 after
2209 device_viewport_rect; 2061 device_viewport_rect;
2210 data_for_recursion->maximum_animation_contents_scale = 0.f; 2062 data_for_recursion->maximum_animation_contents_scale = 0.f;
2211 data_for_recursion->starting_animation_contents_scale = 0.f; 2063 data_for_recursion->starting_animation_contents_scale = 0.f;
2212 data_for_recursion->ancestor_is_animating_scale = false; 2064 data_for_recursion->ancestor_is_animating_scale = false;
2213 data_for_recursion->ancestor_clips_subtree = true; 2065 data_for_recursion->ancestor_clips_subtree = true;
2214 data_for_recursion->in_subtree_of_page_scale_layer = false; 2066 data_for_recursion->in_subtree_of_page_scale_layer = false;
2215 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;
2216 data_for_recursion->subtree_is_visible_from_ancestor = true; 2068 data_for_recursion->subtree_is_visible_from_ancestor = true;
2217 } 2069 }
2218 2070
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 }
2256 2071
2257 static bool ApproximatelyEqual(const gfx::Rect& r1, const gfx::Rect& r2) { 2072 static bool ApproximatelyEqual(const gfx::Rect& r1, const gfx::Rect& r2) {
2258 // TODO(vollick): This tolerance should be lower: crbug.com/471786 2073 // TODO(vollick): This tolerance should be lower: crbug.com/471786
2259 static const int tolerance = 1; 2074 static const int tolerance = 1;
2260 2075
2261 return std::abs(r1.x() - r2.x()) <= tolerance && 2076 return std::abs(r1.x() - r2.x()) <= tolerance &&
2262 std::abs(r1.y() - r2.y()) <= tolerance && 2077 std::abs(r1.y() - r2.y()) <= tolerance &&
2263 std::abs(r1.right() - r2.right()) <= tolerance && 2078 std::abs(r1.right() - r2.right()) <= tolerance &&
2264 std::abs(r1.bottom() - r2.bottom()) <= tolerance; 2079 std::abs(r1.bottom() - r2.bottom()) <= tolerance;
2265 } 2080 }
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
2344 } 2159 }
2345 2160
2346 void VerifyPropertyTreeValuesForLayer(LayerImpl* current_layer, 2161 void VerifyPropertyTreeValuesForLayer(LayerImpl* current_layer,
2347 PropertyTrees* property_trees, 2162 PropertyTrees* property_trees,
2348 bool layers_always_allowed_lcd_text, 2163 bool layers_always_allowed_lcd_text,
2349 bool can_use_lcd_text) { 2164 bool can_use_lcd_text) {
2350 DrawProperties draw_properties; 2165 DrawProperties draw_properties;
2351 ComputeLayerDrawPropertiesUsingPropertyTrees( 2166 ComputeLayerDrawPropertiesUsingPropertyTrees(
2352 current_layer, property_trees, layers_always_allowed_lcd_text, 2167 current_layer, property_trees, layers_always_allowed_lcd_text,
2353 can_use_lcd_text, &draw_properties); 2168 can_use_lcd_text, &draw_properties);
2354
2355 const bool visible_rects_match = ApproximatelyEqual( 2169 const bool visible_rects_match = ApproximatelyEqual(
2356 current_layer->visible_layer_rect(), draw_properties.visible_layer_rect); 2170 current_layer->visible_layer_rect(), draw_properties.visible_layer_rect);
2357 CHECK(visible_rects_match) 2171 CHECK(visible_rects_match)
2358 << "expected: " << current_layer->visible_layer_rect().ToString() 2172 << "expected: " << current_layer->visible_layer_rect().ToString()
2359 << " actual: " << draw_properties.visible_layer_rect.ToString(); 2173 << " actual: " << draw_properties.visible_layer_rect.ToString();
2360 2174
2361 const bool draw_transforms_match = ApproximatelyEqual( 2175 const bool draw_transforms_match = ApproximatelyEqual(
2362 current_layer->draw_properties().target_space_transform, 2176 current_layer->draw_properties().target_space_transform,
2363 draw_properties.target_space_transform); 2177 draw_properties.target_space_transform);
2364 CHECK(draw_transforms_match) 2178 CHECK(draw_transforms_match)
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
2426 if (!IsRootLayer(layer) && SubtreeShouldBeSkipped(layer, layer_is_drawn)) { 2240 if (!IsRootLayer(layer) && SubtreeShouldBeSkipped(layer, layer_is_drawn)) {
2427 layer->draw_properties().render_target = nullptr; 2241 layer->draw_properties().render_target = nullptr;
2428 return; 2242 return;
2429 } 2243 }
2430 2244
2431 bool render_to_separate_surface = 2245 bool render_to_separate_surface =
2432 IsRootLayer(layer) || 2246 IsRootLayer(layer) ||
2433 (can_render_to_separate_surface && layer->render_surface()); 2247 (can_render_to_separate_surface && layer->render_surface());
2434 2248
2435 if (render_to_separate_surface) { 2249 if (render_to_separate_surface) {
2436 DCHECK(layer->render_surface()); 2250 DCHECK(layer->render_surface()) << IsRootLayer(layer)
2251 << can_render_to_separate_surface
2252 << layer->has_render_surface();
2437 layer->draw_properties().render_target = layer; 2253 layer->draw_properties().render_target = layer;
2438 2254
2439 if (layer->mask_layer()) 2255 if (layer->mask_layer())
2440 layer->mask_layer()->draw_properties().render_target = layer; 2256 layer->mask_layer()->draw_properties().render_target = layer;
2441 2257
2442 if (layer->replica_layer() && layer->replica_layer()->mask_layer()) 2258 if (layer->replica_layer() && layer->replica_layer()->mask_layer())
2443 layer->replica_layer()->mask_layer()->draw_properties().render_target = 2259 layer->replica_layer()->mask_layer()->draw_properties().render_target =
2444 layer; 2260 layer;
2445 2261
2446 } else { 2262 } else {
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
2737 } 2553 }
2738 2554
2739 void CalculateDrawPropertiesAndVerify( 2555 void CalculateDrawPropertiesAndVerify(
2740 LayerTreeHostCommon::CalcDrawPropsImplInputs* inputs, 2556 LayerTreeHostCommon::CalcDrawPropsImplInputs* inputs,
2741 PropertyTreeOption property_tree_option) { 2557 PropertyTreeOption property_tree_option) {
2742 inputs->render_surface_layer_list->clear(); 2558 inputs->render_surface_layer_list->clear();
2743 2559
2744 UpdateMetaInformationSequenceNumber(inputs->root_layer); 2560 UpdateMetaInformationSequenceNumber(inputs->root_layer);
2745 PreCalculateMetaInformationRecursiveData recursive_data; 2561 PreCalculateMetaInformationRecursiveData recursive_data;
2746 PreCalculateMetaInformationInternal(inputs->root_layer, &recursive_data); 2562 PreCalculateMetaInformationInternal(inputs->root_layer, &recursive_data);
2747
2748 const bool should_measure_property_tree_performance = 2563 const bool should_measure_property_tree_performance =
2749 inputs->verify_property_trees && 2564 inputs->verify_property_trees &&
2750 (property_tree_option == BUILD_PROPERTY_TREES_IF_NEEDED); 2565 (property_tree_option == BUILD_PROPERTY_TREES_IF_NEEDED);
2751 2566
2752 LayerImplList visible_layer_list; 2567 LayerImplList visible_layer_list;
2753 if (inputs->verify_property_trees || inputs->use_property_trees) { 2568 if (inputs->verify_property_trees || inputs->use_property_trees) {
2754 switch (property_tree_option) { 2569 switch (property_tree_option) {
2755 case BUILD_PROPERTY_TREES_IF_NEEDED: { 2570 case BUILD_PROPERTY_TREES_IF_NEEDED: {
2756 // The translation from layer to property trees is an intermediate 2571 // The translation from layer to property trees is an intermediate
2757 // state. We will eventually get these data passed directly to the 2572 // state. We will eventually get these data passed directly to the
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
2819 } 2634 }
2820 } 2635 }
2821 } 2636 }
2822 2637
2823 if (should_measure_property_tree_performance) { 2638 if (should_measure_property_tree_performance) {
2824 TRACE_EVENT_BEGIN0(TRACE_DISABLED_BY_DEFAULT("cc.debug.cdp-perf"), 2639 TRACE_EVENT_BEGIN0(TRACE_DISABLED_BY_DEFAULT("cc.debug.cdp-perf"),
2825 "LayerTreeHostCommon::CalculateDrawProperties"); 2640 "LayerTreeHostCommon::CalculateDrawProperties");
2826 } 2641 }
2827 2642
2828 std::vector<AccumulatedSurfaceState> accumulated_surface_state; 2643 std::vector<AccumulatedSurfaceState> accumulated_surface_state;
2644 DCHECK(inputs->can_render_to_separate_surface ==
2645 inputs->property_trees->non_root_surfaces_enabled);
2829 CalculateRenderTarget(inputs); 2646 CalculateRenderTarget(inputs);
2830 if (inputs->use_property_trees) { 2647 if (inputs->use_property_trees) {
2831 for (LayerImpl* layer : visible_layer_list) { 2648 for (LayerImpl* layer : visible_layer_list) {
2832 ComputeLayerDrawPropertiesUsingPropertyTrees( 2649 ComputeLayerDrawPropertiesUsingPropertyTrees(
2833 layer, inputs->property_trees, inputs->layers_always_allowed_lcd_text, 2650 layer, inputs->property_trees, inputs->layers_always_allowed_lcd_text,
2834 inputs->can_use_lcd_text, &layer->draw_properties()); 2651 inputs->can_use_lcd_text, &layer->draw_properties());
2835 if (layer->mask_layer()) 2652 if (layer->mask_layer())
2836 ComputeMaskLayerDrawProperties(layer, layer->mask_layer()); 2653 ComputeMaskLayerDrawProperties(layer, layer->mask_layer());
2837 LayerImpl* replica_mask_layer = layer->replica_layer() 2654 LayerImpl* replica_mask_layer = layer->replica_layer()
2838 ? layer->replica_layer()->mask_layer() 2655 ? layer->replica_layer()->mask_layer()
(...skipping 21 matching lines...) Expand all
2860 2677
2861 // A root layer render_surface should always exist after 2678 // A root layer render_surface should always exist after
2862 // CalculateDrawProperties. 2679 // CalculateDrawProperties.
2863 DCHECK(inputs->root_layer->render_surface()); 2680 DCHECK(inputs->root_layer->render_surface());
2864 } 2681 }
2865 2682
2866 void LayerTreeHostCommon::CalculateDrawProperties( 2683 void LayerTreeHostCommon::CalculateDrawProperties(
2867 CalcDrawPropsMainInputs* inputs) { 2684 CalcDrawPropsMainInputs* inputs) {
2868 LayerList update_layer_list; 2685 LayerList update_layer_list;
2869 bool can_render_to_separate_surface = true; 2686 bool can_render_to_separate_surface = true;
2870 UpdateRenderSurfaces(inputs->root_layer, can_render_to_separate_surface,
2871 gfx::Transform(), false);
2872 PropertyTrees* property_trees = 2687 PropertyTrees* property_trees =
2873 inputs->root_layer->layer_tree_host()->property_trees(); 2688 inputs->root_layer->layer_tree_host()->property_trees();
2874 Layer* overscroll_elasticity_layer = nullptr; 2689 Layer* overscroll_elasticity_layer = nullptr;
2875 gfx::Vector2dF elastic_overscroll; 2690 gfx::Vector2dF elastic_overscroll;
2876 BuildPropertyTreesAndComputeVisibleRects( 2691 BuildPropertyTreesAndComputeVisibleRects(
2877 inputs->root_layer, inputs->page_scale_layer, 2692 inputs->root_layer, inputs->page_scale_layer,
2878 inputs->inner_viewport_scroll_layer, inputs->outer_viewport_scroll_layer, 2693 inputs->inner_viewport_scroll_layer, inputs->outer_viewport_scroll_layer,
2879 overscroll_elasticity_layer, elastic_overscroll, 2694 overscroll_elasticity_layer, elastic_overscroll,
2880 inputs->page_scale_factor, inputs->device_scale_factor, 2695 inputs->page_scale_factor, inputs->device_scale_factor,
2881 gfx::Rect(inputs->device_viewport_size), inputs->device_transform, 2696 gfx::Rect(inputs->device_viewport_size), inputs->device_transform,
(...skipping 12 matching lines...) Expand all
2894 2709
2895 PropertyTrees* GetPropertyTrees(Layer* layer) { 2710 PropertyTrees* GetPropertyTrees(Layer* layer) {
2896 return layer->layer_tree_host()->property_trees(); 2711 return layer->layer_tree_host()->property_trees();
2897 } 2712 }
2898 2713
2899 PropertyTrees* GetPropertyTrees(LayerImpl* layer) { 2714 PropertyTrees* GetPropertyTrees(LayerImpl* layer) {
2900 return layer->layer_tree_impl()->property_trees(); 2715 return layer->layer_tree_impl()->property_trees();
2901 } 2716 }
2902 2717
2903 } // namespace cc 2718 } // 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