Flutter Linux Embedder
fl_engine.cc File Reference

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 set_renderable (FlEngine *self, int64_t view_id, FlRenderable *renderable)
 Stores a weak reference to the renderable with the given ID. More...
 
static FlRenderable * get_renderable (FlEngine *self, int64_t view_id)
 
static void remove_renderable (FlEngine *self, int64_t view_id)
 Remove a renderable that no longer exists. More...
 
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 min_width, size_t min_height, size_t max_width, size_t max_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 min_width, size_t min_height, size_t max_width, size_t max_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)
 
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 118 of file fl_engine.cc.

@ LAST_SIGNAL
Definition: fl_engine.cc:118
@ SIGNAL_UPDATE_SEMANTICS
Definition: fl_engine.cc:118
@ SIGNAL_ON_PRE_ENGINE_RESTART
Definition: fl_engine.cc:118

Function Documentation

◆ collect_opengl_backing_store()

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

Definition at line 320 of file fl_engine.cc.

322  {
323  if (!fl_opengl_manager_make_current(self->opengl_manager)) {
324  return false;
325  }
326 
327  // OpenGL context is required when destroying #FlFramebuffer.
328  g_object_unref(backing_store->open_gl.framebuffer.user_data);
329  return true;
330 }
gboolean fl_opengl_manager_make_current(FlOpenGLManager *self)

References fl_opengl_manager_make_current().

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

358  {
359  free(const_cast<void*>(backing_store->software.allocation));
360  return true;
361 }

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

382  {
383  FlEngine* self = static_cast<FlEngine*>(user_data);
384  switch (self->renderer_type) {
385  case kOpenGL:
386  return collect_opengl_backing_store(self, backing_store);
387  case kSoftware:
388  return collect_software_backing_store(self, backing_store);
389  default:
390  return false;
391  }
392 }
const char FlTextDirection FlAssertiveness gpointer user_data
static bool collect_opengl_backing_store(FlEngine *self, const FlutterBackingStore *backing_store)
Definition: fl_engine.cc:320
static bool collect_software_backing_store(FlEngine *self, const FlutterBackingStore *backing_store)
Definition: fl_engine.cc:356

References collect_opengl_backing_store(), collect_software_backing_store(), and user_data.

Referenced by fl_engine_start().

◆ compositor_create_backing_store_callback()

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

Definition at line 364 of file fl_engine.cc.

367  {
368  FlEngine* self = static_cast<FlEngine*>(user_data);
369  switch (self->renderer_type) {
370  case kOpenGL:
371  return create_opengl_backing_store(self, config, backing_store_out);
372  case kSoftware:
373  return create_software_backing_store(self, config, backing_store_out);
374  default:
375  return false;
376  }
377 }
static bool create_opengl_backing_store(FlEngine *self, const FlutterBackingStoreConfig *config, FlutterBackingStore *backing_store_out)
Definition: fl_engine.cc:283
static bool create_software_backing_store(FlEngine *self, const FlutterBackingStoreConfig *config, FlutterBackingStore *backing_store_out)
Definition: fl_engine.cc:332

References create_opengl_backing_store(), create_software_backing_store(), and user_data.

Referenced by fl_engine_start().

◆ compositor_present_view_callback()

static bool compositor_present_view_callback ( const FlutterPresentViewInfo *  info)
static

Definition at line 395 of file fl_engine.cc.

396  {
397  FlEngine* self = static_cast<FlEngine*>(info->user_data);
398 
399  g_autoptr(FlRenderable) renderable = get_renderable(self, info->view_id);
400  if (renderable == nullptr) {
401  return true;
402  }
403 
404  fl_renderable_present_layers(renderable, info->layers, info->layers_count);
405  return true;
406 }
g_autoptr(FlEngine) engine
FlRenderable * renderable
static FlRenderable * get_renderable(FlEngine *self, int64_t view_id)
Definition: fl_engine.cc:188
void fl_renderable_present_layers(FlRenderable *self, const FlutterLayer **layers, size_t layers_count)

References fl_renderable_present_layers(), g_autoptr(), get_renderable(), and renderable.

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

286  {
287  if (!fl_opengl_manager_make_current(self->opengl_manager)) {
288  return false;
289  }
290 
291  GLint sized_format = GL_RGBA8;
292  GLint general_format = GL_RGBA;
293  if (epoxy_has_gl_extension("GL_EXT_texture_format_BGRA8888")) {
294  sized_format = GL_BGRA8_EXT;
295  general_format = GL_BGRA_EXT;
296  }
297 
298  FlFramebuffer* framebuffer = fl_framebuffer_new(
299  general_format, config->size.width, config->size.height, FALSE);
300  if (!framebuffer) {
301  g_warning("Failed to create backing store");
302  return false;
303  }
304 
305  backing_store_out->type = kFlutterBackingStoreTypeOpenGL;
306  backing_store_out->open_gl.type = kFlutterOpenGLTargetTypeFramebuffer;
307  backing_store_out->open_gl.framebuffer.user_data = framebuffer;
308  backing_store_out->open_gl.framebuffer.name =
309  fl_framebuffer_get_id(framebuffer);
310  backing_store_out->open_gl.framebuffer.target = sized_format;
311  backing_store_out->open_gl.framebuffer.destruction_callback = [](void* p) {
312  // Backing store destroyed in fl_compositor_opengl_collect_backing_store(),
313  // set on FlutterCompositor.collect_backing_store_callback during engine
314  // start.
315  };
316 
317  return true;
318 }
GLuint fl_framebuffer_get_id(FlFramebuffer *self)
FlFramebuffer * fl_framebuffer_new(GLint format, size_t width, size_t height, gboolean shareable)

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

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

335  {
336  size_t allocation_length = config->size.width * config->size.height * 4;
337  uint8_t* allocation = static_cast<uint8_t*>(malloc(allocation_length));
338  if (allocation == nullptr) {
339  return false;
340  }
341 
342  backing_store_out->type = kFlutterBackingStoreTypeSoftware;
343  backing_store_out->software.allocation = allocation;
344  backing_store_out->software.height = config->size.height;
345  backing_store_out->software.row_bytes = config->size.width * 4;
346  backing_store_out->software.user_data = nullptr;
347  backing_store_out->software.destruction_callback = [](void* p) {
348  // Backing store destroyed in
349  // fl_compositor_software_collect_backing_store(), set on
350  // FlutterCompositor.collect_backing_store_callback during engine start.
351  };
352 
353  return true;
354 }

Referenced by compositor_create_backing_store_callback().

◆ fl_engine_add_view()

