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

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: fix rebase 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 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 // quad embedded into the root surface's second pass. 262 // quad embedded into the root surface's second pass.
263 // First, there's the first embedded pass which doesn't reference anything 263 // First, there's the first embedded pass which doesn't reference anything
264 // else. 264 // else.
265 TestPassMatchesExpectations(embedded_passes[0], aggregated_pass_list[1]); 265 TestPassMatchesExpectations(embedded_passes[0], aggregated_pass_list[1]);
266 } 266 }
267 267
268 { 268 {
269 SCOPED_TRACE("Third pass"); 269 SCOPED_TRACE("Third pass");
270 const QuadList& third_pass_quad_list = aggregated_pass_list[2]->quad_list; 270 const QuadList& third_pass_quad_list = aggregated_pass_list[2]->quad_list;
271 ASSERT_EQ(2u, third_pass_quad_list.size()); 271 ASSERT_EQ(2u, third_pass_quad_list.size());
272 TestQuadMatchesExpectations(embedded_quads[1][0], 272 QuadList::ConstIterator iter = third_pass_quad_list.begin();
273 third_pass_quad_list.at(0u)); 273 TestQuadMatchesExpectations(embedded_quads[1][0], &*iter);
274 274
275 // This render pass pass quad will reference the first pass from the 275 // This render pass pass quad will reference the first pass from the
276 // embedded surface, which is the second pass in the aggregated frame. 276 // embedded surface, which is the second pass in the aggregated frame.
277 ASSERT_EQ(DrawQuad::RENDER_PASS, third_pass_quad_list.at(1u)->material); 277 ++iter;
278 ASSERT_EQ(DrawQuad::RENDER_PASS, iter->material);
278 const RenderPassDrawQuad* third_pass_render_pass_draw_quad = 279 const RenderPassDrawQuad* third_pass_render_pass_draw_quad =
279 RenderPassDrawQuad::MaterialCast(third_pass_quad_list.at(1u)); 280 RenderPassDrawQuad::MaterialCast(&*iter);
280 EXPECT_EQ(actual_pass_ids[1], 281 EXPECT_EQ(actual_pass_ids[1],
281 third_pass_render_pass_draw_quad->render_pass_id); 282 third_pass_render_pass_draw_quad->render_pass_id);
282 } 283 }
283 284
284 { 285 {
285 SCOPED_TRACE("Fourth pass"); 286 SCOPED_TRACE("Fourth pass");
286 // The fourth pass will have aggregated quads from the root surface's second 287 // The fourth pass will have aggregated quads from the root surface's second
287 // pass and the embedded surface's first pass. 288 // pass and the embedded surface's first pass.
288 const QuadList& fourth_pass_quad_list = aggregated_pass_list[3]->quad_list; 289 const QuadList& fourth_pass_quad_list = aggregated_pass_list[3]->quad_list;
289 ASSERT_EQ(3u, fourth_pass_quad_list.size()); 290 ASSERT_EQ(3u, fourth_pass_quad_list.size());
290 291
291 // The first quad will be the yellow quad from the embedded surface's last 292 // The first quad will be the yellow quad from the embedded surface's last
292 // pass. 293 // pass.
293 TestQuadMatchesExpectations(embedded_quads[2][0], 294 QuadList::ConstIterator iter = fourth_pass_quad_list.begin();
294 fourth_pass_quad_list.at(0u)); 295 TestQuadMatchesExpectations(embedded_quads[2][0], &*iter);
295 296
296 // The next quad will be a render pass quad referencing the second pass from 297 // The next quad will be a render pass quad referencing the second pass from
297 // the embedded surface, which is the third pass in the aggregated frame. 298 // the embedded surface, which is the third pass in the aggregated frame.
298 ASSERT_EQ(DrawQuad::RENDER_PASS, fourth_pass_quad_list.at(1u)->material); 299 ++iter;
300 ASSERT_EQ(DrawQuad::RENDER_PASS, iter->material);
299 const RenderPassDrawQuad* fourth_pass_first_render_pass_draw_quad = 301 const RenderPassDrawQuad* fourth_pass_first_render_pass_draw_quad =
300 RenderPassDrawQuad::MaterialCast(fourth_pass_quad_list.at(1u)); 302 RenderPassDrawQuad::MaterialCast(&*iter);
301 EXPECT_EQ(actual_pass_ids[2], 303 EXPECT_EQ(actual_pass_ids[2],
302 fourth_pass_first_render_pass_draw_quad->render_pass_id); 304 fourth_pass_first_render_pass_draw_quad->render_pass_id);
303 305
304 // The last quad will be a render pass quad referencing the first pass from 306 // The last quad will be a render pass quad referencing the first pass from
305 // the root surface, which is the first pass overall. 307 // the root surface, which is the first pass overall.
306 ASSERT_EQ(DrawQuad::RENDER_PASS, fourth_pass_quad_list.at(2u)->material); 308 ++iter;
309 ASSERT_EQ(DrawQuad::RENDER_PASS, iter->material);
307 const RenderPassDrawQuad* fourth_pass_second_render_pass_draw_quad = 310 const RenderPassDrawQuad* fourth_pass_second_render_pass_draw_quad =
308 RenderPassDrawQuad::MaterialCast(fourth_pass_quad_list.at(2u)); 311 RenderPassDrawQuad::MaterialCast(&*iter);
309 EXPECT_EQ(actual_pass_ids[0], 312 EXPECT_EQ(actual_pass_ids[0],
310 fourth_pass_second_render_pass_draw_quad->render_pass_id); 313 fourth_pass_second_render_pass_draw_quad->render_pass_id);
311 } 314 }
312 315
313 { 316 {
314 SCOPED_TRACE("Fifth pass"); 317 SCOPED_TRACE("Fifth pass");
315 const QuadList& fifth_pass_quad_list = aggregated_pass_list[4]->quad_list; 318 const QuadList& fifth_pass_quad_list = aggregated_pass_list[4]->quad_list;
316 ASSERT_EQ(2u, fifth_pass_quad_list.size()); 319 ASSERT_EQ(2u, fifth_pass_quad_list.size());
317 320
318 TestQuadMatchesExpectations(root_quads[2][0], fifth_pass_quad_list.at(0)); 321 QuadList::ConstIterator iter = fifth_pass_quad_list.begin();
322 TestQuadMatchesExpectations(root_quads[2][0], &*iter);
319 323
320 // The last quad in the last pass will reference the second pass from the 324 // The last quad in the last pass will reference the second pass from the
321 // root surface, which after aggregating is the fourth pass in the overall 325 // root surface, which after aggregating is the fourth pass in the overall
322 // list. 326 // list.
323 ASSERT_EQ(DrawQuad::RENDER_PASS, fifth_pass_quad_list.at(1u)->material); 327 ++iter;
328 ASSERT_EQ(DrawQuad::RENDER_PASS, iter->material);
324 const RenderPassDrawQuad* fifth_pass_render_pass_draw_quad = 329 const RenderPassDrawQuad* fifth_pass_render_pass_draw_quad =
325 RenderPassDrawQuad::MaterialCast(fifth_pass_quad_list.at(1u)); 330 RenderPassDrawQuad::MaterialCast(&*iter);
326 EXPECT_EQ(actual_pass_ids[3], 331 EXPECT_EQ(actual_pass_ids[3],
327 fifth_pass_render_pass_draw_quad->render_pass_id); 332 fifth_pass_render_pass_draw_quad->render_pass_id);
328 } 333 }
329 factory_.Destroy(embedded_surface_id); 334 factory_.Destroy(embedded_surface_id);
330 } 335 }
331 336
332 // Tests an invalid surface reference in a frame. The surface quad should just 337 // Tests an invalid surface reference in a frame. The surface quad should just
333 // be dropped. 338 // be dropped.
334 TEST_F(SurfaceAggregatorValidSurfaceTest, InvalidSurfaceReference) { 339 TEST_F(SurfaceAggregatorValidSurfaceTest, InvalidSurfaceReference) {
335 test::Quad quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN), 340 test::Quad quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN),
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
466 aggregated_pass_list[2]->id}; 471 aggregated_pass_list[2]->id};
467 // Make sure the aggregated frame's pass IDs are all unique. 472 // Make sure the aggregated frame's pass IDs are all unique.
468 for (size_t i = 0; i < 3; ++i) { 473 for (size_t i = 0; i < 3; ++i) {
469 for (size_t j = 0; j < i; ++j) { 474 for (size_t j = 0; j < i; ++j) {
470 EXPECT_NE(actual_pass_ids[j], actual_pass_ids[i]) << "pass ids " << i 475 EXPECT_NE(actual_pass_ids[j], actual_pass_ids[i]) << "pass ids " << i
471 << " and " << j; 476 << " and " << j;
472 } 477 }
473 } 478 }
474 479
475 // Make sure the render pass quads reference the remapped pass IDs. 480 // Make sure the render pass quads reference the remapped pass IDs.
476 DrawQuad* render_pass_quads[] = {aggregated_pass_list[1]->quad_list[0], 481 DrawQuad* render_pass_quads[] = {aggregated_pass_list[1]->quad_list.front(),
477 aggregated_pass_list[2]->quad_list[0]}; 482 aggregated_pass_list[2]->quad_list.front()};
478 ASSERT_EQ(render_pass_quads[0]->material, DrawQuad::RENDER_PASS); 483 ASSERT_EQ(render_pass_quads[0]->material, DrawQuad::RENDER_PASS);
479 EXPECT_EQ( 484 EXPECT_EQ(
480 actual_pass_ids[0], 485 actual_pass_ids[0],
481 RenderPassDrawQuad::MaterialCast(render_pass_quads[0])->render_pass_id); 486 RenderPassDrawQuad::MaterialCast(render_pass_quads[0])->render_pass_id);
482 487
483 ASSERT_EQ(render_pass_quads[1]->material, DrawQuad::RENDER_PASS); 488 ASSERT_EQ(render_pass_quads[1]->material, DrawQuad::RENDER_PASS);
484 EXPECT_EQ( 489 EXPECT_EQ(
485 actual_pass_ids[1], 490 actual_pass_ids[1],
486 RenderPassDrawQuad::MaterialCast(render_pass_quads[1])->render_pass_id); 491 RenderPassDrawQuad::MaterialCast(render_pass_quads[1])->render_pass_id);
487 factory_.Destroy(child_surface_id); 492 factory_.Destroy(child_surface_id);
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
630 DelegatedFrameData* frame_data = aggregated_frame->delegated_frame_data.get(); 635 DelegatedFrameData* frame_data = aggregated_frame->delegated_frame_data.get();
631 636
632 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list; 637 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list;
633 638
634 ASSERT_EQ(1u, aggregated_pass_list.size()); 639 ASSERT_EQ(1u, aggregated_pass_list.size());
635 640
636 const QuadList& aggregated_quad_list = aggregated_pass_list[0]->quad_list; 641 const QuadList& aggregated_quad_list = aggregated_pass_list[0]->quad_list;
637 642
638 ASSERT_EQ(7u, aggregated_quad_list.size()); 643 ASSERT_EQ(7u, aggregated_quad_list.size());
639 644
640 for (size_t i = 0; i < aggregated_quad_list.size(); ++i) { 645 size_t i = 0;
641 DrawQuad* quad = aggregated_quad_list[i]; 646 for (QuadList::ConstIterator iter = aggregated_quad_list.begin();
642 EXPECT_EQ(blend_modes[i], quad->shared_quad_state->blend_mode) << i; 647 iter != aggregated_quad_list.end();
648 ++iter) {
649 EXPECT_EQ(blend_modes[i], iter->shared_quad_state->blend_mode) << i;
650 ++i;
643 } 651 }
644 factory_.Destroy(child_one_surface_id); 652 factory_.Destroy(child_one_surface_id);
645 factory_.Destroy(child_two_surface_id); 653 factory_.Destroy(child_two_surface_id);
646 factory_.Destroy(grandchild_surface_id); 654 factory_.Destroy(grandchild_surface_id);
647 } 655 }
648 656
649 // This tests that when aggregating a frame with multiple render passes that we 657 // This tests that when aggregating a frame with multiple render passes that we
650 // map the transforms for the root pass but do not modify the transform on child 658 // map the transforms for the root pass but do not modify the transform on child
651 // passes. 659 // passes.
652 // 660 //
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
767 gfx::Transform expected_root_pass_quad_transforms[2]; 775 gfx::Transform expected_root_pass_quad_transforms[2];
768 // The first quad in the root pass is the solid color quad from the original 776 // The first quad in the root pass is the solid color quad from the original
769 // root surface. Its transform should be unaffected by the aggregation and 777 // root surface. Its transform should be unaffected by the aggregation and
770 // still be +7 in the y direction. 778 // still be +7 in the y direction.
771 expected_root_pass_quad_transforms[0].Translate(0, 7); 779 expected_root_pass_quad_transforms[0].Translate(0, 7);
772 // The second quad in the root pass is aggregated from the child surface so 780 // The second quad in the root pass is aggregated from the child surface so
773 // its transform should be the combination of its original translation (0, 10) 781 // its transform should be the combination of its original translation (0, 10)
774 // and the child surface draw quad's translation (8, 0). 782 // and the child surface draw quad's translation (8, 0).
775 expected_root_pass_quad_transforms[1].Translate(8, 10); 783 expected_root_pass_quad_transforms[1].Translate(8, 10);
776 784
777 for (size_t i = 0; i < 2; ++i) { 785 size_t i = 0;
778 DrawQuad* quad = aggregated_pass_list[1]->quad_list.at(i); 786 for (QuadList::Iterator iter = aggregated_pass_list[1]->quad_list.begin();
787 iter != aggregated_pass_list[1]->quad_list.end();
788 ++iter) {
779 EXPECT_EQ(expected_root_pass_quad_transforms[i].ToString(), 789 EXPECT_EQ(expected_root_pass_quad_transforms[i].ToString(),
780 quad->quadTransform().ToString()) 790 iter->quadTransform().ToString())
781 << i; 791 << i;
792 i++;
782 } 793 }
783 794
784 EXPECT_EQ(true, 795 EXPECT_EQ(true,
785 aggregated_pass_list[1]->shared_quad_state_list[1]->is_clipped); 796 aggregated_pass_list[1]->shared_quad_state_list[1]->is_clipped);
786 797
787 // The second quad in the root pass is aggregated from the child, so its 798 // The second quad in the root pass is aggregated from the child, so its
788 // clip rect must be transformed by the child's translation. 799 // clip rect must be transformed by the child's translation.
789 EXPECT_EQ( 800 EXPECT_EQ(
790 gfx::Rect(0, 10, 5, 5).ToString(), 801 gfx::Rect(0, 10, 5, 5).ToString(),
791 aggregated_pass_list[1]->shared_quad_state_list[1]->clip_rect.ToString()); 802 aggregated_pass_list[1]->shared_quad_state_list[1]->clip_rect.ToString());
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
1078 returned_ids[i] = client.returned_resources()[i].id; 1089 returned_ids[i] = client.returned_resources()[i].id;
1079 } 1090 }
1080 EXPECT_THAT(returned_ids, 1091 EXPECT_THAT(returned_ids,
1081 testing::WhenSorted(testing::ElementsAreArray(ids))); 1092 testing::WhenSorted(testing::ElementsAreArray(ids)));
1082 factory.Destroy(surface_id); 1093 factory.Destroy(surface_id);
1083 } 1094 }
1084 1095
1085 } // namespace 1096 } // namespace
1086 } // namespace cc 1097 } // namespace cc
1087 1098
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698