forked from flutter/engine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fl_engine_private.h
438 lines (401 loc) · 14.1 KB
/
fl_engine_private.h
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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
// 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_LINUX_FL_ENGINE_PRIVATE_H_
#define FLUTTER_SHELL_PLATFORM_LINUX_FL_ENGINE_PRIVATE_H_
#include <glib-object.h>
#include "flutter/shell/platform/embedder/embedder.h"
#include "flutter/shell/platform/linux/fl_mouse_cursor_handler.h"
#include "flutter/shell/platform/linux/fl_renderer.h"
#include "flutter/shell/platform/linux/fl_task_runner.h"
#include "flutter/shell/platform/linux/public/flutter_linux/fl_dart_project.h"
#include "flutter/shell/platform/linux/public/flutter_linux/fl_engine.h"
G_BEGIN_DECLS
/**
* FlEngineError:
* Errors for #FlEngine objects to set on failures.
*/
typedef enum {
FL_ENGINE_ERROR_FAILED,
} FlEngineError;
GQuark fl_engine_error_quark(void) G_GNUC_CONST;
/**
* FlEnginePlatformMessageHandler:
* @engine: an #FlEngine.
* @channel: channel message received on.
* @message: message content received from Dart.
* @response_handle: a handle to respond to the message with.
* @user_data: (closure): data provided when registering this handler.
*
* Function called when platform messages are received.
*
* Returns: %TRUE if message has been accepted.
*/
typedef gboolean (*FlEnginePlatformMessageHandler)(
FlEngine* engine,
const gchar* channel,
GBytes* message,
const FlutterPlatformMessageResponseHandle* response_handle,
gpointer user_data);
/**
* FlEngineUpdateSemanticsHandler:
* @engine: an #FlEngine.
* @node: semantic node information.
* @user_data: (closure): data provided when registering this handler.
*
* Function called when semantics node updates are received.
*/
typedef void (*FlEngineUpdateSemanticsHandler)(
FlEngine* engine,
const FlutterSemanticsUpdate2* update,
gpointer user_data);
/**
* fl_engine_new_with_renderer:
* @project: an #FlDartProject.
* @renderer: an #FlRenderer.
*
* Creates new Flutter engine.
*
* Returns: a new #FlEngine.
*/
FlEngine* fl_engine_new_with_renderer(FlDartProject* project,
FlRenderer* renderer);
/**
* fl_engine_get_renderer:
* @engine: an #FlEngine.
*
* Gets the renderer used by this engine.
*
* Returns: an #FlRenderer.
*/
FlRenderer* fl_engine_get_renderer(FlEngine* engine);
/**
* fl_engine_start:
* @engine: an #FlEngine.
* @error: (allow-none): #GError location to store the error occurring, or %NULL
* to ignore.
*
* Starts the Flutter engine.
*
* Returns: %TRUE on success.
*/
gboolean fl_engine_start(FlEngine* engine, GError** error);
/**
* fl_engine_get_embedder_api:
* @engine: an #FlEngine.
*
* Gets the embedder API proc table, allowing modificiations for unit testing.
*
* Returns: a mutable pointer to the embedder API proc table.
*/
FlutterEngineProcTable* fl_engine_get_embedder_api(FlEngine* engine);
/**
* fl_engine_add_view:
* @engine: an #FlEngine.
* @width: width of view in pixels.
* @height: height of view in pixels.
* @pixel_ratio: scale factor for view.
* @cancellable: (allow-none): a #GCancellable or %NULL.
* @callback: (scope async): a #GAsyncReadyCallback to call when the view is
* added.
* @user_data: (closure): user data to pass to @callback.
*
* Asynchronously add a new view. The returned view ID should not be used until
* this function completes.
*
* Returns: the ID for the view.
*/
FlutterViewId fl_engine_add_view(FlEngine* engine,
size_t width,
size_t height,
double pixel_ratio,
GCancellable* cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
/**
* fl_engine_add_view_finish:
* @engine: an #FlEngine.
* @result: a #GAsyncResult.
* @error: (allow-none): #GError location to store the error occurring, or %NULL
* to ignore.
*
* Completes request started with fl_engine_add_view().
*
* Returns: %TRUE on success.
*/
gboolean fl_engine_add_view_finish(FlEngine* engine,
GAsyncResult* result,
GError** error);
/**
* fl_engine_remove_view:
* @engine: an #FlEngine.
* @view_id: ID to remove.
* @cancellable: (allow-none): a #GCancellable or %NULL.
* @callback: (scope async): a #GAsyncReadyCallback to call when the view is
* added.
* @user_data: (closure): user data to pass to @callback.
*
* Removes a view previously added with fl_engine_add_view().
*/
void fl_engine_remove_view(FlEngine* engine,
FlutterViewId view_id,
GCancellable* cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
/**
* fl_engine_remove_view_finish:
* @engine: an #FlEngine.
* @result: a #GAsyncResult.
* @error: (allow-none): #GError location to store the error occurring, or %NULL
* to ignore.
*
* Completes request started with fl_engine_remove_view().
*
* Returns: %TRUE on succcess.
*/
gboolean fl_engine_remove_view_finish(FlEngine* engine,
GAsyncResult* result,
GError** error);
/**
* fl_engine_set_platform_message_handler:
* @engine: an #FlEngine.
* @handler: function to call when a platform message is received.
* @user_data: (closure): user data to pass to @handler.
* @destroy_notify: (allow-none): a function which gets called to free
* @user_data, or %NULL.
*
* Registers the function called when a platform message is received. Call
* fl_engine_send_platform_message_response() with the response to this message.
* Ownership of #FlutterPlatformMessageResponseHandle is
* transferred to the caller, and the message must be responded to avoid
* memory leaks.
*/
void fl_engine_set_platform_message_handler(
FlEngine* engine,
FlEnginePlatformMessageHandler handler,
gpointer user_data,
GDestroyNotify destroy_notify);
/**
* fl_engine_set_update_semantics_handler:
* @engine: an #FlEngine.
* @handler: function to call when a semantics update is received.
* @user_data: (closure): user data to pass to @handler.
* @destroy_notify: (allow-none): a function which gets called to free
* @user_data, or %NULL.
*
* Registers the function called when a semantics update is received.
*/
void fl_engine_set_update_semantics_handler(
FlEngine* engine,
FlEngineUpdateSemanticsHandler handler,
gpointer user_data,
GDestroyNotify destroy_notify);
/**
* fl_engine_send_window_metrics_event:
* @engine: an #FlEngine.
* @view_id: the view that the event occured on.
* @width: width of the window in pixels.
* @height: height of the window in pixels.
* @pixel_ratio: scale factor for window.
*
* Sends a window metrics event to the engine.
*/
void fl_engine_send_window_metrics_event(FlEngine* engine,
FlutterViewId view_id,
size_t width,
size_t height,
double pixel_ratio);
/**
* fl_engine_send_mouse_pointer_event:
* @engine: an #FlEngine.
* @view_id: the view that the event occured on.
* @phase: mouse phase.
* @timestamp: time when event occurred in microseconds.
* @x: x location of mouse cursor.
* @y: y location of mouse cursor.
* @device_kind: kind of pointing device.
* @scroll_delta_x: x offset of scroll.
* @scroll_delta_y: y offset of scroll.
* @buttons: buttons that are pressed.
*
* Sends a mouse pointer event to the engine.
*/
void fl_engine_send_mouse_pointer_event(FlEngine* engine,
FlutterViewId view_id,
FlutterPointerPhase phase,
size_t timestamp,
double x,
double y,
FlutterPointerDeviceKind device_kind,
double scroll_delta_x,
double scroll_delta_y,
int64_t buttons);
/**
* fl_engine_send_pointer_pan_zoom_event:
* @engine: an #FlEngine.
* @view_id: the view that the event occured on.
* @timestamp: time when event occurred in microseconds.
* @x: x location of mouse cursor.
* @y: y location of mouse cursor.
* @phase: mouse phase.
* @pan_x: x offset of the pan/zoom in pixels.
* @pan_y: y offset of the pan/zoom in pixels.
* @scale: scale of the pan/zoom.
* @rotation: rotation of the pan/zoom in radians.
*
* Sends a pan/zoom pointer event to the engine.
*/
void fl_engine_send_pointer_pan_zoom_event(FlEngine* engine,
FlutterViewId view_id,
size_t timestamp,
double x,
double y,
FlutterPointerPhase phase,
double pan_x,
double pan_y,
double scale,
double rotation);
/**
* fl_engine_send_key_event:
*/
void fl_engine_send_key_event(FlEngine* engine,
const FlutterKeyEvent* event,
FlutterKeyEventCallback callback,
void* user_data);
/**
* fl_engine_dispatch_semantics_action:
* @engine: an #FlEngine.
* @id: the semantics action identifier.
* @action: the action being dispatched.
* @data: (allow-none): data associated with the action.
*/
void fl_engine_dispatch_semantics_action(FlEngine* engine,
uint64_t id,
FlutterSemanticsAction action,
GBytes* data);
/**
* fl_engine_send_platform_message_response:
* @engine: an #FlEngine.
* @handle: handle that was provided in #FlEnginePlatformMessageHandler.
* @response: (allow-none): response to send or %NULL for an empty response.
* @error: (allow-none): #GError location to store the error occurring, or %NULL
* to ignore.
*
* Responds to a platform message.
*
* Returns: %TRUE on success.
*/
gboolean fl_engine_send_platform_message_response(
FlEngine* engine,
const FlutterPlatformMessageResponseHandle* handle,
GBytes* response,
GError** error);
/**
* fl_engine_send_platform_message:
* @engine: an #FlEngine.
* @channel: channel to send to.
* @message: (allow-none): message buffer to send or %NULL for an empty message
* @cancellable: (allow-none): a #GCancellable or %NULL.
* @callback: (scope async): a #GAsyncReadyCallback to call when the request is
* satisfied.
* @user_data: (closure): user data to pass to @callback.
*
* Asynchronously sends a platform message.
*/
void fl_engine_send_platform_message(FlEngine* engine,
const gchar* channel,
GBytes* message,
GCancellable* cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
/**
* fl_engine_send_platform_message_finish:
* @engine: an #FlEngine.
* @result: a #GAsyncResult.
* @error: (allow-none): #GError location to store the error occurring, or %NULL
* to ignore.
*
* Completes request started with fl_engine_send_platform_message().
*
* Returns: message response on success or %NULL on error.
*/
GBytes* fl_engine_send_platform_message_finish(FlEngine* engine,
GAsyncResult* result,
GError** error);
/**
* fl_engine_get_task_runner:
* @engine: an #FlEngine.
* @result: a #FlTaskRunner.
*
* Returns: task runner responsible for scheduling Flutter tasks.
*/
FlTaskRunner* fl_engine_get_task_runner(FlEngine* engine);
/**
* fl_engine_execute_task:
* @engine: an #FlEngine.
* @task: a #FlutterTask to execute.
*
* Executes given Flutter task.
*/
void fl_engine_execute_task(FlEngine* engine, FlutterTask* task);
/**
* fl_engine_mark_texture_frame_available:
* @engine: an #FlEngine.
* @texture_id: the identifier of the texture whose frame has been updated.
*
* Tells the Flutter engine that a new texture frame is available for the given
* texture.
*
* Returns: %TRUE on success.
*/
gboolean fl_engine_mark_texture_frame_available(FlEngine* engine,
int64_t texture_id);
/**
* fl_engine_register_external_texture:
* @engine: an #FlEngine.
* @texture_id: the identifier of the texture that is available.
*
* Tells the Flutter engine that a new external texture is available.
*
* Returns: %TRUE on success.
*/
gboolean fl_engine_register_external_texture(FlEngine* engine,
int64_t texture_id);
/**
* fl_engine_unregister_external_texture:
* @engine: an #FlEngine.
* @texture_id: the identifier of the texture that is not available anymore.
*
* Tells the Flutter engine that an existing external texture is not available
* anymore.
*
* Returns: %TRUE on success.
*/
gboolean fl_engine_unregister_external_texture(FlEngine* engine,
int64_t texture_id);
/**
* fl_engine_update_accessibility_features:
* @engine: an #FlEngine.
* @flags: the features to enable in the accessibility tree.
*
* Tells the Flutter engine to update the flags on the accessibility tree.
*/
void fl_engine_update_accessibility_features(FlEngine* engine, int32_t flags);
/**
* fl_engine_request_app_exit:
* @engine: an #FlEngine.
*
* Request the application exits.
*/
void fl_engine_request_app_exit(FlEngine* engine);
/**
* fl_engine_get_mouse_cursor_handler:
* @engine: an #FlEngine.
*
* Gets the mouse cursor handler used by this engine.
*
* Returns: a #FlMouseCursorHandler.
*/
FlMouseCursorHandler* fl_engine_get_mouse_cursor_handler(FlEngine* engine);
G_END_DECLS
#endif // FLUTTER_SHELL_PLATFORM_LINUX_FL_ENGINE_PRIVATE_H_