| 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_factory.h" | 5 #include "cc/surfaces/surface_factory.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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 size_t num_resource_ids) { | 107 size_t num_resource_ids) { |
| 108 CompositorFrame frame; | 108 CompositorFrame frame; |
| 109 for (size_t i = 0u; i < num_resource_ids; ++i) { | 109 for (size_t i = 0u; i < num_resource_ids; ++i) { |
| 110 TransferableResource resource; | 110 TransferableResource resource; |
| 111 resource.id = resource_ids[i]; | 111 resource.id = resource_ids[i]; |
| 112 resource.mailbox_holder.texture_target = GL_TEXTURE_2D; | 112 resource.mailbox_holder.texture_target = GL_TEXTURE_2D; |
| 113 resource.mailbox_holder.sync_token = frame_sync_token_; | 113 resource.mailbox_holder.sync_token = frame_sync_token_; |
| 114 frame.resource_list.push_back(resource); | 114 frame.resource_list.push_back(resource); |
| 115 } | 115 } |
| 116 factory_->SubmitCompositorFrame(local_surface_id_, std::move(frame), | 116 factory_->SubmitCompositorFrame(local_surface_id_, std::move(frame), |
| 117 SurfaceFactory::DrawCallback()); | 117 SurfaceFactory::DrawCallback(), |
| 118 SurfaceFactory::WillDrawCallback()); |
| 118 EXPECT_EQ(last_created_surface_id_.local_surface_id(), local_surface_id_); | 119 EXPECT_EQ(last_created_surface_id_.local_surface_id(), local_surface_id_); |
| 119 } | 120 } |
| 120 | 121 |
| 121 void UnrefResources(ResourceId* ids_to_unref, | 122 void UnrefResources(ResourceId* ids_to_unref, |
| 122 int* counts_to_unref, | 123 int* counts_to_unref, |
| 123 size_t num_ids_to_unref) { | 124 size_t num_ids_to_unref) { |
| 124 ReturnedResourceArray unref_array; | 125 ReturnedResourceArray unref_array; |
| 125 for (size_t i = 0; i < num_ids_to_unref; ++i) { | 126 for (size_t i = 0; i < num_ids_to_unref; ++i) { |
| 126 ReturnedResource resource; | 127 ReturnedResource resource; |
| 127 resource.sync_token = consumer_sync_token_; | 128 resource.sync_token = consumer_sync_token_; |
| (...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 458 CheckReturnedResourcesMatchExpected( | 459 CheckReturnedResourcesMatchExpected( |
| 459 expected_returned_ids, expected_returned_counts, | 460 expected_returned_ids, expected_returned_counts, |
| 460 arraysize(expected_returned_counts), consumer_sync_token_); | 461 arraysize(expected_returned_counts), consumer_sync_token_); |
| 461 } | 462 } |
| 462 } | 463 } |
| 463 | 464 |
| 464 TEST_F(SurfaceFactoryTest, BlankNoIndexIncrement) { | 465 TEST_F(SurfaceFactoryTest, BlankNoIndexIncrement) { |
| 465 LocalSurfaceId local_surface_id(6, kArbitraryToken); | 466 LocalSurfaceId local_surface_id(6, kArbitraryToken); |
| 466 SurfaceId surface_id(kArbitraryFrameSinkId, local_surface_id); | 467 SurfaceId surface_id(kArbitraryFrameSinkId, local_surface_id); |
| 467 factory_->SubmitCompositorFrame(local_surface_id, CompositorFrame(), | 468 factory_->SubmitCompositorFrame(local_surface_id, CompositorFrame(), |
| 468 SurfaceFactory::DrawCallback()); | 469 SurfaceFactory::DrawCallback(), |
| 470 SurfaceFactory::WillDrawCallback()); |
| 469 Surface* surface = manager_.GetSurfaceForId(surface_id); | 471 Surface* surface = manager_.GetSurfaceForId(surface_id); |
| 470 ASSERT_NE(nullptr, surface); | 472 ASSERT_NE(nullptr, surface); |
| 471 EXPECT_EQ(2, surface->frame_index()); | 473 EXPECT_EQ(2, surface->frame_index()); |
| 472 EXPECT_EQ(last_created_surface_id().local_surface_id(), local_surface_id); | 474 EXPECT_EQ(last_created_surface_id().local_surface_id(), local_surface_id); |
| 473 } | 475 } |
| 474 | 476 |
| 475 void CreateSurfaceDrawCallback(SurfaceFactory* factory, | 477 void CreateSurfaceDrawCallback(SurfaceFactory* factory, |
| 476 uint32_t* execute_count) { | 478 uint32_t* execute_count) { |
| 477 LocalSurfaceId new_id(7, base::UnguessableToken::Create()); | 479 LocalSurfaceId new_id(7, base::UnguessableToken::Create()); |
| 478 factory->SubmitCompositorFrame(new_id, CompositorFrame(), | 480 factory->SubmitCompositorFrame(new_id, CompositorFrame(), |
| 479 SurfaceFactory::DrawCallback()); | 481 SurfaceFactory::DrawCallback(), |
| 482 SurfaceFactory::WillDrawCallback()); |
| 480 factory->EvictSurface(); | 483 factory->EvictSurface(); |
| 481 *execute_count += 1; | 484 *execute_count += 1; |
| 482 } | 485 } |
| 483 | 486 |
| 484 TEST_F(SurfaceFactoryTest, AddDuringEviction) { | 487 TEST_F(SurfaceFactoryTest, AddDuringEviction) { |
| 485 LocalSurfaceId local_surface_id(6, kArbitraryToken); | 488 LocalSurfaceId local_surface_id(6, kArbitraryToken); |
| 486 | 489 |
| 487 uint32_t execute_count = 0; | 490 uint32_t execute_count = 0; |
| 488 factory_->SubmitCompositorFrame( | 491 factory_->SubmitCompositorFrame( |
| 489 local_surface_id, CompositorFrame(), | 492 local_surface_id, CompositorFrame(), |
| 490 base::Bind(&CreateSurfaceDrawCallback, base::Unretained(factory_.get()), | 493 base::Bind(&CreateSurfaceDrawCallback, base::Unretained(factory_.get()), |
| 491 &execute_count)); | 494 &execute_count), |
| 495 SurfaceFactory::WillDrawCallback()); |
| 492 EXPECT_EQ(0u, execute_count); | 496 EXPECT_EQ(0u, execute_count); |
| 493 factory_->EvictSurface(); | 497 factory_->EvictSurface(); |
| 494 EXPECT_EQ(1u, execute_count); | 498 EXPECT_EQ(1u, execute_count); |
| 495 } | 499 } |
| 496 | 500 |
| 497 void DrawCallback(uint32_t* execute_count) { | 501 void DrawCallback(uint32_t* execute_count) { |
| 498 *execute_count += 1; | 502 *execute_count += 1; |
| 499 } | 503 } |
| 500 | 504 |
| 501 // Tests doing an EvictSurface before shutting down the factory. | 505 // Tests doing an EvictSurface before shutting down the factory. |
| 502 TEST_F(SurfaceFactoryTest, EvictSurface) { | 506 TEST_F(SurfaceFactoryTest, EvictSurface) { |
| 503 LocalSurfaceId local_surface_id(7, kArbitraryToken); | 507 LocalSurfaceId local_surface_id(7, kArbitraryToken); |
| 504 SurfaceId id(kArbitraryFrameSinkId, local_surface_id); | 508 SurfaceId id(kArbitraryFrameSinkId, local_surface_id); |
| 505 | 509 |
| 506 TransferableResource resource; | 510 TransferableResource resource; |
| 507 resource.id = 1; | 511 resource.id = 1; |
| 508 resource.mailbox_holder.texture_target = GL_TEXTURE_2D; | 512 resource.mailbox_holder.texture_target = GL_TEXTURE_2D; |
| 509 CompositorFrame frame; | 513 CompositorFrame frame; |
| 510 frame.resource_list.push_back(resource); | 514 frame.resource_list.push_back(resource); |
| 511 uint32_t execute_count = 0; | 515 uint32_t execute_count = 0; |
| 512 factory_->SubmitCompositorFrame(local_surface_id, std::move(frame), | 516 factory_->SubmitCompositorFrame(local_surface_id, std::move(frame), |
| 513 base::Bind(&DrawCallback, &execute_count)); | 517 base::Bind(&DrawCallback, &execute_count), |
| 518 SurfaceFactory::WillDrawCallback()); |
| 514 EXPECT_EQ(last_created_surface_id().local_surface_id(), local_surface_id); | 519 EXPECT_EQ(last_created_surface_id().local_surface_id(), local_surface_id); |
| 515 local_surface_id_ = LocalSurfaceId(); | 520 local_surface_id_ = LocalSurfaceId(); |
| 516 | 521 |
| 517 EXPECT_TRUE(manager_.GetSurfaceForId(id)); | 522 EXPECT_TRUE(manager_.GetSurfaceForId(id)); |
| 518 EXPECT_TRUE(client_.returned_resources().empty()); | 523 EXPECT_TRUE(client_.returned_resources().empty()); |
| 519 factory_->EvictSurface(); | 524 factory_->EvictSurface(); |
| 520 EXPECT_FALSE(manager_.GetSurfaceForId(id)); | 525 EXPECT_FALSE(manager_.GetSurfaceForId(id)); |
| 521 EXPECT_FALSE(client_.returned_resources().empty()); | 526 EXPECT_FALSE(client_.returned_resources().empty()); |
| 522 EXPECT_EQ(1u, execute_count); | 527 EXPECT_EQ(1u, execute_count); |
| 523 } | 528 } |
| 524 | 529 |
| 525 // Tests doing an EvictSurface which has unregistered dependency. | 530 // Tests doing an EvictSurface which has unregistered dependency. |
| 526 TEST_F(SurfaceFactoryTest, EvictSurfaceDependencyUnRegistered) { | 531 TEST_F(SurfaceFactoryTest, EvictSurfaceDependencyUnRegistered) { |
| 527 LocalSurfaceId local_surface_id(7, kArbitraryToken); | 532 LocalSurfaceId local_surface_id(7, kArbitraryToken); |
| 528 | 533 |
| 529 TransferableResource resource; | 534 TransferableResource resource; |
| 530 resource.id = 1; | 535 resource.id = 1; |
| 531 resource.mailbox_holder.texture_target = GL_TEXTURE_2D; | 536 resource.mailbox_holder.texture_target = GL_TEXTURE_2D; |
| 532 CompositorFrame frame; | 537 CompositorFrame frame; |
| 533 frame.resource_list.push_back(resource); | 538 frame.resource_list.push_back(resource); |
| 534 uint32_t execute_count = 0; | 539 uint32_t execute_count = 0; |
| 535 factory_->SubmitCompositorFrame(local_surface_id, std::move(frame), | 540 factory_->SubmitCompositorFrame(local_surface_id, std::move(frame), |
| 536 base::Bind(&DrawCallback, &execute_count)); | 541 base::Bind(&DrawCallback, &execute_count), |
| 542 SurfaceFactory::WillDrawCallback()); |
| 537 EXPECT_EQ(last_created_surface_id().local_surface_id(), local_surface_id); | 543 EXPECT_EQ(last_created_surface_id().local_surface_id(), local_surface_id); |
| 538 local_surface_id_ = LocalSurfaceId(); | 544 local_surface_id_ = LocalSurfaceId(); |
| 539 | 545 |
| 540 SurfaceId surface_id(kArbitraryFrameSinkId, local_surface_id); | 546 SurfaceId surface_id(kArbitraryFrameSinkId, local_surface_id); |
| 541 Surface* surface = manager_.GetSurfaceForId(surface_id); | 547 Surface* surface = manager_.GetSurfaceForId(surface_id); |
| 542 surface->AddDestructionDependency( | 548 surface->AddDestructionDependency( |
| 543 SurfaceSequence(kAnotherArbitraryFrameSinkId, 4)); | 549 SurfaceSequence(kAnotherArbitraryFrameSinkId, 4)); |
| 544 | 550 |
| 545 EXPECT_TRUE(manager_.GetSurfaceForId(surface_id)); | 551 EXPECT_TRUE(manager_.GetSurfaceForId(surface_id)); |
| 546 EXPECT_TRUE(client_.returned_resources().empty()); | 552 EXPECT_TRUE(client_.returned_resources().empty()); |
| 547 factory_->EvictSurface(); | 553 factory_->EvictSurface(); |
| 548 EXPECT_FALSE(manager_.GetSurfaceForId(surface_id)); | 554 EXPECT_FALSE(manager_.GetSurfaceForId(surface_id)); |
| 549 EXPECT_FALSE(client_.returned_resources().empty()); | 555 EXPECT_FALSE(client_.returned_resources().empty()); |
| 550 EXPECT_EQ(1u, execute_count); | 556 EXPECT_EQ(1u, execute_count); |
| 551 } | 557 } |
| 552 | 558 |
| 553 // Tests doing an EvictSurface which has registered dependency. | 559 // Tests doing an EvictSurface which has registered dependency. |
| 554 TEST_F(SurfaceFactoryTest, EvictSurfaceDependencyRegistered) { | 560 TEST_F(SurfaceFactoryTest, EvictSurfaceDependencyRegistered) { |
| 555 LocalSurfaceId local_surface_id(7, kArbitraryToken); | 561 LocalSurfaceId local_surface_id(7, kArbitraryToken); |
| 556 | 562 |
| 557 TransferableResource resource; | 563 TransferableResource resource; |
| 558 resource.id = 1; | 564 resource.id = 1; |
| 559 resource.mailbox_holder.texture_target = GL_TEXTURE_2D; | 565 resource.mailbox_holder.texture_target = GL_TEXTURE_2D; |
| 560 CompositorFrame frame; | 566 CompositorFrame frame; |
| 561 frame.resource_list.push_back(resource); | 567 frame.resource_list.push_back(resource); |
| 562 uint32_t execute_count = 0; | 568 uint32_t execute_count = 0; |
| 563 factory_->SubmitCompositorFrame(local_surface_id, std::move(frame), | 569 factory_->SubmitCompositorFrame(local_surface_id, std::move(frame), |
| 564 base::Bind(&DrawCallback, &execute_count)); | 570 base::Bind(&DrawCallback, &execute_count), |
| 571 SurfaceFactory::WillDrawCallback()); |
| 565 EXPECT_EQ(last_created_surface_id().local_surface_id(), local_surface_id); | 572 EXPECT_EQ(last_created_surface_id().local_surface_id(), local_surface_id); |
| 566 local_surface_id_ = LocalSurfaceId(); | 573 local_surface_id_ = LocalSurfaceId(); |
| 567 | 574 |
| 568 manager_.RegisterFrameSinkId(kAnotherArbitraryFrameSinkId); | 575 manager_.RegisterFrameSinkId(kAnotherArbitraryFrameSinkId); |
| 569 | 576 |
| 570 SurfaceId surface_id(kArbitraryFrameSinkId, local_surface_id); | 577 SurfaceId surface_id(kArbitraryFrameSinkId, local_surface_id); |
| 571 Surface* surface = manager_.GetSurfaceForId(surface_id); | 578 Surface* surface = manager_.GetSurfaceForId(surface_id); |
| 572 surface->AddDestructionDependency( | 579 surface->AddDestructionDependency( |
| 573 SurfaceSequence(kAnotherArbitraryFrameSinkId, 4)); | 580 SurfaceSequence(kAnotherArbitraryFrameSinkId, 4)); |
| 574 | 581 |
| 575 EXPECT_TRUE(manager_.GetSurfaceForId(surface_id)); | 582 EXPECT_TRUE(manager_.GetSurfaceForId(surface_id)); |
| 576 EXPECT_TRUE(client_.returned_resources().empty()); | 583 EXPECT_TRUE(client_.returned_resources().empty()); |
| 577 factory_->EvictSurface(); | 584 factory_->EvictSurface(); |
| 578 EXPECT_TRUE(manager_.GetSurfaceForId(surface_id)); | 585 EXPECT_TRUE(manager_.GetSurfaceForId(surface_id)); |
| 579 EXPECT_TRUE(client_.returned_resources().empty()); | 586 EXPECT_TRUE(client_.returned_resources().empty()); |
| 580 EXPECT_EQ(0u, execute_count); | 587 EXPECT_EQ(0u, execute_count); |
| 581 | 588 |
| 582 manager_.SatisfySequence(SurfaceSequence(kAnotherArbitraryFrameSinkId, 4)); | 589 manager_.SatisfySequence(SurfaceSequence(kAnotherArbitraryFrameSinkId, 4)); |
| 583 EXPECT_FALSE(manager_.GetSurfaceForId(surface_id)); | 590 EXPECT_FALSE(manager_.GetSurfaceForId(surface_id)); |
| 584 EXPECT_FALSE(client_.returned_resources().empty()); | 591 EXPECT_FALSE(client_.returned_resources().empty()); |
| 585 } | 592 } |
| 586 | 593 |
| 587 TEST_F(SurfaceFactoryTest, DestroySequence) { | 594 TEST_F(SurfaceFactoryTest, DestroySequence) { |
| 588 LocalSurfaceId local_surface_id2(5, kArbitraryToken); | 595 LocalSurfaceId local_surface_id2(5, kArbitraryToken); |
| 589 std::unique_ptr<SurfaceFactory> factory2( | 596 std::unique_ptr<SurfaceFactory> factory2( |
| 590 new SurfaceFactory(kArbitraryFrameSinkId, &manager_, &client_)); | 597 new SurfaceFactory(kArbitraryFrameSinkId, &manager_, &client_)); |
| 591 SurfaceId id2(kArbitraryFrameSinkId, local_surface_id2); | 598 SurfaceId id2(kArbitraryFrameSinkId, local_surface_id2); |
| 592 factory2->SubmitCompositorFrame(local_surface_id2, CompositorFrame(), | 599 factory2->SubmitCompositorFrame(local_surface_id2, CompositorFrame(), |
| 593 SurfaceFactory::DrawCallback()); | 600 SurfaceFactory::DrawCallback(), |
| 601 SurfaceFactory::WillDrawCallback()); |
| 594 | 602 |
| 595 manager_.RegisterFrameSinkId(kArbitraryFrameSinkId); | 603 manager_.RegisterFrameSinkId(kArbitraryFrameSinkId); |
| 596 | 604 |
| 597 // Check that waiting before the sequence is satisfied works. | 605 // Check that waiting before the sequence is satisfied works. |
| 598 manager_.GetSurfaceForId(id2)->AddDestructionDependency( | 606 manager_.GetSurfaceForId(id2)->AddDestructionDependency( |
| 599 SurfaceSequence(kArbitraryFrameSinkId, 4)); | 607 SurfaceSequence(kArbitraryFrameSinkId, 4)); |
| 600 factory2->EvictSurface(); | 608 factory2->EvictSurface(); |
| 601 | 609 |
| 602 DCHECK(manager_.GetSurfaceForId(id2)); | 610 DCHECK(manager_.GetSurfaceForId(id2)); |
| 603 manager_.SatisfySequence(SurfaceSequence(kArbitraryFrameSinkId, 4)); | 611 manager_.SatisfySequence(SurfaceSequence(kArbitraryFrameSinkId, 4)); |
| 604 manager_.SatisfySequence(SurfaceSequence(kArbitraryFrameSinkId, 6)); | 612 manager_.SatisfySequence(SurfaceSequence(kArbitraryFrameSinkId, 6)); |
| 605 DCHECK(!manager_.GetSurfaceForId(id2)); | 613 DCHECK(!manager_.GetSurfaceForId(id2)); |
| 606 | 614 |
| 607 // Check that waiting after the sequence is satisfied works. | 615 // Check that waiting after the sequence is satisfied works. |
| 608 factory2->SubmitCompositorFrame(local_surface_id2, CompositorFrame(), | 616 factory2->SubmitCompositorFrame(local_surface_id2, CompositorFrame(), |
| 609 SurfaceFactory::DrawCallback()); | 617 SurfaceFactory::DrawCallback(), |
| 618 SurfaceFactory::WillDrawCallback()); |
| 610 DCHECK(manager_.GetSurfaceForId(id2)); | 619 DCHECK(manager_.GetSurfaceForId(id2)); |
| 611 manager_.GetSurfaceForId(id2)->AddDestructionDependency( | 620 manager_.GetSurfaceForId(id2)->AddDestructionDependency( |
| 612 SurfaceSequence(kAnotherArbitraryFrameSinkId, 6)); | 621 SurfaceSequence(kAnotherArbitraryFrameSinkId, 6)); |
| 613 factory2->EvictSurface(); | 622 factory2->EvictSurface(); |
| 614 DCHECK(!manager_.GetSurfaceForId(id2)); | 623 DCHECK(!manager_.GetSurfaceForId(id2)); |
| 615 } | 624 } |
| 616 | 625 |
| 617 // Tests that Surface ID namespace invalidation correctly allows | 626 // Tests that Surface ID namespace invalidation correctly allows |
| 618 // Sequences to be ignored. | 627 // Sequences to be ignored. |
| 619 TEST_F(SurfaceFactoryTest, InvalidFrameSinkId) { | 628 TEST_F(SurfaceFactoryTest, InvalidFrameSinkId) { |
| 620 FrameSinkId frame_sink_id(1234, 5678); | 629 FrameSinkId frame_sink_id(1234, 5678); |
| 621 | 630 |
| 622 LocalSurfaceId local_surface_id(5, kArbitraryToken); | 631 LocalSurfaceId local_surface_id(5, kArbitraryToken); |
| 623 SurfaceId id(factory_->frame_sink_id(), local_surface_id); | 632 SurfaceId id(factory_->frame_sink_id(), local_surface_id); |
| 624 factory_->SubmitCompositorFrame(local_surface_id, CompositorFrame(), | 633 factory_->SubmitCompositorFrame(local_surface_id, CompositorFrame(), |
| 625 SurfaceFactory::DrawCallback()); | 634 SurfaceFactory::DrawCallback(), |
| 635 SurfaceFactory::WillDrawCallback()); |
| 626 | 636 |
| 627 manager_.RegisterFrameSinkId(frame_sink_id); | 637 manager_.RegisterFrameSinkId(frame_sink_id); |
| 628 manager_.GetSurfaceForId(id)->AddDestructionDependency( | 638 manager_.GetSurfaceForId(id)->AddDestructionDependency( |
| 629 SurfaceSequence(frame_sink_id, 4)); | 639 SurfaceSequence(frame_sink_id, 4)); |
| 630 | 640 |
| 631 factory_->EvictSurface(); | 641 factory_->EvictSurface(); |
| 632 | 642 |
| 633 // Verify the dependency has prevented the surface from getting destroyed. | 643 // Verify the dependency has prevented the surface from getting destroyed. |
| 634 EXPECT_TRUE(manager_.GetSurfaceForId(id)); | 644 EXPECT_TRUE(manager_.GetSurfaceForId(id)); |
| 635 | 645 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 647 new SurfaceFactory(kArbitraryFrameSinkId, &manager_, &client_)); | 657 new SurfaceFactory(kArbitraryFrameSinkId, &manager_, &client_)); |
| 648 manager_.RegisterFrameSinkId(kAnotherArbitraryFrameSinkId); | 658 manager_.RegisterFrameSinkId(kAnotherArbitraryFrameSinkId); |
| 649 // Give id2 a frame that references local_surface_id_. | 659 // Give id2 a frame that references local_surface_id_. |
| 650 { | 660 { |
| 651 std::unique_ptr<RenderPass> render_pass(RenderPass::Create()); | 661 std::unique_ptr<RenderPass> render_pass(RenderPass::Create()); |
| 652 CompositorFrame frame; | 662 CompositorFrame frame; |
| 653 frame.render_pass_list.push_back(std::move(render_pass)); | 663 frame.render_pass_list.push_back(std::move(render_pass)); |
| 654 frame.metadata.referenced_surfaces.push_back( | 664 frame.metadata.referenced_surfaces.push_back( |
| 655 SurfaceId(factory_->frame_sink_id(), local_surface_id_)); | 665 SurfaceId(factory_->frame_sink_id(), local_surface_id_)); |
| 656 factory2->SubmitCompositorFrame(local_surface_id2, std::move(frame), | 666 factory2->SubmitCompositorFrame(local_surface_id2, std::move(frame), |
| 657 SurfaceFactory::DrawCallback()); | 667 SurfaceFactory::DrawCallback(), |
| 668 SurfaceFactory::WillDrawCallback()); |
| 658 EXPECT_EQ(last_created_surface_id().local_surface_id(), local_surface_id2); | 669 EXPECT_EQ(last_created_surface_id().local_surface_id(), local_surface_id2); |
| 659 } | 670 } |
| 660 manager_.GetSurfaceForId(id2)->AddDestructionDependency( | 671 manager_.GetSurfaceForId(id2)->AddDestructionDependency( |
| 661 SurfaceSequence(kAnotherArbitraryFrameSinkId, 4)); | 672 SurfaceSequence(kAnotherArbitraryFrameSinkId, 4)); |
| 662 factory2->EvictSurface(); | 673 factory2->EvictSurface(); |
| 663 // Give local_surface_id_ a frame that references id2. | 674 // Give local_surface_id_ a frame that references id2. |
| 664 { | 675 { |
| 665 std::unique_ptr<RenderPass> render_pass(RenderPass::Create()); | 676 std::unique_ptr<RenderPass> render_pass(RenderPass::Create()); |
| 666 CompositorFrame frame; | 677 CompositorFrame frame; |
| 667 frame.render_pass_list.push_back(std::move(render_pass)); | 678 frame.render_pass_list.push_back(std::move(render_pass)); |
| 668 frame.metadata.referenced_surfaces.push_back(id2); | 679 frame.metadata.referenced_surfaces.push_back(id2); |
| 669 factory_->SubmitCompositorFrame(local_surface_id_, std::move(frame), | 680 factory_->SubmitCompositorFrame(local_surface_id_, std::move(frame), |
| 670 SurfaceFactory::DrawCallback()); | 681 SurfaceFactory::DrawCallback(), |
| 682 SurfaceFactory::WillDrawCallback()); |
| 671 } | 683 } |
| 672 factory_->EvictSurface(); | 684 factory_->EvictSurface(); |
| 673 EXPECT_TRUE(manager_.GetSurfaceForId(id2)); | 685 EXPECT_TRUE(manager_.GetSurfaceForId(id2)); |
| 674 // local_surface_id_ should be retained by reference from id2. | 686 // local_surface_id_ should be retained by reference from id2. |
| 675 EXPECT_TRUE(manager_.GetSurfaceForId( | 687 EXPECT_TRUE(manager_.GetSurfaceForId( |
| 676 SurfaceId(factory_->frame_sink_id(), local_surface_id_))); | 688 SurfaceId(factory_->frame_sink_id(), local_surface_id_))); |
| 677 | 689 |
| 678 // Satisfy last destruction dependency for id2. | 690 // Satisfy last destruction dependency for id2. |
| 679 manager_.SatisfySequence(SurfaceSequence(kAnotherArbitraryFrameSinkId, 4)); | 691 manager_.SatisfySequence(SurfaceSequence(kAnotherArbitraryFrameSinkId, 4)); |
| 680 | 692 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 693 } | 705 } |
| 694 | 706 |
| 695 TEST_F(SurfaceFactoryTest, DuplicateCopyRequest) { | 707 TEST_F(SurfaceFactoryTest, DuplicateCopyRequest) { |
| 696 { | 708 { |
| 697 std::unique_ptr<RenderPass> render_pass(RenderPass::Create()); | 709 std::unique_ptr<RenderPass> render_pass(RenderPass::Create()); |
| 698 CompositorFrame frame; | 710 CompositorFrame frame; |
| 699 frame.render_pass_list.push_back(std::move(render_pass)); | 711 frame.render_pass_list.push_back(std::move(render_pass)); |
| 700 frame.metadata.referenced_surfaces.push_back( | 712 frame.metadata.referenced_surfaces.push_back( |
| 701 SurfaceId(factory_->frame_sink_id(), local_surface_id_)); | 713 SurfaceId(factory_->frame_sink_id(), local_surface_id_)); |
| 702 factory_->SubmitCompositorFrame(local_surface_id_, std::move(frame), | 714 factory_->SubmitCompositorFrame(local_surface_id_, std::move(frame), |
| 703 SurfaceFactory::DrawCallback()); | 715 SurfaceFactory::DrawCallback(), |
| 716 SurfaceFactory::WillDrawCallback()); |
| 704 EXPECT_EQ(last_created_surface_id().local_surface_id(), local_surface_id_); | 717 EXPECT_EQ(last_created_surface_id().local_surface_id(), local_surface_id_); |
| 705 } | 718 } |
| 706 | 719 |
| 707 bool called1 = false; | 720 bool called1 = false; |
| 708 std::unique_ptr<CopyOutputRequest> request; | 721 std::unique_ptr<CopyOutputRequest> request; |
| 709 request = CopyOutputRequest::CreateRequest( | 722 request = CopyOutputRequest::CreateRequest( |
| 710 base::Bind(&CopyRequestTestCallback, &called1)); | 723 base::Bind(&CopyRequestTestCallback, &called1)); |
| 711 request->set_source(kArbitrarySourceId1); | 724 request->set_source(kArbitrarySourceId1); |
| 712 | 725 |
| 713 factory_->RequestCopyOfSurface(std::move(request)); | 726 factory_->RequestCopyOfSurface(std::move(request)); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 750 render_pass->SetNew(1, gfx::Rect(5, 6), gfx::Rect(), gfx::Transform()); | 763 render_pass->SetNew(1, gfx::Rect(5, 6), gfx::Rect(), gfx::Transform()); |
| 751 frame.render_pass_list.push_back(std::move(render_pass)); | 764 frame.render_pass_list.push_back(std::move(render_pass)); |
| 752 | 765 |
| 753 render_pass = RenderPass::Create(); | 766 render_pass = RenderPass::Create(); |
| 754 render_pass->SetNew(2, gfx::Rect(7, 8), gfx::Rect(), gfx::Transform()); | 767 render_pass->SetNew(2, gfx::Rect(7, 8), gfx::Rect(), gfx::Transform()); |
| 755 frame.render_pass_list.push_back(std::move(render_pass)); | 768 frame.render_pass_list.push_back(std::move(render_pass)); |
| 756 | 769 |
| 757 frame.metadata.device_scale_factor = 2.5f; | 770 frame.metadata.device_scale_factor = 2.5f; |
| 758 | 771 |
| 759 factory_->SubmitCompositorFrame(local_surface_id_, std::move(frame), | 772 factory_->SubmitCompositorFrame(local_surface_id_, std::move(frame), |
| 760 SurfaceFactory::DrawCallback()); | 773 SurfaceFactory::DrawCallback(), |
| 774 SurfaceFactory::WillDrawCallback()); |
| 761 SurfaceId expected_surface_id(factory_->frame_sink_id(), local_surface_id_); | 775 SurfaceId expected_surface_id(factory_->frame_sink_id(), local_surface_id_); |
| 762 EXPECT_EQ(expected_surface_id, last_surface_info_.id()); | 776 EXPECT_EQ(expected_surface_id, last_surface_info_.id()); |
| 763 EXPECT_EQ(2.5f, last_surface_info_.device_scale_factor()); | 777 EXPECT_EQ(2.5f, last_surface_info_.device_scale_factor()); |
| 764 EXPECT_EQ(gfx::Size(7, 8), last_surface_info_.size_in_pixels()); | 778 EXPECT_EQ(gfx::Size(7, 8), last_surface_info_.size_in_pixels()); |
| 765 } | 779 } |
| 766 | 780 |
| 767 } // namespace | 781 } // namespace |
| 768 } // namespace cc | 782 } // namespace cc |
| OLD | NEW |