Commit ceabeecb authored by Albert Chaulk's avatar Albert Chaulk Committed by Commit Bot

Fix resource leak using surface quads in exo

Resources still get produced frequently, but because no
TextureDrawQuads are produced the associated mailboxes don't
get cleaned up

Fix this by also including the resource, so that the compositor
will trigger the usual cleanup path

Bug: b/145355036
Test: manual test on device
Change-Id: Ia364aef10fba5b5af67eb440b30a30bdb6a12361
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1949345
Commit-Queue: Albert Chaulk <achaulk@chromium.org>
Reviewed-by: default avatarMitsuru Oshima <oshima@chromium.org>
Reviewed-by: default avatarDaniel Nicoara <dnicoara@chromium.org>
Cr-Commit-Position: refs/heads/master@{#721776}
parent 40f419bf
...@@ -1048,6 +1048,9 @@ void Surface::AppendContentsToFrame(const gfx::Point& origin, ...@@ -1048,6 +1048,9 @@ void Surface::AppendContentsToFrame(const gfx::Point& origin,
/*stretch_content_to_fill_bounds=*/true, /*stretch_content_to_fill_bounds=*/true,
/*ignores_input_event=*/false); /*ignores_input_event=*/false);
} }
// A resource was still produced for this so we still need to release it
// later.
frame->resource_list.push_back(current_resource_);
} else if (state_.alpha) { } else if (state_.alpha) {
// Texture quad is only needed if buffer is not fully transparent. // Texture quad is only needed if buffer is not fully transparent.
viz::TextureDrawQuad* texture_quad = viz::TextureDrawQuad* texture_quad =
......
...@@ -862,6 +862,38 @@ TEST_P(SurfaceTest, SetAlpha) { ...@@ -862,6 +862,38 @@ TEST_P(SurfaceTest, SetAlpha) {
} }
} }
TEST_P(SurfaceTest, SurfaceQuad) {
gfx::Size buffer_size(1, 1);
auto buffer = std::make_unique<Buffer>(
exo_test_helper()->CreateGpuMemoryBuffer(buffer_size), GL_TEXTURE_2D, 0,
true, true, false);
auto surface = std::make_unique<Surface>();
auto shell_surface = std::make_unique<ShellSurface>(surface.get());
surface->Attach(buffer.get());
surface->SetAlpha(1.0f);
surface->SetEmbeddedSurfaceId(base::BindRepeating([]() -> viz::SurfaceId {
return viz::SurfaceId(
viz::FrameSinkId(1, 1),
viz::LocalSurfaceId(1, 1, base::UnguessableToken::Create()));
}));
{
surface->Commit();
base::RunLoop().RunUntilIdle();
const viz::CompositorFrame& frame =
GetFrameFromSurface(shell_surface.get());
EXPECT_EQ(1u, frame.render_pass_list.size());
EXPECT_EQ(1u, frame.render_pass_list.back()->quad_list.size());
EXPECT_EQ(1u, frame.resource_list.size());
// Ensure that the quad is correct and the resource is included.
EXPECT_EQ(1u, frame.resource_list.back().id);
EXPECT_EQ(viz::DrawQuad::Material::kSurfaceContent,
frame.render_pass_list.back()->quad_list.back()->material);
}
}
TEST_P(SurfaceTest, Commit) { TEST_P(SurfaceTest, Commit) {
std::unique_ptr<Surface> surface(new Surface); std::unique_ptr<Surface> surface(new Surface);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment