Flutter Engine
 
Loading...
Searching...
No Matches
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 ()
 

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 335 of file blit_command_gles.cc.

336 {
337 if (source->GetTextureDescriptor().format != PixelFormat::kR8G8B8A8UNormInt) {
338 VALIDATION_LOG << "Only textures with pixel format RGBA are supported yet.";
339 return false;
340 }
341
342 const auto& gl = reactor.GetProcTable();
343 TextureCoordinateSystem coord_system = source->GetCoordinateSystem();
344
345 GLuint read_fbo = GL_NONE;
346 fml::ScopedCleanupClosure delete_fbos(
347 [&gl, &read_fbo]() { DeleteFBO(gl, read_fbo, GL_FRAMEBUFFER); });
348
349 {
350 auto read = ConfigureFBO(gl, source, GL_FRAMEBUFFER);
351 if (!read.has_value()) {
352 return false;
353 }
354 read_fbo = read.value();
355 }
356
358 .UpdateBufferData([&gl, this, coord_system,
359 rows = source->GetSize().height](uint8_t* data,
360
361 size_t length) {
362 gl.ReadPixels(source_region.GetX(), source_region.GetY(),
363 source_region.GetWidth(), source_region.GetHeight(),
364 GL_RGBA, GL_UNSIGNED_BYTE, data + destination_offset);
365 switch (coord_system) {
366 case TextureCoordinateSystem::kUploadFromHost:
367 break;
368 case TextureCoordinateSystem::kRenderToTexture:
369 // The texture is upside down, and must be inverted when copying
370 // byte data out.
371 FlipImage(data + destination_offset, source_region.GetWidth(),
372 source_region.GetHeight(), 4);
373 }
374 });
375
376 return true;
377};
Wraps a closure that is invoked in the destructor unless released by the caller.
Definition closure.h:32
static DeviceBufferGLES & Cast(DeviceBuffer &base)
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)
TextureCoordinateSystem
Definition formats.h:327
std::shared_ptr< DeviceBuffer > destination
std::shared_ptr< Texture > source
std::shared_ptr< const fml::Mapping > data
#define VALIDATION_LOG
Definition validation.h:91

References impeller::BackendCast< DeviceBufferGLES, DeviceBuffer >::Cast(), impeller::ConfigureFBO(), data, impeller::DeleteFBO(), impeller::BlitCopyTextureToBufferCommand::destination, impeller::ReactorGLES::GetProcTable(), impeller::kR8G8B8A8UNormInt, length, impeller::BlitCopyTextureToBufferCommand::source, impeller::DeviceBufferGLES::UpdateBufferData(), and VALIDATION_LOG.

Referenced by impeller::testing::TEST().

◆ GetLabel()

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

Implements impeller::BlitEncodeGLES.

Definition at line 331 of file blit_command_gles.cc.

331 {
332 return label;
333}

References impeller::BlitCommand::label.


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