| Flutter Impeller |

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:

## 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 (ReactorGLES::Ref reactor, TextureDescriptor desc, HandleGLES external_handle)
| ~TextureGLES () override
bool | IsValid () const 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 TextureDescriptor & | GetTextureDescriptor () const
void | SetCoordinateSystem (TextureCoordinateSystem coordinate_system)
TextureCoordinateSystem | GetCoordinateSystem () const
bool | NeedsMipmapGeneration () const

## Static Public Member Functions
static std::shared_ptr< TextureGLES > | WrapFBO (ReactorGLES::Ref reactor, TextureDescriptor desc, GLuint fbo)
Static Public Member Functions inherited from impeller::BackendCast< TextureGLES, Texture >
static TextureGLES & | Cast (Texture &base)
static const TextureGLES & | Cast (const Texture &base)
static TextureGLES * | Cast (Texture *base)
static const TextureGLES * | Cast (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

enum impeller::TextureGLES::AttachmentType
| strong

Enumerator
kColor0 |
kDepth |
kStencil |

Definition at line 57 of file texture_gles.h.

57 {
58 kColor0,
59 kDepth,
60 kStencil,
61 };

## ◆ IsWrapped

enum bool impeller::TextureGLES::IsWrapped
| strong

Enumerator
kWrapped |

Definition at line 27 of file texture_gles.h.

27 {
28 kWrapped,
29 };

## ◆ Type

enum impeller::TextureGLES::Type
| strong

Enumerator
kTexture |
kTextureMultisampled |
kRenderBuffer |
kRenderBufferMultisampled |

Definition at line 20 of file texture_gles.h.

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

## Constructor & Destructor Documentation

## ◆ TextureGLES() [1/3]

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, std::nullopt) {
144 }

Referenced by WrapFBO().

## ◆ TextureGLES() [2/3]

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

Definition at line 146 of file texture_gles.cc.

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

## ◆ TextureGLES() [3/3]

impeller::TextureGLES::TextureGLES | ( | ReactorGLES::Ref | reactor,
|  | TextureDescriptor | desc,
|  | HandleGLES | external_handle
| ) |  |

Definition at line 151 of file texture_gles.cc.

154 : TextureGLES(std::move(reactor),
155 desc,
156 true,
157 std::nullopt,
158 external_handle) {}

## ◆ ~TextureGLES()

impeller::TextureGLES::~TextureGLES | ( |  | ) |
| override

Definition at line 199 of file texture_gles.cc.

199 {
200 reactor_->CollectHandle(handle_);
201 }

## Member Function Documentation

## ◆ Bind()

bool impeller::TextureGLES::Bind | ( |  | ) | const

Definition at line 444 of file texture_gles.cc.

444 {
445 auto handle = GetGLHandle();
446 if (!handle.has_value()) {
447 return false;
448 }
449 const auto& gl = reactor_->GetProcTable();
450 switch (type_) {
451 case Type::kTexture:
452 case Type::kTextureMultisampled: {
453 const auto target = ToTextureTarget(GetTextureDescriptor().type);
454 if (!target.has_value()) {
455 VALIDATION_LOG << "Could not bind texture of this type.";
456 return false;
457 }
458 gl.BindTexture(target.value(), handle.value());
459 } break;
460 case Type::kRenderBuffer:
461 case Type::kRenderBufferMultisampled:
462 gl.BindRenderbuffer(GL_RENDERBUFFER, handle.value());
463 break;
464 }
465 InitializeContentsIfNecessary();
466 return true;
467 }

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 477 of file texture_gles.cc.

477 {
478 if (!IsValid()) {
479 return false;
480 }
481
482 auto type = GetTextureDescriptor().type;
483 switch (type) {
484 case TextureType::kTexture2D:
485 break;
486 case TextureType::kTexture2DMultisample:
487 VALIDATION_LOG << "Generating mipmaps for multisample textures is not "
488 "supported in the GLES backend.";
489 return false;
490 case TextureType::kTextureCube:
491 break;
492 case TextureType::kTextureExternalOES:
493 break;
494 }
495
496 if (!Bind()) {
497 return false;
498 }
499
500 auto handle = GetGLHandle();
501 if (!handle.has_value()) {
502 return false;
503 }
504
505 const auto& gl = reactor_->GetProcTable();
506 gl.GenerateMipmap(ToTextureType(type));
507 mipmap_generated_ = true;
508 return true;
509 }

