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

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

Issue 2166043002: cc: Compute target space transform dynamically (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Revert ancestors_are_invertible change Created 4 years, 5 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/test/test_layer_tree_host_base.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 461 matching lines...) Expand 10 before | Expand all | Expand 10 after
472 } else { 472 } else {
473 if (clip_node->target_is_clipped) { 473 if (clip_node->target_is_clipped) {
474 combined_clip_rect_in_target_space = 474 combined_clip_rect_in_target_space =
475 clip_node->combined_clip_in_target_space; 475 clip_node->combined_clip_in_target_space;
476 } else { 476 } else {
477 combined_clip_rect_in_target_space = clip_node->clip_in_target_space; 477 combined_clip_rect_in_target_space = clip_node->clip_in_target_space;
478 } 478 }
479 } 479 }
480 480
481 // The clip rect should be intersected with layer rect in target space. 481 // The clip rect should be intersected with layer rect in target space.
482 gfx::Transform content_to_target = 482 gfx::Transform content_to_target = transform_tree.ToTarget(
483 transform_tree.ToTarget(transform_node->id); 483 transform_node->id, layer->render_target_effect_tree_index());
484 content_to_target.Translate(layer->offset_to_transform_parent().x(), 484 content_to_target.Translate(layer->offset_to_transform_parent().x(),
485 layer->offset_to_transform_parent().y()); 485 layer->offset_to_transform_parent().y());
486 gfx::Rect layer_content_rect = gfx::Rect(layer_bounds); 486 gfx::Rect layer_content_rect = gfx::Rect(layer_bounds);
487 gfx::RectF layer_content_bounds_in_target_space = MathUtil::MapClippedRect( 487 gfx::RectF layer_content_bounds_in_target_space = MathUtil::MapClippedRect(
488 content_to_target, gfx::RectF(layer_content_rect)); 488 content_to_target, gfx::RectF(layer_content_rect));
489 // If the layer is fully contained within the clip, treat it as fully 489 // If the layer is fully contained within the clip, treat it as fully
490 // visible. 490 // visible.
491 if (!layer_content_bounds_in_target_space.IsEmpty() && 491 if (!layer_content_bounds_in_target_space.IsEmpty() &&
492 combined_clip_rect_in_target_space.Contains( 492 combined_clip_rect_in_target_space.Contains(
493 layer_content_bounds_in_target_space)) { 493 layer_content_bounds_in_target_space)) {
494 layer->set_visible_layer_rect(gfx::Rect(layer_bounds)); 494 layer->set_visible_layer_rect(gfx::Rect(layer_bounds));
495 continue; 495 continue;
496 } 496 }
497 497
498 combined_clip_rect_in_target_space.Intersect( 498 combined_clip_rect_in_target_space.Intersect(
499 layer_content_bounds_in_target_space); 499 layer_content_bounds_in_target_space);
500 if (combined_clip_rect_in_target_space.IsEmpty()) { 500 if (combined_clip_rect_in_target_space.IsEmpty()) {
501 layer->set_visible_layer_rect(gfx::Rect()); 501 layer->set_visible_layer_rect(gfx::Rect());
502 continue; 502 continue;
503 } 503 }
504 504
505 gfx::Transform target_to_layer; 505 gfx::Transform target_to_layer;
506 if (transform_node->ancestors_are_invertible) { 506 if (transform_node->ancestors_are_invertible) {
507 target_to_layer = transform_tree.FromTarget(transform_node->id); 507 target_to_layer = transform_tree.FromTarget(
508 transform_node->id, layer->render_target_effect_tree_index());
508 } else { 509 } else {
509 bool success = transform_tree.ComputeTransform( 510 bool success = transform_tree.ComputeTransform(
510 target_node_id, transform_node->id, &target_to_layer); 511 target_node_id, transform_node->id, &target_to_layer);
511 if (!success) { 512 if (!success) {
512 // An animated singular transform may become non-singular during the 513 // An animated singular transform may become non-singular during the
513 // animation, so we still need to compute a visible rect. In this 514 // animation, so we still need to compute a visible rect. In this
514 // situation, we treat the entire layer as visible. 515 // situation, we treat the entire layer as visible.
515 layer->set_visible_layer_rect(gfx::Rect(layer_bounds)); 516 layer->set_visible_layer_rect(gfx::Rect(layer_bounds));
516 continue; 517 continue;
517 } 518 }
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
552 return layer->id() == node->owner_id ? tree.parent(node)->id : node->id; 553 return layer->id() == node->owner_id ? tree.parent(node)->id : node->id;
553 } 554 }
554 555
555 template <typename LayerType> 556 template <typename LayerType>
556 static bool IsLayerBackFaceVisible(LayerType* layer, 557 static bool IsLayerBackFaceVisible(LayerType* layer,
557 int transform_tree_index, 558 int transform_tree_index,
558 const TransformTree& tree) { 559 const TransformTree& tree) {
559 const TransformNode* node = tree.Node(transform_tree_index); 560 const TransformNode* node = tree.Node(transform_tree_index);
560 return layer->use_local_transform_for_backface_visibility() 561 return layer->use_local_transform_for_backface_visibility()
561 ? node->local.IsBackFaceVisible() 562 ? node->local.IsBackFaceVisible()
562 : tree.ToTarget(transform_tree_index).IsBackFaceVisible(); 563 : tree.ToTarget(transform_tree_index,
564 layer->render_target_effect_tree_index())
565 .IsBackFaceVisible();
563 } 566 }
564 567
565 static inline bool TransformToScreenIsKnown(Layer* layer, 568 static inline bool TransformToScreenIsKnown(Layer* layer,
566 int transform_tree_index, 569 int transform_tree_index,
567 const TransformTree& tree) { 570 const TransformTree& tree) {
568 const TransformNode* node = tree.Node(transform_tree_index); 571 const TransformNode* node = tree.Node(transform_tree_index);
569 return !node->to_screen_is_potentially_animated; 572 return !node->to_screen_is_potentially_animated;
570 } 573 }
571 574
572 static inline bool TransformToScreenIsKnown(LayerImpl* layer, 575 static inline bool TransformToScreenIsKnown(LayerImpl* layer,
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
817 parent_to_current, parent_clip_node->clip_in_target_space); 820 parent_to_current, parent_clip_node->clip_in_target_space);
818 } 821 }
819 // Only nodes affected by ancestor clips will have their clip adjusted due 822 // Only nodes affected by ancestor clips will have their clip adjusted due
820 // to intersecting with an ancestor clip. But, we still need to propagate 823 // to intersecting with an ancestor clip. But, we still need to propagate
821 // the combined clip to our children because if they are clipped, they may 824 // the combined clip to our children because if they are clipped, they may
822 // need to clip using our parent clip and if we don't propagate it here, 825 // need to clip using our parent clip and if we don't propagate it here,
823 // it will be lost. 826 // it will be lost.
824 if (clip_node->resets_clip && non_root_surfaces_enabled) { 827 if (clip_node->resets_clip && non_root_surfaces_enabled) {
825 if (clip_node->applies_local_clip) { 828 if (clip_node->applies_local_clip) {
826 clip_node->clip_in_target_space = MathUtil::MapClippedRect( 829 clip_node->clip_in_target_space = MathUtil::MapClippedRect(
827 transform_tree.ToTarget(clip_node->transform_id), clip_node->clip); 830 transform_tree.ToTarget(clip_node->transform_id,
831 clip_node->target_effect_id),
832 clip_node->clip);
828 ResetIfHasNanCoordinate(&clip_node->clip_in_target_space); 833 ResetIfHasNanCoordinate(&clip_node->clip_in_target_space);
829 clip_node->combined_clip_in_target_space = 834 clip_node->combined_clip_in_target_space =
830 gfx::IntersectRects(clip_node->clip_in_target_space, 835 gfx::IntersectRects(clip_node->clip_in_target_space,
831 parent_combined_clip_in_target_space); 836 parent_combined_clip_in_target_space);
832 } else { 837 } else {
833 DCHECK(!clip_node->target_is_clipped); 838 DCHECK(!clip_node->target_is_clipped);
834 DCHECK(!clip_node->layers_are_clipped); 839 DCHECK(!clip_node->layers_are_clipped);
835 clip_node->combined_clip_in_target_space = 840 clip_node->combined_clip_in_target_space =
836 parent_combined_clip_in_target_space; 841 parent_combined_clip_in_target_space;
837 } 842 }
(...skipping 15 matching lines...) Expand all
853 // it to an empty rect. 858 // it to an empty rect.
854 clip_node->clip_in_target_space = gfx::RectF(); 859 clip_node->clip_in_target_space = gfx::RectF();
855 } 860 }
856 } else { 861 } else {
857 gfx::Transform source_to_target; 862 gfx::Transform source_to_target;
858 863
859 if (!non_root_surfaces_enabled) { 864 if (!non_root_surfaces_enabled) {
860 source_to_target = transform_tree.ToScreen(clip_node->transform_id); 865 source_to_target = transform_tree.ToScreen(clip_node->transform_id);
861 } else if (transform_tree.ContentTargetId(transform_node->id) == 866 } else if (transform_tree.ContentTargetId(transform_node->id) ==
862 clip_node->target_transform_id) { 867 clip_node->target_transform_id) {
863 source_to_target = transform_tree.ToTarget(clip_node->transform_id); 868 source_to_target = transform_tree.ToTarget(clip_node->transform_id,
869 clip_node->target_effect_id);
864 } else { 870 } else {
865 success = transform_tree.ComputeTransform( 871 success = transform_tree.ComputeTransform(
866 transform_node->id, clip_node->target_transform_id, 872 transform_node->id, clip_node->target_transform_id,
867 &source_to_target); 873 &source_to_target);
868 // We don't have to apply surface contents scale when target is root. 874 // We don't have to apply surface contents scale when target is root.
869 if (clip_node->target_transform_id != 0) { 875 if (clip_node->target_transform_id != 0) {
870 const EffectNode* target_effect_node = 876 const EffectNode* target_effect_node =
871 effect_tree.Node(clip_node->target_effect_id); 877 effect_tree.Node(clip_node->target_effect_id);
872 PostConcatSurfaceContentsScale(target_effect_node, &source_to_target); 878 PostConcatSurfaceContentsScale(target_effect_node, &source_to_target);
873 #if DCHECK_IS_ON() 879 #if DCHECK_IS_ON()
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after
1191 1197
1192 gfx::Transform DrawTransform(const LayerImpl* layer, 1198 gfx::Transform DrawTransform(const LayerImpl* layer,
1193 const TransformTree& transform_tree, 1199 const TransformTree& transform_tree,
1194 const EffectTree& effect_tree) { 1200 const EffectTree& effect_tree) {
1195 gfx::Transform xform; 1201 gfx::Transform xform;
1196 const bool owns_non_root_surface = 1202 const bool owns_non_root_surface =
1197 !IsRootLayer(layer) && layer->has_render_surface(); 1203 !IsRootLayer(layer) && layer->has_render_surface();
1198 if (!owns_non_root_surface) { 1204 if (!owns_non_root_surface) {
1199 // If you're not the root, or you don't own a surface, you need to apply 1205 // If you're not the root, or you don't own a surface, you need to apply
1200 // your local offset. 1206 // your local offset.
1201 xform = transform_tree.ToTarget(layer->transform_tree_index()); 1207 xform = transform_tree.ToTarget(layer->transform_tree_index(),
1208 layer->render_target_effect_tree_index());
1202 if (layer->should_flatten_transform_from_property_tree()) 1209 if (layer->should_flatten_transform_from_property_tree())
1203 xform.FlattenTo2d(); 1210 xform.FlattenTo2d();
1204 xform.Translate(layer->offset_to_transform_parent().x(), 1211 xform.Translate(layer->offset_to_transform_parent().x(),
1205 layer->offset_to_transform_parent().y()); 1212 layer->offset_to_transform_parent().y());
1206 } else { 1213 } else {
1207 // Surfaces need to apply their surface contents scale. 1214 // Surfaces need to apply their surface contents scale.
1208 const EffectNode* effect_node = 1215 const EffectNode* effect_node =
1209 effect_tree.Node(layer->effect_tree_index()); 1216 effect_tree.Node(layer->effect_tree_index());
1210 xform.Scale(effect_node->surface_contents_scale.x(), 1217 xform.Scale(effect_node->surface_contents_scale.x(),
1211 effect_node->surface_contents_scale.y()); 1218 effect_node->surface_contents_scale.y());
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
1587 void UpdateElasticOverscroll(PropertyTrees* property_trees, 1594 void UpdateElasticOverscroll(PropertyTrees* property_trees,
1588 const Layer* overscroll_elasticity_layer, 1595 const Layer* overscroll_elasticity_layer,
1589 const gfx::Vector2dF& elastic_overscroll) { 1596 const gfx::Vector2dF& elastic_overscroll) {
1590 UpdateElasticOverscrollInternal(property_trees, overscroll_elasticity_layer, 1597 UpdateElasticOverscrollInternal(property_trees, overscroll_elasticity_layer,
1591 elastic_overscroll); 1598 elastic_overscroll);
1592 } 1599 }
1593 1600
1594 } // namespace draw_property_utils 1601 } // namespace draw_property_utils
1595 1602
1596 } // namespace cc 1603 } // namespace cc
OLDNEW
« no previous file with comments | « cc/test/test_layer_tree_host_base.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