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

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

Issue 1310283002: cc: Avoid duplicate work when computing draw properties using property trees (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased Created 5 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
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 <vector> 7 #include <vector>
8 8
9 #include "cc/base/math_util.h" 9 #include "cc/base/math_util.h"
10 #include "cc/layers/layer.h" 10 #include "cc/layers/layer.h"
(...skipping 612 matching lines...) Expand 10 before | Expand all | Expand 10 after
623 void ComputeVisibleRectsUsingPropertyTrees(LayerImpl* root_layer, 623 void ComputeVisibleRectsUsingPropertyTrees(LayerImpl* root_layer,
624 PropertyTrees* property_trees, 624 PropertyTrees* property_trees,
625 LayerImplList* update_layer_list) { 625 LayerImplList* update_layer_list) {
626 ComputeVisibleRectsUsingPropertyTreesInternal(root_layer, property_trees, 626 ComputeVisibleRectsUsingPropertyTreesInternal(root_layer, property_trees,
627 update_layer_list); 627 update_layer_list);
628 } 628 }
629 629
630 template <typename LayerType> 630 template <typename LayerType>
631 gfx::Transform DrawTransformFromPropertyTreesInternal( 631 gfx::Transform DrawTransformFromPropertyTreesInternal(
632 const LayerType* layer, 632 const LayerType* layer,
633 const TransformTree& tree) { 633 const TransformNode* node) {
634 const TransformNode* node = tree.Node(layer->transform_tree_index());
635
636 gfx::Transform xform; 634 gfx::Transform xform;
637 const bool owns_non_root_surface = 635 const bool owns_non_root_surface =
638 layer->parent() && layer->has_render_surface(); 636 layer->parent() && layer->has_render_surface();
639 if (!owns_non_root_surface) { 637 if (!owns_non_root_surface) {
640 // If you're not the root, or you don't own a surface, you need to apply 638 // If you're not the root, or you don't own a surface, you need to apply
641 // your local offset. 639 // your local offset.
642 xform = node->data.to_target; 640 xform = node->data.to_target;
643 if (layer->should_flatten_transform_from_property_tree()) 641 if (layer->should_flatten_transform_from_property_tree())
644 xform.FlattenTo2d(); 642 xform.FlattenTo2d();
645 xform.Translate(layer->offset_to_transform_parent().x(), 643 xform.Translate(layer->offset_to_transform_parent().x(),
646 layer->offset_to_transform_parent().y()); 644 layer->offset_to_transform_parent().y());
647 } else { 645 } else {
648 // Surfaces need to apply their sublayer scale. 646 // Surfaces need to apply their sublayer scale.
649 xform.Scale(node->data.sublayer_scale.x(), node->data.sublayer_scale.y()); 647 xform.Scale(node->data.sublayer_scale.x(), node->data.sublayer_scale.y());
650 } 648 }
651 return xform; 649 return xform;
652 } 650 }
653 651
654 gfx::Transform DrawTransformFromPropertyTrees(const Layer* layer, 652 gfx::Transform DrawTransformFromPropertyTrees(const Layer* layer,
655 const TransformTree& tree) { 653 const TransformTree& tree) {
656 return DrawTransformFromPropertyTreesInternal(layer, tree); 654 return DrawTransformFromPropertyTreesInternal(
655 layer, tree.Node(layer->transform_tree_index()));
657 } 656 }
658 657
659 gfx::Transform DrawTransformFromPropertyTrees(const LayerImpl* layer, 658 gfx::Transform DrawTransformFromPropertyTrees(const LayerImpl* layer,
660 const TransformTree& tree) { 659 const TransformTree& tree) {
661 return DrawTransformFromPropertyTreesInternal(layer, tree); 660 return DrawTransformFromPropertyTreesInternal(
661 layer, tree.Node(layer->transform_tree_index()));
662 } 662 }
663 663
664 gfx::Transform DrawTransformOfRenderSurfaceFromPropertyTrees( 664 gfx::Transform SurfaceDrawTransform(const RenderSurfaceImpl* render_surface,
665 const RenderSurfaceImpl* render_surface, 665 const TransformTree& tree) {
666 const TransformTree& tree) {
667 const TransformNode* node = tree.Node(render_surface->TransformTreeIndex()); 666 const TransformNode* node = tree.Node(render_surface->TransformTreeIndex());
668 gfx::Transform render_surface_transform; 667 gfx::Transform render_surface_transform;
669 // The draw transform of root render surface is identity tranform. 668 // The draw transform of root render surface is identity tranform.
670 if (node->id == 1) 669 if (node->id == 1)
671 return render_surface_transform; 670 return render_surface_transform;
672 const TransformNode* target_node = tree.Node(node->data.target_id); 671 const TransformNode* target_node = tree.Node(node->data.target_id);
673 if (target_node->id == 1) 672 if (target_node->id == 1)
674 target_node = tree.Node(0); 673 target_node = tree.Node(0);
675 tree.ComputeTransformWithDestinationSublayerScale(node->id, target_node->id, 674 tree.ComputeTransformWithDestinationSublayerScale(node->id, target_node->id,
676 &render_surface_transform); 675 &render_surface_transform);
677 if (node->data.sublayer_scale.x() != 0.0 && 676 if (node->data.sublayer_scale.x() != 0.0 &&
678 node->data.sublayer_scale.y() != 0.0) 677 node->data.sublayer_scale.y() != 0.0)
679 render_surface_transform.Scale(1.0 / node->data.sublayer_scale.x(), 678 render_surface_transform.Scale(1.0 / node->data.sublayer_scale.x(),
680 1.0 / node->data.sublayer_scale.y()); 679 1.0 / node->data.sublayer_scale.y());
681 return render_surface_transform; 680 return render_surface_transform;
682 } 681 }
683 682
684 bool RenderSurfaceIsClippedFromPropertyTrees( 683 bool SurfaceIsClipped(const RenderSurfaceImpl* render_surface,
685 const RenderSurfaceImpl* render_surface, 684 const ClipNode* clip_node) {
686 const ClipTree& tree) {
687 const ClipNode* node = tree.Node(render_surface->ClipTreeIndex());
688 // If the render surface's owning layer doesn't form a clip node, it is not 685 // If the render surface's owning layer doesn't form a clip node, it is not
689 // clipped. 686 // clipped.
690 if (render_surface->OwningLayerId() != node->owner_id) 687 if (render_surface->OwningLayerId() != clip_node->owner_id)
691 return false; 688 return false;
692 return node->data.render_surface_is_clipped; 689 return clip_node->data.render_surface_is_clipped;
693 } 690 }
694 691
695 gfx::Rect ClipRectOfRenderSurfaceFromPropertyTrees( 692 gfx::Rect SurfaceClipRect(const RenderSurfaceImpl* render_surface,
696 const RenderSurfaceImpl* render_surface, 693 const ClipNode* parent_clip_node,
697 const ClipTree& clip_tree) { 694 bool is_clipped) {
698 if (!RenderSurfaceIsClippedFromPropertyTrees(render_surface, clip_tree)) 695 if (!is_clipped)
699 return gfx::Rect(); 696 return gfx::Rect();
700 const ClipNode* clip_node = clip_tree.Node(render_surface->ClipTreeIndex());
701 const ClipNode* parent_clip_node = clip_tree.parent(clip_node);
702 return gfx::ToEnclosingRect(parent_clip_node->data.clip_in_target_space); 697 return gfx::ToEnclosingRect(parent_clip_node->data.clip_in_target_space);
703 } 698 }
704 699
705 gfx::Transform ScreenSpaceTransformOfRenderSurfaceFromPropertyTrees( 700 gfx::Transform SurfaceScreenSpaceTransform(
706 const RenderSurfaceImpl* render_surface, 701 const RenderSurfaceImpl* render_surface,
707 const TransformTree& tree) { 702 const TransformTree& tree) {
708 const TransformNode* node = tree.Node(render_surface->TransformTreeIndex()); 703 const TransformNode* node = tree.Node(render_surface->TransformTreeIndex());
709 gfx::Transform screen_space_transform; 704 gfx::Transform screen_space_transform;
710 // The screen space transform of root render surface is identity tranform. 705 // The screen space transform of root render surface is identity tranform.
711 if (node->id == 1) 706 if (node->id == 1)
712 return screen_space_transform; 707 return screen_space_transform;
713 screen_space_transform = node->data.to_screen; 708 screen_space_transform = node->data.to_screen;
714 if (node->data.sublayer_scale.x() != 0.0 && 709 if (node->data.sublayer_scale.x() != 0.0 &&
715 node->data.sublayer_scale.y() != 0.0) 710 node->data.sublayer_scale.y() != 0.0)
716 screen_space_transform.Scale(1.0 / node->data.sublayer_scale.x(), 711 screen_space_transform.Scale(1.0 / node->data.sublayer_scale.x(),
717 1.0 / node->data.sublayer_scale.y()); 712 1.0 / node->data.sublayer_scale.y());
718 return screen_space_transform; 713 return screen_space_transform;
719 } 714 }
720 715
721 template <typename LayerType> 716 template <typename LayerType>
722 gfx::Transform ScreenSpaceTransformFromPropertyTreesInternal( 717 gfx::Transform ScreenSpaceTransformFromPropertyTreesInternal(
723 LayerType* layer, 718 LayerType* layer,
724 const TransformTree& tree) { 719 const TransformNode* node) {
725 gfx::Transform xform(1, 0, 0, 1, layer->offset_to_transform_parent().x(), 720 gfx::Transform xform(1, 0, 0, 1, layer->offset_to_transform_parent().x(),
726 layer->offset_to_transform_parent().y()); 721 layer->offset_to_transform_parent().y());
727 if (layer->transform_tree_index() >= 0) { 722 gfx::Transform ssxform = node->data.to_screen;
728 gfx::Transform ssxform = 723 xform.ConcatTransform(ssxform);
729 tree.Node(layer->transform_tree_index())->data.to_screen; 724 if (layer->should_flatten_transform_from_property_tree())
730 xform.ConcatTransform(ssxform); 725 xform.FlattenTo2d();
731 if (layer->should_flatten_transform_from_property_tree())
732 xform.FlattenTo2d();
733 }
734 return xform; 726 return xform;
735 } 727 }
736 728
737 gfx::Transform ScreenSpaceTransformFromPropertyTrees( 729 gfx::Transform ScreenSpaceTransformFromPropertyTrees(
738 const Layer* layer, 730 const Layer* layer,
739 const TransformTree& tree) { 731 const TransformTree& tree) {
740 return ScreenSpaceTransformFromPropertyTreesInternal(layer, tree); 732 return ScreenSpaceTransformFromPropertyTreesInternal(
733 layer, tree.Node(layer->transform_tree_index()));
741 } 734 }
742 735
743 gfx::Transform ScreenSpaceTransformFromPropertyTrees( 736 gfx::Transform ScreenSpaceTransformFromPropertyTrees(
744 const LayerImpl* layer, 737 const LayerImpl* layer,
745 const TransformTree& tree) { 738 const TransformTree& tree) {
746 return ScreenSpaceTransformFromPropertyTreesInternal(layer, tree); 739 return ScreenSpaceTransformFromPropertyTreesInternal(
740 layer, tree.Node(layer->transform_tree_index()));
747 } 741 }
748 742
749 template <typename LayerType> 743 float LayerDrawOpacity(const LayerImpl* layer, const EffectTree& tree) {
750 bool ScreenSpaceTransformIsAnimatingFromPropertyTreesInternal(
751 LayerType* layer,
752 const TransformTree& tree) {
753 return tree.Node(layer->transform_tree_index())->data.to_screen_is_animated;
754 }
755
756 bool ScreenSpaceTransformIsAnimatingFromPropertyTrees(
757 const Layer* layer,
758 const TransformTree& tree) {
759 return ScreenSpaceTransformIsAnimatingFromPropertyTreesInternal(layer, tree);
760 }
761
762 bool ScreenSpaceTransformIsAnimatingFromPropertyTrees(
763 const LayerImpl* layer,
764 const TransformTree& tree) {
765 return ScreenSpaceTransformIsAnimatingFromPropertyTreesInternal(layer, tree);
766 }
767
768 float MaximumAnimationTargetScaleFromPropertyTrees(const LayerImpl* layer,
769 const TransformTree& tree) {
770 if (!layer->layer_tree_impl()
771 ->settings()
772 .layer_transforms_should_scale_layer_contents)
773 return 0.f;
774
775 return tree.Node(layer->transform_tree_index())
776 ->data.combined_maximum_animation_target_scale;
777 }
778
779 float StartingAnimationScaleFromPropertyTrees(const LayerImpl* layer,
780 const TransformTree& tree) {
781 if (!layer->layer_tree_impl()
782 ->settings()
783 .layer_transforms_should_scale_layer_contents)
784 return 0.f;
785
786 return tree.Node(layer->transform_tree_index())
787 ->data.combined_starting_animation_scale;
788 }
789
790 float DrawOpacityFromPropertyTrees(const LayerImpl* layer,
791 const EffectTree& tree) {
792 if (!layer->render_target()) 744 if (!layer->render_target())
793 return 0.f; 745 return 0.f;
794 746
795 const EffectNode* target_node = 747 const EffectNode* target_node =
796 tree.Node(layer->render_target()->effect_tree_index()); 748 tree.Node(layer->render_target()->effect_tree_index());
797 const EffectNode* node = tree.Node(layer->effect_tree_index()); 749 const EffectNode* node = tree.Node(layer->effect_tree_index());
798 if (node == target_node) 750 if (node == target_node)
799 return 1.f; 751 return 1.f;
800 752
801 float draw_opacity = 1.f; 753 float draw_opacity = 1.f;
802 while (node != target_node) { 754 while (node != target_node) {
803 draw_opacity *= node->data.opacity; 755 draw_opacity *= node->data.opacity;
804 node = tree.parent(node); 756 node = tree.parent(node);
805 } 757 }
806 return draw_opacity; 758 return draw_opacity;
807 } 759 }
808 760
809 float DrawOpacityOfRenderSurfaceFromPropertyTrees( 761 float SurfaceDrawOpacity(RenderSurfaceImpl* render_surface,
810 RenderSurfaceImpl* render_surface, 762 const EffectTree& tree) {
811 const EffectTree& tree) {
812 const EffectNode* node = tree.Node(render_surface->EffectTreeIndex()); 763 const EffectNode* node = tree.Node(render_surface->EffectTreeIndex());
813 float target_opacity_tree_index = render_surface->TargetEffectTreeIndex(); 764 float target_opacity_tree_index = render_surface->TargetEffectTreeIndex();
814 if (target_opacity_tree_index < 0) 765 if (target_opacity_tree_index < 0)
815 return node->data.screen_space_opacity; 766 return node->data.screen_space_opacity;
816 const EffectNode* target_node = tree.Node(target_opacity_tree_index); 767 const EffectNode* target_node = tree.Node(target_opacity_tree_index);
817 float draw_opacity = 1.f; 768 float draw_opacity = 1.f;
818 while (node != target_node) { 769 while (node != target_node) {
819 draw_opacity *= node->data.opacity; 770 draw_opacity *= node->data.opacity;
820 node = tree.parent(node); 771 node = tree.parent(node);
821 } 772 }
822 return draw_opacity; 773 return draw_opacity;
823 } 774 }
824 775
825 bool CanUseLcdTextFromPropertyTrees(const LayerImpl* layer, 776 bool LayerCanUseLcdText(const LayerImpl* layer,
826 bool layers_always_allowed_lcd_text, 777 bool layers_always_allowed_lcd_text,
827 bool can_use_lcd_text, 778 bool can_use_lcd_text,
828 PropertyTrees* property_trees) { 779 const TransformNode* transform_node,
780 const EffectNode* effect_node) {
829 if (layers_always_allowed_lcd_text) 781 if (layers_always_allowed_lcd_text)
830 return true; 782 return true;
831 if (!can_use_lcd_text) 783 if (!can_use_lcd_text)
832 return false; 784 return false;
833 if (!layer->contents_opaque()) 785 if (!layer->contents_opaque())
834 return false; 786 return false;
835 DCHECK(!property_trees->transform_tree.needs_update());
836 DCHECK(!property_trees->effect_tree.needs_update());
837 787
838 const EffectNode* opacity_node = 788 if (effect_node->data.screen_space_opacity != 1.f)
839 property_trees->effect_tree.Node(layer->effect_tree_index());
840 if (opacity_node->data.screen_space_opacity != 1.f)
841 return false; 789 return false;
842 const TransformNode* transform_node =
843 property_trees->transform_tree.Node(layer->transform_tree_index());
844 if (!transform_node->data.node_and_ancestors_have_only_integer_translation) 790 if (!transform_node->data.node_and_ancestors_have_only_integer_translation)
845 return false; 791 return false;
846 if (static_cast<int>(layer->offset_to_transform_parent().x()) != 792 if (static_cast<int>(layer->offset_to_transform_parent().x()) !=
847 layer->offset_to_transform_parent().x()) 793 layer->offset_to_transform_parent().x())
848 return false; 794 return false;
849 if (static_cast<int>(layer->offset_to_transform_parent().y()) != 795 if (static_cast<int>(layer->offset_to_transform_parent().y()) !=
850 layer->offset_to_transform_parent().y()) 796 layer->offset_to_transform_parent().y())
851 return false; 797 return false;
852 return true; 798 return true;
853 } 799 }
854 800
855 gfx::Rect DrawableContentRectOfSurfaceFromPropertyTrees( 801 gfx::Rect LayerDrawableContentRect(
856 const RenderSurfaceImpl* render_surface, 802 const LayerImpl* layer,
857 const TransformTree& transform_tree) { 803 const gfx::Rect& layer_bounds_in_target_space,
858 gfx::Rect drawable_content_rect = 804 const gfx::Rect& clip_rect) {
859 gfx::ToEnclosingRect(MathUtil::MapClippedRect( 805 if (layer->is_clipped())
860 DrawTransformOfRenderSurfaceFromPropertyTrees(render_surface, 806 return IntersectRects(layer_bounds_in_target_space, clip_rect);
861 transform_tree),
862 render_surface->content_rect_from_property_trees()));
863 if (render_surface->HasReplica()) {
864 drawable_content_rect.Union(gfx::ToEnclosingRect(MathUtil::MapClippedRect(
865 DrawTransformOfRenderSurfaceReplicaFromPropertyTrees(render_surface,
866 transform_tree),
867 render_surface->content_rect_from_property_trees())));
868 }
869 return drawable_content_rect;
870 }
871 807
872 gfx::Rect DrawableContentRectFromPropertyTrees( 808 return layer_bounds_in_target_space;
873 const LayerImpl* layer,
874 const TransformTree& transform_tree) {
875 gfx::Rect drawable_content_rect = MathUtil::MapEnclosingClippedRect(
876 DrawTransformFromPropertyTrees(layer, transform_tree),
877 gfx::Rect(layer->bounds()));
878 if (layer->is_clipped()) {
879 drawable_content_rect.Intersect(
880 layer->clip_rect_in_target_space_from_property_trees());
881 }
882 return drawable_content_rect;
883 }
884
885 gfx::Rect ClipRectFromPropertyTrees(const LayerImpl* layer,
886 const TransformTree& transform_tree) {
887 if (layer->is_clipped())
888 return layer->clip_rect_in_target_space_from_property_trees();
889 return MathUtil::MapEnclosingClippedRect(
890 DrawTransformFromPropertyTrees(layer, transform_tree),
891 gfx::Rect(layer->bounds()));
892 } 809 }
893 810
894 gfx::Transform ReplicaToSurfaceTransform( 811 gfx::Transform ReplicaToSurfaceTransform(
895 const RenderSurfaceImpl* render_surface, 812 const RenderSurfaceImpl* render_surface,
896 const TransformTree& tree) { 813 const TransformTree& tree) {
897 gfx::Transform replica_to_surface; 814 gfx::Transform replica_to_surface;
898 if (!render_surface->HasReplica()) 815 if (!render_surface->HasReplica())
899 return replica_to_surface; 816 return replica_to_surface;
900 const LayerImpl* replica_layer = render_surface->ReplicaLayer(); 817 const LayerImpl* replica_layer = render_surface->ReplicaLayer();
901 const TransformNode* surface_transform_node = 818 const TransformNode* surface_transform_node =
902 tree.Node(render_surface->TransformTreeIndex()); 819 tree.Node(render_surface->TransformTreeIndex());
903 replica_to_surface.Scale(surface_transform_node->data.sublayer_scale.x(), 820 replica_to_surface.Scale(surface_transform_node->data.sublayer_scale.x(),
904 surface_transform_node->data.sublayer_scale.y()); 821 surface_transform_node->data.sublayer_scale.y());
905 replica_to_surface.Translate(replica_layer->offset_to_transform_parent().x(), 822 replica_to_surface.Translate(replica_layer->offset_to_transform_parent().x(),
906 replica_layer->offset_to_transform_parent().y()); 823 replica_layer->offset_to_transform_parent().y());
907 gfx::Transform replica_transform_node_to_surface; 824 gfx::Transform replica_transform_node_to_surface;
908 tree.ComputeTransform(replica_layer->transform_tree_index(), 825 tree.ComputeTransform(replica_layer->transform_tree_index(),
909 render_surface->TransformTreeIndex(), 826 render_surface->TransformTreeIndex(),
910 &replica_transform_node_to_surface); 827 &replica_transform_node_to_surface);
911 replica_to_surface.PreconcatTransform(replica_transform_node_to_surface); 828 replica_to_surface.PreconcatTransform(replica_transform_node_to_surface);
912 if (surface_transform_node->data.sublayer_scale.x() != 0 && 829 if (surface_transform_node->data.sublayer_scale.x() != 0 &&
913 surface_transform_node->data.sublayer_scale.y() != 0) { 830 surface_transform_node->data.sublayer_scale.y() != 0) {
914 replica_to_surface.Scale( 831 replica_to_surface.Scale(
915 1.0 / surface_transform_node->data.sublayer_scale.x(), 832 1.0 / surface_transform_node->data.sublayer_scale.x(),
916 1.0 / surface_transform_node->data.sublayer_scale.y()); 833 1.0 / surface_transform_node->data.sublayer_scale.y());
917 } 834 }
918 return replica_to_surface; 835 return replica_to_surface;
919 } 836 }
920 837
921 gfx::Transform DrawTransformOfRenderSurfaceReplicaFromPropertyTrees( 838 gfx::Rect LayerClipRect(const LayerImpl* layer,
922 const RenderSurfaceImpl* render_surface, 839 const gfx::Rect& layer_bounds_in_target_space) {
923 const TransformTree& tree) { 840 if (layer->is_clipped())
924 if (!render_surface->HasReplica()) 841 return layer->clip_rect_in_target_space_from_property_trees();
925 return gfx::Transform(); 842
926 return DrawTransformOfRenderSurfaceFromPropertyTrees(render_surface, tree) * 843 return layer_bounds_in_target_space;
927 ReplicaToSurfaceTransform(render_surface, tree);
928 } 844 }
929 845
930 gfx::Transform ScreenSpaceTransformOfRenderSurfaceReplicaFromPropertyTrees( 846 void ComputeLayerDrawPropertiesUsingPropertyTrees(
enne (OOO) 2015/09/02 21:51:35 I love how simple this function is!
931 const RenderSurfaceImpl* render_surface, 847 const LayerImpl* layer,
932 const TransformTree& tree) { 848 const PropertyTrees* property_trees,
933 if (!render_surface->HasReplica()) 849 bool layers_always_allowed_lcd_text,
934 return gfx::Transform(); 850 bool can_use_lcd_text,
935 return ScreenSpaceTransformOfRenderSurfaceFromPropertyTrees(render_surface, 851 DrawProperties* draw_properties) {
936 tree) * 852 draw_properties->visible_layer_rect =
937 ReplicaToSurfaceTransform(render_surface, tree); 853 layer->visible_rect_from_property_trees();
854
855 const TransformNode* transform_node =
856 property_trees->transform_tree.Node(layer->transform_tree_index());
857 const EffectNode* effect_node =
858 property_trees->effect_tree.Node(layer->effect_tree_index());
859
860 draw_properties->target_space_transform =
861 DrawTransformFromPropertyTreesInternal(layer, transform_node);
862 draw_properties->screen_space_transform =
863 ScreenSpaceTransformFromPropertyTreesInternal(layer, transform_node);
864 draw_properties->screen_space_transform_is_animating =
865 transform_node->data.to_screen_is_animated;
866 if (layer->layer_tree_impl()
867 ->settings()
868 .layer_transforms_should_scale_layer_contents) {
869 draw_properties->maximum_animation_contents_scale =
870 transform_node->data.combined_maximum_animation_target_scale;
871 draw_properties->starting_animation_contents_scale =
872 transform_node->data.combined_starting_animation_scale;
873 } else {
874 draw_properties->maximum_animation_contents_scale = 0.f;
875 draw_properties->starting_animation_contents_scale = 0.f;
876 }
877
878 draw_properties->opacity =
879 LayerDrawOpacity(layer, property_trees->effect_tree);
880 draw_properties->can_use_lcd_text =
881 LayerCanUseLcdText(layer, layers_always_allowed_lcd_text,
882 can_use_lcd_text, transform_node, effect_node);
883
884 gfx::Rect bounds_in_target_space = MathUtil::MapEnclosingClippedRect(
885 draw_properties->target_space_transform, gfx::Rect(layer->bounds()));
886 draw_properties->clip_rect = LayerClipRect(layer, bounds_in_target_space);
887 draw_properties->drawable_content_rect = LayerDrawableContentRect(
888 layer, bounds_in_target_space, draw_properties->clip_rect);
889 }
890
891 SurfaceDrawProperties::SurfaceDrawProperties()
892 : is_clipped(false), draw_opacity(0.f) {}
893
894 SurfaceDrawProperties::~SurfaceDrawProperties() {}
895
896 void ComputeSurfaceDrawPropertiesUsingPropertyTrees(
897 RenderSurfaceImpl* render_surface,
898 const PropertyTrees* property_trees,
899 SurfaceDrawProperties* draw_properties) {
900 const ClipNode* clip_node =
901 property_trees->clip_tree.Node(render_surface->ClipTreeIndex());
902
903 draw_properties->is_clipped = SurfaceIsClipped(render_surface, clip_node);
904 draw_properties->draw_opacity =
905 SurfaceDrawOpacity(render_surface, property_trees->effect_tree);
906 draw_properties->draw_transform =
907 SurfaceDrawTransform(render_surface, property_trees->transform_tree);
908 draw_properties->screen_space_transform = SurfaceScreenSpaceTransform(
909 render_surface, property_trees->transform_tree);
910
911 if (render_surface->HasReplica()) {
912 gfx::Transform replica_to_surface = ReplicaToSurfaceTransform(
913 render_surface, property_trees->transform_tree);
914 draw_properties->replica_draw_transform =
915 draw_properties->draw_transform * replica_to_surface;
916 draw_properties->replica_screen_space_transform =
917 draw_properties->screen_space_transform * replica_to_surface;
918 } else {
919 draw_properties->replica_draw_transform.MakeIdentity();
920 draw_properties->replica_screen_space_transform.MakeIdentity();
921 }
922
923 draw_properties->clip_rect = SurfaceClipRect(
924 render_surface, property_trees->clip_tree.parent(clip_node),
925 draw_properties->is_clipped);
938 } 926 }
939 927
940 } // namespace cc 928 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698