| 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 566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 577 factory_->EvictSurface(); | 577 factory_->EvictSurface(); |
| 578 EXPECT_TRUE(manager_.GetSurfaceForId(surface_id)); | 578 EXPECT_TRUE(manager_.GetSurfaceForId(surface_id)); |
| 579 EXPECT_TRUE(client_.returned_resources().empty()); | 579 EXPECT_TRUE(client_.returned_resources().empty()); |
| 580 EXPECT_EQ(0u, execute_count); | 580 EXPECT_EQ(0u, execute_count); |
| 581 | 581 |
| 582 manager_.SatisfySequence(SurfaceSequence(kAnotherArbitraryFrameSinkId, 4)); | 582 manager_.SatisfySequence(SurfaceSequence(kAnotherArbitraryFrameSinkId, 4)); |
| 583 EXPECT_FALSE(manager_.GetSurfaceForId(surface_id)); | 583 EXPECT_FALSE(manager_.GetSurfaceForId(surface_id)); |
| 584 EXPECT_FALSE(client_.returned_resources().empty()); | 584 EXPECT_FALSE(client_.returned_resources().empty()); |
| 585 } | 585 } |
| 586 | 586 |
| 587 // Tests that SurfaceFactory returns resources after Reset(). | |
| 588 TEST_F(SurfaceFactoryTest, Reset) { | |
| 589 LocalSurfaceId id(7, kArbitraryToken); | |
| 590 | |
| 591 TransferableResource resource; | |
| 592 resource.id = 1; | |
| 593 resource.mailbox_holder.texture_target = GL_TEXTURE_2D; | |
| 594 CompositorFrame frame; | |
| 595 frame.resource_list.push_back(resource); | |
| 596 factory_->SubmitCompositorFrame(id, std::move(frame), | |
| 597 SurfaceFactory::DrawCallback()); | |
| 598 EXPECT_EQ(last_created_surface_id().local_surface_id(), id); | |
| 599 | |
| 600 SurfaceId surface_id(kArbitraryFrameSinkId, id); | |
| 601 EXPECT_TRUE(manager_.GetSurfaceForId(surface_id)); | |
| 602 EXPECT_TRUE(client_.returned_resources().empty()); | |
| 603 factory_->Reset(); | |
| 604 EXPECT_FALSE(manager_.GetSurfaceForId(surface_id)); | |
| 605 EXPECT_FALSE(client_.returned_resources().empty()); | |
| 606 local_surface_id_ = LocalSurfaceId(); | |
| 607 } | |
| 608 | |
| 609 // Tests that SurfaceFactory returns resources after Reset() if dependency | |
| 610 // unregistered. | |
| 611 TEST_F(SurfaceFactoryTest, ResetDependenceUnRegistered) { | |
| 612 LocalSurfaceId id(7, kArbitraryToken); | |
| 613 | |
| 614 TransferableResource resource; | |
| 615 resource.id = 1; | |
| 616 resource.mailbox_holder.texture_target = GL_TEXTURE_2D; | |
| 617 CompositorFrame frame; | |
| 618 frame.resource_list.push_back(resource); | |
| 619 factory_->SubmitCompositorFrame(id, std::move(frame), | |
| 620 SurfaceFactory::DrawCallback()); | |
| 621 EXPECT_EQ(last_created_surface_id().local_surface_id(), id); | |
| 622 | |
| 623 SurfaceId surface_id(kArbitraryFrameSinkId, id); | |
| 624 Surface* surface = manager_.GetSurfaceForId(surface_id); | |
| 625 surface->AddDestructionDependency( | |
| 626 SurfaceSequence(kAnotherArbitraryFrameSinkId, 4)); | |
| 627 EXPECT_TRUE(manager_.GetSurfaceForId(surface_id)); | |
| 628 EXPECT_TRUE(client_.returned_resources().empty()); | |
| 629 factory_->Reset(); | |
| 630 EXPECT_FALSE(manager_.GetSurfaceForId(surface_id)); | |
| 631 EXPECT_FALSE(client_.returned_resources().empty()); | |
| 632 local_surface_id_ = LocalSurfaceId(); | |
| 633 } | |
| 634 | |
| 635 // Tests that SurfaceFactory doesn't return resources after Reset() if | |
| 636 // dependency registered. | |
| 637 TEST_F(SurfaceFactoryTest, ResetDependencyRegistered) { | |
| 638 LocalSurfaceId id(7, kArbitraryToken); | |
| 639 | |
| 640 TransferableResource resource; | |
| 641 resource.id = 1; | |
| 642 resource.mailbox_holder.texture_target = GL_TEXTURE_2D; | |
| 643 CompositorFrame frame; | |
| 644 frame.resource_list.push_back(resource); | |
| 645 factory_->SubmitCompositorFrame(id, std::move(frame), | |
| 646 SurfaceFactory::DrawCallback()); | |
| 647 EXPECT_EQ(last_created_surface_id().local_surface_id(), id); | |
| 648 | |
| 649 manager_.RegisterFrameSinkId(kAnotherArbitraryFrameSinkId); | |
| 650 | |
| 651 SurfaceId surface_id(kArbitraryFrameSinkId, id); | |
| 652 Surface* surface = manager_.GetSurfaceForId(surface_id); | |
| 653 surface->AddDestructionDependency( | |
| 654 SurfaceSequence(kAnotherArbitraryFrameSinkId, 4)); | |
| 655 EXPECT_TRUE(manager_.GetSurfaceForId(surface_id)); | |
| 656 EXPECT_TRUE(client_.returned_resources().empty()); | |
| 657 factory_->Reset(); | |
| 658 EXPECT_TRUE(manager_.GetSurfaceForId(surface_id)); | |
| 659 EXPECT_TRUE(client_.returned_resources().empty()); | |
| 660 | |
| 661 manager_.SatisfySequence(SurfaceSequence(kAnotherArbitraryFrameSinkId, 4)); | |
| 662 EXPECT_FALSE(manager_.GetSurfaceForId(surface_id)); | |
| 663 EXPECT_TRUE(client_.returned_resources().empty()); | |
| 664 local_surface_id_ = LocalSurfaceId(); | |
| 665 } | |
| 666 | |
| 667 TEST_F(SurfaceFactoryTest, DestroySequence) { | 587 TEST_F(SurfaceFactoryTest, DestroySequence) { |
| 668 LocalSurfaceId local_surface_id2(5, kArbitraryToken); | 588 LocalSurfaceId local_surface_id2(5, kArbitraryToken); |
| 669 std::unique_ptr<SurfaceFactory> factory2( | 589 std::unique_ptr<SurfaceFactory> factory2( |
| 670 new SurfaceFactory(kArbitraryFrameSinkId, &manager_, &client_)); | 590 new SurfaceFactory(kArbitraryFrameSinkId, &manager_, &client_)); |
| 671 SurfaceId id2(kArbitraryFrameSinkId, local_surface_id2); | 591 SurfaceId id2(kArbitraryFrameSinkId, local_surface_id2); |
| 672 factory2->SubmitCompositorFrame(local_surface_id2, CompositorFrame(), | 592 factory2->SubmitCompositorFrame(local_surface_id2, CompositorFrame(), |
| 673 SurfaceFactory::DrawCallback()); | 593 SurfaceFactory::DrawCallback()); |
| 674 | 594 |
| 675 manager_.RegisterFrameSinkId(kArbitraryFrameSinkId); | 595 manager_.RegisterFrameSinkId(kArbitraryFrameSinkId); |
| 676 | 596 |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 839 factory_->SubmitCompositorFrame(local_surface_id_, std::move(frame), | 759 factory_->SubmitCompositorFrame(local_surface_id_, std::move(frame), |
| 840 SurfaceFactory::DrawCallback()); | 760 SurfaceFactory::DrawCallback()); |
| 841 SurfaceId expected_surface_id(factory_->frame_sink_id(), local_surface_id_); | 761 SurfaceId expected_surface_id(factory_->frame_sink_id(), local_surface_id_); |
| 842 EXPECT_EQ(expected_surface_id, last_surface_info_.id()); | 762 EXPECT_EQ(expected_surface_id, last_surface_info_.id()); |
| 843 EXPECT_EQ(2.5f, last_surface_info_.device_scale_factor()); | 763 EXPECT_EQ(2.5f, last_surface_info_.device_scale_factor()); |
| 844 EXPECT_EQ(gfx::Size(7, 8), last_surface_info_.size_in_pixels()); | 764 EXPECT_EQ(gfx::Size(7, 8), last_surface_info_.size_in_pixels()); |
| 845 } | 765 } |
| 846 | 766 |
| 847 } // namespace | 767 } // namespace |
| 848 } // namespace cc | 768 } // namespace cc |
| OLD | NEW |