Commit d19be0fc authored by Saman Sami's avatar Saman Sami Committed by Commit Bot

Fix frame eviction when surface sync is off

Since surface resurrection doens't work anymore, make sure the renderer
allocates a new id every time it's visible, as the old surface might
have been evicted.

Bug: 893731
Change-Id: I44d715949f2ccc76a270feac9e6fb899a472cbbc
Reviewed-on: https://chromium-review.googlesource.com/c/1293765Reviewed-by: default avatarFady Samuel <fsamuel@chromium.org>
Reviewed-by: default avatarAntoine Labour <piman@chromium.org>
Commit-Queue: Saman Sami <samans@chromium.org>
Cr-Commit-Position: refs/heads/master@{#601630}
parent dcd538eb
......@@ -260,6 +260,11 @@ void AsyncLayerTreeFrameSink::DidDeleteSharedBitmap(
compositor_frame_sink_ptr_->DidDeleteSharedBitmap(id);
}
void AsyncLayerTreeFrameSink::ForceAllocateNewId() {
DCHECK(!enable_surface_synchronization_);
local_surface_id_provider_->ForceAllocateNewId();
}
void AsyncLayerTreeFrameSink::DidReceiveCompositorFrameAck(
const std::vector<viz::ReturnedResource>& resources) {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
......
......@@ -122,6 +122,7 @@ class CC_MOJO_EMBEDDER_EXPORT AsyncLayerTreeFrameSink
void DidAllocateSharedBitmap(mojo::ScopedSharedBufferHandle buffer,
const viz::SharedBitmapId& id) override;
void DidDeleteSharedBitmap(const viz::SharedBitmapId& id) override;
void ForceAllocateNewId() override;
private:
// mojom::CompositorFrameSinkClient implementation:
......
......@@ -117,6 +117,10 @@ class CC_EXPORT LayerTreeFrameSink : public viz::SharedBitmapReporter,
const viz::SharedBitmapId& id) override = 0;
void DidDeleteSharedBitmap(const viz::SharedBitmapId& id) override = 0;
// Ensure next CompositorFrame is submitted to a new surface. Only used when
// surface synchronization is off.
virtual void ForceAllocateNewId() {}
protected:
class ContextLostForwarder;
......
......@@ -2971,6 +2971,12 @@ void LayerTreeHostImpl::SetVisible(bool visible) {
SetFullViewportDamage();
SetNeedsRedraw();
}
// If surface synchronization is off, force allocating a new LocalSurfaceId
// because the previous LocalSurfaceId might have been evicted while we were
// invisible. When surface synchronization is on, the embedder will pass us
// a new LocalSurfaceID.
if (layer_tree_frame_sink_ && !settings_.enable_surface_synchronization)
layer_tree_frame_sink_->ForceAllocateNewId();
} else {
EvictAllUIResources();
// Call PrepareTiles to evict tiles when we become invisible.
......
......@@ -12,6 +12,10 @@ LocalSurfaceIdProvider::LocalSurfaceIdProvider() = default;
LocalSurfaceIdProvider::~LocalSurfaceIdProvider() = default;
void LocalSurfaceIdProvider::ForceAllocateNewId() {
parent_local_surface_id_allocator_.GenerateId();
}
DefaultLocalSurfaceIdProvider::DefaultLocalSurfaceIdProvider() = default;
const LocalSurfaceId& DefaultLocalSurfaceIdProvider::GetLocalSurfaceIdForFrame(
......
......@@ -21,6 +21,11 @@ class VIZ_CLIENT_EXPORT LocalSurfaceIdProvider {
virtual const LocalSurfaceId& GetLocalSurfaceIdForFrame(
const CompositorFrame& frame) = 0;
void ForceAllocateNewId();
protected:
ParentLocalSurfaceIdAllocator parent_local_surface_id_allocator_;
private:
DISALLOW_COPY_AND_ASSIGN(LocalSurfaceIdProvider);
};
......@@ -36,7 +41,6 @@ class VIZ_CLIENT_EXPORT DefaultLocalSurfaceIdProvider
private:
gfx::Size surface_size_;
float device_scale_factor_ = 0;
ParentLocalSurfaceIdAllocator parent_local_surface_id_allocator_;
DISALLOW_COPY_AND_ASSIGN(DefaultLocalSurfaceIdProvider);
};
......
......@@ -398,7 +398,6 @@ class RendererLocalSurfaceIdProvider : public viz::LocalSurfaceIdProvider {
}
private:
viz::ParentLocalSurfaceIdAllocator parent_local_surface_id_allocator_;
RenderWidgetSurfaceProperties surface_properties_;
};
......
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