Flutter Impeller
impeller::TextureGLES Class Referencefinal

#include <texture_gles.h>

Inheritance diagram for impeller::TextureGLES:
impeller::Texture impeller::BackendCast< TextureGLES, Texture >

Public Types

enum  Type {
  Type::kTexture,
  Type::kTextureMultisampled,
  Type::kRenderBuffer,
  Type::kRenderBufferMultisampled
}
 
enum  IsWrapped { IsWrapped::kWrapped }
 
enum  AttachmentType {
  AttachmentType::kColor0,
  AttachmentType::kDepth,
  AttachmentType::kStencil
}
 

Public Member Functions

 TextureGLES (ReactorGLES::Ref reactor, TextureDescriptor desc)
 
 TextureGLES (ReactorGLES::Ref reactor, TextureDescriptor desc, IsWrapped wrapped)
 
 ~TextureGLES () override
 
std::optional< GLuint > GetGLHandle () const
 
bool Bind () const
 
bool GenerateMipmap ()
 
bool SetAsFramebufferAttachment (GLenum target, AttachmentType attachment_type) const
 
Type GetType () const
 
bool IsWrapped () const
 
std::optional< GLuint > GetFBO () const
 
void MarkSliceInitialized (size_t slice) const
 
bool IsSliceInitialized (size_t slice) const
 
- Public Member Functions inherited from impeller::Texture
virtual ~Texture ()
 
bool SetContents (const uint8_t *contents, size_t length, size_t slice=0, bool is_opaque=false)
 
bool SetContents (std::shared_ptr< const fml::Mapping > mapping, size_t slice=0, bool is_opaque=false)
 
bool IsOpaque () const
 
size_t GetMipCount () const
 
const TextureDescriptorGetTextureDescriptor () const
 
void SetCoordinateSystem (TextureCoordinateSystem coordinate_system)
 
TextureCoordinateSystem GetCoordinateSystem () const
 
bool NeedsMipmapGeneration () const
 

Static Public Member Functions

static std::shared_ptr< TextureGLESWrapFBO (ReactorGLES::Ref reactor, TextureDescriptor desc, GLuint fbo)
 
- Static Public Member Functions inherited from impeller::BackendCast< TextureGLES, Texture >
static TextureGLESCast (Texture &base)
 
static const TextureGLESCast (const Texture &base)
 
static TextureGLESCast (Texture *base)
 
static const TextureGLESCast (const Texture *base)
 

Additional Inherited Members

- Protected Member Functions inherited from impeller::Texture
 Texture (TextureDescriptor desc)
 
- Protected Attributes inherited from impeller::Texture
bool mipmap_generated_ = false
 

Detailed Description

Definition at line 17 of file texture_gles.h.

Member Enumeration Documentation

◆ AttachmentType

Enumerator
kColor0 
kDepth 
kStencil 

Definition at line 50 of file texture_gles.h.

50  {
51  kColor0,
52  kDepth,
53  kStencil,
54  };

◆ IsWrapped

Enumerator
kWrapped 

Definition at line 27 of file texture_gles.h.

27  {
28  kWrapped,
29  };

◆ Type

Enumerator
kTexture 
kTextureMultisampled 
kRenderBuffer 
kRenderBufferMultisampled 

Definition at line 20 of file texture_gles.h.

20  {
21  kTexture,
22  kTextureMultisampled,
24  kRenderBufferMultisampled,
25  };

Constructor & Destructor Documentation

◆ TextureGLES() [1/2]

impeller::TextureGLES::TextureGLES ( ReactorGLES::Ref  reactor,
TextureDescriptor  desc 
)

Definition at line 142 of file texture_gles.cc.

143  : TextureGLES(std::move(reactor), desc, false, std::nullopt) {}

Referenced by WrapFBO().

◆ TextureGLES() [2/2]

impeller::TextureGLES::TextureGLES ( ReactorGLES::Ref  reactor,
TextureDescriptor  desc,
IsWrapped  wrapped 
)

Definition at line 145 of file texture_gles.cc.

148  : TextureGLES(std::move(reactor), desc, true, std::nullopt) {}

◆ ~TextureGLES()

impeller::TextureGLES::~TextureGLES ( )
override

