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

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

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

Powered by Google App Engine
This is Rietveld 408576698