forked from flutter/engine
-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathflutter_texture_registrar.h
More file actions
124 lines (105 loc) · 4.52 KB
/
flutter_texture_registrar.h
File metadata and controls
124 lines (105 loc) · 4.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef FLUTTER_SHELL_PLATFORM_COMMON_CPP_PUBLIC_FLUTTER_TEXTURE_REGISTRAR_H_
#define FLUTTER_SHELL_PLATFORM_COMMON_CPP_PUBLIC_FLUTTER_TEXTURE_REGISTRAR_H_
#include <stddef.h>
#include <stdint.h>
#include "flutter_export.h"
#if defined(__cplusplus)
extern "C" {
#endif
struct FlutterDesktopTextureRegistrar;
// Opaque reference to a texture registrar.
typedef struct FlutterDesktopTextureRegistrar*
FlutterDesktopTextureRegistrarRef;
// Possible values for the type specified in FlutterDesktopTextureInfo.
// Additional types may be added in the future.
typedef enum {
// A Pixel buffer-based texture.
kFlutterDesktopPixelBufferTexture,
// A Gpu buffer-based texture.
kFlutterDesktopGpuBufferTexture
} FlutterDesktopTextureType;
// An image buffer object.
typedef struct {
// The pixel data buffer.
const uint8_t* buffer;
// Width of the pixel buffer.
size_t width;
// Height of the pixel buffer.
size_t height;
} FlutterDesktopPixelBuffer;
// An image buffer object.
typedef struct {
// The gpu data buffer.
const void* buffer;
// Width of the gpu buffer.
size_t width;
// Height of the gpu buffer.
size_t height;
} FlutterDesktopGpuBuffer;
// The pixel buffer copy callback definition provided to
// the Flutter engine to copy the texture.
// It is invoked with the intended surface size specified by |width| and
// |height| and the |user_data| held by FlutterDesktopPixelBufferTextureConfig.
//
// As this is usually called from the render thread, the callee must take
// care of proper synchronization. It also needs to be ensured that the
// returned FlutterDesktopPixelBuffer isn't released prior to unregistering
// the corresponding texture.
typedef const FlutterDesktopPixelBuffer* (
*FlutterDesktopPixelBufferTextureCallback)(size_t width,
size_t height,
void* user_data);
typedef const FlutterDesktopGpuBuffer* (
*FlutterDesktopGpuBufferTextureCallback)(size_t width,
size_t height,
void* user_data);
typedef void (*FlutterDesktopGpuBufferDestructionCallback)(void* user_data);
// An object used to configure pixel buffer textures.
typedef struct {
// The callback used by the engine to copy the pixel buffer object.
FlutterDesktopPixelBufferTextureCallback callback;
// Opaque data that will get passed to the provided |callback|.
void* user_data;
} FlutterDesktopPixelBufferTextureConfig;
// An object used to configure GPU buffer textures.
typedef struct {
// The callback used by the engine to obtain the GPU buffer object.
FlutterDesktopGpuBufferTextureCallback callback;
// The callback used by the engine to destruct the GPU buffer object.
FlutterDesktopGpuBufferDestructionCallback destruction_callback;
// Opaque data that will get passed to the provided |callback|.
void* user_data;
} FlutterDesktopGPUBufferTextureConfig;
typedef struct {
FlutterDesktopTextureType type;
union {
FlutterDesktopPixelBufferTextureConfig pixel_buffer_config;
FlutterDesktopGPUBufferTextureConfig gpu_buffer_config;
};
} FlutterDesktopTextureInfo;
// Registers a new texture with the Flutter engine and returns the texture ID.
// This function can be called from any thread.
FLUTTER_EXPORT int64_t FlutterDesktopTextureRegistrarRegisterExternalTexture(
FlutterDesktopTextureRegistrarRef texture_registrar,
const FlutterDesktopTextureInfo* info);
// Unregisters an existing texture from the Flutter engine for a |texture_id|.
// Returns true on success or false if the specified texture doesn't exist.
// This function can be called from any thread.
// However, textures must not be unregistered while they're in use.
FLUTTER_EXPORT bool FlutterDesktopTextureRegistrarUnregisterExternalTexture(
FlutterDesktopTextureRegistrarRef texture_registrar,
int64_t texture_id);
// Marks that a new texture frame is available for a given |texture_id|.
// Returns true on success or false if the specified texture doesn't exist.
// This function can be called from any thread.
FLUTTER_EXPORT bool
FlutterDesktopTextureRegistrarMarkExternalTextureFrameAvailable(
FlutterDesktopTextureRegistrarRef texture_registrar,
int64_t texture_id);
#if defined(__cplusplus)
} // extern "C"
#endif
#endif // FLUTTER_SHELL_PLATFORM_COMMON_CPP_PUBLIC_FLUTTER_TEXTURE_REGISTRAR_H_