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

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

Issue 404563005: Make RenderPass::Id an isolated class (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: one more case in mojo Created 6 years, 4 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
« no previous file with comments | « cc/surfaces/surface_aggregator_test_helpers.cc ('k') | cc/surfaces/surfaces_pixeltest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 expected_passes, arraysize(expected_passes), ids, arraysize(ids)); 194 expected_passes, arraysize(expected_passes), ids, arraysize(ids));
195 195
196 factory_.Destroy(embedded_surface_id); 196 factory_.Destroy(embedded_surface_id);
197 } 197 }
198 198
199 // This tests referencing a surface that has multiple render passes. 199 // This tests referencing a surface that has multiple render passes.
200 TEST_F(SurfaceAggregatorValidSurfaceTest, MultiPassSurfaceReference) { 200 TEST_F(SurfaceAggregatorValidSurfaceTest, MultiPassSurfaceReference) {
201 SurfaceId embedded_surface_id = allocator_.GenerateId(); 201 SurfaceId embedded_surface_id = allocator_.GenerateId();
202 factory_.Create(embedded_surface_id, SurfaceSize()); 202 factory_.Create(embedded_surface_id, SurfaceSize());
203 203
204 RenderPass::Id pass_ids[] = {RenderPass::Id(1, 1), RenderPass::Id(1, 2), 204 RenderPassId pass_ids[] = {RenderPassId(1, 1), RenderPassId(1, 2),
205 RenderPass::Id(1, 3)}; 205 RenderPassId(1, 3)};
206 206
207 test::Quad embedded_quads[][2] = { 207 test::Quad embedded_quads[][2] = {
208 {test::Quad::SolidColorQuad(1), test::Quad::SolidColorQuad(2)}, 208 {test::Quad::SolidColorQuad(1), test::Quad::SolidColorQuad(2)},
209 {test::Quad::SolidColorQuad(3), test::Quad::RenderPassQuad(pass_ids[0])}, 209 {test::Quad::SolidColorQuad(3), test::Quad::RenderPassQuad(pass_ids[0])},
210 {test::Quad::SolidColorQuad(4), test::Quad::RenderPassQuad(pass_ids[1])}}; 210 {test::Quad::SolidColorQuad(4), test::Quad::RenderPassQuad(pass_ids[1])}};
211 test::Pass embedded_passes[] = { 211 test::Pass embedded_passes[] = {
212 test::Pass(embedded_quads[0], arraysize(embedded_quads[0]), pass_ids[0]), 212 test::Pass(embedded_quads[0], arraysize(embedded_quads[0]), pass_ids[0]),
213 test::Pass(embedded_quads[1], arraysize(embedded_quads[1]), pass_ids[1]), 213 test::Pass(embedded_quads[1], arraysize(embedded_quads[1]), pass_ids[1]),
214 test::Pass(embedded_quads[2], arraysize(embedded_quads[2]), pass_ids[2])}; 214 test::Pass(embedded_quads[2], arraysize(embedded_quads[2]), pass_ids[2])};
215 215
(...skipping 16 matching lines...) Expand all
232 aggregator_.Aggregate(root_surface_id_, &surface_set); 232 aggregator_.Aggregate(root_surface_id_, &surface_set);
233 233
234 ASSERT_TRUE(aggregated_frame); 234 ASSERT_TRUE(aggregated_frame);
235 ASSERT_TRUE(aggregated_frame->delegated_frame_data); 235 ASSERT_TRUE(aggregated_frame->delegated_frame_data);
236 236
237 DelegatedFrameData* frame_data = aggregated_frame->delegated_frame_data.get(); 237 DelegatedFrameData* frame_data = aggregated_frame->delegated_frame_data.get();
238 238
239 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list; 239 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list;
240 240
241 ASSERT_EQ(5u, aggregated_pass_list.size()); 241 ASSERT_EQ(5u, aggregated_pass_list.size());
242 RenderPass::Id actual_pass_ids[] = { 242 RenderPassId actual_pass_ids[] = {
243 aggregated_pass_list[0]->id, aggregated_pass_list[1]->id, 243 aggregated_pass_list[0]->id, aggregated_pass_list[1]->id,
244 aggregated_pass_list[2]->id, aggregated_pass_list[3]->id, 244 aggregated_pass_list[2]->id, aggregated_pass_list[3]->id,
245 aggregated_pass_list[4]->id}; 245 aggregated_pass_list[4]->id};
246 for (size_t i = 0; i < 5; ++i) { 246 for (size_t i = 0; i < 5; ++i) {
247 for (size_t j = 0; j < i; ++j) { 247 for (size_t j = 0; j < i; ++j) {
248 EXPECT_NE(actual_pass_ids[i], actual_pass_ids[j]); 248 EXPECT_NE(actual_pass_ids[i], actual_pass_ids[j]);
249 } 249 }
250 } 250 }
251 251
252 { 252 {
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 expected_passes, arraysize(expected_passes), ids, arraysize(ids)); 425 expected_passes, arraysize(expected_passes), ids, arraysize(ids));
426 factory_.Destroy(child_surface_id); 426 factory_.Destroy(child_surface_id);
427 } 427 }
428 428
429 // Tests that we map render pass IDs from different surfaces into a unified 429 // Tests that we map render pass IDs from different surfaces into a unified
430 // namespace and update RenderPassDrawQuad's id references to match. 430 // namespace and update RenderPassDrawQuad's id references to match.
431 TEST_F(SurfaceAggregatorValidSurfaceTest, RenderPassIdMapping) { 431 TEST_F(SurfaceAggregatorValidSurfaceTest, RenderPassIdMapping) {
432 SurfaceId child_surface_id = allocator_.GenerateId(); 432 SurfaceId child_surface_id = allocator_.GenerateId();
433 factory_.Create(child_surface_id, SurfaceSize()); 433 factory_.Create(child_surface_id, SurfaceSize());
434 434
435 RenderPass::Id child_pass_id[] = {RenderPass::Id(1, 1), RenderPass::Id(1, 2)}; 435 RenderPassId child_pass_id[] = {RenderPassId(1, 1), RenderPassId(1, 2)};
436 test::Quad child_quad[][1] = {{test::Quad::SolidColorQuad(SK_ColorGREEN)}, 436 test::Quad child_quad[][1] = {{test::Quad::SolidColorQuad(SK_ColorGREEN)},
437 {test::Quad::RenderPassQuad(child_pass_id[0])}}; 437 {test::Quad::RenderPassQuad(child_pass_id[0])}};
438 test::Pass surface_passes[] = { 438 test::Pass surface_passes[] = {
439 test::Pass(child_quad[0], arraysize(child_quad[0]), child_pass_id[0]), 439 test::Pass(child_quad[0], arraysize(child_quad[0]), child_pass_id[0]),
440 test::Pass(child_quad[1], arraysize(child_quad[1]), child_pass_id[1])}; 440 test::Pass(child_quad[1], arraysize(child_quad[1]), child_pass_id[1])};
441 441
442 SubmitFrame(surface_passes, arraysize(surface_passes), child_surface_id); 442 SubmitFrame(surface_passes, arraysize(surface_passes), child_surface_id);
443 443
444 // Pass IDs from the parent surface may collide with ones from the child. 444 // Pass IDs from the parent surface may collide with ones from the child.
445 RenderPass::Id parent_pass_id[] = {RenderPass::Id(2, 1), 445 RenderPassId parent_pass_id[] = {RenderPassId(2, 1), RenderPassId(1, 2)};
446 RenderPass::Id(1, 2)};
447 test::Quad parent_quad[][1] = { 446 test::Quad parent_quad[][1] = {
448 {test::Quad::SurfaceQuad(child_surface_id)}, 447 {test::Quad::SurfaceQuad(child_surface_id)},
449 {test::Quad::RenderPassQuad(parent_pass_id[0])}}; 448 {test::Quad::RenderPassQuad(parent_pass_id[0])}};
450 test::Pass parent_passes[] = { 449 test::Pass parent_passes[] = {
451 test::Pass(parent_quad[0], arraysize(parent_quad[0]), parent_pass_id[0]), 450 test::Pass(parent_quad[0], arraysize(parent_quad[0]), parent_pass_id[0]),
452 test::Pass(parent_quad[1], arraysize(parent_quad[1]), parent_pass_id[1])}; 451 test::Pass(parent_quad[1], arraysize(parent_quad[1]), parent_pass_id[1])};
453 452
454 SubmitFrame(parent_passes, arraysize(parent_passes), root_surface_id_); 453 SubmitFrame(parent_passes, arraysize(parent_passes), root_surface_id_);
455 std::set<SurfaceId> surface_set; 454 std::set<SurfaceId> surface_set;
456 scoped_ptr<CompositorFrame> aggregated_frame = 455 scoped_ptr<CompositorFrame> aggregated_frame =
457 aggregator_.Aggregate(root_surface_id_, &surface_set); 456 aggregator_.Aggregate(root_surface_id_, &surface_set);
458 457
459 ASSERT_TRUE(aggregated_frame); 458 ASSERT_TRUE(aggregated_frame);
460 ASSERT_TRUE(aggregated_frame->delegated_frame_data); 459 ASSERT_TRUE(aggregated_frame->delegated_frame_data);
461 460
462 DelegatedFrameData* frame_data = aggregated_frame->delegated_frame_data.get(); 461 DelegatedFrameData* frame_data = aggregated_frame->delegated_frame_data.get();
463 462
464 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list; 463 const RenderPassList& aggregated_pass_list = frame_data->render_pass_list;
465 464
466 ASSERT_EQ(3u, aggregated_pass_list.size()); 465 ASSERT_EQ(3u, aggregated_pass_list.size());
467 RenderPass::Id actual_pass_ids[] = {aggregated_pass_list[0]->id, 466 RenderPassId actual_pass_ids[] = {aggregated_pass_list[0]->id,
468 aggregated_pass_list[1]->id, 467 aggregated_pass_list[1]->id,
469 aggregated_pass_list[2]->id}; 468 aggregated_pass_list[2]->id};
470 // Make sure the aggregated frame's pass IDs are all unique. 469 // Make sure the aggregated frame's pass IDs are all unique.
471 for (size_t i = 0; i < 3; ++i) { 470 for (size_t i = 0; i < 3; ++i) {
472 for (size_t j = 0; j < i; ++j) { 471 for (size_t j = 0; j < i; ++j) {
473 EXPECT_NE(actual_pass_ids[j], actual_pass_ids[i]) << "pass ids " << i 472 EXPECT_NE(actual_pass_ids[j], actual_pass_ids[i]) << "pass ids " << i
474 << " and " << j; 473 << " and " << j;
475 } 474 }
476 } 475 }
477 476
478 // Make sure the render pass quads reference the remapped pass IDs. 477 // Make sure the render pass quads reference the remapped pass IDs.
479 DrawQuad* render_pass_quads[] = {aggregated_pass_list[1]->quad_list[0], 478 DrawQuad* render_pass_quads[] = {aggregated_pass_list[1]->quad_list[0],
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
551 TEST_F(SurfaceAggregatorValidSurfaceTest, AggregateSharedQuadStateProperties) { 550 TEST_F(SurfaceAggregatorValidSurfaceTest, AggregateSharedQuadStateProperties) {
552 const SkXfermode::Mode blend_modes[] = {SkXfermode::kClear_Mode, // 0 551 const SkXfermode::Mode blend_modes[] = {SkXfermode::kClear_Mode, // 0
553 SkXfermode::kSrc_Mode, // 1 552 SkXfermode::kSrc_Mode, // 1
554 SkXfermode::kDst_Mode, // 2 553 SkXfermode::kDst_Mode, // 2
555 SkXfermode::kSrcOver_Mode, // 3 554 SkXfermode::kSrcOver_Mode, // 3
556 SkXfermode::kDstOver_Mode, // 4 555 SkXfermode::kDstOver_Mode, // 4
557 SkXfermode::kSrcIn_Mode, // 5 556 SkXfermode::kSrcIn_Mode, // 5
558 SkXfermode::kDstIn_Mode, // 6 557 SkXfermode::kDstIn_Mode, // 6
559 }; 558 };
560 559
561 RenderPass::Id pass_id(1, 1); 560 RenderPassId pass_id(1, 1);
562 SurfaceId grandchild_surface_id = allocator_.GenerateId(); 561 SurfaceId grandchild_surface_id = allocator_.GenerateId();
563 factory_.Create(grandchild_surface_id, SurfaceSize()); 562 factory_.Create(grandchild_surface_id, SurfaceSize());
564 scoped_ptr<RenderPass> grandchild_pass = RenderPass::Create(); 563 scoped_ptr<RenderPass> grandchild_pass = RenderPass::Create();
565 gfx::Rect output_rect(SurfaceSize()); 564 gfx::Rect output_rect(SurfaceSize());
566 gfx::Rect damage_rect(SurfaceSize()); 565 gfx::Rect damage_rect(SurfaceSize());
567 gfx::Transform transform_to_root_target; 566 gfx::Transform transform_to_root_target;
568 grandchild_pass->SetNew( 567 grandchild_pass->SetNew(
569 pass_id, output_rect, damage_rect, transform_to_root_target); 568 pass_id, output_rect, damage_rect, transform_to_root_target);
570 AddSolidColorQuadWithBlendMode( 569 AddSolidColorQuadWithBlendMode(
571 SurfaceSize(), grandchild_pass.get(), blend_modes[2]); 570 SurfaceSize(), grandchild_pass.get(), blend_modes[2]);
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
661 // of +5 in the x direction. The second pass has a reference to the first pass' 660 // of +5 in the x direction. The second pass has a reference to the first pass'
662 // pass id and a transform of +8 in the x direction. 661 // pass id and a transform of +8 in the x direction.
663 // 662 //
664 // After aggregation, the child surface's root pass quad should have both 663 // After aggregation, the child surface's root pass quad should have both
665 // transforms concatenated for a total transform of +8 x, +10 y. The 664 // transforms concatenated for a total transform of +8 x, +10 y. The
666 // contributing render pass' transform in the aggregate frame should not be 665 // contributing render pass' transform in the aggregate frame should not be
667 // affected. 666 // affected.
668 TEST_F(SurfaceAggregatorValidSurfaceTest, AggregateMultiplePassWithTransform) { 667 TEST_F(SurfaceAggregatorValidSurfaceTest, AggregateMultiplePassWithTransform) {
669 SurfaceId child_surface_id = allocator_.GenerateId(); 668 SurfaceId child_surface_id = allocator_.GenerateId();
670 factory_.Create(child_surface_id, SurfaceSize()); 669 factory_.Create(child_surface_id, SurfaceSize());
671 RenderPass::Id child_pass_id[] = {RenderPass::Id(1, 1), RenderPass::Id(1, 2)}; 670 RenderPassId child_pass_id[] = {RenderPassId(1, 1), RenderPassId(1, 2)};
672 test::Quad child_quads[][1] = { 671 test::Quad child_quads[][1] = {
673 {test::Quad::SolidColorQuad(SK_ColorGREEN)}, 672 {test::Quad::SolidColorQuad(SK_ColorGREEN)},
674 {test::Quad::RenderPassQuad(child_pass_id[0])}}; 673 {test::Quad::RenderPassQuad(child_pass_id[0])}};
675 test::Pass child_passes[] = { 674 test::Pass child_passes[] = {
676 test::Pass(child_quads[0], arraysize(child_quads[0]), child_pass_id[0]), 675 test::Pass(child_quads[0], arraysize(child_quads[0]), child_pass_id[0]),
677 test::Pass(child_quads[1], arraysize(child_quads[1]), child_pass_id[1])}; 676 test::Pass(child_quads[1], arraysize(child_quads[1]), child_pass_id[1])};
678 677
679 RenderPassList child_pass_list; 678 RenderPassList child_pass_list;
680 AddPasses(&child_pass_list, 679 AddPasses(&child_pass_list,
681 gfx::Rect(SurfaceSize()), 680 gfx::Rect(SurfaceSize()),
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
845 844
846 DISALLOW_COPY_AND_ASSIGN(ResourceTrackingSurfaceFactoryClient); 845 DISALLOW_COPY_AND_ASSIGN(ResourceTrackingSurfaceFactoryClient);
847 }; 846 };
848 847
849 void SubmitFrameWithResources(ResourceProvider::ResourceId* resource_ids, 848 void SubmitFrameWithResources(ResourceProvider::ResourceId* resource_ids,
850 size_t num_resource_ids, 849 size_t num_resource_ids,
851 SurfaceFactory* factory, 850 SurfaceFactory* factory,
852 SurfaceId surface_id) { 851 SurfaceId surface_id) {
853 scoped_ptr<DelegatedFrameData> frame_data(new DelegatedFrameData); 852 scoped_ptr<DelegatedFrameData> frame_data(new DelegatedFrameData);
854 scoped_ptr<RenderPass> pass = RenderPass::Create(); 853 scoped_ptr<RenderPass> pass = RenderPass::Create();
855 pass->id = RenderPass::Id(1, 1); 854 pass->id = RenderPassId(1, 1);
856 SharedQuadState* sqs = pass->CreateAndAppendSharedQuadState(); 855 SharedQuadState* sqs = pass->CreateAndAppendSharedQuadState();
857 for (size_t i = 0u; i < num_resource_ids; ++i) { 856 for (size_t i = 0u; i < num_resource_ids; ++i) {
858 TransferableResource resource; 857 TransferableResource resource;
859 resource.id = resource_ids[i]; 858 resource.id = resource_ids[i];
860 resource.is_software = true; 859 resource.is_software = true;
861 frame_data->resource_list.push_back(resource); 860 frame_data->resource_list.push_back(resource);
862 TextureDrawQuad* quad = pass->CreateAndAppendDrawQuad<TextureDrawQuad>(); 861 TextureDrawQuad* quad = pass->CreateAndAppendDrawQuad<TextureDrawQuad>();
863 const gfx::Rect rect; 862 const gfx::Rect rect;
864 const gfx::Rect opaque_rect; 863 const gfx::Rect opaque_rect;
865 const gfx::Rect visible_rect; 864 const gfx::Rect visible_rect;
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
918 returned_ids[i] = client.returned_resources()[i].id; 917 returned_ids[i] = client.returned_resources()[i].id;
919 } 918 }
920 EXPECT_THAT(returned_ids, 919 EXPECT_THAT(returned_ids,
921 testing::WhenSorted(testing::ElementsAreArray(ids))); 920 testing::WhenSorted(testing::ElementsAreArray(ids)));
922 factory.Destroy(surface_id); 921 factory.Destroy(surface_id);
923 } 922 }
924 923
925 } // namespace 924 } // namespace
926 } // namespace cc 925 } // namespace cc
927 926
OLDNEW
« no previous file with comments | « cc/surfaces/surface_aggregator_test_helpers.cc ('k') | cc/surfaces/surfaces_pixeltest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698