| Flutter Linux Embedder |

Classes | Enumerations | Functions | Variables
fl_engine.cc File Reference
`#include "flutter/shell/platform/linux/public/flutter_linux/fl_engine.h"`
`#include <gmodule.h>`
`#include <cstring>`
`#include "flutter/shell/platform/common/engine_switches.h"`
`#include "flutter/shell/platform/embedder/embedder.h"`
`#include "flutter/shell/platform/linux/fl_binary_messenger_private.h"`
`#include "flutter/shell/platform/linux/fl_dart_project_private.h"`
`#include "flutter/shell/platform/linux/fl_display_monitor.h"`
`#include "flutter/shell/platform/linux/fl_engine_private.h"`
`#include "flutter/shell/platform/linux/fl_pixel_buffer_texture_private.h"`
`#include "flutter/shell/platform/linux/fl_platform_handler.h"`
`#include "flutter/shell/platform/linux/fl_plugin_registrar_private.h"`
`#include "flutter/shell/platform/linux/fl_renderer.h"`
`#include "flutter/shell/platform/linux/fl_renderer_gdk.h"`
`#include "flutter/shell/platform/linux/fl_renderer_headless.h"`
`#include "flutter/shell/platform/linux/fl_settings_handler.h"`
`#include "flutter/shell/platform/linux/fl_texture_gl_private.h"`
`#include "flutter/shell/platform/linux/fl_texture_registrar_private.h"`
`#include "flutter/shell/platform/linux/public/flutter_linux/fl_plugin_registry.h"`

Go to the source code of this file.

## Classes
struct | _FlEngine

## Enumerations
enum | { SIGNAL_ON_PRE_ENGINE_RESTART , LAST_SIGNAL }

## Functions
static void | fl_engine_plugin_registry_iface_init (FlPluginRegistryInterface *iface)
| G_DEFINE_TYPE_WITH_CODE (FlEngine, fl_engine, G_TYPE_OBJECT, G_IMPLEMENT_INTERFACE(fl_plugin_registry_get_type(), fl_engine_plugin_registry_iface_init)) enum
static void | parse_locale (const gchar *locale, gchar **language, gchar **territory, gchar **codeset, gchar **modifier)
static void | view_added_cb (const FlutterAddViewResult *result)
static void | view_removed_cb (const FlutterRemoveViewResult *result)
static void | free_locale (FlutterLocale *locale)
static void | setup_locales (FlEngine *self)
static bool | compositor_create_backing_store_callback (const FlutterBackingStoreConfig *config, FlutterBackingStore *backing_store_out, void *user_data)
static bool | compositor_collect_backing_store_callback (const FlutterBackingStore *backing_store, void *user_data)
static bool | compositor_present_view_callback (const FlutterPresentViewInfo *info)
static void * | fl_engine_gl_proc_resolver (void *user_data, const char *name)
static bool | fl_engine_gl_make_current (void *user_data)
static bool | fl_engine_gl_clear_current (void *user_data)
static uint32_t | fl_engine_gl_get_fbo (void *user_data)
static bool | fl_engine_gl_present (void *user_data)
static bool | fl_engine_gl_make_resource_current (void *user_data)
static bool | fl_engine_gl_external_texture_frame_callback (void *user_data, int64_t texture_id, size_t width, size_t height, FlutterOpenGLTexture *opengl_texture)
static bool | fl_engine_runs_task_on_current_thread (void *user_data)
static void | fl_engine_post_task (FlutterTask task, uint64_t target_time_nanos, void *user_data)
static void | fl_engine_platform_message_cb (const FlutterPlatformMessage *message, void *user_data)
static void | fl_engine_update_semantics_cb (const FlutterSemanticsUpdate2 *update, void *user_data)
static void | fl_engine_on_pre_engine_restart_cb (void *user_data)
static void | fl_engine_platform_message_response_cb (const uint8_t *data, size_t data_length, void *user_data)
static FlPluginRegistrar * | fl_engine_get_registrar_for_plugin (FlPluginRegistry *registry, const gchar *name)
static void | fl_engine_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
static void | fl_engine_dispose (GObject *object)
static void | fl_engine_class_init (FlEngineClass *klass)
static void | fl_engine_init (FlEngine *self)
FlEngine * | fl_engine_new_with_renderer (FlDartProject *project, FlRenderer *renderer)
G_MODULE_EXPORT FlEngine * | fl_engine_new (FlDartProject *project)
G_MODULE_EXPORT FlEngine * | fl_engine_new_headless (FlDartProject *project)
FlRenderer * | fl_engine_get_renderer (FlEngine *self)
FlDisplayMonitor * | fl_engine_get_display_monitor (FlEngine *self)
gboolean | fl_engine_start (FlEngine *self, GError **error)
FlutterEngineProcTable * | fl_engine_get_embedder_api (FlEngine *self)
void | fl_engine_notify_display_update (FlEngine *self, const FlutterEngineDisplay *displays, size_t displays_length)
FlutterViewId | fl_engine_add_view (FlEngine *self, size_t width, size_t height, double pixel_ratio, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data)
gboolean | fl_engine_add_view_finish (FlEngine *self, GAsyncResult *result, GError **error)
void | fl_engine_remove_view (FlEngine *self, FlutterViewId view_id, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data)
gboolean | fl_engine_remove_view_finish (FlEngine *self, GAsyncResult *result, GError **error)
void | fl_engine_set_platform_message_handler (FlEngine *self, FlEnginePlatformMessageHandler handler, gpointer user_data, GDestroyNotify destroy_notify)
void | fl_engine_set_update_semantics_handler (FlEngine *self, FlEngineUpdateSemanticsHandler handler, gpointer user_data, GDestroyNotify destroy_notify)
gboolean | fl_engine_send_platform_message_response (FlEngine *self, const FlutterPlatformMessageResponseHandle *handle, GBytes *response, GError **error)
void | fl_engine_send_platform_message (FlEngine *self, const gchar *channel, GBytes *message, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data)
GBytes * | fl_engine_send_platform_message_finish (FlEngine *self, GAsyncResult *result, GError **error)
void | fl_engine_send_window_metrics_event (FlEngine *self, FlutterEngineDisplayId display_id, FlutterViewId view_id, size_t width, size_t height, double pixel_ratio)
void | fl_engine_send_mouse_pointer_event (FlEngine *self, 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)
void | fl_engine_send_touch_up_event (FlEngine *self, FlutterViewId view_id, size_t timestamp, double x, double y, int32_t device)
void | fl_engine_send_touch_down_event (FlEngine *self, FlutterViewId view_id, size_t timestamp, double x, double y, int32_t device)
void | fl_engine_send_touch_move_event (FlEngine *self, FlutterViewId view_id, size_t timestamp, double x, double y, int32_t device)
void | fl_engine_send_touch_add_event (FlEngine *self, FlutterViewId view_id, size_t timestamp, double x, double y, int32_t device)
void | fl_engine_send_touch_remove_event (FlEngine *self, FlutterViewId view_id, size_t timestamp, double x, double y, int32_t device)
void | fl_engine_send_pointer_pan_zoom_event (FlEngine *self, FlutterViewId view_id, size_t timestamp, double x, double y, FlutterPointerPhase phase, double pan_x, double pan_y, double scale, double rotation)
static void | send_key_event_cb (bool handled, void *user_data)
void | fl_engine_send_key_event (FlEngine *self, const FlutterKeyEvent *event, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data)
gboolean | fl_engine_send_key_event_finish (FlEngine *self, GAsyncResult *result, gboolean *handled, GError **error)
void | fl_engine_dispatch_semantics_action (FlEngine *self, uint64_t id, FlutterSemanticsAction action, GBytes *data)
gboolean | fl_engine_mark_texture_frame_available (FlEngine *self, int64_t texture_id)
gboolean | fl_engine_register_external_texture (FlEngine *self, int64_t texture_id)
gboolean | fl_engine_unregister_external_texture (FlEngine *self, int64_t texture_id)
G_MODULE_EXPORT FlBinaryMessenger * | fl_engine_get_binary_messenger (FlEngine *self)
FlTaskRunner * | fl_engine_get_task_runner (FlEngine *self)
void | fl_engine_execute_task (FlEngine *self, FlutterTask *task)
G_MODULE_EXPORT FlTextureRegistrar * | fl_engine_get_texture_registrar (FlEngine *self)
void | fl_engine_update_accessibility_features (FlEngine *self, int32_t flags)
void | fl_engine_request_app_exit (FlEngine *self)
FlMouseCursorHandler * | fl_engine_get_mouse_cursor_handler (FlEngine *self)

## Variables
static constexpr size_t | kPlatformTaskRunnerIdentifier = 1
static constexpr int32_t | kMousePointerDeviceId = 0
static constexpr int32_t | kPointerPanZoomDeviceId = 1
static guint | fl_engine_signals [LAST_SIGNAL]

## Enumeration Type Documentation

## ◆ anonymous enum

anonymous enum

Enumerator
SIGNAL_ON_PRE_ENGINE_RESTART |
LAST_SIGNAL |

Definition at line 98 of file fl_engine.cc.

98 { SIGNAL_ON_PRE_ENGINE_RESTART, LAST_SIGNAL };
LAST_SIGNAL
@ LAST_SIGNAL
Definition: fl_engine.cc:98
SIGNAL_ON_PRE_ENGINE_RESTART
@ SIGNAL_ON_PRE_ENGINE_RESTART
Definition: fl_engine.cc:98

## Function Documentation

## ◆ compositor_collect_backing_store_callback()

static bool compositor_collect_backing_store_callback | ( | const FlutterBackingStore * | backing_store,
|  | void * | user_data
| ) |  |
| static

Definition at line 245 of file fl_engine.cc.

247 {
248 g_return_val_if_fail(FL_IS_RENDERER(user_data), false);
249 return fl_renderer_collect_backing_store(FL_RENDERER(user_data),
250 backing_store);
251 }
user_data
G_BEGIN_DECLS G_MODULE_EXPORT FlValue gpointer user_data
Definition: fl_event_channel.h:90
fl_renderer_collect_backing_store
gboolean fl_renderer_collect_backing_store(FlRenderer *self, const FlutterBackingStore *backing_store)
Definition: fl_renderer.cc:423

References fl_renderer_collect_backing_store(), and user_data.

Referenced by fl_engine_start().

## ◆ compositor_create_backing_store_callback()

static bool compositor_create_backing_store_callback | ( | const FlutterBackingStoreConfig * | config,
|  | FlutterBackingStore * | backing_store_out,
|  | void * | user_data
| ) |  |
| static

