| 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 34 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.origin.x, source_region.origin.y, 0);
74 auto source_size_mtl =
75 MTLSizeMake(source_region.size.width, source_region.size.height, 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, Buffer >::Cast(), impeller::BlitCopyTextureToBufferCommand::destination_offset, impeller::DeviceBufferMTL::GetMTLBuffer(), impeller::TextureMTL::GetMTLTexture(), impeller::TSize< T >::height, impeller::TRect< T >::origin, impeller::TRect< T >::size, impeller::BlitCopyTextureToBufferCommand::source, impeller::BlitCopyTextureToBufferCommand::source_region, impeller::TSize< T >::width, impeller::TPoint< T >::x, and impeller::TPoint< T >::y.

## ◆ 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::TRect::size
TSize< Type > size
Definition: rect.h:24
impeller::TPoint::y
Type y
Definition: point.h:24
impeller::TextureMTL::GetMTLTexture
id< MTLTexture > GetMTLTexture() const
Definition: texture_mtl.mm:100
impeller::BlitCommand::label
std::string label
Definition: blit_command.h:14
impeller::BytesPerPixelForPixelFormat
constexpr size_t BytesPerPixelForPixelFormat(PixelFormat format)
Definition: formats.h:399
impeller::BlitCopyTextureToBufferCommand::destination_offset
size_t destination_offset
Definition: blit_command.h:28
impeller::TRect::origin
TPoint< Type > origin
Definition: rect.h:23
impeller::TSize::width
Type width
Definition: size.h:21
impeller::TPoint::x
Type x
Definition: point.h:23
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:14
impeller::BlitCopyTextureToBufferCommand::source
std::shared_ptr< Texture > source
Definition: blit_command.h:25
impeller::TSize::height
Type height
Definition: size.h:22
impeller::BlitCopyTextureToBufferCommand::source_region
IRect source_region
Definition: blit_command.h:27