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

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

Powered by Google App Engine
This is Rietveld 408576698