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

Side by Side Diff: cc/surfaces/surface_aggregator_unittest.cc

Issue 551013002: Use Custome ListContainer to Allocate SharedQuadState (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@DQAllo
Patch Set: use ElementAt for unittest Created 6 years, 2 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/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 727 matching lines...) Expand 10 before | Expand all | Expand 10 after
738 738
739 RenderPassList child_pass_list; 739 RenderPassList child_pass_list;
740 AddPasses(&child_pass_list, 740 AddPasses(&child_pass_list,
741 gfx::Rect(SurfaceSize()), 741 gfx::Rect(SurfaceSize()),
742 child_passes, 742 child_passes,
743 arraysize(child_passes)); 743 arraysize(child_passes));
744 744
745 RenderPass* child_nonroot_pass = child_pass_list.at(0u); 745 RenderPass* child_nonroot_pass = child_pass_list.at(0u);
746 child_nonroot_pass->transform_to_root_target.Translate(8, 0); 746 child_nonroot_pass->transform_to_root_target.Translate(8, 0);
747 SharedQuadState* child_nonroot_pass_sqs = 747 SharedQuadState* child_nonroot_pass_sqs =
748 child_nonroot_pass->shared_quad_state_list[0]; 748 child_nonroot_pass->shared_quad_state_list.front();
749 child_nonroot_pass_sqs->content_to_target_transform.Translate(5, 0); 749 child_nonroot_pass_sqs->content_to_target_transform.Translate(5, 0);
750 750
751 RenderPass* child_root_pass = child_pass_list.at(1u); 751 RenderPass* child_root_pass = child_pass_list.at(1u);
752 SharedQuadState* child_root_pass_sqs = 752 SharedQuadState* child_root_pass_sqs =
753 child_root_pass->shared_quad_state_list[0]; 753 child_root_pass->shared_quad_state_list.front();
754 child_root_pass_sqs->content_to_target_transform.Translate(8, 0); 754 child_root_pass_sqs->content_to_target_transform.Translate(8, 0);
755 child_root_pass_sqs->is_clipped = true; 755 child_root_pass_sqs->is_clipped = true;
756 child_root_pass_sqs->clip_rect = gfx::Rect(0, 0, 5, 5); 756 child_root_pass_sqs->clip_rect = gfx::Rect(0, 0, 5, 5);
757 757
758 scoped_ptr<DelegatedFrameData> child_frame_data(new DelegatedFrameData); 758 scoped_ptr<DelegatedFrameData> child_frame_data(new DelegatedFrameData);
759 child_pass_list.swap(child_frame_data->render_pass_list); 759 child_pass_list.swap(child_frame_data->render_pass_list);
760 760
761 scoped_ptr<CompositorFrame> child_frame(new CompositorFrame); 761 scoped_ptr<CompositorFrame> child_frame(new CompositorFrame);
762 child_frame->delegated_frame_data = child_frame_data.Pass(); 762 child_frame->delegated_frame_data = child_frame_data.Pass();
763 763
764 factory_.SubmitFrame(child_surface_id, child_frame.Pass(), base::Closure()); 764 factory_.SubmitFrame(child_surface_id, child_frame.Pass(), base::Closure());
765 765
766 test::Quad root_quads[] = {test::Quad::SolidColorQuad(1), 766 test::Quad root_quads[] = {test::Quad::SolidColorQuad(1),
767 test::Quad::SurfaceQuad(child_surface_id)}; 767 test::Quad::SurfaceQuad(child_surface_id)};
768 test::Pass root_passes[] = {test::Pass(root_quads, arraysize(root_quads))}; 768 test::Pass root_passes[] = {test::Pass(root_quads, arraysize(root_quads))};
769 769
770 RenderPassList root_pass_list; 770 RenderPassList root_pass_list;
771 AddPasses(&root_pass_list, 771 AddPasses(&root_pass_list,
772 gfx::Rect(SurfaceSize()), 772 gfx::Rect(SurfaceSize()),
773 root_passes, 773 root_passes,
774 arraysize(root_passes)); 774 arraysize(root_passes));
775 775
776 root_pass_list.at(0) 776 root_pass_list.at(0)
777 ->shared_quad_state_list[0] 777 ->shared_quad_state_list.front()
778 ->content_to_target_transform.Translate(0, 7); 778 ->content_to_target_transform.Translate(0, 7);
779 root_pass_list.at(0) 779 root_pass_list.at(0)
780 ->shared_quad_state_list[1] 780 ->shared_quad_state_list.ElementAt(1)
781 ->content_to_target_transform.Translate(0, 10); 781 ->content_to_target_transform.Translate(0, 10);
782 782
783 scoped_ptr<DelegatedFrameData> root_frame_data(new DelegatedFrameData); 783 scoped_ptr<DelegatedFrameData> root_frame_data(new DelegatedFrameData);
784 root_pass_list.swap(root_frame_data->render_pass_list); 784 root_pass_list.swap(root_frame_data->render_pass_list);
785 785
786 scoped_ptr<CompositorFrame> root_frame(new CompositorFrame); 786 scoped_ptr<CompositorFrame> root_frame(new CompositorFrame);
787 root_frame->delegated_frame_data = root_frame_data.Pass(); 787 root_frame->delegated_frame_data = root_frame_data.Pass();
788 788
789 factory_.SubmitFrame(root_surface_id_, root_frame.Pass(), base::Closure()); 789 factory_.SubmitFrame(root_surface_id_, root_frame.Pass(), base::Closure());
790 790
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
841 size_t i = 0; 841 size_t i = 0;
842 for (QuadList::Iterator iter = aggregated_pass_list[1]->quad_list.begin(); 842 for (QuadList::Iterator iter = aggregated_pass_list[1]->quad_list.begin();
843 iter != aggregated_pass_list[1]->quad_list.end(); 843 iter != aggregated_pass_list[1]->quad_list.end();
844 ++iter) { 844 ++iter) {
845 EXPECT_EQ(expected_root_pass_quad_transforms[i].ToString(), 845 EXPECT_EQ(expected_root_pass_quad_transforms[i].ToString(),
846 iter->quadTransform().ToString()) 846 iter->quadTransform().ToString())
847 << i; 847 << i;
848 i++; 848 i++;
849 } 849 }
850 850
851 EXPECT_EQ(true, 851 SharedQuadStateList::Iterator sqs_iter =
852 aggregated_pass_list[1]->shared_quad_state_list[1]->is_clipped); 852 aggregated_pass_list[1]->shared_quad_state_list.begin();
853 ++sqs_iter;
danakj 2014/09/26 20:40:55 ElementAt
weiliangc 2014/10/01 23:02:00 Done.
854 EXPECT_EQ(true, sqs_iter->is_clipped);
853 855
854 // The second quad in the root pass is aggregated from the child, so its 856 // 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. 857 // clip rect must be transformed by the child's translation.
856 EXPECT_EQ( 858 EXPECT_EQ(gfx::Rect(0, 10, 5, 5).ToString(), sqs_iter->clip_rect.ToString());
danakj 2014/09/26 20:40:55 ElementAt
weiliangc 2014/10/01 23:02:00 Done.
857 gfx::Rect(0, 10, 5, 5).ToString(),
858 aggregated_pass_list[1]->shared_quad_state_list[1]->clip_rect.ToString());
859 859
860 factory_.Destroy(child_surface_id); 860 factory_.Destroy(child_surface_id);
861 } 861 }
862 862
863 // Tests that damage rects are aggregated correctly when surfaces change. 863 // Tests that damage rects are aggregated correctly when surfaces change.
864 TEST_F(SurfaceAggregatorValidSurfaceTest, AggregateDamageRect) { 864 TEST_F(SurfaceAggregatorValidSurfaceTest, AggregateDamageRect) {
865 SurfaceId child_surface_id = allocator_.GenerateId(); 865 SurfaceId child_surface_id = allocator_.GenerateId();
866 factory_.Create(child_surface_id, SurfaceSize()); 866 factory_.Create(child_surface_id, SurfaceSize());
867 RenderPassId child_pass_id = RenderPassId(1, 1); 867 RenderPassId child_pass_id = RenderPassId(1, 1);
868 test::Quad child_quads[] = {test::Quad::RenderPassQuad(child_pass_id)}; 868 test::Quad child_quads[] = {test::Quad::RenderPassQuad(child_pass_id)};
869 test::Pass child_passes[] = { 869 test::Pass child_passes[] = {
870 test::Pass(child_quads, arraysize(child_quads), child_pass_id)}; 870 test::Pass(child_quads, arraysize(child_quads), child_pass_id)};
871 871
872 RenderPassList child_pass_list; 872 RenderPassList child_pass_list;
873 AddPasses(&child_pass_list, 873 AddPasses(&child_pass_list,
874 gfx::Rect(SurfaceSize()), 874 gfx::Rect(SurfaceSize()),
875 child_passes, 875 child_passes,
876 arraysize(child_passes)); 876 arraysize(child_passes));
877 877
878 RenderPass* child_root_pass = child_pass_list.at(0u); 878 RenderPass* child_root_pass = child_pass_list.at(0u);
879 SharedQuadState* child_root_pass_sqs = 879 SharedQuadState* child_root_pass_sqs =
880 child_root_pass->shared_quad_state_list[0]; 880 child_root_pass->shared_quad_state_list.front();
881 child_root_pass_sqs->content_to_target_transform.Translate(8, 0); 881 child_root_pass_sqs->content_to_target_transform.Translate(8, 0);
882 882
883 scoped_ptr<DelegatedFrameData> child_frame_data(new DelegatedFrameData); 883 scoped_ptr<DelegatedFrameData> child_frame_data(new DelegatedFrameData);
884 child_pass_list.swap(child_frame_data->render_pass_list); 884 child_pass_list.swap(child_frame_data->render_pass_list);
885 885
886 scoped_ptr<CompositorFrame> child_frame(new CompositorFrame); 886 scoped_ptr<CompositorFrame> child_frame(new CompositorFrame);
887 child_frame->delegated_frame_data = child_frame_data.Pass(); 887 child_frame->delegated_frame_data = child_frame_data.Pass();
888 888
889 factory_.SubmitFrame(child_surface_id, child_frame.Pass(), base::Closure()); 889 factory_.SubmitFrame(child_surface_id, child_frame.Pass(), base::Closure());
890 890
891 test::Quad root_quads[] = {test::Quad::SurfaceQuad(child_surface_id)}; 891 test::Quad root_quads[] = {test::Quad::SurfaceQuad(child_surface_id)};
892 test::Pass root_passes[] = {test::Pass(root_quads, arraysize(root_quads))}; 892 test::Pass root_passes[] = {test::Pass(root_quads, arraysize(root_quads))};
893 893
894 RenderPassList root_pass_list; 894 RenderPassList root_pass_list;
895 AddPasses(&root_pass_list, 895 AddPasses(&root_pass_list,
896 gfx::Rect(SurfaceSize()), 896 gfx::Rect(SurfaceSize()),
897 root_passes, 897 root_passes,
898 arraysize(root_passes)); 898 arraysize(root_passes));
899 899
900 root_pass_list.at(0) 900 root_pass_list.at(0)
901 ->shared_quad_state_list[0] 901 ->shared_quad_state_list.front()
902 ->content_to_target_transform.Translate(0, 10); 902 ->content_to_target_transform.Translate(0, 10);
903 root_pass_list.at(0)->damage_rect = gfx::Rect(5, 5, 10, 10); 903 root_pass_list.at(0)->damage_rect = gfx::Rect(5, 5, 10, 10);
904 904
905 scoped_ptr<DelegatedFrameData> root_frame_data(new DelegatedFrameData); 905 scoped_ptr<DelegatedFrameData> root_frame_data(new DelegatedFrameData);
906 root_pass_list.swap(root_frame_data->render_pass_list); 906 root_pass_list.swap(root_frame_data->render_pass_list);
907 907
908 scoped_ptr<CompositorFrame> root_frame(new CompositorFrame); 908 scoped_ptr<CompositorFrame> root_frame(new CompositorFrame);
909 root_frame->delegated_frame_data = root_frame_data.Pass(); 909 root_frame->delegated_frame_data = root_frame_data.Pass();
910 910
911 factory_.SubmitFrame(root_surface_id_, root_frame.Pass(), base::Closure()); 911 factory_.SubmitFrame(root_surface_id_, root_frame.Pass(), base::Closure());
(...skipping 15 matching lines...) Expand all
927 aggregated_pass_list[0]->damage_rect.Contains(gfx::Rect(SurfaceSize()))); 927 aggregated_pass_list[0]->damage_rect.Contains(gfx::Rect(SurfaceSize())));
928 928
929 { 929 {
930 AddPasses(&child_pass_list, 930 AddPasses(&child_pass_list,
931 gfx::Rect(SurfaceSize()), 931 gfx::Rect(SurfaceSize()),
932 child_passes, 932 child_passes,
933 arraysize(child_passes)); 933 arraysize(child_passes));
934 934
935 RenderPass* child_root_pass = child_pass_list.at(0u); 935 RenderPass* child_root_pass = child_pass_list.at(0u);
936 SharedQuadState* child_root_pass_sqs = 936 SharedQuadState* child_root_pass_sqs =
937 child_root_pass->shared_quad_state_list[0]; 937 child_root_pass->shared_quad_state_list.front();
938 child_root_pass_sqs->content_to_target_transform.Translate(8, 0); 938 child_root_pass_sqs->content_to_target_transform.Translate(8, 0);
939 child_root_pass->damage_rect = gfx::Rect(10, 10, 10, 10); 939 child_root_pass->damage_rect = gfx::Rect(10, 10, 10, 10);
940 940
941 scoped_ptr<DelegatedFrameData> child_frame_data(new DelegatedFrameData); 941 scoped_ptr<DelegatedFrameData> child_frame_data(new DelegatedFrameData);
942 child_pass_list.swap(child_frame_data->render_pass_list); 942 child_pass_list.swap(child_frame_data->render_pass_list);
943 943
944 scoped_ptr<CompositorFrame> child_frame(new CompositorFrame); 944 scoped_ptr<CompositorFrame> child_frame(new CompositorFrame);
945 child_frame->delegated_frame_data = child_frame_data.Pass(); 945 child_frame->delegated_frame_data = child_frame_data.Pass();
946 946
947 factory_.SubmitFrame(child_surface_id, child_frame.Pass(), base::Closure()); 947 factory_.SubmitFrame(child_surface_id, child_frame.Pass(), base::Closure());
(...skipping 18 matching lines...) Expand all
966 } 966 }
967 967
968 { 968 {
969 RenderPassList root_pass_list; 969 RenderPassList root_pass_list;
970 AddPasses(&root_pass_list, 970 AddPasses(&root_pass_list,
971 gfx::Rect(SurfaceSize()), 971 gfx::Rect(SurfaceSize()),
972 root_passes, 972 root_passes,
973 arraysize(root_passes)); 973 arraysize(root_passes));
974 974
975 root_pass_list.at(0) 975 root_pass_list.at(0)
976 ->shared_quad_state_list[0] 976 ->shared_quad_state_list.front()
977 ->content_to_target_transform.Translate(0, 10); 977 ->content_to_target_transform.Translate(0, 10);
978 root_pass_list.at(0)->damage_rect = gfx::Rect(0, 0, 1, 1); 978 root_pass_list.at(0)->damage_rect = gfx::Rect(0, 0, 1, 1);
979 979
980 scoped_ptr<DelegatedFrameData> root_frame_data(new DelegatedFrameData); 980 scoped_ptr<DelegatedFrameData> root_frame_data(new DelegatedFrameData);
981 root_pass_list.swap(root_frame_data->render_pass_list); 981 root_pass_list.swap(root_frame_data->render_pass_list);
982 982
983 scoped_ptr<CompositorFrame> root_frame(new CompositorFrame); 983 scoped_ptr<CompositorFrame> root_frame(new CompositorFrame);
984 root_frame->delegated_frame_data = root_frame_data.Pass(); 984 root_frame->delegated_frame_data = root_frame_data.Pass();
985 985
986 factory_.SubmitFrame(root_surface_id_, root_frame.Pass(), base::Closure()); 986 factory_.SubmitFrame(root_surface_id_, root_frame.Pass(), base::Closure());
987 } 987 }
988 988
989 { 989 {
990 RenderPassList root_pass_list; 990 RenderPassList root_pass_list;
991 AddPasses(&root_pass_list, 991 AddPasses(&root_pass_list,
992 gfx::Rect(SurfaceSize()), 992 gfx::Rect(SurfaceSize()),
993 root_passes, 993 root_passes,
994 arraysize(root_passes)); 994 arraysize(root_passes));
995 995
996 root_pass_list.at(0) 996 root_pass_list.at(0)
997 ->shared_quad_state_list[0] 997 ->shared_quad_state_list.front()
998 ->content_to_target_transform.Translate(0, 10); 998 ->content_to_target_transform.Translate(0, 10);
999 root_pass_list.at(0)->damage_rect = gfx::Rect(1, 1, 1, 1); 999 root_pass_list.at(0)->damage_rect = gfx::Rect(1, 1, 1, 1);
1000 1000
1001 scoped_ptr<DelegatedFrameData> root_frame_data(new DelegatedFrameData); 1001 scoped_ptr<DelegatedFrameData> root_frame_data(new DelegatedFrameData);
1002 root_pass_list.swap(root_frame_data->render_pass_list); 1002 root_pass_list.swap(root_frame_data->render_pass_list);
1003 1003
1004 scoped_ptr<CompositorFrame> root_frame(new CompositorFrame); 1004 scoped_ptr<CompositorFrame> root_frame(new CompositorFrame);
1005 root_frame->delegated_frame_data = root_frame_data.Pass(); 1005 root_frame->delegated_frame_data = root_frame_data.Pass();
1006 1006
1007 factory_.SubmitFrame(root_surface_id_, root_frame.Pass(), base::Closure()); 1007 factory_.SubmitFrame(root_surface_id_, root_frame.Pass(), base::Closure());
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
1146 returned_ids[i] = client.returned_resources()[i].id; 1146 returned_ids[i] = client.returned_resources()[i].id;
1147 } 1147 }
1148 EXPECT_THAT(returned_ids, 1148 EXPECT_THAT(returned_ids,
1149 testing::WhenSorted(testing::ElementsAreArray(ids))); 1149 testing::WhenSorted(testing::ElementsAreArray(ids)));
1150 factory.Destroy(surface_id); 1150 factory.Destroy(surface_id);
1151 } 1151 }
1152 1152
1153 } // namespace 1153 } // namespace
1154 } // namespace cc 1154 } // namespace cc
1155 1155
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698