Commit 8eb2abcd authored by Fady Samuel's avatar Fady Samuel Committed by Commit Bot

Surface resurrection: Return resources and call draw callbacks if client does not change

When a surface is evicted and then is "resurrected", we drop the active and pending
frame. However, we do not return resources or call draw callbacks. This prevents video
from updating the content in its texture. In this CL, if a surface is resurrected
to the same client, then we return resources and call draw callbacks on the previously
held frames.

Bug: 796541
Cq-Include-Trybots: master.tryserver.chromium.android:android_optional_gpu_tests_rel
Change-Id: I12e8c8a31324887afe24300bc1b8ccbb4354ec86
Reviewed-on: https://chromium-review.googlesource.com/847336
Commit-Queue: Mounir Lamouri <mlamouri@chromium.org>
Reviewed-by: default avatarSaman Sami <samans@chromium.org>
Cr-Commit-Position: refs/heads/master@{#526680}
parent e5d92d31
......@@ -1000,9 +1000,12 @@ TEST_F(SurfaceSynchronizationTest, SurfaceResurrection) {
// Create the child surface by submitting a frame to it.
EXPECT_EQ(nullptr, GetSurfaceForId(child_id));
child_support1().SubmitCompositorFrame(child_id.local_surface_id(),
MakeDefaultCompositorFrame());
TransferableResource resource;
resource.id = 1234;
child_support1().SubmitCompositorFrame(
child_id.local_surface_id(),
MakeCompositorFrame(empty_surface_ids(), empty_surface_ids(),
{resource}));
// Verify that the child surface is created.
Surface* surface = GetSurfaceForId(child_id);
EXPECT_NE(nullptr, surface);
......@@ -1022,9 +1025,17 @@ TEST_F(SurfaceSynchronizationTest, SurfaceResurrection) {
// Child submits another frame to the same local surface id that is marked
// destroyed.
surface_observer().Reset();
child_support1().SubmitCompositorFrame(child_id.local_surface_id(),
MakeDefaultCompositorFrame());
{
std::vector<ReturnedResource> returned_resources =
TransferableResource::ReturnResources({resource});
EXPECT_CALL(support_client_, ReclaimResources(_)).Times(0);
EXPECT_CALL(support_client_,
DidReceiveCompositorFrameAck(Eq(returned_resources)));
surface_observer().Reset();
child_support1().SubmitCompositorFrame(child_id.local_surface_id(),
MakeDefaultCompositorFrame());
testing::Mock::VerifyAndClearExpectations(&support_client_);
}
// Verify that the surface that was marked destroyed is recovered and is being
// used again.
......
......@@ -43,9 +43,13 @@ Surface::~Surface() {
void Surface::Reset(base::WeakPtr<SurfaceClient> client) {
seen_first_frame_activation_ = false;
if (surface_client_.get() == client.get()) {
UnrefFrameResourcesAndRunCallbacks(std::move(pending_frame_data_));
UnrefFrameResourcesAndRunCallbacks(std::move(active_frame_data_));
}
surface_client_ = client;
pending_frame_data_.reset();
active_frame_data_.reset();
surface_client_ = client;
}
bool Surface::InheritActivationDeadlineFrom(
......
......@@ -42,6 +42,7 @@ TEST(SurfaceTest, PresentationCallback) {
.Build();
EXPECT_CALL(client, DidReceiveCompositorFrameAck(testing::_)).Times(1);
support->SubmitCompositorFrame(local_surface_id, std::move(frame));
testing::Mock::VerifyAndClearExpectations(&client);
}
{
......@@ -55,6 +56,7 @@ TEST(SurfaceTest, PresentationCallback) {
EXPECT_CALL(client, DidDiscardCompositorFrame(1)).Times(1);
EXPECT_CALL(client, DidReceiveCompositorFrameAck(testing::_)).Times(1);
support->SubmitCompositorFrame(local_surface_id, std::move(frame));
testing::Mock::VerifyAndClearExpectations(&client);
}
{
......@@ -66,6 +68,7 @@ TEST(SurfaceTest, PresentationCallback) {
.Build();
EXPECT_CALL(client, DidDiscardCompositorFrame(3)).Times(1);
support->SubmitCompositorFrame(local_surface_id, std::move(frame));
testing::Mock::VerifyAndClearExpectations(&client);
}
{
......@@ -77,6 +80,7 @@ TEST(SurfaceTest, PresentationCallback) {
.SetDeviceScaleFactor(2.f)
.SetPresentationToken(4)
.Build();
EXPECT_CALL(client, DidDiscardCompositorFrame(2)).Times(1);
EXPECT_CALL(client, DidDiscardCompositorFrame(4)).Times(1);
support->SubmitCompositorFrame(local_surface_id, std::move(frame));
}
......
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