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

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

Issue 2087963003: cc: Stop creating unused 0 property tree nodes other than transform Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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
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 490 matching lines...) Expand 10 before | Expand all | Expand 10 after
501 if (std::isnan(rect->x()) || std::isnan(rect->y()) || 501 if (std::isnan(rect->x()) || std::isnan(rect->y()) ||
502 std::isnan(rect->right()) || std::isnan(rect->bottom())) 502 std::isnan(rect->right()) || std::isnan(rect->bottom()))
503 *rect = gfx::RectF(); 503 *rect = gfx::RectF();
504 } 504 }
505 505
506 void ComputeClips(ClipTree* clip_tree, 506 void ComputeClips(ClipTree* clip_tree,
507 const TransformTree& transform_tree, 507 const TransformTree& transform_tree,
508 bool non_root_surfaces_enabled) { 508 bool non_root_surfaces_enabled) {
509 if (!clip_tree->needs_update()) 509 if (!clip_tree->needs_update())
510 return; 510 return;
511 for (int i = 1; i < static_cast<int>(clip_tree->size()); ++i) { 511 for (int i = ClipTree::kRootNodeId; i < static_cast<int>(clip_tree->size());
512 ++i) {
512 ClipNode* clip_node = clip_tree->Node(i); 513 ClipNode* clip_node = clip_tree->Node(i);
513 514
514 if (clip_node->id == 1) { 515 if (clip_node->id == ClipTree::kRootNodeId) {
515 ResetIfHasNanCoordinate(&clip_node->data.clip); 516 ResetIfHasNanCoordinate(&clip_node->data.clip);
516 clip_node->data.clip_in_target_space = clip_node->data.clip; 517 clip_node->data.clip_in_target_space = clip_node->data.clip;
517 clip_node->data.combined_clip_in_target_space = clip_node->data.clip; 518 clip_node->data.combined_clip_in_target_space = clip_node->data.clip;
518 continue; 519 continue;
519 } 520 }
520 const TransformNode* transform_node = 521 const TransformNode* transform_node =
521 transform_tree.Node(clip_node->data.transform_id); 522 transform_tree.Node(clip_node->data.transform_id);
522 ClipNode* parent_clip_node = clip_tree->parent(clip_node); 523 ClipNode* parent_clip_node = clip_tree->parent(clip_node);
523 524
524 gfx::Transform parent_to_current; 525 gfx::Transform parent_to_current;
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
641 } 642 }
642 ResetIfHasNanCoordinate(&clip_node->data.clip_in_target_space); 643 ResetIfHasNanCoordinate(&clip_node->data.clip_in_target_space);
643 ResetIfHasNanCoordinate(&clip_node->data.combined_clip_in_target_space); 644 ResetIfHasNanCoordinate(&clip_node->data.combined_clip_in_target_space);
644 } 645 }
645 clip_tree->set_needs_update(false); 646 clip_tree->set_needs_update(false);
646 } 647 }
647 648
648 void ComputeTransforms(TransformTree* transform_tree) { 649 void ComputeTransforms(TransformTree* transform_tree) {
649 if (!transform_tree->needs_update()) 650 if (!transform_tree->needs_update())
650 return; 651 return;
651 for (int i = 1; i < static_cast<int>(transform_tree->size()); ++i) 652 for (int i = TransformTree::kRootNodeId;
653 i < static_cast<int>(transform_tree->size()); ++i)
652 transform_tree->UpdateTransforms(i); 654 transform_tree->UpdateTransforms(i);
653 transform_tree->set_needs_update(false); 655 transform_tree->set_needs_update(false);
654 } 656 }
655 657
656 void UpdateRenderTarget(EffectTree* effect_tree, 658 void UpdateRenderTarget(EffectTree* effect_tree,
657 bool can_render_to_separate_surface) { 659 bool can_render_to_separate_surface) {
658 for (int i = 1; i < static_cast<int>(effect_tree->size()); ++i) { 660 for (int i = EffectTree::kRootNodeId;
661 i < static_cast<int>(effect_tree->size()); ++i) {
659 EffectNode* node = effect_tree->Node(i); 662 EffectNode* node = effect_tree->Node(i);
660 if (i == 1) { 663 if (i == EffectTree::kRootNodeId) {
661 // Render target on the first effect node is root. 664 // Render target on the first effect node is root.
662 node->data.target_id = 0; 665 node->data.target_id = EffectTree::kRootNodeId;
663 } else if (!can_render_to_separate_surface) { 666 } else if (!can_render_to_separate_surface) {
ajuma 2016/06/22 13:29:50 This can be combined with the previous condition n
664 node->data.target_id = 1; 667 node->data.target_id = EffectTree::kRootNodeId;
665 } else if (effect_tree->parent(node)->data.has_render_surface) { 668 } else if (effect_tree->parent(node)->data.has_render_surface) {
666 node->data.target_id = node->parent_id; 669 node->data.target_id = node->parent_id;
667 } else { 670 } else {
668 node->data.target_id = effect_tree->parent(node)->data.target_id; 671 node->data.target_id = effect_tree->parent(node)->data.target_id;
669 } 672 }
670 } 673 }
671 } 674 }
672 675
673 void ComputeEffects(EffectTree* effect_tree) { 676 void ComputeEffects(EffectTree* effect_tree) {
674 if (!effect_tree->needs_update()) 677 if (!effect_tree->needs_update())
675 return; 678 return;
676 for (int i = 1; i < static_cast<int>(effect_tree->size()); ++i) 679 for (int i = EffectTree::kRootNodeId;
680 i < static_cast<int>(effect_tree->size()); ++i)
677 effect_tree->UpdateEffects(i); 681 effect_tree->UpdateEffects(i);
678 effect_tree->set_needs_update(false); 682 effect_tree->set_needs_update(false);
679 } 683 }
680 684
681 static gfx::RectF ComputeCurrentClip(const ClipNode* clip_node, 685 static gfx::RectF ComputeCurrentClip(const ClipNode* clip_node,
682 const TransformTree& transform_tree, 686 const TransformTree& transform_tree,
683 int target_transform_id) { 687 int target_transform_id) {
684 if (clip_node->data.transform_id != target_transform_id) { 688 if (clip_node->data.transform_id != target_transform_id) {
685 gfx::Transform current_to_target; 689 gfx::Transform current_to_target;
686 if (!transform_tree.ComputeTransformWithDestinationSublayerScale( 690 if (!transform_tree.ComputeTransformWithDestinationSublayerScale(
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
763 accumulated_clip = gfx::IntersectRects(accumulated_clip, current_clip); 767 accumulated_clip = gfx::IntersectRects(accumulated_clip, current_clip);
764 } 768 }
765 769
766 return accumulated_clip.IsEmpty() ? gfx::RectF() : accumulated_clip; 770 return accumulated_clip.IsEmpty() ? gfx::RectF() : accumulated_clip;
767 } 771 }
768 772
769 static void ComputeClipsWithEffectTree(PropertyTrees* property_trees) { 773 static void ComputeClipsWithEffectTree(PropertyTrees* property_trees) {
770 EffectTree* effect_tree = &property_trees->effect_tree; 774 EffectTree* effect_tree = &property_trees->effect_tree;
771 const ClipTree* clip_tree = &property_trees->clip_tree; 775 const ClipTree* clip_tree = &property_trees->clip_tree;
772 const TransformTree* transform_tree = &property_trees->transform_tree; 776 const TransformTree* transform_tree = &property_trees->transform_tree;
773 EffectNode* root_effect_node = effect_tree->Node(1); 777 EffectNode* root_effect_node = effect_tree->Node(EffectTree::kRootNodeId);
774 const RenderSurfaceImpl* root_render_surface = 778 const RenderSurfaceImpl* root_render_surface =
775 root_effect_node->data.render_surface; 779 root_effect_node->data.render_surface;
776 gfx::Rect root_clip = gfx::ToEnclosingRect( 780 gfx::Rect root_clip = gfx::ToEnclosingRect(
777 clip_tree->Node(root_effect_node->data.clip_id)->data.clip); 781 clip_tree->Node(root_effect_node->data.clip_id)->data.clip);
778 if (root_render_surface->is_clipped()) 782 if (root_render_surface->is_clipped())
779 DCHECK(root_clip == root_render_surface->clip_rect()) 783 DCHECK(root_clip == root_render_surface->clip_rect())
780 << "clip on root render surface: " 784 << "clip on root render surface: "
781 << root_render_surface->clip_rect().ToString() 785 << root_render_surface->clip_rect().ToString()
782 << " v.s. root effect node's clip: " << root_clip.ToString(); 786 << " v.s. root effect node's clip: " << root_clip.ToString();
783 for (int i = 2; i < static_cast<int>(effect_tree->size()); ++i) { 787 for (int i = 2; i < static_cast<int>(effect_tree->size()); ++i) {
ajuma 2016/06/22 17:06:57 Should this be kRootNodeId+1 instead of 2?
784 EffectNode* effect_node = effect_tree->Node(i); 788 EffectNode* effect_node = effect_tree->Node(i);
785 const EffectNode* target_node = 789 const EffectNode* target_node =
786 effect_tree->Node(effect_node->data.target_id); 790 effect_tree->Node(effect_node->data.target_id);
787 gfx::RectF accumulated_clip = 791 gfx::RectF accumulated_clip =
788 ComputeAccumulatedClip(*clip_tree, effect_node->data.clip_id, 792 ComputeAccumulatedClip(*clip_tree, effect_node->data.clip_id,
789 *effect_tree, target_node->id, *transform_tree); 793 *effect_tree, target_node->id, *transform_tree);
790 const RenderSurfaceImpl* render_surface = effect_node->data.render_surface; 794 const RenderSurfaceImpl* render_surface = effect_node->data.render_surface;
791 if (render_surface && render_surface->is_clipped()) { 795 if (render_surface && render_surface->is_clipped()) {
792 DCHECK(gfx::ToEnclosingRect(accumulated_clip) == 796 DCHECK(gfx::ToEnclosingRect(accumulated_clip) ==
793 render_surface->clip_rect()) 797 render_surface->clip_rect())
(...skipping 11 matching lines...) Expand all
805 const ClipTree* clip_tree = &property_trees->clip_tree; 809 const ClipTree* clip_tree = &property_trees->clip_tree;
806 const TransformTree* transform_tree = &property_trees->transform_tree; 810 const TransformTree* transform_tree = &property_trees->transform_tree;
807 const EffectNode* effect_node = effect_tree->Node(layer->effect_tree_index()); 811 const EffectNode* effect_node = effect_tree->Node(layer->effect_tree_index());
808 const EffectNode* target_node = 812 const EffectNode* target_node =
809 effect_node->data.has_render_surface 813 effect_node->data.has_render_surface
810 ? effect_node 814 ? effect_node
811 : effect_tree->Node(effect_node->data.target_id); 815 : effect_tree->Node(effect_node->data.target_id);
812 // TODO(weiliangc): When effect node has up to date render surface info on 816 // TODO(weiliangc): When effect node has up to date render surface info on
813 // compositor thread, no need to check for resourceless draw mode 817 // compositor thread, no need to check for resourceless draw mode
814 if (!property_trees->non_root_surfaces_enabled) { 818 if (!property_trees->non_root_surfaces_enabled) {
815 target_node = effect_tree->Node(1); 819 target_node = effect_tree->Node(EffectTree::kRootNodeId);
816 } 820 }
817 821
818 gfx::RectF accumulated_clip = 822 gfx::RectF accumulated_clip =
819 ComputeAccumulatedClip(*clip_tree, layer->clip_tree_index(), *effect_tree, 823 ComputeAccumulatedClip(*clip_tree, layer->clip_tree_index(), *effect_tree,
820 target_node->id, *transform_tree); 824 target_node->id, *transform_tree);
821 825
822 if ((!property_trees->non_root_surfaces_enabled && 826 if ((!property_trees->non_root_surfaces_enabled &&
823 clip_tree->Node(layer->clip_tree_index()) 827 clip_tree->Node(layer->clip_tree_index())
824 ->data.layers_are_clipped_when_surfaces_disabled) || 828 ->data.layers_are_clipped_when_surfaces_disabled) ||
825 clip_tree->Node(layer->clip_tree_index())->data.layers_are_clipped) { 829 clip_tree->Node(layer->clip_tree_index())->data.layers_are_clipped) {
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
977 // Surfaces need to apply their sublayer scale. 981 // Surfaces need to apply their sublayer scale.
978 xform.Scale(node->data.sublayer_scale.x(), node->data.sublayer_scale.y()); 982 xform.Scale(node->data.sublayer_scale.x(), node->data.sublayer_scale.y());
979 } 983 }
980 return xform; 984 return xform;
981 } 985 }
982 986
983 static void SetSurfaceDrawTransform(const TransformTree& tree, 987 static void SetSurfaceDrawTransform(const TransformTree& tree,
984 RenderSurfaceImpl* render_surface) { 988 RenderSurfaceImpl* render_surface) {
985 const TransformNode* node = tree.Node(render_surface->TransformTreeIndex()); 989 const TransformNode* node = tree.Node(render_surface->TransformTreeIndex());
986 // The draw transform of root render surface is identity tranform. 990 // The draw transform of root render surface is identity tranform.
987 if (node->id == 1) { 991 if (node->id == TransformTree::kRootNodeId) {
988 render_surface->SetDrawTransform(gfx::Transform()); 992 render_surface->SetDrawTransform(gfx::Transform());
989 return; 993 return;
990 } 994 }
991 995
992 gfx::Transform render_surface_transform; 996 gfx::Transform render_surface_transform;
993 const TransformNode* target_node = tree.Node(tree.TargetId(node->id)); 997 const TransformNode* target_node = tree.Node(tree.TargetId(node->id));
994 tree.ComputeTransformWithDestinationSublayerScale(node->id, target_node->id, 998 tree.ComputeTransformWithDestinationSublayerScale(node->id, target_node->id,
995 &render_surface_transform); 999 &render_surface_transform);
996 if (node->data.sublayer_scale.x() != 0.0 && 1000 if (node->data.sublayer_scale.x() != 0.0 &&
997 node->data.sublayer_scale.y() != 0.0) 1001 node->data.sublayer_scale.y() != 0.0)
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
1318 void UpdateElasticOverscroll(PropertyTrees* property_trees, 1322 void UpdateElasticOverscroll(PropertyTrees* property_trees,
1319 const Layer* overscroll_elasticity_layer, 1323 const Layer* overscroll_elasticity_layer,
1320 const gfx::Vector2dF& elastic_overscroll) { 1324 const gfx::Vector2dF& elastic_overscroll) {
1321 UpdateElasticOverscrollInternal(property_trees, overscroll_elasticity_layer, 1325 UpdateElasticOverscrollInternal(property_trees, overscroll_elasticity_layer,
1322 elastic_overscroll); 1326 elastic_overscroll);
1323 } 1327 }
1324 1328
1325 } // namespace draw_property_utils 1329 } // namespace draw_property_utils
1326 1330
1327 } // namespace cc 1331 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698