Definition at line 235 of file fl_engine.cc.

238 {
239 g_return_val_if_fail(FL_IS_RENDERER(user_data), false);
240 return fl_renderer_create_backing_store(FL_RENDERER(user_data), config,
241 backing_store_out);
242 }
fl_renderer_create_backing_store
gboolean fl_renderer_create_backing_store(FlRenderer *self, const FlutterBackingStoreConfig *config, FlutterBackingStore *backing_store_out)
Definition: fl_renderer.cc:391

References fl_renderer_create_backing_store(), and user_data.

Referenced by fl_engine_start().

## ◆ compositor_present_view_callback()

static bool compositor_present_view_callback | ( | const FlutterPresentViewInfo * | info | ) |
| static

Definition at line 254 of file fl_engine.cc.

255 {
256 g_return_val_if_fail(FL_IS_RENDERER(info->user_data), false);
257 return fl_renderer_present_layers(FL_RENDERER(info->user_data), info->view_id,
258 info->layers, info->layers_count);
259 }
fl_renderer_present_layers
gboolean fl_renderer_present_layers(FlRenderer *self, FlutterViewId view_id, const FlutterLayer **layers, size_t layers_count)
Definition: fl_renderer.cc:453

References fl_renderer_present_layers().

Referenced by fl_engine_start().

## ◆ fl_engine_add_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: @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.

Definition at line 678 of file fl_engine.cc.

684 {
685 g_return_val_if_fail(FL_IS_ENGINE(self), -1);
686
687 g_autoptr(GTask) task = g_task_new(self, cancellable, callback, user_data);
688
689 FlutterViewId view_id = self->next_view_id;
690 self->next_view_id++;
691
692 // We don't know which display this view will open on, so set to zero and this
693 // will be updated in a following FlutterWindowMetricsEvent
694 FlutterEngineDisplayId display_id = 0;
695
696 FlutterWindowMetricsEvent metrics;
697 metrics.struct_size = sizeof(FlutterWindowMetricsEvent);
698 metrics.width = width;
699 metrics.height = height;
700 metrics.pixel_ratio = pixel_ratio;
701 metrics.display_id = display_id;
702 metrics.view_id = view_id;
703 FlutterAddViewInfo info;
704 info.struct_size = sizeof(FlutterAddViewInfo);
705 info.view_id = view_id;
706 info.view_metrics = &metrics;
707 info.user_data = g_object_ref(task);
708 info.add_view_callback = view_added_cb;
709 FlutterEngineResult result = self->embedder_api.AddView(self->engine, &info);
710 if (result != kSuccess) {
711 g_task_return_new_error(task, fl_engine_error_quark(),
712 FL_ENGINE_ERROR_FAILED, "AddView returned %d",
713 result);
714 // This would have been done in the callback, but that won't occur now.
715 g_object_unref(task);
716 }
717
718 return view_id;
719 }
view_added_cb
static void view_added_cb(const FlutterAddViewResult *result)
Definition: fl_engine.cc:155
fl_engine_error_quark
GQuark fl_engine_error_quark(void) G_GNUC_CONST
FL_ENGINE_ERROR_FAILED
@ FL_ENGINE_ERROR_FAILED
Definition: fl_engine_private.h:26
height
const uint8_t uint32_t uint32_t * height
Definition: fl_pixel_buffer_texture_test.cc:39
width
const uint8_t uint32_t * width
Definition: fl_pixel_buffer_texture_test.cc:38

References FL_ENGINE_ERROR_FAILED, fl_engine_error_quark(), height, user_data, view_added_cb(), and width.

Referenced by fl_view_new_for_engine(), and TEST().

## ◆ fl_engine_add_view_finish()

gboolean fl_engine_add_view_finish | ( | FlEngine * | engine,
|  | GAsyncResult * | result,
|  | GError ** | error
| ) |  |

fl_engine_add_view_finish: @engine: an #FlEngine.

Returns
  : 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.

Definition at line 721 of file fl_engine.cc.

723 {
724 g_return_val_if_fail(FL_IS_ENGINE(self), FALSE);
725 return g_task_propagate_boolean(G_TASK(result), error);
726 }
error
const uint8_t uint32_t uint32_t GError ** error
Definition: fl_pixel_buffer_texture_test.cc:40

References error.

Referenced by add_view_cb(), add_view_engine_error_cb(), add_view_error_cb(), and view_added_cb().

## ◆ fl_engine_class_init()

static void fl_engine_class_init | ( | FlEngineClass * | klass | ) |
| static

Definition at line 478 of file fl_engine.cc.

478 {
479 G_OBJECT_CLASS(klass)->dispose = fl_engine_dispose;
480 G_OBJECT_CLASS(klass)->set_property = fl_engine_set_property;
481
482 g_object_class_install_property(
483 G_OBJECT_CLASS(klass), PROP_BINARY_MESSENGER,
484 g_param_spec_object(
485 "binary-messenger", "messenger", "Binary messenger",
486 fl_binary_messenger_get_type(),
487 static_cast<GParamFlags>(G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY |
488 G_PARAM_STATIC_STRINGS)));
489
490 fl_engine_signals[SIGNAL_ON_PRE_ENGINE_RESTART] = g_signal_new(
491 "on-pre-engine-restart", fl_engine_get_type(), G_SIGNAL_RUN_LAST, 0,
492 nullptr, nullptr, nullptr, G_TYPE_NONE, 0);
493 }
fl_engine_dispose
static void fl_engine_dispose(GObject *object)
Definition: fl_engine.cc:436
fl_engine_signals
static guint fl_engine_signals[LAST_SIGNAL]
Definition: fl_engine.cc:100
fl_engine_set_property
static void fl_engine_set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
Definition: fl_engine.cc:420

References fl_engine_dispose(), fl_engine_set_property(), fl_engine_signals, and SIGNAL_ON_PRE_ENGINE_RESTART.

## ◆ fl_engine_dispatch_semantics_action()

