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

SharedImageBackingGLImage: Use Retain/Release to scope GL texture

Change SharedImageBackingGLImage to not allocate a GL texture until
it is going to be used, and also delete the GL texture when it is
no longer in use. This is needed for Metal-only SkiaRenderer, where
we really don't want to be using GL (and actually can't, because
there isn't a context hanging around at all times).

TBR=geofflang

Bug: 1092155
Change-Id: I6c14d03b50f40bd96de1c0c7355c03493c22865d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2298723Reviewed-by: default avatarGeoff Lang <geofflang@chromium.org>
Commit-Queue: ccameron <ccameron@chromium.org>
Cr-Commit-Position: refs/heads/master@{#789707}
parent 241ef1f3
...@@ -17,6 +17,7 @@ class SharedImageRepresentationGLTextureClient { ...@@ -17,6 +17,7 @@ class SharedImageRepresentationGLTextureClient {
public: public:
virtual bool SharedImageRepresentationGLTextureBeginAccess() = 0; virtual bool SharedImageRepresentationGLTextureBeginAccess() = 0;
virtual void SharedImageRepresentationGLTextureEndAccess() = 0; virtual void SharedImageRepresentationGLTextureEndAccess() = 0;
virtual void SharedImageRepresentationGLTextureRelease(bool have_context) = 0;
}; };
// Representation of a SharedImageBackingGLTexture or SharedImageBackingGLImage // Representation of a SharedImageBackingGLTexture or SharedImageBackingGLImage
...@@ -30,6 +31,7 @@ class SharedImageRepresentationGLTextureImpl ...@@ -30,6 +31,7 @@ class SharedImageRepresentationGLTextureImpl
SharedImageRepresentationGLTextureClient* client, SharedImageRepresentationGLTextureClient* client,
MemoryTypeTracker* tracker, MemoryTypeTracker* tracker,
gles2::Texture* texture); gles2::Texture* texture);
~SharedImageRepresentationGLTextureImpl() override;
private: private:
// SharedImageRepresentationGLTexture: // SharedImageRepresentationGLTexture:
...@@ -283,6 +285,7 @@ class SharedImageBackingGLImage ...@@ -283,6 +285,7 @@ class SharedImageBackingGLImage
// SharedImageRepresentationGLTextureClient: // SharedImageRepresentationGLTextureClient:
bool SharedImageRepresentationGLTextureBeginAccess() override; bool SharedImageRepresentationGLTextureBeginAccess() override;
void SharedImageRepresentationGLTextureEndAccess() override; void SharedImageRepresentationGLTextureEndAccess() override;
void SharedImageRepresentationGLTextureRelease(bool have_context) override;
bool IsPassthrough() const { return is_passthrough_; } bool IsPassthrough() const { return is_passthrough_; }
...@@ -293,11 +296,20 @@ class SharedImageBackingGLImage ...@@ -293,11 +296,20 @@ class SharedImageBackingGLImage
bool BindOrCopyImageIfNeeded(); bool BindOrCopyImageIfNeeded();
bool image_bind_or_copy_needed_ = true; bool image_bind_or_copy_needed_ = true;
void RetainGLTexture();
void ReleaseGLTexture(bool have_context);
size_t gl_texture_retain_count_ = 0;
bool gl_texture_retained_for_legacy_mailbox_ = false;
const SharedImageBackingGLCommon::InitializeGLTextureParams gl_params_; const SharedImageBackingGLCommon::InitializeGLTextureParams gl_params_;
const SharedImageBackingFactoryGLTexture::UnpackStateAttribs const SharedImageBackingFactoryGLTexture::UnpackStateAttribs
gl_unpack_attribs_; gl_unpack_attribs_;
const bool is_passthrough_; const bool is_passthrough_;
// This is the cleared rect used by ClearedRect and SetClearedRect when
// |texture_| is nullptr.
gfx::Rect cleared_rect_;
gles2::Texture* rgb_emulation_texture_ = nullptr; gles2::Texture* rgb_emulation_texture_ = nullptr;
gles2::Texture* texture_ = nullptr; gles2::Texture* texture_ = nullptr;
scoped_refptr<gles2::TexturePassthrough> passthrough_texture_; scoped_refptr<gles2::TexturePassthrough> passthrough_texture_;
......
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