Flutter Engine Uber Docs
Docs for the entire Flutter Engine repo.
 
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 284 of file blit_command_gles.cc.

285 {
286 const auto& gl = reactor.GetProcTable();
287
288 PixelFormat source_format = source->GetTextureDescriptor().format;
289 std::optional<PixelFormatGLES> gles_format =
290 ToPixelFormatGLES(source_format,
291 /*supports_bgra=*/
292 reactor.GetProcTable().GetDescription()->HasExtension(
293 "GL_EXT_texture_format_BGRA8888"));
294
295 if (!gles_format.has_value()) {
296 VALIDATION_LOG << "Texture has unsupported pixel format.";
297 return false;
298 }
299
300 GLuint read_fbo = GL_NONE;
301 fml::ScopedCleanupClosure delete_fbos(
302 [&gl, &read_fbo]() { DeleteFBO(gl, read_fbo, GL_FRAMEBUFFER); });
303
304 {
305 auto read = ConfigureFBO(gl, source, GL_FRAMEBUFFER);
306 if (!read.has_value()) {
307 return false;
308 }
309 read_fbo = read.value();
310 }
311
313 .UpdateBufferData([&gl, //
314 this, //
315 format = gles_format->external_format, //
316 type = gles_format->type //
317 ](uint8_t* data, size_t length) {
318 gl.ReadPixels(source_region.GetX(), source_region.GetY(),
319 source_region.GetWidth(), source_region.GetHeight(),
320 format, type, data + destination_offset);
321 });
322
323 return true;
324};
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
std::optional< PixelFormatGLES > ToPixelFormatGLES(PixelFormat pixel_format, bool supports_bgra)
static std::optional< GLuint > ConfigureFBO(const ProcTableGLES &gl, const std::shared_ptr< Texture > &texture, GLenum fbo_type)
PixelFormat
The Pixel formats supported by Impeller. The naming convention denotes the usage of the component,...
Definition formats.h:99
static void DeleteFBO(const ProcTableGLES &gl, GLuint fbo, GLenum type)
std::shared_ptr< ReactorGLES > reactor
impeller::ShaderType type
std::shared_ptr< DeviceBuffer > destination
std::shared_ptr< Texture > source
#define VALIDATION_LOG
Definition validation.h:91

References impeller::BackendCast< DeviceBufferGLES, DeviceBuffer >::Cast(), impeller::ConfigureFBO(), impeller::DeleteFBO(), impeller::BlitCopyTextureToBufferCommand::destination, format, length, reactor, impeller::BlitCopyTextureToBufferCommand::source, impeller::ToPixelFormatGLES(), type, impeller::DeviceBufferGLES::UpdateBufferData(), and VALIDATION_LOG.

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

◆ GetLabel()

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

Implements impeller::BlitEncodeGLES.

Definition at line 280 of file blit_command_gles.cc.

280 {
281 return label;
282}

References impeller::BlitCommand::label.


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