| 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/surfaces/surface_aggregator.h" | 5 #include "cc/surfaces/surface_aggregator.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 &manager_, | 66 &manager_, |
| 67 kArbitraryRootFrameSinkId, | 67 kArbitraryRootFrameSinkId, |
| 68 kRootIsRoot, | 68 kRootIsRoot, |
| 69 kHandlesFrameSinkIdInvalidation, | 69 kHandlesFrameSinkIdInvalidation, |
| 70 kNeedsSyncPoints)), | 70 kNeedsSyncPoints)), |
| 71 aggregator_(&manager_, NULL, use_damage_rect) {} | 71 aggregator_(&manager_, NULL, use_damage_rect) {} |
| 72 | 72 |
| 73 SurfaceAggregatorTest() : SurfaceAggregatorTest(false) {} | 73 SurfaceAggregatorTest() : SurfaceAggregatorTest(false) {} |
| 74 | 74 |
| 75 void TearDown() override { | 75 void TearDown() override { |
| 76 support_->EvictFrame(); | 76 support_->EvictCurrentSurface(); |
| 77 testing::Test::TearDown(); | 77 testing::Test::TearDown(); |
| 78 } | 78 } |
| 79 | 79 |
| 80 protected: | 80 protected: |
| 81 SurfaceManager manager_; | 81 SurfaceManager manager_; |
| 82 FakeCompositorFrameSinkSupportClient fake_client_; | 82 FakeCompositorFrameSinkSupportClient fake_client_; |
| 83 std::unique_ptr<CompositorFrameSinkSupport> support_; | 83 std::unique_ptr<CompositorFrameSinkSupport> support_; |
| 84 SurfaceAggregator aggregator_; | 84 SurfaceAggregator aggregator_; |
| 85 }; | 85 }; |
| 86 | 86 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 99 : SurfaceAggregatorValidSurfaceTest(false) {} | 99 : SurfaceAggregatorValidSurfaceTest(false) {} |
| 100 | 100 |
| 101 void SetUp() override { | 101 void SetUp() override { |
| 102 SurfaceAggregatorTest::SetUp(); | 102 SurfaceAggregatorTest::SetUp(); |
| 103 root_local_surface_id_ = allocator_.GenerateId(); | 103 root_local_surface_id_ = allocator_.GenerateId(); |
| 104 root_surface_ = manager_.GetSurfaceForId( | 104 root_surface_ = manager_.GetSurfaceForId( |
| 105 SurfaceId(support_->frame_sink_id(), root_local_surface_id_)); | 105 SurfaceId(support_->frame_sink_id(), root_local_surface_id_)); |
| 106 } | 106 } |
| 107 | 107 |
| 108 void TearDown() override { | 108 void TearDown() override { |
| 109 child_support_->EvictFrame(); | 109 child_support_->EvictCurrentSurface(); |
| 110 SurfaceAggregatorTest::TearDown(); | 110 SurfaceAggregatorTest::TearDown(); |
| 111 } | 111 } |
| 112 | 112 |
| 113 void AggregateAndVerify(test::Pass* expected_passes, | 113 void AggregateAndVerify(test::Pass* expected_passes, |
| 114 size_t expected_pass_count, | 114 size_t expected_pass_count, |
| 115 SurfaceId* surface_ids, | 115 SurfaceId* surface_ids, |
| 116 size_t expected_surface_count) { | 116 size_t expected_surface_count) { |
| 117 CompositorFrame aggregated_frame = aggregator_.Aggregate( | 117 CompositorFrame aggregated_frame = aggregator_.Aggregate( |
| 118 SurfaceId(support_->frame_sink_id(), root_local_surface_id_)); | 118 SurfaceId(support_->frame_sink_id(), root_local_surface_id_)); |
| 119 | 119 |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 render_pass_list[0]->shared_quad_state_list); | 223 render_pass_list[0]->shared_quad_state_list); |
| 224 ASSERT_EQ(2u, shared_quad_state_list.size()); | 224 ASSERT_EQ(2u, shared_quad_state_list.size()); |
| 225 EXPECT_EQ(1.f, shared_quad_state_list.ElementAt(0)->opacity); | 225 EXPECT_EQ(1.f, shared_quad_state_list.ElementAt(0)->opacity); |
| 226 EXPECT_EQ(1.f, shared_quad_state_list.ElementAt(1)->opacity); | 226 EXPECT_EQ(1.f, shared_quad_state_list.ElementAt(1)->opacity); |
| 227 | 227 |
| 228 SharedQuadStateList& shared_quad_state_list2( | 228 SharedQuadStateList& shared_quad_state_list2( |
| 229 render_pass_list[1]->shared_quad_state_list); | 229 render_pass_list[1]->shared_quad_state_list); |
| 230 ASSERT_EQ(1u, shared_quad_state_list2.size()); | 230 ASSERT_EQ(1u, shared_quad_state_list2.size()); |
| 231 EXPECT_EQ(.5f, shared_quad_state_list2.ElementAt(0)->opacity); | 231 EXPECT_EQ(.5f, shared_quad_state_list2.ElementAt(0)->opacity); |
| 232 | 232 |
| 233 embedded_support->EvictFrame(); | 233 embedded_support->EvictCurrentSurface(); |
| 234 } | 234 } |
| 235 | 235 |
| 236 TEST_F(SurfaceAggregatorValidSurfaceTest, MultiPassSimpleFrame) { | 236 TEST_F(SurfaceAggregatorValidSurfaceTest, MultiPassSimpleFrame) { |
| 237 test::Quad quads[][2] = {{test::Quad::SolidColorQuad(SK_ColorWHITE), | 237 test::Quad quads[][2] = {{test::Quad::SolidColorQuad(SK_ColorWHITE), |
| 238 test::Quad::SolidColorQuad(SK_ColorLTGRAY)}, | 238 test::Quad::SolidColorQuad(SK_ColorLTGRAY)}, |
| 239 {test::Quad::SolidColorQuad(SK_ColorGRAY), | 239 {test::Quad::SolidColorQuad(SK_ColorGRAY), |
| 240 test::Quad::SolidColorQuad(SK_ColorDKGRAY)}}; | 240 test::Quad::SolidColorQuad(SK_ColorDKGRAY)}}; |
| 241 test::Pass passes[] = {test::Pass(quads[0], arraysize(quads[0]), 1), | 241 test::Pass passes[] = {test::Pass(quads[0], arraysize(quads[0]), 1), |
| 242 test::Pass(quads[1], arraysize(quads[1]), 2)}; | 242 test::Pass(quads[1], arraysize(quads[1]), 2)}; |
| 243 | 243 |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 333 test::Quad expected_quads[] = {test::Quad::SolidColorQuad(SK_ColorWHITE), | 333 test::Quad expected_quads[] = {test::Quad::SolidColorQuad(SK_ColorWHITE), |
| 334 test::Quad::SolidColorQuad(SK_ColorGREEN), | 334 test::Quad::SolidColorQuad(SK_ColorGREEN), |
| 335 test::Quad::SolidColorQuad(SK_ColorBLACK)}; | 335 test::Quad::SolidColorQuad(SK_ColorBLACK)}; |
| 336 test::Pass expected_passes[] = { | 336 test::Pass expected_passes[] = { |
| 337 test::Pass(expected_quads, arraysize(expected_quads))}; | 337 test::Pass(expected_quads, arraysize(expected_quads))}; |
| 338 SurfaceId root_surface_id(support_->frame_sink_id(), root_local_surface_id_); | 338 SurfaceId root_surface_id(support_->frame_sink_id(), root_local_surface_id_); |
| 339 SurfaceId ids[] = {root_surface_id, embedded_surface_id}; | 339 SurfaceId ids[] = {root_surface_id, embedded_surface_id}; |
| 340 AggregateAndVerify( | 340 AggregateAndVerify( |
| 341 expected_passes, arraysize(expected_passes), ids, arraysize(ids)); | 341 expected_passes, arraysize(expected_passes), ids, arraysize(ids)); |
| 342 | 342 |
| 343 embedded_support->EvictFrame(); | 343 embedded_support->EvictCurrentSurface(); |
| 344 } | 344 } |
| 345 | 345 |
| 346 // This test verifies that in the absence of a primary Surface, | 346 // This test verifies that in the absence of a primary Surface, |
| 347 // SurfaceAggregator will embed a fallback Surface, if available. If the primary | 347 // SurfaceAggregator will embed a fallback Surface, if available. If the primary |
| 348 // Surface is available, though, the fallback will not be used. | 348 // Surface is available, though, the fallback will not be used. |
| 349 TEST_F(SurfaceAggregatorValidSurfaceTest, FallbackSurfaceReference) { | 349 TEST_F(SurfaceAggregatorValidSurfaceTest, FallbackSurfaceReference) { |
| 350 std::unique_ptr<CompositorFrameSinkSupport> primary_child_support = | 350 std::unique_ptr<CompositorFrameSinkSupport> primary_child_support = |
| 351 CompositorFrameSinkSupport::Create( | 351 CompositorFrameSinkSupport::Create( |
| 352 nullptr, &manager_, kArbitraryFrameSinkId1, kChildIsRoot, | 352 nullptr, &manager_, kArbitraryFrameSinkId1, kChildIsRoot, |
| 353 kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints); | 353 kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 408 | 408 |
| 409 // Now that the primary Surface has a CompositorFrame, we expect | 409 // Now that the primary Surface has a CompositorFrame, we expect |
| 410 // SurfaceAggregator to embed the primary Surface, and drop the fallback | 410 // SurfaceAggregator to embed the primary Surface, and drop the fallback |
| 411 // Surface. | 411 // Surface. |
| 412 test::Quad expected_quads2[] = {test::Quad::SolidColorQuad(SK_ColorGREEN)}; | 412 test::Quad expected_quads2[] = {test::Quad::SolidColorQuad(SK_ColorGREEN)}; |
| 413 test::Pass expected_passes2[] = { | 413 test::Pass expected_passes2[] = { |
| 414 test::Pass(expected_quads2, arraysize(expected_quads2))}; | 414 test::Pass(expected_quads2, arraysize(expected_quads2))}; |
| 415 AggregateAndVerify(expected_passes2, arraysize(expected_passes2), ids, | 415 AggregateAndVerify(expected_passes2, arraysize(expected_passes2), ids, |
| 416 arraysize(ids)); | 416 arraysize(ids)); |
| 417 | 417 |
| 418 primary_child_support->EvictFrame(); | 418 primary_child_support->EvictCurrentSurface(); |
| 419 fallback_child_support->EvictFrame(); | 419 fallback_child_support->EvictCurrentSurface(); |
| 420 } | 420 } |
| 421 | 421 |
| 422 // This test verifies that in the presence of both primary Surface and fallback | 422 // This test verifies that in the presence of both primary Surface and fallback |
| 423 // Surface, the fallback will not be used. | 423 // Surface, the fallback will not be used. |
| 424 TEST_F(SurfaceAggregatorValidSurfaceTest, FallbackSurfaceReferenceWithPrimary) { | 424 TEST_F(SurfaceAggregatorValidSurfaceTest, FallbackSurfaceReferenceWithPrimary) { |
| 425 std::unique_ptr<CompositorFrameSinkSupport> primary_child_support = | 425 std::unique_ptr<CompositorFrameSinkSupport> primary_child_support = |
| 426 CompositorFrameSinkSupport::Create( | 426 CompositorFrameSinkSupport::Create( |
| 427 nullptr, &manager_, kArbitraryFrameSinkId1, kChildIsRoot, | 427 nullptr, &manager_, kArbitraryFrameSinkId1, kChildIsRoot, |
| 428 kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints); | 428 kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints); |
| 429 LocalSurfaceId primary_child_local_surface_id = allocator_.GenerateId(); | 429 LocalSurfaceId primary_child_local_surface_id = allocator_.GenerateId(); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 473 test::Quad expected_quads1[] = {test::Quad::SolidColorQuad(SK_ColorGREEN)}; | 473 test::Quad expected_quads1[] = {test::Quad::SolidColorQuad(SK_ColorGREEN)}; |
| 474 test::Pass expected_passes1[] = { | 474 test::Pass expected_passes1[] = { |
| 475 test::Pass(expected_quads1, arraysize(expected_quads1))}; | 475 test::Pass(expected_quads1, arraysize(expected_quads1))}; |
| 476 | 476 |
| 477 SurfaceId root_surface_id(support_->frame_sink_id(), root_local_surface_id_); | 477 SurfaceId root_surface_id(support_->frame_sink_id(), root_local_surface_id_); |
| 478 SurfaceId ids[] = {root_surface_id, primary_child_surface_id, | 478 SurfaceId ids[] = {root_surface_id, primary_child_surface_id, |
| 479 fallback_child_surface_id}; | 479 fallback_child_surface_id}; |
| 480 AggregateAndVerify(expected_passes1, arraysize(expected_passes1), ids, | 480 AggregateAndVerify(expected_passes1, arraysize(expected_passes1), ids, |
| 481 arraysize(ids)); | 481 arraysize(ids)); |
| 482 | 482 |
| 483 primary_child_support->EvictFrame(); | 483 primary_child_support->EvictCurrentSurface(); |
| 484 fallback_child_support->EvictFrame(); | 484 fallback_child_support->EvictCurrentSurface(); |
| 485 } | 485 } |
| 486 | 486 |
| 487 TEST_F(SurfaceAggregatorValidSurfaceTest, CopyRequest) { | 487 TEST_F(SurfaceAggregatorValidSurfaceTest, CopyRequest) { |
| 488 std::unique_ptr<CompositorFrameSinkSupport> embedded_support = | 488 std::unique_ptr<CompositorFrameSinkSupport> embedded_support = |
| 489 CompositorFrameSinkSupport::Create( | 489 CompositorFrameSinkSupport::Create( |
| 490 nullptr, &manager_, kArbitraryFrameSinkId1, kChildIsRoot, | 490 nullptr, &manager_, kArbitraryFrameSinkId1, kChildIsRoot, |
| 491 kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints); | 491 kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints); |
| 492 LocalSurfaceId embedded_local_surface_id = allocator_.GenerateId(); | 492 LocalSurfaceId embedded_local_surface_id = allocator_.GenerateId(); |
| 493 SurfaceId embedded_surface_id(embedded_support->frame_sink_id(), | 493 SurfaceId embedded_surface_id(embedded_support->frame_sink_id(), |
| 494 embedded_local_surface_id); | 494 embedded_local_surface_id); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 532 | 532 |
| 533 SurfaceId surface_ids[] = {root_surface_id, embedded_surface_id}; | 533 SurfaceId surface_ids[] = {root_surface_id, embedded_surface_id}; |
| 534 EXPECT_EQ(arraysize(surface_ids), | 534 EXPECT_EQ(arraysize(surface_ids), |
| 535 aggregator_.previous_contained_surfaces().size()); | 535 aggregator_.previous_contained_surfaces().size()); |
| 536 for (size_t i = 0; i < arraysize(surface_ids); i++) { | 536 for (size_t i = 0; i < arraysize(surface_ids); i++) { |
| 537 EXPECT_TRUE( | 537 EXPECT_TRUE( |
| 538 aggregator_.previous_contained_surfaces().find(surface_ids[i]) != | 538 aggregator_.previous_contained_surfaces().find(surface_ids[i]) != |
| 539 aggregator_.previous_contained_surfaces().end()); | 539 aggregator_.previous_contained_surfaces().end()); |
| 540 } | 540 } |
| 541 | 541 |
| 542 embedded_support->EvictFrame(); | 542 embedded_support->EvictCurrentSurface(); |
| 543 } | 543 } |
| 544 | 544 |
| 545 // Root surface may contain copy requests. | 545 // Root surface may contain copy requests. |
| 546 TEST_F(SurfaceAggregatorValidSurfaceTest, RootCopyRequest) { | 546 TEST_F(SurfaceAggregatorValidSurfaceTest, RootCopyRequest) { |
| 547 std::unique_ptr<CompositorFrameSinkSupport> embedded_support = | 547 std::unique_ptr<CompositorFrameSinkSupport> embedded_support = |
| 548 CompositorFrameSinkSupport::Create( | 548 CompositorFrameSinkSupport::Create( |
| 549 nullptr, &manager_, kArbitraryFrameSinkId2, kChildIsRoot, | 549 nullptr, &manager_, kArbitraryFrameSinkId2, kChildIsRoot, |
| 550 kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints); | 550 kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints); |
| 551 LocalSurfaceId embedded_local_surface_id = allocator_.GenerateId(); | 551 LocalSurfaceId embedded_local_surface_id = allocator_.GenerateId(); |
| 552 SurfaceId embedded_surface_id(embedded_support->frame_sink_id(), | 552 SurfaceId embedded_surface_id(embedded_support->frame_sink_id(), |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 613 } | 613 } |
| 614 | 614 |
| 615 // Ensure copy requests have been removed from root surface. | 615 // Ensure copy requests have been removed from root surface. |
| 616 const CompositorFrame& original_frame = | 616 const CompositorFrame& original_frame = |
| 617 manager_.GetSurfaceForId(root_surface_id)->GetActiveFrame(); | 617 manager_.GetSurfaceForId(root_surface_id)->GetActiveFrame(); |
| 618 const RenderPassList& original_pass_list = original_frame.render_pass_list; | 618 const RenderPassList& original_pass_list = original_frame.render_pass_list; |
| 619 ASSERT_EQ(2u, original_pass_list.size()); | 619 ASSERT_EQ(2u, original_pass_list.size()); |
| 620 DCHECK(original_pass_list[0]->copy_requests.empty()); | 620 DCHECK(original_pass_list[0]->copy_requests.empty()); |
| 621 DCHECK(original_pass_list[1]->copy_requests.empty()); | 621 DCHECK(original_pass_list[1]->copy_requests.empty()); |
| 622 | 622 |
| 623 embedded_support->EvictFrame(); | 623 embedded_support->EvictCurrentSurface(); |
| 624 } | 624 } |
| 625 | 625 |
| 626 TEST_F(SurfaceAggregatorValidSurfaceTest, UnreferencedSurface) { | 626 TEST_F(SurfaceAggregatorValidSurfaceTest, UnreferencedSurface) { |
| 627 std::unique_ptr<CompositorFrameSinkSupport> embedded_support = | 627 std::unique_ptr<CompositorFrameSinkSupport> embedded_support = |
| 628 CompositorFrameSinkSupport::Create( | 628 CompositorFrameSinkSupport::Create( |
| 629 nullptr, &manager_, kArbitraryFrameSinkId1, kChildIsRoot, | 629 nullptr, &manager_, kArbitraryFrameSinkId1, kChildIsRoot, |
| 630 kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints); | 630 kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints); |
| 631 std::unique_ptr<CompositorFrameSinkSupport> parent_support = | 631 std::unique_ptr<CompositorFrameSinkSupport> parent_support = |
| 632 CompositorFrameSinkSupport::Create( | 632 CompositorFrameSinkSupport::Create( |
| 633 nullptr, &manager_, kArbitraryFrameSinkId2, kRootIsRoot, | 633 nullptr, &manager_, kArbitraryFrameSinkId2, kRootIsRoot, |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 710 SurfaceId(support_->frame_sink_id(), root_local_surface_id_), | 710 SurfaceId(support_->frame_sink_id(), root_local_surface_id_), |
| 711 parent_surface_id, embedded_surface_id, nonexistent_surface_id}; | 711 parent_surface_id, embedded_surface_id, nonexistent_surface_id}; |
| 712 EXPECT_EQ(arraysize(surface_ids), | 712 EXPECT_EQ(arraysize(surface_ids), |
| 713 aggregator_.previous_contained_surfaces().size()); | 713 aggregator_.previous_contained_surfaces().size()); |
| 714 for (size_t i = 0; i < arraysize(surface_ids); i++) { | 714 for (size_t i = 0; i < arraysize(surface_ids); i++) { |
| 715 EXPECT_TRUE( | 715 EXPECT_TRUE( |
| 716 aggregator_.previous_contained_surfaces().find(surface_ids[i]) != | 716 aggregator_.previous_contained_surfaces().find(surface_ids[i]) != |
| 717 aggregator_.previous_contained_surfaces().end()); | 717 aggregator_.previous_contained_surfaces().end()); |
| 718 } | 718 } |
| 719 | 719 |
| 720 embedded_support->EvictFrame(); | 720 embedded_support->EvictCurrentSurface(); |
| 721 parent_support->EvictFrame(); | 721 parent_support->EvictCurrentSurface(); |
| 722 } | 722 } |
| 723 | 723 |
| 724 // This tests referencing a surface that has multiple render passes. | 724 // This tests referencing a surface that has multiple render passes. |
| 725 TEST_F(SurfaceAggregatorValidSurfaceTest, MultiPassSurfaceReference) { | 725 TEST_F(SurfaceAggregatorValidSurfaceTest, MultiPassSurfaceReference) { |
| 726 LocalSurfaceId embedded_local_surface_id = child_allocator_.GenerateId(); | 726 LocalSurfaceId embedded_local_surface_id = child_allocator_.GenerateId(); |
| 727 SurfaceId embedded_surface_id(child_support_->frame_sink_id(), | 727 SurfaceId embedded_surface_id(child_support_->frame_sink_id(), |
| 728 embedded_local_surface_id); | 728 embedded_local_surface_id); |
| 729 | 729 |
| 730 int pass_ids[] = {1, 2, 3}; | 730 int pass_ids[] = {1, 2, 3}; |
| 731 | 731 |
| (...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1194 | 1194 |
| 1195 ASSERT_EQ(7u, aggregated_quad_list.size()); | 1195 ASSERT_EQ(7u, aggregated_quad_list.size()); |
| 1196 | 1196 |
| 1197 for (auto iter = aggregated_quad_list.cbegin(); | 1197 for (auto iter = aggregated_quad_list.cbegin(); |
| 1198 iter != aggregated_quad_list.cend(); | 1198 iter != aggregated_quad_list.cend(); |
| 1199 ++iter) { | 1199 ++iter) { |
| 1200 EXPECT_EQ(blend_modes[iter.index()], iter->shared_quad_state->blend_mode) | 1200 EXPECT_EQ(blend_modes[iter.index()], iter->shared_quad_state->blend_mode) |
| 1201 << iter.index(); | 1201 << iter.index(); |
| 1202 } | 1202 } |
| 1203 | 1203 |
| 1204 grandchild_support->EvictFrame(); | 1204 grandchild_support->EvictCurrentSurface(); |
| 1205 child_one_support->EvictFrame(); | 1205 child_one_support->EvictCurrentSurface(); |
| 1206 child_two_support->EvictFrame(); | 1206 child_two_support->EvictCurrentSurface(); |
| 1207 } | 1207 } |
| 1208 | 1208 |
| 1209 // This tests that when aggregating a frame with multiple render passes that we | 1209 // This tests that when aggregating a frame with multiple render passes that we |
| 1210 // map the transforms for the root pass but do not modify the transform on child | 1210 // map the transforms for the root pass but do not modify the transform on child |
| 1211 // passes. | 1211 // passes. |
| 1212 // | 1212 // |
| 1213 // The root surface has one pass with a surface quad transformed by +10 in the y | 1213 // The root surface has one pass with a surface quad transformed by +10 in the y |
| 1214 // direction. | 1214 // direction. |
| 1215 // | 1215 // |
| 1216 // The middle surface has one pass with a surface quad scaled by 2 in the x | 1216 // The middle surface has one pass with a surface quad scaled by 2 in the x |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1384 aggregated_pass_list[1]->shared_quad_state_list.ElementAt(1)->is_clipped); | 1384 aggregated_pass_list[1]->shared_quad_state_list.ElementAt(1)->is_clipped); |
| 1385 | 1385 |
| 1386 // The second quad in the root pass is aggregated from the child, so its | 1386 // The second quad in the root pass is aggregated from the child, so its |
| 1387 // clip rect must be transformed by the child's translation/scale and | 1387 // clip rect must be transformed by the child's translation/scale and |
| 1388 // clipped be the visible_rects for both children. | 1388 // clipped be the visible_rects for both children. |
| 1389 EXPECT_EQ(gfx::Rect(0, 13, 8, 12).ToString(), | 1389 EXPECT_EQ(gfx::Rect(0, 13, 8, 12).ToString(), |
| 1390 aggregated_pass_list[1] | 1390 aggregated_pass_list[1] |
| 1391 ->shared_quad_state_list.ElementAt(1) | 1391 ->shared_quad_state_list.ElementAt(1) |
| 1392 ->clip_rect.ToString()); | 1392 ->clip_rect.ToString()); |
| 1393 | 1393 |
| 1394 middle_support->EvictFrame(); | 1394 middle_support->EvictCurrentSurface(); |
| 1395 } | 1395 } |
| 1396 | 1396 |
| 1397 // Tests that damage rects are aggregated correctly when surfaces change. | 1397 // Tests that damage rects are aggregated correctly when surfaces change. |
| 1398 TEST_F(SurfaceAggregatorValidSurfaceTest, AggregateDamageRect) { | 1398 TEST_F(SurfaceAggregatorValidSurfaceTest, AggregateDamageRect) { |
| 1399 std::unique_ptr<CompositorFrameSinkSupport> parent_support = | 1399 std::unique_ptr<CompositorFrameSinkSupport> parent_support = |
| 1400 CompositorFrameSinkSupport::Create( | 1400 CompositorFrameSinkSupport::Create( |
| 1401 nullptr, &manager_, kArbitraryMiddleFrameSinkId, kChildIsRoot, | 1401 nullptr, &manager_, kArbitraryMiddleFrameSinkId, kChildIsRoot, |
| 1402 kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints); | 1402 kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints); |
| 1403 test::Quad child_quads[] = {test::Quad::RenderPassQuad(1)}; | 1403 test::Quad child_quads[] = {test::Quad::RenderPassQuad(1)}; |
| 1404 test::Pass child_passes[] = { | 1404 test::Pass child_passes[] = { |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1562 | 1562 |
| 1563 const RenderPassList& aggregated_pass_list = | 1563 const RenderPassList& aggregated_pass_list = |
| 1564 aggregated_frame.render_pass_list; | 1564 aggregated_frame.render_pass_list; |
| 1565 | 1565 |
| 1566 ASSERT_EQ(2u, aggregated_pass_list.size()); | 1566 ASSERT_EQ(2u, aggregated_pass_list.size()); |
| 1567 | 1567 |
| 1568 EXPECT_TRUE(aggregated_pass_list[1]->damage_rect.Contains( | 1568 EXPECT_TRUE(aggregated_pass_list[1]->damage_rect.Contains( |
| 1569 gfx::Rect(SurfaceSize()))); | 1569 gfx::Rect(SurfaceSize()))); |
| 1570 } | 1570 } |
| 1571 | 1571 |
| 1572 parent_support->EvictFrame(); | 1572 parent_support->EvictCurrentSurface(); |
| 1573 } | 1573 } |
| 1574 | 1574 |
| 1575 // Check that damage is correctly calculated for surfaces. | 1575 // Check that damage is correctly calculated for surfaces. |
| 1576 TEST_F(SurfaceAggregatorValidSurfaceTest, SwitchSurfaceDamage) { | 1576 TEST_F(SurfaceAggregatorValidSurfaceTest, SwitchSurfaceDamage) { |
| 1577 test::Quad root_render_pass_quads[] = {test::Quad::SolidColorQuad(1)}; | 1577 test::Quad root_render_pass_quads[] = {test::Quad::SolidColorQuad(1)}; |
| 1578 | 1578 |
| 1579 test::Pass root_passes[] = { | 1579 test::Pass root_passes[] = { |
| 1580 test::Pass(root_render_pass_quads, arraysize(root_render_pass_quads), 2)}; | 1580 test::Pass(root_render_pass_quads, arraysize(root_render_pass_quads), 2)}; |
| 1581 | 1581 |
| 1582 CompositorFrame root_frame = test::MakeEmptyCompositorFrame(); | 1582 CompositorFrame root_frame = test::MakeEmptyCompositorFrame(); |
| (...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2022 frame = aggregator_->Aggregate(surface_id); | 2022 frame = aggregator_->Aggregate(surface_id); |
| 2023 | 2023 |
| 2024 ASSERT_EQ(3u, client.returned_resources().size()); | 2024 ASSERT_EQ(3u, client.returned_resources().size()); |
| 2025 ResourceId returned_ids[3]; | 2025 ResourceId returned_ids[3]; |
| 2026 for (size_t i = 0; i < 3; ++i) { | 2026 for (size_t i = 0; i < 3; ++i) { |
| 2027 returned_ids[i] = client.returned_resources()[i].id; | 2027 returned_ids[i] = client.returned_resources()[i].id; |
| 2028 } | 2028 } |
| 2029 EXPECT_THAT(returned_ids, | 2029 EXPECT_THAT(returned_ids, |
| 2030 testing::WhenSorted(testing::ElementsAreArray(ids))); | 2030 testing::WhenSorted(testing::ElementsAreArray(ids))); |
| 2031 | 2031 |
| 2032 support->EvictFrame(); | 2032 support->EvictCurrentSurface(); |
| 2033 } | 2033 } |
| 2034 | 2034 |
| 2035 TEST_F(SurfaceAggregatorWithResourcesTest, TakeInvalidResources) { | 2035 TEST_F(SurfaceAggregatorWithResourcesTest, TakeInvalidResources) { |
| 2036 FakeCompositorFrameSinkSupportClient client; | 2036 FakeCompositorFrameSinkSupportClient client; |
| 2037 std::unique_ptr<CompositorFrameSinkSupport> support = | 2037 std::unique_ptr<CompositorFrameSinkSupport> support = |
| 2038 CompositorFrameSinkSupport::Create( | 2038 CompositorFrameSinkSupport::Create( |
| 2039 &client, &manager_, kArbitraryRootFrameSinkId, kRootIsRoot, | 2039 &client, &manager_, kArbitraryRootFrameSinkId, kRootIsRoot, |
| 2040 kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints); | 2040 kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints); |
| 2041 LocalSurfaceId local_surface_id(7u, base::UnguessableToken::Create()); | 2041 LocalSurfaceId local_surface_id(7u, base::UnguessableToken::Create()); |
| 2042 SurfaceId surface_id(support->frame_sink_id(), local_surface_id); | 2042 SurfaceId surface_id(support->frame_sink_id(), local_surface_id); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 2056 CompositorFrame returned_frame = aggregator_->Aggregate(surface_id); | 2056 CompositorFrame returned_frame = aggregator_->Aggregate(surface_id); |
| 2057 | 2057 |
| 2058 // Nothing should be available to be returned yet. | 2058 // Nothing should be available to be returned yet. |
| 2059 EXPECT_TRUE(client.returned_resources().empty()); | 2059 EXPECT_TRUE(client.returned_resources().empty()); |
| 2060 | 2060 |
| 2061 SubmitCompositorFrameWithResources(NULL, 0, true, SurfaceId(), support.get(), | 2061 SubmitCompositorFrameWithResources(NULL, 0, true, SurfaceId(), support.get(), |
| 2062 surface_id); | 2062 surface_id); |
| 2063 ASSERT_EQ(1u, client.returned_resources().size()); | 2063 ASSERT_EQ(1u, client.returned_resources().size()); |
| 2064 EXPECT_EQ(11u, client.returned_resources()[0].id); | 2064 EXPECT_EQ(11u, client.returned_resources()[0].id); |
| 2065 | 2065 |
| 2066 support->EvictFrame(); | 2066 support->EvictCurrentSurface(); |
| 2067 } | 2067 } |
| 2068 | 2068 |
| 2069 TEST_F(SurfaceAggregatorWithResourcesTest, TwoSurfaces) { | 2069 TEST_F(SurfaceAggregatorWithResourcesTest, TwoSurfaces) { |
| 2070 FakeCompositorFrameSinkSupportClient client; | 2070 FakeCompositorFrameSinkSupportClient client; |
| 2071 std::unique_ptr<CompositorFrameSinkSupport> support1 = | 2071 std::unique_ptr<CompositorFrameSinkSupport> support1 = |
| 2072 CompositorFrameSinkSupport::Create( | 2072 CompositorFrameSinkSupport::Create( |
| 2073 &client, &manager_, FrameSinkId(1, 1), kChildIsRoot, | 2073 &client, &manager_, FrameSinkId(1, 1), kChildIsRoot, |
| 2074 kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints); | 2074 kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints); |
| 2075 std::unique_ptr<CompositorFrameSinkSupport> support2 = | 2075 std::unique_ptr<CompositorFrameSinkSupport> support2 = |
| 2076 CompositorFrameSinkSupport::Create( | 2076 CompositorFrameSinkSupport::Create( |
| (...skipping 25 matching lines...) Expand all Loading... |
| 2102 // surface1_id wasn't referenced, so its resources should be returned. | 2102 // surface1_id wasn't referenced, so its resources should be returned. |
| 2103 ASSERT_EQ(3u, client.returned_resources().size()); | 2103 ASSERT_EQ(3u, client.returned_resources().size()); |
| 2104 ResourceId returned_ids[3]; | 2104 ResourceId returned_ids[3]; |
| 2105 for (size_t i = 0; i < 3; ++i) { | 2105 for (size_t i = 0; i < 3; ++i) { |
| 2106 returned_ids[i] = client.returned_resources()[i].id; | 2106 returned_ids[i] = client.returned_resources()[i].id; |
| 2107 } | 2107 } |
| 2108 EXPECT_THAT(returned_ids, | 2108 EXPECT_THAT(returned_ids, |
| 2109 testing::WhenSorted(testing::ElementsAreArray(ids))); | 2109 testing::WhenSorted(testing::ElementsAreArray(ids))); |
| 2110 EXPECT_EQ(3u, resource_provider_->num_resources()); | 2110 EXPECT_EQ(3u, resource_provider_->num_resources()); |
| 2111 | 2111 |
| 2112 support1->EvictFrame(); | 2112 support1->EvictCurrentSurface(); |
| 2113 support2->EvictFrame(); | 2113 support2->EvictCurrentSurface(); |
| 2114 } | 2114 } |
| 2115 | 2115 |
| 2116 // Ensure that aggregator completely ignores Surfaces that reference invalid | 2116 // Ensure that aggregator completely ignores Surfaces that reference invalid |
| 2117 // resources. | 2117 // resources. |
| 2118 TEST_F(SurfaceAggregatorWithResourcesTest, InvalidChildSurface) { | 2118 TEST_F(SurfaceAggregatorWithResourcesTest, InvalidChildSurface) { |
| 2119 std::unique_ptr<CompositorFrameSinkSupport> root_support = | 2119 std::unique_ptr<CompositorFrameSinkSupport> root_support = |
| 2120 CompositorFrameSinkSupport::Create( | 2120 CompositorFrameSinkSupport::Create( |
| 2121 nullptr, &manager_, kArbitraryRootFrameSinkId, kRootIsRoot, | 2121 nullptr, &manager_, kArbitraryRootFrameSinkId, kRootIsRoot, |
| 2122 kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints); | 2122 kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints); |
| 2123 std::unique_ptr<CompositorFrameSinkSupport> middle_support = | 2123 std::unique_ptr<CompositorFrameSinkSupport> middle_support = |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2163 child_surface_id, middle_support.get(), | 2163 child_surface_id, middle_support.get(), |
| 2164 middle_surface_id); | 2164 middle_surface_id); |
| 2165 | 2165 |
| 2166 frame = aggregator_->Aggregate(root_surface_id); | 2166 frame = aggregator_->Aggregate(root_surface_id); |
| 2167 | 2167 |
| 2168 pass_list = &frame.render_pass_list; | 2168 pass_list = &frame.render_pass_list; |
| 2169 ASSERT_EQ(1u, pass_list->size()); | 2169 ASSERT_EQ(1u, pass_list->size()); |
| 2170 EXPECT_EQ(3u, pass_list->back()->shared_quad_state_list.size()); | 2170 EXPECT_EQ(3u, pass_list->back()->shared_quad_state_list.size()); |
| 2171 EXPECT_EQ(9u, pass_list->back()->quad_list.size()); | 2171 EXPECT_EQ(9u, pass_list->back()->quad_list.size()); |
| 2172 | 2172 |
| 2173 root_support->EvictFrame(); | 2173 root_support->EvictCurrentSurface(); |
| 2174 middle_support->EvictFrame(); | 2174 middle_support->EvictCurrentSurface(); |
| 2175 child_support->EvictFrame(); | 2175 child_support->EvictCurrentSurface(); |
| 2176 } | 2176 } |
| 2177 | 2177 |
| 2178 TEST_F(SurfaceAggregatorWithResourcesTest, SecureOutputTexture) { | 2178 TEST_F(SurfaceAggregatorWithResourcesTest, SecureOutputTexture) { |
| 2179 std::unique_ptr<CompositorFrameSinkSupport> support1 = | 2179 std::unique_ptr<CompositorFrameSinkSupport> support1 = |
| 2180 CompositorFrameSinkSupport::Create( | 2180 CompositorFrameSinkSupport::Create( |
| 2181 nullptr, &manager_, FrameSinkId(1, 1), kChildIsRoot, | 2181 nullptr, &manager_, FrameSinkId(1, 1), kChildIsRoot, |
| 2182 kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints); | 2182 kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints); |
| 2183 std::unique_ptr<CompositorFrameSinkSupport> support2 = | 2183 std::unique_ptr<CompositorFrameSinkSupport> support2 = |
| 2184 CompositorFrameSinkSupport::Create( | 2184 CompositorFrameSinkSupport::Create( |
| 2185 nullptr, &manager_, FrameSinkId(2, 2), kChildIsRoot, | 2185 nullptr, &manager_, FrameSinkId(2, 2), kChildIsRoot, |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2234 render_pass->quad_list.front()->material); | 2234 render_pass->quad_list.front()->material); |
| 2235 | 2235 |
| 2236 aggregator_->set_output_is_secure(false); | 2236 aggregator_->set_output_is_secure(false); |
| 2237 | 2237 |
| 2238 frame = aggregator_->Aggregate(surface2_id); | 2238 frame = aggregator_->Aggregate(surface2_id); |
| 2239 render_pass = frame.render_pass_list.back().get(); | 2239 render_pass = frame.render_pass_list.back().get(); |
| 2240 | 2240 |
| 2241 // Output is insecure, so texture should be drawn. | 2241 // Output is insecure, so texture should be drawn. |
| 2242 EXPECT_EQ(DrawQuad::SOLID_COLOR, render_pass->quad_list.back()->material); | 2242 EXPECT_EQ(DrawQuad::SOLID_COLOR, render_pass->quad_list.back()->material); |
| 2243 | 2243 |
| 2244 support1->EvictFrame(); | 2244 support1->EvictCurrentSurface(); |
| 2245 support2->EvictFrame(); | 2245 support2->EvictCurrentSurface(); |
| 2246 } | 2246 } |
| 2247 | 2247 |
| 2248 // Ensure that the render passes have correct color spaces. | 2248 // Ensure that the render passes have correct color spaces. |
| 2249 TEST_F(SurfaceAggregatorValidSurfaceTest, ColorSpaceTest) { | 2249 TEST_F(SurfaceAggregatorValidSurfaceTest, ColorSpaceTest) { |
| 2250 test::Quad quads[][2] = {{test::Quad::SolidColorQuad(SK_ColorWHITE), | 2250 test::Quad quads[][2] = {{test::Quad::SolidColorQuad(SK_ColorWHITE), |
| 2251 test::Quad::SolidColorQuad(SK_ColorLTGRAY)}, | 2251 test::Quad::SolidColorQuad(SK_ColorLTGRAY)}, |
| 2252 {test::Quad::SolidColorQuad(SK_ColorGRAY), | 2252 {test::Quad::SolidColorQuad(SK_ColorGRAY), |
| 2253 test::Quad::SolidColorQuad(SK_ColorDKGRAY)}}; | 2253 test::Quad::SolidColorQuad(SK_ColorDKGRAY)}}; |
| 2254 test::Pass passes[] = {test::Pass(quads[0], arraysize(quads[0]), 2), | 2254 test::Pass passes[] = {test::Pass(quads[0], arraysize(quads[0]), 2), |
| 2255 test::Pass(quads[1], arraysize(quads[1]), 1)}; | 2255 test::Pass(quads[1], arraysize(quads[1]), 1)}; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 2279 aggregated_frame = aggregator_.Aggregate(surface_id); | 2279 aggregated_frame = aggregator_.Aggregate(surface_id); |
| 2280 EXPECT_EQ(3u, aggregated_frame.render_pass_list.size()); | 2280 EXPECT_EQ(3u, aggregated_frame.render_pass_list.size()); |
| 2281 EXPECT_EQ(color_space1, aggregated_frame.render_pass_list[0]->color_space); | 2281 EXPECT_EQ(color_space1, aggregated_frame.render_pass_list[0]->color_space); |
| 2282 EXPECT_EQ(color_space1, aggregated_frame.render_pass_list[1]->color_space); | 2282 EXPECT_EQ(color_space1, aggregated_frame.render_pass_list[1]->color_space); |
| 2283 EXPECT_EQ(color_space3, aggregated_frame.render_pass_list[2]->color_space); | 2283 EXPECT_EQ(color_space3, aggregated_frame.render_pass_list[2]->color_space); |
| 2284 } | 2284 } |
| 2285 | 2285 |
| 2286 } // namespace | 2286 } // namespace |
| 2287 } // namespace cc | 2287 } // namespace cc |
| 2288 | 2288 |
| OLD | NEW |