Flutter Engine
The Flutter Engine
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
fl_pixel_buffer_texture.h
Go to the documentation of this file.
1// Copyright 2013 The Flutter Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef FLUTTER_SHELL_PLATFORM_LINUX_PUBLIC_FLUTTER_LINUX_FL_PIXEL_BUFFER_TEXTURE_H_
6#define FLUTTER_SHELL_PLATFORM_LINUX_PUBLIC_FLUTTER_LINUX_FL_PIXEL_BUFFER_TEXTURE_H_
7
8#if !defined(__FLUTTER_LINUX_INSIDE__) && !defined(FLUTTER_LINUX_COMPILATION)
9#error "Only <flutter_linux/flutter_linux.h> can be included directly."
10#endif
11
12#include <gmodule.h>
13
14#include "fl_texture.h"
15
16G_BEGIN_DECLS
17
18G_MODULE_EXPORT
19G_DECLARE_DERIVABLE_TYPE(FlPixelBufferTexture,
20 fl_pixel_buffer_texture,
21 FL,
22 PIXEL_BUFFER_TEXTURE,
23 GObject)
24
25/**
26 * FlPixelBufferTexture:
27 *
28 * #FlPixelBufferTexture represents an OpenGL texture generated from a pixel
29 * buffer.
30 *
31 * The following example shows how to implement an #FlPixelBufferTexture.
32 * ![<!-- language="C" -->
33 * struct _MyTexture {
34 * FlPixelBufferTexture parent_instance;
35 *
36 * uint8_t *buffer; // your pixel buffer.
37 * }
38 *
39 * G_DEFINE_TYPE(MyTexture,
40 * my_texture,
41 * fl_pixel_buffer_texture_get_type ())
42 *
43 * static gboolean
44 * my_texture_copy_pixels (FlPixelBufferTexture* texture,
45 * const uint8_t** out_buffer,
46 * uint32_t* width,
47 * uint32_t* height,
48 * GError** error) {
49 * // This method is called on Render Thread. Be careful with your
50 * // cross-thread operation.
51 *
52 * // @width and @height are initially stored the canvas size in Flutter.
53 *
54 * // You must prepare your pixel buffer in RGBA format.
55 * // So you may do some format conversion first if your original pixel
56 * // buffer is not in RGBA format.
57 * manage_your_pixel_buffer_here ();
58 *
59 * if (your_operations_are_successfully_finished) {
60 * // Directly return pointer to your pixel buffer here.
61 * // Flutter takes content of your pixel buffer after this function
62 * // is finished. So you must make the buffer live long enough until
63 * // next tick of Render Thread.
64 * // If it is hard to manage lifetime of your pixel buffer, you should
65 * // take look into #FlTextureGL.
66 *
67 * *out_buffer = buffer;
68 * *width = real_width_of_buffer;
69 * *height = real_height_of_buffer;
70 * return TRUE;
71 * } else {
72 * // set @error to report failure.
73 * return FALSE;
74 * }
75 * }
76 *
77 * static void my_texture_class_init(MyTextureClass* klass) {
78 * FL_PIXEL_BUFFER_TEXTURE_CLASS(klass)->copy_pixels =
79 * my_texture_copy_pixels;
80 * }
81 *
82 * static void my_texture_init(MyTexture* self) {}
83 * ]|
84 */
85
86struct _FlPixelBufferTextureClass {
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};
112
113G_END_DECLS
114
115#endif // FLUTTER_SHELL_PLATFORM_LINUX_PUBLIC_FLUTTER_LINUX_FL_PIXEL_BUFFER_TEXTURE_H_
G_BEGIN_DECLS G_MODULE_EXPORT G_DECLARE_DERIVABLE_TYPE(FlPixelBufferTexture, fl_pixel_buffer_texture, FL, PIXEL_BUFFER_TEXTURE, GObject) struct _FlPixelBufferTextureClass
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