| Flutter Impeller |

Public Types | Public Member Functions | Friends | 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 () 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
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

## Friends
class | AllocatorMTL

## Additional Inherited Members
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)
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 15 of file texture_gles.h.

## Member Enumeration Documentation

## ◆ AttachmentType

enum impeller::TextureGLES::AttachmentType
| strong

Enumerator
kColor0 |
kDepth |
kStencil |

Definition at line 44 of file texture_gles.h.

44 {
45 kColor0,
46 kDepth,
47 kStencil,
48 };

## ◆ IsWrapped

enum impeller::TextureGLES::IsWrapped
| strong

Enumerator
kWrapped |

Definition at line 25 of file texture_gles.h.

25 {
26 kWrapped,
27 };

## ◆ Type

enum impeller::TextureGLES::Type
| strong

Enumerator
kTexture |
kTextureMultisampled |
kRenderBuffer |
kRenderBufferMultisampled |

Definition at line 18 of file texture_gles.h.

18 {
19 kTexture,
20 kTextureMultisampled,
21 kRenderBuffer,
22 kRenderBufferMultisampled,
23 };

## Constructor & Destructor Documentation

## ◆ TextureGLES() [1/2]

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

Definition at line 70 of file texture_gles.cc.

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

## ◆ TextureGLES() [2/2]

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

Definition at line 73 of file texture_gles.cc.

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

## ◆ ~TextureGLES()

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

Definition at line 105 of file texture_gles.cc.

105 {
106 reactor_->CollectHandle(handle_);
107 }

## Member Function Documentation

## ◆ Bind()

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

Definition at line 425 of file texture_gles.cc.

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

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

Referenced by GenerateMipmap().

## ◆ GenerateMipmap()

bool impeller::TextureGLES::GenerateMipmap | ( |  | ) |

Definition at line 450 of file texture_gles.cc.

450 {
451 if (!IsValid()) {
452 return false;
453 }
454
455 auto type = GetTextureDescriptor().type;
456 switch (type) {
457 case TextureType::kTexture2D:
458 break;
459 case TextureType::kTexture2DMultisample:
460 VALIDATION_LOG << "Generating mipmaps for multisample textures is not "
461 "supported in the GLES backend.";
462 return false;
463 case TextureType::kTextureCube:
464 break;
465 case TextureType::kTextureExternalOES:
466 break;
467 }
468
469 if (!Bind()) {
470 return false;
471 }
472
473 auto handle = GetGLHandle();
474 if (!handle.has_value()) {
475 return false;
476 }
477
478 const auto& gl = reactor_->GetProcTable();
479 gl.GenerateMipmap(ToTextureType(type));
480 mipmap_generated_ = true;
481 return true;
482 }

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

## ◆ GetGLHandle()

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

Definition at line 418 of file texture_gles.cc.

418 {
419 if (!IsValid()) {
420 return std::nullopt;
421 }
422 return reactor_->GetGLHandle(handle_);
423 }

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

## ◆ GetType()

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

Definition at line 484 of file texture_gles.cc.

484 {
485 return type_;
486 }

## ◆ IsWrapped()

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

Definition at line 55 of file texture_gles.h.

55 { return is_wrapped_; }

## ◆ SetAsFramebufferAttachment()

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

Definition at line 499 of file texture_gles.cc.

501 {
502 if (!IsValid()) {
503 return false;
504 }
505 InitializeContentsIfNecessary();
506 auto handle = GetGLHandle();
507 if (!handle.has_value()) {
508 return false;
509 }
510 const auto& gl = reactor_->GetProcTable();
511
512 switch (type_) {
513 case Type::kTexture:
514 gl.FramebufferTexture2D(target, // target
515 ToAttachmentType(attachment_type), // attachment
516 GL_TEXTURE_2D, // textarget
517 handle.value(), // texture
518 0 // level
519 );
520 break;
521 case Type::kTextureMultisampled:
522 gl.FramebufferTexture2DMultisampleEXT(
523 target, // target
524 ToAttachmentType(attachment_type), // attachment
525 GL_TEXTURE_2D, // textarget
526 handle.value(), // texture
527 0, // level
528 4 // samples
529 );
530 break;
531 case Type::kRenderBuffer:
532 case Type::kRenderBufferMultisampled:
533 gl.FramebufferRenderbuffer(
534 target, // target
535 ToAttachmentType(attachment_type), // attachment
536 GL_RENDERBUFFER, // render-buffer target
537 handle.value() // render-buffer
538 );
539 break;
540 }
541
542 return true;
543 }

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

Referenced by impeller::ConfigureFBO().

## Friends And Related Function Documentation

## ◆ AllocatorMTL

friend class AllocatorMTL
| friend

Definition at line 58 of file texture_gles.h.

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:418
impeller::HandleType::kTexture
@ kTexture
impeller::TextureGLES::Type::kRenderBufferMultisampled
@ kRenderBufferMultisampled
impeller::TextureDescriptor::type
TextureType type
Definition: texture_descriptor.h:39
impeller::TextureType::kTexture2DMultisample
@ kTexture2DMultisample
impeller::TextureGLES::Type::kRenderBuffer
@ kRenderBuffer
impeller::TextureGLES::TextureGLES
TextureGLES(ReactorGLES::Ref reactor, TextureDescriptor desc)
Definition: texture_gles.cc:70
impeller::TextureType::kTextureCube
@ kTextureCube
impeller::ToTextureType
constexpr GLenum ToTextureType(TextureType type)
Definition: formats_gles.h:170
impeller::Texture::mipmap_generated_
bool mipmap_generated_
Definition: texture.h:64
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:184
impeller::TextureGLES::Bind
bool Bind() const
Definition: texture_gles.cc:425
impeller::TextureGLES::Type::kTexture
@ kTexture
impeller::ToAttachmentType
static GLenum ToAttachmentType(TextureGLES::AttachmentType point)
Definition: texture_gles.cc:488