FlutterViewId fl_engine_add_view ( FlEngine *  engine,
FlRenderable *  renderable,
size_t  min_width,
size_t  min_height,
size_t  max_width,
size_t  max_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. @min_width: minimum width of view in pixels. @min_height: minimum height of view in pixels. @max_width: maximum width of view in pixels. @max_height: maximum 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 923 of file fl_engine.cc.

932  {
933  g_return_val_if_fail(FL_IS_ENGINE(self), -1);
934 
935  g_autoptr(GTask) task = g_task_new(self, cancellable, callback, user_data);
936 
937  FlutterViewId view_id = self->next_view_id;
938  self->next_view_id++;
939 
941 
942  // We don't know which display this view will open on, so set to zero and this
943  // will be updated in a following FlutterWindowMetricsEvent
944  FlutterEngineDisplayId display_id = 0;
945 
946  FlutterWindowMetricsEvent metrics = {};
947  metrics.struct_size = sizeof(FlutterWindowMetricsEvent);
948  metrics.width = min_width;
949  metrics.height = min_height;
950  metrics.pixel_ratio = pixel_ratio;
951  metrics.display_id = display_id;
952  metrics.view_id = view_id;
953  metrics.has_constraints = true;
954  metrics.min_width_constraint = min_width;
955  metrics.min_height_constraint = min_height;
956  metrics.max_width_constraint = max_width;
957  metrics.max_height_constraint = max_height;
958  FlutterAddViewInfo info;
959  info.struct_size = sizeof(FlutterAddViewInfo);
960  info.view_id = view_id;
961  info.view_metrics = &metrics;
962  info.user_data = g_object_ref(task);
963  info.add_view_callback = view_added_cb;
964  FlutterEngineResult result = self->embedder_api.AddView(self->engine, &info);
965  if (result != kSuccess) {
966  g_task_return_new_error(task, fl_engine_error_quark(),
967  FL_ENGINE_ERROR_FAILED, "AddView 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 
973  return view_id;
974 }
static void view_added_cb(const FlutterAddViewResult *result)
Definition: fl_engine.cc:204
static void set_renderable(FlEngine *self, int64_t view_id, FlRenderable *renderable)
Stores a weak reference to the renderable with the given ID.
Definition: fl_engine.cc:176
GQuark fl_engine_error_quark(void) G_GNUC_CONST
@ FL_ENGINE_ERROR_FAILED
G_BEGIN_DECLS FlutterViewId view_id

References FL_ENGINE_ERROR_FAILED, fl_engine_error_quark(), g_autoptr(), renderable, set_renderable(), user_data, view_added_cb(), and view_id.

Referenced by fl_view_new_for_engine(), fl_view_new_sized_to_content(), 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. If error is not NULL, *error must be initialized (typically NULL, but an error from a previous call using GLib error handling is explicitly valid).

Completes request started with fl_engine_add_view().

Returns: TRUE on success.

Definition at line 976 of file fl_engine.cc.

978  {
979  g_return_val_if_fail(FL_IS_ENGINE(self), FALSE);
980  return g_task_propagate_boolean(G_TASK(result), error);
981 }
const uint8_t uint32_t uint32_t GError ** error

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

641  {
642  G_OBJECT_CLASS(klass)->dispose = fl_engine_dispose;
643  G_OBJECT_CLASS(klass)->set_property = fl_engine_set_property;
644 
645  g_object_class_install_property(
646  G_OBJECT_CLASS(klass), PROP_BINARY_MESSENGER,
647  g_param_spec_object(
648  "binary-messenger", "messenger", "Binary messenger",
649  fl_binary_messenger_get_type(),
650  static_cast<GParamFlags>(G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY |
651  G_PARAM_STATIC_STRINGS)));
652 
654  "on-pre-engine-restart", fl_engine_get_type(), G_SIGNAL_RUN_LAST, 0,
655  nullptr, nullptr, nullptr, G_TYPE_NONE, 0);
657  "update-semantics", fl_engine_get_type(), G_SIGNAL_RUN_LAST, 0, nullptr,
658  nullptr, nullptr, G_TYPE_NONE, 1, G_TYPE_POINTER);
659 }
static void fl_engine_dispose(GObject *object)
Definition: fl_engine.cc:591
static guint fl_engine_signals[LAST_SIGNAL]
Definition: fl_engine.cc:120
static void fl_engine_set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
Definition: fl_engine.cc:575

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

1444  {
1445  g_return_if_fail(FL_IS_ENGINE(self));
1446 
1447  if (self->engine == nullptr) {
1448  return;
1449  }
1450 
1451  const uint8_t* action_data = nullptr;
1452  size_t action_data_length = 0;
1453  if (data != nullptr) {
1454  action_data = static_cast<const uint8_t*>(
1455  g_bytes_get_data(data, &action_data_length));
1456  }
1457 
1458  FlutterSendSemanticsActionInfo info;
1459  info.struct_size = sizeof(FlutterSendSemanticsActionInfo);
1460  info.view_id = view_id;
1461  info.node_id = node_id;
1462  info.action = action;
1463  info.data = action_data;
1464  info.data_length = action_data_length;
1465  if (self->embedder_api.SendSemanticsAction(self->engine, &info) != kSuccess) {
1466  g_warning("Failed to send semantics action");
1467  }
1468 }

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

591  {
592  FlEngine* self = FL_ENGINE(object);
593 
594  if (self->engine != nullptr) {
595  if (self->embedder_api.Shutdown(self->engine) != kSuccess) {
596  g_warning("Failed to shutdown Flutter engine");
597  }
598  self->engine = nullptr;
599  }
600 
601  if (self->aot_data != nullptr) {
602  if (self->embedder_api.CollectAOTData(self->aot_data) != kSuccess) {
603  g_warning("Failed to send collect AOT data");
604  }
605  self->aot_data = nullptr;
606  }
607 
608  fl_binary_messenger_shutdown(self->binary_messenger);
609  fl_texture_registrar_shutdown(self->texture_registrar);
610 
611  g_clear_object(&self->project);
612  g_clear_object(&self->display_monitor);
613  g_clear_object(&self->opengl_manager);
614  g_clear_object(&self->texture_registrar);
615  g_clear_object(&self->binary_messenger);
616  g_clear_object(&self->settings_handler);
617  g_clear_object(&self->platform_handler);
618  g_clear_object(&self->accessibility_handler);
619  g_clear_object(&self->keyboard_manager);
620  g_clear_object(&self->text_input_handler);
621  g_clear_object(&self->keyboard_handler);
622  g_clear_object(&self->mouse_cursor_handler);
623  g_clear_object(&self->task_runner);
624  {
625  g_autoptr(GMutexLocker) locker =
626  g_mutex_locker_new(&self->renderables_mutex);
627  g_clear_pointer(&self->renderables_by_view_id, g_hash_table_unref);
628  }
629  g_mutex_clear(&self->renderables_mutex);
630 
631  if (self->platform_message_handler_destroy_notify) {
632  self->platform_message_handler_destroy_notify(
633  self->platform_message_handler_data);
634  }
635  self->platform_message_handler_data = nullptr;
636  self->platform_message_handler_destroy_notify = nullptr;
637 
638  G_OBJECT_CLASS(fl_engine_parent_class)->dispose(object);
639 }
void fl_binary_messenger_shutdown(FlBinaryMessenger *self)
void fl_texture_registrar_shutdown(FlTextureRegistrar *self)

References fl_binary_messenger_shutdown(), fl_texture_registrar_shutdown(), and g_autoptr().

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

1502  {
1503  g_return_if_fail(FL_IS_ENGINE(self));
1504  if (self->embedder_api.RunTask(self->engine, task) != kSuccess) {
1505  g_warning("Failed to run task");
1506  }
1507 }

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

725  {
726  void* engine = reinterpret_cast<void*>(id);
727  g_return_val_if_fail(FL_IS_ENGINE(engine), nullptr);
728  return FL_ENGINE(engine);
729 }
int64_t id

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

1492  {
1493  g_return_val_if_fail(FL_IS_ENGINE(self), nullptr);
1494  return self->binary_messenger;
1495 }

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

755  {
756  g_return_val_if_fail(FL_IS_ENGINE(self), nullptr);
757  return self->display_monitor;
758 }

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

902  {
903  return &(self->embedder_api);
904 }

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

1534  {
1535  g_return_val_if_fail(FL_IS_ENGINE(self), nullptr);
1536  return self->keyboard_manager;
1537 }

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

1544  {
1545  g_return_val_if_fail(FL_IS_ENGINE(self), nullptr);
1546  return self->mouse_cursor_handler;
1547 }

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

750  {
751  g_return_val_if_fail(FL_IS_ENGINE(self), nullptr);
752  return self->opengl_manager;
753 }

Referenced by realize_cb(), and setup_opengl().

◆ fl_engine_get_registrar_for_plugin()

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

Definition at line 561 of file fl_engine.cc.

563  {
564  FlEngine* self = FL_ENGINE(registry);
565 
566  return fl_plugin_registrar_new(nullptr, self->binary_messenger,
567  self->texture_registrar);
568 }
FlPluginRegistrar * fl_plugin_registrar_new(FlView *view, FlBinaryMessenger *messenger, FlTextureRegistrar *texture_registrar)

References fl_plugin_registrar_new().

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

983  {
984  g_return_val_if_fail(FL_IS_ENGINE(self), nullptr);
985 
986  return get_renderable(self, view_id);
987 }

References get_renderable(), 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 745 of file fl_engine.cc.

745  {
746  g_return_val_if_fail(FL_IS_ENGINE(self), static_cast<FlutterRendererType>(0));
747  return self->renderer_type;
748 }

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

1497  {
1498  g_return_val_if_fail(FL_IS_ENGINE(self), nullptr);
1499  return self->task_runner;
1500 }

Referenced by setup_opengl(), setup_software(), and 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 1539 of file fl_engine.cc.

1539  {
1540  g_return_val_if_fail(FL_IS_ENGINE(self), nullptr);
1541  return self->text_input_handler;
1542 }

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

1510  {
1511  g_return_val_if_fail(FL_IS_ENGINE(self), nullptr);
1512  return self->texture_registrar;
1513 }

Referenced by fl_view_get_registrar_for_plugin().

◆ fl_engine_gl_clear_current()

static bool fl_engine_gl_clear_current ( void *  user_data)
static

Definition at line 419 of file fl_engine.cc.

419  {
420  FlEngine* self = static_cast<FlEngine*>(user_data);
421  return fl_opengl_manager_clear_current(self->opengl_manager);
422 }
gboolean fl_opengl_manager_clear_current(FlOpenGLManager *self)

References fl_opengl_manager_clear_current(), and user_data.

Referenced by fl_engine_start().

◆ fl_engine_gl_external_texture_frame_callback()

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

Definition at line 435 of file fl_engine.cc.

440  {
441  FlEngine* self = static_cast<FlEngine*>(user_data);
442  if (!self->texture_registrar) {
443  return false;
444  }
445 
446  FlTexture* texture =
447  fl_texture_registrar_lookup_texture(self->texture_registrar, texture_id);
448  if (texture == nullptr) {
449  g_warning("Unable to find texture %" G_GINT64_FORMAT, texture_id);
450  return false;
451  }
452 
453  gboolean result;
454  g_autoptr(GError) error = nullptr;
455  if (FL_IS_TEXTURE_GL(texture)) {
456  result = fl_texture_gl_populate(FL_TEXTURE_GL(texture), width, height,
457  opengl_texture, &error);
458  } else if (FL_IS_PIXEL_BUFFER_TEXTURE(texture)) {
459  result =
460  fl_pixel_buffer_texture_populate(FL_PIXEL_BUFFER_TEXTURE(texture),
461  width, height, opengl_texture, &error);
462  } else {
463  g_warning("Unsupported texture type %" G_GINT64_FORMAT, texture_id);
464  return false;
465  }
466 
467  if (!result) {
468  g_warning("%s", error->message);
469  return false;
470  }
471 
472  return true;
473 }
self height
self width
gboolean fl_pixel_buffer_texture_populate(FlPixelBufferTexture *texture, uint32_t width, uint32_t height, FlutterOpenGLTexture *opengl_texture, GError **error)
gboolean fl_texture_gl_populate(FlTextureGL *self, uint32_t width, uint32_t height, FlutterOpenGLTexture *opengl_texture, GError **error)
FlTexture * fl_texture_registrar_lookup_texture(FlTextureRegistrar *self, int64_t texture_id)
int64_t texture_id

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

Referenced by fl_engine_start().

◆ fl_engine_gl_get_fbo()

static uint32_t fl_engine_gl_get_fbo ( void *  user_data)
static

Definition at line 424 of file fl_engine.cc.

424  {
425  // There is only one frame buffer object - always return that.
426  return 0;
427 }

Referenced by fl_engine_start().

◆ fl_engine_gl_make_current()

static bool fl_engine_gl_make_current ( void *  user_data)
static

Definition at line 414 of file fl_engine.cc.

414  {
415  FlEngine* self = static_cast<FlEngine*>(user_data);
416  return fl_opengl_manager_make_current(self->opengl_manager);
417 }

References fl_opengl_manager_make_current(), and user_data.

Referenced by fl_engine_start().

◆ fl_engine_gl_make_resource_current()

static bool fl_engine_gl_make_resource_current ( void *  user_data)
static

Definition at line 429 of file fl_engine.cc.

429  {
430  FlEngine* self = static_cast<FlEngine*>(user_data);
431  return fl_opengl_manager_make_resource_current(self->opengl_manager);
432 }
gboolean fl_opengl_manager_make_resource_current(FlOpenGLManager *self)

References fl_opengl_manager_make_resource_current(), 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 410 of file fl_engine.cc.

410  {
411  return reinterpret_cast<void*>(eglGetProcAddress(name));
412 }

Referenced by fl_engine_start().

◆ fl_engine_init()

static void fl_engine_init ( FlEngine *  self)
static

Definition at line 661 of file fl_engine.cc.

661  {
662  self->thread = g_thread_self();
663 
664  self->embedder_api.struct_size = sizeof(FlutterEngineProcTable);
665  if (FlutterEngineGetProcAddresses(&self->embedder_api) != kSuccess) {
666  g_warning("Failed get get engine function pointers");
667  }
668 
669  self->opengl_manager = fl_opengl_manager_new();
670 
671  self->display_monitor =
672  fl_display_monitor_new(self, gdk_display_get_default());
673  self->task_runner = fl_task_runner_new(self);
674 
675  // Implicit view is 0, so start at 1.
676  self->next_view_id = 1;
677  g_mutex_init(&self->renderables_mutex);
678  self->renderables_by_view_id = g_hash_table_new_full(
679  g_direct_hash, g_direct_equal, nullptr, [](gpointer value) {
680  GWeakRef* ref = static_cast<GWeakRef*>(value);
681  g_weak_ref_clear(ref);
682  free(ref);
683  });
684 
685  self->texture_registrar = fl_texture_registrar_new(self);
686 }
FlDisplayMonitor * fl_display_monitor_new(FlEngine *engine, GdkDisplay *display)
FlOpenGLManager * fl_opengl_manager_new()
uint8_t value
FlTaskRunner * fl_task_runner_new(FlEngine *engine)
FlTextureRegistrar * fl_texture_registrar_new(FlEngine *engine)

References fl_display_monitor_new(), fl_opengl_manager_new(), fl_task_runner_new(), fl_texture_registrar_new(), 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 1470 of file fl_engine.cc.

1471  {
1472  g_return_val_if_fail(FL_IS_ENGINE(self), FALSE);
1473  return self->embedder_api.MarkExternalTextureFrameAvailable(
1474  self->engine, texture_id) == kSuccess;
1475 }

References texture_id.

Referenced by mark_texture_frame_available().

◆ fl_engine_new()

G_MODULE_EXPORT FlEngine* fl_engine_new ( FlDartProject *  project)

FlEngine:

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

Creates new Flutter engine.

Returns: a new #FlEngine.

Definition at line 731 of file fl_engine.cc.

731  {
732  return fl_engine_new_full(project, nullptr);
733 }
static FlEngine * fl_engine_new_full(FlDartProject *project, FlBinaryMessenger *binary_messenger)
Definition: fl_engine.cc:688

References fl_engine_new_full().

Referenced by fl_engine_new_headless(), fl_view_new(), FlAccessibleNodeTest::SetUp(), and TEST().

◆ fl_engine_new_full()

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

Definition at line 688 of file fl_engine.cc.

689  {
690  g_return_val_if_fail(FL_IS_DART_PROJECT(project), nullptr);
691 
692  FlEngine* self = FL_ENGINE(g_object_new(fl_engine_get_type(), nullptr));
693 
694  self->project = FL_DART_PROJECT(g_object_ref(project));
695  const gchar* renderer = g_getenv("FLUTTER_LINUX_RENDERER");
696  if (g_strcmp0(renderer, "software") == 0) {
697  self->renderer_type = kSoftware;
698  g_warning(
699  "Using the software renderer. Not all features are supported. This is "
700  "not recommended.\n"
701  "\n"
702  "To switch back to the default renderer, unset the "
703  "FLUTTER_LINUX_RENDERER environment variable.");
704  } else {
705  if (renderer != nullptr && strcmp(renderer, "opengl") != 0) {
706  g_warning("Unknown renderer type '%s', defaulting to opengl", renderer);
707  }
708  self->renderer_type = kOpenGL;
709  }
710 
711  if (binary_messenger != nullptr) {
712  self->binary_messenger =
713  FL_BINARY_MESSENGER(g_object_ref(binary_messenger));
714  } else {
715  self->binary_messenger = fl_binary_messenger_new(self);
716  }
717  self->keyboard_manager = fl_keyboard_manager_new(self);
718  self->mouse_cursor_handler =
719  fl_mouse_cursor_handler_new(self->binary_messenger);
720  self->accessibility_handler = fl_accessibility_handler_new(self);
721 
722  return self;
723 }
FlAccessibilityHandler * fl_accessibility_handler_new(FlEngine *engine)
FlBinaryMessenger * fl_binary_messenger_new(FlEngine *engine)
FlKeyboardManager * fl_keyboard_manager_new(FlEngine *engine)
FlMouseCursorHandler * fl_mouse_cursor_handler_new(FlBinaryMessenger *messenger)

References fl_accessibility_handler_new(), fl_binary_messenger_new(), fl_keyboard_manager_new(), and fl_mouse_cursor_handler_new().

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

741  {
742  return fl_engine_new(project);
743 }
G_MODULE_EXPORT FlEngine * fl_engine_new(FlDartProject *project)
Definition: fl_engine.cc:731

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

736  {
737  g_autoptr(FlDartProject) project = fl_dart_project_new();
738  return fl_engine_new_full(project, binary_messenger);
739 }
G_MODULE_EXPORT FlDartProject * fl_dart_project_new()

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

908  {
909  g_return_if_fail(FL_IS_ENGINE(self));
910 
911  FlutterEngineResult result = self->embedder_api.NotifyDisplayUpdate(
912  self->engine, kFlutterEngineDisplaysUpdateTypeStartup, displays,
913  displays_length);
914  if (result != kSuccess) {
915  g_warning("Failed to notify display update to Flutter engine: %d", result);
916  }
917 }

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

542  {
543  FlEngine* self = FL_ENGINE(user_data);
544 
545  setup_keyboard(self);
546 
547  g_signal_emit(self, fl_engine_signals[SIGNAL_ON_PRE_ENGINE_RESTART], 0);
548 }
static void setup_keyboard(FlEngine *self)
Definition: fl_engine.cc:518

References fl_engine_signals, 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 491 of file fl_engine.cc.

492  {
493  FlEngine* self = FL_ENGINE(user_data);
494 
495  gboolean handled = FALSE;
496  if (self->platform_message_handler != nullptr) {
497  g_autoptr(GBytes) data =
498  g_bytes_new(message->message, message->message_size);
499  handled = self->platform_message_handler(
500  self, message->channel, data, message->response_handle,
501  self->platform_message_handler_data);
502  }
503 
504  if (!handled) {
505  fl_engine_send_platform_message_response(self, message->response_handle,
506  nullptr, nullptr);
507  }
508 }
const char * message
gboolean fl_engine_send_platform_message_response(FlEngine *self, const FlutterPlatformMessageResponseHandle *handle, GBytes *response, GError **error)
Definition: fl_engine.cc:1042

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

554  {
555  g_autoptr(GTask) task = G_TASK(user_data);
556  g_task_return_pointer(task, g_bytes_new(data, data_length),
557  reinterpret_cast<GDestroyNotify>(g_bytes_unref));
558 }

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

571  {
572  iface->get_registrar_for_plugin = fl_engine_get_registrar_for_plugin;
573 }
static FlPluginRegistrar * fl_engine_get_registrar_for_plugin(FlPluginRegistry *registry, const gchar *name)
Definition: fl_engine.cc:561

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

484  {
485  FlEngine* self = static_cast<FlEngine*>(user_data);
486 
487  fl_task_runner_post_flutter_task(self->task_runner, task, target_time_nanos);
488 }
void fl_task_runner_post_flutter_task(FlTaskRunner *self, FlutterTask task, uint64_t target_time_nanos)

References fl_task_runner_post_flutter_task(), and user_data.

Referenced by fl_engine_start().

◆ fl_engine_register_external_texture()

gboolean fl_engine_register_external_texture ( FlEngine *  engine,
int64_t  texture_id 
)

fl_engine_register_external_texture: @engine: an #FlEngine. @texture_id: the identifier of the texture that is available.

Tells the Flutter engine that a new external texture is available.

Returns: TRUE on success.

Definition at line 1477 of file fl_engine.cc.

1478  {
1479  g_return_val_if_fail(FL_IS_ENGINE(self), FALSE);
1480  return self->embedder_api.RegisterExternalTexture(self->engine, texture_id) ==
1481  kSuccess;
1482 }

References texture_id.

Referenced by register_texture().

◆ fl_engine_remove_view()

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

fl_engine_remove_view: @engine: an #FlEngine. @view_id: ID to remove. @cancellable: (allow-none): a #GCancellable or NULL. @callback: (scope async): a #GAsyncReadyCallback to call when the view is added. @user_data: (closure): user data to pass to @callback.

Removes a view previously added with fl_engine_add_view().

Definition at line 989 of file fl_engine.cc.

993  {
994  g_return_if_fail(FL_IS_ENGINE(self));
995 
996  remove_renderable(self, view_id);
997 
998  g_autoptr(GTask) task = g_task_new(self, cancellable, callback, user_data);
999 
1000  FlutterRemoveViewInfo info;
1001  info.struct_size = sizeof(FlutterRemoveViewInfo);
1002  info.view_id = view_id;
1003  info.user_data = g_object_ref(task);
1004  info.remove_view_callback = view_removed_cb;
1005  FlutterEngineResult result =
1006  self->embedder_api.RemoveView(self->engine, &info);
1007  if (result != kSuccess) {
1008  g_task_return_new_error(task, fl_engine_error_quark(),
1009  FL_ENGINE_ERROR_FAILED, "RemoveView returned %d",
1010  result);
1011  // This would have been done in the callback, but that won't occur now.
1012  g_object_unref(task);
1013  }
1014 }
static void remove_renderable(FlEngine *self, int64_t view_id)
Remove a renderable that no longer exists.
Definition: fl_engine.cc:199
static void view_removed_cb(const FlutterRemoveViewResult *result)
Definition: fl_engine.cc:215

References FL_ENGINE_ERROR_FAILED, fl_engine_error_quark(), g_autoptr(), remove_renderable(), 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. If error is not NULL, *error must be initialized (typically NULL, but an error from a previous call using GLib error handling is explicitly valid).

Completes request started with fl_engine_remove_view().

Returns: TRUE on succcess.

Definition at line 1016 of file fl_engine.cc.

1018  {
1019  g_return_val_if_fail(FL_IS_ENGINE(self), FALSE);
1020  return g_task_propagate_boolean(G_TASK(result), error);
1021 }

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

1529  {
1530  g_return_if_fail(FL_IS_ENGINE(self));
1531  fl_platform_handler_request_app_exit(self->platform_handler);
1532 }
void fl_platform_handler_request_app_exit(FlPlatformHandler *self)

References fl_platform_handler_request_app_exit().

Referenced by window_delete_event_cb().

◆ fl_engine_runs_task_on_current_thread()

static bool fl_engine_runs_task_on_current_thread ( void *  user_data)
static

Definition at line 476 of file fl_engine.cc.

476  {
477  FlEngine* self = static_cast<FlEngine*>(user_data);
478  return self->thread == g_thread_self();
479 }

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

1404  {
1405  g_return_if_fail(FL_IS_ENGINE(self));
1406 
1407  g_autoptr(GTask) task = g_task_new(self, cancellable, callback, user_data);
1408 
1409  if (self->engine == nullptr) {
1410  g_task_return_new_error(task, fl_engine_error_quark(),
1411  FL_ENGINE_ERROR_FAILED, "No engine");
1412  return;
1413  }
1414 
1415  if (self->embedder_api.SendKeyEvent(self->engine, event, send_key_event_cb,
1416  g_object_ref(task)) != kSuccess) {
1417  g_task_return_new_error(task, fl_engine_error_quark(),
1418  FL_ENGINE_ERROR_FAILED, "Failed to send key event");
1419  g_object_unref(task);
1420  }
1421 }
static void send_key_event_cb(bool handled, void *user_data)
Definition: fl_engine.cc:1393

References FL_ENGINE_ERROR_FAILED, fl_engine_error_quark(), g_autoptr(), 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. If error is not NULL, *error must be initialized (typically NULL, but an error from a previous call using GLib error handling is explicitly valid).

Completes request started with fl_engine_send_key_event().

Returns: TRUE on success.

Definition at line 1423 of file fl_engine.cc.

1426  {
1427  g_return_val_if_fail(FL_IS_ENGINE(self), FALSE);
1428  g_return_val_if_fail(g_task_is_valid(result, self), FALSE);
1429 
1430  g_autofree gboolean* return_value =
1431  static_cast<gboolean*>(g_task_propagate_pointer(G_TASK(result), error));
1432  if (return_value == nullptr) {
1433  return FALSE;
1434  }
1435 
1436  *handled = *return_value;
1437  return TRUE;
1438 }
return TRUE

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

1185  {
1186  g_return_if_fail(FL_IS_ENGINE(self));
1187 
1188  if (self->engine == nullptr) {
1189  return;
1190  }
1191 
1192  FlutterPointerEvent fl_event = {};
1193  fl_event.struct_size = sizeof(fl_event);
1194  fl_event.phase = phase;
1195  fl_event.timestamp = timestamp;
1196  fl_event.x = x;
1197  fl_event.y = y;
1198  if (scroll_delta_x != 0 || scroll_delta_y != 0) {
1199  fl_event.signal_kind = kFlutterPointerSignalKindScroll;
1200  }
1201  fl_event.scroll_delta_x = scroll_delta_x;
1202  fl_event.scroll_delta_y = scroll_delta_y;
1203  fl_event.device_kind = device_kind;
1204  fl_event.buttons = buttons;
1205  fl_event.device = kMousePointerDeviceId;
1206  fl_event.view_id = view_id;
1207  if (self->embedder_api.SendPointerEvent(self->engine, &fl_event, 1) !=
1208  kSuccess) {
1209  g_warning("Failed to send pointer event");
1210  }
1211 }
static constexpr int32_t kMousePointerDeviceId
Definition: fl_engine.cc:36

References kMousePointerDeviceId, 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 1074 of file fl_engine.cc.

1079  {
1080  g_return_if_fail(FL_IS_ENGINE(self));
1081 
1082  GTask* task = nullptr;
1083  FlutterPlatformMessageResponseHandle* response_handle = nullptr;
1084  if (callback != nullptr) {
1085  task = g_task_new(self, cancellable, callback, user_data);
1086 
1087  if (self->engine == nullptr) {
1088  g_task_return_new_error(task, fl_engine_error_quark(),
1089  FL_ENGINE_ERROR_FAILED, "No engine to send to");
1090  return;
1091  }
1092 
1093  FlutterEngineResult result =
1094  self->embedder_api.PlatformMessageCreateResponseHandle(
1095  self->engine, fl_engine_platform_message_response_cb, task,
1096  &response_handle);
1097  if (result != kSuccess) {
1098  g_task_return_new_error(task, fl_engine_error_quark(),
1100  "Failed to create response handle");
1101  g_object_unref(task);
1102  return;
1103  }
1104  } else if (self->engine == nullptr) {
1105  return;
1106  }
1107 
1108  FlutterPlatformMessage fl_message = {};
1109  fl_message.struct_size = sizeof(fl_message);
1110  fl_message.channel = channel;
1111  fl_message.message =
1112  message != nullptr
1113  ? static_cast<const uint8_t*>(g_bytes_get_data(message, nullptr))
1114  : nullptr;
1115  fl_message.message_size = message != nullptr ? g_bytes_get_size(message) : 0;
1116  fl_message.response_handle = response_handle;
1117  FlutterEngineResult result =
1118  self->embedder_api.SendPlatformMessage(self->engine, &fl_message);
1119 
1120  if (result != kSuccess && task != nullptr) {
1121  g_task_return_new_error(task, fl_engine_error_quark(),
1123  "Failed to send platform messages");
1124  g_object_unref(task);
1125  }
1126 
1127  if (response_handle != nullptr) {
1128  if (self->embedder_api.PlatformMessageReleaseResponseHandle(
1129  self->engine, response_handle) != kSuccess) {
1130  g_warning("Failed to release response handle");
1131  }
1132  }
1133 }
static void fl_engine_platform_message_response_cb(const uint8_t *data, size_t data_length, void *user_data)
Definition: fl_engine.cc:552

References FL_ENGINE_ERROR_FAILED, fl_engine_error_quark(), fl_engine_platform_message_response_cb(), message, 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. If error is not NULL, *error must be initialized (typically NULL, but an error from a previous call using GLib error handling is explicitly valid).

Completes request started with fl_engine_send_platform_message().

Returns: message response on success or NULL on error.

Definition at line 1135 of file fl_engine.cc.

1137  {
1138  g_return_val_if_fail(FL_IS_ENGINE(self), FALSE);
1139  g_return_val_if_fail(g_task_is_valid(result, self), FALSE);
1140 
1141  return static_cast<GBytes*>(g_task_propagate_pointer(G_TASK(result), error));
1142 }

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. If error is not NULL, *error must be initialized (typically NULL, but an error from a previous call using GLib error handling is explicitly valid).

Responds to a platform message.

Returns: TRUE on success.

Definition at line 1042 of file fl_engine.cc.

1046  {
1047  g_return_val_if_fail(FL_IS_ENGINE(self), FALSE);
1048  g_return_val_if_fail(handle != nullptr, FALSE);
1049 
1050  if (self->engine == nullptr) {
1052  "No engine to send response to");
1053  return FALSE;
1054  }
1055 
1056  gsize data_length = 0;
1057  const uint8_t* data = nullptr;
1058  if (response != nullptr) {
1059  data =
1060  static_cast<const uint8_t*>(g_bytes_get_data(response, &data_length));
1061  }
1062  FlutterEngineResult result = self->embedder_api.SendPlatformMessageResponse(
1063  self->engine, handle, data, data_length);
1064 
1065  if (result != kSuccess) {
1067  "Failed to send platform message response");
1068  return FALSE;
1069  }
1070 
1071  return TRUE;
1072 }

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

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

