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 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
319 // First, there's the first embedded pass which doesn't reference anything | 319 // First, there's the first embedded pass which doesn't reference anything |
320 // else. | 320 // else. |
321 TestPassMatchesExpectations(embedded_passes[0], aggregated_pass_list[1]); | 321 TestPassMatchesExpectations(embedded_passes[0], aggregated_pass_list[1]); |
322 } | 322 } |
323 | 323 |
324 { | 324 { |
325 SCOPED_TRACE("Third pass"); | 325 SCOPED_TRACE("Third pass"); |
326 const QuadList& third_pass_quad_list = aggregated_pass_list[2]->quad_list; | 326 const QuadList& third_pass_quad_list = aggregated_pass_list[2]->quad_list; |
327 ASSERT_EQ(2u, third_pass_quad_list.size()); | 327 ASSERT_EQ(2u, third_pass_quad_list.size()); |
328 TestQuadMatchesExpectations(embedded_quads[1][0], | 328 TestQuadMatchesExpectations(embedded_quads[1][0], |
329 third_pass_quad_list.at(0u)); | 329 third_pass_quad_list.ElementAt(0)); |
330 | 330 |
331 // This render pass pass quad will reference the first pass from the | 331 // This render pass pass quad will reference the first pass from the |
332 // embedded surface, which is the second pass in the aggregated frame. | 332 // embedded surface, which is the second pass in the aggregated frame. |
333 ASSERT_EQ(DrawQuad::RENDER_PASS, third_pass_quad_list.at(1u)->material); | 333 ASSERT_EQ(DrawQuad::RENDER_PASS, |
| 334 third_pass_quad_list.ElementAt(1)->material); |
334 const RenderPassDrawQuad* third_pass_render_pass_draw_quad = | 335 const RenderPassDrawQuad* third_pass_render_pass_draw_quad = |
335 RenderPassDrawQuad::MaterialCast(third_pass_quad_list.at(1u)); | 336 RenderPassDrawQuad::MaterialCast(third_pass_quad_list.ElementAt(1)); |
336 EXPECT_EQ(actual_pass_ids[1], | 337 EXPECT_EQ(actual_pass_ids[1], |
337 third_pass_render_pass_draw_quad->render_pass_id); | 338 third_pass_render_pass_draw_quad->render_pass_id); |
338 } | 339 } |
339 | 340 |
340 { | 341 { |
341 SCOPED_TRACE("Fourth pass"); | 342 SCOPED_TRACE("Fourth pass"); |
342 // The fourth pass will have aggregated quads from the root surface's second | 343 // The fourth pass will have aggregated quads from the root surface's second |
343 // pass and the embedded surface's first pass. | 344 // pass and the embedded surface's first pass. |
344 const QuadList& fourth_pass_quad_list = aggregated_pass_list[3]->quad_list; | 345 const QuadList& fourth_pass_quad_list = aggregated_pass_list[3]->quad_list; |
345 ASSERT_EQ(3u, fourth_pass_quad_list.size()); | 346 ASSERT_EQ(3u, fourth_pass_quad_list.size()); |
346 | 347 |
347 // The first quad will be the yellow quad from the embedded surface's last | 348 // The first quad will be the yellow quad from the embedded surface's last |
348 // pass. | 349 // pass. |
349 TestQuadMatchesExpectations(embedded_quads[2][0], | 350 TestQuadMatchesExpectations(embedded_quads[2][0], |
350 fourth_pass_quad_list.at(0u)); | 351 fourth_pass_quad_list.ElementAt(0)); |
351 | 352 |
352 // The next quad will be a render pass quad referencing the second pass from | 353 // The next quad will be a render pass quad referencing the second pass from |
353 // the embedded surface, which is the third pass in the aggregated frame. | 354 // the embedded surface, which is the third pass in the aggregated frame. |
354 ASSERT_EQ(DrawQuad::RENDER_PASS, fourth_pass_quad_list.at(1u)->material); | 355 ASSERT_EQ(DrawQuad::RENDER_PASS, |
| 356 fourth_pass_quad_list.ElementAt(1)->material); |
355 const RenderPassDrawQuad* fourth_pass_first_render_pass_draw_quad = | 357 const RenderPassDrawQuad* fourth_pass_first_render_pass_draw_quad = |
356 RenderPassDrawQuad::MaterialCast(fourth_pass_quad_list.at(1u)); | 358 RenderPassDrawQuad::MaterialCast(fourth_pass_quad_list.ElementAt(1)); |
357 EXPECT_EQ(actual_pass_ids[2], | 359 EXPECT_EQ(actual_pass_ids[2], |
358 fourth_pass_first_render_pass_draw_quad->render_pass_id); | 360 fourth_pass_first_render_pass_draw_quad->render_pass_id); |
359 | 361 |
360 // The last quad will be a render pass quad referencing the first pass from | 362 // The last quad will be a render pass quad referencing the first pass from |
361 // the root surface, which is the first pass overall. | 363 // the root surface, which is the first pass overall. |
362 ASSERT_EQ(DrawQuad::RENDER_PASS, fourth_pass_quad_list.at(2u)->material); | 364 ASSERT_EQ(DrawQuad::RENDER_PASS, |
| 365 fourth_pass_quad_list.ElementAt(2)->material); |
363 const RenderPassDrawQuad* fourth_pass_second_render_pass_draw_quad = | 366 const RenderPassDrawQuad* fourth_pass_second_render_pass_draw_quad = |
364 RenderPassDrawQuad::MaterialCast(fourth_pass_quad_list.at(2u)); | 367 RenderPassDrawQuad::MaterialCast(fourth_pass_quad_list.ElementAt(2)); |
365 EXPECT_EQ(actual_pass_ids[0], | 368 EXPECT_EQ(actual_pass_ids[0], |
366 fourth_pass_second_render_pass_draw_quad->render_pass_id); | 369 fourth_pass_second_render_pass_draw_quad->render_pass_id); |
367 } | 370 } |
368 | 371 |
369 { | 372 { |
370 SCOPED_TRACE("Fifth pass"); | 373 SCOPED_TRACE("Fifth pass"); |
371 const QuadList& fifth_pass_quad_list = aggregated_pass_list[4]->quad_list; | 374 const QuadList& fifth_pass_quad_list = aggregated_pass_list[4]->quad_list; |
372 ASSERT_EQ(2u, fifth_pass_quad_list.size()); | 375 ASSERT_EQ(2u, fifth_pass_quad_list.size()); |
373 | 376 |
374 TestQuadMatchesExpectations(root_quads[2][0], fifth_pass_quad_list.at(0)); | 377 TestQuadMatchesExpectations(root_quads[2][0], |
| 378 fifth_pass_quad_list.ElementAt(0)); |
375 | 379 |
376 // The last quad in the last pass will reference the second pass from the | 380 // The last quad in the last pass will reference the second pass from the |
377 // root surface, which after aggregating is the fourth pass in the overall | 381 // root surface, which after aggregating is the fourth pass in the overall |
378 // list. | 382 // list. |
379 ASSERT_EQ(DrawQuad::RENDER_PASS, fifth_pass_quad_list.at(1u)->material); | 383 ASSERT_EQ(DrawQuad::RENDER_PASS, |
| 384 fifth_pass_quad_list.ElementAt(1)->material); |
380 const RenderPassDrawQuad* fifth_pass_render_pass_draw_quad = | 385 const RenderPassDrawQuad* fifth_pass_render_pass_draw_quad = |
381 RenderPassDrawQuad::MaterialCast(fifth_pass_quad_list.at(1u)); | 386 RenderPassDrawQuad::MaterialCast(fifth_pass_quad_list.ElementAt(1)); |
382 EXPECT_EQ(actual_pass_ids[3], | 387 EXPECT_EQ(actual_pass_ids[3], |
383 fifth_pass_render_pass_draw_quad->render_pass_id); | 388 fifth_pass_render_pass_draw_quad->render_pass_id); |
384 } | 389 } |
385 factory_.Destroy(embedded_surface_id); | 390 factory_.Destroy(embedded_surface_id); |
386 } | 391 } |
387 | 392 |
388 // Tests an invalid surface reference in a frame. The surface quad should just | 393 // Tests an invalid surface reference in a frame. The surface quad should just |
389 // be dropped. | 394 // be dropped. |
390 TEST_F(SurfaceAggregatorValidSurfaceTest, InvalidSurfaceReference) { | 395 TEST_F(SurfaceAggregatorValidSurfaceTest, InvalidSurfaceReference) { |
391 test::Quad quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN), | 396 test::Quad quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN), |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
522 aggregated_pass_list[2]->id}; | 527 aggregated_pass_list[2]->id}; |
523 // Make sure the aggregated frame's pass IDs are all unique. | 528 // Make sure the aggregated frame's pass IDs are all unique. |
524 for (size_t i = 0; i < 3; ++i) { | 529 for (size_t i = 0; i < 3; ++i) { |
525 for (size_t j = 0; j < i; ++j) { | 530 for (size_t j = 0; j < i; ++j) { |
526 EXPECT_NE(actual_pass_ids[j], actual_pass_ids[i]) << "pass ids " << i | 531 EXPECT_NE(actual_pass_ids[j], actual_pass_ids[i]) << "pass ids " << i |
527 << " and " << j; | 532 << " and " << j; |
528 } | 533 } |
529 } | 534 } |
530 | 535 |
531 // Make sure the render pass quads reference the remapped pass IDs. | 536 // Make sure the render pass quads reference the remapped pass IDs. |
532 DrawQuad* render_pass_quads[] = {aggregated_pass_list[1]->quad_list[0], | 537 DrawQuad* render_pass_quads[] = {aggregated_pass_list[1]->quad_list.front(), |
533 aggregated_pass_list[2]->quad_list[0]}; | 538 aggregated_pass_list[2]->quad_list.front()}; |
534 ASSERT_EQ(render_pass_quads[0]->material, DrawQuad::RENDER_PASS); | 539 ASSERT_EQ(render_pass_quads[0]->material, DrawQuad::RENDER_PASS); |
535 EXPECT_EQ( | 540 EXPECT_EQ( |
536 actual_pass_ids[0], | 541 actual_pass_ids[0], |
537 RenderPassDrawQuad::MaterialCast(render_pass_quads[0])->render_pass_id); | 542 RenderPassDrawQuad::MaterialCast(render_pass_quads[0])->render_pass_id); |
538 | 543 |
539 ASSERT_EQ(render_pass_quads[1]->material, DrawQuad::RENDER_PASS); | 544 ASSERT_EQ(render_pass_quads[1]->material, DrawQuad::RENDER_PASS); |
540 EXPECT_EQ( | 545 EXPECT_EQ( |
541 actual_pass_ids[1], | 546 actual_pass_ids[1], |
542 RenderPassDrawQuad::MaterialCast(render_pass_quads[1])->render_pass_id); | 547 RenderPassDrawQuad::MaterialCast(render_pass_quads[1])->render_pass_id); |
543 factory_.Destroy(child_surface_id); | 548 factory_.Destroy(child_surface_id); |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
686 DelegatedFrameData* frame_data = aggregated_frame->delegated_frame_data.get(); | 691 DelegatedFrameData* frame_data = aggregated_frame->delegated_frame_data.get(); |
687 | 692 |
688 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list; | 693 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list; |
689 | 694 |
690 ASSERT_EQ(1u, aggregated_pass_list.size()); | 695 ASSERT_EQ(1u, aggregated_pass_list.size()); |
691 | 696 |
692 const QuadList& aggregated_quad_list = aggregated_pass_list[0]->quad_list; | 697 const QuadList& aggregated_quad_list = aggregated_pass_list[0]->quad_list; |
693 | 698 |
694 ASSERT_EQ(7u, aggregated_quad_list.size()); | 699 ASSERT_EQ(7u, aggregated_quad_list.size()); |
695 | 700 |
696 for (size_t i = 0; i < aggregated_quad_list.size(); ++i) { | 701 size_t i = 0; |
697 DrawQuad* quad = aggregated_quad_list[i]; | 702 for (QuadList::ConstIterator iter = aggregated_quad_list.begin(); |
698 EXPECT_EQ(blend_modes[i], quad->shared_quad_state->blend_mode) << i; | 703 iter != aggregated_quad_list.end(); |
| 704 ++iter) { |
| 705 EXPECT_EQ(blend_modes[i], iter->shared_quad_state->blend_mode) << i; |
| 706 ++i; |
699 } | 707 } |
700 factory_.Destroy(child_one_surface_id); | 708 factory_.Destroy(child_one_surface_id); |
701 factory_.Destroy(child_two_surface_id); | 709 factory_.Destroy(child_two_surface_id); |
702 factory_.Destroy(grandchild_surface_id); | 710 factory_.Destroy(grandchild_surface_id); |
703 } | 711 } |
704 | 712 |
705 // This tests that when aggregating a frame with multiple render passes that we | 713 // This tests that when aggregating a frame with multiple render passes that we |
706 // map the transforms for the root pass but do not modify the transform on child | 714 // map the transforms for the root pass but do not modify the transform on child |
707 // passes. | 715 // passes. |
708 // | 716 // |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
823 gfx::Transform expected_root_pass_quad_transforms[2]; | 831 gfx::Transform expected_root_pass_quad_transforms[2]; |
824 // The first quad in the root pass is the solid color quad from the original | 832 // The first quad in the root pass is the solid color quad from the original |
825 // root surface. Its transform should be unaffected by the aggregation and | 833 // root surface. Its transform should be unaffected by the aggregation and |
826 // still be +7 in the y direction. | 834 // still be +7 in the y direction. |
827 expected_root_pass_quad_transforms[0].Translate(0, 7); | 835 expected_root_pass_quad_transforms[0].Translate(0, 7); |
828 // The second quad in the root pass is aggregated from the child surface so | 836 // The second quad in the root pass is aggregated from the child surface so |
829 // its transform should be the combination of its original translation (0, 10) | 837 // its transform should be the combination of its original translation (0, 10) |
830 // and the child surface draw quad's translation (8, 0). | 838 // and the child surface draw quad's translation (8, 0). |
831 expected_root_pass_quad_transforms[1].Translate(8, 10); | 839 expected_root_pass_quad_transforms[1].Translate(8, 10); |
832 | 840 |
833 for (size_t i = 0; i < 2; ++i) { | 841 size_t i = 0; |
834 DrawQuad* quad = aggregated_pass_list[1]->quad_list.at(i); | 842 for (QuadList::Iterator iter = aggregated_pass_list[1]->quad_list.begin(); |
| 843 iter != aggregated_pass_list[1]->quad_list.end(); |
| 844 ++iter) { |
835 EXPECT_EQ(expected_root_pass_quad_transforms[i].ToString(), | 845 EXPECT_EQ(expected_root_pass_quad_transforms[i].ToString(), |
836 quad->quadTransform().ToString()) | 846 iter->quadTransform().ToString()) |
837 << i; | 847 << i; |
| 848 i++; |
838 } | 849 } |
839 | 850 |
840 EXPECT_EQ(true, | 851 EXPECT_EQ(true, |
841 aggregated_pass_list[1]->shared_quad_state_list[1]->is_clipped); | 852 aggregated_pass_list[1]->shared_quad_state_list[1]->is_clipped); |
842 | 853 |
843 // The second quad in the root pass is aggregated from the child, so its | 854 // The second quad in the root pass is aggregated from the child, so its |
844 // clip rect must be transformed by the child's translation. | 855 // clip rect must be transformed by the child's translation. |
845 EXPECT_EQ( | 856 EXPECT_EQ( |
846 gfx::Rect(0, 10, 5, 5).ToString(), | 857 gfx::Rect(0, 10, 5, 5).ToString(), |
847 aggregated_pass_list[1]->shared_quad_state_list[1]->clip_rect.ToString()); | 858 aggregated_pass_list[1]->shared_quad_state_list[1]->clip_rect.ToString()); |
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1135 returned_ids[i] = client.returned_resources()[i].id; | 1146 returned_ids[i] = client.returned_resources()[i].id; |
1136 } | 1147 } |
1137 EXPECT_THAT(returned_ids, | 1148 EXPECT_THAT(returned_ids, |
1138 testing::WhenSorted(testing::ElementsAreArray(ids))); | 1149 testing::WhenSorted(testing::ElementsAreArray(ids))); |
1139 factory.Destroy(surface_id); | 1150 factory.Destroy(surface_id); |
1140 } | 1151 } |
1141 | 1152 |
1142 } // namespace | 1153 } // namespace |
1143 } // namespace cc | 1154 } // namespace cc |
1144 | 1155 |
OLD | NEW |