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

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

Issue 2464153004: cc: Set clip rect to empty rect when layer's is_clipped is false (Closed)
Patch Set: fix format Created 4 years, 1 month 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 | « no previous file | no next file » | 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 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 DCHECK(accumulated_clip.is_clipped); 267 DCHECK(accumulated_clip.is_clipped);
268 return accumulated_clip.clip_rect; 268 return accumulated_clip.clip_rect;
269 } 269 }
270 270
271 void CalculateClipRects(const std::vector<LayerImpl*>& visible_layer_list, 271 void CalculateClipRects(const std::vector<LayerImpl*>& visible_layer_list,
272 const PropertyTrees* property_trees, 272 const PropertyTrees* property_trees,
273 bool non_root_surfaces_enabled) { 273 bool non_root_surfaces_enabled) {
274 const ClipTree& clip_tree = property_trees->clip_tree; 274 const ClipTree& clip_tree = property_trees->clip_tree;
275 for (auto& layer : visible_layer_list) { 275 for (auto& layer : visible_layer_list) {
276 const ClipNode* clip_node = clip_tree.Node(layer->clip_tree_index()); 276 const ClipNode* clip_node = clip_tree.Node(layer->clip_tree_index());
277 bool layer_needs_clip_rect =
278 non_root_surfaces_enabled
279 ? clip_node->layers_are_clipped
280 : clip_node->layers_are_clipped_when_surfaces_disabled;
281 if (!layer_needs_clip_rect) {
282 layer->set_clip_rect(gfx::Rect());
283 continue;
284 }
277 if (!non_root_surfaces_enabled) { 285 if (!non_root_surfaces_enabled) {
278 layer->set_clip_rect( 286 layer->set_clip_rect(
279 gfx::ToEnclosingRect(clip_node->clip_in_target_space)); 287 gfx::ToEnclosingRect(clip_node->clip_in_target_space));
280 continue; 288 continue;
281 } 289 }
282 290
283 // When both the layer and the target are unclipped, the entire layer 291 const TransformTree& transform_tree = property_trees->transform_tree;
284 // content rect is visible. 292 const TransformNode* transform_node =
285 const bool fully_visible = 293 transform_tree.Node(layer->transform_tree_index());
286 !clip_node->layers_are_clipped && !clip_node->target_is_clipped; 294 int target_node_id = transform_tree.ContentTargetId(transform_node->id);
weiliangc 2016/11/02 21:08:07 Could you explain why target_is_clipped is ok to b
jaydasika 2016/11/02 21:21:56 if !non_root_surfaces_enabled = true, we wont reac
weiliangc 2016/11/02 21:34:28 For !non_root_surface_enabled, old cold will set t
jaydasika 2016/11/02 21:46:40 When layer is not clipped, clip rect is never used
weiliangc 2016/11/03 19:21:54 Ah I see because !non_root_surface_enabled's root
287 295
288 if (!fully_visible) { 296 // The clip node stores clip rect in its target space.
289 const TransformTree& transform_tree = property_trees->transform_tree; 297 gfx::RectF clip_rect_in_target_space = clip_node->clip_in_target_space;
290 const TransformNode* transform_node =
291 transform_tree.Node(layer->transform_tree_index());
292 int target_node_id = transform_tree.ContentTargetId(transform_node->id);
293 298
294 // The clip node stores clip rect in its target space. 299 // If required, this clip rect should be mapped to the current layer's
295 gfx::RectF clip_rect_in_target_space = clip_node->clip_in_target_space; 300 // target space.
301 if (clip_node->target_transform_id != target_node_id) {
302 // In this case, layer has a clip parent or scroll parent (or shares the
303 // target with an ancestor layer that has clip parent) and the clip
304 // parent's target is different from the layer's target. As the layer's
305 // target has unclippped descendants, it is unclippped.
306 if (!clip_node->layers_are_clipped)
307 continue;
296 308
297 // If required, this clip rect should be mapped to the current layer's 309 // Compute the clip rect in target space and store it.
298 // target space. 310 bool for_visible_rect_calculation = false;
299 if (clip_node->target_transform_id != target_node_id) { 311 if (!ComputeClipRectInTargetSpace(
300 // In this case, layer has a clip parent or scroll parent (or shares the 312 layer, clip_node, property_trees, target_node_id,
301 // target with an ancestor layer that has clip parent) and the clip 313 for_visible_rect_calculation, &clip_rect_in_target_space))
302 // parent's target is different from the layer's target. As the layer's 314 continue;
303 // target has unclippped descendants, it is unclippped. 315 }
304 if (!clip_node->layers_are_clipped)
305 continue;
306 316
307 // Compute the clip rect in target space and store it. 317 if (!clip_rect_in_target_space.IsEmpty()) {
308 bool for_visible_rect_calculation = false; 318 layer->set_clip_rect(gfx::ToEnclosingRect(clip_rect_in_target_space));
309 if (!ComputeClipRectInTargetSpace( 319 } else {
310 layer, clip_node, property_trees, target_node_id, 320 layer->set_clip_rect(gfx::Rect());
311 for_visible_rect_calculation, &clip_rect_in_target_space))
312 continue;
313 }
314
315 if (!clip_rect_in_target_space.IsEmpty()) {
316 layer->set_clip_rect(gfx::ToEnclosingRect(clip_rect_in_target_space));
317 } else {
318 layer->set_clip_rect(gfx::Rect());
319 }
320 } 321 }
321 } 322 }
322 } 323 }
323 324
324 void CalculateVisibleRects(const LayerImplList& visible_layer_list, 325 void CalculateVisibleRects(const LayerImplList& visible_layer_list,
325 const PropertyTrees* property_trees, 326 const PropertyTrees* property_trees,
326 bool non_root_surfaces_enabled) { 327 bool non_root_surfaces_enabled) {
327 const EffectTree& effect_tree = property_trees->effect_tree; 328 const EffectTree& effect_tree = property_trees->effect_tree;
328 const TransformTree& transform_tree = property_trees->transform_tree; 329 const TransformTree& transform_tree = property_trees->transform_tree;
329 const ClipTree& clip_tree = property_trees->clip_tree; 330 const ClipTree& clip_tree = property_trees->clip_tree;
(...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after
949 << " v.s. accumulated clip: " 950 << " v.s. accumulated clip: "
950 << gfx::ToEnclosingRect(accumulated_clip).ToString(); 951 << gfx::ToEnclosingRect(accumulated_clip).ToString();
951 } 952 }
952 } 953 }
953 } 954 }
954 955
955 static void ComputeLayerClipRect(const PropertyTrees* property_trees, 956 static void ComputeLayerClipRect(const PropertyTrees* property_trees,
956 const LayerImpl* layer) { 957 const LayerImpl* layer) {
957 const EffectTree* effect_tree = &property_trees->effect_tree; 958 const EffectTree* effect_tree = &property_trees->effect_tree;
958 const ClipTree* clip_tree = &property_trees->clip_tree; 959 const ClipTree* clip_tree = &property_trees->clip_tree;
960 const ClipNode* clip_node = clip_tree->Node(layer->clip_tree_index());
959 const EffectNode* effect_node = effect_tree->Node(layer->effect_tree_index()); 961 const EffectNode* effect_node = effect_tree->Node(layer->effect_tree_index());
960 const EffectNode* target_node = 962 const EffectNode* target_node =
961 effect_node->has_render_surface 963 effect_node->has_render_surface
962 ? effect_node 964 ? effect_node
963 : effect_tree->Node(effect_node->target_id); 965 : effect_tree->Node(effect_node->target_id);
964 // TODO(weiliangc): When effect node has up to date render surface info on 966 // TODO(weiliangc): When effect node has up to date render surface info on
965 // compositor thread, no need to check for resourceless draw mode 967 // compositor thread, no need to check for resourceless draw mode
966 if (!property_trees->non_root_surfaces_enabled) { 968 if (!property_trees->non_root_surfaces_enabled) {
967 target_node = effect_tree->Node(1); 969 target_node = effect_tree->Node(1);
968 } 970 }
969 971
970 bool include_viewport_clip = false; 972 bool include_viewport_clip = false;
971 ConditionalClip accumulated_clip_rect = 973 ConditionalClip accumulated_clip_rect =
972 ComputeAccumulatedClip(property_trees, include_viewport_clip, 974 ComputeAccumulatedClip(property_trees, include_viewport_clip,
973 layer->clip_tree_index(), target_node->id); 975 layer->clip_tree_index(), target_node->id);
974 976
977 bool is_clipped_from_clip_tree =
978 property_trees->non_root_surfaces_enabled
979 ? clip_node->layers_are_clipped
980 : clip_node->layers_are_clipped_when_surfaces_disabled;
981 DCHECK_EQ(is_clipped_from_clip_tree, accumulated_clip_rect.is_clipped);
982
975 gfx::RectF accumulated_clip = accumulated_clip_rect.clip_rect; 983 gfx::RectF accumulated_clip = accumulated_clip_rect.clip_rect;
976 984
977 if ((!property_trees->non_root_surfaces_enabled && 985 DCHECK(layer->clip_rect() == gfx::ToEnclosingRect(accumulated_clip))
978 clip_tree->Node(layer->clip_tree_index()) 986 << " layer: " << layer->id() << " clip id: " << layer->clip_tree_index()
979 ->layers_are_clipped_when_surfaces_disabled) || 987 << " layer clip: " << layer->clip_rect().ToString() << " v.s. "
980 clip_tree->Node(layer->clip_tree_index())->layers_are_clipped) { 988 << gfx::ToEnclosingRect(accumulated_clip).ToString()
981 DCHECK(layer->clip_rect() == gfx::ToEnclosingRect(accumulated_clip)) 989 << " and clip node clip: "
982 << " layer: " << layer->id() << " clip id: " << layer->clip_tree_index() 990 << gfx::ToEnclosingRect(clip_node->clip_in_target_space).ToString();
983 << " layer clip: " << layer->clip_rect().ToString() << " v.s. "
984 << gfx::ToEnclosingRect(accumulated_clip).ToString()
985 << " and clip node clip: "
986 << gfx::ToEnclosingRect(
987 clip_tree->Node(layer->clip_tree_index())->clip_in_target_space)
988 .ToString();
989 }
990 } 991 }
991 992
992 static void ComputeVisibleRectsInternal( 993 static void ComputeVisibleRectsInternal(
993 LayerImpl* root_layer, 994 LayerImpl* root_layer,
994 PropertyTrees* property_trees, 995 PropertyTrees* property_trees,
995 bool can_render_to_separate_surface, 996 bool can_render_to_separate_surface,
996 std::vector<LayerImpl*>* visible_layer_list) { 997 std::vector<LayerImpl*>* visible_layer_list) {
997 if (property_trees->non_root_surfaces_enabled != 998 if (property_trees->non_root_surfaces_enabled !=
998 can_render_to_separate_surface) { 999 can_render_to_separate_surface) {
999 property_trees->non_root_surfaces_enabled = can_render_to_separate_surface; 1000 property_trees->non_root_surfaces_enabled = can_render_to_separate_surface;
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after
1467 void UpdateElasticOverscroll(PropertyTrees* property_trees, 1468 void UpdateElasticOverscroll(PropertyTrees* property_trees,
1468 const Layer* overscroll_elasticity_layer, 1469 const Layer* overscroll_elasticity_layer,
1469 const gfx::Vector2dF& elastic_overscroll) { 1470 const gfx::Vector2dF& elastic_overscroll) {
1470 UpdateElasticOverscrollInternal(property_trees, overscroll_elasticity_layer, 1471 UpdateElasticOverscrollInternal(property_trees, overscroll_elasticity_layer,
1471 elastic_overscroll); 1472 elastic_overscroll);
1472 } 1473 }
1473 1474
1474 } // namespace draw_property_utils 1475 } // namespace draw_property_utils
1475 1476
1476 } // namespace cc 1477 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698