Flutter Engine Uber Docs
Docs for the entire Flutter Engine repo.
 
Loading...
Searching...
No Matches
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. If error is not NULL, *error must be initialized (typically NULL, but an error from a previous call using GLib error handling is explicitly valid).

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. If `error` is not %NULL, `*error` must be initialized
97 * (typically %NULL, but an error from a previous call using GLib error
98 * handling is explicitly valid).
99 *
100 * Retrieve pixel buffer in RGBA format.
101 *
102 * As this method is usually invoked from the render thread, you must
103 * take care of proper synchronization. It also needs to be ensured that
104 * the returned buffer is not released prior to unregistering this texture.
105 *
106 * Returns: %TRUE on success.
107 */
108 gboolean (*copy_pixels)(FlPixelBufferTexture* texture,
109 const uint8_t** buffer,
110 uint32_t* width,
111 uint32_t* height,
112 GError** error);
113};
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 disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set profile Make the profiler discard new samples once the profiler sample buffer is full When this flag is not the profiler sample buffer is used as a ring buffer
Definition switch_defs.h:98
int32_t height
int32_t width

References error, height, texture, and width.