| 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 | AttachmentPoint { AttachmentPoint::kColor0, AttachmentPoint::kDepth, AttachmentPoint::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, AttachmentPoint point) 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

## ◆ AttachmentPoint

enum impeller::TextureGLES::AttachmentPoint
| 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 46 of file texture_gles.cc.

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

## ◆ TextureGLES() [2/2]

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

Definition at line 49 of file texture_gles.cc.

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

## ◆ ~TextureGLES()

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

Definition at line 81 of file texture_gles.cc.

81 {
82 reactor_->CollectHandle(handle_);
83 }

## Member Function Documentation

## ◆ Bind()

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

Definition at line 397 of file texture_gles.cc.

397 {
398 auto handle = GetGLHandle();
399 if (!handle.has_value()) {
400 return false;
401 }
402 const auto& gl = reactor_->GetProcTable();
403 switch (type_) {
404 case Type::kTexture:
405 case Type::kTextureMultisampled: {
406 const auto target = ToTextureTarget(GetTextureDescriptor().type);
407 if (!target.has_value()) {
408 VALIDATION_LOG << "Could not bind texture of this type.";
409 return false;
410 }
411 gl.BindTexture(target.value(), handle.value());
412 } break;
413 case Type::kRenderBuffer:
414 case Type::kRenderBufferMultisampled:
415 gl.BindRenderbuffer(GL_RENDERBUFFER, handle.value());
416 break;
417 }
418 InitializeContentsIfNecessary();
419 return true;
420 }

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

422 {
423 if (!IsValid()) {
424 return false;
425 }
426
427 auto type = GetTextureDescriptor().type;
428 switch (type) {
429 case TextureType::kTexture2D:
430 break;
431 case TextureType::kTexture2DMultisample:
432 VALIDATION_LOG << "Generating mipmaps for multisample textures is not "
433 "supported in the GLES backend.";
434 return false;
435 case TextureType::kTextureCube:
436 break;
437 case TextureType::kTextureExternalOES:
438 break;
439 }
440
441 if (!Bind()) {
442 return false;
443 }
444
445 auto handle = GetGLHandle();
446 if (!handle.has_value()) {
447 return false;
448 }
449
450 const auto& gl = reactor_->GetProcTable();
451 gl.GenerateMipmap(ToTextureType(type));
452 mipmap_generated_ = true;
453 return true;
454 }

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

390 {
391 if (!IsValid()) {
392 return std::nullopt;
393 }
394 return reactor_->GetGLHandle(handle_);
395 }

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

## ◆ GetType()

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

Definition at line 456 of file texture_gles.cc.

456 {
457 return type_;
458 }

## ◆ IsWrapped()

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

Definition at line 54 of file texture_gles.h.

54 { return is_wrapped_; }

## ◆ SetAsFramebufferAttachment()

bool impeller::TextureGLES::SetAsFramebufferAttachment | ( | GLenum | target,
|  | AttachmentPoint | point
| ) |  | const

Definition at line 471 of file texture_gles.cc.

472 {
473 if (!IsValid()) {
474 return false;
475 }
476 InitializeContentsIfNecessary();
477 auto handle = GetGLHandle();
478 if (!handle.has_value()) {
479 return false;
480 }
481 const auto& gl = reactor_->GetProcTable();
482
483 switch (type_) {
484 case Type::kTexture:
485 gl.FramebufferTexture2D(target, // target
486 ToAttachmentPoint(point), // attachment
487 GL_TEXTURE_2D, // textarget
488 handle.value(), // texture
489 0 // level
490 );
491 break;
492 case Type::kTextureMultisampled:
493 gl.FramebufferTexture2DMultisampleEXT(
494 target, // target
495 ToAttachmentPoint(point), // attachment
496 GL_TEXTURE_2D, // textarget
497 handle.value(), // texture
498 0, // level
499 4 // samples
500 );
501 break;
502 case Type::kRenderBuffer:
503 case Type::kRenderBufferMultisampled:
504 gl.FramebufferRenderbuffer(target, // target
505 ToAttachmentPoint(point), // attachment
506 GL_RENDERBUFFER, // render-buffer target
507 handle.value() // render-buffer
508 );
509 break;
510 }
511
512 return true;
513 }

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

Referenced by impeller::ConfigureFBO().

## Friends And Related Function Documentation

## ◆ AllocatorMTL

friend class AllocatorMTL
| friend

Definition at line 57 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::ToAttachmentPoint
static GLenum ToAttachmentPoint(TextureGLES::AttachmentPoint point)
Definition: texture_gles.cc:460
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:390
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:46
impeller::AttachmentKind::kStencil
@ kStencil
impeller::TextureType::kTextureCube
@ kTextureCube
impeller::AttachmentKind::kDepth
@ kDepth
impeller::ToTextureType
constexpr GLenum ToTextureType(TextureType type)
Definition: formats_gles.h:170
impeller::Texture::mipmap_generated_
bool mipmap_generated_
Definition: texture.h:61
impeller::TextureType::kTexture2D
@ kTexture2D
VALIDATION_LOG
#define VALIDATION_LOG
Definition: validation.h:67
impeller::ToTextureTarget
constexpr std::optional< GLenum > ToTextureTarget(TextureType type)
Definition: formats_gles.h:184
impeller::TextureGLES::Bind
bool Bind() const
Definition: texture_gles.cc:397
impeller::TextureGLES::Type::kTexture
@ kTexture