| Flutter Impeller |

Public Types | Public Member Functions | Static Public Member Functions | List of all members
impeller::TextureMTL Class Referencefinal

`#include <texture_mtl.h>`

Inheritance diagram for impeller::TextureMTL:

## Public Types
using | AcquireTextureProc = std::function< id< MTLTexture >()>
| This callback needs to always return the same texture when called multiple times. More...

## Public Member Functions
| TextureMTL (TextureDescriptor desc, const AcquireTextureProc &aquire_proc, bool wrapped=false, bool drawable=false)
| ~TextureMTL () override
id< MTLTexture > | GetMTLTexture () const
bool | IsWrapped () const
bool | IsDrawable () const
| Whether or not this texture is wrapping a Metal drawable. More...
bool | IsValid () const override
bool | GenerateMipmap (id< MTLBlitCommandEncoder > encoder)
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
virtual Scalar | GetYCoordScale () const
bool | NeedsMipmapGeneration () const

## Static Public Member Functions
static std::shared_ptr< TextureMTL > | Wrapper (TextureDescriptor desc, id< MTLTexture > texture, std::function< void()> deletion_proc=nullptr)
static std::shared_ptr< TextureMTL > | Create (TextureDescriptor desc, id< MTLTexture > texture)
Static Public Member Functions inherited from impeller::BackendCast< TextureMTL, Texture >
static TextureMTL & | Cast (Texture &base)
static const TextureMTL & | Cast (const Texture &base)
static TextureMTL * | Cast (Texture *base)
static const TextureMTL * | 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 16 of file texture_mtl.h.

## Member Typedef Documentation

## ◆ AcquireTextureProc

using impeller::TextureMTL::AcquireTextureProc = std::function<id<MTLTexture>()>

This callback needs to always return the same texture when called multiple times.

Definition at line 21 of file texture_mtl.h.

## Constructor & Destructor Documentation

## ◆ TextureMTL()

impeller::TextureMTL::TextureMTL | ( | TextureDescriptor | desc,
|  | const AcquireTextureProc & | aquire_proc,
|  | bool | wrapped = `false`,
|  | bool | drawable = `false`
| ) |  |

Definition at line 22 of file texture_mtl.mm.

26 : Texture(p_desc), aquire_proc_(aquire_proc), is_drawable_(drawable) {
27 const auto& desc = GetTextureDescriptor();
28
29 if (!desc.IsValid() || !aquire_proc) {
30 return;
31 }
32
33 if (desc.size != GetSize()) {
34 VALIDATION_LOG << "The texture and its descriptor disagree about its size.";
35 return;
36 }
37
38 is_wrapped_ = wrapped;
39 is_valid_ = true;
40 }
impeller::Texture::GetTextureDescriptor
const TextureDescriptor & GetTextureDescriptor() const
Definition: texture.cc:57
impeller::Texture::Texture
Texture(TextureDescriptor desc)
Definition: texture.cc:11
VALIDATION_LOG
#define VALIDATION_LOG
Definition: validation.h:91

References impeller::Texture::GetTextureDescriptor(), impeller::TextureDescriptor::IsValid(), impeller::TextureDescriptor::size, and VALIDATION_LOG.

Referenced by Wrapper().

## ◆ ~TextureMTL()

impeller::TextureMTL::~TextureMTL | ( |  | ) |
| override

Definition at line 64 of file texture_mtl.mm.

64 {
65 #ifdef IMPELLER_DEBUG
66 if (debug_allocator_) {
67 auto desc = GetTextureDescriptor();
68 if (desc.storage_mode == StorageMode::kDeviceTransient) {
69 return;
70 }
71 debug_allocator_->Decrement(desc.GetByteSizeOfBaseMipLevel());
72 }
73 #endif // IMPELLER_DEBUG
74 }
impeller::StorageMode::kDeviceTransient
@ kDeviceTransient

References impeller::TextureDescriptor::GetByteSizeOfBaseMipLevel(), impeller::Texture::GetTextureDescriptor(), impeller::kDeviceTransient, and impeller::TextureDescriptor::storage_mode.

## Member Function Documentation

## ◆ Create()

std::shared_ptr< TextureMTL > impeller::TextureMTL::Create | ( | TextureDescriptor | desc,
|  | id< MTLTexture > | texture
| ) |  |
| static

Definition at line 59 of file texture_mtl.mm.

60 {
61 return std::make_shared<TextureMTL>(desc, [texture]() { return texture; });
62 }

Referenced by impeller::WrapTextureWithRenderTarget().

## ◆ GenerateMipmap()

bool impeller::TextureMTL::GenerateMipmap | ( | id< MTLBlitCommandEncoder > | encoder | ) |

Definition at line 163 of file texture_mtl.mm.

163 {
164 if (is_drawable_) {
165 return false;
166 }
167
168 auto texture = aquire_proc_();
169 if (!texture) {
170 return false;
171 }
172
173 [encoder generateMipmapsForTexture:texture];
174 mipmap_generated_ = true;
175
176 return true;
177 }
impeller::Texture::mipmap_generated_
bool mipmap_generated_
Definition: texture.h:79

References impeller::Texture::mipmap_generated_.

## ◆ GetMTLTexture()

id< MTLTexture > impeller::TextureMTL::GetMTLTexture | ( |  | ) | const

Definition at line 147 of file texture_mtl.mm.

147 {
148 return aquire_proc_();
149 }

Referenced by impeller::ConfigureAttachment(), and impeller::ConfigureResolveTextureAttachment().

## ◆ IsDrawable()

bool impeller::TextureMTL::IsDrawable | ( |  | ) | const

Whether or not this texture is wrapping a Metal drawable.

Definition at line 159 of file texture_mtl.mm.

159 {
160 return is_drawable_;
161 }

## ◆ IsValid()

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

Implements impeller::Texture.

Definition at line 151 of file texture_mtl.mm.

151 {
152 return is_valid_;
153 }

## ◆ IsWrapped()

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

Definition at line 155 of file texture_mtl.mm.

155 {
156 return is_wrapped_;
157 }

## ◆ Wrapper()

std::shared_ptr< TextureMTL > impeller::TextureMTL::Wrapper | ( | TextureDescriptor | desc,
|  | id< MTLTexture > | texture,
|  | std::function< void()> | deletion_proc = `nullptr`
| ) |  |
| static

Definition at line 42 of file texture_mtl.mm.

45 {
46 if (deletion_proc) {
47 return std::shared_ptr<TextureMTL>(
48 new TextureMTL(
49 desc, [texture]() { return texture; }, true),
50 [deletion_proc = std::move(deletion_proc)](TextureMTL* t) {
51 deletion_proc();
52 delete t;
53 });
54 }
55 return std::shared_ptr<TextureMTL>(
56 new TextureMTL(desc, [texture]() { return texture; }, true));
57 }
impeller::TextureMTL::TextureMTL
TextureMTL(TextureDescriptor desc, const AcquireTextureProc &aquire_proc, bool wrapped=false, bool drawable=false)
Definition: texture_mtl.mm:22

References TextureMTL().

Referenced by impeller::SurfaceMTL::MakeFromTexture(), impeller::WrapperMTL(), and impeller::WrapTextureMTL().

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

- impeller/renderer/backend/metal/texture_mtl.h
- impeller/renderer/backend/metal/texture_mtl.mm