| Flutter Impeller |

Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
impeller::Texture Class Referenceabstract

`#include <texture.h>`

Inheritance diagram for impeller::Texture:

## Public Member Functions
virtual | ~Texture ()
virtual void | SetLabel (std::string_view label)=0
| Label this resource for inspection in GPU debugging tools. More...
virtual void | SetLabel (std::string_view label, std::string_view trailing)=0
| Label this resource for inspection in GPU debugging tools, with label and trailing will be concatenated together. More...
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 TextureDescriptor & | GetTextureDescriptor () const
void | SetCoordinateSystem (TextureCoordinateSystem coordinate_system)
TextureCoordinateSystem | GetCoordinateSystem () const
virtual Scalar | GetYCoordScale () const
bool | NeedsMipmapGeneration () const

## Protected Member Functions
| 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
bool | mipmap_generated_ = false

## Detailed Description

Definition at line 17 of file texture.h.

## Constructor & Destructor Documentation

## ◆ ~Texture()

impeller::Texture::~Texture | ( |  | ) |
| virtual default

## ◆ Texture()

impeller::Texture::Texture | ( | TextureDescriptor | desc | ) |
| explicit protected

Definition at line 11 of file texture.cc.

11 : desc_(desc) {}

## Member Function Documentation

## ◆ GetCoordinateSystem()

TextureCoordinateSystem impeller::Texture::GetCoordinateSystem | ( |  | ) | const

Definition at line 77 of file texture.cc.

77 {
78 return coordinate_system_;
79 }

## ◆ GetMipCount()

size_t impeller::Texture::GetMipCount | ( |  | ) | const

Definition at line 53 of file texture.cc.

53 {
54 return GetTextureDescriptor().mip_count;
55 }

References GetTextureDescriptor(), and impeller::TextureDescriptor::mip_count.

## ◆ GetSize()

virtual ISize impeller::Texture::GetSize | ( |  | ) | const
| pure virtual

Implemented in impeller::TextureVK.

## ◆ GetTextureDescriptor()

const TextureDescriptor & impeller::Texture::GetTextureDescriptor | ( |  | ) | const

Definition at line 57 of file texture.cc.

57 {
58 return desc_;
59 }

Referenced by impeller::TextureGLES::Bind(), impeller::SamplerGLES::ConfigureBoundTexture(), impeller::BlitCopyBufferToTextureCommandGLES::Encode(), impeller::TextureGLES::GenerateMipmap(), GetMipCount(), impeller::TextureVK::GetSize(), impeller::TextureMTL::TextureMTL(), and impeller::TextureMTL::~TextureMTL().

## ◆ GetYCoordScale()

Scalar impeller::Texture::GetYCoordScale | ( |  | ) | const
| virtual

Definition at line 81 of file texture.cc.

81 {
82 return 1.0;
83 }

## ◆ IsOpaque()

bool impeller::Texture::IsOpaque | ( |  | ) | const

Definition at line 49 of file texture.cc.

49 {
50 return is_opaque_;
51 }

## ◆ IsValid()

virtual bool impeller::Texture::IsValid | ( |  | ) | const
| pure virtual

Implemented in impeller::TextureGLES, and impeller::TextureMTL.

Referenced by impeller::Bind().

## ◆ NeedsMipmapGeneration()

bool impeller::Texture::NeedsMipmapGeneration | ( |  | ) | const

Returns true if mipmaps have never been generated. The contents of the mipmap may be out of date if the root texture has been modified and the mipmaps hasn't been regenerated.

Definition at line 85 of file texture.cc.

85 {
86 return !mipmap_generated_ && desc_.mip_count > 1;
87 }

References impeller::TextureDescriptor::mip_count, and mipmap_generated_.

Referenced by impeller::Bind(), and impeller::SamplerGLES::ConfigureBoundTexture().

## ◆ OnSetContents() [1/2]

