| 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 protected: | 54 protected: |
| 55 SurfaceManager manager_; | 55 SurfaceManager manager_; |
| 56 EmptySurfaceFactoryClient empty_client_; | 56 EmptySurfaceFactoryClient empty_client_; |
| 57 SurfaceFactory factory_; | 57 SurfaceFactory factory_; |
| 58 SurfaceAggregator aggregator_; | 58 SurfaceAggregator aggregator_; |
| 59 }; | 59 }; |
| 60 | 60 |
| 61 TEST_F(SurfaceAggregatorTest, ValidSurfaceNoFrame) { | 61 TEST_F(SurfaceAggregatorTest, ValidSurfaceNoFrame) { |
| 62 SurfaceId one_id(7); | 62 SurfaceId one_id(7); |
| 63 factory_.Create(one_id, SurfaceSize()); | 63 factory_.Create(one_id, SurfaceSize()); |
| 64 scoped_ptr<CompositorFrame> frame = aggregator_.Aggregate(one_id); | 64 std::set<Surface*> surface_list; |
| 65 scoped_ptr<CompositorFrame> frame = |
| 66 aggregator_.Aggregate(one_id, &surface_list); |
| 65 EXPECT_FALSE(frame); | 67 EXPECT_FALSE(frame); |
| 66 factory_.Destroy(one_id); | 68 factory_.Destroy(one_id); |
| 67 } | 69 } |
| 68 | 70 |
| 69 class SurfaceAggregatorValidSurfaceTest : public SurfaceAggregatorTest { | 71 class SurfaceAggregatorValidSurfaceTest : public SurfaceAggregatorTest { |
| 70 public: | 72 public: |
| 71 SurfaceAggregatorValidSurfaceTest() : allocator_(1u) {} | 73 SurfaceAggregatorValidSurfaceTest() : allocator_(1u) {} |
| 72 | 74 |
| 73 virtual void SetUp() { | 75 virtual void SetUp() { |
| 74 SurfaceAggregatorTest::SetUp(); | 76 SurfaceAggregatorTest::SetUp(); |
| 75 root_surface_id_ = allocator_.GenerateId(); | 77 root_surface_id_ = allocator_.GenerateId(); |
| 76 factory_.Create(root_surface_id_, SurfaceSize()); | 78 factory_.Create(root_surface_id_, SurfaceSize()); |
| 77 } | 79 } |
| 78 | 80 |
| 79 virtual void TearDown() { | 81 virtual void TearDown() { |
| 80 factory_.Destroy(root_surface_id_); | 82 factory_.Destroy(root_surface_id_); |
| 81 SurfaceAggregatorTest::TearDown(); | 83 SurfaceAggregatorTest::TearDown(); |
| 82 } | 84 } |
| 83 | 85 |
| 84 void AggregateAndVerify(test::Pass* expected_passes, | 86 void AggregateAndVerify(test::Pass* expected_passes, |
| 85 size_t expected_pass_count) { | 87 size_t expected_pass_count, |
| 88 SurfaceId* surface_ids, |
| 89 size_t expected_surface_count) { |
| 90 std::set<Surface*> surface_set; |
| 86 scoped_ptr<CompositorFrame> aggregated_frame = | 91 scoped_ptr<CompositorFrame> aggregated_frame = |
| 87 aggregator_.Aggregate(root_surface_id_); | 92 aggregator_.Aggregate(root_surface_id_, &surface_set); |
| 88 | 93 |
| 89 ASSERT_TRUE(aggregated_frame); | 94 ASSERT_TRUE(aggregated_frame); |
| 90 ASSERT_TRUE(aggregated_frame->delegated_frame_data); | 95 ASSERT_TRUE(aggregated_frame->delegated_frame_data); |
| 91 | 96 |
| 92 DelegatedFrameData* frame_data = | 97 DelegatedFrameData* frame_data = |
| 93 aggregated_frame->delegated_frame_data.get(); | 98 aggregated_frame->delegated_frame_data.get(); |
| 94 | 99 |
| 95 TestPassesMatchExpectations( | 100 TestPassesMatchExpectations( |
| 96 expected_passes, expected_pass_count, &frame_data->render_pass_list); | 101 expected_passes, expected_pass_count, &frame_data->render_pass_list); |
| 102 |
| 103 EXPECT_EQ(expected_surface_count, surface_set.size()); |
| 104 for (size_t i = 0; i < expected_surface_count; i++) { |
| 105 Surface* surface = manager_.GetSurfaceForId(surface_ids[i]); |
| 106 EXPECT_TRUE(!!surface); |
| 107 EXPECT_TRUE(surface_set.find(surface) != surface_set.end()); |
| 108 } |
| 97 } | 109 } |
| 98 | 110 |
| 99 void SubmitFrame(test::Pass* passes, | 111 void SubmitFrame(test::Pass* passes, |
| 100 size_t pass_count, | 112 size_t pass_count, |
| 101 SurfaceId surface_id) { | 113 SurfaceId surface_id) { |
| 102 RenderPassList pass_list; | 114 RenderPassList pass_list; |
| 103 AddPasses(&pass_list, gfx::Rect(SurfaceSize()), passes, pass_count); | 115 AddPasses(&pass_list, gfx::Rect(SurfaceSize()), passes, pass_count); |
| 104 | 116 |
| 105 scoped_ptr<DelegatedFrameData> frame_data(new DelegatedFrameData); | 117 scoped_ptr<DelegatedFrameData> frame_data(new DelegatedFrameData); |
| 106 pass_list.swap(frame_data->render_pass_list); | 118 pass_list.swap(frame_data->render_pass_list); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 128 | 140 |
| 129 // Tests that a very simple frame containing only two solid color quads makes it | 141 // Tests that a very simple frame containing only two solid color quads makes it |
| 130 // through the aggregator correctly. | 142 // through the aggregator correctly. |
| 131 TEST_F(SurfaceAggregatorValidSurfaceTest, SimpleFrame) { | 143 TEST_F(SurfaceAggregatorValidSurfaceTest, SimpleFrame) { |
| 132 test::Quad quads[] = {test::Quad::SolidColorQuad(SK_ColorRED), | 144 test::Quad quads[] = {test::Quad::SolidColorQuad(SK_ColorRED), |
| 133 test::Quad::SolidColorQuad(SK_ColorBLUE)}; | 145 test::Quad::SolidColorQuad(SK_ColorBLUE)}; |
| 134 test::Pass passes[] = {test::Pass(quads, arraysize(quads))}; | 146 test::Pass passes[] = {test::Pass(quads, arraysize(quads))}; |
| 135 | 147 |
| 136 SubmitFrame(passes, arraysize(passes), root_surface_id_); | 148 SubmitFrame(passes, arraysize(passes), root_surface_id_); |
| 137 | 149 |
| 138 AggregateAndVerify(passes, arraysize(passes)); | 150 SurfaceId ids[] = {root_surface_id_}; |
| 151 AggregateAndVerify(passes, arraysize(passes), ids, arraysize(ids)); |
| 139 } | 152 } |
| 140 | 153 |
| 141 TEST_F(SurfaceAggregatorValidSurfaceTest, MultiPassSimpleFrame) { | 154 TEST_F(SurfaceAggregatorValidSurfaceTest, MultiPassSimpleFrame) { |
| 142 test::Quad quads[][2] = {{test::Quad::SolidColorQuad(SK_ColorWHITE), | 155 test::Quad quads[][2] = {{test::Quad::SolidColorQuad(SK_ColorWHITE), |
| 143 test::Quad::SolidColorQuad(SK_ColorLTGRAY)}, | 156 test::Quad::SolidColorQuad(SK_ColorLTGRAY)}, |
| 144 {test::Quad::SolidColorQuad(SK_ColorGRAY), | 157 {test::Quad::SolidColorQuad(SK_ColorGRAY), |
| 145 test::Quad::SolidColorQuad(SK_ColorDKGRAY)}}; | 158 test::Quad::SolidColorQuad(SK_ColorDKGRAY)}}; |
| 146 test::Pass passes[] = {test::Pass(quads[0], arraysize(quads[0])), | 159 test::Pass passes[] = {test::Pass(quads[0], arraysize(quads[0])), |
| 147 test::Pass(quads[1], arraysize(quads[1]))}; | 160 test::Pass(quads[1], arraysize(quads[1]))}; |
| 148 | 161 |
| 149 SubmitFrame(passes, arraysize(passes), root_surface_id_); | 162 SubmitFrame(passes, arraysize(passes), root_surface_id_); |
| 150 | 163 |
| 151 AggregateAndVerify(passes, arraysize(passes)); | 164 SurfaceId ids[] = {root_surface_id_}; |
| 165 AggregateAndVerify(passes, arraysize(passes), ids, arraysize(ids)); |
| 152 } | 166 } |
| 153 | 167 |
| 154 // This tests very simple embedding. root_surface has a frame containing a few | 168 // This tests very simple embedding. root_surface has a frame containing a few |
| 155 // solid color quads and a surface quad referencing embedded_surface. | 169 // solid color quads and a surface quad referencing embedded_surface. |
| 156 // embedded_surface has a frame containing only a solid color quad. The solid | 170 // embedded_surface has a frame containing only a solid color quad. The solid |
| 157 // color quad should be aggregated into the final frame. | 171 // color quad should be aggregated into the final frame. |
| 158 TEST_F(SurfaceAggregatorValidSurfaceTest, SimpleSurfaceReference) { | 172 TEST_F(SurfaceAggregatorValidSurfaceTest, SimpleSurfaceReference) { |
| 159 SurfaceId embedded_surface_id = allocator_.GenerateId(); | 173 SurfaceId embedded_surface_id = allocator_.GenerateId(); |
| 160 factory_.Create(embedded_surface_id, SurfaceSize()); | 174 factory_.Create(embedded_surface_id, SurfaceSize()); |
| 161 | 175 |
| 162 test::Quad embedded_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN)}; | 176 test::Quad embedded_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN)}; |
| 163 test::Pass embedded_passes[] = { | 177 test::Pass embedded_passes[] = { |
| 164 test::Pass(embedded_quads, arraysize(embedded_quads))}; | 178 test::Pass(embedded_quads, arraysize(embedded_quads))}; |
| 165 | 179 |
| 166 SubmitFrame(embedded_passes, arraysize(embedded_passes), embedded_surface_id); | 180 SubmitFrame(embedded_passes, arraysize(embedded_passes), embedded_surface_id); |
| 167 | 181 |
| 168 test::Quad root_quads[] = {test::Quad::SolidColorQuad(SK_ColorWHITE), | 182 test::Quad root_quads[] = {test::Quad::SolidColorQuad(SK_ColorWHITE), |
| 169 test::Quad::SurfaceQuad(embedded_surface_id), | 183 test::Quad::SurfaceQuad(embedded_surface_id), |
| 170 test::Quad::SolidColorQuad(SK_ColorBLACK)}; | 184 test::Quad::SolidColorQuad(SK_ColorBLACK)}; |
| 171 test::Pass root_passes[] = {test::Pass(root_quads, arraysize(root_quads))}; | 185 test::Pass root_passes[] = {test::Pass(root_quads, arraysize(root_quads))}; |
| 172 | 186 |
| 173 SubmitFrame(root_passes, arraysize(root_passes), root_surface_id_); | 187 SubmitFrame(root_passes, arraysize(root_passes), root_surface_id_); |
| 174 | 188 |
| 175 test::Quad expected_quads[] = {test::Quad::SolidColorQuad(SK_ColorWHITE), | 189 test::Quad expected_quads[] = {test::Quad::SolidColorQuad(SK_ColorWHITE), |
| 176 test::Quad::SolidColorQuad(SK_ColorGREEN), | 190 test::Quad::SolidColorQuad(SK_ColorGREEN), |
| 177 test::Quad::SolidColorQuad(SK_ColorBLACK)}; | 191 test::Quad::SolidColorQuad(SK_ColorBLACK)}; |
| 178 test::Pass expected_passes[] = { | 192 test::Pass expected_passes[] = { |
| 179 test::Pass(expected_quads, arraysize(expected_quads))}; | 193 test::Pass(expected_quads, arraysize(expected_quads))}; |
| 180 AggregateAndVerify(expected_passes, arraysize(expected_passes)); | 194 SurfaceId ids[] = {root_surface_id_, embedded_surface_id}; |
| 195 AggregateAndVerify( |
| 196 expected_passes, arraysize(expected_passes), ids, arraysize(ids)); |
| 181 | 197 |
| 182 factory_.Destroy(embedded_surface_id); | 198 factory_.Destroy(embedded_surface_id); |
| 183 } | 199 } |
| 184 | 200 |
| 185 // This tests referencing a surface that has multiple render passes. | 201 // This tests referencing a surface that has multiple render passes. |
| 186 TEST_F(SurfaceAggregatorValidSurfaceTest, MultiPassSurfaceReference) { | 202 TEST_F(SurfaceAggregatorValidSurfaceTest, MultiPassSurfaceReference) { |
| 187 SurfaceId embedded_surface_id = allocator_.GenerateId(); | 203 SurfaceId embedded_surface_id = allocator_.GenerateId(); |
| 188 factory_.Create(embedded_surface_id, SurfaceSize()); | 204 factory_.Create(embedded_surface_id, SurfaceSize()); |
| 189 | 205 |
| 190 RenderPass::Id pass_ids[] = {RenderPass::Id(1, 1), RenderPass::Id(1, 2), | 206 RenderPass::Id pass_ids[] = {RenderPass::Id(1, 1), RenderPass::Id(1, 2), |
| (...skipping 15 matching lines...) Expand all Loading... |
| 206 {test::Quad::SurfaceQuad(embedded_surface_id), | 222 {test::Quad::SurfaceQuad(embedded_surface_id), |
| 207 test::Quad::RenderPassQuad(pass_ids[0])}, | 223 test::Quad::RenderPassQuad(pass_ids[0])}, |
| 208 {test::Quad::SolidColorQuad(7), test::Quad::RenderPassQuad(pass_ids[1])}}; | 224 {test::Quad::SolidColorQuad(7), test::Quad::RenderPassQuad(pass_ids[1])}}; |
| 209 test::Pass root_passes[] = { | 225 test::Pass root_passes[] = { |
| 210 test::Pass(root_quads[0], arraysize(root_quads[0]), pass_ids[0]), | 226 test::Pass(root_quads[0], arraysize(root_quads[0]), pass_ids[0]), |
| 211 test::Pass(root_quads[1], arraysize(root_quads[1]), pass_ids[1]), | 227 test::Pass(root_quads[1], arraysize(root_quads[1]), pass_ids[1]), |
| 212 test::Pass(root_quads[2], arraysize(root_quads[2]), pass_ids[2])}; | 228 test::Pass(root_quads[2], arraysize(root_quads[2]), pass_ids[2])}; |
| 213 | 229 |
| 214 SubmitFrame(root_passes, arraysize(root_passes), root_surface_id_); | 230 SubmitFrame(root_passes, arraysize(root_passes), root_surface_id_); |
| 215 | 231 |
| 232 std::set<Surface*> surface_list; |
| 216 scoped_ptr<CompositorFrame> aggregated_frame = | 233 scoped_ptr<CompositorFrame> aggregated_frame = |
| 217 aggregator_.Aggregate(root_surface_id_); | 234 aggregator_.Aggregate(root_surface_id_, &surface_list); |
| 218 | 235 |
| 219 ASSERT_TRUE(aggregated_frame); | 236 ASSERT_TRUE(aggregated_frame); |
| 220 ASSERT_TRUE(aggregated_frame->delegated_frame_data); | 237 ASSERT_TRUE(aggregated_frame->delegated_frame_data); |
| 221 | 238 |
| 222 DelegatedFrameData* frame_data = aggregated_frame->delegated_frame_data.get(); | 239 DelegatedFrameData* frame_data = aggregated_frame->delegated_frame_data.get(); |
| 223 | 240 |
| 224 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list; | 241 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list; |
| 225 | 242 |
| 226 ASSERT_EQ(5u, aggregated_pass_list.size()); | 243 ASSERT_EQ(5u, aggregated_pass_list.size()); |
| 227 RenderPass::Id actual_pass_ids[] = { | 244 RenderPass::Id actual_pass_ids[] = { |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 322 test::Quad::SurfaceQuad(InvalidSurfaceId()), | 339 test::Quad::SurfaceQuad(InvalidSurfaceId()), |
| 323 test::Quad::SolidColorQuad(SK_ColorBLUE)}; | 340 test::Quad::SolidColorQuad(SK_ColorBLUE)}; |
| 324 test::Pass passes[] = {test::Pass(quads, arraysize(quads))}; | 341 test::Pass passes[] = {test::Pass(quads, arraysize(quads))}; |
| 325 | 342 |
| 326 SubmitFrame(passes, arraysize(passes), root_surface_id_); | 343 SubmitFrame(passes, arraysize(passes), root_surface_id_); |
| 327 | 344 |
| 328 test::Quad expected_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN), | 345 test::Quad expected_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN), |
| 329 test::Quad::SolidColorQuad(SK_ColorBLUE)}; | 346 test::Quad::SolidColorQuad(SK_ColorBLUE)}; |
| 330 test::Pass expected_passes[] = { | 347 test::Pass expected_passes[] = { |
| 331 test::Pass(expected_quads, arraysize(expected_quads))}; | 348 test::Pass(expected_quads, arraysize(expected_quads))}; |
| 332 AggregateAndVerify(expected_passes, arraysize(expected_passes)); | 349 SurfaceId ids[] = {root_surface_id_}; |
| 350 AggregateAndVerify( |
| 351 expected_passes, arraysize(expected_passes), ids, arraysize(ids)); |
| 333 } | 352 } |
| 334 | 353 |
| 335 // Tests a reference to a valid surface with no submitted frame. This quad | 354 // Tests a reference to a valid surface with no submitted frame. This quad |
| 336 // should also just be dropped. | 355 // should also just be dropped. |
| 337 TEST_F(SurfaceAggregatorValidSurfaceTest, ValidSurfaceReferenceWithNoFrame) { | 356 TEST_F(SurfaceAggregatorValidSurfaceTest, ValidSurfaceReferenceWithNoFrame) { |
| 338 SurfaceId surface_with_no_frame_id = allocator_.GenerateId(); | 357 SurfaceId surface_with_no_frame_id = allocator_.GenerateId(); |
| 339 factory_.Create(surface_with_no_frame_id, gfx::Size(5, 5)); | 358 factory_.Create(surface_with_no_frame_id, gfx::Size(5, 5)); |
| 340 test::Quad quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN), | 359 test::Quad quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN), |
| 341 test::Quad::SurfaceQuad(surface_with_no_frame_id), | 360 test::Quad::SurfaceQuad(surface_with_no_frame_id), |
| 342 test::Quad::SolidColorQuad(SK_ColorBLUE)}; | 361 test::Quad::SolidColorQuad(SK_ColorBLUE)}; |
| 343 test::Pass passes[] = {test::Pass(quads, arraysize(quads))}; | 362 test::Pass passes[] = {test::Pass(quads, arraysize(quads))}; |
| 344 | 363 |
| 345 SubmitFrame(passes, arraysize(passes), root_surface_id_); | 364 SubmitFrame(passes, arraysize(passes), root_surface_id_); |
| 346 | 365 |
| 347 test::Quad expected_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN), | 366 test::Quad expected_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN), |
| 348 test::Quad::SolidColorQuad(SK_ColorBLUE)}; | 367 test::Quad::SolidColorQuad(SK_ColorBLUE)}; |
| 349 test::Pass expected_passes[] = { | 368 test::Pass expected_passes[] = { |
| 350 test::Pass(expected_quads, arraysize(expected_quads))}; | 369 test::Pass(expected_quads, arraysize(expected_quads))}; |
| 351 AggregateAndVerify(expected_passes, arraysize(expected_passes)); | 370 SurfaceId ids[] = {root_surface_id_, surface_with_no_frame_id}; |
| 371 AggregateAndVerify( |
| 372 expected_passes, arraysize(expected_passes), ids, arraysize(ids)); |
| 352 factory_.Destroy(surface_with_no_frame_id); | 373 factory_.Destroy(surface_with_no_frame_id); |
| 353 } | 374 } |
| 354 | 375 |
| 355 // Tests a surface quad referencing itself, generating a trivial cycle. | 376 // Tests a surface quad referencing itself, generating a trivial cycle. |
| 356 // The quad creating the cycle should be dropped from the final frame. | 377 // The quad creating the cycle should be dropped from the final frame. |
| 357 TEST_F(SurfaceAggregatorValidSurfaceTest, SimpleCyclicalReference) { | 378 TEST_F(SurfaceAggregatorValidSurfaceTest, SimpleCyclicalReference) { |
| 358 test::Quad quads[] = {test::Quad::SurfaceQuad(root_surface_id_), | 379 test::Quad quads[] = {test::Quad::SurfaceQuad(root_surface_id_), |
| 359 test::Quad::SolidColorQuad(SK_ColorYELLOW)}; | 380 test::Quad::SolidColorQuad(SK_ColorYELLOW)}; |
| 360 test::Pass passes[] = {test::Pass(quads, arraysize(quads))}; | 381 test::Pass passes[] = {test::Pass(quads, arraysize(quads))}; |
| 361 | 382 |
| 362 SubmitFrame(passes, arraysize(passes), root_surface_id_); | 383 SubmitFrame(passes, arraysize(passes), root_surface_id_); |
| 363 | 384 |
| 364 test::Quad expected_quads[] = {test::Quad::SolidColorQuad(SK_ColorYELLOW)}; | 385 test::Quad expected_quads[] = {test::Quad::SolidColorQuad(SK_ColorYELLOW)}; |
| 365 test::Pass expected_passes[] = { | 386 test::Pass expected_passes[] = { |
| 366 test::Pass(expected_quads, arraysize(expected_quads))}; | 387 test::Pass(expected_quads, arraysize(expected_quads))}; |
| 367 AggregateAndVerify(expected_passes, arraysize(expected_passes)); | 388 SurfaceId ids[] = {root_surface_id_}; |
| 389 AggregateAndVerify( |
| 390 expected_passes, arraysize(expected_passes), ids, arraysize(ids)); |
| 368 } | 391 } |
| 369 | 392 |
| 370 // Tests a more complex cycle with one intermediate surface. | 393 // Tests a more complex cycle with one intermediate surface. |
| 371 TEST_F(SurfaceAggregatorValidSurfaceTest, TwoSurfaceCyclicalReference) { | 394 TEST_F(SurfaceAggregatorValidSurfaceTest, TwoSurfaceCyclicalReference) { |
| 372 SurfaceId child_surface_id = allocator_.GenerateId(); | 395 SurfaceId child_surface_id = allocator_.GenerateId(); |
| 373 factory_.Create(child_surface_id, SurfaceSize()); | 396 factory_.Create(child_surface_id, SurfaceSize()); |
| 374 | 397 |
| 375 test::Quad parent_quads[] = {test::Quad::SolidColorQuad(SK_ColorBLUE), | 398 test::Quad parent_quads[] = {test::Quad::SolidColorQuad(SK_ColorBLUE), |
| 376 test::Quad::SurfaceQuad(child_surface_id), | 399 test::Quad::SurfaceQuad(child_surface_id), |
| 377 test::Quad::SolidColorQuad(SK_ColorCYAN)}; | 400 test::Quad::SolidColorQuad(SK_ColorCYAN)}; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 392 // SK_ColorBLUE from the parent | 415 // SK_ColorBLUE from the parent |
| 393 // SK_ColorGREEN from the child | 416 // SK_ColorGREEN from the child |
| 394 // SK_ColorMAGENTA from the child | 417 // SK_ColorMAGENTA from the child |
| 395 // SK_ColorCYAN from the parent | 418 // SK_ColorCYAN from the parent |
| 396 test::Quad expected_quads[] = {test::Quad::SolidColorQuad(SK_ColorBLUE), | 419 test::Quad expected_quads[] = {test::Quad::SolidColorQuad(SK_ColorBLUE), |
| 397 test::Quad::SolidColorQuad(SK_ColorGREEN), | 420 test::Quad::SolidColorQuad(SK_ColorGREEN), |
| 398 test::Quad::SolidColorQuad(SK_ColorMAGENTA), | 421 test::Quad::SolidColorQuad(SK_ColorMAGENTA), |
| 399 test::Quad::SolidColorQuad(SK_ColorCYAN)}; | 422 test::Quad::SolidColorQuad(SK_ColorCYAN)}; |
| 400 test::Pass expected_passes[] = { | 423 test::Pass expected_passes[] = { |
| 401 test::Pass(expected_quads, arraysize(expected_quads))}; | 424 test::Pass(expected_quads, arraysize(expected_quads))}; |
| 402 AggregateAndVerify(expected_passes, arraysize(expected_passes)); | 425 SurfaceId ids[] = {root_surface_id_, child_surface_id}; |
| 426 AggregateAndVerify( |
| 427 expected_passes, arraysize(expected_passes), ids, arraysize(ids)); |
| 403 factory_.Destroy(child_surface_id); | 428 factory_.Destroy(child_surface_id); |
| 404 } | 429 } |
| 405 | 430 |
| 406 // Tests that we map render pass IDs from different surfaces into a unified | 431 // Tests that we map render pass IDs from different surfaces into a unified |
| 407 // namespace and update RenderPassDrawQuad's id references to match. | 432 // namespace and update RenderPassDrawQuad's id references to match. |
| 408 TEST_F(SurfaceAggregatorValidSurfaceTest, RenderPassIdMapping) { | 433 TEST_F(SurfaceAggregatorValidSurfaceTest, RenderPassIdMapping) { |
| 409 SurfaceId child_surface_id = allocator_.GenerateId(); | 434 SurfaceId child_surface_id = allocator_.GenerateId(); |
| 410 factory_.Create(child_surface_id, SurfaceSize()); | 435 factory_.Create(child_surface_id, SurfaceSize()); |
| 411 | 436 |
| 412 RenderPass::Id child_pass_id[] = {RenderPass::Id(1, 1), RenderPass::Id(1, 2)}; | 437 RenderPass::Id child_pass_id[] = {RenderPass::Id(1, 1), RenderPass::Id(1, 2)}; |
| 413 test::Quad child_quad[][1] = {{test::Quad::SolidColorQuad(SK_ColorGREEN)}, | 438 test::Quad child_quad[][1] = {{test::Quad::SolidColorQuad(SK_ColorGREEN)}, |
| 414 {test::Quad::RenderPassQuad(child_pass_id[0])}}; | 439 {test::Quad::RenderPassQuad(child_pass_id[0])}}; |
| 415 test::Pass surface_passes[] = { | 440 test::Pass surface_passes[] = { |
| 416 test::Pass(child_quad[0], arraysize(child_quad[0]), child_pass_id[0]), | 441 test::Pass(child_quad[0], arraysize(child_quad[0]), child_pass_id[0]), |
| 417 test::Pass(child_quad[1], arraysize(child_quad[1]), child_pass_id[1])}; | 442 test::Pass(child_quad[1], arraysize(child_quad[1]), child_pass_id[1])}; |
| 418 | 443 |
| 419 SubmitFrame(surface_passes, arraysize(surface_passes), child_surface_id); | 444 SubmitFrame(surface_passes, arraysize(surface_passes), child_surface_id); |
| 420 | 445 |
| 421 // Pass IDs from the parent surface may collide with ones from the child. | 446 // Pass IDs from the parent surface may collide with ones from the child. |
| 422 RenderPass::Id parent_pass_id[] = {RenderPass::Id(2, 1), | 447 RenderPass::Id parent_pass_id[] = {RenderPass::Id(2, 1), |
| 423 RenderPass::Id(1, 2)}; | 448 RenderPass::Id(1, 2)}; |
| 424 test::Quad parent_quad[][1] = { | 449 test::Quad parent_quad[][1] = { |
| 425 {test::Quad::SurfaceQuad(child_surface_id)}, | 450 {test::Quad::SurfaceQuad(child_surface_id)}, |
| 426 {test::Quad::RenderPassQuad(parent_pass_id[0])}}; | 451 {test::Quad::RenderPassQuad(parent_pass_id[0])}}; |
| 427 test::Pass parent_passes[] = { | 452 test::Pass parent_passes[] = { |
| 428 test::Pass(parent_quad[0], arraysize(parent_quad[0]), parent_pass_id[0]), | 453 test::Pass(parent_quad[0], arraysize(parent_quad[0]), parent_pass_id[0]), |
| 429 test::Pass(parent_quad[1], arraysize(parent_quad[1]), parent_pass_id[1])}; | 454 test::Pass(parent_quad[1], arraysize(parent_quad[1]), parent_pass_id[1])}; |
| 430 | 455 |
| 431 SubmitFrame(parent_passes, arraysize(parent_passes), root_surface_id_); | 456 SubmitFrame(parent_passes, arraysize(parent_passes), root_surface_id_); |
| 457 std::set<Surface*> surface_list; |
| 432 scoped_ptr<CompositorFrame> aggregated_frame = | 458 scoped_ptr<CompositorFrame> aggregated_frame = |
| 433 aggregator_.Aggregate(root_surface_id_); | 459 aggregator_.Aggregate(root_surface_id_, &surface_list); |
| 434 | 460 |
| 435 ASSERT_TRUE(aggregated_frame); | 461 ASSERT_TRUE(aggregated_frame); |
| 436 ASSERT_TRUE(aggregated_frame->delegated_frame_data); | 462 ASSERT_TRUE(aggregated_frame->delegated_frame_data); |
| 437 | 463 |
| 438 DelegatedFrameData* frame_data = aggregated_frame->delegated_frame_data.get(); | 464 DelegatedFrameData* frame_data = aggregated_frame->delegated_frame_data.get(); |
| 439 | 465 |
| 440 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list; | 466 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list; |
| 441 | 467 |
| 442 ASSERT_EQ(3u, aggregated_pass_list.size()); | 468 ASSERT_EQ(3u, aggregated_pass_list.size()); |
| 443 RenderPass::Id actual_pass_ids[] = {aggregated_pass_list[0]->id, | 469 RenderPass::Id actual_pass_ids[] = {aggregated_pass_list[0]->id, |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 593 root_pass->CreateAndAppendDrawQuad<SurfaceDrawQuad>(); | 619 root_pass->CreateAndAppendDrawQuad<SurfaceDrawQuad>(); |
| 594 child_two_surface_quad->SetNew(root_pass->shared_quad_state_list.back(), | 620 child_two_surface_quad->SetNew(root_pass->shared_quad_state_list.back(), |
| 595 gfx::Rect(SurfaceSize()), | 621 gfx::Rect(SurfaceSize()), |
| 596 gfx::Rect(SurfaceSize()), | 622 gfx::Rect(SurfaceSize()), |
| 597 child_two_surface_id); | 623 child_two_surface_id); |
| 598 AddSolidColorQuadWithBlendMode( | 624 AddSolidColorQuadWithBlendMode( |
| 599 SurfaceSize(), root_pass.get(), blend_modes[6]); | 625 SurfaceSize(), root_pass.get(), blend_modes[6]); |
| 600 | 626 |
| 601 QueuePassAsFrame(root_pass.Pass(), root_surface_id_); | 627 QueuePassAsFrame(root_pass.Pass(), root_surface_id_); |
| 602 | 628 |
| 629 std::set<Surface*> surface_list; |
| 603 scoped_ptr<CompositorFrame> aggregated_frame = | 630 scoped_ptr<CompositorFrame> aggregated_frame = |
| 604 aggregator_.Aggregate(root_surface_id_); | 631 aggregator_.Aggregate(root_surface_id_, &surface_list); |
| 605 | 632 |
| 606 ASSERT_TRUE(aggregated_frame); | 633 ASSERT_TRUE(aggregated_frame); |
| 607 ASSERT_TRUE(aggregated_frame->delegated_frame_data); | 634 ASSERT_TRUE(aggregated_frame->delegated_frame_data); |
| 608 | 635 |
| 609 DelegatedFrameData* frame_data = aggregated_frame->delegated_frame_data.get(); | 636 DelegatedFrameData* frame_data = aggregated_frame->delegated_frame_data.get(); |
| 610 | 637 |
| 611 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list; | 638 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list; |
| 612 | 639 |
| 613 ASSERT_EQ(1u, aggregated_pass_list.size()); | 640 ASSERT_EQ(1u, aggregated_pass_list.size()); |
| 614 | 641 |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 694 ->content_to_target_transform.Translate(0, 10); | 721 ->content_to_target_transform.Translate(0, 10); |
| 695 | 722 |
| 696 scoped_ptr<DelegatedFrameData> root_frame_data(new DelegatedFrameData); | 723 scoped_ptr<DelegatedFrameData> root_frame_data(new DelegatedFrameData); |
| 697 root_pass_list.swap(root_frame_data->render_pass_list); | 724 root_pass_list.swap(root_frame_data->render_pass_list); |
| 698 | 725 |
| 699 scoped_ptr<CompositorFrame> root_frame(new CompositorFrame); | 726 scoped_ptr<CompositorFrame> root_frame(new CompositorFrame); |
| 700 root_frame->delegated_frame_data = root_frame_data.Pass(); | 727 root_frame->delegated_frame_data = root_frame_data.Pass(); |
| 701 | 728 |
| 702 factory_.SubmitFrame(root_surface_id_, root_frame.Pass()); | 729 factory_.SubmitFrame(root_surface_id_, root_frame.Pass()); |
| 703 | 730 |
| 731 std::set<Surface*> surface_list; |
| 704 scoped_ptr<CompositorFrame> aggregated_frame = | 732 scoped_ptr<CompositorFrame> aggregated_frame = |
| 705 aggregator_.Aggregate(root_surface_id_); | 733 aggregator_.Aggregate(root_surface_id_, &surface_list); |
| 706 | 734 |
| 707 ASSERT_TRUE(aggregated_frame); | 735 ASSERT_TRUE(aggregated_frame); |
| 708 ASSERT_TRUE(aggregated_frame->delegated_frame_data); | 736 ASSERT_TRUE(aggregated_frame->delegated_frame_data); |
| 709 | 737 |
| 710 DelegatedFrameData* frame_data = aggregated_frame->delegated_frame_data.get(); | 738 DelegatedFrameData* frame_data = aggregated_frame->delegated_frame_data.get(); |
| 711 | 739 |
| 712 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list; | 740 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list; |
| 713 | 741 |
| 714 ASSERT_EQ(2u, aggregated_pass_list.size()); | 742 ASSERT_EQ(2u, aggregated_pass_list.size()); |
| 715 | 743 |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 855 | 883 |
| 856 TEST_F(SurfaceAggregatorWithResourcesTest, TakeResourcesOneSurface) { | 884 TEST_F(SurfaceAggregatorWithResourcesTest, TakeResourcesOneSurface) { |
| 857 ResourceTrackingSurfaceFactoryClient client; | 885 ResourceTrackingSurfaceFactoryClient client; |
| 858 SurfaceFactory factory(&manager_, &client); | 886 SurfaceFactory factory(&manager_, &client); |
| 859 SurfaceId surface_id(7u); | 887 SurfaceId surface_id(7u); |
| 860 factory.Create(surface_id, SurfaceSize()); | 888 factory.Create(surface_id, SurfaceSize()); |
| 861 | 889 |
| 862 ResourceProvider::ResourceId ids[] = {11, 12, 13}; | 890 ResourceProvider::ResourceId ids[] = {11, 12, 13}; |
| 863 SubmitFrameWithResources(ids, arraysize(ids), &factory, surface_id); | 891 SubmitFrameWithResources(ids, arraysize(ids), &factory, surface_id); |
| 864 | 892 |
| 865 scoped_ptr<CompositorFrame> frame = aggregator_->Aggregate(surface_id); | 893 std::set<Surface*> surface_list; |
| 894 scoped_ptr<CompositorFrame> frame = |
| 895 aggregator_->Aggregate(surface_id, &surface_list); |
| 866 | 896 |
| 867 // Nothing should be available to be returned yet. | 897 // Nothing should be available to be returned yet. |
| 868 EXPECT_TRUE(client.returned_resources().empty()); | 898 EXPECT_TRUE(client.returned_resources().empty()); |
| 869 | 899 |
| 870 SubmitFrameWithResources(NULL, 0u, &factory, surface_id); | 900 SubmitFrameWithResources(NULL, 0u, &factory, surface_id); |
| 871 | 901 |
| 872 frame = aggregator_->Aggregate(surface_id); | 902 surface_list.clear(); |
| 903 frame = aggregator_->Aggregate(surface_id, &surface_list); |
| 873 | 904 |
| 874 ASSERT_EQ(3u, client.returned_resources().size()); | 905 ASSERT_EQ(3u, client.returned_resources().size()); |
| 875 ResourceProvider::ResourceId returned_ids[3]; | 906 ResourceProvider::ResourceId returned_ids[3]; |
| 876 for (size_t i = 0; i < 3; ++i) { | 907 for (size_t i = 0; i < 3; ++i) { |
| 877 returned_ids[i] = client.returned_resources()[i].id; | 908 returned_ids[i] = client.returned_resources()[i].id; |
| 878 } | 909 } |
| 879 EXPECT_THAT(returned_ids, | 910 EXPECT_THAT(returned_ids, |
| 880 testing::WhenSorted(testing::ElementsAreArray(ids))); | 911 testing::WhenSorted(testing::ElementsAreArray(ids))); |
| 881 factory.Destroy(surface_id); | 912 factory.Destroy(surface_id); |
| 882 } | 913 } |
| 883 | 914 |
| 884 } // namespace | 915 } // namespace |
| 885 } // namespace cc | 916 } // namespace cc |
| 886 | 917 |
| OLD | NEW |