void fl_engine_dispatch_semantics_action | ( | FlEngine * | engine,
|  | uint64_t | id,
|  | FlutterSemanticsAction | action,
|  | GBytes * | 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.

Definition at line 1161 of file fl_engine.cc.

1164 {
1165 g_return_if_fail(FL_IS_ENGINE(self));
1166
1167 if (self->engine == nullptr) {
1168 return;
1169 }
1170
1171 const uint8_t* action_data = nullptr;
1172 size_t action_data_length = 0;
1173 if (data != nullptr) {
1174 action_data = static_cast<const uint8_t*>(
1175 g_bytes_get_data(data, &action_data_length));
1176 }
1177
1178 self->embedder_api.DispatchSemanticsAction(self->engine, id, action,
1179 action_data, action_data_length);
1180 }

Referenced by fl_accessible_node_perform_action_impl(), and TEST().

## ◆ fl_engine_dispose()

static void fl_engine_dispose | ( | GObject * | object | ) |
| static

Definition at line 436 of file fl_engine.cc.

436 {
437 FlEngine* self = FL_ENGINE(object);
438
439 if (self->engine != nullptr) {
440 self->embedder_api.Shutdown(self->engine);
441 self->engine = nullptr;
442 }
443
444 if (self->aot_data != nullptr) {
445 self->embedder_api.CollectAOTData(self->aot_data);
446 self->aot_data = nullptr;
447 }
448
449 fl_binary_messenger_shutdown(self->binary_messenger);
450 fl_texture_registrar_shutdown(self->texture_registrar);
451
452 g_clear_object(&self->project);
453 g_clear_object(&self->renderer);
454 g_clear_object(&self->texture_registrar);
455 g_clear_object(&self->binary_messenger);
456 g_clear_object(&self->settings_handler);
457 g_clear_object(&self->platform_handler);
458 g_clear_object(&self->mouse_cursor_handler);
459 g_clear_object(&self->task_runner);
460
461 if (self->platform_message_handler_destroy_notify) {
462 self->platform_message_handler_destroy_notify(
463 self->platform_message_handler_data);
464 }
465 self->platform_message_handler_data = nullptr;
466 self->platform_message_handler_destroy_notify = nullptr;
467
468 if (self->update_semantics_handler_destroy_notify) {
469 self->update_semantics_handler_destroy_notify(
470 self->update_semantics_handler_data);
471 }
472 self->update_semantics_handler_data = nullptr;
473 self->update_semantics_handler_destroy_notify = nullptr;
474
475 G_OBJECT_CLASS(fl_engine_parent_class)->dispose(object);
476 }
fl_binary_messenger_shutdown
void fl_binary_messenger_shutdown(FlBinaryMessenger *self)
Definition: fl_binary_messenger.cc:500
fl_texture_registrar_shutdown
void fl_texture_registrar_shutdown(FlTextureRegistrar *self)
Definition: fl_texture_registrar.cc:215

References fl_binary_messenger_shutdown(), and fl_texture_registrar_shutdown().

Referenced by fl_engine_class_init().

## ◆ fl_engine_execute_task()

void fl_engine_execute_task | ( | FlEngine * | engine,
|  | FlutterTask * | task
| ) |  |

fl_engine_execute_task: @engine: an #FlEngine. @task: a #FlutterTask to execute.

Executes given Flutter task.

Definition at line 1214 of file fl_engine.cc.

1214 {
1215 g_return_if_fail(FL_IS_ENGINE(self));
1216 self->embedder_api.RunTask(self->engine, task);
1217 }

Referenced by fl_task_runner_process_expired_tasks_locked().

## ◆ fl_engine_get_binary_messenger()

G_MODULE_EXPORT FlBinaryMessenger* fl_engine_get_binary_messenger | ( | FlEngine * | engine | ) |

fl_engine_get_binary_messenger: @engine: an #FlEngine.

Gets the messenger to communicate with this engine.

Returns: an #FlBinaryMessenger.

Definition at line 1203 of file fl_engine.cc.

1204 {
1205 g_return_val_if_fail(FL_IS_ENGINE(self), nullptr);
1206 return self->binary_messenger;
1207 }

Referenced by fl_settings_handler_new(), fl_view_get_registrar_for_plugin(), init_keyboard(), realize_cb(), and TEST().

## ◆ fl_engine_get_display_monitor()

FlDisplayMonitor* fl_engine_get_display_monitor | ( | FlEngine * | engine | ) |

fl_engine_get_display_monitor: @engine: an #FlEngine.

Gets the display monitor used by this engine.

Returns: an #FlDisplayMonitor.

Definition at line 539 of file fl_engine.cc.

539 {
540 g_return_val_if_fail(FL_IS_ENGINE(self), nullptr);
541 return self->display_monitor;
542 }

Referenced by handle_geometry_changed().

## ◆ fl_engine_get_embedder_api()

FlutterEngineProcTable* fl_engine_get_embedder_api | ( | FlEngine * | engine | ) |

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.

Definition at line 661 of file fl_engine.cc.

661 {
662 return &(self->embedder_api);
663 }

Referenced by TEST().

## ◆ fl_engine_get_mouse_cursor_handler()

FlMouseCursorHandler* fl_engine_get_mouse_cursor_handler | ( | FlEngine * | engine | ) |

fl_engine_get_mouse_cursor_handler: @engine: an #FlEngine.

Gets the mouse cursor handler used by this engine.

Returns: a #FlMouseCursorHandler.

Definition at line 1241 of file fl_engine.cc.

1241 {
1242 g_return_val_if_fail(FL_IS_ENGINE(self), nullptr);
1243 return self->mouse_cursor_handler;
1244 }

Referenced by cursor_changed_cb(), fl_view_dispose(), and setup_cursor().

## ◆ fl_engine_get_registrar_for_plugin()

static FlPluginRegistrar* fl_engine_get_registrar_for_plugin | ( | FlPluginRegistry * | registry,
|  | const gchar * | name
| ) |  |
| static

Definition at line 406 of file fl_engine.cc.

408 {
409 FlEngine* self = FL_ENGINE(registry);
410
411 return fl_plugin_registrar_new(nullptr, self->binary_messenger,
412 self->texture_registrar);
413 }
fl_plugin_registrar_new
FlPluginRegistrar * fl_plugin_registrar_new(FlView *view, FlBinaryMessenger *messenger, FlTextureRegistrar *texture_registrar)
Definition: fl_plugin_registrar.cc:84

References fl_plugin_registrar_new().

Referenced by fl_engine_plugin_registry_iface_init().

## ◆ fl_engine_get_renderer()

FlRenderer* fl_engine_get_renderer | ( | FlEngine * | engine | ) |

fl_engine_get_renderer: @engine: an #FlEngine.

Gets the renderer used by this engine.

Returns: an #FlRenderer.

Definition at line 534 of file fl_engine.cc.

534 {
535 g_return_val_if_fail(FL_IS_ENGINE(self), nullptr);
536 return self->renderer;
537 }

Referenced by fl_view_new(), and fl_view_new_for_engine().

## ◆ fl_engine_get_task_runner()

FlTaskRunner* fl_engine_get_task_runner | ( | FlEngine * | engine | ) |

fl_engine_get_task_runner: @engine: an #FlEngine.

Returns
  : a #FlTaskRunner.

Returns: task runner responsible for scheduling Flutter tasks.

Definition at line 1209 of file fl_engine.cc.

1209 {
1210 g_return_val_if_fail(FL_IS_ENGINE(self), nullptr);
1211 return self->task_runner;
1212 }

Referenced by fl_renderer_unblock_main_thread(), and fl_renderer_wait_for_frame().

## ◆ fl_engine_get_texture_registrar()

G_MODULE_EXPORT FlTextureRegistrar* fl_engine_get_texture_registrar | ( | FlEngine * | engine | ) |

fl_engine_get_texture_registrar: @engine: an #FlEngine.

Gets the texture registrar for registering textures.

Returns: an #FlTextureRegistrar.

Definition at line 1219 of file fl_engine.cc.

1220 {
1221 g_return_val_if_fail(FL_IS_ENGINE(self), nullptr);
1222 return self->texture_registrar;
1223 }

Referenced by fl_view_get_registrar_for_plugin().

## ◆ fl_engine_gl_clear_current()

static bool fl_engine_gl_clear_current | ( | void * | user_data | ) |
| static

Definition at line 274 of file fl_engine.cc.

274 {
275 FlEngine* self = static_cast<FlEngine*>(user_data);
276 fl_renderer_clear_current(self->renderer);
277 return true;
278 }
fl_renderer_clear_current
void fl_renderer_clear_current(FlRenderer *self)
Definition: fl_renderer.cc:379

References fl_renderer_clear_current(), and user_data.

Referenced by fl_engine_start().

## ◆ fl_engine_gl_external_texture_frame_callback()

static bool fl_engine_gl_external_texture_frame_callback | ( | void * | user_data,
|  | int64_t | texture_id,
|  | size_t | width,
|  | size_t | height,
|  | FlutterOpenGLTexture * | opengl_texture
| ) |  |
| static

Definition at line 298 of file fl_engine.cc.

303 {
304 FlEngine* self = static_cast<FlEngine*>(user_data);
305 if (!self->texture_registrar) {
306 return false;
307 }
308
309 FlTexture* texture =
310 fl_texture_registrar_lookup_texture(self->texture_registrar, texture_id);
311 if (texture == nullptr) {
312 g_warning("Unable to find texture %" G_GINT64_FORMAT, texture_id);
313 return false;
314 }
315
316 gboolean result;
317 g_autoptr(GError) error = nullptr;
318 if (FL_IS_TEXTURE_GL(texture)) {
319 result = fl_texture_gl_populate(FL_TEXTURE_GL(texture), width, height,
320 opengl_texture, &error);
321 } else if (FL_IS_PIXEL_BUFFER_TEXTURE(texture)) {
322 result =
323 fl_pixel_buffer_texture_populate(FL_PIXEL_BUFFER_TEXTURE(texture),
324 width, height, opengl_texture, &error);
325 } else {
326 g_warning("Unsupported texture type %" G_GINT64_FORMAT, texture_id);
327 return false;
328 }
329
330 if (!result) {
331 g_warning("%s", error->message);
332 return false;
333 }
334
335 return true;
336 }
fl_pixel_buffer_texture_populate
gboolean fl_pixel_buffer_texture_populate(FlPixelBufferTexture *texture, uint32_t width, uint32_t height, FlutterOpenGLTexture *opengl_texture, GError **error)
Definition: fl_pixel_buffer_texture.cc:71
fl_texture_gl_populate
gboolean fl_texture_gl_populate(FlTextureGL *self, uint32_t width, uint32_t height, FlutterOpenGLTexture *opengl_texture, GError **error)
Definition: fl_texture_gl.cc:50
fl_texture_registrar_lookup_texture
FlTexture * fl_texture_registrar_lookup_texture(FlTextureRegistrar *self, int64_t texture_id)
Definition: fl_texture_registrar.cc:190
texture_id
int64_t texture_id
Definition: texture_registrar_unittests.cc:24

References error, fl_pixel_buffer_texture_populate(), fl_texture_gl_populate(), fl_texture_registrar_lookup_texture(), height, texture_id, user_data, and width.

Referenced by fl_engine_start().

## ◆ fl_engine_gl_get_fbo()

static uint32_t fl_engine_gl_get_fbo | ( | void * | user_data | ) |
| static

Definition at line 280 of file fl_engine.cc.

280 {
281 FlEngine* self = static_cast<FlEngine*>(user_data);
282 return fl_renderer_get_fbo(self->renderer);
283 }
fl_renderer_get_fbo
guint32 fl_renderer_get_fbo(FlRenderer *self)
Definition: fl_renderer.cc:384

References fl_renderer_get_fbo(), and user_data.

Referenced by fl_engine_start().

## ◆ fl_engine_gl_make_current()

static bool fl_engine_gl_make_current | ( | void * | user_data | ) |
| static

Definition at line 268 of file fl_engine.cc.

268 {
269 FlEngine* self = static_cast<FlEngine*>(user_data);
270 fl_renderer_make_current(self->renderer);
271 return true;
272 }
fl_renderer_make_current
void fl_renderer_make_current(FlRenderer *self)
Definition: fl_renderer.cc:369

References fl_renderer_make_current(), and user_data.

Referenced by fl_engine_start().

## ◆ fl_engine_gl_make_resource_current()

static bool fl_engine_gl_make_resource_current | ( | void * | user_data | ) |
| static

Definition at line 291 of file fl_engine.cc.

291 {
292 FlEngine* self = static_cast<FlEngine*>(user_data);
293 fl_renderer_make_resource_current(self->renderer);
294 return true;
295 }
fl_renderer_make_resource_current
void fl_renderer_make_resource_current(FlRenderer *self)
Definition: fl_renderer.cc:374

References fl_renderer_make_resource_current(), and user_data.

Referenced by fl_engine_start().

## ◆ fl_engine_gl_present()

static bool fl_engine_gl_present | ( | void * | user_data | ) |
| static

Definition at line 285 of file fl_engine.cc.

285 {
286 // No action required, as this is handled in
287 // compositor_present_view_callback.
288 return true;
289 }

Referenced by fl_engine_start().

## ◆ fl_engine_gl_proc_resolver()

static void* fl_engine_gl_proc_resolver | ( | void * | user_data,
|  | const char * | name
| ) |  |
| static

Definition at line 263 of file fl_engine.cc.

263 {
264 FlEngine* self = static_cast<FlEngine*>(user_data);
265 return fl_renderer_get_proc_address(self->renderer, name);
266 }
fl_renderer_get_proc_address
void * fl_renderer_get_proc_address(FlRenderer *self, const char *name)
Definition: fl_renderer.cc:363

References fl_renderer_get_proc_address(), and user_data.

Referenced by fl_engine_start().

## ◆ fl_engine_init()

static void fl_engine_init | ( | FlEngine * | self | ) |
| static

Definition at line 495 of file fl_engine.cc.

495 {
496 self->thread = g_thread_self();
497
498 self->embedder_api.struct_size = sizeof(FlutterEngineProcTable);
499 if (FlutterEngineGetProcAddresses(&self->embedder_api) != kSuccess) {
500 g_warning("Failed get get engine function pointers");
501 }
502
503 // Implicit view is 0, so start at 1.
504 self->next_view_id = 1;
505
506 self->texture_registrar = fl_texture_registrar_new(self);
507 }
fl_texture_registrar_new
FlTextureRegistrar * fl_texture_registrar_new(FlEngine *engine)
Definition: fl_texture_registrar.cc:221

References fl_texture_registrar_new().

## ◆ fl_engine_mark_texture_frame_available()

gboolean fl_engine_mark_texture_frame_available | ( | FlEngine * | engine,
|  | int64_t | texture_id
| ) |  |

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.

Definition at line 1182 of file fl_engine.cc.

1183 {
1184 g_return_val_if_fail(FL_IS_ENGINE(self), FALSE);
1185 return self->embedder_api.MarkExternalTextureFrameAvailable(
1186 self->engine, texture_id) == kSuccess;
1187 }

References texture_id.

Referenced by mark_texture_frame_available().

## ◆ fl_engine_new()

G_MODULE_EXPORT FlEngine* fl_engine_new | ( | FlDartProject * | project | ) |

FlEngine:

#FlEngine is an object that contains a running Flutter engine. fl_engine_new: @project: an #FlDartProject.

Creates new Flutter engine.

Returns: a new #FlEngine.

Definition at line 524 of file fl_engine.cc.

524 {
525 g_autoptr(FlRendererGdk) renderer = fl_renderer_gdk_new();
526 return fl_engine_new_with_renderer(project, FL_RENDERER(renderer));
527 }
fl_engine_new_with_renderer
FlEngine * fl_engine_new_with_renderer(FlDartProject *project, FlRenderer *renderer)
Definition: fl_engine.cc:509
fl_renderer_gdk_new
FlRendererGdk * fl_renderer_gdk_new()
Definition: fl_renderer_gdk.cc:63

References fl_engine_new_with_renderer(), and fl_renderer_gdk_new().

Referenced by fl_view_new(), and TEST().

## ◆ fl_engine_new_headless()

G_MODULE_EXPORT FlEngine* fl_engine_new_headless | ( | FlDartProject * | project | ) |

fl_engine_new_headless: @project: an #FlDartProject.

Creates new Flutter engine running in headless mode.

Returns: a new #FlEngine.

Definition at line 529 of file fl_engine.cc.

529 {
530 g_autoptr(FlRendererHeadless) renderer = fl_renderer_headless_new();
531 return fl_engine_new_with_renderer(project, FL_RENDERER(renderer));
532 }
fl_renderer_headless_new
FlRendererHeadless * fl_renderer_headless_new()
Definition: fl_renderer_headless.cc:31

References fl_engine_new_with_renderer(), and fl_renderer_headless_new().

## ◆ fl_engine_new_with_renderer()

FlEngine* fl_engine_new_with_renderer | ( | FlDartProject * | project,
|  | FlRenderer * | renderer
| ) |  |

fl_engine_new_with_renderer: @project: an #FlDartProject. @renderer: an #FlRenderer.

Creates new Flutter engine.

Returns: a new #FlEngine.

Definition at line 509 of file fl_engine.cc.

510 {
511 g_return_val_if_fail(FL_IS_DART_PROJECT(project), nullptr);
512 g_return_val_if_fail(FL_IS_RENDERER(renderer), nullptr);
513
514 FlEngine* self = FL_ENGINE(g_object_new(fl_engine_get_type(), nullptr));
515 self->project = FL_DART_PROJECT(g_object_ref(project));
516 self->renderer = FL_RENDERER(g_object_ref(renderer));
517 self->binary_messenger = fl_binary_messenger_new(self);
518
519 fl_renderer_set_engine(self->renderer, self);
520
521 return self;
522 }
fl_binary_messenger_new
FlBinaryMessenger * fl_binary_messenger_new(FlEngine *engine)
Definition: fl_binary_messenger.cc:391
fl_renderer_set_engine
void fl_renderer_set_engine(FlRenderer *self, FlEngine *engine)
Definition: fl_renderer.cc:332

References fl_binary_messenger_new(), and fl_renderer_set_engine().

Referenced by fl_engine_new(), and fl_engine_new_headless().

## ◆ fl_engine_notify_display_update()

void fl_engine_notify_display_update | ( | FlEngine * | engine,
|  | const FlutterEngineDisplay * | displays,
|  | size_t | displays_length
| ) |  |

fl_engine_notify_display_update: @engine: an #FlEngine. @displays: displays present on the system. @displays_length: length of @displays.

Notify the current displays that are in the system.

Definition at line 665 of file fl_engine.cc.

667 {
668 g_return_if_fail(FL_IS_ENGINE(self));
669
670 FlutterEngineResult result = self->embedder_api.NotifyDisplayUpdate(
671 self->engine, kFlutterEngineDisplaysUpdateTypeStartup, displays,
672 displays_length);
673 if (result != kSuccess) {
674 g_warning("Failed to notify display update to Flutter engine: %d", result);
675 }
676 }

Referenced by notify_display_update(), and TEST().

## ◆ fl_engine_on_pre_engine_restart_cb()

static void fl_engine_on_pre_engine_restart_cb | ( | void * | user_data | ) |
| static

Definition at line 389 of file fl_engine.cc.

389 {
390 FlEngine* self = FL_ENGINE(user_data);
391
392 g_signal_emit(self, fl_engine_signals[SIGNAL_ON_PRE_ENGINE_RESTART], 0);
393 }

References fl_engine_signals, SIGNAL_ON_PRE_ENGINE_RESTART, and user_data.

Referenced by fl_engine_start().

## ◆ fl_engine_platform_message_cb()

static void fl_engine_platform_message_cb | ( | const FlutterPlatformMessage * | message,
|  | void * | user_data
| ) |  |
| static

Definition at line 354 of file fl_engine.cc.

355 {
356 FlEngine* self = FL_ENGINE(user_data);
357
358 gboolean handled = FALSE;
359 if (self->platform_message_handler != nullptr) {
360 g_autoptr(GBytes) data =
361 g_bytes_new(message->message, message->message_size);
362 handled = self->platform_message_handler(
363 self, message->channel, data, message->response_handle,
364 self->platform_message_handler_data);
365 }
366
367 if (!handled) {
368 fl_engine_send_platform_message_response(self, message->response_handle,
369 nullptr, nullptr);
370 }
371 }
fl_engine_send_platform_message_response
gboolean fl_engine_send_platform_message_response(FlEngine *self, const FlutterPlatformMessageResponseHandle *handle, GBytes *response, GError **error)
Definition: fl_engine.cc:796

References fl_engine_send_platform_message_response(), and user_data.

Referenced by fl_engine_start().

## ◆ fl_engine_platform_message_response_cb()

static void fl_engine_platform_message_response_cb | ( | const uint8_t * | data,
|  | size_t | data_length,
|  | void * | user_data
| ) |  |
| static

Definition at line 397 of file fl_engine.cc.

399 {
400 g_autoptr(GTask) task = G_TASK(user_data);
401 g_task_return_pointer(task, g_bytes_new(data, data_length),
402 reinterpret_cast<GDestroyNotify>(g_bytes_unref));
403 }

References user_data.

Referenced by fl_engine_send_platform_message().

## ◆ fl_engine_plugin_registry_iface_init()

static void fl_engine_plugin_registry_iface_init | ( | FlPluginRegistryInterface * | iface | ) |
| static

Definition at line 415 of file fl_engine.cc.

416 {
417 iface->get_registrar_for_plugin = fl_engine_get_registrar_for_plugin;
418 }
fl_engine_get_registrar_for_plugin
static FlPluginRegistrar * fl_engine_get_registrar_for_plugin(FlPluginRegistry *registry, const gchar *name)
Definition: fl_engine.cc:406

References fl_engine_get_registrar_for_plugin().

## ◆ fl_engine_post_task()

static void fl_engine_post_task | ( | FlutterTask | task,
|  | uint64_t | target_time_nanos,
|  | void * | user_data
| ) |  |
| static

Definition at line 345 of file fl_engine.cc.

347 {
348 FlEngine* self = static_cast<FlEngine*>(user_data);
349
350 fl_task_runner_post_task(self->task_runner, task, target_time_nanos);
351 }
fl_task_runner_post_task
void fl_task_runner_post_task(FlTaskRunner *self, FlutterTask task, uint64_t target_time_nanos)
Definition: fl_task_runner.cc:161

References fl_task_runner_post_task(), and user_data.

Referenced by fl_engine_start().

## ◆ fl_engine_register_external_texture()

gboolean fl_engine_register_external_texture | ( | 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.

Definition at line 1189 of file fl_engine.cc.

1190 {
1191 g_return_val_if_fail(FL_IS_ENGINE(self), FALSE);
1192 return self->embedder_api.RegisterExternalTexture(self->engine, texture_id) ==
1193 kSuccess;
1194 }

References texture_id.

Referenced by register_texture().

## ◆ fl_engine_remove_view()

void fl_engine_remove_view | ( | FlEngine * | engine,
|  | FlutterViewId | view_id,
|  | GCancellable * | cancellable,
|  | GAsyncReadyCallback | callback,
|  | gpointer | user_data
| ) |  |

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().

Definition at line 728 of file fl_engine.cc.

732 {
733 g_return_if_fail(FL_IS_ENGINE(self));
734
735 g_autoptr(GTask) task = g_task_new(self, cancellable, callback, user_data);
736
737 FlutterRemoveViewInfo info;
738 info.struct_size = sizeof(FlutterRemoveViewInfo);
739 info.view_id = view_id;
740 info.user_data = g_object_ref(task);
741 info.remove_view_callback = view_removed_cb;
742 FlutterEngineResult result =
743 self->embedder_api.RemoveView(self->engine, &info);
744 if (result != kSuccess) {
745 g_task_return_new_error(task, fl_engine_error_quark(),
746 FL_ENGINE_ERROR_FAILED, "RemoveView returned %d",
747 result);
748 // This would have been done in the callback, but that won't occur now.
749 g_object_unref(task);
750 }
751 }
view_removed_cb
static void view_removed_cb(const FlutterRemoveViewResult *result)
Definition: fl_engine.cc:166

References FL_ENGINE_ERROR_FAILED, fl_engine_error_quark(), user_data, and view_removed_cb().

Referenced by fl_view_dispose(), and TEST().

## ◆ fl_engine_remove_view_finish()

gboolean fl_engine_remove_view_finish | ( | FlEngine * | engine,
|  | GAsyncResult * | result,
|  | GError ** | error
| ) |  |

fl_engine_remove_view_finish: @engine: an #FlEngine.

Returns
  : 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.

Definition at line 753 of file fl_engine.cc.

755 {
756 g_return_val_if_fail(FL_IS_ENGINE(self), FALSE);
757 return g_task_propagate_boolean(G_TASK(result), error);
758 }

References error.

Referenced by remove_view_cb(), remove_view_engine_error_cb(), and remove_view_error_cb().

## ◆ fl_engine_request_app_exit()

void fl_engine_request_app_exit | ( | FlEngine * | engine | ) |

fl_engine_request_app_exit: @engine: an #FlEngine.

Request the application exits.

Definition at line 1236 of file fl_engine.cc.

1236 {
1237 g_return_if_fail(FL_IS_ENGINE(self));
1238 fl_platform_handler_request_app_exit(self->platform_handler);
1239 }
fl_platform_handler_request_app_exit
void fl_platform_handler_request_app_exit(FlPlatformHandler *self)
Definition: fl_platform_handler.cc:264

References fl_platform_handler_request_app_exit().

Referenced by window_delete_event_cb().

## ◆ fl_engine_runs_task_on_current_thread()

static bool fl_engine_runs_task_on_current_thread | ( | void * | user_data | ) |
| static

Definition at line 339 of file fl_engine.cc.

339 {
340 FlEngine* self = static_cast<FlEngine*>(user_data);
341 return self->thread == g_thread_self();
342 }

References user_data.

Referenced by fl_engine_start().

## ◆ fl_engine_send_key_event()

void fl_engine_send_key_event | ( | FlEngine * | engine,
|  | const FlutterKeyEvent * | event,
|  | GCancellable * | cancellable,
|  | GAsyncReadyCallback | callback,
|  | gpointer | user_data
| ) |  |

fl_engine_send_key_event: @engine: an #FlEngine. @event: key event to send. @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.

Send a key event to the engine.

Definition at line 1121 of file fl_engine.cc.

1125 {
1126 g_return_if_fail(FL_IS_ENGINE(self));
1127
1128 g_autoptr(GTask) task = g_task_new(self, cancellable, callback, user_data);
1129
1130 if (self->engine == nullptr) {
1131 g_task_return_new_error(task, fl_engine_error_quark(),
1132 FL_ENGINE_ERROR_FAILED, "No engine");
1133 return;
1134 }
1135
1136 if (self->embedder_api.SendKeyEvent(self->engine, event, send_key_event_cb,
1137 g_object_ref(task)) != kSuccess) {
1138 g_task_return_new_error(task, fl_engine_error_quark(),
1139 FL_ENGINE_ERROR_FAILED, "Failed to send key event");
1140 g_object_unref(task);
1141 }
1142 }
send_key_event_cb
static void send_key_event_cb(bool handled, void *user_data)
Definition: fl_engine.cc:1114

References FL_ENGINE_ERROR_FAILED, fl_engine_error_quark(), send_key_event_cb(), and user_data.

Referenced by fl_keyboard_manager_new(), and TEST().

## ◆ fl_engine_send_key_event_finish()

gboolean fl_engine_send_key_event_finish | ( | FlEngine * | engine,
|  | GAsyncResult * | result,
|  | gboolean * | handled,
|  | GError ** | error
| ) |  |

fl_engine_send_key_event_finish: @engine: an #FlEngine.

Returns
  : a #GAsyncResult. @handled: location to write if this event was handled by the engine. @error: (allow-none): #GError location to store the error occurring, or NULL to ignore.

Completes request started with fl_engine_send_key_event().

Returns: TRUE on success.

Definition at line 1144 of file fl_engine.cc.

1147 {
1148 g_return_val_if_fail(FL_IS_ENGINE(self), FALSE);
1149 g_return_val_if_fail(g_task_is_valid(result, self), FALSE);
1150
1151 g_autofree gboolean* return_value =
1152 static_cast<gboolean*>(g_task_propagate_pointer(G_TASK(result), error));
1153 if (return_value == nullptr) {
1154 return FALSE;
1155 }
1156
1157 *handled = *return_value;
1158 return TRUE;
1159 }
TRUE
return TRUE
Definition: fl_pixel_buffer_texture_test.cc:53

References error, and TRUE.

Referenced by TEST().

## ◆ fl_engine_send_mouse_pointer_event()

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_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.

Definition at line 918 of file fl_engine.cc.

927 {
928 g_return_if_fail(FL_IS_ENGINE(self));
929
930 if (self->engine == nullptr) {
931 return;
932 }
933
934 FlutterPointerEvent fl_event = {};
935 fl_event.struct_size = sizeof(fl_event);
936 fl_event.phase = phase;
937 fl_event.timestamp = timestamp;
938 fl_event.x = x;
939 fl_event.y = y;
940 if (scroll_delta_x != 0 || scroll_delta_y != 0) {
941 fl_event.signal_kind = kFlutterPointerSignalKindScroll;
942 }
943 fl_event.scroll_delta_x = scroll_delta_x;
944 fl_event.scroll_delta_y = scroll_delta_y;
945 fl_event.device_kind = device_kind;
946 fl_event.buttons = buttons;
947 fl_event.device = kMousePointerDeviceId;
948 fl_event.view_id = view_id;
949 self->embedder_api.SendPointerEvent(self->engine, &fl_event, 1);
950 }
kMousePointerDeviceId
static constexpr int32_t kMousePointerDeviceId
Definition: fl_engine.cc:33

References kMousePointerDeviceId.

Referenced by ensure_pointer_added(), fl_pointer_manager_handle_button_press(), fl_pointer_manager_handle_button_release(), fl_pointer_manager_handle_leave(), fl_pointer_manager_handle_motion(), fl_scrolling_manager_handle_scroll_event(), and TEST().

## ◆ fl_engine_send_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: @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.

Definition at line 828 of file fl_engine.cc.

833 {
834 g_return_if_fail(FL_IS_ENGINE(self));
835
836 GTask* task = nullptr;
837 FlutterPlatformMessageResponseHandle* response_handle = nullptr;
838 if (callback != nullptr) {
839 task = g_task_new(self, cancellable, callback, user_data);
840
841 if (self->engine == nullptr) {
842 g_task_return_new_error(task, fl_engine_error_quark(),
843 FL_ENGINE_ERROR_FAILED, "No engine to send to");
844 return;
845 }
846
847 FlutterEngineResult result =
848 self->embedder_api.PlatformMessageCreateResponseHandle(
849 self->engine, fl_engine_platform_message_response_cb, task,
850 &response_handle);
851 if (result != kSuccess) {
852 g_task_return_new_error(task, fl_engine_error_quark(),
853 FL_ENGINE_ERROR_FAILED,
854 "Failed to create response handle");
855 g_object_unref(task);
856 return;
857 }
858 } else if (self->engine == nullptr) {
859 return;
860 }
861
862 FlutterPlatformMessage fl_message = {};
863 fl_message.struct_size = sizeof(fl_message);
864 fl_message.channel = channel;
865 fl_message.message =
866 message != nullptr
867 ? static_cast<const uint8_t*>(g_bytes_get_data(message, nullptr))
868 : nullptr;
869 fl_message.message_size = message != nullptr ? g_bytes_get_size(message) : 0;
870 fl_message.response_handle = response_handle;
871 FlutterEngineResult result =
872 self->embedder_api.SendPlatformMessage(self->engine, &fl_message);
873
874 if (result != kSuccess && task != nullptr) {
875 g_task_return_new_error(task, fl_engine_error_quark(),
876 FL_ENGINE_ERROR_FAILED,
877 "Failed to send platform messages");
878 g_object_unref(task);
879 }
880
881 if (response_handle != nullptr) {
882 self->embedder_api.PlatformMessageReleaseResponseHandle(self->engine,
883 response_handle);
884 }
885 }
fl_engine_platform_message_response_cb
static void fl_engine_platform_message_response_cb(const uint8_t *data, size_t data_length, void *user_data)
Definition: fl_engine.cc:397

References FL_ENGINE_ERROR_FAILED, fl_engine_error_quark(), fl_engine_platform_message_response_cb(), and user_data.

Referenced by send_on_channel(), and TEST().

## ◆ fl_engine_send_platform_message_finish()

GBytes* fl_engine_send_platform_message_finish | ( | FlEngine * | engine,
|  | GAsyncResult * | result,
|  | GError ** | error
| ) |  |

fl_engine_send_platform_message_finish: @engine: an #FlEngine.

Returns
  : 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.

Definition at line 887 of file fl_engine.cc.

889 {
890 g_return_val_if_fail(FL_IS_ENGINE(self), FALSE);
891 g_return_val_if_fail(g_task_is_valid(result, self), FALSE);
892
893 return static_cast<GBytes*>(g_task_propagate_pointer(G_TASK(result), error));
894 }

References error.

Referenced by send_on_channel_finish().

## ◆ fl_engine_send_platform_message_response()

gboolean fl_engine_send_platform_message_response | ( | FlEngine * | engine,
|  | const FlutterPlatformMessageResponseHandle * | handle,
|  | GBytes * | response,
|  | GError ** | error
| ) |  |

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.

Definition at line 796 of file fl_engine.cc.

800 {
801 g_return_val_if_fail(FL_IS_ENGINE(self), FALSE);
802 g_return_val_if_fail(handle != nullptr, FALSE);
803
804 if (self->engine == nullptr) {
805 g_set_error(error, fl_engine_error_quark(), FL_ENGINE_ERROR_FAILED,
806 "No engine to send response to");
807 return FALSE;
808 }
809
810 gsize data_length = 0;
811 const uint8_t* data = nullptr;
812 if (response != nullptr) {
813 data =
814 static_cast<const uint8_t*>(g_bytes_get_data(response, &data_length));
815 }
816 FlutterEngineResult result = self->embedder_api.SendPlatformMessageResponse(
817 self->engine, handle, data, data_length);
818
819 if (result != kSuccess) {
820 g_set_error(error, fl_engine_error_quark(), FL_ENGINE_ERROR_FAILED,
821 "Failed to send platform message response");
822 return FALSE;
823 }
824
825 return TRUE;
826 }

References error, FL_ENGINE_ERROR_FAILED, fl_engine_error_quark(), and TRUE.

Referenced by fl_engine_platform_message_cb(), send_response(), and TEST().

## ◆ fl_engine_send_pointer_pan_zoom_event()

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_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.

Definition at line 1082 of file fl_engine.cc.

1091 {
1092 g_return_if_fail(FL_IS_ENGINE(self));
1093
1094 if (self->engine == nullptr) {
1095 return;
1096 }
1097
1098 FlutterPointerEvent fl_event = {};
1099 fl_event.struct_size = sizeof(fl_event);
1100 fl_event.timestamp = timestamp;
1101 fl_event.x = x;
1102 fl_event.y = y;
1103 fl_event.phase = phase;
1104 fl_event.pan_x = pan_x;
1105 fl_event.pan_y = pan_y;
1106 fl_event.scale = scale;
1107 fl_event.rotation = rotation;
1108 fl_event.device = kPointerPanZoomDeviceId;
1109 fl_event.device_kind = kFlutterPointerDeviceKindTrackpad;
1110 fl_event.view_id = view_id;
1111 self->embedder_api.SendPointerEvent(self->engine, &fl_event, 1);
1112 }
kPointerPanZoomDeviceId
static constexpr int32_t kPointerPanZoomDeviceId
Definition: fl_engine.cc:34

References kPointerPanZoomDeviceId.

Referenced by fl_scrolling_manager_handle_rotation_begin(), fl_scrolling_manager_handle_rotation_end(), fl_scrolling_manager_handle_rotation_update(), fl_scrolling_manager_handle_scroll_event(), fl_scrolling_manager_handle_zoom_begin(), fl_scrolling_manager_handle_zoom_end(), fl_scrolling_manager_handle_zoom_update(), and TEST().

## ◆ fl_engine_send_touch_add_event()

void fl_engine_send_touch_add_event | ( | FlEngine * | engine,
|  | FlutterViewId | view_id,
|  | size_t | timestamp,
|  | double | x,
|  | double | y,
|  | int32_t | device
| ) |  |

fl_engine_send_touch_add_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. @device: device id.

Sends a touch add event to the engine.

Definition at line 1030 of file fl_engine.cc.

1035 {
1036 g_return_if_fail(FL_IS_ENGINE(self));
1037
1038 if (self->engine == nullptr) {
1039 return;
1040 }
1041
1042 FlutterPointerEvent event;
1043 event.timestamp = timestamp;
1044 event.x = x;
1045 event.y = y;
1046 event.device_kind = kFlutterPointerDeviceKindTouch;
1047 event.device = device;
1048 event.buttons = 0;
1049 event.view_id = view_id;
1050 event.phase = FlutterPointerPhase::kAdd;
1051 event.struct_size = sizeof(event);
1052
1053 self->embedder_api.SendPointerEvent(self->engine, &event, 1);
1054 }

Referenced by ensure_touch_added().

## ◆ fl_engine_send_touch_down_event()

void fl_engine_send_touch_down_event | ( | FlEngine * | engine,
|  | FlutterViewId | view_id,
|  | size_t | timestamp,
|  | double | x,
|  | double | y,
|  | int32_t | device
| ) |  |

fl_engine_send_touch_down_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. @device: device id.

Sends a touch down event to the engine.

Definition at line 978 of file fl_engine.cc.

983 {
984 g_return_if_fail(FL_IS_ENGINE(self));
985
986 if (self->engine == nullptr) {
987 return;
988 }
989
990 FlutterPointerEvent event;
991 event.timestamp = timestamp;
992 event.x = x;
993 event.y = y;
994 event.device_kind = kFlutterPointerDeviceKindTouch;
995 event.device = device;
996 event.buttons = FlutterPointerMouseButtons::kFlutterPointerButtonMousePrimary;
997 event.view_id = view_id;
998 event.phase = FlutterPointerPhase::kDown;
999 event.struct_size = sizeof(event);
1000
1001 self->embedder_api.SendPointerEvent(self->engine, &event, 1);
1002 }

Referenced by fl_touch_manager_handle_touch_event().

## ◆ fl_engine_send_touch_move_event()

void fl_engine_send_touch_move_event | ( | FlEngine * | engine,
|  | FlutterViewId | view_id,
|  | size_t | timestamp,
|  | double | x,
|  | double | y,
|  | int32_t | device
| ) |  |

fl_engine_send_touch_move_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. @device: device id.

Sends a touch move event to the engine.

Definition at line 1004 of file fl_engine.cc.

1009 {
1010 g_return_if_fail(FL_IS_ENGINE(self));
1011
1012 if (self->engine == nullptr) {
1013 return;
1014 }
1015
1016 FlutterPointerEvent event;
1017 event.timestamp = timestamp;
1018 event.x = x;
1019 event.y = y;
1020 event.device_kind = kFlutterPointerDeviceKindTouch;
1021 event.device = device;
1022 event.buttons = FlutterPointerMouseButtons::kFlutterPointerButtonMousePrimary;
1023 event.view_id = view_id;
1024 event.phase = FlutterPointerPhase::kMove;
1025 event.struct_size = sizeof(event);
1026
1027 self->embedder_api.SendPointerEvent(self->engine, &event, 1);
1028 }

Referenced by fl_touch_manager_handle_touch_event().

## ◆ fl_engine_send_touch_remove_event()

void fl_engine_send_touch_remove_event | ( | FlEngine * | engine,
|  | FlutterViewId | view_id,
|  | size_t | timestamp,
|  | double | x,
|  | double | y,
|  | int32_t | device
| ) |  |

fl_engine_send_touch_remove_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. @device: device id.

Sends a touch remove event to the engine.

Definition at line 1056 of file fl_engine.cc.

1061 {
1062 g_return_if_fail(FL_IS_ENGINE(self));
1063
1064 if (self->engine == nullptr) {
1065 return;
1066 }
1067
1068 FlutterPointerEvent event;
1069 event.timestamp = timestamp;
1070 event.x = x;
1071 event.y = y;
1072 event.device_kind = kFlutterPointerDeviceKindTouch;
1073 event.device = device;
1074 event.buttons = 0;
1075 event.view_id = view_id;
1076 event.phase = FlutterPointerPhase::kRemove;
1077 event.struct_size = sizeof(event);
1078
1079 self->embedder_api.SendPointerEvent(self->engine, &event, 1);
1080 }

Referenced by fl_touch_manager_handle_touch_event().

## ◆ fl_engine_send_touch_up_event()

void fl_engine_send_touch_up_event | ( | FlEngine * | engine,
|  | FlutterViewId | view_id,
|  | size_t | timestamp,
|  | double | x,
|  | double | y,
|  | int32_t | device
| ) |  |

fl_engine_send_touch_up_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. @device: device id.

Sends a touch up event to the engine.

Definition at line 952 of file fl_engine.cc.

957 {
958 g_return_if_fail(FL_IS_ENGINE(self));
959
960 if (self->engine == nullptr) {
961 return;
962 }
963
964 FlutterPointerEvent event;
965 event.timestamp = timestamp;
966 event.x = x;
967 event.y = y;
968 event.device_kind = kFlutterPointerDeviceKindTouch;
969 event.device = device;
970 event.buttons = 0;
971 event.view_id = view_id;
972 event.phase = FlutterPointerPhase::kUp;
973 event.struct_size = sizeof(event);
974
975 self->embedder_api.SendPointerEvent(self->engine, &event, 1);
976 }

Referenced by fl_touch_manager_handle_touch_event().

## ◆ fl_engine_send_window_metrics_event()

void fl_engine_send_window_metrics_event | ( | FlEngine * | engine,
|  | FlutterEngineDisplayId | display_id,
|  | FlutterViewId | view_id,
|  | size_t | width,
|  | size_t | height,
|  | double | pixel_ratio
| ) |  |

fl_engine_send_window_metrics_event: @engine: an #FlEngine. @display_id: the display this view is rendering on. @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.

Definition at line 896 of file fl_engine.cc.

901 {
902 g_return_if_fail(FL_IS_ENGINE(self));
903
904 if (self->engine == nullptr) {
905 return;
906 }
907
908 FlutterWindowMetricsEvent event = {};
909 event.struct_size = sizeof(FlutterWindowMetricsEvent);
910 event.width = width;
911 event.height = height;
912 event.pixel_ratio = pixel_ratio;
913 event.display_id = display_id;
914 event.view_id = view_id;
915 self->embedder_api.SendWindowMetricsEvent(self->engine, &event);
916 }

References height, and width.

Referenced by handle_geometry_changed(), and TEST().

## ◆ fl_engine_set_platform_message_handler()

void fl_engine_set_platform_message_handler | ( | FlEngine * | engine,
|  | FlEnginePlatformMessageHandler | handler,
|  | gpointer | user_data,
|  | GDestroyNotify | destroy_notify
| ) |  |

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.

Definition at line 760 of file fl_engine.cc.

764 {
765 g_return_if_fail(FL_IS_ENGINE(self));
766 g_return_if_fail(handler != nullptr);
767
768 if (self->platform_message_handler_destroy_notify) {
769 self->platform_message_handler_destroy_notify(
770 self->platform_message_handler_data);
771 }
772
773 self->platform_message_handler = handler;
774 self->platform_message_handler_data = user_data;
775 self->platform_message_handler_destroy_notify = destroy_notify;
776 }

References user_data.

Referenced by fl_binary_messenger_new().

## ◆ fl_engine_set_property()

static void fl_engine_set_property | ( | GObject * | object,
|  | guint | prop_id,
|  | const GValue * | value,
|  | GParamSpec * | pspec
| ) |  |
| static

Definition at line 420 of file fl_engine.cc.

423 {
424 FlEngine* self = FL_ENGINE(object);
425 switch (prop_id) {
426 case PROP_BINARY_MESSENGER:
427 g_set_object(&self->binary_messenger,
428 FL_BINARY_MESSENGER(g_value_get_object(value)));
429 break;
430 default:
431 G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
432 break;
433 }
434 }
value
uint8_t value
Definition: fl_standard_message_codec.cc:36
prop_id
guint prop_id
Definition: fl_standard_method_codec.cc:31
pspec
guint const GValue GParamSpec * pspec
Definition: fl_standard_method_codec.cc:33

References prop_id, pspec, and value.

Referenced by fl_engine_class_init().

## ◆ fl_engine_set_update_semantics_handler()

void fl_engine_set_update_semantics_handler | ( | FlEngine * | engine,
|  | FlEngineUpdateSemanticsHandler | 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.

Definition at line 778 of file fl_engine.cc.

782 {
783 g_return_if_fail(FL_IS_ENGINE(self));
784
785 if (self->update_semantics_handler_destroy_notify) {
786 self->update_semantics_handler_destroy_notify(
787 self->update_semantics_handler_data);
788 }
789
790 self->update_semantics_handler = handler;
791 self->update_semantics_handler_data = user_data;
792 self->update_semantics_handler_destroy_notify = destroy_notify;
793 }

References user_data.

Referenced by fl_view_dispose(), and fl_view_new().

## ◆ fl_engine_start()

gboolean fl_engine_start | ( | FlEngine * | engine,
|  | GError ** | error
| ) |  |

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.

Definition at line 544 of file fl_engine.cc.

544 {
545 g_return_val_if_fail(FL_IS_ENGINE(self), FALSE);
546
547 self->task_runner = fl_task_runner_new(self);
548
549 FlutterRendererConfig config = {};
550 config.type = kOpenGL;
551 config.open_gl.struct_size = sizeof(FlutterOpenGLRendererConfig);
552 config.open_gl.gl_proc_resolver = fl_engine_gl_proc_resolver;
553 config.open_gl.make_current = fl_engine_gl_make_current;
554 config.open_gl.clear_current = fl_engine_gl_clear_current;
555 config.open_gl.fbo_callback = fl_engine_gl_get_fbo;
556 config.open_gl.present = fl_engine_gl_present;
557 config.open_gl.make_resource_current = fl_engine_gl_make_resource_current;
558 config.open_gl.gl_external_texture_frame_callback =
559 fl_engine_gl_external_texture_frame_callback;
560
561 FlutterTaskRunnerDescription platform_task_runner = {};
562 platform_task_runner.struct_size = sizeof(FlutterTaskRunnerDescription);
563 platform_task_runner.user_data = self;
564 platform_task_runner.runs_task_on_current_thread_callback =
565 fl_engine_runs_task_on_current_thread;
566 platform_task_runner.post_task_callback = fl_engine_post_task;
567 platform_task_runner.identifier = kPlatformTaskRunnerIdentifier;
568
569 FlutterCustomTaskRunners custom_task_runners = {};
570 custom_task_runners.struct_size = sizeof(FlutterCustomTaskRunners);
571 custom_task_runners.platform_task_runner = &platform_task_runner;
572 custom_task_runners.render_task_runner = &platform_task_runner;
573
574 g_autoptr(GPtrArray) command_line_args =
575 g_ptr_array_new_with_free_func(g_free);
576 g_ptr_array_insert(command_line_args, 0, g_strdup("flutter"));
577 for (const auto& env_switch : flutter::GetSwitchesFromEnvironment()) {
578 g_ptr_array_add(command_line_args, g_strdup(env_switch.c_str()));
579 }
580
581 gchar** dart_entrypoint_args =
582 fl_dart_project_get_dart_entrypoint_arguments(self->project);
583
584 FlutterProjectArgs args = {};
585 args.struct_size = sizeof(FlutterProjectArgs);
586 args.assets_path = fl_dart_project_get_assets_path(self->project);
587 args.icu_data_path = fl_dart_project_get_icu_data_path(self->project);
588 args.command_line_argc = command_line_args->len;
589 args.command_line_argv =
590 reinterpret_cast<const char* const*>(command_line_args->pdata);
591 args.platform_message_callback = fl_engine_platform_message_cb;
592 args.update_semantics_callback2 = fl_engine_update_semantics_cb;
593 args.custom_task_runners = &custom_task_runners;
594 args.shutdown_dart_vm_when_done = true;
595 args.on_pre_engine_restart_callback = fl_engine_on_pre_engine_restart_cb;
596 args.dart_entrypoint_argc =
597 dart_entrypoint_args != nullptr ? g_strv_length(dart_entrypoint_args) : 0;
598 args.dart_entrypoint_argv =
599 reinterpret_cast<const char* const*>(dart_entrypoint_args);
600
601 FlutterCompositor compositor = {};
602 compositor.struct_size = sizeof(FlutterCompositor);
603 compositor.user_data = self->renderer;
604 compositor.create_backing_store_callback =
605 compositor_create_backing_store_callback;
606 compositor.collect_backing_store_callback =
607 compositor_collect_backing_store_callback;
608 compositor.present_view_callback = compositor_present_view_callback;
609 args.compositor = &compositor;
610
611 if (self->embedder_api.RunsAOTCompiledDartCode()) {
612 FlutterEngineAOTDataSource source = {};
613 source.type = kFlutterEngineAOTDataSourceTypeElfPath;
614 source.elf_path = fl_dart_project_get_aot_library_path(self->project);
615 if (self->embedder_api.CreateAOTData(&source, &self->aot_data) !=
616 kSuccess) {
617 g_set_error(error, fl_engine_error_quark(), FL_ENGINE_ERROR_FAILED,
618 "Failed to create AOT data");
619 return FALSE;
620 }
621 args.aot_data = self->aot_data;
622 }
623
624 FlutterEngineResult result = self->embedder_api.Initialize(
625 FLUTTER_ENGINE_VERSION, &config, &args, self, &self->engine);
626 if (result != kSuccess) {
627 g_set_error(error, fl_engine_error_quark(), FL_ENGINE_ERROR_FAILED,
628 "Failed to initialize Flutter engine");
629 return FALSE;
630 }
631
632 result = self->embedder_api.RunInitialized(self->engine);
633 if (result != kSuccess) {
634 g_set_error(error, fl_engine_error_quark(), FL_ENGINE_ERROR_FAILED,
635 "Failed to run Flutter engine");
636 return FALSE;
637 }
638
639 setup_locales(self);
640
641 g_autoptr(FlSettings) settings = fl_settings_new();
642 self->settings_handler = fl_settings_handler_new(self);
643 fl_settings_handler_start(self->settings_handler, settings);
644
645 self->platform_handler = fl_platform_handler_new(self->binary_messenger);
646 self->mouse_cursor_handler =
647 fl_mouse_cursor_handler_new(self->binary_messenger);
648
649 result = self->embedder_api.UpdateSemanticsEnabled(self->engine, TRUE);
650 if (result != kSuccess) {
651 g_warning("Failed to enable accessibility features on Flutter engine");
652 }
653
654 self->display_monitor =
655 fl_display_monitor_new(self, gdk_display_get_default());
656 fl_display_monitor_start(self->display_monitor);
657
658 return TRUE;
659 }
fl_dart_project_get_aot_library_path
G_MODULE_EXPORT const gchar * fl_dart_project_get_aot_library_path(FlDartProject *self)
Definition: fl_dart_project.cc:72
fl_dart_project_get_dart_entrypoint_arguments
G_MODULE_EXPORT gchar ** fl_dart_project_get_dart_entrypoint_arguments(FlDartProject *self)
Definition: fl_dart_project.cc:104
fl_dart_project_get_icu_data_path
G_MODULE_EXPORT const gchar * fl_dart_project_get_icu_data_path(FlDartProject *self)
Definition: fl_dart_project.cc:98
fl_dart_project_get_assets_path
G_MODULE_EXPORT const gchar * fl_dart_project_get_assets_path(FlDartProject *self)
Definition: fl_dart_project.cc:85
fl_display_monitor_start
void fl_display_monitor_start(FlDisplayMonitor *self)
Definition: fl_display_monitor.cc:103
fl_display_monitor_new
FlDisplayMonitor * fl_display_monitor_new(FlEngine *engine, GdkDisplay *display)
Definition: fl_display_monitor.cc:94
fl_engine_gl_external_texture_frame_callback
static bool fl_engine_gl_external_texture_frame_callback(void *user_data, int64_t texture_id, size_t width, size_t height, FlutterOpenGLTexture *opengl_texture)
Definition: fl_engine.cc:298
fl_engine_runs_task_on_current_thread
static bool fl_engine_runs_task_on_current_thread(void *user_data)
Definition: fl_engine.cc:339
fl_engine_on_pre_engine_restart_cb
static void fl_engine_on_pre_engine_restart_cb(void *user_data)
Definition: fl_engine.cc:389
compositor_create_backing_store_callback
static bool compositor_create_backing_store_callback(const FlutterBackingStoreConfig *config, FlutterBackingStore *backing_store_out, void *user_data)
Definition: fl_engine.cc:235
fl_engine_gl_make_current
static bool fl_engine_gl_make_current(void *user_data)
Definition: fl_engine.cc:268
compositor_present_view_callback
static bool compositor_present_view_callback(const FlutterPresentViewInfo *info)
Definition: fl_engine.cc:254
compositor_collect_backing_store_callback
static bool compositor_collect_backing_store_callback(const FlutterBackingStore *backing_store, void *user_data)
Definition: fl_engine.cc:245
fl_engine_post_task
static void fl_engine_post_task(FlutterTask task, uint64_t target_time_nanos, void *user_data)
Definition: fl_engine.cc:345
fl_engine_gl_get_fbo
static uint32_t fl_engine_gl_get_fbo(void *user_data)
Definition: fl_engine.cc:280
fl_engine_gl_proc_resolver
static void * fl_engine_gl_proc_resolver(void *user_data, const char *name)
Definition: fl_engine.cc:263
fl_engine_gl_present
static bool fl_engine_gl_present(void *user_data)
Definition: fl_engine.cc:285
setup_locales
static void setup_locales(FlEngine *self)
Definition: fl_engine.cc:184
fl_engine_update_semantics_cb
static void fl_engine_update_semantics_cb(const FlutterSemanticsUpdate2 *update, void *user_data)
Definition: fl_engine.cc:374
fl_engine_gl_make_resource_current
static bool fl_engine_gl_make_resource_current(void *user_data)
Definition: fl_engine.cc:291
fl_engine_platform_message_cb
static void fl_engine_platform_message_cb(const FlutterPlatformMessage *message, void *user_data)
Definition: fl_engine.cc:354
kPlatformTaskRunnerIdentifier
static constexpr size_t kPlatformTaskRunnerIdentifier
Definition: fl_engine.cc:29
fl_engine_gl_clear_current
static bool fl_engine_gl_clear_current(void *user_data)
Definition: fl_engine.cc:274
args
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
Definition: fl_event_channel.h:89
fl_mouse_cursor_handler_new
FlMouseCursorHandler * fl_mouse_cursor_handler_new(FlBinaryMessenger *messenger)
Definition: fl_mouse_cursor_handler.cc:134
fl_platform_handler_new
FlPlatformHandler * fl_platform_handler_new(FlBinaryMessenger *messenger)
Definition: fl_platform_handler.cc:251
fl_settings_new
FlSettings * fl_settings_new()
Definition: fl_settings.cc:55
fl_settings_handler_start
void fl_settings_handler_start(FlSettingsHandler *self, FlSettings *settings)
Definition: fl_settings_handler.cc:88
fl_settings_handler_new
FlSettingsHandler * fl_settings_handler_new(FlEngine *engine)
Definition: fl_settings_handler.cc:74
fl_task_runner_new
FlTaskRunner * fl_task_runner_new(FlEngine *engine)
Definition: fl_task_runner.cc:154
flutter::GetSwitchesFromEnvironment
std::vector< std::string > GetSwitchesFromEnvironment()
Definition: engine_switches.cc:14

References args, compositor_collect_backing_store_callback(), compositor_create_backing_store_callback(), compositor_present_view_callback(), error, fl_dart_project_get_aot_library_path(), fl_dart_project_get_assets_path(), fl_dart_project_get_dart_entrypoint_arguments(), fl_dart_project_get_icu_data_path(), fl_display_monitor_new(), fl_display_monitor_start(), FL_ENGINE_ERROR_FAILED, fl_engine_error_quark(), fl_engine_gl_clear_current(), fl_engine_gl_external_texture_frame_callback(), fl_engine_gl_get_fbo(), fl_engine_gl_make_current(), fl_engine_gl_make_resource_current(), fl_engine_gl_present(), fl_engine_gl_proc_resolver(), fl_engine_on_pre_engine_restart_cb(), fl_engine_platform_message_cb(), fl_engine_post_task(), fl_engine_runs_task_on_current_thread(), fl_engine_update_semantics_cb(), fl_mouse_cursor_handler_new(), fl_platform_handler_new(), fl_settings_handler_new(), fl_settings_handler_start(), fl_settings_new(), fl_task_runner_new(), flutter::GetSwitchesFromEnvironment(), kPlatformTaskRunnerIdentifier, setup_locales(), and TRUE.

Referenced by realize_cb(), and TEST().

## ◆ fl_engine_unregister_external_texture()

gboolean fl_engine_unregister_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.

Definition at line 1196 of file fl_engine.cc.

1197 {
1198 g_return_val_if_fail(FL_IS_ENGINE(self), FALSE);
1199 return self->embedder_api.UnregisterExternalTexture(self->engine,
1200 texture_id) == kSuccess;
1201 }

References texture_id.

Referenced by unregister_texture().

## ◆ fl_engine_update_accessibility_features()

void fl_engine_update_accessibility_features | ( | FlEngine * | engine,
|  | int32_t | flags
| ) |  |

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.

Definition at line 1225 of file fl_engine.cc.

1225 {
1226 g_return_if_fail(FL_IS_ENGINE(self));
1227
1228 if (self->engine == nullptr) {
1229 return;
1230 }
1231
1232 self->embedder_api.UpdateAccessibilityFeatures(
1233 self->engine, static_cast<FlutterAccessibilityFeature>(flags));
1234 }
flags
FlutterSemanticsFlag flags
Definition: fl_accessible_node.cc:106

References flags.

Referenced by update_settings().

## ◆ fl_engine_update_semantics_cb()

static void fl_engine_update_semantics_cb | ( | const FlutterSemanticsUpdate2 * | update,
|  | void * | user_data
| ) |  |
| static

Definition at line 374 of file fl_engine.cc.

375 {
376 FlEngine* self = FL_ENGINE(user_data);
377
378 if (self->update_semantics_handler != nullptr) {
379 self->update_semantics_handler(self, update,
380 self->update_semantics_handler_data);
381 }
382 }

References user_data.

Referenced by fl_engine_start().

## ◆ free_locale()

static void free_locale | ( | FlutterLocale * | locale | ) |
| static

Definition at line 177 of file fl_engine.cc.

177 {
178 free(const_cast<gchar*>(locale->language_code));
179 free(const_cast<gchar*>(locale->country_code));
180 free(locale);
181 }

Referenced by setup_locales().

## ◆ G_DEFINE_TYPE_WITH_CODE()

G_DEFINE_TYPE_WITH_CODE | ( | FlEngine | ,
|  | fl_engine | ,
|  | G_TYPE_OBJECT | ,
|  | G_IMPLEMENT_INTERFACE(fl_plugin_registry_get_type(), fl_engine_plugin_registry_iface_init) |
| ) |  |

Definition at line 102 of file fl_engine.cc.

109 { PROP_0, PROP_BINARY_MESSENGER, PROP_LAST };
PROP_LAST
@ PROP_LAST
Definition: fl_accessible_node.cc:84
PROP_0
@ PROP_0
Definition: fl_accessible_node.cc:84

References PROP_0, and PROP_LAST.

## ◆ parse_locale()

static void parse_locale | ( | const gchar * | locale,
|  | gchar ** | language,
|  | gchar ** | territory,
|  | gchar ** | codeset,
|  | gchar ** | modifier
| ) |  |
| static

Definition at line 112 of file fl_engine.cc.

116 {
117 gchar* l = g_strdup(locale);
118
119 // Locales are in the form "language[_territory][.codeset][@modifier]"
120 gchar* match = strrchr(l, '@');
121 if (match != nullptr) {
122 if (modifier != nullptr) {
123 *modifier = g_strdup(match + 1);
124 }
125 *match = '\0';
126 } else if (modifier != nullptr) {
127 *modifier = nullptr;
128 }
129
130 match = strrchr(l, '.');
131 if (match != nullptr) {
132 if (codeset != nullptr) {
133 *codeset = g_strdup(match + 1);
134 }
135 *match = '\0';
136 } else if (codeset != nullptr) {
137 *codeset = nullptr;
138 }
139
140 match = strrchr(l, '_');
141 if (match != nullptr) {
142 if (territory != nullptr) {
143 *territory = g_strdup(match + 1);
144 }
145 *match = '\0';
146 } else if (territory != nullptr) {
147 *territory = nullptr;
148 }
149
150 if (language != nullptr) {
151 *language = l;
152 }
153 }

Referenced by setup_locales().

## ◆ send_key_event_cb()

static void send_key_event_cb | ( | bool | handled,
|  | void * | user_data
| ) |  |
| static

Definition at line 1114 of file fl_engine.cc.

1114 {
1115 g_autoptr(GTask) task = G_TASK(user_data);
1116 gboolean* return_value = g_new0(gboolean, 1);
1117 *return_value = handled;
1118 g_task_return_pointer(task, return_value, g_free);
1119 }

References user_data.

Referenced by fl_engine_send_key_event().

## ◆ setup_locales()

static void setup_locales | ( | FlEngine * | self | ) |
| static

Definition at line 184 of file fl_engine.cc.

184 {
185 const gchar* const* languages = g_get_language_names();
186 g_autoptr(GPtrArray) locales_array = g_ptr_array_new_with_free_func(
187 reinterpret_cast<GDestroyNotify>(free_locale));
188 for (int i = 0; languages[i] != nullptr; i++) {
189 g_autofree gchar* locale_string = g_strstrip(g_strdup(languages[i]));
190
191 // Ignore empty locales, caused by settings like `LANGUAGE=pt_BR:`
192 if (strcmp(locale_string, "") == 0) {
193 continue;
194 }
195
196 g_autofree gchar* language = nullptr;
197 g_autofree gchar* territory = nullptr;
198 parse_locale(locale_string, &language, &territory, nullptr, nullptr);
199
200 // Ignore duplicate locales, caused by settings like `LANGUAGE=C` (returns
201 // two "C") or `LANGUAGE=en:en`
202 gboolean has_locale = FALSE;
203 for (guint j = 0; !has_locale && j < locales_array->len; j++) {
204 FlutterLocale* locale =
205 reinterpret_cast<FlutterLocale*>(g_ptr_array_index(locales_array, j));
206 has_locale = g_strcmp0(locale->language_code, language) == 0 &&
207 g_strcmp0(locale->country_code, territory) == 0;
208 }
209 if (has_locale) {
210 continue;
211 }
212
213 FlutterLocale* locale =
214 static_cast<FlutterLocale*>(g_malloc0(sizeof(FlutterLocale)));
215 g_ptr_array_add(locales_array, locale);
216 locale->struct_size = sizeof(FlutterLocale);
217 locale->language_code =
218 reinterpret_cast<const gchar*>(g_steal_pointer(&language));
219 locale->country_code =
220 reinterpret_cast<const gchar*>(g_steal_pointer(&territory));
221 locale->script_code = nullptr;
222 locale->variant_code = nullptr;
223 }
224 FlutterLocale** locales =
225 reinterpret_cast<FlutterLocale**>(locales_array->pdata);
226 FlutterEngineResult result = self->embedder_api.UpdateLocales(
227 self->engine, const_cast<const FlutterLocale**>(locales),
228 locales_array->len);
229 if (result != kSuccess) {
230 g_warning("Failed to set up Flutter locales");
231 }
232 }
parse_locale
static void parse_locale(const gchar *locale, gchar **language, gchar **territory, gchar **codeset, gchar **modifier)
Definition: fl_engine.cc:112
free_locale
static void free_locale(FlutterLocale *locale)
Definition: fl_engine.cc:177
i
int i
Definition: fl_socket_accessible.cc:18

References free_locale(), i, and parse_locale().

Referenced by fl_engine_start().

## ◆ view_added_cb()

static void view_added_cb | ( | const FlutterAddViewResult * | result | ) |
| static

Definition at line 155 of file fl_engine.cc.

155 {
156 g_autoptr(GTask) task = G_TASK(result->user_data);
157
158 if (result->added) {
159 g_task_return_boolean(task, TRUE);
160 } else {
161 g_task_return_new_error(task, fl_engine_error_quark(),
162 FL_ENGINE_ERROR_FAILED, "Failed to add view");
163 }
164 }

References FL_ENGINE_ERROR_FAILED, fl_engine_error_quark(), and TRUE.

Referenced by fl_engine_add_view().

## ◆ view_removed_cb()

static void view_removed_cb | ( | const FlutterRemoveViewResult * | result | ) |
| static

Definition at line 166 of file fl_engine.cc.

166 {
167 g_autoptr(GTask) task = G_TASK(result->user_data);
168
169 if (result->removed) {
170 g_task_return_boolean(task, TRUE);
171 } else {
172 g_task_return_new_error(task, fl_engine_error_quark(),
173 FL_ENGINE_ERROR_FAILED, "Failed to remove view");
174 }
175 }

References FL_ENGINE_ERROR_FAILED, fl_engine_error_quark(), and TRUE.

Referenced by fl_engine_remove_view().

## Variable Documentation

## ◆ fl_engine_signals

guint fl_engine_signals[LAST_SIGNAL]
| static

Definition at line 100 of file fl_engine.cc.

Referenced by fl_engine_class_init(), and fl_engine_on_pre_engine_restart_cb().

## ◆ kMousePointerDeviceId

constexpr int32_t kMousePointerDeviceId = 0
| static constexpr

Definition at line 33 of file fl_engine.cc.

Referenced by fl_engine_send_mouse_pointer_event().

## ◆ kPlatformTaskRunnerIdentifier

constexpr size_t kPlatformTaskRunnerIdentifier = 1
| static constexpr

Definition at line 29 of file fl_engine.cc.

Referenced by fl_engine_start().

## ◆ kPointerPanZoomDeviceId

constexpr int32_t kPointerPanZoomDeviceId = 1
| static constexpr

Definition at line 34 of file fl_engine.cc.

Referenced by fl_engine_send_pointer_pan_zoom_event().