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 { ...@@ -79,14 +79,10 @@ class SharedImageBackingGLCommon : public SharedImageBacking {
bool framebuffer_attachment_angle = false; bool framebuffer_attachment_angle = false;
bool has_immutable_storage = false; bool has_immutable_storage = false;
}; };
virtual bool InitializeGLTexture(GLuint service_id,
const InitializeGLTextureParams& params);
GLenum GetGLTarget() const; GLenum GetGLTarget() const;
GLuint GetGLServiceId() const; GLuint GetGLServiceId() const;
virtual void BeginSkiaReadAccess() = 0;
protected: protected:
// SharedImageBacking: // SharedImageBacking:
gfx::Rect ClearedRect() const final; gfx::Rect ClearedRect() const final;
...@@ -98,10 +94,6 @@ class SharedImageBackingGLCommon : public SharedImageBacking { ...@@ -98,10 +94,6 @@ class SharedImageBackingGLCommon : public SharedImageBacking {
std::unique_ptr<SharedImageRepresentationGLTexturePassthrough> std::unique_ptr<SharedImageRepresentationGLTexturePassthrough>
ProduceGLTexturePassthrough(SharedImageManager* manager, ProduceGLTexturePassthrough(SharedImageManager* manager,
MemoryTypeTracker* tracker) final; MemoryTypeTracker* tracker) final;
std::unique_ptr<SharedImageRepresentationSkia> ProduceSkia(
SharedImageManager* manager,
MemoryTypeTracker* tracker,
scoped_refptr<SharedContextState> context_state) final;
std::unique_ptr<SharedImageRepresentationDawn> ProduceDawn( std::unique_ptr<SharedImageRepresentationDawn> ProduceDawn(
SharedImageManager* manager, SharedImageManager* manager,
MemoryTypeTracker* tracker, MemoryTypeTracker* tracker,
...@@ -109,6 +101,14 @@ class SharedImageBackingGLCommon : public SharedImageBacking { ...@@ -109,6 +101,14 @@ class SharedImageBackingGLCommon : public SharedImageBacking {
bool IsPassthrough() const { return is_passthrough_; } 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_; const bool is_passthrough_;
gles2::Texture* texture_ = nullptr; gles2::Texture* texture_ = nullptr;
scoped_refptr<gles2::TexturePassthrough> passthrough_texture_; scoped_refptr<gles2::TexturePassthrough> passthrough_texture_;
...@@ -121,15 +121,14 @@ class SharedImageRepresentationSkiaImpl : public SharedImageRepresentationSkia { ...@@ -121,15 +121,14 @@ class SharedImageRepresentationSkiaImpl : public SharedImageRepresentationSkia {
public: public:
SharedImageRepresentationSkiaImpl( SharedImageRepresentationSkiaImpl(
SharedImageManager* manager, SharedImageManager* manager,
SharedImageBackingGLCommon* backing, SharedImageBacking* backing,
scoped_refptr<SharedContextState> context_state, scoped_refptr<SharedContextState> context_state,
sk_sp<SkPromiseImageTexture> cached_promise_texture, sk_sp<SkPromiseImageTexture> promise_texture,
MemoryTypeTracker* tracker, MemoryTypeTracker* tracker);
GLenum target,
GLuint service_id);
~SharedImageRepresentationSkiaImpl() override; ~SharedImageRepresentationSkiaImpl() override;
sk_sp<SkPromiseImageTexture> promise_texture(); void SetBeginReadAccessCallback(
base::RepeatingClosure begin_read_access_callback);
private: private:
// SharedImageRepresentationSkia: // SharedImageRepresentationSkia:
...@@ -147,6 +146,7 @@ class SharedImageRepresentationSkiaImpl : public SharedImageRepresentationSkia { ...@@ -147,6 +146,7 @@ class SharedImageRepresentationSkiaImpl : public SharedImageRepresentationSkia {
void CheckContext(); void CheckContext();
base::RepeatingClosure begin_read_access_callback_;
scoped_refptr<SharedContextState> context_state_; scoped_refptr<SharedContextState> context_state_;
sk_sp<SkPromiseImageTexture> promise_texture_; sk_sp<SkPromiseImageTexture> promise_texture_;
...@@ -171,6 +171,9 @@ class SharedImageBackingGLTexture : public SharedImageBackingGLCommon { ...@@ -171,6 +171,9 @@ class SharedImageBackingGLTexture : public SharedImageBackingGLCommon {
delete; delete;
~SharedImageBackingGLTexture() override; ~SharedImageBackingGLTexture() override;
void InitializeGLTexture(GLuint service_id,
const InitializeGLTextureParams& params);
private: private:
// SharedImageBacking: // SharedImageBacking:
void Update(std::unique_ptr<gfx::GpuFence> in_fence) override; void Update(std::unique_ptr<gfx::GpuFence> in_fence) override;
...@@ -178,9 +181,10 @@ class SharedImageBackingGLTexture : public SharedImageBackingGLCommon { ...@@ -178,9 +181,10 @@ class SharedImageBackingGLTexture : public SharedImageBackingGLCommon {
base::trace_event::MemoryAllocatorDump* dump, base::trace_event::MemoryAllocatorDump* dump,
base::trace_event::ProcessMemoryDump* pmd, base::trace_event::ProcessMemoryDump* pmd,
uint64_t client_tracing_id) override; uint64_t client_tracing_id) override;
std::unique_ptr<SharedImageRepresentationSkia> ProduceSkia(
// SharedImageBackingGLCommon: SharedImageManager* manager,
void BeginSkiaReadAccess() override; MemoryTypeTracker* tracker,
scoped_refptr<SharedContextState> context_state) override;
}; };
// Implementation of SharedImageBacking that creates a GL Texture that is backed // Implementation of SharedImageBacking that creates a GL Texture that is backed
...@@ -202,9 +206,8 @@ class SharedImageBackingGLImage : public SharedImageBackingGLCommon { ...@@ -202,9 +206,8 @@ class SharedImageBackingGLImage : public SharedImageBackingGLCommon {
delete; delete;
~SharedImageBackingGLImage() override; ~SharedImageBackingGLImage() override;
// SharedImageBackingGLCommon: bool InitializeGLTexture(const InitializeGLTextureParams& params);
bool InitializeGLTexture(GLuint service_id, void InitializePixels(GLenum format, GLenum type, const uint8_t* data);
const InitializeGLTextureParams& params) override;
private: private:
// SharedImageBacking: // SharedImageBacking:
...@@ -214,17 +217,22 @@ class SharedImageBackingGLImage : public SharedImageBackingGLCommon { ...@@ -214,17 +217,22 @@ class SharedImageBackingGLImage : public SharedImageBackingGLCommon {
base::trace_event::ProcessMemoryDump* pmd, base::trace_event::ProcessMemoryDump* pmd,
uint64_t client_tracing_id) override; uint64_t client_tracing_id) override;
scoped_refptr<gfx::NativePixmap> GetNativePixmap() 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> std::unique_ptr<SharedImageRepresentationGLTexture>
ProduceRGBEmulationGLTexture(SharedImageManager* manager, ProduceRGBEmulationGLTexture(SharedImageManager* manager,
MemoryTypeTracker* tracker) override; MemoryTypeTracker* tracker) override;
// SharedImageBackingGLCommon: void BeginSkiaReadAccess();
void BeginSkiaReadAccess() override;
scoped_refptr<gl::GLImage> image_; scoped_refptr<gl::GLImage> image_;
gles2::Texture* rgb_emulation_texture_ = nullptr; gles2::Texture* rgb_emulation_texture_ = nullptr;
const SharedImageBackingFactoryGLTexture::UnpackStateAttribs attribs_; const SharedImageBackingFactoryGLTexture::UnpackStateAttribs attribs_;
scoped_refptr<gfx::NativePixmap> native_pixmap_; scoped_refptr<gfx::NativePixmap> native_pixmap_;
base::WeakPtrFactory<SharedImageBackingGLImage> weak_factory_;
}; };
} // namespace gpu } // 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