Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | List of all members
impeller::BlitCopyTextureToBufferCommandMTL Struct Reference

#include <blit_command_mtl.h>

Inheritance diagram for impeller::BlitCopyTextureToBufferCommandMTL:
impeller::BlitCopyTextureToBufferCommand impeller::BlitEncodeMTL impeller::BlitCommand impeller::BackendCast< BlitEncodeMTL, BlitCommand >

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 BlitEncodeMTLCast (BlitCommand &base)
 
static const BlitEncodeMTLCast (const BlitCommand &base)
 
static BlitEncodeMTLCast (BlitCommand *base)
 
static const BlitEncodeMTLCast (const BlitCommand *base)
 
- Public Attributes inherited from impeller::BlitCopyTextureToBufferCommand
std::shared_ptr< Texturesource
 
std::shared_ptr< DeviceBufferdestination
 
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 ( )
overridedefault

Member Function Documentation

◆ Encode()

bool impeller::BlitCopyTextureToBufferCommandMTL::Encode ( id< MTLBlitCommandEncoder >  encoder) const
overridevirtual

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};
static TextureMTL & Cast(Texture &base)
id< MTLBuffer > GetMTLBuffer() const
id< MTLTexture > GetMTLTexture() const
constexpr size_t BytesPerPixelForPixelFormat(PixelFormat format)
Definition formats.h:448
std::shared_ptr< Texture > source
constexpr Type GetY() const
Returns the Y coordinate of the upper left corner, equivalent to |GetOrigin().y|.
Definition rect.h:304
constexpr Type GetHeight() const
Returns the height of the rectangle, equivalent to |GetSize().height|.
Definition rect.h:314
constexpr Type GetX() const
Returns the X coordinate of the upper left corner, equivalent to |GetOrigin().x|.
Definition rect.h:300
constexpr Type GetWidth() const
Returns the width of the rectangle, equivalent to |GetSize().width|.
Definition rect.h:308

◆ GetLabel()

std::string impeller::BlitCopyTextureToBufferCommandMTL::GetLabel ( ) const
overridevirtual

Implements impeller::BlitEncodeMTL.

Definition at line 56 of file blit_command_mtl.mm.

56 {
57 return label;
58}

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