References Bind(), GetGLHandle(), impeller::Texture::GetTextureDescriptor(), IsValid(), 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

Definition at line 587 of file texture_gles.cc.

587 {
588 return wrapped_fbo_;
589 }

## ◆ GetGLHandle()

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

Definition at line 437 of file texture_gles.cc.

437 {
438 if (!IsValid()) {
439 return std::nullopt;
440 }
441 return reactor_->GetGLHandle(handle_);
442 }

References IsValid().

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

## ◆ GetType()

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

Definition at line 511 of file texture_gles.cc.

511 {
512 return type_;
513 }

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

## ◆ IsSliceInitialized()

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

Definition at line 473 of file texture_gles.cc.

473 {
474 return slices_initialized_[slice];
475 }

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

## ◆ IsValid()

bool impeller::TextureGLES::IsValid | ( |  | ) | const
| override virtual

Implements impeller::Texture.

Definition at line 204 of file texture_gles.cc.

204 {
205 return is_valid_;
206 }

Referenced by GenerateMipmap(), GetGLHandle(), and SetAsFramebufferAttachment().

## ◆ IsWrapped()

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

## ◆ MarkSliceInitialized()

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

Definition at line 469 of file texture_gles.cc.

469 {
470 slices_initialized_[slice] = true;
471 }

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

## ◆ SetAsFramebufferAttachment()

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

Definition at line 526 of file texture_gles.cc.

528 {
529 if (!IsValid()) {
530 return false;
531 }
532 InitializeContentsIfNecessary();
533 auto handle = GetGLHandle();
534 if (!handle.has_value()) {
535 return false;
536 }
537 const auto& gl = reactor_->GetProcTable();
538
539 switch (type_) {
540 case Type::kTexture:
541 gl.FramebufferTexture2D(target, // target
542 ToAttachmentType(attachment_type), // attachment
543 GL_TEXTURE_2D, // textarget
544 handle.value(), // texture
545 0 // level
546 );
547 break;
548 case Type::kTextureMultisampled:
549 gl.FramebufferTexture2DMultisampleEXT(
550 target, // target
551 ToAttachmentType(attachment_type), // attachment
552 GL_TEXTURE_2D, // textarget
553 handle.value(), // texture
554 0, // level
555 4 // samples
556 );
557 break;
558 case Type::kRenderBuffer:
559 case Type::kRenderBufferMultisampled:
560 gl.FramebufferRenderbuffer(
561 target, // target
562 ToAttachmentType(attachment_type), // attachment
563 GL_RENDERBUFFER, // render-buffer target
564 handle.value() // render-buffer
565 );
566 break;
567 }
568
569 return true;
570 }

References GetGLHandle(), IsValid(), 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 160 of file texture_gles.cc.

162 {
163 return std::shared_ptr<TextureGLES>(
164 new TextureGLES(std::move(reactor), desc, true, fbo, std::nullopt));
165 }

References TextureGLES().

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

- impeller/renderer/backend/gles/texture_gles.h
- impeller/renderer/backend/gles/texture_gles.cc

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:437
impeller::HandleType::kTexture
@ kTexture
impeller::TextureGLES::Type::kRenderBufferMultisampled
@ kRenderBufferMultisampled
impeller::TextureGLES::IsValid
bool IsValid() const override
Definition: texture_gles.cc:204
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:171
impeller::Texture::mipmap_generated_
bool mipmap_generated_
Definition: texture.h:70
impeller::TextureType::kTexture2D
@ kTexture2D
VALIDATION_LOG
#define VALIDATION_LOG
Definition: validation.h:91
impeller::ToTextureTarget
constexpr std::optional< GLenum > ToTextureTarget(TextureType type)
Definition: formats_gles.h:185
impeller::TextureGLES::Bind
bool Bind() const
Definition: texture_gles.cc:444
impeller::TextureGLES::Type::kTexture
@ kTexture
impeller::ToAttachmentType
static GLenum ToAttachmentType(TextureGLES::AttachmentType point)
Definition: texture_gles.cc:515