Definition at line 186 of file texture_gles.cc.

186  {
187  reactor_->CollectHandle(handle_);
188 }

Member Function Documentation

◆ Bind()

bool impeller::TextureGLES::Bind ( ) const

Definition at line 431 of file texture_gles.cc.

431  {
432  auto handle = GetGLHandle();
433  if (!handle.has_value()) {
434  return false;
435  }
436  const auto& gl = reactor_->GetProcTable();
437  switch (type_) {
438  case Type::kTexture:
440  const auto target = ToTextureTarget(GetTextureDescriptor().type);
441  if (!target.has_value()) {
442  VALIDATION_LOG << "Could not bind texture of this type.";
443  return false;
444  }
445  gl.BindTexture(target.value(), handle.value());
446  } break;
447  case Type::kRenderBuffer:
449  gl.BindRenderbuffer(GL_RENDERBUFFER, handle.value());
450  break;
451  }
452  InitializeContentsIfNecessary();
453  return true;
454 }

References GetGLHandle(), impeller::Texture::GetTextureDescriptor(), kRenderBuffer, kRenderBufferMultisampled, kTexture, kTextureMultisampled, impeller::ToTextureTarget(), type, and VALIDATION_LOG.

Referenced by GenerateMipmap().

◆ GenerateMipmap()

bool impeller::TextureGLES::GenerateMipmap ( )

Definition at line 464 of file texture_gles.cc.

464  {
465  if (!IsValid()) {
466  return false;
467  }
468 
469  auto type = GetTextureDescriptor().type;
470  switch (type) {
472  break;
474  VALIDATION_LOG << "Generating mipmaps for multisample textures is not "
475  "supported in the GLES backend.";
476  return false;
478  break;
480  break;
481  }
482 
483  if (!Bind()) {
484  return false;
485  }
486 
487  auto handle = GetGLHandle();
488  if (!handle.has_value()) {
489  return false;
490  }
491 
492  const auto& gl = reactor_->GetProcTable();
493  gl.GenerateMipmap(ToTextureType(type));
494  mipmap_generated_ = true;
495  return true;
496 }

References Bind(), GetGLHandle(), impeller::Texture::GetTextureDescriptor(), impeller::kTexture2D, impeller::kTexture2DMultisample, impeller::kTextureCube, impeller::kTextureExternalOES, impeller::Texture::mipmap_generated_, impeller::ToTextureType(), impeller::TextureDescriptor::type, type, and VALIDATION_LOG.

◆ GetFBO()

std::optional<GLuint> impeller::TextureGLES::GetFBO ( ) const
inline

Definition at line 63 of file texture_gles.h.

63 { return wrapped_fbo_; }

◆ GetGLHandle()

std::optional< GLuint > impeller::TextureGLES::GetGLHandle ( ) const

Definition at line 424 of file texture_gles.cc.

424  {
425  if (!IsValid()) {
426  return std::nullopt;
427  }
428  return reactor_->GetGLHandle(handle_);
429 }

Referenced by Bind(), impeller::ConfigureFBO(), impeller::BlitCopyBufferToTextureCommandGLES::Encode(), GenerateMipmap(), and SetAsFramebufferAttachment().

◆ GetType()

TextureGLES::Type impeller::TextureGLES::GetType ( ) const

Definition at line 498 of file texture_gles.cc.

498  {
499  return type_;
500 }

Referenced by impeller::BlitCopyBufferToTextureCommandGLES::Encode().

◆ IsSliceInitialized()

bool impeller::TextureGLES::IsSliceInitialized ( size_t  slice) const

Definition at line 460 of file texture_gles.cc.

460  {
461  return slices_initialized_[slice];
462 }

Referenced by impeller::BlitCopyBufferToTextureCommandGLES::Encode().

◆ IsWrapped()

bool impeller::TextureGLES::IsWrapped ( ) const
inline

Definition at line 61 of file texture_gles.h.

61 { return is_wrapped_; }

◆ MarkSliceInitialized()

void impeller::TextureGLES::MarkSliceInitialized ( size_t  slice) const

Definition at line 456 of file texture_gles.cc.

456  {
457  slices_initialized_[slice] = true;
458 }

