Index: cc/surfaces/surface_factory_unittest.cc |
diff --git a/cc/surfaces/surface_factory_unittest.cc b/cc/surfaces/surface_factory_unittest.cc |
index 2f917d7853923e68907bc27af5c31fddf2ef54a7..d532a085101c668a72cbd1b0ed2d39405d89d08d 100644 |
--- a/cc/surfaces/surface_factory_unittest.cc |
+++ b/cc/surfaces/surface_factory_unittest.cc |
@@ -72,7 +72,8 @@ class SurfaceFactoryTest : public testing::Test, public SurfaceObserver { |
frame_sync_token_(GenTestSyncToken(4)), |
consumer_sync_token_(GenTestSyncToken(5)) { |
manager_.AddObserver(this); |
- factory_->Create(local_frame_id_); |
+ factory_->SubmitCompositorFrame(local_frame_id_, CompositorFrame(), |
+ SurfaceFactory::DrawCallback()); |
} |
const SurfaceId& last_created_surface_id() const { |
@@ -92,8 +93,6 @@ class SurfaceFactoryTest : public testing::Test, public SurfaceObserver { |
} |
~SurfaceFactoryTest() override { |
- if (!local_frame_id_.is_null()) |
- factory_->Destroy(local_frame_id_); |
manager_.RemoveObserver(this); |
} |
@@ -434,76 +433,25 @@ TEST_F(SurfaceFactoryTest, ResourceLifetime) { |
TEST_F(SurfaceFactoryTest, BlankNoIndexIncrement) { |
LocalFrameId local_frame_id(6, 0); |
SurfaceId surface_id(kArbitraryFrameSinkId, local_frame_id); |
- factory_->Create(local_frame_id); |
- Surface* surface = manager_.GetSurfaceForId(surface_id); |
- ASSERT_NE(nullptr, surface); |
- EXPECT_EQ(2, surface->frame_index()); |
- |
factory_->SubmitCompositorFrame(local_frame_id, CompositorFrame(), |
SurfaceFactory::DrawCallback()); |
+ Surface* surface = manager_.GetSurfaceForId(surface_id); |
+ ASSERT_NE(nullptr, surface); |
EXPECT_EQ(2, surface->frame_index()); |
EXPECT_EQ(last_created_surface_id().local_frame_id(), local_frame_id); |
- factory_->Destroy(local_frame_id); |
-} |
- |
-void CreateSurfaceDrawCallback(SurfaceFactory* factory, |
- uint32_t* execute_count) { |
- LocalFrameId new_id(7, 0); |
- factory->Create(new_id); |
- factory->Destroy(new_id); |
- *execute_count += 1; |
-} |
- |
-TEST_F(SurfaceFactoryTest, AddDuringDestroy) { |
- LocalFrameId local_frame_id(6, 0); |
- factory_->Create(local_frame_id); |
- |
- uint32_t execute_count = 0; |
- factory_->SubmitCompositorFrame( |
- local_frame_id, CompositorFrame(), |
- base::Bind(&CreateSurfaceDrawCallback, base::Unretained(factory_.get()), |
- &execute_count)); |
- EXPECT_EQ(0u, execute_count); |
- factory_->Destroy(local_frame_id); |
- EXPECT_EQ(1u, execute_count); |
-} |
- |
-void DrawCallback(uint32_t* execute_count) { |
- *execute_count += 1; |
-} |
- |
-// Tests doing a DestroyAll before shutting down the factory; |
-TEST_F(SurfaceFactoryTest, DestroyAll) { |
- LocalFrameId id(7, 0); |
- factory_->Create(id); |
- |
- TransferableResource resource; |
- resource.id = 1; |
- resource.mailbox_holder.texture_target = GL_TEXTURE_2D; |
- CompositorFrame frame; |
- frame.resource_list.push_back(resource); |
- uint32_t execute_count = 0; |
- factory_->SubmitCompositorFrame(id, std::move(frame), |
- base::Bind(&DrawCallback, &execute_count)); |
- EXPECT_EQ(last_created_surface_id().local_frame_id(), id); |
- local_frame_id_ = LocalFrameId(); |
- factory_->DestroyAll(); |
- EXPECT_EQ(1u, execute_count); |
} |
// Tests that SurfaceFactory doesn't return resources after Reset(). |
TEST_F(SurfaceFactoryTest, Reset) { |
LocalFrameId id(7, 0); |
- factory_->Create(id); |
TransferableResource resource; |
resource.id = 1; |
resource.mailbox_holder.texture_target = GL_TEXTURE_2D; |
CompositorFrame frame; |
frame.resource_list.push_back(resource); |
- uint32_t execute_count = 0; |
factory_->SubmitCompositorFrame(id, std::move(frame), |
- base::Bind(&DrawCallback, &execute_count)); |
+ SurfaceFactory::DrawCallback()); |
EXPECT_EQ(last_created_surface_id().local_frame_id(), id); |
SurfaceId surface_id(kArbitraryFrameSinkId, id); |
@@ -516,16 +464,20 @@ TEST_F(SurfaceFactoryTest, Reset) { |
} |
TEST_F(SurfaceFactoryTest, DestroySequence) { |
+ SurfaceFactory* factory2 = |
+ new SurfaceFactory(kArbitraryFrameSinkId, &manager_, &client_); |
LocalFrameId local_frame_id2(5, 0); |
SurfaceId id2(kArbitraryFrameSinkId, local_frame_id2); |
- factory_->Create(local_frame_id2); |
+ factory2->SubmitCompositorFrame(local_frame_id2, CompositorFrame(), |
+ SurfaceFactory::DrawCallback()); |
manager_.RegisterFrameSinkId(kArbitraryFrameSinkId); |
// Check that waiting before the sequence is satisfied works. |
manager_.GetSurfaceForId(id2)->AddDestructionDependency( |
SurfaceSequence(kArbitraryFrameSinkId, 4)); |
- factory_->Destroy(local_frame_id2); |
+ factory2->SubmitCompositorFrame(LocalFrameId(0, 0), CompositorFrame(), |
+ SurfaceFactory::DrawCallback()); |
CompositorFrame frame; |
frame.metadata.satisfies_sequences.push_back(6); |
@@ -533,15 +485,17 @@ TEST_F(SurfaceFactoryTest, DestroySequence) { |
DCHECK(manager_.GetSurfaceForId(id2)); |
factory_->SubmitCompositorFrame(local_frame_id_, std::move(frame), |
SurfaceFactory::DrawCallback()); |
- EXPECT_EQ(last_created_surface_id().local_frame_id(), local_frame_id_); |
+ // EXPECT_EQ(last_created_surface_id().local_frame_id(), local_frame_id_); |
DCHECK(!manager_.GetSurfaceForId(id2)); |
// Check that waiting after the sequence is satisfied works. |
- factory_->Create(local_frame_id2); |
+ factory2->SubmitCompositorFrame(local_frame_id2, CompositorFrame(), |
+ SurfaceFactory::DrawCallback()); |
DCHECK(manager_.GetSurfaceForId(id2)); |
manager_.GetSurfaceForId(id2)->AddDestructionDependency( |
SurfaceSequence(FrameSinkId(0, 0), 6)); |
- factory_->Destroy(local_frame_id2); |
+ factory2->SubmitCompositorFrame(LocalFrameId(0, 1), CompositorFrame(), |
+ SurfaceFactory::DrawCallback()); |
DCHECK(!manager_.GetSurfaceForId(id2)); |
} |
@@ -552,12 +506,16 @@ TEST_F(SurfaceFactoryTest, InvalidFrameSinkId) { |
LocalFrameId local_frame_id(5, 0); |
SurfaceId id(factory_->frame_sink_id(), local_frame_id); |
- factory_->Create(local_frame_id); |
+ factory_->SubmitCompositorFrame(local_frame_id, CompositorFrame(), |
+ SurfaceFactory::DrawCallback()); |
manager_.RegisterFrameSinkId(frame_sink_id); |
manager_.GetSurfaceForId(id)->AddDestructionDependency( |
SurfaceSequence(frame_sink_id, 4)); |
- factory_->Destroy(local_frame_id); |
+ |
+ LocalFrameId local_frame_id_2(6, 0); |
+ factory_->SubmitCompositorFrame(local_frame_id_2, CompositorFrame(), |
+ SurfaceFactory::DrawCallback()); |
// Verify the dependency has prevented the surface from getting destroyed. |
EXPECT_TRUE(manager_.GetSurfaceForId(id)); |
@@ -572,12 +530,13 @@ TEST_F(SurfaceFactoryTest, InvalidFrameSinkId) { |
TEST_F(SurfaceFactoryTest, DestroyCycle) { |
LocalFrameId local_frame_id2(5, 0); |
SurfaceId id2(kArbitraryFrameSinkId, local_frame_id2); |
- factory_->Create(local_frame_id2); |
+ SurfaceFactory* factory2 = |
+ new SurfaceFactory(kArbitraryFrameSinkId, &manager_, &client_); |
+ // factory2->SubmitCompositorFrame(local_frame_id2, CompositorFrame(), |
+ // SurfaceFactory::DrawCallback()); |
manager_.RegisterFrameSinkId(FrameSinkId(0, 0)); |
- manager_.GetSurfaceForId(id2)->AddDestructionDependency( |
- SurfaceSequence(FrameSinkId(0, 0), 4)); |
// Give id2 a frame that references local_frame_id_. |
{ |
@@ -586,12 +545,15 @@ TEST_F(SurfaceFactoryTest, DestroyCycle) { |
frame.render_pass_list.push_back(std::move(render_pass)); |
frame.metadata.referenced_surfaces.push_back( |
SurfaceId(factory_->frame_sink_id(), local_frame_id_)); |
- factory_->SubmitCompositorFrame(local_frame_id2, std::move(frame), |
+ factory2->SubmitCompositorFrame(local_frame_id2, std::move(frame), |
SurfaceFactory::DrawCallback()); |
EXPECT_EQ(last_created_surface_id().local_frame_id(), local_frame_id2); |
} |
- factory_->Destroy(local_frame_id2); |
- |
+ manager_.GetSurfaceForId(id2)->AddDestructionDependency( |
+ SurfaceSequence(FrameSinkId(0, 0), 4)); |
+ factory2->SubmitCompositorFrame(LocalFrameId(0, 0), CompositorFrame(), |
+ SurfaceFactory::DrawCallback()); |
+ LOG(ERROR) << manager_.GetSurfaceForId(id2)->referenced_surfaces().size(); |
// Give local_frame_id_ a frame that references id2. |
{ |
std::unique_ptr<RenderPass> render_pass(RenderPass::Create()); |
@@ -600,9 +562,9 @@ TEST_F(SurfaceFactoryTest, DestroyCycle) { |
frame.metadata.referenced_surfaces.push_back(id2); |
factory_->SubmitCompositorFrame(local_frame_id_, std::move(frame), |
SurfaceFactory::DrawCallback()); |
- EXPECT_EQ(last_created_surface_id().local_frame_id(), local_frame_id_); |
} |
- factory_->Destroy(local_frame_id_); |
+ factory_->SubmitCompositorFrame(LocalFrameId(0, 1), CompositorFrame(), |
+ SurfaceFactory::DrawCallback()); |
EXPECT_TRUE(manager_.GetSurfaceForId(id2)); |
// local_frame_id_ should be retained by reference from id2. |
EXPECT_TRUE(manager_.GetSurfaceForId( |
@@ -671,8 +633,9 @@ TEST_F(SurfaceFactoryTest, DuplicateCopyRequest) { |
EXPECT_FALSE(called2); |
EXPECT_FALSE(called3); |
- factory_->Destroy(local_frame_id_); |
local_frame_id_ = LocalFrameId(); |
+ factory_->SubmitCompositorFrame(local_frame_id_, CompositorFrame(), |
+ SurfaceFactory::DrawCallback()); |
EXPECT_TRUE(called1); |
EXPECT_TRUE(called2); |
EXPECT_TRUE(called3); |