virtual bool impeller::Texture::OnSetContents | ( | const uint8_t * | contents,
|  | size_t | length,
|  | size_t | slice
| ) |  |
| protected pure virtual

Referenced by SetContents().

## ◆ OnSetContents() [2/2]

virtual bool impeller::Texture::OnSetContents | ( | std::shared_ptr< const fml::Mapping > | mapping,
|  | size_t | slice
| ) |  |
| protected pure virtual

## ◆ SetContents() [1/2]

bool impeller::Texture::SetContents | ( | const uint8_t * | contents,
|  | size_t | length,
|  | size_t | slice = `0`,
|  | bool | is_opaque = `false`
| ) |  |

Definition at line 15 of file texture.cc.

18 {
19 if (!IsSliceValid(slice)) {
20 VALIDATION_LOG << "Invalid slice for texture.";
21 return false;
22 }
23 if (!OnSetContents(contents, length, slice)) {
24 return false;
25 }
26 coordinate_system_ = TextureCoordinateSystem::kUploadFromHost;
27 is_opaque_ = is_opaque;
28 return true;
29 }

References impeller::kUploadFromHost, OnSetContents(), and VALIDATION_LOG.

## ◆ SetContents() [2/2]

bool impeller::Texture::SetContents | ( | std::shared_ptr< const fml::Mapping > | mapping,
|  | size_t | slice = `0`,
|  | bool | is_opaque = `false`
| ) |  |

Definition at line 31 of file texture.cc.

33 {
34 if (!IsSliceValid(slice)) {
35 VALIDATION_LOG << "Invalid slice for texture.";
36 return false;
37 }
38 if (!mapping) {
39 return false;
40 }
41 if (!OnSetContents(std::move(mapping), slice)) {
42 return false;
43 }
44 coordinate_system_ = TextureCoordinateSystem::kUploadFromHost;
45 is_opaque_ = is_opaque;
46 return true;
47 }

References impeller::kUploadFromHost, OnSetContents(), and VALIDATION_LOG.

## ◆ SetCoordinateSystem()

void impeller::Texture::SetCoordinateSystem | ( | TextureCoordinateSystem | coordinate_system | ) |

Update the coordinate system used by the texture.

The setting is used to conditionally invert the coordinates to account for the different origin of GLES textures.

Definition at line 73 of file texture.cc.

73 {
74 coordinate_system_ = coordinate_system;
75 }

## ◆ SetLabel() [1/2]

virtual void impeller::Texture::SetLabel | ( | std::string_view | label | ) |
| pure virtual

Label this resource for inspection in GPU debugging tools.

This functionality may be disabled in release builds.

## ◆ SetLabel() [2/2]

virtual void impeller::Texture::SetLabel | ( | std::string_view | label,
|  | std::string_view | trailing
| ) |  |
| pure virtual

Label this resource for inspection in GPU debugging tools, with label and trailing will be concatenated together.

This functionality may be disabled in release builds.

## Member Data Documentation

## ◆ mipmap_generated_

bool impeller::Texture::mipmap_generated_ = false
| protected

Definition at line 79 of file texture.h.

Referenced by impeller::TextureMTL::GenerateMipmap(), impeller::TextureGLES::GenerateMipmap(), NeedsMipmapGeneration(), and impeller::TextureVK::SetMipMapGenerated().

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

- impeller/core/texture.h
- impeller/core/texture.cc

impeller::Texture::GetTextureDescriptor
const TextureDescriptor & GetTextureDescriptor() const
Definition: texture.cc:57
impeller::TextureDescriptor::mip_count
size_t mip_count
Definition: texture_descriptor.h:43
impeller::TextureCoordinateSystem::kUploadFromHost
@ kUploadFromHost
impeller::Texture::mipmap_generated_
bool mipmap_generated_
Definition: texture.h:79
VALIDATION_LOG
#define VALIDATION_LOG
Definition: validation.h:91
impeller::Texture::OnSetContents
virtual bool OnSetContents(const uint8_t *contents, size_t length, size_t slice)=0