Flutter Engine
The Flutter Engine
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};
const uint8_t uint32_t uint32_t GError ** error
FlTexture * texture
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace buffer
Definition: switches.h:126
int32_t height
int32_t width