Flutter Engine
The Flutter Engine
Public Member Functions | List of all members
impeller::BlitCopyTextureToBufferCommandGLES Struct Reference

#include <blit_command_gles.h>

Inheritance diagram for impeller::BlitCopyTextureToBufferCommandGLES:
impeller::BlitEncodeGLES impeller::BlitCopyTextureToBufferCommand impeller::BackendCast< BlitEncodeGLES, BlitCommand > impeller::BlitCommand

Public Member Functions

 ~BlitCopyTextureToBufferCommandGLES () override
 
std::string GetLabel () const override
 
bool Encode (const ReactorGLES &reactor) const override
 
- Public Member Functions inherited from impeller::BlitEncodeGLES
virtual ~BlitEncodeGLES ()
 
virtual std::string GetLabel () const =0
 
virtual bool Encode (const ReactorGLES &reactor) const =0
 

Additional Inherited Members

- Static Public Member Functions inherited from impeller::BackendCast< BlitEncodeGLES, BlitCommand >
static BlitEncodeGLESCast (BlitCommand &base)
 
static const BlitEncodeGLESCast (const BlitCommand &base)
 
static BlitEncodeGLESCast (BlitCommand *base)
 
static const BlitEncodeGLESCast (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 43 of file blit_command_gles.h.

Constructor & Destructor Documentation

◆ ~BlitCopyTextureToBufferCommandGLES()

impeller::BlitCopyTextureToBufferCommandGLES::~BlitCopyTextureToBufferCommandGLES ( )
overridedefault

Member Function Documentation

◆ Encode()

bool impeller::BlitCopyTextureToBufferCommandGLES::Encode ( const ReactorGLES reactor) const
overridevirtual

Implements impeller::BlitEncodeGLES.

Definition at line 310 of file blit_command_gles.cc.

311 {
312 if (source->GetTextureDescriptor().format != PixelFormat::kR8G8B8A8UNormInt) {
313 VALIDATION_LOG << "Only textures with pixel format RGBA are supported yet.";
314 return false;
315 }
316
317 const auto& gl = reactor.GetProcTable();
318
319 GLuint read_fbo = GL_NONE;
320 fml::ScopedCleanupClosure delete_fbos(
321 [&gl, &read_fbo]() { DeleteFBO(gl, read_fbo, GL_READ_FRAMEBUFFER); });
322
323 {
324 auto read = ConfigureFBO(gl, source, GL_READ_FRAMEBUFFER);
325 if (!read.has_value()) {
326 return false;
327 }
328 read_fbo = read.value();
329 }
330
332 .UpdateBufferData([&gl, this](uint8_t* data, size_t length) {
333 gl.ReadPixels(source_region.GetX(), source_region.GetY(),
335 GL_RGBA, GL_UNSIGNED_BYTE, data + destination_offset);
336 });
337
338 return true;
339};
static bool read(SkStream *stream, void *buffer, size_t amount)
Wraps a closure that is invoked in the destructor unless released by the caller.
Definition: closure.h:32
static DeviceBufferGLES & Cast(DeviceBuffer &base)
Definition: backend_cast.h:13
void UpdateBufferData(const std::function< void(uint8_t *, size_t length)> &update_buffer_data)
size_t length
static std::optional< GLuint > ConfigureFBO(const ProcTableGLES &gl, const std::shared_ptr< Texture > &texture, GLenum fbo_type)
static void DeleteFBO(const ProcTableGLES &gl, GLuint fbo, GLenum type)
gl
Definition: malisc.py:41
std::shared_ptr< DeviceBuffer > destination
Definition: blit_command.h:27
std::shared_ptr< Texture > source
Definition: blit_command.h:26
constexpr Type GetY() const
Returns the Y coordinate of the upper left corner, equivalent to |GetOrigin().y|.
Definition: rect.h:327
constexpr Type GetHeight() const
Returns the height of the rectangle, equivalent to |GetSize().height|.
Definition: rect.h:337
constexpr Type GetX() const
Returns the X coordinate of the upper left corner, equivalent to |GetOrigin().x|.
Definition: rect.h:323
constexpr Type GetWidth() const
Returns the width of the rectangle, equivalent to |GetSize().width|.
Definition: rect.h:331
std::shared_ptr< const fml::Mapping > data
Definition: texture_gles.cc:63
#define VALIDATION_LOG
Definition: validation.h:73

◆ GetLabel()

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

Implements impeller::BlitEncodeGLES.

Definition at line 306 of file blit_command_gles.cc.

306 {
307 return label;
308}

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