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 1065 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1076 | 1076 |
1077 scoped_ptr<DelegatedFrameData> child_frame_data(new DelegatedFrameData); | 1077 scoped_ptr<DelegatedFrameData> child_frame_data(new DelegatedFrameData); |
1078 child_pass_list.swap(child_frame_data->render_pass_list); | 1078 child_pass_list.swap(child_frame_data->render_pass_list); |
1079 | 1079 |
1080 scoped_ptr<CompositorFrame> child_frame(new CompositorFrame); | 1080 scoped_ptr<CompositorFrame> child_frame(new CompositorFrame); |
1081 child_frame->delegated_frame_data = child_frame_data.Pass(); | 1081 child_frame->delegated_frame_data = child_frame_data.Pass(); |
1082 | 1082 |
1083 factory_.SubmitFrame(child_surface_id, child_frame.Pass(), | 1083 factory_.SubmitFrame(child_surface_id, child_frame.Pass(), |
1084 SurfaceFactory::DrawCallback()); | 1084 SurfaceFactory::DrawCallback()); |
1085 | 1085 |
1086 test::Quad root_quads[] = {test::Quad::SurfaceQuad(child_surface_id, 1.f)}; | 1086 RenderPassId pass_id(5, 10); |
1087 test::Pass root_passes[] = {test::Pass(root_quads, arraysize(root_quads))}; | 1087 test::Quad first_quads[] = {test::Quad::SurfaceQuad(child_surface_id, 1.f)}; |
| 1088 test::Quad root_quads[] = {test::Quad::RenderPassQuad(pass_id)}; |
| 1089 |
| 1090 test::Pass root_passes[] = { |
| 1091 test::Pass(first_quads, arraysize(first_quads), pass_id), |
| 1092 test::Pass(root_quads, arraysize(root_quads))}; |
1088 | 1093 |
1089 RenderPassList root_pass_list; | 1094 RenderPassList root_pass_list; |
1090 AddPasses(&root_pass_list, | 1095 AddPasses(&root_pass_list, |
1091 gfx::Rect(SurfaceSize()), | 1096 gfx::Rect(SurfaceSize()), |
1092 root_passes, | 1097 root_passes, |
1093 arraysize(root_passes)); | 1098 arraysize(root_passes)); |
1094 | 1099 |
1095 root_pass_list.at(0) | 1100 root_pass_list.at(0) |
1096 ->shared_quad_state_list.front() | 1101 ->shared_quad_state_list.front() |
1097 ->content_to_target_transform.Translate(0, 10); | 1102 ->content_to_target_transform.Translate(0, 10); |
1098 root_pass_list.at(0)->damage_rect = gfx::Rect(5, 5, 10, 10); | 1103 root_pass_list.at(0)->damage_rect = gfx::Rect(5, 5, 10, 10); |
| 1104 root_pass_list.at(1)->damage_rect = gfx::Rect(5, 5, 100, 100); |
1099 | 1105 |
1100 scoped_ptr<DelegatedFrameData> root_frame_data(new DelegatedFrameData); | 1106 scoped_ptr<DelegatedFrameData> root_frame_data(new DelegatedFrameData); |
1101 root_pass_list.swap(root_frame_data->render_pass_list); | 1107 root_pass_list.swap(root_frame_data->render_pass_list); |
1102 | 1108 |
1103 scoped_ptr<CompositorFrame> root_frame(new CompositorFrame); | 1109 scoped_ptr<CompositorFrame> root_frame(new CompositorFrame); |
1104 root_frame->delegated_frame_data = root_frame_data.Pass(); | 1110 root_frame->delegated_frame_data = root_frame_data.Pass(); |
1105 | 1111 |
1106 factory_.SubmitFrame(root_surface_id_, root_frame.Pass(), | 1112 factory_.SubmitFrame(root_surface_id_, root_frame.Pass(), |
1107 SurfaceFactory::DrawCallback()); | 1113 SurfaceFactory::DrawCallback()); |
1108 | 1114 |
1109 scoped_ptr<CompositorFrame> aggregated_frame = | 1115 scoped_ptr<CompositorFrame> aggregated_frame = |
1110 aggregator_.Aggregate(root_surface_id_); | 1116 aggregator_.Aggregate(root_surface_id_); |
1111 | 1117 |
1112 ASSERT_TRUE(aggregated_frame); | 1118 ASSERT_TRUE(aggregated_frame); |
1113 ASSERT_TRUE(aggregated_frame->delegated_frame_data); | 1119 ASSERT_TRUE(aggregated_frame->delegated_frame_data); |
1114 | 1120 |
1115 DelegatedFrameData* frame_data = aggregated_frame->delegated_frame_data.get(); | 1121 DelegatedFrameData* frame_data = aggregated_frame->delegated_frame_data.get(); |
1116 | 1122 |
1117 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list; | 1123 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list; |
1118 | 1124 |
1119 ASSERT_EQ(1u, aggregated_pass_list.size()); | 1125 ASSERT_EQ(2u, aggregated_pass_list.size()); |
1120 | 1126 |
1121 // Damage rect for first aggregation should contain entire root surface. | 1127 // Damage rect for first aggregation should contain entire root surface. |
1122 EXPECT_TRUE( | 1128 EXPECT_TRUE( |
1123 aggregated_pass_list[0]->damage_rect.Contains(gfx::Rect(SurfaceSize()))); | 1129 aggregated_pass_list[1]->damage_rect.Contains(gfx::Rect(SurfaceSize()))); |
1124 | 1130 |
1125 { | 1131 { |
1126 AddPasses(&child_pass_list, | 1132 AddPasses(&child_pass_list, |
1127 gfx::Rect(SurfaceSize()), | 1133 gfx::Rect(SurfaceSize()), |
1128 child_passes, | 1134 child_passes, |
1129 arraysize(child_passes)); | 1135 arraysize(child_passes)); |
1130 | 1136 |
1131 RenderPass* child_root_pass = child_pass_list.at(0u); | 1137 RenderPass* child_root_pass = child_pass_list.at(0u); |
1132 SharedQuadState* child_root_pass_sqs = | 1138 SharedQuadState* child_root_pass_sqs = |
1133 child_root_pass->shared_quad_state_list.front(); | 1139 child_root_pass->shared_quad_state_list.front(); |
(...skipping 13 matching lines...) Expand all Loading... |
1147 aggregator_.Aggregate(root_surface_id_); | 1153 aggregator_.Aggregate(root_surface_id_); |
1148 | 1154 |
1149 ASSERT_TRUE(aggregated_frame); | 1155 ASSERT_TRUE(aggregated_frame); |
1150 ASSERT_TRUE(aggregated_frame->delegated_frame_data); | 1156 ASSERT_TRUE(aggregated_frame->delegated_frame_data); |
1151 | 1157 |
1152 DelegatedFrameData* frame_data = | 1158 DelegatedFrameData* frame_data = |
1153 aggregated_frame->delegated_frame_data.get(); | 1159 aggregated_frame->delegated_frame_data.get(); |
1154 | 1160 |
1155 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list; | 1161 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list; |
1156 | 1162 |
1157 ASSERT_EQ(1u, aggregated_pass_list.size()); | 1163 ASSERT_EQ(2u, aggregated_pass_list.size()); |
1158 | 1164 |
1159 // Outer surface didn't change, so transformed inner damage rect should be | 1165 // Outer surface didn't change, so transformed inner damage rect should be |
1160 // used. | 1166 // used. |
1161 EXPECT_EQ(gfx::Rect(10, 20, 10, 10).ToString(), | 1167 EXPECT_EQ(gfx::Rect(10, 20, 10, 10).ToString(), |
1162 aggregated_pass_list[0]->damage_rect.ToString()); | 1168 aggregated_pass_list[1]->damage_rect.ToString()); |
1163 } | 1169 } |
1164 | 1170 |
1165 { | 1171 { |
1166 RenderPassList root_pass_list; | 1172 RenderPassList root_pass_list; |
1167 AddPasses(&root_pass_list, | 1173 AddPasses(&root_pass_list, |
1168 gfx::Rect(SurfaceSize()), | 1174 gfx::Rect(SurfaceSize()), |
1169 root_passes, | 1175 root_passes, |
1170 arraysize(root_passes)); | 1176 arraysize(root_passes)); |
1171 | 1177 |
1172 root_pass_list.at(0) | 1178 root_pass_list.at(0) |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1209 aggregator_.Aggregate(root_surface_id_); | 1215 aggregator_.Aggregate(root_surface_id_); |
1210 | 1216 |
1211 ASSERT_TRUE(aggregated_frame); | 1217 ASSERT_TRUE(aggregated_frame); |
1212 ASSERT_TRUE(aggregated_frame->delegated_frame_data); | 1218 ASSERT_TRUE(aggregated_frame->delegated_frame_data); |
1213 | 1219 |
1214 DelegatedFrameData* frame_data = | 1220 DelegatedFrameData* frame_data = |
1215 aggregated_frame->delegated_frame_data.get(); | 1221 aggregated_frame->delegated_frame_data.get(); |
1216 | 1222 |
1217 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list; | 1223 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list; |
1218 | 1224 |
1219 ASSERT_EQ(1u, aggregated_pass_list.size()); | 1225 ASSERT_EQ(2u, aggregated_pass_list.size()); |
1220 | 1226 |
1221 // The root surface was enqueued without being aggregated once, so it should | 1227 // The root surface was enqueued without being aggregated once, so it should |
1222 // be treated as completely damaged. | 1228 // be treated as completely damaged. |
1223 EXPECT_TRUE(aggregated_pass_list[0]->damage_rect.Contains( | 1229 EXPECT_TRUE(aggregated_pass_list[1]->damage_rect.Contains( |
1224 gfx::Rect(SurfaceSize()))); | 1230 gfx::Rect(SurfaceSize()))); |
1225 } | 1231 } |
1226 | 1232 |
1227 factory_.Destroy(child_surface_id); | 1233 factory_.Destroy(child_surface_id); |
1228 } | 1234 } |
1229 | 1235 |
1230 class SurfaceAggregatorWithResourcesTest : public testing::Test { | 1236 class SurfaceAggregatorWithResourcesTest : public testing::Test { |
1231 public: | 1237 public: |
1232 void SetUp() override { | 1238 void SetUp() override { |
1233 output_surface_ = FakeOutputSurface::CreateSoftware( | 1239 output_surface_ = FakeOutputSurface::CreateSoftware( |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1415 EXPECT_THAT(returned_ids, | 1421 EXPECT_THAT(returned_ids, |
1416 testing::WhenSorted(testing::ElementsAreArray(ids))); | 1422 testing::WhenSorted(testing::ElementsAreArray(ids))); |
1417 EXPECT_EQ(3u, resource_provider_->num_resources()); | 1423 EXPECT_EQ(3u, resource_provider_->num_resources()); |
1418 factory.Destroy(surface_id); | 1424 factory.Destroy(surface_id); |
1419 factory.Destroy(surface_id2); | 1425 factory.Destroy(surface_id2); |
1420 } | 1426 } |
1421 | 1427 |
1422 } // namespace | 1428 } // namespace |
1423 } // namespace cc | 1429 } // namespace cc |
1424 | 1430 |
OLD | NEW |