5#ifndef FLUTTER_IMPELLER_RENDERER_BACKEND_GLES_TEXTURE_GLES_H_
6#define FLUTTER_IMPELLER_RENDERER_BACKEND_GLES_TEXTURE_GLES_H_
43 static std::shared_ptr<TextureGLES>
WrapFBO(
44 std::shared_ptr<ReactorGLES> reactor,
61 std::shared_ptr<ReactorGLES> reactor,
76 std::shared_ptr<ReactorGLES> reactor,
81 bool threadsafe =
false);
91 [[nodiscard]]
bool Bind();
111 std::optional<GLuint>
GetFBO()
const;
174 std::shared_ptr<ReactorGLES> reactor_;
177 std::optional<HandleGLES> fence_ = std::nullopt;
186 static constexpr size_t kMaxTrackedMipLevels = 16;
187 std::array<std::bitset<kMaxTrackedMipLevels>, 6> slice_mip_initialized_ = {};
188 const bool is_wrapped_;
189 const std::optional<GLuint> wrapped_fbo_;
191 bool is_valid_ =
false;
193 TextureGLES(std::shared_ptr<ReactorGLES> reactor,
194 TextureDescriptor desc,
196 std::optional<GLuint> fbo,
197 std::optional<HandleGLES> external_handle);
200 void SetLabel(std::string_view label)
override;
203 void SetLabel(std::string_view label, std::string_view trailing)
override;
206 bool OnSetContents(
const uint8_t* contents,
208 size_t slice)
override;
211 bool OnSetContents(std::shared_ptr<const fml::Mapping> mapping,
212 size_t slice)
override;
215 ISize GetSize()
const override;
218 Scalar GetYCoordScale()
const override;
220 void InitializeContentsIfNecessary();
222 TextureGLES(
const TextureGLES&) =
delete;
224 TextureGLES& operator=(
const TextureGLES&) =
delete;
Represents a handle to an underlying OpenGL object. Unlike OpenGL object handles, these handles can b...
static HandleGLES DeadHandle()
Creates a dead handle.
void MarkSliceInitialized(size_t slice)
Indicates that a specific texture slice has been initialized.
static std::shared_ptr< TextureGLES > WrapFBO(std::shared_ptr< ReactorGLES > reactor, TextureDescriptor desc, GLuint fbo)
Create a texture by wrapping an external framebuffer object whose lifecycle is owned by the caller.
void MarkContentsInitialized()
Indicates that all texture storage has already been allocated and contents initialized.
const HandleGLES & GetCachedFBO() const
Retrieve the cached FBO object, or a dead handle if there is no object.
bool SetAsFramebufferAttachment(GLenum target, AttachmentType attachment_type)
std::optional< HandleGLES > GetSyncFence() const
bool IsSliceMipLevelInitialized(size_t slice, size_t mip_level) const
bool IsSliceInitialized(size_t slice) const
@ kRenderBufferMultisampled
void MarkSliceMipLevelInitialized(size_t slice, size_t mip_level)
Indicates that storage for mip_level of slice has been allocated by a glTexImage2D call (or equivalen...
bool IsValid() const override
void SetFence(HandleGLES fence)
Attach a sync fence to this texture that will be waited on before encoding a rendering operation that...
void Leak()
Reset the internal texture state so that the reactor will not free the associated handle.
void SetCachedFBO(HandleGLES fbo)
static std::shared_ptr< TextureGLES > CreatePlaceholder(std::shared_ptr< ReactorGLES > reactor, TextureDescriptor desc)
Create a "texture" that is never expected to be bound/unbound explicitly or initialized in any way....
std::optional< GLuint > GetFBO() const
Type ComputeTypeForBinding(GLenum target) const
std::optional< GLuint > GetGLHandle() const
static std::shared_ptr< TextureGLES > WrapTexture(std::shared_ptr< ReactorGLES > reactor, TextureDescriptor desc, HandleGLES external_handle)
Create a texture by wrapping an external OpenGL texture handle. Ownership of the texture handle is as...
A lightweight object that describes the attributes of a texture that can then used an allocator to cr...