◆ fl_engine_send_pointer_pan_zoom_event()

void fl_engine_send_pointer_pan_zoom_event ( FlEngine *  engine,
FlutterViewId  view_id,
size_t  timestamp,
double  x,
double  y,
FlutterPointerPhase  phase,
double  pan_x,
double  pan_y,
double  scale,
double  rotation 
)

fl_engine_send_pointer_pan_zoom_event: @engine: an #FlEngine. @view_id: the view that the event occured on. @timestamp: time when event occurred in microseconds. @x: x location of mouse cursor. @y: y location of mouse cursor. @phase: mouse phase. @pan_x: x offset of the pan/zoom in pixels. @pan_y: y offset of the pan/zoom in pixels. @scale: scale of the pan/zoom. @rotation: rotation of the pan/zoom in radians.

Sends a pan/zoom pointer event to the engine.

Definition at line 1358 of file fl_engine.cc.

1367  {
1368  g_return_if_fail(FL_IS_ENGINE(self));
1369 
1370  if (self->engine == nullptr) {
1371  return;
1372  }
1373 
1374  FlutterPointerEvent fl_event = {};
1375  fl_event.struct_size = sizeof(fl_event);
1376  fl_event.timestamp = timestamp;
1377  fl_event.x = x;
1378  fl_event.y = y;
1379  fl_event.phase = phase;
1380  fl_event.pan_x = pan_x;
1381  fl_event.pan_y = pan_y;
1382  fl_event.scale = scale;
1383  fl_event.rotation = rotation;
1384  fl_event.device = kPointerPanZoomDeviceId;
1385  fl_event.device_kind = kFlutterPointerDeviceKindTrackpad;
1386  fl_event.view_id = view_id;
1387  if (self->embedder_api.SendPointerEvent(self->engine, &fl_event, 1) !=
1388  kSuccess) {
1389  g_warning("Failed to send pointer event");
1390  }
1391 }
static constexpr int32_t kPointerPanZoomDeviceId
Definition: fl_engine.cc:37

