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

276 {
277 const auto& gl = reactor.GetProcTable();
278
279 PixelFormat source_format = source->GetTextureDescriptor().format;
280 std::optional<PixelFormatGLES> gles_format =
281 ToPixelFormatGLES(source_format,
282 /*supports_bgra=*/
283 reactor.GetProcTable().GetDescription()->HasExtension(
284 "GL_EXT_texture_format_BGRA8888"));
285
286 if (!gles_format.has_value()) {
287 VALIDATION_LOG << "Texture has unsupported pixel format.";
288 return false;
289 }
290
291 TextureCoordinateSystem coord_system = source->GetCoordinateSystem();
292
293 GLuint read_fbo = GL_NONE;
294 fml::ScopedCleanupClosure delete_fbos(
295 [&gl, &read_fbo]() { DeleteFBO(gl, read_fbo, GL_FRAMEBUFFER); });
296
297 {
298 auto read = ConfigureFBO(gl, source, GL_FRAMEBUFFER);
299 if (!read.has_value()) {
300 return false;
301 }
302 read_fbo = read.value();
303 }
304
307 [&gl, //
308 this, //
309 format = gles_format->external_format, //
310 type = gles_format->type, //
311 coord_system, //
312 bytes_per_pixel = BytesPerPixelForPixelFormat(source_format) //
313 ](uint8_t* data, size_t length) {
314 gl.ReadPixels(source_region.GetX(), source_region.GetY(),
316 format, type, data + destination_offset);
317 switch (coord_system) {
319 break;
321 // The texture is upside down, and must be inverted when copying
322 // byte data out.
323 FlipImage(data + destination_offset, source_region.GetWidth(),
324 source_region.GetHeight(), bytes_per_pixel);
325 }
326 });
327
328 return true;
329};
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
constexpr size_t BytesPerPixelForPixelFormat(PixelFormat format)
Definition formats.h:469
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)
TextureCoordinateSystem
Definition formats.h:330
impeller::ShaderType type
std::shared_ptr< DeviceBuffer > destination
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:371
constexpr Type GetHeight() const
Returns the height of the rectangle, equivalent to |GetSize().height|.
Definition rect.h:381
constexpr Type GetX() const
Returns the X coordinate of the upper left corner, equivalent to |GetOrigin().x|.
Definition rect.h:367
constexpr Type GetWidth() const
Returns the width of the rectangle, equivalent to |GetSize().width|.
Definition rect.h:375
#define VALIDATION_LOG
Definition validation.h:91

References impeller::BytesPerPixelForPixelFormat(), impeller::BackendCast< DeviceBufferGLES, DeviceBuffer >::Cast(), impeller::ConfigureFBO(), impeller::DeleteFBO(), impeller::BlitCopyTextureToBufferCommand::destination, impeller::BlitCopyTextureToBufferCommand::destination_offset, format, impeller::ProcTableGLES::GetDescription(), impeller::TRect< T >::GetHeight(), impeller::ReactorGLES::GetProcTable(), impeller::TRect< T >::GetWidth(), impeller::TRect< T >::GetX(), impeller::TRect< T >::GetY(), impeller::DescriptionGLES::HasExtension(), impeller::kRenderToTexture, impeller::kUploadFromHost, length, impeller::BlitCopyTextureToBufferCommand::source, impeller::BlitCopyTextureToBufferCommand::source_region, 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 271 of file blit_command_gles.cc.

271 {
272 return label;
273}

References impeller::BlitCommand::label.


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