5#ifndef FLUTTER_IMPELLER_RENDERER_BACKEND_GLES_TEXTURE_GLES_H_
6#define FLUTTER_IMPELLER_RENDERER_BACKEND_GLES_TEXTURE_GLES_H_
44 static std::shared_ptr<TextureGLES>
WrapFBO(
45 std::shared_ptr<ReactorGLES>
reactor,
62 std::shared_ptr<ReactorGLES>
reactor,
77 std::shared_ptr<ReactorGLES>
reactor,
82 bool threadsafe =
false);
89 [[nodiscard]]
bool Bind();
100 uint32_t mip_level = 0,
111 std::optional<GLuint>
GetFBO()
const;
181 std::shared_ptr<ReactorGLES> reactor_;
193 static constexpr size_t kMaxTrackedMipLevels = 16;
194 std::array<std::bitset<kMaxTrackedMipLevels>, 6> slice_mip_initialized_ = {};
195 const bool is_wrapped_;
196 const std::optional<GLuint> wrapped_fbo_;
197 UniqueHandleGLES cached_fbo_;
198 uint32_t cached_fbo_mip_level_ = 0;
199 uint32_t cached_fbo_slice_ = 0;
200 bool is_valid_ =
false;
202 TextureGLES(std::shared_ptr<ReactorGLES>
reactor,
203 TextureDescriptor desc,
205 std::optional<GLuint> fbo,
206 std::optional<HandleGLES> external_handle);
209 void SetLabel(std::string_view label)
override;
212 void SetLabel(std::string_view label, std::string_view trailing)
override;
215 bool OnSetContents(
const uint8_t* contents,
217 size_t slice)
override;
220 bool OnSetContents(std::shared_ptr<const fml::Mapping> mapping,
221 size_t slice)
override;
224 ISize GetSize()
const override;
226 void InitializeContentsIfNecessary();
231 bool EnsureSliceMipLevelStorage(
size_t slice,
size_t mip_level);
233 TextureGLES(
const TextureGLES&) =
delete;
235 TextureGLES& operator=(
const TextureGLES&) =
delete;
Represents a handle to an underlying OpenGL object. Unlike OpenGL object handles, these handles can b...
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.
std::optional< HandleGLES > GetSyncFence() const
bool IsSliceMipLevelInitialized(size_t slice, size_t mip_level) const
bool CachedFBOMatchesSubresource(uint32_t mip_level, uint32_t slice) const
bool IsSliceInitialized(size_t slice) const
void SetCachedFBOSubresource(uint32_t mip_level, uint32_t slice)
Records the subresource the cached FBO is currently bound to.
@ 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....
bool SetAsFramebufferAttachment(GLenum target, AttachmentType attachment_type, uint32_t mip_level=0, uint32_t slice=0)
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 unique handle to an OpenGL object. The collection of this handle scheduled the destruction of the a...
std::shared_ptr< ReactorGLES > reactor
A lightweight object that describes the attributes of a texture that can then used an allocator to cr...