References kPointerPanZoomDeviceId, 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 1300 of file fl_engine.cc.

1305  {
1306  g_return_if_fail(FL_IS_ENGINE(self));
1307 
1308  if (self->engine == nullptr) {
1309  return;
1310  }
1311 
1312  FlutterPointerEvent event;
1313  event.timestamp = timestamp;
1314  event.x = x;
1315  event.y = y;
1316  event.device_kind = kFlutterPointerDeviceKindTouch;
1317  event.device = device;
1318  event.buttons = 0;
1319  event.view_id = view_id;
1320  event.phase = FlutterPointerPhase::kAdd;
1321  event.struct_size = sizeof(event);
1322 
1323  if (self->embedder_api.SendPointerEvent(self->engine, &event, 1) !=
1324  kSuccess) {
1325  g_warning("Failed to send pointer event");
1326  }
1327 }

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

1247  {
1248  g_return_if_fail(FL_IS_ENGINE(self));
1249 
1250  if (self->engine == nullptr) {
1251  return;
1252  }
1253 
1254  FlutterPointerEvent event;
1255  event.timestamp = timestamp;
1256  event.x = x;
1257  event.y = y;
1258  event.device_kind = kFlutterPointerDeviceKindTouch;
1259  event.device = device;
1260  event.buttons = FlutterPointerMouseButtons::kFlutterPointerButtonMousePrimary;
1261  event.view_id = view_id;
1262  event.phase = FlutterPointerPhase::kDown;
1263  event.struct_size = sizeof(event);
1264 
1265  if (self->embedder_api.SendPointerEvent(self->engine, &event, 1) !=
1266  kSuccess) {
1267  g_warning("Failed to send pointer event");
1268  }
1269 }

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

