Commit f47e79f6 authored by Christopher Cameron's avatar Christopher Cameron Committed by Commit Bot

Separate SharedImageBackingGL Texture vs Image

At the beginning of this refactor there were 2 SharedImageBacking
classes: passthrough vs not-passthrough.

This is towards having 2 SharedImageBacking: GLImage vs normal
GL texture. The classes still inherit from a single Common class.
This moves some of the common code into static methods in the
Common class. In particular
* Make separate InitializeGLTexture functions, and move much of
  the common code into SharedImageBackingGLCommon::
  MakeTextureAndSetParameters.
* Make SharedImageRepresentationSkiaImpl have a method to take a
  callback to make on BeginReadAccess, rather than calling a
  method on SharedImageBackingGLCommon.
  - De-common-ize SharedImageBackingGLCommon::ProduceSkia.
  - Change it to have the caller create the SkPromiseImageTexture.
* Add SharedImageBackingGLImage::InitializePixels
  - For now this just calls glTexSubImage2D
  - In the future this will write to the GpuMemoryBuffer.

Bug: 1092155
Change-Id: If5f60356d683673e610192b7c851664a138a9951
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2248413
Commit-Queue: ccameron <ccameron@chromium.org>
Reviewed-by: default avatarGeoff Lang <geofflang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#780011}
parent 37ca7c98
......@@ -79,14 +79,10 @@ class SharedImageBackingGLCommon : public SharedImageBacking {
bool framebuffer_attachment_angle = false;
bool has_immutable_storage = false;
};
virtual bool InitializeGLTexture(GLuint service_id,
const InitializeGLTextureParams& params);
GLenum GetGLTarget() const;
GLuint GetGLServiceId() const;
virtual void BeginSkiaReadAccess() = 0;
protected:
// SharedImageBacking:
gfx::Rect ClearedRect() const final;
......@@ -98,10 +94,6 @@ class SharedImageBackingGLCommon : public SharedImageBacking {
std::unique_ptr<SharedImageRepresentationGLTexturePassthrough>
ProduceGLTexturePassthrough(SharedImageManager* manager,
MemoryTypeTracker* tracker) final;
std::unique_ptr<SharedImageRepresentationSkia> ProduceSkia(
SharedImageManager* manager,
MemoryTypeTracker* tracker,
scoped_refptr<SharedContextState> context_state) final;
std::unique_ptr<SharedImageRepresentationDawn> ProduceDawn(
SharedImageManager* manager,
MemoryTypeTracker* tracker,
......@@ -109,6 +101,14 @@ class SharedImageBackingGLCommon : public SharedImageBacking {
bool IsPassthrough() const { return is_passthrough_; }
// Helper function to create a GL texture.
static void MakeTextureAndSetParameters(
GLenum target,
GLuint service_id,
bool framebuffer_attachment_angle,
scoped_refptr<gles2::TexturePassthrough>* passthrough_texture,
gles2::Texture** texture);
const bool is_passthrough_;
gles2::Texture* texture_ = nullptr;
scoped_refptr<gles2::TexturePassthrough> passthrough_texture_;
......@@ -121,15 +121,14 @@ class SharedImageRepresentationSkiaImpl : public SharedImageRepresentationSkia {
public:
SharedImageRepresentationSkiaImpl(
SharedImageManager* manager,
SharedImageBackingGLCommon* backing,
SharedImageBacking* backing,
scoped_refptr<SharedContextState> context_state,
sk_sp<SkPromiseImageTexture> cached_promise_texture,
MemoryTypeTracker* tracker,
GLenum target,
GLuint service_id);
sk_sp<SkPromiseImageTexture> promise_texture,
MemoryTypeTracker* tracker);
~SharedImageRepresentationSkiaImpl() override;
sk_sp<SkPromiseImageTexture> promise_texture();
void SetBeginReadAccessCallback(
base::RepeatingClosure begin_read_access_callback);
private:
// SharedImageRepresentationSkia:
......@@ -147,6 +146,7 @@ class SharedImageRepresentationSkiaImpl : public SharedImageRepresentationSkia {
void CheckContext();
base::RepeatingClosure begin_read_access_callback_;
scoped_refptr<SharedContextState> context_state_;
sk_sp<SkPromiseImageTexture> promise_texture_;
......@@ -171,6 +171,9 @@ class SharedImageBackingGLTexture : public SharedImageBackingGLCommon {
delete;
~SharedImageBackingGLTexture() override;
void InitializeGLTexture(GLuint service_id,
const InitializeGLTextureParams& params);
private:
// SharedImageBacking:
void Update(std::unique_ptr<gfx::GpuFence> in_fence) override;
......@@ -178,9 +181,10 @@ class SharedImageBackingGLTexture : public SharedImageBackingGLCommon {
base::trace_event::MemoryAllocatorDump* dump,
base::trace_event::ProcessMemoryDump* pmd,
uint64_t client_tracing_id) override;
// SharedImageBackingGLCommon:
void BeginSkiaReadAccess() override;
std::unique_ptr<SharedImageRepresentationSkia> ProduceSkia(
SharedImageManager* manager,
MemoryTypeTracker* tracker,
scoped_refptr<SharedContextState> context_state) override;
};
// Implementation of SharedImageBacking that creates a GL Texture that is backed
......@@ -202,9 +206,8 @@ class SharedImageBackingGLImage : public SharedImageBackingGLCommon {
delete;
~SharedImageBackingGLImage() override;
// SharedImageBackingGLCommon:
bool InitializeGLTexture(GLuint service_id,
const InitializeGLTextureParams& params) override;
bool InitializeGLTexture(const InitializeGLTextureParams& params);
void InitializePixels(GLenum format, GLenum type, const uint8_t* data);
private:
// SharedImageBacking:
......@@ -214,17 +217,22 @@ class SharedImageBackingGLImage : public SharedImageBackingGLCommon {
base::trace_event::ProcessMemoryDump* pmd,
uint64_t client_tracing_id) override;
scoped_refptr<gfx::NativePixmap> GetNativePixmap() override;
std::unique_ptr<SharedImageRepresentationSkia> ProduceSkia(
SharedImageManager* manager,
MemoryTypeTracker* tracker,
scoped_refptr<SharedContextState> context_state) override;
std::unique_ptr<SharedImageRepresentationGLTexture>
ProduceRGBEmulationGLTexture(SharedImageManager* manager,
MemoryTypeTracker* tracker) override;
// SharedImageBackingGLCommon:
void BeginSkiaReadAccess() override;
void BeginSkiaReadAccess();
scoped_refptr<gl::GLImage> image_;
gles2::Texture* rgb_emulation_texture_ = nullptr;
const SharedImageBackingFactoryGLTexture::UnpackStateAttribs attribs_;
scoped_refptr<gfx::NativePixmap> native_pixmap_;
base::WeakPtrFactory<SharedImageBackingGLImage> weak_factory_;
};
} // namespace gpu
......
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