| Flutter Linux Embedder |

Functions
fl_pixel_buffer_texture.h File Reference
`#include <gmodule.h>`
`#include "fl_texture.h"`

Go to the source code of this file.

## Functions
G_BEGIN_DECLS G_MODULE_EXPORT | G_DECLARE_DERIVABLE_TYPE (FlPixelBufferTexture, fl_pixel_buffer_texture, FL, PIXEL_BUFFER_TEXTURE, GObject) struct _FlPixelBufferTextureClass

## Function Documentation

## ◆ G_DECLARE_DERIVABLE_TYPE()

G_BEGIN_DECLS G_MODULE_EXPORT G_DECLARE_DERIVABLE_TYPE | ( | FlPixelBufferTexture | ,
|  | fl_pixel_buffer_texture | ,
|  | FL | ,
|  | PIXEL_BUFFER_TEXTURE | ,
|  | GObject |
| ) |  |

FlPixelBufferTexture:

#FlPixelBufferTexture represents an OpenGL texture generated from a pixel buffer.

The following example shows how to implement an #FlPixelBufferTexture. ![ struct _MyTexture { FlPixelBufferTexture parent_instance;

uint8_t *buffer; // your pixel buffer. }

G_DEFINE_TYPE(MyTexture, my_texture, fl_pixel_buffer_texture_get_type ())

static gboolean my_texture_copy_pixels (FlPixelBufferTexture* texture, const uint8_t** out_buffer, uint32_t* width, uint32_t* height, GError** error) { // This method is called on Render Thread. Be careful with your // cross-thread operation.

// @width and @height are initially stored the canvas size in Flutter.

// You must prepare your pixel buffer in RGBA format. // So you may do some format conversion first if your original pixel // buffer is not in RGBA format. manage_your_pixel_buffer_here ();

if (your_operations_are_successfully_finished) { // Directly return pointer to your pixel buffer here. // Flutter takes content of your pixel buffer after this function // is finished. So you must make the buffer live long enough until // next tick of Render Thread. // If it is hard to manage lifetime of your pixel buffer, you should // take look into #FlTextureGL.

*out_buffer = buffer; *width = real_width_of_buffer; *height = real_height_of_buffer; return TRUE; } else { // set @error to report failure. return FALSE; } }

static void my_texture_class_init(MyTextureClass* klass) { FL_PIXEL_BUFFER_TEXTURE_CLASS(klass)->copy_pixels = my_texture_copy_pixels; }

static void my_texture_init(MyTexture* self) {} ]|

FlPixelBufferTexture::copy_pixels: @texture: an #FlPixelBufferTexture. @buffer: (out): pixel data. @width: (inout): width of the texture in pixels. @height: (inout): height of the texture in pixels. @error: (allow-none): #GError location to store the error occurring, or NULL to ignore.

Retrieve pixel buffer in RGBA format.

As this method is usually invoked from the render thread, you must take care of proper synchronization. It also needs to be ensured that the returned buffer is not released prior to unregistering this texture.

Returns: TRUE on success.

Definition at line 19 of file fl_pixel_buffer_texture.h.

86 {
87 GObjectClass parent_class;
88
89 /**
90 * FlPixelBufferTexture::copy_pixels:
91 * @texture: an #FlPixelBufferTexture.
92 * @buffer: (out): pixel data.
93 * @width: (inout): width of the texture in pixels.
94 * @height: (inout): height of the texture in pixels.
95 * @error: (allow-none): #GError location to store the error occurring, or
96 * %NULL to ignore.
97 *
98 * Retrieve pixel buffer in RGBA format.
99 *
100 * As this method is usually invoked from the render thread, you must
101 * take care of proper synchronization. It also needs to be ensured that
102 * the returned buffer is not released prior to unregistering this texture.
103 *
104 * Returns: %TRUE on success.
105 */
106 gboolean (*copy_pixels)(FlPixelBufferTexture* texture,
107 const uint8_t** buffer,
108 uint32_t* width,
109 uint32_t* height,
110 GError** error);
111 };
height
self height
Definition: fl_compositor_software.cc:43
width
self width
Definition: fl_compositor_software.cc:42
buffer
static const uint8_t buffer[]
Definition: fl_pixel_buffer_texture_test.cc:44
error
const uint8_t uint32_t uint32_t GError ** error
Definition: fl_pixel_buffer_texture_test.cc:40

References buffer, error, height, and width.