1276  {
1277  g_return_if_fail(FL_IS_ENGINE(self));
1278 
1279  if (self->engine == nullptr) {
1280  return;
1281  }
1282 
1283  FlutterPointerEvent event;
1284  event.timestamp = timestamp;
1285  event.x = x;
1286  event.y = y;
1287  event.device_kind = kFlutterPointerDeviceKindTouch;
1288  event.device = device;
1289  event.buttons = FlutterPointerMouseButtons::kFlutterPointerButtonMousePrimary;
1290  event.view_id = view_id;
1291  event.phase = FlutterPointerPhase::kMove;
1292  event.struct_size = sizeof(event);
1293 
1294  if (self->embedder_api.SendPointerEvent(self->engine, &event, 1) !=
1295  kSuccess) {
1296  g_warning("Failed to send pointer event");
1297  }
1298 }

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

1334  {
1335  g_return_if_fail(FL_IS_ENGINE(self));
1336 
1337  if (self->engine == nullptr) {
1338  return;
1339  }
1340 
1341  FlutterPointerEvent event;
1342  event.timestamp = timestamp;
1343  event.x = x;
1344  event.y = y;
1345  event.device_kind = kFlutterPointerDeviceKindTouch;
1346  event.device = device;
1347  event.buttons = 0;
1348  event.view_id = view_id;
1349  event.phase = FlutterPointerPhase::kRemove;
1350  event.struct_size = sizeof(event);
1351 
1352  if (self->embedder_api.SendPointerEvent(self->engine, &event, 1) !=
1353  kSuccess) {
1354  g_warning("Failed to send pointer event");
1355  }
1356 }

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

