| Flutter Impeller |

Public Member Functions | List of all members
impeller::BlitCopyTextureToBufferCommandMTL Struct Reference

`#include <blit_command_mtl.h>`

Inheritance diagram for impeller::BlitCopyTextureToBufferCommandMTL:

## Public Member Functions
| ~BlitCopyTextureToBufferCommandMTL () override
std::string | GetLabel () const override
bool | Encode (id< MTLBlitCommandEncoder > encoder) const override
Public Member Functions inherited from impeller::BlitEncodeMTL
virtual | ~BlitEncodeMTL ()

## Additional Inherited Members
Static Public Member Functions inherited from impeller::BackendCast< BlitEncodeMTL, BlitCommand >
static BlitEncodeMTL & | Cast (BlitCommand &base)
static const BlitEncodeMTL & | Cast (const BlitCommand &base)
static BlitEncodeMTL * | Cast (BlitCommand *base)
static const BlitEncodeMTL * | Cast (const BlitCommand *base)
Public Attributes inherited from impeller::BlitCopyTextureToBufferCommand
std::shared_ptr< Texture > | source
std::shared_ptr< DeviceBuffer > | destination
IRect | source_region
size_t | destination_offset
Public Attributes inherited from impeller::BlitCommand
std::string | label

## Detailed Description

Definition at line 35 of file blit_command_mtl.h.

## Constructor & Destructor Documentation

## ◆ ~BlitCopyTextureToBufferCommandMTL()

impeller::BlitCopyTextureToBufferCommandMTL::~BlitCopyTextureToBufferCommandMTL | ( |  | ) |
| override default

## Member Function Documentation

## ◆ Encode()

bool impeller::BlitCopyTextureToBufferCommandMTL::Encode | ( | id< MTLBlitCommandEncoder > | encoder | ) | const
| override virtual

Implements impeller::BlitEncodeMTL.

Definition at line 60 of file blit_command_mtl.mm.

61 {
62 auto source_mtl = TextureMTL::Cast(*source).GetMTLTexture();
63 if (!source_mtl) {
64 return false;
65 }
66
67 auto destination_mtl = DeviceBufferMTL::Cast(*destination).GetMTLBuffer();
68 if (!destination_mtl) {
69 return false;
70 }
71
72 auto source_origin_mtl =
73 MTLOriginMake(source_region.GetX(), source_region.GetY(), 0);
74 auto source_size_mtl =
75 MTLSizeMake(source_region.GetWidth(), source_region.GetHeight(), 1);
76
77 auto destination_bytes_per_pixel =
78 BytesPerPixelForPixelFormat(source->GetTextureDescriptor().format);
79 auto destination_bytes_per_row =
80 source_size_mtl.width * destination_bytes_per_pixel;
81 auto destination_bytes_per_image =
82 source_size_mtl.height * destination_bytes_per_row;
83
84 [encoder copyFromTexture:source_mtl
85 sourceSlice:0
86 sourceLevel:0
87 sourceOrigin:source_origin_mtl
88 sourceSize:source_size_mtl
89 toBuffer:destination_mtl
90 destinationOffset:destination_offset
91 destinationBytesPerRow:destination_bytes_per_row
92 destinationBytesPerImage:destination_bytes_per_image];
93
94 return true;
95 };

References impeller::BytesPerPixelForPixelFormat(), impeller::BackendCast< TextureMTL, Texture >::Cast(), impeller::BackendCast< DeviceBufferMTL, DeviceBuffer >::Cast(), impeller::BlitCopyTextureToBufferCommand::destination_offset, impeller::TRect< T >::GetHeight(), impeller::DeviceBufferMTL::GetMTLBuffer(), impeller::TextureMTL::GetMTLTexture(), impeller::TRect< T >::GetWidth(), impeller::TRect< T >::GetX(), impeller::TRect< T >::GetY(), impeller::BlitCopyTextureToBufferCommand::source, and impeller::BlitCopyTextureToBufferCommand::source_region.

## ◆ GetLabel()

std::string impeller::BlitCopyTextureToBufferCommandMTL::GetLabel | ( |  | ) | const
| override virtual

Implements impeller::BlitEncodeMTL.

Definition at line 56 of file blit_command_mtl.mm.

56 {
57 return label;
58 }

References impeller::BlitCommand::label.

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

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

impeller::TextureMTL::GetMTLTexture
id< MTLTexture > GetMTLTexture() const
Definition: texture_mtl.mm:116
impeller::TRect::GetX
constexpr Type GetX() const
Returns the X coordinate of the upper left corner, equivalent to |GetOrigin().x|.
Definition: rect.h:300
impeller::TRect::GetHeight
constexpr Type GetHeight() const
Returns the height of the rectangle, equivalent to |GetSize().height|.
Definition: rect.h:314
impeller::BlitCommand::label
std::string label
Definition: blit_command.h:15
impeller::BytesPerPixelForPixelFormat
constexpr size_t BytesPerPixelForPixelFormat(PixelFormat format)
Definition: formats.h:448
impeller::TRect::GetWidth
constexpr Type GetWidth() const
Returns the width of the rectangle, equivalent to |GetSize().width|.
Definition: rect.h:308
impeller::BlitCopyTextureToBufferCommand::destination_offset
size_t destination_offset
Definition: blit_command.h:29
impeller::DeviceBufferMTL::GetMTLBuffer
id< MTLBuffer > GetMTLBuffer() const
Definition: device_buffer_mtl.mm:21
impeller::BackendCast< TextureMTL, Texture >::Cast
static TextureMTL & Cast(Texture &base)
Definition: backend_cast.h:13
impeller::BlitCopyTextureToBufferCommand::source
std::shared_ptr< Texture > source
Definition: blit_command.h:26
impeller::TRect::GetY
constexpr Type GetY() const
Returns the Y coordinate of the upper left corner, equivalent to |GetOrigin().y|.
Definition: rect.h:304
impeller::BlitCopyTextureToBufferCommand::source_region
IRect source_region
Definition: blit_command.h:28