| Flutter Impeller |

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

`#include <blit_command_mtl.h>`

Inheritance diagram for impeller::BlitCopyBufferToTextureCommandMTL:

## Public Member Functions
| ~BlitCopyBufferToTextureCommandMTL () 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::BlitCopyBufferToTextureCommand
BufferView | source
std::shared_ptr< Texture > | destination
IPoint | destination_origin
Public Attributes inherited from impeller::BlitCommand
std::string | label

## Detailed Description

Definition at line 53 of file blit_command_mtl.h.

## Constructor & Destructor Documentation

## ◆ ~BlitCopyBufferToTextureCommandMTL()

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

## Member Function Documentation

## ◆ Encode()

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

Implements impeller::BlitEncodeMTL.

Definition at line 104 of file blit_command_mtl.mm.

105 {
106 auto source_mtl = DeviceBufferMTL::Cast(*source.buffer).GetMTLBuffer();
107 if (!source_mtl) {
108 return false;
109 }
110
111 auto destination_mtl = TextureMTL::Cast(*destination).GetMTLTexture();
112 if (!destination_mtl) {
113 return false;
114 }
115
116 auto destination_origin_mtl =
117 MTLOriginMake(destination_origin.x, destination_origin.y, 0);
118
119 auto image_size = destination->GetTextureDescriptor().size;
120 auto source_size_mtl = MTLSizeMake(image_size.width, image_size.height, 1);
121
122 auto destination_bytes_per_pixel =
123 BytesPerPixelForPixelFormat(destination->GetTextureDescriptor().format);
124 auto destination_bytes_per_row =
125 source_size_mtl.width * destination_bytes_per_pixel;
126 auto destination_bytes_per_image =
127 source_size_mtl.height * destination_bytes_per_row;
128
129 [encoder copyFromBuffer:source_mtl
130 sourceOffset:source.range.offset
131 sourceBytesPerRow:destination_bytes_per_row
132 sourceBytesPerImage:destination_bytes_per_image
133 sourceSize:source_size_mtl
134 toTexture:destination_mtl
135 destinationSlice:0
136 destinationLevel:0
137 destinationOrigin:destination_origin_mtl];
138
139 return true;
140 };

References impeller::BufferView::buffer, impeller::BytesPerPixelForPixelFormat(), impeller::BackendCast< TextureMTL, Texture >::Cast(), impeller::BackendCast< DeviceBufferMTL, Buffer >::Cast(), impeller::BlitCopyBufferToTextureCommand::destination, impeller::BlitCopyBufferToTextureCommand::destination_origin, impeller::DeviceBufferMTL::GetMTLBuffer(), impeller::TextureMTL::GetMTLTexture(), impeller::Range::offset, impeller::BufferView::range, impeller::BlitCopyBufferToTextureCommand::source, impeller::TPoint< T >::x, and impeller::TPoint< T >::y.

## ◆ GetLabel()

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

Implements impeller::BlitEncodeMTL.

Definition at line 100 of file blit_command_mtl.mm.

100 {
101 return label;
102 }

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::TPoint::y
Type y
Definition: point.h:24
impeller::Range::offset
size_t offset
Definition: range.h:14
impeller::TextureMTL::GetMTLTexture
id< MTLTexture > GetMTLTexture() const
Definition: texture_mtl.mm:100
impeller::BufferView::range
Range range
Definition: buffer_view.h:16
impeller::BlitCommand::label
std::string label
Definition: blit_command.h:14
impeller::BlitCopyBufferToTextureCommand::source
BufferView source
Definition: blit_command.h:32
impeller::BytesPerPixelForPixelFormat
constexpr size_t BytesPerPixelForPixelFormat(PixelFormat format)
Definition: formats.h:399
impeller::BufferView::buffer
std::shared_ptr< const Buffer > buffer
Definition: buffer_view.h:14
impeller::TPoint::x
Type x
Definition: point.h:23
impeller::DeviceBufferMTL::GetMTLBuffer
id< MTLBuffer > GetMTLBuffer() const
Definition: device_buffer_mtl.mm:21
impeller::BackendCast< DeviceBufferMTL, Buffer >::Cast
static DeviceBufferMTL & Cast(Buffer &base)
Definition: backend_cast.h:14
impeller::BlitCopyBufferToTextureCommand::destination_origin
IPoint destination_origin
Definition: blit_command.h:34
impeller::BlitCopyBufferToTextureCommand::destination
std::shared_ptr< Texture > destination
Definition: blit_command.h:33