Commit aaa46efe authored by Peng Huang's avatar Peng Huang Committed by Commit Bot

skiarenderer: fixing flickering with skia renderer on Android

The problem is because a recent CL https://crrev.com/c/2149640 which
implements ProduceOverlay() but doesn't provide gpu fence for the
overlay access. Workaround the problem by creating a gpu fence for the
primary plane in SkiaOutputDeviceBufferQueue when GL is used.

Bug: 1082519,1085485
Change-Id: I86431c866d94ee2f1e29a939aed11f6dab6a57b8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2212548Reviewed-by: default avatarVasiliy Telezhnikov <vasilyt@chromium.org>
Commit-Queue: Vasiliy Telezhnikov <vasilyt@chromium.org>
Commit-Queue: Peng Huang <penghuang@chromium.org>
Auto-Submit: Peng Huang <penghuang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#771155}
parent c3b12cef
...@@ -41,8 +41,12 @@ constexpr uint32_t kSharedImageUsage = ...@@ -41,8 +41,12 @@ constexpr uint32_t kSharedImageUsage =
class SkiaOutputDeviceBufferQueue::Image { class SkiaOutputDeviceBufferQueue::Image {
public: public:
Image(gpu::SharedImageFactory* factory, Image(gpu::SharedImageFactory* factory,
gpu::SharedImageRepresentationFactory* representation_factory) gpu::SharedImageRepresentationFactory* representation_factory,
: factory_(factory), representation_factory_(representation_factory) {} bool is_gl)
: factory_(factory),
representation_factory_(representation_factory),
is_gl_(is_gl) {}
~Image() { ~Image() {
// TODO(vasilyt): As we are going to delete image anyway we should be able // TODO(vasilyt): As we are going to delete image anyway we should be able
// to abort write to avoid unnecessary flush to submit semaphores. // to abort write to avoid unnecessary flush to submit semaphores.
...@@ -182,15 +186,21 @@ class SkiaOutputDeviceBufferQueue::Image { ...@@ -182,15 +186,21 @@ class SkiaOutputDeviceBufferQueue::Image {
} }
gl::GLImage* GetGLImage(std::unique_ptr<gfx::GpuFence>* fence) { gl::GLImage* GetGLImage(std::unique_ptr<gfx::GpuFence>* fence) {
if (scoped_overlay_read_access_) if (scoped_overlay_read_access_) {
// TODO(penghuang): Remove it when SharedImageBackingFactoryGLTexture
// supports ProduceOverlay properly.
if (fence && is_gl_ && gl::GLFence::IsGpuFenceSupported()) {
if (auto gl_fence = gl::GLFence::CreateForGpuFence())
*fence = gl_fence->GetGpuFence();
}
return scoped_overlay_read_access_->gl_image(); return scoped_overlay_read_access_->gl_image();
}
DCHECK(scoped_gl_read_access_); if (fence && gl::GLFence::IsGpuFenceSupported()) {
if (gl::GLFence::IsGpuFenceSupported() && fence) {
if (auto gl_fence = gl::GLFence::CreateForGpuFence()) if (auto gl_fence = gl::GLFence::CreateForGpuFence())
*fence = gl_fence->GetGpuFence(); *fence = gl_fence->GetGpuFence();
} }
DCHECK(scoped_gl_read_access_);
auto* texture = gl_representation_->GetTexture(); auto* texture = gl_representation_->GetTexture();
return texture->GetLevelImage(texture->target(), 0); return texture->GetLevelImage(texture->target(), 0);
} }
...@@ -206,6 +216,7 @@ class SkiaOutputDeviceBufferQueue::Image { ...@@ -206,6 +216,7 @@ class SkiaOutputDeviceBufferQueue::Image {
private: private:
gpu::SharedImageFactory* const factory_; gpu::SharedImageFactory* const factory_;
gpu::SharedImageRepresentationFactory* const representation_factory_; gpu::SharedImageRepresentationFactory* const representation_factory_;
const bool is_gl_;
base::ScopedClosureRunner shared_image_deletor_; base::ScopedClosureRunner shared_image_deletor_;
std::unique_ptr<gpu::SharedImageRepresentationSkia> skia_representation_; std::unique_ptr<gpu::SharedImageRepresentationSkia> skia_representation_;
...@@ -421,7 +432,7 @@ void SkiaOutputDeviceBufferQueue::SchedulePrimaryPlane( ...@@ -421,7 +432,7 @@ void SkiaOutputDeviceBufferQueue::SchedulePrimaryPlane(
image->BeginPresent(); image->BeginPresent();
std::unique_ptr<gfx::GpuFence> fence; std::unique_ptr<gfx::GpuFence> fence;
// If the submitted_image_ is being scheduled, we don't new a new fence. // If the submitted_image_ is being scheduled, we don't need a new fence.
auto* gl_image = auto* gl_image =
image->GetGLImage(image == submitted_image_ ? nullptr : &fence); image->GetGLImage(image == submitted_image_ ? nullptr : &fence);
...@@ -602,7 +613,8 @@ bool SkiaOutputDeviceBufferQueue::Reshape(const gfx::Size& size, ...@@ -602,7 +613,8 @@ bool SkiaOutputDeviceBufferQueue::Reshape(const gfx::Size& size,
for (int i = 0; i < capabilities_.max_frames_pending + 1; ++i) { for (int i = 0; i < capabilities_.max_frames_pending + 1; ++i) {
auto image = std::make_unique<Image>( auto image = std::make_unique<Image>(
&shared_image_factory_, shared_image_representation_factory_.get()); &shared_image_factory_, shared_image_representation_factory_.get(),
dependency_->GetSharedContextState()->GrContextIsGL());
if (!image->Initialize(image_size_, color_space_, image_format_, if (!image->Initialize(image_size_, color_space_, image_format_,
dependency_, shared_image_usage_)) { dependency_, shared_image_usage_)) {
DLOG(ERROR) << "Failed to initialize image."; DLOG(ERROR) << "Failed to initialize image.";
......
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