Flutter Engine
The Flutter Engine
Public Types | Public Member Functions | Static Public Member Functions | List of all members
impeller::TextureGLES Class Referencefinal

#include <texture_gles.h>

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

Public Types

enum class  Type { kTexture , kTextureMultisampled , kRenderBuffer , kRenderBufferMultisampled }
 
enum class  IsWrapped { kWrapped }
 
enum class  AttachmentType { kColor0 , kDepth , 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 ()
 
virtual void SetLabel (std::string_view label)=0
 
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)
 
virtual bool IsValid () const =0
 
virtual ISize GetSize () const =0
 
bool IsOpaque () const
 
size_t GetMipCount () const
 
const TextureDescriptorGetTextureDescriptor () const
 
void SetCoordinateSystem (TextureCoordinateSystem coordinate_system)
 
TextureCoordinateSystem GetCoordinateSystem () const
 
virtual Scalar GetYCoordScale () 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)
 
virtual bool OnSetContents (const uint8_t *contents, size_t length, size_t slice)=0
 
virtual bool OnSetContents (std::shared_ptr< const fml::Mapping > mapping, size_t slice)=0
 
- 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.

◆ IsWrapped

Enumerator
kWrapped 

Definition at line 27 of file texture_gles.h.

◆ Type

enum class impeller::TextureGLES::Type
strong
Enumerator
kTexture 
kTextureMultisampled 
kRenderBuffer 
kRenderBufferMultisampled 

Definition at line 20 of file texture_gles.h.

20 {
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) {}
TextureGLES(ReactorGLES::Ref reactor, TextureDescriptor desc)

◆ 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:
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;
449 gl.BindRenderbuffer(GL_RENDERBUFFER, handle.value());
450 break;
451 }
452 InitializeContentsIfNecessary();
453 return true;
454}
std::optional< GLuint > GetGLHandle() const
const TextureDescriptor & GetTextureDescriptor() const
Definition: texture.cc:57
uint32_t * target
constexpr std::optional< GLenum > ToTextureTarget(TextureType type)
Definition: formats_gles.h:183
gl
Definition: malisc.py:41
GLenum type
Definition: texture_gles.cc:62
#define VALIDATION_LOG
Definition: validation.h:73

◆ GenerateMipmap()

bool impeller::TextureGLES::GenerateMipmap ( )

Definition at line 464 of file texture_gles.cc.

464 {
465 if (!IsValid()) {
466 return false;
467 }
468
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}
bool mipmap_generated_
Definition: texture.h:70
constexpr GLenum ToTextureType(TextureType type)
Definition: formats_gles.h:169

◆ 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}

◆ GetType()

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

Definition at line 498 of file texture_gles.cc.

498 {
499 return type_;
500}

◆ 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}

◆ 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}

◆ 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;
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}
static GLenum ToAttachmentType(TextureGLES::AttachmentType point)

◆ 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}

The documentation for this class was generated from the following files: