Flutter Engine
The Flutter Engine
flutter_texture_registrar.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_COMMON_PUBLIC_FLUTTER_TEXTURE_REGISTRAR_H_
6#define FLUTTER_SHELL_PLATFORM_COMMON_PUBLIC_FLUTTER_TEXTURE_REGISTRAR_H_
7
8#include <stddef.h>
9#include <stdint.h>
10
11#include "flutter_export.h"
12
13#if defined(__cplusplus)
14extern "C" {
15#endif
16
17struct FlutterDesktopTextureRegistrar;
18// Opaque reference to a texture registrar.
19typedef struct FlutterDesktopTextureRegistrar*
21
22// Possible values for the type specified in FlutterDesktopTextureInfo.
23// Additional types may be added in the future.
24typedef enum {
25 // A Pixel buffer-based texture.
27 // A platform-specific GPU surface-backed texture.
30
31// Supported GPU surface types.
32typedef enum {
33 // Uninitialized.
35 // A DXGI shared texture handle (Windows only).
36 // See
37 // https://docs.microsoft.com/en-us/windows/win32/api/dxgi/nf-dxgi-idxgiresource-getsharedhandle
39 // A |ID3D11Texture2D| (Windows only).
42
43// Supported pixel formats.
44typedef enum {
45 // Uninitialized.
47 // Represents a 32-bit RGBA color format with 8 bits each for red, green, blue
48 // and alpha.
50 // Represents a 32-bit BGRA color format with 8 bits each for blue, green, red
51 // and alpha.
54
55// An image buffer object.
56typedef struct {
57 // The pixel data buffer.
58 const uint8_t* buffer;
59 // Width of the pixel buffer.
60 size_t width;
61 // Height of the pixel buffer.
62 size_t height;
63 // An optional callback that gets invoked when the |buffer| can be released.
64 void (*release_callback)(void* release_context);
65 // Opaque data passed to |release_callback|.
68
69// A GPU surface descriptor.
70typedef struct {
71 // The size of this struct. Must be
72 // sizeof(FlutterDesktopGpuSurfaceDescriptor).
74 // The surface handle. The expected type depends on the
75 // |FlutterDesktopGpuSurfaceType|.
76 //
77 // Provide a |ID3D11Texture2D*| when using
78 // |kFlutterDesktopGpuSurfaceTypeD3d11Texture2D| or a |HANDLE| when using
79 // |kFlutterDesktopGpuSurfaceTypeDxgiSharedHandle|.
80 //
81 // The referenced resource needs to stay valid until it has been opened by
82 // Flutter. Consider incrementing the resource's reference count in the
83 // |FlutterDesktopGpuSurfaceTextureCallback| and registering a
84 // |release_callback| for decrementing the reference count once it has been
85 // opened.
86 void* handle;
87 // The physical width.
88 size_t width;
89 // The physical height.
90 size_t height;
91 // The visible width.
92 // It might be less or equal to the physical |width|.
94 // The visible height.
95 // It might be less or equal to the physical |height|.
97 // The pixel format which might be optional depending on the surface type.
99 // An optional callback that gets invoked when the |handle| has been opened.
100 void (*release_callback)(void* release_context);
101 // Opaque data passed to |release_callback|.
104
105// The pixel buffer copy callback definition provided to
106// the Flutter engine to copy the texture.
107// It is invoked with the intended surface size specified by |width| and
108// |height| and the |user_data| held by
109// |FlutterDesktopPixelBufferTextureConfig|.
110//
111// As this is usually called from the render thread, the callee must take
112// care of proper synchronization. It also needs to be ensured that the
113// returned |FlutterDesktopPixelBuffer| isn't released prior to unregistering
114// the corresponding texture.
117 size_t height,
118 void* user_data);
119
120// The GPU surface callback definition provided to the Flutter engine to obtain
121// the surface. It is invoked with the intended surface size specified by
122// |width| and |height| and the |user_data| held by
123// |FlutterDesktopGpuSurfaceTextureConfig|.
126 size_t height,
127 void* user_data);
128
129// An object used to configure pixel buffer textures.
130typedef struct {
131 // The callback used by the engine to copy the pixel buffer object.
133 // Opaque data that will get passed to the provided |callback|.
136
137// An object used to configure GPU-surface textures.
138typedef struct {
139 // The size of this struct. Must be
140 // sizeof(FlutterDesktopGpuSurfaceTextureConfig).
142 // The concrete surface type (e.g.
143 // |kFlutterDesktopGpuSurfaceTypeDxgiSharedHandle|)
145 // The callback used by the engine to obtain the surface descriptor.
147 // Opaque data that will get passed to the provided |callback|.
150
151typedef struct {
153 union {
156 };
158
159// Registers a new texture with the Flutter engine and returns the texture ID.
160// This function can be called from any thread.
164
165// Asynchronously unregisters the texture identified by |texture_id| from the
166// Flutter engine.
167// An optional |callback| gets invoked upon completion.
168// This function can be called from any thread.
171 int64_t texture_id,
172 void (*callback)(void* user_data),
173 void* user_data);
174
175// Marks that a new texture frame is available for a given |texture_id|.
176// Returns true on success or false if the specified texture doesn't exist.
177// This function can be called from any thread.
181 int64_t texture_id);
182
183#if defined(__cplusplus)
184} // extern "C"
185#endif
186
187#endif // FLUTTER_SHELL_PLATFORM_COMMON_PUBLIC_FLUTTER_TEXTURE_REGISTRAR_H_
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition: DM.cpp:213
FlKeyEvent uint64_t FlKeyResponderAsyncCallback callback
#define FLUTTER_EXPORT
struct FlutterDesktopTextureRegistrar * FlutterDesktopTextureRegistrarRef
FLUTTER_EXPORT bool FlutterDesktopTextureRegistrarMarkExternalTextureFrameAvailable(FlutterDesktopTextureRegistrarRef texture_registrar, int64_t texture_id)
FLUTTER_EXPORT void FlutterDesktopTextureRegistrarUnregisterExternalTexture(FlutterDesktopTextureRegistrarRef texture_registrar, int64_t texture_id, void(*callback)(void *user_data), void *user_data)
FLUTTER_EXPORT int64_t FlutterDesktopTextureRegistrarRegisterExternalTexture(FlutterDesktopTextureRegistrarRef texture_registrar, const FlutterDesktopTextureInfo *info)
FlutterDesktopPixelFormat
@ kFlutterDesktopPixelFormatBGRA8888
@ kFlutterDesktopPixelFormatNone
@ kFlutterDesktopPixelFormatRGBA8888
const FlutterDesktopGpuSurfaceDescriptor *(* FlutterDesktopGpuSurfaceTextureCallback)(size_t width, size_t height, void *user_data)
const FlutterDesktopPixelBuffer *(* FlutterDesktopPixelBufferTextureCallback)(size_t width, size_t height, void *user_data)
FlutterDesktopGpuSurfaceType
@ kFlutterDesktopGpuSurfaceTypeDxgiSharedHandle
@ kFlutterDesktopGpuSurfaceTypeD3d11Texture2D
@ kFlutterDesktopGpuSurfaceTypeNone
FlutterDesktopTextureType
@ kFlutterDesktopGpuSurfaceTexture
@ kFlutterDesktopPixelBufferTexture
G_BEGIN_DECLS FlTextureRegistrar * texture_registrar
int32_t height
int32_t width
FlutterDesktopGpuSurfaceTextureCallback callback
FlutterDesktopPixelBufferTextureCallback callback
FlutterDesktopGpuSurfaceTextureConfig gpu_surface_config
FlutterDesktopTextureType type
FlutterDesktopPixelBufferTextureConfig pixel_buffer_config
void * user_data
int64_t texture_id