| Flutter Linux Embedder |

Classes | Enumerations | Functions | Variables
fl_engine.cc File Reference
`#include "flutter/shell/platform/linux/public/flutter_linux/fl_engine.h"`
`#include <epoxy/egl.h>`
`#include <gmodule.h>`
`#include <cstring>`
`#include "flutter/common/constants.h"`
`#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_framebuffer.h"`
`#include "flutter/shell/platform/linux/fl_keyboard_handler.h"`
`#include "flutter/shell/platform/linux/fl_opengl_manager.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_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/fl_windowing_handler.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 , SIGNAL_UPDATE_SEMANTICS , 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 | create_opengl_backing_store (FlEngine *self, const FlutterBackingStoreConfig *config, FlutterBackingStore *backing_store_out)
static bool | collect_opengl_backing_store (FlEngine *self, const FlutterBackingStore *backing_store)
static bool | create_software_backing_store (FlEngine *self, const FlutterBackingStoreConfig *config, FlutterBackingStore *backing_store_out)
static bool | collect_software_backing_store (FlEngine *self, const FlutterBackingStore *backing_store)
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_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 | setup_keyboard (FlEngine *self)
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)
static FlEngine * | fl_engine_new_full (FlDartProject *project, FlBinaryMessenger *binary_messenger)
FlEngine * | fl_engine_for_id (int64_t id)
G_MODULE_EXPORT FlEngine * | fl_engine_new (FlDartProject *project)
FlEngine * | fl_engine_new_with_binary_messenger (FlBinaryMessenger *binary_messenger)
G_MODULE_EXPORT FlEngine * | fl_engine_new_headless (FlDartProject *project)
FlutterRendererType | fl_engine_get_renderer_type (FlEngine *self)
FlOpenGLManager * | fl_engine_get_opengl_manager (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)
void | fl_engine_set_implicit_view (FlEngine *self, FlRenderable *renderable)
FlutterViewId | fl_engine_add_view (FlEngine *self, FlRenderable *renderable, 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)
FlRenderable * | fl_engine_get_renderable (FlEngine *self, FlutterViewId view_id)
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)
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, FlutterViewId view_id, uint64_t node_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)
FlWindowingHandler * | fl_engine_get_windowing_handler (FlEngine *self)
FlKeyboardManager * | fl_engine_get_keyboard_manager (FlEngine *self)
FlTextInputHandler * | fl_engine_get_text_input_handler (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 |
SIGNAL_UPDATE_SEMANTICS |
LAST_SIGNAL |

Definition at line 114 of file fl_engine.cc.

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

## Function Documentation

## ◆ collect_opengl_backing_store()

static bool collect_opengl_backing_store | ( | FlEngine * | self,
|  | const FlutterBackingStore * | backing_store
| ) |  |
| static

Definition at line 285 of file fl_engine.cc.

287 {
288 fl_opengl_manager_make_current(self->opengl_manager);
289
290 // OpenGL context is required when destroying #FlFramebuffer.
291 g_object_unref(backing_store->open_gl.framebuffer.user_data);
292 return true;
293 }
self
g_cond_signal & self
Definition: fl_compositor_software.cc:67
fl_opengl_manager_make_current
void fl_opengl_manager_make_current(FlOpenGLManager *self)
Definition: fl_opengl_manager.cc:76

References fl_opengl_manager_make_current(), and self.

Referenced by compositor_collect_backing_store_callback().

## ◆ collect_software_backing_store()

static bool collect_software_backing_store | ( | FlEngine * | self,
|  | const FlutterBackingStore * | backing_store
| ) |  |
| static

Definition at line 319 of file fl_engine.cc.

321 {
322 free(const_cast<void*>(backing_store->software.allocation));
323 return true;
324 }

Referenced by compositor_collect_backing_store_callback().

## ◆ compositor_collect_backing_store_callback()

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

Definition at line 343 of file fl_engine.cc.

345 {
346 FlEngine* self = static_cast<FlEngine*>(user_data);
347 switch (self->renderer_type) {
348 case kOpenGL:
349 return collect_opengl_backing_store(self, backing_store);
350 case kSoftware:
351 return collect_software_backing_store(self, backing_store);
352 default:
353 return false;
354 }
355 }
collect_opengl_backing_store
static bool collect_opengl_backing_store(FlEngine *self, const FlutterBackingStore *backing_store)
Definition: fl_engine.cc:285
collect_software_backing_store
static bool collect_software_backing_store(FlEngine *self, const FlutterBackingStore *backing_store)
Definition: fl_engine.cc:319
user_data
G_BEGIN_DECLS G_MODULE_EXPORT FlValue gpointer user_data
Definition: fl_event_channel.h:90

References collect_opengl_backing_store(), collect_software_backing_store(), self, 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 327 of file fl_engine.cc.

330 {
331 FlEngine* self = static_cast<FlEngine*>(user_data);
332 switch (self->renderer_type) {
333 case kOpenGL:
334 return create_opengl_backing_store(self, config, backing_store_out);
335 case kSoftware:
336 return create_software_backing_store(self, config, backing_store_out);
337 default:
338 return false;
339 }
340 }
create_opengl_backing_store
static bool create_opengl_backing_store(FlEngine *self, const FlutterBackingStoreConfig *config, FlutterBackingStore *backing_store_out)
Definition: fl_engine.cc:250
create_software_backing_store
static bool create_software_backing_store(FlEngine *self, const FlutterBackingStoreConfig *config, FlutterBackingStore *backing_store_out)
Definition: fl_engine.cc:295

References create_opengl_backing_store(), create_software_backing_store(), self, 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 358 of file fl_engine.cc.

359 {
360 FlEngine* self = static_cast<FlEngine*>(info->user_data);
361
362 GWeakRef* ref = static_cast<GWeakRef*>(g_hash_table_lookup(
363 self->renderables_by_view_id, GINT_TO_POINTER(info->view_id)));
364 if (ref == nullptr) {
365 return true;
366 }
367 g_autoptr(FlRenderable) renderable = FL_RENDERABLE(g_weak_ref_get(ref));
368 if (renderable == nullptr) {
369 return true;
370 }
371
372 fl_renderable_present_layers(renderable, info->layers, info->layers_count);
373 return true;
374 }
g_autoptr
g_autoptr(GMutexLocker) locker
fl_renderable_present_layers
void fl_renderable_present_layers(FlRenderable *self, const FlutterLayer **layers, size_t layers_count)
Definition: fl_renderable.cc:11

References fl_renderable_present_layers(), g_autoptr(), and self.

Referenced by fl_engine_start().

## ◆ create_opengl_backing_store()

static bool create_opengl_backing_store | ( | FlEngine * | self,
|  | const FlutterBackingStoreConfig * | config,
|  | FlutterBackingStore * | backing_store_out
| ) |  |
| static

Definition at line 250 of file fl_engine.cc.

253 {
254 fl_opengl_manager_make_current(self->opengl_manager);
255
256 GLint sized_format = GL_RGBA8;
257 GLint general_format = GL_RGBA;
258 if (epoxy_has_gl_extension("GL_EXT_texture_format_BGRA8888")) {
259 sized_format = GL_BGRA8_EXT;
260 general_format = GL_BGRA_EXT;
261 }
262
263 FlFramebuffer* framebuffer = fl_framebuffer_new(
264 general_format, config->size.width, config->size.height, FALSE);
265 if (!framebuffer) {
266 g_warning("Failed to create backing store");
267 return false;
268 }
269
270 backing_store_out->type = kFlutterBackingStoreTypeOpenGL;
271 backing_store_out->open_gl.type = kFlutterOpenGLTargetTypeFramebuffer;
272 backing_store_out->open_gl.framebuffer.user_data = framebuffer;
273 backing_store_out->open_gl.framebuffer.name =
274 fl_framebuffer_get_id(framebuffer);
275 backing_store_out->open_gl.framebuffer.target = sized_format;
276 backing_store_out->open_gl.framebuffer.destruction_callback = [](void* p) {
277 // Backing store destroyed in fl_compositor_opengl_collect_backing_store(),
278 // set on FlutterCompositor.collect_backing_store_callback during engine
279 // start.
280 };
281
282 return true;
283 }
fl_framebuffer_get_id
GLuint fl_framebuffer_get_id(FlFramebuffer *self)
Definition: fl_framebuffer.cc:148
fl_framebuffer_new
FlFramebuffer * fl_framebuffer_new(GLint format, size_t width, size_t height, gboolean shareable)
Definition: fl_framebuffer.cc:69

References fl_framebuffer_get_id(), fl_framebuffer_new(), fl_opengl_manager_make_current(), and self.

Referenced by compositor_create_backing_store_callback().

## ◆ create_software_backing_store()

static bool create_software_backing_store | ( | FlEngine * | self,
|  | const FlutterBackingStoreConfig * | config,
|  | FlutterBackingStore * | backing_store_out
| ) |  |
| static

Definition at line 295 of file fl_engine.cc.

298 {
299 size_t allocation_length = config->size.width * config->size.height * 4;
300 uint8_t* allocation = static_cast<uint8_t*>(malloc(allocation_length));
301 if (allocation == nullptr) {
302 return false;
303 }
304
305 backing_store_out->type = kFlutterBackingStoreTypeSoftware;
306 backing_store_out->software.allocation = allocation;
307 backing_store_out->software.height = config->size.height;
308 backing_store_out->software.row_bytes = config->size.width * 4;
309 backing_store_out->software.user_data = nullptr;
310 backing_store_out->software.destruction_callback = [](void* p) {
311 // Backing store destroyed in
312 // fl_compositor_software_collect_backing_store(), set on
313 // FlutterCompositor.collect_backing_store_callback during engine start.
314 };
315
316 return true;
317 }

Referenced by compositor_create_backing_store_callback().

## ◆ fl_engine_add_view()

FlutterViewId fl_engine_add_view | ( | FlEngine * | engine,
|  | FlRenderable * | renderable,
|  | size_t | width,
|  | size_t | height,
|  | double | pixel_ratio,
|  | GCancellable * | cancellable,
|  | GAsyncReadyCallback | callback,
|  | gpointer | user_data
| ) |  |

fl_engine_add_view: @engine: an #FlEngine. @renderable: the object that will render this view. @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 883 of file fl_engine.cc.

890 {
891 g_return_val_if_fail(FL_IS_ENGINE(self), -1);
892
893 g_autoptr(GTask) task = g_task_new(self, cancellable, callback, user_data);
894
895 FlutterViewId view_id = self->next_view_id;
896 self->next_view_id++;
897
898 GWeakRef* ref = g_new(GWeakRef, 1);
899 g_weak_ref_init(ref, G_OBJECT(renderable));
900 g_hash_table_insert(self->renderables_by_view_id, GINT_TO_POINTER(view_id),
901 ref);
902
903 // We don't know which display this view will open on, so set to zero and this
904 // will be updated in a following FlutterWindowMetricsEvent
905 FlutterEngineDisplayId display_id = 0;
906
907 FlutterWindowMetricsEvent metrics = {};
908 metrics.struct_size = sizeof(FlutterWindowMetricsEvent);
909 metrics.width = width;
910 metrics.height = height;
911 metrics.pixel_ratio = pixel_ratio;
912 metrics.display_id = display_id;
913 metrics.view_id = view_id;
914 FlutterAddViewInfo info;
915 info.struct_size = sizeof(FlutterAddViewInfo);
916 info.view_id = view_id;
917 info.view_metrics = &metrics;
918 info.user_data = g_object_ref(task);
919 info.add_view_callback = view_added_cb;
920 FlutterEngineResult result = self->embedder_api.AddView(self->engine, &info);
921 if (result != kSuccess) {
922 g_task_return_new_error(task, fl_engine_error_quark(),
923 FL_ENGINE_ERROR_FAILED, "AddView returned %d",
924 result);
925 // This would have been done in the callback, but that won't occur now.
926 g_object_unref(task);
927 }
928
929 return view_id;
930 }
height
self height
Definition: fl_compositor_software.cc:43
width
self width
Definition: fl_compositor_software.cc:42
view_added_cb
static void view_added_cb(const FlutterAddViewResult *result)
Definition: fl_engine.cc:171
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:30
view_id
G_BEGIN_DECLS FlutterViewId view_id
Definition: fl_view_accessible.h:49

References FL_ENGINE_ERROR_FAILED, fl_engine_error_quark(), g_autoptr(), height, self, user_data, view_added_cb(), view_id, 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 932 of file fl_engine.cc.

934 {
935 g_return_val_if_fail(FL_IS_ENGINE(self), FALSE);
936 return g_task_propagate_boolean(G_TASK(result), error);
937 }
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 603 of file fl_engine.cc.

603 {
604 G_OBJECT_CLASS(klass)->dispose = fl_engine_dispose;
605 G_OBJECT_CLASS(klass)->set_property = fl_engine_set_property;
606
607 g_object_class_install_property(
608 G_OBJECT_CLASS(klass), PROP_BINARY_MESSENGER,
609 g_param_spec_object(
610 "binary-messenger", "messenger", "Binary messenger",
611 fl_binary_messenger_get_type(),
612 static_cast<GParamFlags>(G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY |
613 G_PARAM_STATIC_STRINGS)));
614
615 fl_engine_signals[SIGNAL_ON_PRE_ENGINE_RESTART] = g_signal_new(
616 "on-pre-engine-restart", fl_engine_get_type(), G_SIGNAL_RUN_LAST, 0,
617 nullptr, nullptr, nullptr, G_TYPE_NONE, 0);
618 fl_engine_signals[SIGNAL_UPDATE_SEMANTICS] = g_signal_new(
619 "update-semantics", fl_engine_get_type(), G_SIGNAL_RUN_LAST, 0, nullptr,
620 nullptr, nullptr, G_TYPE_NONE, 1, G_TYPE_POINTER);
621 }
fl_engine_dispose
static void fl_engine_dispose(GObject *object)
Definition: fl_engine.cc:562
fl_engine_signals
static guint fl_engine_signals[LAST_SIGNAL]
Definition: fl_engine.cc:116
fl_engine_set_property
static void fl_engine_set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
Definition: fl_engine.cc:546

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

## ◆ fl_engine_dispatch_semantics_action()

void fl_engine_dispatch_semantics_action | ( | FlEngine * | engine,
|  | FlutterViewId | view_id,
|  | uint64_t | node_id,
|  | FlutterSemanticsAction | action,
|  | GBytes * | data
| ) |  |

fl_engine_dispatch_semantics_action: @engine: an #FlEngine. @view_id: the view that the event occured on. @node_id: the semantics action identifier. @action: the action being dispatched. @data: (allow-none): data associated with the action.

Definition at line 1365 of file fl_engine.cc.

1369 {
1370 g_return_if_fail(FL_IS_ENGINE(self));
1371
1372 if (self->engine == nullptr) {
1373 return;
1374 }
1375
1376 const uint8_t* action_data = nullptr;
1377 size_t action_data_length = 0;
1378 if (data != nullptr) {
1379 action_data = static_cast<const uint8_t*>(
1380 g_bytes_get_data(data, &action_data_length));
1381 }
1382
1383 FlutterSendSemanticsActionInfo info;
1384 info.struct_size = sizeof(FlutterSendSemanticsActionInfo);
1385 info.view_id = view_id;
1386 info.node_id = node_id;
1387 info.action = action;
1388 info.data = action_data;
1389 info.data_length = action_data_length;
1390 self->embedder_api.SendSemanticsAction(self->engine, &info);
1391 }
action
FlutterSemanticsAction action
Definition: fl_accessible_node.cc:86

References action, self, and view_id.

Referenced by fl_accessible_node_perform_action_impl(), and TEST().

## ◆ fl_engine_dispose()

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

Definition at line 562 of file fl_engine.cc.

562 {
563 FlEngine* self = FL_ENGINE(object);
564
565 if (self->engine != nullptr) {
566 self->embedder_api.Shutdown(self->engine);
567 self->engine = nullptr;
568 }
569
570 if (self->aot_data != nullptr) {
571 self->embedder_api.CollectAOTData(self->aot_data);
572 self->aot_data = nullptr;
573 }
574
575 fl_binary_messenger_shutdown(self->binary_messenger);
576 fl_texture_registrar_shutdown(self->texture_registrar);
577
578 g_clear_object(&self->project);
579 g_clear_object(&self->display_monitor);
580 g_clear_object(&self->opengl_manager);
581 g_clear_object(&self->texture_registrar);
582 g_clear_object(&self->binary_messenger);
583 g_clear_object(&self->settings_handler);
584 g_clear_object(&self->platform_handler);
585 g_clear_object(&self->windowing_handler);
586 g_clear_object(&self->keyboard_manager);
587 g_clear_object(&self->text_input_handler);
588 g_clear_object(&self->keyboard_handler);
589 g_clear_object(&self->mouse_cursor_handler);
590 g_clear_object(&self->task_runner);
591 g_clear_pointer(&self->renderables_by_view_id, g_hash_table_unref);
592
593 if (self->platform_message_handler_destroy_notify) {
594 self->platform_message_handler_destroy_notify(
595 self->platform_message_handler_data);
596 }
597 self->platform_message_handler_data = nullptr;
598 self->platform_message_handler_destroy_notify = nullptr;
599
600 G_OBJECT_CLASS(fl_engine_parent_class)->dispose(object);
601 }
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(), fl_texture_registrar_shutdown(), and self.

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 1425 of file fl_engine.cc.

1425 {
1426 g_return_if_fail(FL_IS_ENGINE(self));
1427 self->embedder_api.RunTask(self->engine, task);
1428 }

References self.

Referenced by fl_task_runner_process_expired_tasks_locked().

## ◆ fl_engine_for_id()

FlEngine* fl_engine_for_id | ( | int64_t | handle | ) |

fl_engine_for_id: @handle: an engine identifier obtained through PlatformDispatcher.instance.engineId.

Returns Flutter engine associated with the identifier. The identifier must be valid and for a running engine otherwise the behavior is undefined. Must be called from the main thread.

Returns: a #FlEngine or NULL.

Definition at line 686 of file fl_engine.cc.

686 {
687 void* engine = reinterpret_cast<void*>(id);
688 g_return_val_if_fail(FL_IS_ENGINE(engine), nullptr);
689 return FL_ENGINE(engine);
690 }
id
int64_t id
Definition: fl_pixel_buffer_texture.cc:28

References id.

Referenced by TEST().

## ◆ 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 1414 of file fl_engine.cc.

1415 {
1416 g_return_val_if_fail(FL_IS_ENGINE(self), nullptr);
1417 return self->binary_messenger;
1418 }

Referenced by fl_keyboard_manager_new(), fl_settings_handler_new(), fl_view_get_registrar_for_plugin(), fl_windowing_handler_new(), 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 716 of file fl_engine.cc.

716 {
717 g_return_val_if_fail(FL_IS_ENGINE(self), nullptr);
718 return self->display_monitor;
719 }

Referenced by handle_geometry_changed(), and TEST().

## ◆ 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 859 of file fl_engine.cc.

859 {
860 return &(self->embedder_api);
861 }

Referenced by TEST().

## ◆ fl_engine_get_keyboard_manager()

FlKeyboardManager* fl_engine_get_keyboard_manager | ( | FlEngine * | engine | ) |

fl_engine_get_keyboard_manager: @engine: an #FlEngine.

Gets the keyboard manager used by this engine.

Returns: an #FlKeyboardManager.

Definition at line 1457 of file fl_engine.cc.

1457 {
1458 g_return_val_if_fail(FL_IS_ENGINE(self), nullptr);
1459 return self->keyboard_manager;
1460 }

Referenced by handle_key_event(), sync_modifier_if_needed(), and 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: an #FlMouseCursorHandler.

Definition at line 1467 of file fl_engine.cc.

1467 {
1468 g_return_val_if_fail(FL_IS_ENGINE(self), nullptr);
1469 return self->mouse_cursor_handler;
1470 }

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

## ◆ fl_engine_get_opengl_manager()

FlOpenGLManager* fl_engine_get_opengl_manager | ( | FlEngine * | engine | ) |

fl_engine_get_opengl_manager: @engine: an #FlEngine.

Gets the OpenGL manager used by this engine.

Returns: an #FlOpenGLManager.

Definition at line 711 of file fl_engine.cc.

711 {
712 g_return_val_if_fail(FL_IS_ENGINE(self), nullptr);
713 return self->opengl_manager;
714 }

Referenced by fl_compositor_opengl_new(), and realize_cb().

## ◆ fl_engine_get_registrar_for_plugin()

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

Definition at line 532 of file fl_engine.cc.

534 {
535 FlEngine* self = FL_ENGINE(registry);
536
537 return fl_plugin_registrar_new(nullptr, self->binary_messenger,
538 self->texture_registrar);
539 }
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(), and self.

Referenced by fl_engine_plugin_registry_iface_init().

## ◆ fl_engine_get_renderable()

FlRenderable* fl_engine_get_renderable | ( | FlEngine * | engine,
|  | FlutterViewId | view_id
| ) |  |

fl_engine_get_renderable: @engine: an #FlEngine. @view_id: ID to check.

Gets the renderable associated with the give view ID.

Returns: (transfer full): a reference to an #FlRenderable or NULL if none for this ID.

Definition at line 939 of file fl_engine.cc.

939 {
940 g_return_val_if_fail(FL_IS_ENGINE(self), nullptr);
941
942 GWeakRef* ref = static_cast<GWeakRef*>(g_hash_table_lookup(
943 self->renderables_by_view_id, GINT_TO_POINTER(view_id)));
944 return FL_RENDERABLE(g_weak_ref_get(ref));
945 }

References self, and view_id.

## ◆ fl_engine_get_renderer_type()

FlutterRendererType fl_engine_get_renderer_type | ( | FlEngine * | engine | ) |

fl_engine_get_renderer_type: @engine: an #FlEngine.

Gets the rendering type used by this engine.

Returns: type of rendering used.

Definition at line 706 of file fl_engine.cc.

706 {
707 g_return_val_if_fail(FL_IS_ENGINE(self), static_cast<FlutterRendererType>(0));
708 return self->renderer_type;
709 }

Referenced by realize_cb().

## ◆ 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 1420 of file fl_engine.cc.

1420 {
1421 g_return_val_if_fail(FL_IS_ENGINE(self), nullptr);
1422 return self->task_runner;
1423 }

Referenced by TEST().

## ◆ fl_engine_get_text_input_handler()

FlTextInputHandler* fl_engine_get_text_input_handler | ( | FlEngine * | engine | ) |

fl_engine_get_text_input_handler: @engine: an #FlEngine.

Gets the text input handler used by this engine.

Returns: an #FlTextInputHandler.

Definition at line 1462 of file fl_engine.cc.

1462 {
1463 g_return_val_if_fail(FL_IS_ENGINE(self), nullptr);
1464 return self->text_input_handler;
1465 }

Referenced by fl_view_focus_in_event(), and handle_key_event().

## ◆ 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 1430 of file fl_engine.cc.

1431 {
1432 g_return_val_if_fail(FL_IS_ENGINE(self), nullptr);
1433 return self->texture_registrar;
1434 }

Referenced by fl_view_get_registrar_for_plugin().

## ◆ fl_engine_get_windowing_handler()

FlWindowingHandler* fl_engine_get_windowing_handler | ( | FlEngine * | engine | ) |

fl_engine_get_windowing_handler: @engine: an #FlEngine.

Gets the windowing handler used by this engine.

Returns: an #FlWindowingHandler.

Definition at line 1452 of file fl_engine.cc.

1452 {
1453 g_return_val_if_fail(FL_IS_ENGINE(self), nullptr);
1454 return self->windowing_handler;
1455 }

Referenced by fl_application_activate(), and TEST().

## ◆ fl_engine_gl_clear_current()

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

Definition at line 388 of file fl_engine.cc.

388 {
389 FlEngine* self = static_cast<FlEngine*>(user_data);
390 fl_opengl_manager_clear_current(self->opengl_manager);
391 return true;
392 }
fl_opengl_manager_clear_current
void fl_opengl_manager_clear_current(FlOpenGLManager *self)
Definition: fl_opengl_manager.cc:86

References fl_opengl_manager_clear_current(), self, 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 406 of file fl_engine.cc.

411 {
412 FlEngine* self = static_cast<FlEngine*>(user_data);
413 if (!self->texture_registrar) {
414 return false;
415 }
416
417 FlTexture* texture =
418 fl_texture_registrar_lookup_texture(self->texture_registrar, texture_id);
419 if (texture == nullptr) {
420 g_warning("Unable to find texture %" G_GINT64_FORMAT, texture_id);
421 return false;
422 }
423
424 gboolean result;
425 g_autoptr(GError) error = nullptr;
426 if (FL_IS_TEXTURE_GL(texture)) {
427 result = fl_texture_gl_populate(FL_TEXTURE_GL(texture), width, height,
428 opengl_texture, &error);
429 } else if (FL_IS_PIXEL_BUFFER_TEXTURE(texture)) {
430 result =
431 fl_pixel_buffer_texture_populate(FL_PIXEL_BUFFER_TEXTURE(texture),
432 width, height, opengl_texture, &error);
433 } else {
434 g_warning("Unsupported texture type %" G_GINT64_FORMAT, texture_id);
435 return false;
436 }
437
438 if (!result) {
439 g_warning("%s", error->message);
440 return false;
441 }
442
443 return true;
444 }
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(), g_autoptr(), height, self, 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 394 of file fl_engine.cc.

394 {
395 // There is only one frame buffer object - always return that.
396 return 0;
397 }

Referenced by fl_engine_start().

## ◆ fl_engine_gl_make_current()

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

Definition at line 382 of file fl_engine.cc.

382 {
383 FlEngine* self = static_cast<FlEngine*>(user_data);
384 fl_opengl_manager_make_current(self->opengl_manager);
385 return true;
386 }

References fl_opengl_manager_make_current(), self, 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 399 of file fl_engine.cc.

399 {
400 FlEngine* self = static_cast<FlEngine*>(user_data);
401 fl_opengl_manager_make_resource_current(self->opengl_manager);
402 return true;
403 }
fl_opengl_manager_make_resource_current
void fl_opengl_manager_make_resource_current(FlOpenGLManager *self)
Definition: fl_opengl_manager.cc:81

References fl_opengl_manager_make_resource_current(), self, and user_data.

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 378 of file fl_engine.cc.

378 {
379 return reinterpret_cast<void*>(eglGetProcAddress(name));
380 }

Referenced by fl_engine_start().

## ◆ fl_engine_init()

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

Definition at line 623 of file fl_engine.cc.

623 {
624 self->thread = g_thread_self();
625
626 self->embedder_api.struct_size = sizeof(FlutterEngineProcTable);
627 if (FlutterEngineGetProcAddresses(&self->embedder_api) != kSuccess) {
628 g_warning("Failed get get engine function pointers");
629 }
630
631 self->opengl_manager = fl_opengl_manager_new();
632
633 self->display_monitor =
634 fl_display_monitor_new(self, gdk_display_get_default());
635 self->task_runner = fl_task_runner_new(self);
636
637 // Implicit view is 0, so start at 1.
638 self->next_view_id = 1;
639 self->renderables_by_view_id = g_hash_table_new_full(
640 g_direct_hash, g_direct_equal, nullptr, [](gpointer value) {
641 GWeakRef* ref = static_cast<GWeakRef*>(value);
642 g_weak_ref_clear(ref);
643 free(ref);
644 });
645
646 self->texture_registrar = fl_texture_registrar_new(self);
647 }
fl_display_monitor_new
FlDisplayMonitor * fl_display_monitor_new(FlEngine *engine, GdkDisplay *display)
Definition: fl_display_monitor.cc:94
fl_opengl_manager_new
FlOpenGLManager * fl_opengl_manager_new()
Definition: fl_opengl_manager.cc:70
value
uint8_t value
Definition: fl_standard_message_codec.cc:36
fl_task_runner_new
FlTaskRunner * fl_task_runner_new(FlEngine *engine)
Definition: fl_task_runner.cc:157
fl_texture_registrar_new
FlTextureRegistrar * fl_texture_registrar_new(FlEngine *engine)
Definition: fl_texture_registrar.cc:221

References fl_display_monitor_new(), fl_opengl_manager_new(), fl_task_runner_new(), fl_texture_registrar_new(), self, and value.

## ◆ 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 1393 of file fl_engine.cc.

1394 {
1395 g_return_val_if_fail(FL_IS_ENGINE(self), FALSE);
1396 return self->embedder_api.MarkExternalTextureFrameAvailable(
1397 self->engine, texture_id) == kSuccess;
1398 }

References self, and 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 692 of file fl_engine.cc.

692 {
693 return fl_engine_new_full(project, nullptr);
694 }
fl_engine_new_full
static FlEngine * fl_engine_new_full(FlDartProject *project, FlBinaryMessenger *binary_messenger)
Definition: fl_engine.cc:649

References fl_engine_new_full().

Referenced by fl_engine_new_headless(), fl_view_new(), and TEST().

## ◆ fl_engine_new_full()

static FlEngine* fl_engine_new_full | ( | FlDartProject * | project,
|  | FlBinaryMessenger * | binary_messenger
| ) |  |
| static

Definition at line 649 of file fl_engine.cc.

650 {
651 g_return_val_if_fail(FL_IS_DART_PROJECT(project), nullptr);
652
653 FlEngine* self = FL_ENGINE(g_object_new(fl_engine_get_type(), nullptr));
654
655 self->project = FL_DART_PROJECT(g_object_ref(project));
656 const gchar* renderer = g_getenv("FLUTTER_LINUX_RENDERER");
657 if (g_strcmp0(renderer, "software") == 0) {
658 self->renderer_type = kSoftware;
659 g_warning(
660 "Using the software renderer. Not all features are supported. This is "
661 "not recommended.\n"
662 "\n"
663 "To switch back to the default renderer, unset the "
664 "FLUTTER_LINUX_RENDERER environment variable.");
665 } else {
666 if (renderer != nullptr && strcmp(renderer, "opengl") != 0) {
667 g_warning("Unknown renderer type '%s', defaulting to opengl", renderer);
668 }
669 self->renderer_type = kOpenGL;
670 }
671
672 if (binary_messenger != nullptr) {
673 self->binary_messenger =
674 FL_BINARY_MESSENGER(g_object_ref(binary_messenger));
675 } else {
676 self->binary_messenger = fl_binary_messenger_new(self);
677 }
678 self->keyboard_manager = fl_keyboard_manager_new(self);
679 self->mouse_cursor_handler =
680 fl_mouse_cursor_handler_new(self->binary_messenger);
681 self->windowing_handler = fl_windowing_handler_new(self);
682
683 return self;
684 }
fl_binary_messenger_new
FlBinaryMessenger * fl_binary_messenger_new(FlEngine *engine)
Definition: fl_binary_messenger.cc:391
fl_keyboard_manager_new
FlKeyboardManager * fl_keyboard_manager_new(FlEngine *engine)
Definition: fl_keyboard_manager.cc:356
fl_mouse_cursor_handler_new
FlMouseCursorHandler * fl_mouse_cursor_handler_new(FlBinaryMessenger *messenger)
Definition: fl_mouse_cursor_handler.cc:134
fl_windowing_handler_new
FlWindowingHandler * fl_windowing_handler_new(FlEngine *engine)
Definition: fl_windowing_handler.cc:260

References fl_binary_messenger_new(), fl_keyboard_manager_new(), fl_mouse_cursor_handler_new(), fl_windowing_handler_new(), and self.

Referenced by fl_engine_new(), and fl_engine_new_with_binary_messenger().

## ◆ 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 702 of file fl_engine.cc.

702 {
703 return fl_engine_new(project);
704 }
fl_engine_new
G_MODULE_EXPORT FlEngine * fl_engine_new(FlDartProject *project)
Definition: fl_engine.cc:692

References fl_engine_new().

## ◆ fl_engine_new_with_binary_messenger()

FlEngine* fl_engine_new_with_binary_messenger | ( | FlBinaryMessenger * | binary_messenger | ) |

fl_engine_new_with_binary_messenger: @binary_messenger: an #FlBinaryMessenger.

Creates a new engine with a custom binary messenger. Used for testing.

Returns: a new #FlEngine.

Definition at line 696 of file fl_engine.cc.

697 {
698 g_autoptr(FlDartProject) project = fl_dart_project_new();
699 return fl_engine_new_full(project, binary_messenger);
700 }
fl_dart_project_new
G_MODULE_EXPORT FlDartProject * fl_dart_project_new()
Definition: fl_dart_project.cc:52

References fl_dart_project_new(), fl_engine_new_full(), and g_autoptr().

Referenced by TEST().

## ◆ 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 863 of file fl_engine.cc.

865 {
866 g_return_if_fail(FL_IS_ENGINE(self));
867
868 FlutterEngineResult result = self->embedder_api.NotifyDisplayUpdate(
869 self->engine, kFlutterEngineDisplaysUpdateTypeStartup, displays,
870 displays_length);
871 if (result != kSuccess) {
872 g_warning("Failed to notify display update to Flutter engine: %d", result);
873 }
874 }

References self.

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 513 of file fl_engine.cc.

513 {
514 FlEngine* self = FL_ENGINE(user_data);
515
516 setup_keyboard(self);
517
518 g_signal_emit(self, fl_engine_signals[SIGNAL_ON_PRE_ENGINE_RESTART], 0);
519 }
g_signal_emit
g_signal_emit(self, fl_application_signals[SIGNAL_CREATE_WINDOW], 0, view, &window)
setup_keyboard
static void setup_keyboard(FlEngine *self)
Definition: fl_engine.cc:489

References fl_engine_signals, g_signal_emit(), setup_keyboard(), 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 462 of file fl_engine.cc.

463 {
464 FlEngine* self = FL_ENGINE(user_data);
465
466 gboolean handled = FALSE;
467 if (self->platform_message_handler != nullptr) {
468 g_autoptr(GBytes) data =
469 g_bytes_new(message->message, message->message_size);
470 handled = self->platform_message_handler(
471 self, message->channel, data, message->response_handle,
472 self->platform_message_handler_data);
473 }
474
475 if (!handled) {
476 fl_engine_send_platform_message_response(self, message->response_handle,
477 nullptr, nullptr);
478 }
479 }
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:1000

References fl_engine_send_platform_message_response(), g_autoptr(), self, 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 523 of file fl_engine.cc.

525 {
526 g_autoptr(GTask) task = G_TASK(user_data);
527 g_task_return_pointer(task, g_bytes_new(data, data_length),
528 reinterpret_cast<GDestroyNotify>(g_bytes_unref));
529 }

References g_autoptr(), and 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 541 of file fl_engine.cc.

542 {
543 iface->get_registrar_for_plugin = fl_engine_get_registrar_for_plugin;
544 }
fl_engine_get_registrar_for_plugin
static FlPluginRegistrar * fl_engine_get_registrar_for_plugin(FlPluginRegistry *registry, const gchar *name)
Definition: fl_engine.cc:532

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 453 of file fl_engine.cc.

455 {
456 FlEngine* self = static_cast<FlEngine*>(user_data);
457
458 fl_task_runner_post_flutter_task(self->task_runner, task, target_time_nanos);
459 }
fl_task_runner_post_flutter_task
void fl_task_runner_post_flutter_task(FlTaskRunner *self, FlutterTask task, uint64_t target_time_nanos)
Definition: fl_task_runner.cc:164

References fl_task_runner_post_flutter_task(), self, 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 1400 of file fl_engine.cc.

1401 {
1402 g_return_val_if_fail(FL_IS_ENGINE(self), FALSE);
1403 return self->embedder_api.RegisterExternalTexture(self->engine, texture_id) ==
1404 kSuccess;
1405 }

References self, and 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 947 of file fl_engine.cc.

951 {
952 g_return_if_fail(FL_IS_ENGINE(self));
953
954 g_hash_table_remove(self->renderables_by_view_id, GINT_TO_POINTER(view_id));
955
956 g_autoptr(GTask) task = g_task_new(self, cancellable, callback, user_data);
957
958 FlutterRemoveViewInfo info;
959 info.struct_size = sizeof(FlutterRemoveViewInfo);
960 info.view_id = view_id;
961 info.user_data = g_object_ref(task);
962 info.remove_view_callback = view_removed_cb;
963 FlutterEngineResult result =
964 self->embedder_api.RemoveView(self->engine, &info);
965 if (result != kSuccess) {
966 g_task_return_new_error(task, fl_engine_error_quark(),
967 FL_ENGINE_ERROR_FAILED, "RemoveView returned %d",
968 result);
969 // This would have been done in the callback, but that won't occur now.
970 g_object_unref(task);
971 }
972 }
view_removed_cb
static void view_removed_cb(const FlutterRemoveViewResult *result)
Definition: fl_engine.cc:182

References FL_ENGINE_ERROR_FAILED, fl_engine_error_quark(), g_autoptr(), self, user_data, view_id, 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 974 of file fl_engine.cc.

976 {
977 g_return_val_if_fail(FL_IS_ENGINE(self), FALSE);
978 return g_task_propagate_boolean(G_TASK(result), error);
979 }

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 1447 of file fl_engine.cc.

1447 {
1448 g_return_if_fail(FL_IS_ENGINE(self));
1449 fl_platform_handler_request_app_exit(self->platform_handler);
1450 }
fl_platform_handler_request_app_exit
void fl_platform_handler_request_app_exit(FlPlatformHandler *self)
Definition: fl_platform_handler.cc:267

References fl_platform_handler_request_app_exit(), and self.

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 447 of file fl_engine.cc.

447 {
448 FlEngine* self = static_cast<FlEngine*>(user_data);
449 return self->thread == g_thread_self();
450 }

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 1325 of file fl_engine.cc.

1329 {
1330 g_return_if_fail(FL_IS_ENGINE(self));
1331
1332 g_autoptr(GTask) task = g_task_new(self, cancellable, callback, user_data);
1333
1334 if (self->engine == nullptr) {
1335 g_task_return_new_error(task, fl_engine_error_quark(),
1336 FL_ENGINE_ERROR_FAILED, "No engine");
1337 return;
1338 }
1339
1340 if (self->embedder_api.SendKeyEvent(self->engine, event, send_key_event_cb,
1341 g_object_ref(task)) != kSuccess) {
1342 g_task_return_new_error(task, fl_engine_error_quark(),
1343 FL_ENGINE_ERROR_FAILED, "Failed to send key event");
1344 g_object_unref(task);
1345 }
1346 }
send_key_event_cb
static void send_key_event_cb(bool handled, void *user_data)
Definition: fl_engine.cc:1318

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

Referenced by fl_key_embedder_responder_handle_event(), fl_key_embedder_responder_handle_event_impl(), synthesize_simple_event(), 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 1348 of file fl_engine.cc.

1351 {
1352 g_return_val_if_fail(FL_IS_ENGINE(self), FALSE);
1353 g_return_val_if_fail(g_task_is_valid(result, self), FALSE);
1354
1355 g_autofree gboolean* return_value =
1356 static_cast<gboolean*>(g_task_propagate_pointer(G_TASK(result), error));
1357 if (return_value == nullptr) {
1358 return FALSE;
1359 }
1360
1361 *handled = *return_value;
1362 return TRUE;
1363 }
TRUE
return TRUE
Definition: fl_compositor_software.cc:69

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 1122 of file fl_engine.cc.

1131 {
1132 g_return_if_fail(FL_IS_ENGINE(self));
1133
1134 if (self->engine == nullptr) {
1135 return;
1136 }
1137
1138 FlutterPointerEvent fl_event = {};
1139 fl_event.struct_size = sizeof(fl_event);
1140 fl_event.phase = phase;
1141 fl_event.timestamp = timestamp;
1142 fl_event.x = x;
1143 fl_event.y = y;
1144 if (scroll_delta_x != 0 || scroll_delta_y != 0) {
1145 fl_event.signal_kind = kFlutterPointerSignalKindScroll;
1146 }
1147 fl_event.scroll_delta_x = scroll_delta_x;
1148 fl_event.scroll_delta_y = scroll_delta_y;
1149 fl_event.device_kind = device_kind;
1150 fl_event.buttons = buttons;
1151 fl_event.device = kMousePointerDeviceId;
1152 fl_event.view_id = view_id;
1153 self->embedder_api.SendPointerEvent(self->engine, &fl_event, 1);
1154 }
kMousePointerDeviceId
static constexpr int32_t kMousePointerDeviceId
Definition: fl_engine.cc:36

References kMousePointerDeviceId, self, and view_id.

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 1032 of file fl_engine.cc.

1037 {
1038 g_return_if_fail(FL_IS_ENGINE(self));
1039
1040 GTask* task = nullptr;
1041 FlutterPlatformMessageResponseHandle* response_handle = nullptr;
1042 if (callback != nullptr) {
1043 task = g_task_new(self, cancellable, callback, user_data);
1044
1045 if (self->engine == nullptr) {
1046 g_task_return_new_error(task, fl_engine_error_quark(),
1047 FL_ENGINE_ERROR_FAILED, "No engine to send to");
1048 return;
1049 }
1050
1051 FlutterEngineResult result =
1052 self->embedder_api.PlatformMessageCreateResponseHandle(
1053 self->engine, fl_engine_platform_message_response_cb, task,
1054 &response_handle);
1055 if (result != kSuccess) {
1056 g_task_return_new_error(task, fl_engine_error_quark(),
1057 FL_ENGINE_ERROR_FAILED,
1058 "Failed to create response handle");
1059 g_object_unref(task);
1060 return;
1061 }
1062 } else if (self->engine == nullptr) {
1063 return;
1064 }
1065
1066 FlutterPlatformMessage fl_message = {};
1067 fl_message.struct_size = sizeof(fl_message);
1068 fl_message.channel = channel;
1069 fl_message.message =
1070 message != nullptr
1071 ? static_cast<const uint8_t*>(g_bytes_get_data(message, nullptr))
1072 : nullptr;
1073 fl_message.message_size = message != nullptr ? g_bytes_get_size(message) : 0;
1074 fl_message.response_handle = response_handle;
1075 FlutterEngineResult result =
1076 self->embedder_api.SendPlatformMessage(self->engine, &fl_message);
1077
1078 if (result != kSuccess && task != nullptr) {
1079 g_task_return_new_error(task, fl_engine_error_quark(),
1080 FL_ENGINE_ERROR_FAILED,
1081 "Failed to send platform messages");
1082 g_object_unref(task);
1083 }
1084
1085 if (response_handle != nullptr) {
1086 self->embedder_api.PlatformMessageReleaseResponseHandle(self->engine,
1087 response_handle);
1088 }
1089 }
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:523

References FL_ENGINE_ERROR_FAILED, fl_engine_error_quark(), fl_engine_platform_message_response_cb(), self, 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 1091 of file fl_engine.cc.

1093 {
1094 g_return_val_if_fail(FL_IS_ENGINE(self), FALSE);
1095 g_return_val_if_fail(g_task_is_valid(result, self), FALSE);
1096
1097 return static_cast<GBytes*>(g_task_propagate_pointer(G_TASK(result), error));
1098 }

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 1000 of file fl_engine.cc.

1004 {
1005 g_return_val_if_fail(FL_IS_ENGINE(self), FALSE);
1006 g_return_val_if_fail(handle != nullptr, FALSE);
1007
1008 if (self->engine == nullptr) {
1009 g_set_error(error, fl_engine_error_quark(), FL_ENGINE_ERROR_FAILED,
1010 "No engine to send response to");
1011 return FALSE;
1012 }
1013
1014 gsize data_length = 0;
1015 const uint8_t* data = nullptr;
1016 if (response != nullptr) {
1017 data =
1018 static_cast<const uint8_t*>(g_bytes_get_data(response, &data_length));
1019 }
1020 FlutterEngineResult result = self->embedder_api.SendPlatformMessageResponse(
1021 self->engine, handle, data, data_length);
1022
1023 if (result != kSuccess) {
1024 g_set_error(error, fl_engine_error_quark(), FL_ENGINE_ERROR_FAILED,
1025 "Failed to send platform message response");
1026 return FALSE;
1027 }
1028
1029 return TRUE;
1030 }

References error, FL_ENGINE_ERROR_FAILED, fl_engine_error_quark(), self, 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 1286 of file fl_engine.cc.

1295 {
1296 g_return_if_fail(FL_IS_ENGINE(self));
1297
1298 if (self->engine == nullptr) {
1299 return;
1300 }
1301
1302 FlutterPointerEvent fl_event = {};
1303 fl_event.struct_size = sizeof(fl_event);
1304 fl_event.timestamp = timestamp;
1305 fl_event.x = x;
1306 fl_event.y = y;
1307 fl_event.phase = phase;
1308 fl_event.pan_x = pan_x;
1309 fl_event.pan_y = pan_y;
1310 fl_event.scale = scale;
1311 fl_event.rotation = rotation;
1312 fl_event.device = kPointerPanZoomDeviceId;
1313 fl_event.device_kind = kFlutterPointerDeviceKindTrackpad;
1314 fl_event.view_id = view_id;
1315 self->embedder_api.SendPointerEvent(self->engine, &fl_event, 1);
1316 }
kPointerPanZoomDeviceId
static constexpr int32_t kPointerPanZoomDeviceId
Definition: fl_engine.cc:37

References kPointerPanZoomDeviceId, self, and view_id.

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 1234 of file fl_engine.cc.

1239 {
1240 g_return_if_fail(FL_IS_ENGINE(self));
1241
1242 if (self->engine == nullptr) {
1243 return;
1244 }
1245
1246 FlutterPointerEvent event;
1247 event.timestamp = timestamp;
1248 event.x = x;
1249 event.y = y;
1250 event.device_kind = kFlutterPointerDeviceKindTouch;
1251 event.device = device;
1252 event.buttons = 0;
1253 event.view_id = view_id;
1254 event.phase = FlutterPointerPhase::kAdd;
1255 event.struct_size = sizeof(event);
1256
1257 self->embedder_api.SendPointerEvent(self->engine, &event, 1);
1258 }

References self, and view_id.

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 1182 of file fl_engine.cc.

1187 {
1188 g_return_if_fail(FL_IS_ENGINE(self));
1189
1190 if (self->engine == nullptr) {
1191 return;
1192 }
1193
1194 FlutterPointerEvent event;
1195 event.timestamp = timestamp;
1196 event.x = x;
1197 event.y = y;
1198 event.device_kind = kFlutterPointerDeviceKindTouch;
1199 event.device = device;
1200 event.buttons = FlutterPointerMouseButtons::kFlutterPointerButtonMousePrimary;
1201 event.view_id = view_id;
1202 event.phase = FlutterPointerPhase::kDown;
1203 event.struct_size = sizeof(event);
1204
1205 self->embedder_api.SendPointerEvent(self->engine, &event, 1);
1206 }

References self, and view_id.

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 1208 of file fl_engine.cc.

1213 {
1214 g_return_if_fail(FL_IS_ENGINE(self));
1215
1216 if (self->engine == nullptr) {
1217 return;
1218 }
1219
1220 FlutterPointerEvent event;
1221 event.timestamp = timestamp;
1222 event.x = x;
1223 event.y = y;
1224 event.device_kind = kFlutterPointerDeviceKindTouch;
1225 event.device = device;
1226 event.buttons = FlutterPointerMouseButtons::kFlutterPointerButtonMousePrimary;
1227 event.view_id = view_id;
1228 event.phase = FlutterPointerPhase::kMove;
1229 event.struct_size = sizeof(event);
1230
1231 self->embedder_api.SendPointerEvent(self->engine, &event, 1);
1232 }

References self, and view_id.

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 1260 of file fl_engine.cc.

1265 {
1266 g_return_if_fail(FL_IS_ENGINE(self));
1267
1268 if (self->engine == nullptr) {
1269 return;
1270 }
1271
1272 FlutterPointerEvent event;
1273 event.timestamp = timestamp;
1274 event.x = x;
1275 event.y = y;
1276 event.device_kind = kFlutterPointerDeviceKindTouch;
1277 event.device = device;
1278 event.buttons = 0;
1279 event.view_id = view_id;
1280 event.phase = FlutterPointerPhase::kRemove;
1281 event.struct_size = sizeof(event);
1282
1283 self->embedder_api.SendPointerEvent(self->engine, &event, 1);
1284 }

References self, and view_id.

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 1156 of file fl_engine.cc.

1161 {
1162 g_return_if_fail(FL_IS_ENGINE(self));
1163
1164 if (self->engine == nullptr) {
1165 return;
1166 }
1167
1168 FlutterPointerEvent event;
1169 event.timestamp = timestamp;
1170 event.x = x;
1171 event.y = y;
1172 event.device_kind = kFlutterPointerDeviceKindTouch;
1173 event.device = device;
1174 event.buttons = 0;
1175 event.view_id = view_id;
1176 event.phase = FlutterPointerPhase::kUp;
1177 event.struct_size = sizeof(event);
1178
1179 self->embedder_api.SendPointerEvent(self->engine, &event, 1);
1180 }

References self, and view_id.

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 1100 of file fl_engine.cc.

1105 {
1106 g_return_if_fail(FL_IS_ENGINE(self));
1107
1108 if (self->engine == nullptr) {
1109 return;
1110 }
1111
1112 FlutterWindowMetricsEvent event = {};
1113 event.struct_size = sizeof(FlutterWindowMetricsEvent);
1114 event.width = width;
1115 event.height = height;
1116 event.pixel_ratio = pixel_ratio;
1117 event.display_id = display_id;
1118 event.view_id = view_id;
1119 self->embedder_api.SendWindowMetricsEvent(self->engine, &event);
1120 }

References height, self, view_id, and width.

Referenced by handle_geometry_changed(), and TEST().

## ◆ fl_engine_set_implicit_view()

void fl_engine_set_implicit_view | ( | FlEngine * | engine,
|  | FlRenderable * | renderable
| ) |  |

fl_engine_set_implicit_view: @engine: an #FlEngine. @renderable: the object that will render the implicit view.

Sets the object to render the implicit view.

Definition at line 876 of file fl_engine.cc.

876 {
877 GWeakRef* ref = g_new(GWeakRef, 1);
878 g_weak_ref_init(ref, G_OBJECT(renderable));
879 g_hash_table_insert(self->renderables_by_view_id,
880 GINT_TO_POINTER(flutter::kFlutterImplicitViewId), ref);
881 }

References self.

Referenced by fl_view_new(), 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 981 of file fl_engine.cc.

985 {
986 g_return_if_fail(FL_IS_ENGINE(self));
987 g_return_if_fail(handler != nullptr);
988
989 if (self->platform_message_handler_destroy_notify) {
990 self->platform_message_handler_destroy_notify(
991 self->platform_message_handler_data);
992 }
993
994 self->platform_message_handler = handler;
995 self->platform_message_handler_data = user_data;
996 self->platform_message_handler_destroy_notify = destroy_notify;
997 }

References self, and 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 546 of file fl_engine.cc.

549 {
550 FlEngine* self = FL_ENGINE(object);
551 switch (prop_id) {
552 case PROP_BINARY_MESSENGER:
553 g_set_object(&self->binary_messenger,
554 FL_BINARY_MESSENGER(g_value_get_object(value)));
555 break;
556 default:
557 G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
558 break;
559 }
560 }
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, self, and value.

Referenced by fl_engine_class_init().

## ◆ 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 721 of file fl_engine.cc.

721 {
722 g_return_val_if_fail(FL_IS_ENGINE(self), FALSE);
723
724 FlutterRendererConfig config = {};
725 config.type = self->renderer_type;
726 switch (config.type) {
727 case kSoftware:
728 config.software.struct_size = sizeof(FlutterSoftwareRendererConfig);
729 // No action required, as this is handled in
730 // compositor_present_view_callback.
731 config.software.surface_present_callback =
732 [](void* user_data, const void* allocation, size_t row_bytes,
733 size_t height) { return true; };
734 break;
735 case kOpenGL:
736 config.open_gl.struct_size = sizeof(FlutterOpenGLRendererConfig);
737 config.open_gl.gl_proc_resolver = fl_engine_gl_proc_resolver;
738 config.open_gl.make_current = fl_engine_gl_make_current;
739 config.open_gl.clear_current = fl_engine_gl_clear_current;
740 config.open_gl.fbo_callback = fl_engine_gl_get_fbo;
741 // No action required, as this is handled in
742 // compositor_present_view_callback.
743 config.open_gl.present = [](void* user_data) { return true; };
744 config.open_gl.make_resource_current = fl_engine_gl_make_resource_current;
745 config.open_gl.gl_external_texture_frame_callback =
746 fl_engine_gl_external_texture_frame_callback;
747 break;
748 case kMetal:
749 case kVulkan:
750 default:
751 g_set_error(error, fl_engine_error_quark(), FL_ENGINE_ERROR_FAILED,
752 "Unsupported renderer type");
753 return FALSE;
754 }
755
756 FlutterTaskRunnerDescription platform_task_runner = {};
757 platform_task_runner.struct_size = sizeof(FlutterTaskRunnerDescription);
758 platform_task_runner.user_data = self;
759 platform_task_runner.runs_task_on_current_thread_callback =
760 fl_engine_runs_task_on_current_thread;
761 platform_task_runner.post_task_callback = fl_engine_post_task;
762 platform_task_runner.identifier = kPlatformTaskRunnerIdentifier;
763
764 FlutterCustomTaskRunners custom_task_runners = {};
765 custom_task_runners.struct_size = sizeof(FlutterCustomTaskRunners);
766 custom_task_runners.platform_task_runner = &platform_task_runner;
767
768 if (fl_dart_project_get_ui_thread_policy(self->project) ==
769 FL_UI_THREAD_POLICY_RUN_ON_PLATFORM_THREAD) {
770 custom_task_runners.ui_task_runner = &platform_task_runner;
771 }
772
773 g_autoptr(GPtrArray) command_line_args =
774 g_ptr_array_new_with_free_func(g_free);
775 g_ptr_array_insert(command_line_args, 0, g_strdup("flutter"));
776 for (const auto& env_switch : flutter::GetSwitchesFromEnvironment()) {
777 g_ptr_array_add(command_line_args, g_strdup(env_switch.c_str()));
778 }
779
780 gchar** dart_entrypoint_args =
781 fl_dart_project_get_dart_entrypoint_arguments(self->project);
782
783 FlutterProjectArgs args = {};
784 args.struct_size = sizeof(FlutterProjectArgs);
785 args.assets_path = fl_dart_project_get_assets_path(self->project);
786 args.icu_data_path = fl_dart_project_get_icu_data_path(self->project);
787 args.command_line_argc = command_line_args->len;
788 args.command_line_argv =
789 reinterpret_cast<const char* const*>(command_line_args->pdata);
790 args.platform_message_callback = fl_engine_platform_message_cb;
791 args.update_semantics_callback2 = fl_engine_update_semantics_cb;
792 args.custom_task_runners = &custom_task_runners;
793 args.shutdown_dart_vm_when_done = true;
794 args.on_pre_engine_restart_callback = fl_engine_on_pre_engine_restart_cb;
795 args.dart_entrypoint_argc =
796 dart_entrypoint_args != nullptr ? g_strv_length(dart_entrypoint_args) : 0;
797 args.dart_entrypoint_argv =
798 reinterpret_cast<const char* const*>(dart_entrypoint_args);
799 args.engine_id = reinterpret_cast<int64_t>(self);
800
801 FlutterCompositor compositor = {};
802 compositor.struct_size = sizeof(FlutterCompositor);
803 compositor.user_data = self;
804 compositor.create_backing_store_callback =
805 compositor_create_backing_store_callback;
806 compositor.collect_backing_store_callback =
807 compositor_collect_backing_store_callback;
808 compositor.present_view_callback = compositor_present_view_callback;
809 args.compositor = &compositor;
810
811 if (self->embedder_api.RunsAOTCompiledDartCode()) {
812 FlutterEngineAOTDataSource source = {};
813 source.type = kFlutterEngineAOTDataSourceTypeElfPath;
814 source.elf_path = fl_dart_project_get_aot_library_path(self->project);
815 if (self->embedder_api.CreateAOTData(&source, &self->aot_data) !=
816 kSuccess) {
817 g_set_error(error, fl_engine_error_quark(), FL_ENGINE_ERROR_FAILED,
818 "Failed to create AOT data");
819 return FALSE;
820 }
821 args.aot_data = self->aot_data;
822 }
823
824 FlutterEngineResult result = self->embedder_api.Initialize(
825 FLUTTER_ENGINE_VERSION, &config, &args, self, &self->engine);
826 if (result != kSuccess) {
827 g_set_error(error, fl_engine_error_quark(), FL_ENGINE_ERROR_FAILED,
828 "Failed to initialize Flutter engine");
829 return FALSE;
830 }
831
832 result = self->embedder_api.RunInitialized(self->engine);
833 if (result != kSuccess) {
834 g_set_error(error, fl_engine_error_quark(), FL_ENGINE_ERROR_FAILED,
835 "Failed to run Flutter engine");
836 return FALSE;
837 }
838
839 setup_locales(self);
840
841 g_autoptr(FlSettings) settings = fl_settings_new();
842 self->settings_handler = fl_settings_handler_new(self);
843 fl_settings_handler_start(self->settings_handler, settings);
844
845 self->platform_handler = fl_platform_handler_new(self->binary_messenger);
846
847 setup_keyboard(self);
848
849 result = self->embedder_api.UpdateSemanticsEnabled(self->engine, TRUE);
850 if (result != kSuccess) {
851 g_warning("Failed to enable accessibility features on Flutter engine");
852 }
853
854 fl_display_monitor_start(self->display_monitor);
855
856 return TRUE;
857 }
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:74
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:106
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:100
fl_dart_project_get_assets_path
G_MODULE_EXPORT const gchar * fl_dart_project_get_assets_path(FlDartProject *self)
Definition: fl_dart_project.cc:87
fl_dart_project_get_ui_thread_policy
G_MODULE_EXPORT FlUIThreadPolicy fl_dart_project_get_ui_thread_policy(FlDartProject *project)
Definition: fl_dart_project.cc:128
FL_UI_THREAD_POLICY_RUN_ON_PLATFORM_THREAD
@ FL_UI_THREAD_POLICY_RUN_ON_PLATFORM_THREAD
Definition: fl_dart_project.h:143
fl_display_monitor_start
void fl_display_monitor_start(FlDisplayMonitor *self)
Definition: fl_display_monitor.cc:103
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:406
fl_engine_runs_task_on_current_thread
static bool fl_engine_runs_task_on_current_thread(void *user_data)
Definition: fl_engine.cc:447
fl_engine_on_pre_engine_restart_cb
static void fl_engine_on_pre_engine_restart_cb(void *user_data)
Definition: fl_engine.cc:513
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:327
fl_engine_gl_make_current
static bool fl_engine_gl_make_current(void *user_data)
Definition: fl_engine.cc:382
compositor_present_view_callback
static bool compositor_present_view_callback(const FlutterPresentViewInfo *info)
Definition: fl_engine.cc:358
compositor_collect_backing_store_callback
static bool compositor_collect_backing_store_callback(const FlutterBackingStore *backing_store, void *user_data)
Definition: fl_engine.cc:343
fl_engine_post_task
static void fl_engine_post_task(FlutterTask task, uint64_t target_time_nanos, void *user_data)
Definition: fl_engine.cc:453
fl_engine_gl_get_fbo
static uint32_t fl_engine_gl_get_fbo(void *user_data)
Definition: fl_engine.cc:394
fl_engine_gl_proc_resolver
static void * fl_engine_gl_proc_resolver(void *user_data, const char *name)
Definition: fl_engine.cc:378
setup_locales
static void setup_locales(FlEngine *self)
Definition: fl_engine.cc:200
fl_engine_update_semantics_cb
static void fl_engine_update_semantics_cb(const FlutterSemanticsUpdate2 *update, void *user_data)
Definition: fl_engine.cc:482
fl_engine_gl_make_resource_current
static bool fl_engine_gl_make_resource_current(void *user_data)
Definition: fl_engine.cc:399
fl_engine_platform_message_cb
static void fl_engine_platform_message_cb(const FlutterPlatformMessage *message, void *user_data)
Definition: fl_engine.cc:462
kPlatformTaskRunnerIdentifier
static constexpr size_t kPlatformTaskRunnerIdentifier
Definition: fl_engine.cc:32
fl_engine_gl_clear_current
static bool fl_engine_gl_clear_current(void *user_data)
Definition: fl_engine.cc:388
args
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
Definition: fl_event_channel.h:89
fl_platform_handler_new
FlPlatformHandler * fl_platform_handler_new(FlBinaryMessenger *messenger)
Definition: fl_platform_handler.cc:254
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
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_dart_project_get_ui_thread_policy(), 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_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_platform_handler_new(), fl_settings_handler_new(), fl_settings_handler_start(), fl_settings_new(), FL_UI_THREAD_POLICY_RUN_ON_PLATFORM_THREAD, g_autoptr(), flutter::GetSwitchesFromEnvironment(), height, kPlatformTaskRunnerIdentifier, self, setup_keyboard(), setup_locales(), TRUE, and user_data.

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 1407 of file fl_engine.cc.

1408 {
1409 g_return_val_if_fail(FL_IS_ENGINE(self), FALSE);
1410 return self->embedder_api.UnregisterExternalTexture(self->engine,
1411 texture_id) == kSuccess;
1412 }

References self, and 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 1436 of file fl_engine.cc.

1436 {
1437 g_return_if_fail(FL_IS_ENGINE(self));
1438
1439 if (self->engine == nullptr) {
1440 return;
1441 }
1442
1443 self->embedder_api.UpdateAccessibilityFeatures(
1444 self->engine, static_cast<FlutterAccessibilityFeature>(flags));
1445 }

References self.

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 482 of file fl_engine.cc.

483 {
484 FlEngine* self = FL_ENGINE(user_data);
485
486 g_signal_emit(self, fl_engine_signals[SIGNAL_UPDATE_SEMANTICS], 0, update);
487 }

References fl_engine_signals, g_signal_emit(), SIGNAL_UPDATE_SEMANTICS, and user_data.

Referenced by fl_engine_start().

## ◆ free_locale()

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

Definition at line 193 of file fl_engine.cc.

193 {
194 free(const_cast<gchar*>(locale->language_code));
195 free(const_cast<gchar*>(locale->country_code));
196 free(locale);
197 }

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 118 of file fl_engine.cc.

125 { PROP_0, PROP_BINARY_MESSENGER, PROP_LAST };
PROP_LAST
@ PROP_LAST
Definition: fl_accessible_node.cc:64
PROP_0
@ PROP_0
Definition: fl_accessible_node.cc:64

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 128 of file fl_engine.cc.

132 {
133 gchar* l = g_strdup(locale);
134
135 // Locales are in the form "language[_territory][.codeset][@modifier]"
136 gchar* match = strrchr(l, '@');
137 if (match != nullptr) {
138 if (modifier != nullptr) {
139 *modifier = g_strdup(match + 1);
140 }
141 *match = '\0';
142 } else if (modifier != nullptr) {
143 *modifier = nullptr;
144 }
145
146 match = strrchr(l, '.');
147 if (match != nullptr) {
148 if (codeset != nullptr) {
149 *codeset = g_strdup(match + 1);
150 }
151 *match = '\0';
152 } else if (codeset != nullptr) {
153 *codeset = nullptr;
154 }
155
156 match = strrchr(l, '_');
157 if (match != nullptr) {
158 if (territory != nullptr) {
159 *territory = g_strdup(match + 1);
160 }
161 *match = '\0';
162 } else if (territory != nullptr) {
163 *territory = nullptr;
164 }
165
166 if (language != nullptr) {
167 *language = l;
168 }
169 }

Referenced by setup_locales().

## ◆ send_key_event_cb()

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

Definition at line 1318 of file fl_engine.cc.

1318 {
1319 g_autoptr(GTask) task = G_TASK(user_data);
1320 gboolean* return_value = g_new0(gboolean, 1);
1321 *return_value = handled;
1322 g_task_return_pointer(task, return_value, g_free);
1323 }

References g_autoptr(), and user_data.

Referenced by fl_engine_send_key_event().

## ◆ setup_keyboard()

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

Definition at line 489 of file fl_engine.cc.

489 {
490 g_clear_object(&self->keyboard_manager);
491 self->keyboard_manager = fl_keyboard_manager_new(self);
492
493 g_clear_object(&self->keyboard_handler);
494 self->keyboard_handler =
495 fl_keyboard_handler_new(self->binary_messenger, self->keyboard_manager);
496
497 GtkWidget* widget =
498 self->text_input_handler != nullptr
499 ? fl_text_input_handler_get_widget(self->text_input_handler)
500 : nullptr;
501 g_clear_object(&self->text_input_handler);
502 self->text_input_handler = fl_text_input_handler_new(self->binary_messenger);
503 if (widget != nullptr) {
504 fl_text_input_handler_set_widget(self->text_input_handler, widget);
505 }
506 }
fl_keyboard_handler_new
FlKeyboardHandler * fl_keyboard_handler_new(FlBinaryMessenger *messenger, FlKeyboardManager *keyboard_manager)
Definition: fl_keyboard_handler.cc:63
fl_text_input_handler_new
FlTextInputHandler * fl_text_input_handler_new(FlBinaryMessenger *messenger)
Definition: fl_text_input_handler.cc:422
fl_text_input_handler_set_widget
void fl_text_input_handler_set_widget(FlTextInputHandler *self, GtkWidget *widget)
Definition: fl_text_input_handler.cc:464
fl_text_input_handler_get_widget
GtkWidget * fl_text_input_handler_get_widget(FlTextInputHandler *self)
Definition: fl_text_input_handler.cc:472

References fl_keyboard_handler_new(), fl_keyboard_manager_new(), fl_text_input_handler_get_widget(), fl_text_input_handler_new(), fl_text_input_handler_set_widget(), and self.

Referenced by fl_engine_on_pre_engine_restart_cb(), and fl_engine_start().

## ◆ setup_locales()

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

Definition at line 200 of file fl_engine.cc.

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

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

Referenced by fl_engine_start().

## ◆ view_added_cb()

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

Definition at line 171 of file fl_engine.cc.

171 {
172 g_autoptr(GTask) task = G_TASK(result->user_data);
173
174 if (result->added) {
175 g_task_return_boolean(task, TRUE);
176 } else {
177 g_task_return_new_error(task, fl_engine_error_quark(),
178 FL_ENGINE_ERROR_FAILED, "Failed to add view");
179 }
180 }

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

Referenced by fl_engine_add_view().

## ◆ view_removed_cb()

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

Definition at line 182 of file fl_engine.cc.

182 {
183 g_autoptr(GTask) task = G_TASK(result->user_data);
184
185 if (result->removed) {
186 g_task_return_boolean(task, TRUE);
187 } else {
188 g_task_return_new_error(task, fl_engine_error_quark(),
189 FL_ENGINE_ERROR_FAILED, "Failed to remove view");
190 }
191 }

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

Referenced by fl_engine_remove_view().

## Variable Documentation

## ◆ fl_engine_signals

guint fl_engine_signals[LAST_SIGNAL]
| static

Definition at line 116 of file fl_engine.cc.

Referenced by fl_engine_class_init(), fl_engine_on_pre_engine_restart_cb(), and fl_engine_update_semantics_cb().

## ◆ kMousePointerDeviceId

constexpr int32_t kMousePointerDeviceId = 0
| static constexpr

Definition at line 36 of file fl_engine.cc.

Referenced by fl_engine_send_mouse_pointer_event().

## ◆ kPlatformTaskRunnerIdentifier

constexpr size_t kPlatformTaskRunnerIdentifier = 1
| static constexpr

Definition at line 32 of file fl_engine.cc.

Referenced by fl_engine_start().

## ◆ kPointerPanZoomDeviceId

constexpr int32_t kPointerPanZoomDeviceId = 1
| static constexpr

Definition at line 37 of file fl_engine.cc.

Referenced by fl_engine_send_pointer_pan_zoom_event().