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 921 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
932 middle_pass_list.swap(middle_frame_data->render_pass_list); | 932 middle_pass_list.swap(middle_frame_data->render_pass_list); |
933 | 933 |
934 scoped_ptr<CompositorFrame> middle_frame(new CompositorFrame); | 934 scoped_ptr<CompositorFrame> middle_frame(new CompositorFrame); |
935 middle_frame->delegated_frame_data = middle_frame_data.Pass(); | 935 middle_frame->delegated_frame_data = middle_frame_data.Pass(); |
936 | 936 |
937 factory_.SubmitFrame(middle_surface_id, middle_frame.Pass(), | 937 factory_.SubmitFrame(middle_surface_id, middle_frame.Pass(), |
938 SurfaceFactory::DrawCallback()); | 938 SurfaceFactory::DrawCallback()); |
939 } | 939 } |
940 | 940 |
941 // Root surface. | 941 // Root surface. |
942 test::Quad root_quads[] = {test::Quad::SolidColorQuad(1), | 942 test::Quad secondary_quads[] = { |
943 test::Quad::SurfaceQuad(middle_surface_id, 1.f)}; | 943 test::Quad::SolidColorQuad(1), |
944 test::Pass root_passes[] = {test::Pass(root_quads, arraysize(root_quads))}; | 944 test::Quad::SurfaceQuad(middle_surface_id, 1.f)}; |
| 945 test::Quad root_quads[] = {test::Quad::SolidColorQuad(1)}; |
| 946 test::Pass root_passes[] = { |
| 947 test::Pass(secondary_quads, arraysize(secondary_quads)), |
| 948 test::Pass(root_quads, arraysize(root_quads))}; |
945 | 949 |
946 RenderPassList root_pass_list; | 950 RenderPassList root_pass_list; |
947 AddPasses(&root_pass_list, | 951 AddPasses(&root_pass_list, |
948 gfx::Rect(SurfaceSize()), | 952 gfx::Rect(SurfaceSize()), |
949 root_passes, | 953 root_passes, |
950 arraysize(root_passes)); | 954 arraysize(root_passes)); |
951 | 955 |
952 root_pass_list.at(0) | 956 root_pass_list.at(0) |
953 ->shared_quad_state_list.front() | 957 ->shared_quad_state_list.front() |
954 ->content_to_target_transform.Translate(0, 7); | 958 ->content_to_target_transform.Translate(0, 7); |
955 root_pass_list.at(0) | 959 root_pass_list.at(0) |
956 ->shared_quad_state_list.ElementAt(1) | 960 ->shared_quad_state_list.ElementAt(1) |
957 ->content_to_target_transform.Translate(0, 10); | 961 ->content_to_target_transform.Translate(0, 10); |
958 root_pass_list.at(0)->quad_list.ElementAt(1)->visible_rect = | 962 root_pass_list.at(0)->quad_list.ElementAt(1)->visible_rect = |
959 gfx::Rect(0, 0, 8, 100); | 963 gfx::Rect(0, 0, 8, 100); |
960 | 964 |
| 965 root_pass_list[0]->transform_to_root_target.Translate(10, 5); |
| 966 |
961 scoped_ptr<DelegatedFrameData> root_frame_data(new DelegatedFrameData); | 967 scoped_ptr<DelegatedFrameData> root_frame_data(new DelegatedFrameData); |
962 root_pass_list.swap(root_frame_data->render_pass_list); | 968 root_pass_list.swap(root_frame_data->render_pass_list); |
963 | 969 |
964 scoped_ptr<CompositorFrame> root_frame(new CompositorFrame); | 970 scoped_ptr<CompositorFrame> root_frame(new CompositorFrame); |
965 root_frame->delegated_frame_data = root_frame_data.Pass(); | 971 root_frame->delegated_frame_data = root_frame_data.Pass(); |
966 | 972 |
967 factory_.SubmitFrame(root_surface_id_, root_frame.Pass(), | 973 factory_.SubmitFrame(root_surface_id_, root_frame.Pass(), |
968 SurfaceFactory::DrawCallback()); | 974 SurfaceFactory::DrawCallback()); |
969 | 975 |
970 scoped_ptr<CompositorFrame> aggregated_frame = | 976 scoped_ptr<CompositorFrame> aggregated_frame = |
971 aggregator_.Aggregate(root_surface_id_); | 977 aggregator_.Aggregate(root_surface_id_); |
972 | 978 |
973 ASSERT_TRUE(aggregated_frame); | 979 ASSERT_TRUE(aggregated_frame); |
974 ASSERT_TRUE(aggregated_frame->delegated_frame_data); | 980 ASSERT_TRUE(aggregated_frame->delegated_frame_data); |
975 | 981 |
976 DelegatedFrameData* frame_data = aggregated_frame->delegated_frame_data.get(); | 982 DelegatedFrameData* frame_data = aggregated_frame->delegated_frame_data.get(); |
977 | 983 |
978 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list; | 984 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list; |
979 | 985 |
980 ASSERT_EQ(2u, aggregated_pass_list.size()); | 986 ASSERT_EQ(3u, aggregated_pass_list.size()); |
981 | 987 |
982 ASSERT_EQ(1u, aggregated_pass_list[0]->shared_quad_state_list.size()); | 988 ASSERT_EQ(1u, aggregated_pass_list[0]->shared_quad_state_list.size()); |
983 | 989 |
984 // The first pass should have one shared quad state for the one solid color | 990 // The first pass should have one shared quad state for the one solid color |
985 // quad. | 991 // quad. |
986 EXPECT_EQ(1u, aggregated_pass_list[0]->shared_quad_state_list.size()); | 992 EXPECT_EQ(1u, aggregated_pass_list[0]->shared_quad_state_list.size()); |
987 // The second (root) pass should have just two shared quad states. We'll | 993 // The second pass should have just two shared quad states. We'll |
988 // verify the properties through the quads. | 994 // verify the properties through the quads. |
989 EXPECT_EQ(2u, aggregated_pass_list[1]->shared_quad_state_list.size()); | 995 EXPECT_EQ(2u, aggregated_pass_list[1]->shared_quad_state_list.size()); |
990 | 996 |
| 997 EXPECT_EQ(1u, aggregated_pass_list[2]->shared_quad_state_list.size()); |
| 998 |
991 SharedQuadState* aggregated_first_pass_sqs = | 999 SharedQuadState* aggregated_first_pass_sqs = |
992 aggregated_pass_list[0]->shared_quad_state_list.front(); | 1000 aggregated_pass_list[0]->shared_quad_state_list.front(); |
993 | 1001 |
994 // The first pass's transform should be unaffected by the embedding and still | 1002 // The first pass's transform should be unaffected by the embedding and still |
995 // be a translation by +5 in the x direction. | 1003 // be a translation by +5 in the x direction. |
996 gfx::Transform expected_aggregated_first_pass_sqs_transform; | 1004 gfx::Transform expected_aggregated_first_pass_sqs_transform; |
997 expected_aggregated_first_pass_sqs_transform.Translate(5, 0); | 1005 expected_aggregated_first_pass_sqs_transform.Translate(5, 0); |
998 EXPECT_EQ(expected_aggregated_first_pass_sqs_transform.ToString(), | 1006 EXPECT_EQ(expected_aggregated_first_pass_sqs_transform.ToString(), |
999 aggregated_first_pass_sqs->content_to_target_transform.ToString()); | 1007 aggregated_first_pass_sqs->content_to_target_transform.ToString()); |
1000 | 1008 |
1001 // The first pass's transform to the root target should include the aggregated | 1009 // The first pass's transform to the root target should include the aggregated |
1002 // transform. | 1010 // transform, including the transform from the child pass to the root. |
1003 gfx::Transform expected_first_pass_transform_to_root_target; | 1011 gfx::Transform expected_first_pass_transform_to_root_target; |
| 1012 expected_first_pass_transform_to_root_target.Translate(10, 5); |
1004 expected_first_pass_transform_to_root_target.Translate(0, 10); | 1013 expected_first_pass_transform_to_root_target.Translate(0, 10); |
1005 expected_first_pass_transform_to_root_target.Scale(2, 3); | 1014 expected_first_pass_transform_to_root_target.Scale(2, 3); |
1006 expected_first_pass_transform_to_root_target.Translate(8, 0); | 1015 expected_first_pass_transform_to_root_target.Translate(8, 0); |
1007 EXPECT_EQ(expected_first_pass_transform_to_root_target.ToString(), | 1016 EXPECT_EQ(expected_first_pass_transform_to_root_target.ToString(), |
1008 aggregated_pass_list[0]->transform_to_root_target.ToString()); | 1017 aggregated_pass_list[0]->transform_to_root_target.ToString()); |
1009 | 1018 |
1010 ASSERT_EQ(2u, aggregated_pass_list[1]->quad_list.size()); | 1019 ASSERT_EQ(2u, aggregated_pass_list[1]->quad_list.size()); |
1011 | 1020 |
1012 gfx::Transform expected_root_pass_quad_transforms[2]; | 1021 gfx::Transform expected_root_pass_quad_transforms[2]; |
1013 // The first quad in the root pass is the solid color quad from the original | 1022 // The first quad in the root pass is the solid color quad from the original |
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1406 EXPECT_THAT(returned_ids, | 1415 EXPECT_THAT(returned_ids, |
1407 testing::WhenSorted(testing::ElementsAreArray(ids))); | 1416 testing::WhenSorted(testing::ElementsAreArray(ids))); |
1408 EXPECT_EQ(3u, resource_provider_->num_resources()); | 1417 EXPECT_EQ(3u, resource_provider_->num_resources()); |
1409 factory.Destroy(surface_id); | 1418 factory.Destroy(surface_id); |
1410 factory.Destroy(surface_id2); | 1419 factory.Destroy(surface_id2); |
1411 } | 1420 } |
1412 | 1421 |
1413 } // namespace | 1422 } // namespace |
1414 } // namespace cc | 1423 } // namespace cc |
1415 | 1424 |
OLD | NEW |