Referenced by impeller::BlitCopyBufferToTextureCommandGLES::Encode().

◆ SetAsFramebufferAttachment()

bool impeller::TextureGLES::SetAsFramebufferAttachment ( GLenum  target,
AttachmentType  attachment_type 
) const

Definition at line 513 of file texture_gles.cc.

515  {
516  if (!IsValid()) {
517  return false;
518  }
519  InitializeContentsIfNecessary();
520  auto handle = GetGLHandle();
521  if (!handle.has_value()) {
522  return false;
523  }
524  const auto& gl = reactor_->GetProcTable();
525 
526  switch (type_) {
527  case Type::kTexture:
528  gl.FramebufferTexture2D(target, // target
529  ToAttachmentType(attachment_type), // attachment
530  GL_TEXTURE_2D, // textarget
531  handle.value(), // texture
532  0 // level
533  );
534  break;
536  gl.FramebufferTexture2DMultisampleEXT(
537  target, // target
538  ToAttachmentType(attachment_type), // attachment
539  GL_TEXTURE_2D, // textarget
540  handle.value(), // texture
541  0, // level
542  4 // samples
543  );
544  break;
545  case Type::kRenderBuffer:
547  gl.FramebufferRenderbuffer(
548  target, // target
549  ToAttachmentType(attachment_type), // attachment
550  GL_RENDERBUFFER, // render-buffer target
551  handle.value() // render-buffer
552  );
553  break;
554  }
555 
556  return true;
557 }

References GetGLHandle(), kRenderBuffer, kRenderBufferMultisampled, kTexture, kTextureMultisampled, and impeller::ToAttachmentType().

Referenced by impeller::ConfigureFBO().

◆ WrapFBO()

std::shared_ptr< TextureGLES > impeller::TextureGLES::WrapFBO ( ReactorGLES::Ref  reactor,
TextureDescriptor  desc,
GLuint  fbo 
)
static

Definition at line 150 of file texture_gles.cc.

152  {
153  return std::shared_ptr<TextureGLES>(
154  new TextureGLES(std::move(reactor), desc, true, fbo));
155 }

References TextureGLES().


The documentation for this class was generated from the following files:
impeller::TextureType::kTextureExternalOES
@ kTextureExternalOES
impeller::HandleType::kRenderBuffer
@ kRenderBuffer
impeller::TextureGLES::Type::kTextureMultisampled
@ kTextureMultisampled
impeller::Texture::GetTextureDescriptor
const TextureDescriptor & GetTextureDescriptor() const
Definition: texture.cc:57
impeller::TextureGLES::GetGLHandle
std::optional< GLuint > GetGLHandle() const
Definition: texture_gles.cc:424
impeller::HandleType::kTexture
@ kTexture
impeller::TextureGLES::Type::kRenderBufferMultisampled
@ kRenderBufferMultisampled
impeller::TextureDescriptor::type
TextureType type
Definition: texture_descriptor.h:40
impeller::TextureType::kTexture2DMultisample
@ kTexture2DMultisample
impeller::TextureGLES::Type::kRenderBuffer
@ kRenderBuffer
impeller::TextureGLES::TextureGLES
TextureGLES(ReactorGLES::Ref reactor, TextureDescriptor desc)
Definition: texture_gles.cc:142
type
GLenum type
Definition: texture_gles.cc:62
impeller::TextureType::kTextureCube
@ kTextureCube
impeller::ToTextureType
constexpr GLenum ToTextureType(TextureType type)
Definition: formats_gles.h:169
impeller::Texture::mipmap_generated_
bool mipmap_generated_
Definition: texture.h:70
impeller::TextureType::kTexture2D
@ kTexture2D
VALIDATION_LOG
#define VALIDATION_LOG
Definition: validation.h:73
impeller::ToTextureTarget
constexpr std::optional< GLenum > ToTextureTarget(TextureType type)
Definition: formats_gles.h:183
impeller::TextureGLES::Bind
bool Bind() const
Definition: texture_gles.cc:431
impeller::TextureGLES::Type::kTexture
@ kTexture
impeller::ToAttachmentType
static GLenum ToAttachmentType(TextureGLES::AttachmentType point)
Definition: texture_gles.cc:502