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

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

Issue 2225973003: cc: Remove usage of ComputeVisibleRects on main thread (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments and fix perf regressions Created 4 years, 4 months 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/layers/layer.cc ('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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/draw_property_utils.h" 5 #include "cc/trees/draw_property_utils.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <vector> 9 #include <vector>
10 10
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 #endif 78 #endif
79 79
80 static const EffectNode* ContentsTargetEffectNode( 80 static const EffectNode* ContentsTargetEffectNode(
81 const int effect_tree_index, 81 const int effect_tree_index,
82 const EffectTree& effect_tree) { 82 const EffectTree& effect_tree) {
83 const EffectNode* effect_node = effect_tree.Node(effect_tree_index); 83 const EffectNode* effect_node = effect_tree.Node(effect_tree_index);
84 return effect_node->render_surface ? effect_node 84 return effect_node->render_surface ? effect_node
85 : effect_tree.Node(effect_node->target_id); 85 : effect_tree.Node(effect_node->target_id);
86 } 86 }
87 87
88 template <typename LayerType> 88 bool ComputeClipRectInTargetSpace(const LayerImpl* layer,
89 bool ComputeClipRectInTargetSpace(const LayerType* layer,
90 const ClipNode* clip_node, 89 const ClipNode* clip_node,
91 const PropertyTrees* property_trees, 90 const PropertyTrees* property_trees,
92 int target_node_id, 91 int target_node_id,
93 gfx::RectF* clip_rect_in_target_space) { 92 gfx::RectF* clip_rect_in_target_space) {
94 DCHECK(layer->clip_tree_index() == clip_node->id); 93 DCHECK(layer->clip_tree_index() == clip_node->id);
95 DCHECK(clip_node->target_transform_id != target_node_id); 94 DCHECK(clip_node->target_transform_id != target_node_id);
96 95
97 const EffectTree& effect_tree = property_trees->effect_tree; 96 const EffectTree& effect_tree = property_trees->effect_tree;
98 const EffectNode* target_effect_node = 97 const EffectNode* target_effect_node =
99 ContentsTargetEffectNode(layer->effect_tree_index(), effect_tree); 98 ContentsTargetEffectNode(layer->effect_tree_index(), effect_tree);
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 344
346 if (!clip_rect_in_target_space.IsEmpty()) { 345 if (!clip_rect_in_target_space.IsEmpty()) {
347 layer->set_clip_rect(gfx::ToEnclosingRect(clip_rect_in_target_space)); 346 layer->set_clip_rect(gfx::ToEnclosingRect(clip_rect_in_target_space));
348 } else { 347 } else {
349 layer->set_clip_rect(gfx::Rect()); 348 layer->set_clip_rect(gfx::Rect());
350 } 349 }
351 } 350 }
352 } 351 }
353 } 352 }
354 353
355 bool GetLayerClipRect(const scoped_refptr<Layer> layer,
356 const ClipNode* clip_node,
357 const PropertyTrees* property_trees,
358 int target_node_id,
359 gfx::RectF* clip_rect_in_target_space) {
360 return ComputeClipRectInTargetSpace(layer.get(), clip_node, property_trees,
361 target_node_id,
362 clip_rect_in_target_space);
363 }
364
365 bool GetLayerClipRect(const LayerImpl* layer, 354 bool GetLayerClipRect(const LayerImpl* layer,
366 const ClipNode* clip_node, 355 const ClipNode* clip_node,
367 const PropertyTrees* property_trees, 356 const PropertyTrees* property_trees,
368 int target_node_id, 357 int target_node_id,
369 gfx::RectF* clip_rect_in_target_space) { 358 gfx::RectF* clip_rect_in_target_space) {
370 // This is equivalent of calling ComputeClipRectInTargetSpace. 359 // This is equivalent of calling ComputeClipRectInTargetSpace.
371 *clip_rect_in_target_space = gfx::RectF(layer->clip_rect()); 360 *clip_rect_in_target_space = gfx::RectF(layer->clip_rect());
372 return property_trees->transform_tree.Node(target_node_id) 361 return property_trees->transform_tree.Node(target_node_id)
373 ->ancestors_are_invertible; 362 ->ancestors_are_invertible;
374 } 363 }
375 364
376 template <typename LayerType> 365 void CalculateVisibleRects(const LayerImplList& visible_layer_list,
377 void CalculateVisibleRects( 366 const PropertyTrees* property_trees,
378 const typename LayerType::LayerListType& visible_layer_list, 367 bool non_root_surfaces_enabled) {
379 const PropertyTrees* property_trees,
380 bool non_root_surfaces_enabled) {
381 const EffectTree& effect_tree = property_trees->effect_tree; 368 const EffectTree& effect_tree = property_trees->effect_tree;
382 const TransformTree& transform_tree = property_trees->transform_tree; 369 const TransformTree& transform_tree = property_trees->transform_tree;
383 const ClipTree& clip_tree = property_trees->clip_tree; 370 const ClipTree& clip_tree = property_trees->clip_tree;
384 for (auto& layer : visible_layer_list) { 371 for (auto& layer : visible_layer_list) {
385 gfx::Size layer_bounds = layer->bounds(); 372 gfx::Size layer_bounds = layer->bounds();
386 373
387 int effect_ancestor_with_copy_request = 374 int effect_ancestor_with_copy_request =
388 effect_tree.ClosestAncestorWithCopyRequest(layer->effect_tree_index()); 375 effect_tree.ClosestAncestorWithCopyRequest(layer->effect_tree_index());
389 if (effect_ancestor_with_copy_request > 1) { 376 if (effect_ancestor_with_copy_request > 1) {
390 // Non root copy request. 377 // Non root copy request.
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
558 545
559 template <typename LayerType> 546 template <typename LayerType>
560 static int TransformTreeIndexForBackfaceVisibility(LayerType* layer, 547 static int TransformTreeIndexForBackfaceVisibility(LayerType* layer,
561 const TransformTree& tree) { 548 const TransformTree& tree) {
562 if (!layer->use_parent_backface_visibility()) 549 if (!layer->use_parent_backface_visibility())
563 return layer->transform_tree_index(); 550 return layer->transform_tree_index();
564 const TransformNode* node = tree.Node(layer->transform_tree_index()); 551 const TransformNode* node = tree.Node(layer->transform_tree_index());
565 return layer->id() == node->owner_id ? tree.parent(node)->id : node->id; 552 return layer->id() == node->owner_id ? tree.parent(node)->id : node->id;
566 } 553 }
567 554
555 static bool IsTargetSpaceTransformBackFaceVisible(Layer* layer,
556 int transform_tree_index,
557 const TransformTree& tree) {
558 // We do not skip back face invisible layers on main thread as target space
559 // transform will not be available here.
560 return false;
561 }
562
563 static bool IsTargetSpaceTransformBackFaceVisible(LayerImpl* layer,
564 int transform_tree_index,
565 const TransformTree& tree) {
566 return tree
567 .ToTarget(transform_tree_index, layer->render_target_effect_tree_index())
568 .IsBackFaceVisible();
569 }
570
568 template <typename LayerType> 571 template <typename LayerType>
569 static bool IsLayerBackFaceVisible(LayerType* layer, 572 static bool IsLayerBackFaceVisible(LayerType* layer,
570 int transform_tree_index, 573 int transform_tree_index,
571 const TransformTree& tree) { 574 const TransformTree& tree) {
572 const TransformNode* node = tree.Node(transform_tree_index); 575 const TransformNode* node = tree.Node(transform_tree_index);
573 return layer->use_local_transform_for_backface_visibility() 576 return layer->use_local_transform_for_backface_visibility()
574 ? node->local.IsBackFaceVisible() 577 ? node->local.IsBackFaceVisible()
575 : tree.ToTarget(transform_tree_index, 578 : IsTargetSpaceTransformBackFaceVisible(
576 layer->render_target_effect_tree_index()) 579 layer, transform_tree_index, tree);
577 .IsBackFaceVisible();
578 } 580 }
579 581
580 static inline bool TransformToScreenIsKnown(Layer* layer, 582 static inline bool TransformToScreenIsKnown(Layer* layer,
581 int transform_tree_index, 583 int transform_tree_index,
582 const TransformTree& tree) { 584 const TransformTree& tree) {
583 const TransformNode* node = tree.Node(transform_tree_index); 585 const TransformNode* node = tree.Node(transform_tree_index);
584 return !node->to_screen_is_potentially_animated; 586 return !node->to_screen_is_potentially_animated;
585 } 587 }
586 588
587 static inline bool TransformToScreenIsKnown(LayerImpl* layer, 589 static inline bool TransformToScreenIsKnown(LayerImpl* layer,
(...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after
1094 // Computation of clips uses surface contents scale which is updated while 1096 // Computation of clips uses surface contents scale which is updated while
1095 // computing effects. So, ComputeEffects should be before ComputeClips. 1097 // computing effects. So, ComputeEffects should be before ComputeClips.
1096 ComputeEffects(&property_trees->effect_tree); 1098 ComputeEffects(&property_trees->effect_tree);
1097 ComputeClips(property_trees, can_render_to_separate_surface); 1099 ComputeClips(property_trees, can_render_to_separate_surface);
1098 1100
1099 FindLayersThatNeedUpdates(root_layer->layer_tree_impl(), 1101 FindLayersThatNeedUpdates(root_layer->layer_tree_impl(),
1100 property_trees->transform_tree, 1102 property_trees->transform_tree,
1101 property_trees->effect_tree, visible_layer_list); 1103 property_trees->effect_tree, visible_layer_list);
1102 CalculateClipRects<LayerImpl>(*visible_layer_list, property_trees, 1104 CalculateClipRects<LayerImpl>(*visible_layer_list, property_trees,
1103 can_render_to_separate_surface); 1105 can_render_to_separate_surface);
1104 CalculateVisibleRects<LayerImpl>(*visible_layer_list, property_trees, 1106 CalculateVisibleRects(*visible_layer_list, property_trees,
1105 can_render_to_separate_surface); 1107 can_render_to_separate_surface);
1106 } 1108 }
1107 1109
1108 void UpdatePropertyTrees(PropertyTrees* property_trees, 1110 void UpdatePropertyTrees(PropertyTrees* property_trees,
1109 bool can_render_to_separate_surface) { 1111 bool can_render_to_separate_surface) {
1110 if (property_trees->non_root_surfaces_enabled != 1112 if (property_trees->non_root_surfaces_enabled !=
1111 can_render_to_separate_surface) { 1113 can_render_to_separate_surface) {
1112 property_trees->non_root_surfaces_enabled = can_render_to_separate_surface; 1114 property_trees->non_root_surfaces_enabled = can_render_to_separate_surface;
1113 property_trees->transform_tree.set_needs_update(true); 1115 property_trees->transform_tree.set_needs_update(true);
1114 } 1116 }
1115 if (property_trees->transform_tree.needs_update()) { 1117 if (property_trees->transform_tree.needs_update()) {
1116 property_trees->clip_tree.set_needs_update(true); 1118 property_trees->clip_tree.set_needs_update(true);
1117 property_trees->effect_tree.set_needs_update(true); 1119 property_trees->effect_tree.set_needs_update(true);
1118 } 1120 }
1119 ComputeTransforms(&property_trees->transform_tree); 1121 ComputeTransforms(&property_trees->transform_tree);
1120 // Computation of clips uses surface contents scale which is updated while 1122 // Computation of clips uses surface contents scale which is updated while
1121 // computing effects. So, ComputeEffects should be before ComputeClips. 1123 // computing effects. So, ComputeEffects should be before ComputeClips.
1122 ComputeEffects(&property_trees->effect_tree); 1124 ComputeEffects(&property_trees->effect_tree);
1123 ComputeClips(property_trees, can_render_to_separate_surface); 1125 ComputeClips(property_trees, can_render_to_separate_surface);
1124 } 1126 }
1125 1127
1126 void ComputeVisibleRectsForTesting(PropertyTrees* property_trees,
1127 bool can_render_to_separate_surface,
1128 LayerList* update_layer_list) {
1129 CalculateVisibleRects<Layer>(*update_layer_list, property_trees,
1130 can_render_to_separate_surface);
1131 }
1132
1133 void BuildPropertyTreesAndComputeVisibleRects( 1128 void BuildPropertyTreesAndComputeVisibleRects(
1134 LayerImpl* root_layer, 1129 LayerImpl* root_layer,
1135 const LayerImpl* page_scale_layer, 1130 const LayerImpl* page_scale_layer,
1136 const LayerImpl* inner_viewport_scroll_layer, 1131 const LayerImpl* inner_viewport_scroll_layer,
1137 const LayerImpl* outer_viewport_scroll_layer, 1132 const LayerImpl* outer_viewport_scroll_layer,
1138 const LayerImpl* overscroll_elasticity_layer, 1133 const LayerImpl* overscroll_elasticity_layer,
1139 const gfx::Vector2dF& elastic_overscroll, 1134 const gfx::Vector2dF& elastic_overscroll,
1140 float page_scale_factor, 1135 float page_scale_factor,
1141 float device_scale_factor, 1136 float device_scale_factor,
1142 const gfx::Rect& viewport, 1137 const gfx::Rect& viewport,
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after
1601 void UpdateElasticOverscroll(PropertyTrees* property_trees, 1596 void UpdateElasticOverscroll(PropertyTrees* property_trees,
1602 const Layer* overscroll_elasticity_layer, 1597 const Layer* overscroll_elasticity_layer,
1603 const gfx::Vector2dF& elastic_overscroll) { 1598 const gfx::Vector2dF& elastic_overscroll) {
1604 UpdateElasticOverscrollInternal(property_trees, overscroll_elasticity_layer, 1599 UpdateElasticOverscrollInternal(property_trees, overscroll_elasticity_layer,
1605 elastic_overscroll); 1600 elastic_overscroll);
1606 } 1601 }
1607 1602
1608 } // namespace draw_property_utils 1603 } // namespace draw_property_utils
1609 1604
1610 } // namespace cc 1605 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/layer.cc ('k') | cc/trees/layer_tree_host_common_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698