1218  {
1219  g_return_if_fail(FL_IS_ENGINE(self));
1220 
1221  if (self->engine == nullptr) {
1222  return;
1223  }
1224 
1225  FlutterPointerEvent event;
1226  event.timestamp = timestamp;
1227  event.x = x;
1228  event.y = y;
1229  event.device_kind = kFlutterPointerDeviceKindTouch;
1230  event.device = device;
1231  event.buttons = 0;
1232  event.view_id = view_id;
1233  event.phase = FlutterPointerPhase::kUp;
1234  event.struct_size = sizeof(event);
1235 
1236  if (self->embedder_api.SendPointerEvent(self->engine, &event, 1) !=
1237  kSuccess) {
1238  g_warning("Failed to send pointer event");
1239  }
1240 }

References 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  min_width,
size_t  min_height,
size_t  max_width,
size_t  max_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. @min_width: minimum width of view in pixels. @min_height: minimum height of view in pixels. @max_width: maximum width of view in pixels. @max_height: maximum height of view in pixels. @pixel_ratio: scale factor for view.

Sends a window metrics event to the engine.

Definition at line 1144 of file fl_engine.cc.

1151  {
1152  g_return_if_fail(FL_IS_ENGINE(self));
1153 
1154  if (self->engine == nullptr) {
1155  return;
1156  }
1157 
1158  FlutterWindowMetricsEvent event = {};
1159  event.struct_size = sizeof(FlutterWindowMetricsEvent);
1160  event.width = min_width;
1161  event.height = min_height;
1162  event.pixel_ratio = pixel_ratio;
1163  event.display_id = display_id;
1164  event.view_id = view_id;
1165  event.has_constraints = true;
1166  event.min_width_constraint = min_width;
1167  event.min_height_constraint = min_height;
1168  event.max_width_constraint = max_width;
1169  event.max_height_constraint = max_height;
1170  if (self->embedder_api.SendWindowMetricsEvent(self->engine, &event) !=
1171  kSuccess) {
1172  g_warning("Failed to send window metrics");
1173  }
1174 }

References view_id.

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

919  {
920  set_renderable(self, flutter::kFlutterImplicitViewId, renderable);
921 }

References renderable, and set_renderable().

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

1027  {
1028  g_return_if_fail(FL_IS_ENGINE(self));
1029  g_return_if_fail(handler != nullptr);
1030 
1031  if (self->platform_message_handler_destroy_notify) {
1032  self->platform_message_handler_destroy_notify(
1033  self->platform_message_handler_data);
1034  }
1035 
1036  self->platform_message_handler = handler;
1037  self->platform_message_handler_data = user_data;
1038  self->platform_message_handler_destroy_notify = destroy_notify;
1039 }

References user_data.

Referenced by fl_binary_messenger_new().

◆ fl_engine_set_property()

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

Definition at line 575 of file fl_engine.cc.

578  {
579  FlEngine* self = FL_ENGINE(object);
580  switch (prop_id) {
581  case PROP_BINARY_MESSENGER:
582  g_set_object(&self->binary_messenger,
583  FL_BINARY_MESSENGER(g_value_get_object(value)));
584  break;
585  default:
586  G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
587  break;
588  }
589 }
guint prop_id
guint const GValue GParamSpec * pspec

References prop_id, pspec, 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. If error is not NULL, *error must be initialized (typically NULL, but an error from a previous call using GLib error handling is explicitly valid).

Starts the Flutter engine.

Returns: TRUE on success.

Definition at line 760 of file fl_engine.cc.

