OLD | NEW |
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/output/compositor_frame.h" | 5 #include "cc/output/compositor_frame.h" |
6 #include "cc/output/delegated_frame_data.h" | 6 #include "cc/output/delegated_frame_data.h" |
7 #include "cc/quads/render_pass.h" | 7 #include "cc/quads/render_pass.h" |
8 #include "cc/quads/render_pass_draw_quad.h" | 8 #include "cc/quads/render_pass_draw_quad.h" |
9 #include "cc/quads/solid_color_draw_quad.h" | 9 #include "cc/quads/solid_color_draw_quad.h" |
10 #include "cc/quads/surface_draw_quad.h" | 10 #include "cc/quads/surface_draw_quad.h" |
(...skipping 680 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
691 DelegatedFrameData* frame_data = aggregated_frame->delegated_frame_data.get(); | 691 DelegatedFrameData* frame_data = aggregated_frame->delegated_frame_data.get(); |
692 | 692 |
693 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list; | 693 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list; |
694 | 694 |
695 ASSERT_EQ(1u, aggregated_pass_list.size()); | 695 ASSERT_EQ(1u, aggregated_pass_list.size()); |
696 | 696 |
697 const QuadList& aggregated_quad_list = aggregated_pass_list[0]->quad_list; | 697 const QuadList& aggregated_quad_list = aggregated_pass_list[0]->quad_list; |
698 | 698 |
699 ASSERT_EQ(7u, aggregated_quad_list.size()); | 699 ASSERT_EQ(7u, aggregated_quad_list.size()); |
700 | 700 |
701 size_t i = 0; | |
702 for (QuadList::ConstIterator iter = aggregated_quad_list.begin(); | 701 for (QuadList::ConstIterator iter = aggregated_quad_list.begin(); |
703 iter != aggregated_quad_list.end(); | 702 iter != aggregated_quad_list.end(); |
704 ++iter) { | 703 ++iter) { |
705 EXPECT_EQ(blend_modes[i], iter->shared_quad_state->blend_mode) << i; | 704 EXPECT_EQ(blend_modes[iter.index()], iter->shared_quad_state->blend_mode) |
706 ++i; | 705 << iter.index(); |
707 } | 706 } |
708 factory_.Destroy(child_one_surface_id); | 707 factory_.Destroy(child_one_surface_id); |
709 factory_.Destroy(child_two_surface_id); | 708 factory_.Destroy(child_two_surface_id); |
710 factory_.Destroy(grandchild_surface_id); | 709 factory_.Destroy(grandchild_surface_id); |
711 } | 710 } |
712 | 711 |
713 // This tests that when aggregating a frame with multiple render passes that we | 712 // This tests that when aggregating a frame with multiple render passes that we |
714 // map the transforms for the root pass but do not modify the transform on child | 713 // map the transforms for the root pass but do not modify the transform on child |
715 // passes. | 714 // passes. |
716 // | 715 // |
(...skipping 21 matching lines...) Expand all Loading... |
738 | 737 |
739 RenderPassList child_pass_list; | 738 RenderPassList child_pass_list; |
740 AddPasses(&child_pass_list, | 739 AddPasses(&child_pass_list, |
741 gfx::Rect(SurfaceSize()), | 740 gfx::Rect(SurfaceSize()), |
742 child_passes, | 741 child_passes, |
743 arraysize(child_passes)); | 742 arraysize(child_passes)); |
744 | 743 |
745 RenderPass* child_nonroot_pass = child_pass_list.at(0u); | 744 RenderPass* child_nonroot_pass = child_pass_list.at(0u); |
746 child_nonroot_pass->transform_to_root_target.Translate(8, 0); | 745 child_nonroot_pass->transform_to_root_target.Translate(8, 0); |
747 SharedQuadState* child_nonroot_pass_sqs = | 746 SharedQuadState* child_nonroot_pass_sqs = |
748 child_nonroot_pass->shared_quad_state_list[0]; | 747 child_nonroot_pass->shared_quad_state_list.front(); |
749 child_nonroot_pass_sqs->content_to_target_transform.Translate(5, 0); | 748 child_nonroot_pass_sqs->content_to_target_transform.Translate(5, 0); |
750 | 749 |
751 RenderPass* child_root_pass = child_pass_list.at(1u); | 750 RenderPass* child_root_pass = child_pass_list.at(1u); |
752 SharedQuadState* child_root_pass_sqs = | 751 SharedQuadState* child_root_pass_sqs = |
753 child_root_pass->shared_quad_state_list[0]; | 752 child_root_pass->shared_quad_state_list.front(); |
754 child_root_pass_sqs->content_to_target_transform.Translate(8, 0); | 753 child_root_pass_sqs->content_to_target_transform.Translate(8, 0); |
755 child_root_pass_sqs->is_clipped = true; | 754 child_root_pass_sqs->is_clipped = true; |
756 child_root_pass_sqs->clip_rect = gfx::Rect(0, 0, 5, 5); | 755 child_root_pass_sqs->clip_rect = gfx::Rect(0, 0, 5, 5); |
757 | 756 |
758 scoped_ptr<DelegatedFrameData> child_frame_data(new DelegatedFrameData); | 757 scoped_ptr<DelegatedFrameData> child_frame_data(new DelegatedFrameData); |
759 child_pass_list.swap(child_frame_data->render_pass_list); | 758 child_pass_list.swap(child_frame_data->render_pass_list); |
760 | 759 |
761 scoped_ptr<CompositorFrame> child_frame(new CompositorFrame); | 760 scoped_ptr<CompositorFrame> child_frame(new CompositorFrame); |
762 child_frame->delegated_frame_data = child_frame_data.Pass(); | 761 child_frame->delegated_frame_data = child_frame_data.Pass(); |
763 | 762 |
764 factory_.SubmitFrame(child_surface_id, child_frame.Pass(), base::Closure()); | 763 factory_.SubmitFrame(child_surface_id, child_frame.Pass(), base::Closure()); |
765 | 764 |
766 test::Quad root_quads[] = {test::Quad::SolidColorQuad(1), | 765 test::Quad root_quads[] = {test::Quad::SolidColorQuad(1), |
767 test::Quad::SurfaceQuad(child_surface_id)}; | 766 test::Quad::SurfaceQuad(child_surface_id)}; |
768 test::Pass root_passes[] = {test::Pass(root_quads, arraysize(root_quads))}; | 767 test::Pass root_passes[] = {test::Pass(root_quads, arraysize(root_quads))}; |
769 | 768 |
770 RenderPassList root_pass_list; | 769 RenderPassList root_pass_list; |
771 AddPasses(&root_pass_list, | 770 AddPasses(&root_pass_list, |
772 gfx::Rect(SurfaceSize()), | 771 gfx::Rect(SurfaceSize()), |
773 root_passes, | 772 root_passes, |
774 arraysize(root_passes)); | 773 arraysize(root_passes)); |
775 | 774 |
776 root_pass_list.at(0) | 775 root_pass_list.at(0) |
777 ->shared_quad_state_list[0] | 776 ->shared_quad_state_list.front() |
778 ->content_to_target_transform.Translate(0, 7); | 777 ->content_to_target_transform.Translate(0, 7); |
779 root_pass_list.at(0) | 778 root_pass_list.at(0) |
780 ->shared_quad_state_list[1] | 779 ->shared_quad_state_list.ElementAt(1) |
781 ->content_to_target_transform.Translate(0, 10); | 780 ->content_to_target_transform.Translate(0, 10); |
782 | 781 |
783 scoped_ptr<DelegatedFrameData> root_frame_data(new DelegatedFrameData); | 782 scoped_ptr<DelegatedFrameData> root_frame_data(new DelegatedFrameData); |
784 root_pass_list.swap(root_frame_data->render_pass_list); | 783 root_pass_list.swap(root_frame_data->render_pass_list); |
785 | 784 |
786 scoped_ptr<CompositorFrame> root_frame(new CompositorFrame); | 785 scoped_ptr<CompositorFrame> root_frame(new CompositorFrame); |
787 root_frame->delegated_frame_data = root_frame_data.Pass(); | 786 root_frame->delegated_frame_data = root_frame_data.Pass(); |
788 | 787 |
789 factory_.SubmitFrame(root_surface_id_, root_frame.Pass(), base::Closure()); | 788 factory_.SubmitFrame(root_surface_id_, root_frame.Pass(), base::Closure()); |
790 | 789 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
831 gfx::Transform expected_root_pass_quad_transforms[2]; | 830 gfx::Transform expected_root_pass_quad_transforms[2]; |
832 // The first quad in the root pass is the solid color quad from the original | 831 // The first quad in the root pass is the solid color quad from the original |
833 // root surface. Its transform should be unaffected by the aggregation and | 832 // root surface. Its transform should be unaffected by the aggregation and |
834 // still be +7 in the y direction. | 833 // still be +7 in the y direction. |
835 expected_root_pass_quad_transforms[0].Translate(0, 7); | 834 expected_root_pass_quad_transforms[0].Translate(0, 7); |
836 // The second quad in the root pass is aggregated from the child surface so | 835 // The second quad in the root pass is aggregated from the child surface so |
837 // its transform should be the combination of its original translation (0, 10) | 836 // its transform should be the combination of its original translation (0, 10) |
838 // and the child surface draw quad's translation (8, 0). | 837 // and the child surface draw quad's translation (8, 0). |
839 expected_root_pass_quad_transforms[1].Translate(8, 10); | 838 expected_root_pass_quad_transforms[1].Translate(8, 10); |
840 | 839 |
841 size_t i = 0; | |
842 for (QuadList::Iterator iter = aggregated_pass_list[1]->quad_list.begin(); | 840 for (QuadList::Iterator iter = aggregated_pass_list[1]->quad_list.begin(); |
843 iter != aggregated_pass_list[1]->quad_list.end(); | 841 iter != aggregated_pass_list[1]->quad_list.end(); |
844 ++iter) { | 842 ++iter) { |
845 EXPECT_EQ(expected_root_pass_quad_transforms[i].ToString(), | 843 EXPECT_EQ(expected_root_pass_quad_transforms[iter.index()].ToString(), |
846 iter->quadTransform().ToString()) | 844 iter->quadTransform().ToString()) |
847 << i; | 845 << iter.index(); |
848 i++; | |
849 } | 846 } |
850 | 847 |
851 EXPECT_EQ(true, | 848 EXPECT_TRUE( |
852 aggregated_pass_list[1]->shared_quad_state_list[1]->is_clipped); | 849 aggregated_pass_list[1]->shared_quad_state_list.ElementAt(1)->is_clipped); |
853 | 850 |
854 // The second quad in the root pass is aggregated from the child, so its | 851 // The second quad in the root pass is aggregated from the child, so its |
855 // clip rect must be transformed by the child's translation. | 852 // clip rect must be transformed by the child's translation. |
856 EXPECT_EQ( | 853 EXPECT_EQ(gfx::Rect(0, 10, 5, 5).ToString(), |
857 gfx::Rect(0, 10, 5, 5).ToString(), | 854 aggregated_pass_list[1] |
858 aggregated_pass_list[1]->shared_quad_state_list[1]->clip_rect.ToString()); | 855 ->shared_quad_state_list.ElementAt(1) |
| 856 ->clip_rect.ToString()); |
859 | 857 |
860 factory_.Destroy(child_surface_id); | 858 factory_.Destroy(child_surface_id); |
861 } | 859 } |
862 | 860 |
863 // Tests that damage rects are aggregated correctly when surfaces change. | 861 // Tests that damage rects are aggregated correctly when surfaces change. |
864 TEST_F(SurfaceAggregatorValidSurfaceTest, AggregateDamageRect) { | 862 TEST_F(SurfaceAggregatorValidSurfaceTest, AggregateDamageRect) { |
865 SurfaceId child_surface_id = allocator_.GenerateId(); | 863 SurfaceId child_surface_id = allocator_.GenerateId(); |
866 factory_.Create(child_surface_id, SurfaceSize()); | 864 factory_.Create(child_surface_id, SurfaceSize()); |
867 RenderPassId child_pass_id = RenderPassId(1, 1); | 865 RenderPassId child_pass_id = RenderPassId(1, 1); |
868 test::Quad child_quads[] = {test::Quad::RenderPassQuad(child_pass_id)}; | 866 test::Quad child_quads[] = {test::Quad::RenderPassQuad(child_pass_id)}; |
869 test::Pass child_passes[] = { | 867 test::Pass child_passes[] = { |
870 test::Pass(child_quads, arraysize(child_quads), child_pass_id)}; | 868 test::Pass(child_quads, arraysize(child_quads), child_pass_id)}; |
871 | 869 |
872 RenderPassList child_pass_list; | 870 RenderPassList child_pass_list; |
873 AddPasses(&child_pass_list, | 871 AddPasses(&child_pass_list, |
874 gfx::Rect(SurfaceSize()), | 872 gfx::Rect(SurfaceSize()), |
875 child_passes, | 873 child_passes, |
876 arraysize(child_passes)); | 874 arraysize(child_passes)); |
877 | 875 |
878 RenderPass* child_root_pass = child_pass_list.at(0u); | 876 RenderPass* child_root_pass = child_pass_list.at(0u); |
879 SharedQuadState* child_root_pass_sqs = | 877 SharedQuadState* child_root_pass_sqs = |
880 child_root_pass->shared_quad_state_list[0]; | 878 child_root_pass->shared_quad_state_list.front(); |
881 child_root_pass_sqs->content_to_target_transform.Translate(8, 0); | 879 child_root_pass_sqs->content_to_target_transform.Translate(8, 0); |
882 | 880 |
883 scoped_ptr<DelegatedFrameData> child_frame_data(new DelegatedFrameData); | 881 scoped_ptr<DelegatedFrameData> child_frame_data(new DelegatedFrameData); |
884 child_pass_list.swap(child_frame_data->render_pass_list); | 882 child_pass_list.swap(child_frame_data->render_pass_list); |
885 | 883 |
886 scoped_ptr<CompositorFrame> child_frame(new CompositorFrame); | 884 scoped_ptr<CompositorFrame> child_frame(new CompositorFrame); |
887 child_frame->delegated_frame_data = child_frame_data.Pass(); | 885 child_frame->delegated_frame_data = child_frame_data.Pass(); |
888 | 886 |
889 factory_.SubmitFrame(child_surface_id, child_frame.Pass(), base::Closure()); | 887 factory_.SubmitFrame(child_surface_id, child_frame.Pass(), base::Closure()); |
890 | 888 |
891 test::Quad root_quads[] = {test::Quad::SurfaceQuad(child_surface_id)}; | 889 test::Quad root_quads[] = {test::Quad::SurfaceQuad(child_surface_id)}; |
892 test::Pass root_passes[] = {test::Pass(root_quads, arraysize(root_quads))}; | 890 test::Pass root_passes[] = {test::Pass(root_quads, arraysize(root_quads))}; |
893 | 891 |
894 RenderPassList root_pass_list; | 892 RenderPassList root_pass_list; |
895 AddPasses(&root_pass_list, | 893 AddPasses(&root_pass_list, |
896 gfx::Rect(SurfaceSize()), | 894 gfx::Rect(SurfaceSize()), |
897 root_passes, | 895 root_passes, |
898 arraysize(root_passes)); | 896 arraysize(root_passes)); |
899 | 897 |
900 root_pass_list.at(0) | 898 root_pass_list.at(0) |
901 ->shared_quad_state_list[0] | 899 ->shared_quad_state_list.front() |
902 ->content_to_target_transform.Translate(0, 10); | 900 ->content_to_target_transform.Translate(0, 10); |
903 root_pass_list.at(0)->damage_rect = gfx::Rect(5, 5, 10, 10); | 901 root_pass_list.at(0)->damage_rect = gfx::Rect(5, 5, 10, 10); |
904 | 902 |
905 scoped_ptr<DelegatedFrameData> root_frame_data(new DelegatedFrameData); | 903 scoped_ptr<DelegatedFrameData> root_frame_data(new DelegatedFrameData); |
906 root_pass_list.swap(root_frame_data->render_pass_list); | 904 root_pass_list.swap(root_frame_data->render_pass_list); |
907 | 905 |
908 scoped_ptr<CompositorFrame> root_frame(new CompositorFrame); | 906 scoped_ptr<CompositorFrame> root_frame(new CompositorFrame); |
909 root_frame->delegated_frame_data = root_frame_data.Pass(); | 907 root_frame->delegated_frame_data = root_frame_data.Pass(); |
910 | 908 |
911 factory_.SubmitFrame(root_surface_id_, root_frame.Pass(), base::Closure()); | 909 factory_.SubmitFrame(root_surface_id_, root_frame.Pass(), base::Closure()); |
(...skipping 15 matching lines...) Expand all Loading... |
927 aggregated_pass_list[0]->damage_rect.Contains(gfx::Rect(SurfaceSize()))); | 925 aggregated_pass_list[0]->damage_rect.Contains(gfx::Rect(SurfaceSize()))); |
928 | 926 |
929 { | 927 { |
930 AddPasses(&child_pass_list, | 928 AddPasses(&child_pass_list, |
931 gfx::Rect(SurfaceSize()), | 929 gfx::Rect(SurfaceSize()), |
932 child_passes, | 930 child_passes, |
933 arraysize(child_passes)); | 931 arraysize(child_passes)); |
934 | 932 |
935 RenderPass* child_root_pass = child_pass_list.at(0u); | 933 RenderPass* child_root_pass = child_pass_list.at(0u); |
936 SharedQuadState* child_root_pass_sqs = | 934 SharedQuadState* child_root_pass_sqs = |
937 child_root_pass->shared_quad_state_list[0]; | 935 child_root_pass->shared_quad_state_list.front(); |
938 child_root_pass_sqs->content_to_target_transform.Translate(8, 0); | 936 child_root_pass_sqs->content_to_target_transform.Translate(8, 0); |
939 child_root_pass->damage_rect = gfx::Rect(10, 10, 10, 10); | 937 child_root_pass->damage_rect = gfx::Rect(10, 10, 10, 10); |
940 | 938 |
941 scoped_ptr<DelegatedFrameData> child_frame_data(new DelegatedFrameData); | 939 scoped_ptr<DelegatedFrameData> child_frame_data(new DelegatedFrameData); |
942 child_pass_list.swap(child_frame_data->render_pass_list); | 940 child_pass_list.swap(child_frame_data->render_pass_list); |
943 | 941 |
944 scoped_ptr<CompositorFrame> child_frame(new CompositorFrame); | 942 scoped_ptr<CompositorFrame> child_frame(new CompositorFrame); |
945 child_frame->delegated_frame_data = child_frame_data.Pass(); | 943 child_frame->delegated_frame_data = child_frame_data.Pass(); |
946 | 944 |
947 factory_.SubmitFrame(child_surface_id, child_frame.Pass(), base::Closure()); | 945 factory_.SubmitFrame(child_surface_id, child_frame.Pass(), base::Closure()); |
(...skipping 18 matching lines...) Expand all Loading... |
966 } | 964 } |
967 | 965 |
968 { | 966 { |
969 RenderPassList root_pass_list; | 967 RenderPassList root_pass_list; |
970 AddPasses(&root_pass_list, | 968 AddPasses(&root_pass_list, |
971 gfx::Rect(SurfaceSize()), | 969 gfx::Rect(SurfaceSize()), |
972 root_passes, | 970 root_passes, |
973 arraysize(root_passes)); | 971 arraysize(root_passes)); |
974 | 972 |
975 root_pass_list.at(0) | 973 root_pass_list.at(0) |
976 ->shared_quad_state_list[0] | 974 ->shared_quad_state_list.front() |
977 ->content_to_target_transform.Translate(0, 10); | 975 ->content_to_target_transform.Translate(0, 10); |
978 root_pass_list.at(0)->damage_rect = gfx::Rect(0, 0, 1, 1); | 976 root_pass_list.at(0)->damage_rect = gfx::Rect(0, 0, 1, 1); |
979 | 977 |
980 scoped_ptr<DelegatedFrameData> root_frame_data(new DelegatedFrameData); | 978 scoped_ptr<DelegatedFrameData> root_frame_data(new DelegatedFrameData); |
981 root_pass_list.swap(root_frame_data->render_pass_list); | 979 root_pass_list.swap(root_frame_data->render_pass_list); |
982 | 980 |
983 scoped_ptr<CompositorFrame> root_frame(new CompositorFrame); | 981 scoped_ptr<CompositorFrame> root_frame(new CompositorFrame); |
984 root_frame->delegated_frame_data = root_frame_data.Pass(); | 982 root_frame->delegated_frame_data = root_frame_data.Pass(); |
985 | 983 |
986 factory_.SubmitFrame(root_surface_id_, root_frame.Pass(), base::Closure()); | 984 factory_.SubmitFrame(root_surface_id_, root_frame.Pass(), base::Closure()); |
987 } | 985 } |
988 | 986 |
989 { | 987 { |
990 RenderPassList root_pass_list; | 988 RenderPassList root_pass_list; |
991 AddPasses(&root_pass_list, | 989 AddPasses(&root_pass_list, |
992 gfx::Rect(SurfaceSize()), | 990 gfx::Rect(SurfaceSize()), |
993 root_passes, | 991 root_passes, |
994 arraysize(root_passes)); | 992 arraysize(root_passes)); |
995 | 993 |
996 root_pass_list.at(0) | 994 root_pass_list.at(0) |
997 ->shared_quad_state_list[0] | 995 ->shared_quad_state_list.front() |
998 ->content_to_target_transform.Translate(0, 10); | 996 ->content_to_target_transform.Translate(0, 10); |
999 root_pass_list.at(0)->damage_rect = gfx::Rect(1, 1, 1, 1); | 997 root_pass_list.at(0)->damage_rect = gfx::Rect(1, 1, 1, 1); |
1000 | 998 |
1001 scoped_ptr<DelegatedFrameData> root_frame_data(new DelegatedFrameData); | 999 scoped_ptr<DelegatedFrameData> root_frame_data(new DelegatedFrameData); |
1002 root_pass_list.swap(root_frame_data->render_pass_list); | 1000 root_pass_list.swap(root_frame_data->render_pass_list); |
1003 | 1001 |
1004 scoped_ptr<CompositorFrame> root_frame(new CompositorFrame); | 1002 scoped_ptr<CompositorFrame> root_frame(new CompositorFrame); |
1005 root_frame->delegated_frame_data = root_frame_data.Pass(); | 1003 root_frame->delegated_frame_data = root_frame_data.Pass(); |
1006 | 1004 |
1007 factory_.SubmitFrame(root_surface_id_, root_frame.Pass(), base::Closure()); | 1005 factory_.SubmitFrame(root_surface_id_, root_frame.Pass(), base::Closure()); |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1146 returned_ids[i] = client.returned_resources()[i].id; | 1144 returned_ids[i] = client.returned_resources()[i].id; |
1147 } | 1145 } |
1148 EXPECT_THAT(returned_ids, | 1146 EXPECT_THAT(returned_ids, |
1149 testing::WhenSorted(testing::ElementsAreArray(ids))); | 1147 testing::WhenSorted(testing::ElementsAreArray(ids))); |
1150 factory.Destroy(surface_id); | 1148 factory.Destroy(surface_id); |
1151 } | 1149 } |
1152 | 1150 |
1153 } // namespace | 1151 } // namespace |
1154 } // namespace cc | 1152 } // namespace cc |
1155 | 1153 |
OLD | NEW |