Commit e7d1c898 authored by Peng Huang's avatar Peng Huang Committed by Chromium LUCI CQ

Support passthrough for ScopedHardwareBufferFenceSync backing.

Bug: 1157074
Change-Id: I6fad512dcb8a262d67fc5160c2af89b0a8dfeefe
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2581938
Commit-Queue: Peng Huang <penghuang@chromium.org>
Commit-Queue: vikas soni <vikassoni@chromium.org>
Auto-Submit: Peng Huang <penghuang@chromium.org>
Reviewed-by: default avatarvikas soni <vikassoni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#835279}
parent ae4abbb5
......@@ -164,6 +164,57 @@ class SharedImageRepresentationGLTextureScopedHardwareBufferFenceSync
SharedImageRepresentationGLTextureScopedHardwareBufferFenceSync);
};
class SharedImageRepresentationGLTexturePassthroughScopedHardwareBufferFenceSync
: public SharedImageRepresentationGLTexturePassthrough {
public:
SharedImageRepresentationGLTexturePassthroughScopedHardwareBufferFenceSync(
SharedImageManager* manager,
SharedImageBackingScopedHardwareBufferFenceSync* backing,
MemoryTypeTracker* tracker,
scoped_refptr<gles2::TexturePassthrough> texture)
: SharedImageRepresentationGLTexturePassthrough(manager,
backing,
tracker),
texture_(std::move(texture)) {
DCHECK(texture_);
}
~SharedImageRepresentationGLTexturePassthroughScopedHardwareBufferFenceSync()
override {
if (!has_context())
texture_->MarkContextLost();
}
const scoped_refptr<gles2::TexturePassthrough>& GetTexturePassthrough()
override {
return texture_;
}
bool BeginAccess(GLenum mode) override {
// This representation only supports read access.
DCHECK_EQ(mode,
static_cast<GLenum>(GL_SHARED_IMAGE_ACCESS_MODE_READ_CHROMIUM));
return ahb_backing()->BeginGLReadAccess();
}
void EndAccess() override { ahb_backing()->EndGLReadAccess(); }
private:
SharedImageBackingScopedHardwareBufferFenceSync* ahb_backing() {
auto* ahb_backing =
static_cast<SharedImageBackingScopedHardwareBufferFenceSync*>(
backing());
DCHECK(ahb_backing);
return ahb_backing;
}
scoped_refptr<gles2::TexturePassthrough> texture_;
DISALLOW_COPY_AND_ASSIGN(
SharedImageRepresentationGLTexturePassthroughScopedHardwareBufferFenceSync);
};
class SharedImageRepresentationSkiaVkScopedHardwareBufferFenceSync
: public SharedImageRepresentationSkiaVkAndroid {
public:
......@@ -231,8 +282,8 @@ std::unique_ptr<SharedImageRepresentationGLTexturePassthrough>
SharedImageBackingScopedHardwareBufferFenceSync::ProduceGLTexturePassthrough(
SharedImageManager* manager,
MemoryTypeTracker* tracker) {
NOTREACHED();
return nullptr;
return GenGLTexturePassthroughRepresentation(manager, tracker);
;
}
std::unique_ptr<SharedImageRepresentationSkia>
......@@ -262,7 +313,12 @@ SharedImageBackingScopedHardwareBufferFenceSync::ProduceSkia(
DCHECK(context_state->GrContextIsGL());
auto gl_representation = GenGLTextureRepresentation(manager, tracker);
std::unique_ptr<SharedImageRepresentationGLTextureBase> gl_representation;
if (context_state->feature_info()->is_passthrough_cmd_decoder()) {
gl_representation = GenGLTexturePassthroughRepresentation(manager, tracker);
} else {
gl_representation = GenGLTextureRepresentation(manager, tracker);
}
if (!gl_representation)
return nullptr;
return SharedImageRepresentationSkiaGL::Create(std::move(gl_representation),
......@@ -284,4 +340,19 @@ SharedImageBackingScopedHardwareBufferFenceSync::GenGLTextureRepresentation(
manager, this, tracker, texture);
}
std::unique_ptr<
SharedImageRepresentationGLTexturePassthroughScopedHardwareBufferFenceSync>
SharedImageBackingScopedHardwareBufferFenceSync::
GenGLTexturePassthroughRepresentation(SharedImageManager* manager,
MemoryTypeTracker* tracker) {
auto texture = GenGLTexturePassthrough(
scoped_hardware_buffer_->buffer(), GL_TEXTURE_EXTERNAL_OES, color_space(),
size(), estimated_size(), ClearedRect());
if (!texture)
return nullptr;
return std::make_unique<
SharedImageRepresentationGLTexturePassthroughScopedHardwareBufferFenceSync>(
manager, this, tracker, std::move(texture));
}
} // namespace gpu
......@@ -18,15 +18,13 @@ class ScopedHardwareBufferFenceSync;
} // namespace base
namespace gpu {
class SharedImageRepresentationGLTexture;
class SharedImageRepresentationGLTextureScopedHardwareBufferFenceSync;
class SharedImageRepresentationSkia;
struct Mailbox;
class
SharedImageRepresentationGLTexturePassthroughScopedHardwareBufferFenceSync;
// Backing which wraps ScopedHardwareBufferFenceSync object and allows
// producing/using different representations from it. This backing is not thread
// safe.
// TODO(vikassoni): Add support for passthrough textures.
class GPU_GLES2_EXPORT SharedImageBackingScopedHardwareBufferFenceSync
: public SharedImageBackingAndroid {
public:
......@@ -66,12 +64,18 @@ class GPU_GLES2_EXPORT SharedImageBackingScopedHardwareBufferFenceSync
private:
friend class SharedImageRepresentationGLTextureScopedHardwareBufferFenceSync;
friend class
SharedImageRepresentationGLTexturePassthroughScopedHardwareBufferFenceSync;
friend class SharedImageRepresentationSkiaVkScopedHardwareBufferFenceSync;
std::unique_ptr<
SharedImageRepresentationGLTextureScopedHardwareBufferFenceSync>
GenGLTextureRepresentation(SharedImageManager* manager,
MemoryTypeTracker* tracker);
std::unique_ptr<
SharedImageRepresentationGLTexturePassthroughScopedHardwareBufferFenceSync>
GenGLTexturePassthroughRepresentation(SharedImageManager* manager,
MemoryTypeTracker* tracker);
bool BeginGLReadAccess();
void EndGLReadAccess();
void EndSkiaReadAccess();
......
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