760  {
761  g_return_val_if_fail(FL_IS_ENGINE(self), FALSE);
762 
763  FlutterRendererConfig config = {};
764  config.type = self->renderer_type;
765  switch (config.type) {
766  case kSoftware:
767  config.software.struct_size = sizeof(FlutterSoftwareRendererConfig);
768  // No action required, as this is handled in
769  // compositor_present_view_callback.
770  config.software.surface_present_callback =
771  [](void* user_data, const void* allocation, size_t row_bytes,
772  size_t height) { return true; };
773  break;
774  case kOpenGL:
775  config.open_gl.struct_size = sizeof(FlutterOpenGLRendererConfig);
776  config.open_gl.gl_proc_resolver = fl_engine_gl_proc_resolver;
777  config.open_gl.make_current = fl_engine_gl_make_current;
778  config.open_gl.clear_current = fl_engine_gl_clear_current;
779  config.open_gl.fbo_callback = fl_engine_gl_get_fbo;
780  // No action required, as this is handled in
781  // compositor_present_view_callback.
782  config.open_gl.present = [](void* user_data) { return true; };
783  config.open_gl.make_resource_current = fl_engine_gl_make_resource_current;
784  config.open_gl.gl_external_texture_frame_callback =
786  break;
787  case kMetal:
788  case kVulkan:
789  default:
791  "Unsupported renderer type");
792  return FALSE;
793  }
794 
795  FlutterTaskRunnerDescription platform_task_runner = {};
796  platform_task_runner.struct_size = sizeof(FlutterTaskRunnerDescription);
797  platform_task_runner.user_data = self;
798  platform_task_runner.runs_task_on_current_thread_callback =
800  platform_task_runner.post_task_callback = fl_engine_post_task;
801  platform_task_runner.identifier = kPlatformTaskRunnerIdentifier;
802 
803  FlutterCustomTaskRunners custom_task_runners = {};
804  custom_task_runners.struct_size = sizeof(FlutterCustomTaskRunners);
805  custom_task_runners.platform_task_runner = &platform_task_runner;
806 
807  switch (fl_dart_project_get_ui_thread_policy(self->project)) {
809  break;
812  custom_task_runners.ui_task_runner = &platform_task_runner;
813  break;
814  }
815 
816  g_autoptr(GPtrArray) command_line_args =
817  g_ptr_array_new_with_free_func(g_free);
818  g_ptr_array_insert(command_line_args, 0, g_strdup("flutter"));
819  for (const auto& env_switch : flutter::GetSwitchesFromEnvironment()) {
820  g_ptr_array_add(command_line_args, g_strdup(env_switch.c_str()));
821  }
822 
823  gchar** dart_entrypoint_args =
825 
826  FlutterProjectArgs args = {};
827  args.struct_size = sizeof(FlutterProjectArgs);
828  args.assets_path = fl_dart_project_get_assets_path(self->project);
829  args.icu_data_path = fl_dart_project_get_icu_data_path(self->project);
830  args.command_line_argc = command_line_args->len;
831  args.command_line_argv =
832  reinterpret_cast<const char* const*>(command_line_args->pdata);
833  args.platform_message_callback = fl_engine_platform_message_cb;
834  args.update_semantics_callback2 = fl_engine_update_semantics_cb;
835  args.custom_task_runners = &custom_task_runners;
836  args.shutdown_dart_vm_when_done = true;
837  args.on_pre_engine_restart_callback = fl_engine_on_pre_engine_restart_cb;
838  args.dart_entrypoint_argc =
839  dart_entrypoint_args != nullptr ? g_strv_length(dart_entrypoint_args) : 0;
840  args.dart_entrypoint_argv =
841  reinterpret_cast<const char* const*>(dart_entrypoint_args);
842  args.engine_id = reinterpret_cast<int64_t>(self);
843 
844  FlutterCompositor compositor = {};
845  compositor.struct_size = sizeof(FlutterCompositor);
846  compositor.user_data = self;
847  compositor.create_backing_store_callback =
849  compositor.collect_backing_store_callback =
851  compositor.present_view_callback = compositor_present_view_callback;
852  args.compositor = &compositor;
853 
854  if (self->embedder_api.RunsAOTCompiledDartCode()) {
855  FlutterEngineAOTDataSource source = {};
856  source.type = kFlutterEngineAOTDataSourceTypeElfPath;
857  source.elf_path = fl_dart_project_get_aot_library_path(self->project);
858  if (self->embedder_api.CreateAOTData(&source, &self->aot_data) !=
859  kSuccess) {
861  "Failed to create AOT data");
862  return FALSE;
863  }
864  args.aot_data = self->aot_data;
865  }
866 
867  FlutterEngineResult result = self->embedder_api.Initialize(
868  FLUTTER_ENGINE_VERSION, &config, &args, self, &self->engine);
869  if (result != kSuccess) {
871  "Failed to initialize Flutter engine");
872  return FALSE;
873  }
874 
875  result = self->embedder_api.RunInitialized(self->engine);
876  if (result != kSuccess) {
878  "Failed to run Flutter engine");
879  return FALSE;
880  }
881 
882  setup_locales(self);
883 
884  g_autoptr(FlSettings) settings = fl_settings_new();
885  self->settings_handler = fl_settings_handler_new(self);
886  fl_settings_handler_start(self->settings_handler, settings);
887 
888  self->platform_handler = fl_platform_handler_new(self->binary_messenger);
889 
890  setup_keyboard(self);
891 
892  result = self->embedder_api.UpdateSemanticsEnabled(self->engine, TRUE);
893  if (result != kSuccess) {
894  g_warning("Failed to enable accessibility features on Flutter engine");
895  }
896 
897  fl_display_monitor_start(self->display_monitor);
898 
899  return TRUE;
900 }
G_MODULE_EXPORT const gchar * fl_dart_project_get_aot_library_path(FlDartProject *self)
G_MODULE_EXPORT gchar ** fl_dart_project_get_dart_entrypoint_arguments(FlDartProject *self)
G_MODULE_EXPORT const gchar * fl_dart_project_get_icu_data_path(FlDartProject *self)
G_MODULE_EXPORT const gchar * fl_dart_project_get_assets_path(FlDartProject *self)
G_MODULE_EXPORT FlUIThreadPolicy fl_dart_project_get_ui_thread_policy(FlDartProject *project)
@ FL_UI_THREAD_POLICY_RUN_ON_PLATFORM_THREAD
@ FL_UI_THREAD_POLICY_RUN_ON_SEPARATE_THREAD
@ FL_UI_THREAD_POLICY_DEFAULT
void fl_display_monitor_start(FlDisplayMonitor *self)
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:435
static bool fl_engine_runs_task_on_current_thread(void *user_data)
Definition: fl_engine.cc:476
static void fl_engine_on_pre_engine_restart_cb(void *user_data)
Definition: fl_engine.cc:542
static bool compositor_create_backing_store_callback(const FlutterBackingStoreConfig *config, FlutterBackingStore *backing_store_out, void *user_data)
Definition: fl_engine.cc:364
static bool fl_engine_gl_make_current(void *user_data)
Definition: fl_engine.cc:414
static bool compositor_present_view_callback(const FlutterPresentViewInfo *info)
Definition: fl_engine.cc:395
static bool compositor_collect_backing_store_callback(const FlutterBackingStore *backing_store, void *user_data)
Definition: fl_engine.cc:380
static void fl_engine_post_task(FlutterTask task, uint64_t target_time_nanos, void *user_data)
Definition: fl_engine.cc:482
static uint32_t fl_engine_gl_get_fbo(void *user_data)
Definition: fl_engine.cc:424
static void * fl_engine_gl_proc_resolver(void *user_data, const char *name)
Definition: fl_engine.cc:410
static void setup_locales(FlEngine *self)
Definition: fl_engine.cc:233
static void fl_engine_update_semantics_cb(const FlutterSemanticsUpdate2 *update, void *user_data)
Definition: fl_engine.cc:511
static bool fl_engine_gl_make_resource_current(void *user_data)
Definition: fl_engine.cc:429
static void fl_engine_platform_message_cb(const FlutterPlatformMessage *message, void *user_data)
Definition: fl_engine.cc:491
static constexpr size_t kPlatformTaskRunnerIdentifier
Definition: fl_engine.cc:32
static bool fl_engine_gl_clear_current(void *user_data)
Definition: fl_engine.cc:419
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
FlPlatformHandler * fl_platform_handler_new(FlBinaryMessenger *messenger)
FlSettings * fl_settings_new()
Definition: fl_settings.cc:55
void fl_settings_handler_start(FlSettingsHandler *self, FlSettings *settings)
FlSettingsHandler * fl_settings_handler_new(FlEngine *engine)
std::vector< std::string > GetSwitchesFromEnvironment()

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_DEFAULT, FL_UI_THREAD_POLICY_RUN_ON_PLATFORM_THREAD, FL_UI_THREAD_POLICY_RUN_ON_SEPARATE_THREAD, g_autoptr(), flutter::GetSwitchesFromEnvironment(), height, kPlatformTaskRunnerIdentifier, 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 1484 of file fl_engine.cc.

1485  {
1486  g_return_val_if_fail(FL_IS_ENGINE(self), FALSE);
1487  return self->embedder_api.UnregisterExternalTexture(self->engine,
1488  texture_id) == kSuccess;
1489 }

References texture_id.

Referenced by unregister_texture().

◆ fl_engine_update_accessibility_features()

void fl_engine_update_accessibility_features ( FlEngine *  engine,
int32_t  flags 
)

fl_engine_update_accessibility_features: @engine: an #FlEngine. @flags: the features to enable in the accessibility tree.

Tells the Flutter engine to update the flags on the accessibility tree.

Definition at line 1515 of file fl_engine.cc.

1515  {
1516  g_return_if_fail(FL_IS_ENGINE(self));
1517 
1518  if (self->engine == nullptr) {
1519  return;
1520  }
1521 
1522  if (self->embedder_api.UpdateAccessibilityFeatures(
1523  self->engine, static_cast<FlutterAccessibilityFeature>(flags)) !=
1524  kSuccess) {
1525  g_warning("Failed to update accessibility features");
1526  }
1527 }

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

512  {
513  FlEngine* self = FL_ENGINE(user_data);
514 
515  g_signal_emit(self, fl_engine_signals[SIGNAL_UPDATE_SEMANTICS], 0, update);
516 }

References fl_engine_signals, SIGNAL_UPDATE_SEMANTICS, and user_data.

Referenced by fl_engine_start().

◆ free_locale()

static void free_locale ( FlutterLocale *  locale)
static

Definition at line 226 of file fl_engine.cc.

