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

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

Issue 2295463002: [NOT FOR REVIEW] use cominbed clip for visible rect calculation
Patch Set: always use combined clip in target space Created 4 years, 3 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 | « 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 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 343
344 if (!clip_rect_in_target_space.IsEmpty()) { 344 if (!clip_rect_in_target_space.IsEmpty()) {
345 layer->set_clip_rect(gfx::ToEnclosingRect(clip_rect_in_target_space)); 345 layer->set_clip_rect(gfx::ToEnclosingRect(clip_rect_in_target_space));
346 } else { 346 } else {
347 layer->set_clip_rect(gfx::Rect()); 347 layer->set_clip_rect(gfx::Rect());
348 } 348 }
349 } 349 }
350 } 350 }
351 } 351 }
352 352
353 bool GetLayerClipRect(const LayerImpl* layer,
354 const ClipNode* clip_node,
355 const PropertyTrees* property_trees,
356 int target_node_id,
357 gfx::RectF* clip_rect_in_target_space) {
358 // This is equivalent of calling ComputeClipRectInTargetSpace.
359 *clip_rect_in_target_space = gfx::RectF(layer->clip_rect());
360 return property_trees->transform_tree.Node(target_node_id)
361 ->ancestors_are_invertible;
362 }
363
364 void CalculateVisibleRects(const LayerImplList& visible_layer_list, 353 void CalculateVisibleRects(const LayerImplList& visible_layer_list,
365 const PropertyTrees* property_trees, 354 const PropertyTrees* property_trees,
366 bool non_root_surfaces_enabled) { 355 bool non_root_surfaces_enabled) {
367 const EffectTree& effect_tree = property_trees->effect_tree; 356 const EffectTree& effect_tree = property_trees->effect_tree;
368 const TransformTree& transform_tree = property_trees->transform_tree; 357 const TransformTree& transform_tree = property_trees->transform_tree;
369 const ClipTree& clip_tree = property_trees->clip_tree; 358 const ClipTree& clip_tree = property_trees->clip_tree;
370 for (auto& layer : visible_layer_list) { 359 for (auto& layer : visible_layer_list) {
371 gfx::Size layer_bounds = layer->bounds(); 360 gfx::Size layer_bounds = layer->bounds();
372 361
373 int effect_ancestor_with_copy_request = 362 int effect_ancestor_with_copy_request =
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 426
438 if (fully_visible) { 427 if (fully_visible) {
439 layer->set_visible_layer_rect(gfx::Rect(layer_bounds)); 428 layer->set_visible_layer_rect(gfx::Rect(layer_bounds));
440 continue; 429 continue;
441 } 430 }
442 431
443 int target_node_id = transform_tree.ContentTargetId(transform_node->id); 432 int target_node_id = transform_tree.ContentTargetId(transform_node->id);
444 433
445 // The clip node stores clip rect in its target space. If required, 434 // The clip node stores clip rect in its target space. If required,
446 // this clip rect should be mapped to the current layer's target space. 435 // this clip rect should be mapped to the current layer's target space.
447 gfx::RectF combined_clip_rect_in_target_space; 436 gfx::RectF combined_clip_rect_in_target_space =
448 437 clip_node->combined_clip_in_target_space;
449 if (clip_node->target_transform_id != target_node_id) {
450 // In this case, layer has a clip parent or scroll parent (or shares the
451 // target with an ancestor layer that has clip parent) and the clip
452 // parent's target is different from the layer's target. As the layer's
453 // target has unclippped descendants, it is unclippped.
454 if (!clip_node->layers_are_clipped) {
455 layer->set_visible_layer_rect(gfx::Rect(layer_bounds));
456 continue;
457 }
458
459 // We use the clip node's clip_in_target_space (and not
460 // combined_clip_in_target_space) here because we want to clip
461 // with respect to clip parent's local clip and not its combined clip as
462 // the combined clip has even the clip parent's target's clip baked into
463 // it and as our target is different, we don't want to use it in our
464 // visible rect computation.
465 if (!GetLayerClipRect(layer, clip_node, property_trees, target_node_id,
466 &combined_clip_rect_in_target_space)) {
467 layer->set_visible_layer_rect(gfx::Rect(layer_bounds));
468 continue;
469 }
470 } else {
471 if (clip_node->target_is_clipped) {
472 combined_clip_rect_in_target_space =
473 clip_node->combined_clip_in_target_space;
474 } else {
475 combined_clip_rect_in_target_space = clip_node->clip_in_target_space;
476 }
477 }
478
479 // The clip rect should be intersected with layer rect in target space.
480 gfx::Transform content_to_target = transform_tree.ToTarget(
481 transform_node->id, layer->render_target_effect_tree_index());
482 content_to_target.Translate(layer->offset_to_transform_parent().x(),
483 layer->offset_to_transform_parent().y());
484 gfx::Rect layer_content_rect = gfx::Rect(layer_bounds);
485 gfx::RectF layer_content_bounds_in_target_space = MathUtil::MapClippedRect(
486 content_to_target, gfx::RectF(layer_content_rect));
487 // If the layer is fully contained within the clip, treat it as fully
488 // visible.
489 if (!layer_content_bounds_in_target_space.IsEmpty() &&
490 combined_clip_rect_in_target_space.Contains(
491 layer_content_bounds_in_target_space)) {
492 layer->set_visible_layer_rect(gfx::Rect(layer_bounds));
493 continue;
494 }
495
496 combined_clip_rect_in_target_space.Intersect(
497 layer_content_bounds_in_target_space);
498 if (combined_clip_rect_in_target_space.IsEmpty()) {
499 layer->set_visible_layer_rect(gfx::Rect());
500 continue;
501 }
502 438
503 gfx::Transform target_to_layer; 439 gfx::Transform target_to_layer;
504 if (transform_node->ancestors_are_invertible) { 440 if (transform_node->ancestors_are_invertible) {
505 target_to_layer = transform_tree.FromTarget( 441 target_to_layer = transform_tree.FromTarget(
506 transform_node->id, layer->render_target_effect_tree_index()); 442 transform_node->id, layer->render_target_effect_tree_index());
507 } else { 443 } else {
508 const EffectNode* target_effect_node = 444 const EffectNode* target_effect_node =
509 ContentsTargetEffectNode(layer->effect_tree_index(), effect_tree); 445 ContentsTargetEffectNode(layer->effect_tree_index(), effect_tree);
510 bool success = property_trees->ComputeTransformFromTarget( 446 bool success = property_trees->ComputeTransformFromTarget(
511 transform_node->id, target_effect_node->id, &target_to_layer); 447 transform_node->id, target_effect_node->id, &target_to_layer);
(...skipping 1083 matching lines...) Expand 10 before | Expand all | Expand 10 after
1595 void UpdateElasticOverscroll(PropertyTrees* property_trees, 1531 void UpdateElasticOverscroll(PropertyTrees* property_trees,
1596 const Layer* overscroll_elasticity_layer, 1532 const Layer* overscroll_elasticity_layer,
1597 const gfx::Vector2dF& elastic_overscroll) { 1533 const gfx::Vector2dF& elastic_overscroll) {
1598 UpdateElasticOverscrollInternal(property_trees, overscroll_elasticity_layer, 1534 UpdateElasticOverscrollInternal(property_trees, overscroll_elasticity_layer,
1599 elastic_overscroll); 1535 elastic_overscroll);
1600 } 1536 }
1601 1537
1602 } // namespace draw_property_utils 1538 } // namespace draw_property_utils
1603 1539
1604 } // namespace cc 1540 } // 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