226  {
227  free(const_cast<gchar*>(locale->language_code));
228  free(const_cast<gchar*>(locale->country_code));
229  free(locale);
230 }

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

129  { PROP_0, PROP_BINARY_MESSENGER, PROP_LAST };
@ PROP_LAST
@ PROP_0

References PROP_0, and PROP_LAST.

◆ get_renderable()

static FlRenderable* get_renderable ( FlEngine *  self,
int64_t  view_id 
)
static

Returns the renderable with the given ID, or nullptr if no such view exists. Returns a reference to the renderable.

Definition at line 188 of file fl_engine.cc.

188  {
189  g_autoptr(GMutexLocker) locker = g_mutex_locker_new(&self->renderables_mutex);
190  GWeakRef* ref = static_cast<GWeakRef*>(g_hash_table_lookup(
191  self->renderables_by_view_id, GINT_TO_POINTER(view_id)));
192  if (ref == nullptr) {
193  return nullptr;
194  }
195  return FL_RENDERABLE(g_weak_ref_get(ref));
196 }

References g_autoptr(), and view_id.

Referenced by compositor_present_view_callback(), and fl_engine_get_renderable().

◆ parse_locale()

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

Definition at line 132 of file fl_engine.cc.

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

Referenced by setup_locales().

◆ remove_renderable()

static void remove_renderable ( FlEngine *  self,
int64_t  view_id 
)
static

Remove a renderable that no longer exists.

Definition at line 199 of file fl_engine.cc.

199  {
200  g_autoptr(GMutexLocker) locker = g_mutex_locker_new(&self->renderables_mutex);
201  g_hash_table_remove(self->renderables_by_view_id, GINT_TO_POINTER(view_id));
202 }

References g_autoptr(), and view_id.

Referenced by fl_engine_remove_view().

◆ send_key_event_cb()

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

Definition at line 1393 of file fl_engine.cc.

1393  {
1394  g_autoptr(GTask) task = G_TASK(user_data);
1395  gboolean* return_value = g_new0(gboolean, 1);
1396  *return_value = handled;
1397  g_task_return_pointer(task, return_value, g_free);
1398 }

References g_autoptr(), and user_data.

Referenced by fl_engine_send_key_event().

◆ set_renderable()

static void set_renderable ( FlEngine *  self,
int64_t  view_id,
FlRenderable *  renderable 
)
static

Stores a weak reference to the renderable with the given ID.

Definition at line 176 of file fl_engine.cc.

178  {
179  g_autoptr(GMutexLocker) locker = g_mutex_locker_new(&self->renderables_mutex);
180  GWeakRef* ref = g_new(GWeakRef, 1);
181  g_weak_ref_init(ref, G_OBJECT(renderable));
182  g_hash_table_insert(self->renderables_by_view_id, GINT_TO_POINTER(view_id),
183  ref);
184 }

References g_autoptr(), renderable, and view_id.

Referenced by fl_engine_add_view(), and fl_engine_set_implicit_view().

◆ setup_keyboard()

static void setup_keyboard ( FlEngine *  self)
static

Definition at line 518 of file fl_engine.cc.

518  {
519  g_clear_object(&self->keyboard_manager);
520  self->keyboard_manager = fl_keyboard_manager_new(self);
521 
522  g_clear_object(&self->keyboard_handler);
523  self->keyboard_handler =
524  fl_keyboard_handler_new(self->binary_messenger, self->keyboard_manager);
525 
526  GtkWidget* widget =
527  self->text_input_handler != nullptr
528  ? fl_text_input_handler_get_widget(self->text_input_handler)
529  : nullptr;
530  g_clear_object(&self->text_input_handler);
531  self->text_input_handler = fl_text_input_handler_new(self->binary_messenger);
532  if (widget != nullptr) {
533  fl_text_input_handler_set_widget(self->text_input_handler, widget);
534  }
535 }
FlKeyboardHandler * fl_keyboard_handler_new(FlBinaryMessenger *messenger, FlKeyboardManager *keyboard_manager)
FlTextInputHandler * fl_text_input_handler_new(FlBinaryMessenger *messenger)
void fl_text_input_handler_set_widget(FlTextInputHandler *self, GtkWidget *widget)
GtkWidget * fl_text_input_handler_get_widget(FlTextInputHandler *self)

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

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

233  {
234  const gchar* const* languages = g_get_language_names();
235  g_autoptr(GPtrArray) locales_array = g_ptr_array_new_with_free_func(
236  reinterpret_cast<GDestroyNotify>(free_locale));
237  for (int i = 0; languages[i] != nullptr; i++) {
238  g_autofree gchar* locale_string = g_strstrip(g_strdup(languages[i]));
239 
240  // Ignore empty locales, caused by settings like `LANGUAGE=pt_BR:`
241  if (strcmp(locale_string, "") == 0) {
242  continue;
243  }
244 
245  g_autofree gchar* language = nullptr;
246  g_autofree gchar* territory = nullptr;
247  parse_locale(locale_string, &language, &territory, nullptr, nullptr);
248 
249  // Ignore duplicate locales, caused by settings like `LANGUAGE=C` (returns
250  // two "C") or `LANGUAGE=en:en`
251  gboolean has_locale = FALSE;
252  for (guint j = 0; !has_locale && j < locales_array->len; j++) {
253  FlutterLocale* locale =
254  reinterpret_cast<FlutterLocale*>(g_ptr_array_index(locales_array, j));
255  has_locale = g_strcmp0(locale->language_code, language) == 0 &&
256  g_strcmp0(locale->country_code, territory) == 0;
257  }
258  if (has_locale) {
259  continue;
260  }
261 
262  FlutterLocale* locale =
263  static_cast<FlutterLocale*>(g_malloc0(sizeof(FlutterLocale)));
264  g_ptr_array_add(locales_array, locale);
265  locale->struct_size = sizeof(FlutterLocale);
266  locale->language_code =
267  reinterpret_cast<const gchar*>(g_steal_pointer(&language));
268  locale->country_code =
269  reinterpret_cast<const gchar*>(g_steal_pointer(&territory));
270  locale->script_code = nullptr;
271  locale->variant_code = nullptr;
272  }
273  FlutterLocale** locales =
274  reinterpret_cast<FlutterLocale**>(locales_array->pdata);
275  FlutterEngineResult result = self->embedder_api.UpdateLocales(
276  self->engine, const_cast<const FlutterLocale**>(locales),
277  locales_array->len);
278  if (result != kSuccess) {
279  g_warning("Failed to set up Flutter locales");
280  }
281 }
static void parse_locale(const gchar *locale, gchar **language, gchar **territory, gchar **codeset, gchar **modifier)
Definition: fl_engine.cc:132
static void free_locale(FlutterLocale *locale)
Definition: fl_engine.cc:226

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

Referenced by fl_engine_start().

◆ view_added_cb()

static void view_added_cb ( const FlutterAddViewResult *  result)
static

Definition at line 204 of file fl_engine.cc.

204  {
205  g_autoptr(GTask) task = G_TASK(result->user_data);
206 
207  if (result->added) {
208  g_task_return_boolean(task, TRUE);
209  } else {
210  g_task_return_new_error(task, fl_engine_error_quark(),
211  FL_ENGINE_ERROR_FAILED, "Failed to add view");
212  }
213 }

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

215  {
216  g_autoptr(GTask) task = G_TASK(result->user_data);
217 
218  if (result->removed) {
219  g_task_return_boolean(task, TRUE);
220  } else {
221  g_task_return_new_error(task, fl_engine_error_quark(),
222  FL_ENGINE_ERROR_FAILED, "Failed to remove view");
223  }
224 }

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

◆ kMousePointerDeviceId

constexpr int32_t kMousePointerDeviceId = 0
staticconstexpr

Definition at line 36 of file fl_engine.cc.

Referenced by fl_engine_send_mouse_pointer_event().

◆ kPlatformTaskRunnerIdentifier

constexpr size_t kPlatformTaskRunnerIdentifier = 1
staticconstexpr

Definition at line 32 of file fl_engine.cc.

Referenced by fl_engine_start().

◆ kPointerPanZoomDeviceId

constexpr int32_t kPointerPanZoomDeviceId = 1
staticconstexpr

Definition at line 37 of file fl_engine.cc.

Referenced by fl_engine_send_pointer_pan_zoom_event().