Flutter Linux Embedder
fl_engine_private.h File Reference

Go to the source code of this file.

Typedefs

typedef gboolean(* FlEnginePlatformMessageHandler) (FlEngine *engine, const gchar *channel, GBytes *message, const FlutterPlatformMessageResponseHandle *response_handle, gpointer user_data)
 

Enumerations

enum  FlEngineError { FL_ENGINE_ERROR_FAILED }
 

Functions

GQuark fl_engine_error_quark (void) G_GNUC_CONST
 
FlEngine * fl_engine_new_with_binary_messenger (FlBinaryMessenger *binary_messenger)
 
FlutterRendererType fl_engine_get_renderer_type (FlEngine *engine)
 
FlOpenGLManager * fl_engine_get_opengl_manager (FlEngine *engine)
 
FlDisplayMonitor * fl_engine_get_display_monitor (FlEngine *engine)
 
gboolean fl_engine_start (FlEngine *engine, GError **error)
 
FlutterEngineProcTable * fl_engine_get_embedder_api (FlEngine *engine)
 
void fl_engine_notify_display_update (FlEngine *engine, const FlutterEngineDisplay *displays, size_t displays_length)
 
void fl_engine_set_implicit_view (FlEngine *engine, FlRenderable *renderable)
 
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)
 
gboolean fl_engine_add_view_finish (FlEngine *engine, GAsyncResult *result, GError **error)
 
FlRenderable * fl_engine_get_renderable (FlEngine *engine, FlutterViewId view_id)
 
void fl_engine_remove_view (FlEngine *engine, FlutterViewId view_id, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data)
 
gboolean fl_engine_remove_view_finish (FlEngine *engine, GAsyncResult *result, GError **error)
 
void fl_engine_set_platform_message_handler (FlEngine *engine, FlEnginePlatformMessageHandler handler, gpointer user_data, GDestroyNotify destroy_notify)
 
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)
 
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, double rotation, double pressure)
 
void fl_engine_send_touch_up_event (FlEngine *engine, FlutterViewId view_id, size_t timestamp, double x, double y, int32_t device)
 
void fl_engine_send_touch_down_event (FlEngine *engine, FlutterViewId view_id, size_t timestamp, double x, double y, int32_t device)
 
void fl_engine_send_touch_move_event (FlEngine *engine, FlutterViewId view_id, size_t timestamp, double x, double y, int32_t device)
 
void fl_engine_send_touch_add_event (FlEngine *engine, FlutterViewId view_id, size_t timestamp, double x, double y, int32_t device)
 
void fl_engine_send_touch_remove_event (FlEngine *engine, FlutterViewId view_id, size_t timestamp, double x, double y, int32_t device)
 
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)
 
void fl_engine_send_key_event (FlEngine *engine, const FlutterKeyEvent *event, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data)
 
gboolean fl_engine_send_key_event_finish (FlEngine *engine, GAsyncResult *result, gboolean *handled, GError **error)
 
void fl_engine_dispatch_semantics_action (FlEngine *engine, FlutterViewId view_id, uint64_t node_id, FlutterSemanticsAction action, GBytes *data)
 
gboolean fl_engine_send_platform_message_response (FlEngine *engine, const FlutterPlatformMessageResponseHandle *handle, GBytes *response, GError **error)
 
void fl_engine_send_platform_message (FlEngine *engine, const gchar *channel, GBytes *message, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data)
 
GBytes * fl_engine_send_platform_message_finish (FlEngine *engine, GAsyncResult *result, GError **error)
 
FlTaskRunner * fl_engine_get_task_runner (FlEngine *engine)
 
void fl_engine_execute_task (FlEngine *engine, FlutterTask *task)
 
gboolean fl_engine_mark_texture_frame_available (FlEngine *engine, int64_t texture_id)
 
gboolean fl_engine_register_external_texture (FlEngine *engine, int64_t texture_id)
 
gboolean fl_engine_unregister_external_texture (FlEngine *engine, int64_t texture_id)
 
void fl_engine_update_accessibility_features (FlEngine *engine, int32_t flags)
 
void fl_engine_request_app_exit (FlEngine *engine)
 
FlKeyboardManager * fl_engine_get_keyboard_manager (FlEngine *engine)
 
FlTextInputHandler * fl_engine_get_text_input_handler (FlEngine *engine)
 
FlMouseCursorHandler * fl_engine_get_mouse_cursor_handler (FlEngine *engine)
 
FlEngine * fl_engine_for_id (int64_t handle)
 

Typedef Documentation

◆ FlEnginePlatformMessageHandler

typedef gboolean(* FlEnginePlatformMessageHandler) (FlEngine *engine, const gchar *channel, GBytes *message, const FlutterPlatformMessageResponseHandle *response_handle, gpointer user_data)

FlEnginePlatformMessageHandler: @engine: an #FlEngine. @channel: channel message received on. @message: message content received from Dart. @response_handle: a handle to respond to the message with. @user_data: (closure): data provided when registering this handler.

Function called when platform messages are received.

Returns: TRUE if message has been accepted.

Definition at line 46 of file fl_engine_private.h.

Enumeration Type Documentation

◆ FlEngineError

FlEngineError: Errors for #FlEngine objects to set on failures.

Enumerator
FL_ENGINE_ERROR_FAILED 

Definition at line 28 of file fl_engine_private.h.

28  {
FlEngineError
@ FL_ENGINE_ERROR_FAILED

Function Documentation

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

970  {
971  g_return_val_if_fail(FL_IS_ENGINE(self), -1);
972 
973  g_autoptr(GTask) task = g_task_new(self, cancellable, callback, user_data);
974 
975  FlutterViewId view_id = self->next_view_id;
976  self->next_view_id++;
977 
979 
980  // We don't know which display this view will open on, so set to zero and this
981  // will be updated in a following FlutterWindowMetricsEvent
982  FlutterEngineDisplayId display_id = 0;
983 
984  FlutterWindowMetricsEvent metrics = {};
985  metrics.struct_size = sizeof(FlutterWindowMetricsEvent);
986  metrics.width = min_width;
987  metrics.height = min_height;
988  metrics.pixel_ratio = pixel_ratio;
989  metrics.display_id = display_id;
990  metrics.view_id = view_id;
991  metrics.has_constraints = true;
992  metrics.min_width_constraint = min_width;
993  metrics.min_height_constraint = min_height;
994  metrics.max_width_constraint = max_width;
995  metrics.max_height_constraint = max_height;
996  FlutterAddViewInfo info;
997  info.struct_size = sizeof(FlutterAddViewInfo);
998  info.view_id = view_id;
999  info.view_metrics = &metrics;
1000  info.user_data = g_object_ref(task);
1001  info.add_view_callback = view_added_cb;
1002  FlutterEngineResult result = self->embedder_api.AddView(self->engine, &info);
1003  if (result != kSuccess) {
1004  g_task_return_new_error(task, fl_engine_error_quark(),
1005  FL_ENGINE_ERROR_FAILED, "AddView returned %d",
1006  result);
1007  // This would have been done in the callback, but that won't occur now.
1008  g_object_unref(task);
1009  }
1010 
1011  return view_id;
1012 }
g_autoptr(FlEngine) engine
FlRenderable * renderable
const char FlTextDirection FlAssertiveness gpointer user_data
static void view_added_cb(const FlutterAddViewResult *result)
Definition: fl_engine.cc:203
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:175
GQuark fl_engine_error_quark(void) G_GNUC_CONST
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_F().

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

1016  {
1017  g_return_val_if_fail(FL_IS_ENGINE(self), FALSE);
1018  return g_task_propagate_boolean(G_TASK(result), error);
1019 }
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_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 1491 of file fl_engine.cc.

1495  {
1496  g_return_if_fail(FL_IS_ENGINE(self));
1497 
1498  if (self->engine == nullptr) {
1499  return;
1500  }
1501 
1502  const uint8_t* action_data = nullptr;
1503  size_t action_data_length = 0;
1504  if (data != nullptr) {
1505  action_data = static_cast<const uint8_t*>(
1506  g_bytes_get_data(data, &action_data_length));
1507  }
1508 
1509  FlutterSendSemanticsActionInfo info;
1510  info.struct_size = sizeof(FlutterSendSemanticsActionInfo);
1511  info.view_id = view_id;
1512  info.node_id = node_id;
1513  info.action = action;
1514  info.data = action_data;
1515  info.data_length = action_data_length;
1516  if (self->embedder_api.SendSemanticsAction(self->engine, &info) != kSuccess) {
1517  g_warning("Failed to send semantics action");
1518  }
1519 }

References view_id.

Referenced by fl_accessible_node_perform_action_impl(), and TEST_F().

◆ fl_engine_error_quark()

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

1553  {
1554  g_return_if_fail(FL_IS_ENGINE(self));
1555  if (self->embedder_api.RunTask(self->engine, task) != kSuccess) {
1556  g_warning("Failed to run task");
1557  }
1558 }

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

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

References id.

Referenced by TEST_F().

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

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

Referenced by handle_geometry_changed(), and TEST_F().

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

940  {
941  return &(self->embedder_api);
942 }

Referenced by TEST_F().

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

1585  {
1586  g_return_val_if_fail(FL_IS_ENGINE(self), nullptr);
1587  return self->keyboard_manager;
1588 }

Referenced by handle_key_event(), sync_modifier_if_needed(), and TEST_F().

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

1595  {
1596  g_return_val_if_fail(FL_IS_ENGINE(self), nullptr);
1597  return self->mouse_cursor_handler;
1598 }

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

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

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

Referenced by realize_cb(), and setup_opengl().

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

1021  {
1022  g_return_val_if_fail(FL_IS_ENGINE(self), nullptr);
1023 
1024  return get_renderable(self, view_id);
1025 }
static FlRenderable * get_renderable(FlEngine *self, int64_t view_id)
Definition: fl_engine.cc:187

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

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

Referenced by fl_view_renderer_realize().

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

1548  {
1549  g_return_val_if_fail(FL_IS_ENGINE(self), nullptr);
1550  return self->task_runner;
1551 }

Referenced by setup_opengl(), setup_software(), and TEST_F().

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

1590  {
1591  g_return_val_if_fail(FL_IS_ENGINE(self), nullptr);
1592  return self->text_input_handler;
1593 }

Referenced by fl_view_dispose(), fl_view_focus_in_event(), handle_key_event(), and TEST_F().

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

1522  {
1523  g_return_val_if_fail(FL_IS_ENGINE(self), FALSE);
1524  return self->embedder_api.MarkExternalTextureFrameAvailable(
1525  self->engine, texture_id) == kSuccess;
1526 }
GLuint texture_id

References texture_id.

Referenced by mark_texture_frame_available().

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

735  {
736  g_autoptr(FlDartProject) project = fl_dart_project_new();
737  return fl_engine_new_full(project, binary_messenger);
738 }
G_MODULE_EXPORT FlDartProject * fl_dart_project_new()
static FlEngine * fl_engine_new_full(FlDartProject *project, FlBinaryMessenger *binary_messenger)
Definition: fl_engine.cc:687

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

Referenced by FlAccessibilityHandlerTest::SetUp(), FlKeyboardHandlerTest::SetUp(), and FlSettingsHandlerTest::SetUp().

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

946  {
947  g_return_if_fail(FL_IS_ENGINE(self));
948 
949  FlutterEngineResult result = self->embedder_api.NotifyDisplayUpdate(
950  self->engine, kFlutterEngineDisplaysUpdateTypeStartup, displays,
951  displays_length);
952  if (result != kSuccess) {
953  g_warning("Failed to notify display update to Flutter engine: %d", result);
954  }
955 }

Referenced by notify_display_update(), and TEST_F().

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

1529  {
1530  g_return_val_if_fail(FL_IS_ENGINE(self), FALSE);
1531  return self->embedder_api.RegisterExternalTexture(self->engine, texture_id) ==
1532  kSuccess;
1533 }

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

1031  {
1032  g_return_if_fail(FL_IS_ENGINE(self));
1033 
1034  remove_renderable(self, view_id);
1035 
1036  g_autoptr(GTask) task = g_task_new(self, cancellable, callback, user_data);
1037 
1038  FlutterRemoveViewInfo info;
1039  info.struct_size = sizeof(FlutterRemoveViewInfo);
1040  info.view_id = view_id;
1041  info.user_data = g_object_ref(task);
1042  info.remove_view_callback = view_removed_cb;
1043  FlutterEngineResult result =
1044  self->embedder_api.RemoveView(self->engine, &info);
1045  if (result != kSuccess) {
1046  g_task_return_new_error(task, fl_engine_error_quark(),
1047  FL_ENGINE_ERROR_FAILED, "RemoveView returned %d",
1048  result);
1049  // This would have been done in the callback, but that won't occur now.
1050  g_object_unref(task);
1051  }
1052 }
static void remove_renderable(FlEngine *self, int64_t view_id)
Remove a renderable that no longer exists.
Definition: fl_engine.cc:198
static void view_removed_cb(const FlutterRemoveViewResult *result)
Definition: fl_engine.cc:214

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

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

1056  {
1057  g_return_val_if_fail(FL_IS_ENGINE(self), FALSE);
1058  return g_task_propagate_boolean(G_TASK(result), error);
1059 }

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

1580  {
1581  g_return_if_fail(FL_IS_ENGINE(self));
1582  fl_platform_handler_request_app_exit(self->platform_handler);
1583 }
void fl_platform_handler_request_app_exit(FlPlatformHandler *self)

References fl_platform_handler_request_app_exit().

Referenced by window_delete_event_cb().

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

1455  {
1456  g_return_if_fail(FL_IS_ENGINE(self));
1457 
1458  g_autoptr(GTask) task = g_task_new(self, cancellable, callback, user_data);
1459 
1460  if (self->engine == nullptr) {
1461  g_task_return_new_error(task, fl_engine_error_quark(),
1462  FL_ENGINE_ERROR_FAILED, "No engine");
1463  return;
1464  }
1465 
1466  if (self->embedder_api.SendKeyEvent(self->engine, event, send_key_event_cb,
1467  g_object_ref(task)) != kSuccess) {
1468  g_task_return_new_error(task, fl_engine_error_quark(),
1469  FL_ENGINE_ERROR_FAILED, "Failed to send key event");
1470  g_object_unref(task);
1471  }
1472 }
static void send_key_event_cb(bool handled, void *user_data)
Definition: fl_engine.cc:1444

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

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

1477  {
1478  g_return_val_if_fail(FL_IS_ENGINE(self), FALSE);
1479  g_return_val_if_fail(g_task_is_valid(result, self), FALSE);
1480 
1481  g_autofree gboolean* return_value =
1482  static_cast<gboolean*>(g_task_propagate_pointer(G_TASK(result), error));
1483  if (return_value == nullptr) {
1484  return FALSE;
1485  }
1486 
1487  *handled = *return_value;
1488  return TRUE;
1489 }
return TRUE

References error, and TRUE.

Referenced by TEST_F().

◆ 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,
double  rotation,
double  pressure 
)

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. @rotation: rotation of the pointer device in degrees. @pressure: pressure of the pointer device.

Sends a mouse pointer event to the engine.

Definition at line 1215 of file fl_engine.cc.

1226  {
1227  g_return_if_fail(FL_IS_ENGINE(self));
1228 
1229  if (self->engine == nullptr) {
1230  return;
1231  }
1232 
1233  FlutterPointerEvent fl_event = {};
1234  fl_event.struct_size = sizeof(fl_event);
1235  fl_event.phase = phase;
1236  fl_event.timestamp = timestamp;
1237  fl_event.x = x;
1238  fl_event.y = y;
1239  if (scroll_delta_x != 0 || scroll_delta_y != 0) {
1240  fl_event.signal_kind = kFlutterPointerSignalKindScroll;
1241  }
1242  fl_event.scroll_delta_x = scroll_delta_x;
1243  fl_event.scroll_delta_y = scroll_delta_y;
1244  fl_event.device_kind = device_kind;
1245  fl_event.buttons = buttons;
1246  fl_event.device = kMousePointerDeviceId;
1247  fl_event.view_id = view_id;
1248  // GDK reports tablet pressure through GDK_AXIS_PRESSURE. The GDK input device
1249  // documentation defines pressure as normalized from 0.0 to 1.0, which matches
1250  // Flutter's expected pressure range.
1251  // See: https://refspecs.linuxbase.org/gtk/2.6/gdk/gdk-Input-Devices.html
1252  fl_event.pressure = pressure;
1253  fl_event.pressure_min = 0.0;
1254  fl_event.pressure_max = 1.0;
1255  // GTK reports rotation in degrees, so convert it to radians for
1256  // FlutterPointerEvent.rotation.
1257  fl_event.rotation = rotation * G_PI / 180.0;
1258  if (self->embedder_api.SendPointerEvent(self->engine, &fl_event, 1) !=
1259  kSuccess) {
1260  g_warning("Failed to send pointer event");
1261  }
1262 }
FlFramebuffer double x
FlFramebuffer double double y
static constexpr int32_t kMousePointerDeviceId
Definition: fl_engine.cc:35

References kMousePointerDeviceId, view_id, x, and y.

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

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

1117  {
1118  g_return_if_fail(FL_IS_ENGINE(self));
1119 
1120  GTask* task = nullptr;
1121  FlutterPlatformMessageResponseHandle* response_handle = nullptr;
1122  if (callback != nullptr) {
1123  task = g_task_new(self, cancellable, callback, user_data);
1124 
1125  if (self->engine == nullptr) {
1126  g_task_return_new_error(task, fl_engine_error_quark(),
1127  FL_ENGINE_ERROR_FAILED, "No engine to send to");
1128  g_object_unref(task);
1129  return;
1130  }
1131 
1132  FlutterEngineResult result =
1133  self->embedder_api.PlatformMessageCreateResponseHandle(
1134  self->engine, fl_engine_platform_message_response_cb, task,
1135  &response_handle);
1136  if (result != kSuccess) {
1137  g_task_return_new_error(task, fl_engine_error_quark(),
1139  "Failed to create response handle");
1140  g_object_unref(task);
1141  return;
1142  }
1143  } else if (self->engine == nullptr) {
1144  return;
1145  }
1146 
1147  FlutterPlatformMessage fl_message = {};
1148  fl_message.struct_size = sizeof(fl_message);
1149  fl_message.channel = channel;
1150  fl_message.message =
1151  message != nullptr
1152  ? static_cast<const uint8_t*>(g_bytes_get_data(message, nullptr))
1153  : nullptr;
1154  fl_message.message_size = message != nullptr ? g_bytes_get_size(message) : 0;
1155  fl_message.response_handle = response_handle;
1156  FlutterEngineResult result =
1157  self->embedder_api.SendPlatformMessage(self->engine, &fl_message);
1158 
1159  if (result != kSuccess && task != nullptr) {
1160  g_task_return_new_error(task, fl_engine_error_quark(),
1162  "Failed to send platform messages");
1163  g_object_unref(task);
1164  }
1165 
1166  if (response_handle != nullptr) {
1167  if (self->embedder_api.PlatformMessageReleaseResponseHandle(
1168  self->engine, response_handle) != kSuccess) {
1169  g_warning("Failed to release response handle");
1170  }
1171  }
1172 }
const char * message
static void fl_engine_platform_message_response_cb(const uint8_t *data, size_t data_length, void *user_data)
Definition: fl_engine.cc:551

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

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

1176  {
1177  g_return_val_if_fail(FL_IS_ENGINE(self), FALSE);
1178  g_return_val_if_fail(g_task_is_valid(result, self), FALSE);
1179 
1180  return static_cast<GBytes*>(g_task_propagate_pointer(G_TASK(result), error));
1181 }

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

1084  {
1085  g_return_val_if_fail(FL_IS_ENGINE(self), FALSE);
1086  g_return_val_if_fail(handle != nullptr, FALSE);
1087 
1088  if (self->engine == nullptr) {
1090  "No engine to send response to");
1091  return FALSE;
1092  }
1093 
1094  gsize data_length = 0;
1095  const uint8_t* data = nullptr;
1096  if (response != nullptr) {
1097  data =
1098  static_cast<const uint8_t*>(g_bytes_get_data(response, &data_length));
1099  }
1100  FlutterEngineResult result = self->embedder_api.SendPlatformMessageResponse(
1101  self->engine, handle, data, data_length);
1102 
1103  if (result != kSuccess) {
1105  "Failed to send platform message response");
1106  return FALSE;
1107  }
1108 
1109  return TRUE;
1110 }

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

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

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

1418  {
1419  g_return_if_fail(FL_IS_ENGINE(self));
1420 
1421  if (self->engine == nullptr) {
1422  return;
1423  }
1424 
1425  FlutterPointerEvent fl_event = {};
1426  fl_event.struct_size = sizeof(fl_event);
1427  fl_event.timestamp = timestamp;
1428  fl_event.x = x;
1429  fl_event.y = y;
1430  fl_event.phase = phase;
1431  fl_event.pan_x = pan_x;
1432  fl_event.pan_y = pan_y;
1433  fl_event.scale = scale;
1434  fl_event.rotation = rotation;
1435  fl_event.device = kPointerPanZoomDeviceId;
1436  fl_event.device_kind = kFlutterPointerDeviceKindTrackpad;
1437  fl_event.view_id = view_id;
1438  if (self->embedder_api.SendPointerEvent(self->engine, &fl_event, 1) !=
1439  kSuccess) {
1440  g_warning("Failed to send pointer event");
1441  }
1442 }
static constexpr int32_t kPointerPanZoomDeviceId
Definition: fl_engine.cc:36

References kPointerPanZoomDeviceId, view_id, x, and y.

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

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

1356  {
1357  g_return_if_fail(FL_IS_ENGINE(self));
1358 
1359  if (self->engine == nullptr) {
1360  return;
1361  }
1362 
1363  FlutterPointerEvent event;
1364  event.timestamp = timestamp;
1365  event.x = x;
1366  event.y = y;
1367  event.device_kind = kFlutterPointerDeviceKindTouch;
1368  event.device = device;
1369  event.buttons = 0;
1370  event.view_id = view_id;
1371  event.phase = FlutterPointerPhase::kAdd;
1372  event.struct_size = sizeof(event);
1373 
1374  if (self->embedder_api.SendPointerEvent(self->engine, &event, 1) !=
1375  kSuccess) {
1376  g_warning("Failed to send pointer event");
1377  }
1378 }

References view_id, x, and y.

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

1298  {
1299  g_return_if_fail(FL_IS_ENGINE(self));
1300 
1301  if (self->engine == nullptr) {
1302  return;
1303  }
1304 
1305  FlutterPointerEvent event;
1306  event.timestamp = timestamp;
1307  event.x = x;
1308  event.y = y;
1309  event.device_kind = kFlutterPointerDeviceKindTouch;
1310  event.device = device;
1311  event.buttons = FlutterPointerMouseButtons::kFlutterPointerButtonMousePrimary;
1312  event.view_id = view_id;
1313  event.phase = FlutterPointerPhase::kDown;
1314  event.struct_size = sizeof(event);
1315 
1316  if (self->embedder_api.SendPointerEvent(self->engine, &event, 1) !=
1317  kSuccess) {
1318  g_warning("Failed to send pointer event");
1319  }
1320 }

References view_id, x, and y.

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

1327  {
1328  g_return_if_fail(FL_IS_ENGINE(self));
1329 
1330  if (self->engine == nullptr) {
1331  return;
1332  }
1333 
1334  FlutterPointerEvent event;
1335  event.timestamp = timestamp;
1336  event.x = x;
1337  event.y = y;
1338  event.device_kind = kFlutterPointerDeviceKindTouch;
1339  event.device = device;
1340  event.buttons = FlutterPointerMouseButtons::kFlutterPointerButtonMousePrimary;
1341  event.view_id = view_id;
1342  event.phase = FlutterPointerPhase::kMove;
1343  event.struct_size = sizeof(event);
1344 
1345  if (self->embedder_api.SendPointerEvent(self->engine, &event, 1) !=
1346  kSuccess) {
1347  g_warning("Failed to send pointer event");
1348  }
1349 }

References view_id, x, and y.

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

1385  {
1386  g_return_if_fail(FL_IS_ENGINE(self));
1387 
1388  if (self->engine == nullptr) {
1389  return;
1390  }
1391 
1392  FlutterPointerEvent event;
1393  event.timestamp = timestamp;
1394  event.x = x;
1395  event.y = y;
1396  event.device_kind = kFlutterPointerDeviceKindTouch;
1397  event.device = device;
1398  event.buttons = 0;
1399  event.view_id = view_id;
1400  event.phase = FlutterPointerPhase::kRemove;
1401  event.struct_size = sizeof(event);
1402 
1403  if (self->embedder_api.SendPointerEvent(self->engine, &event, 1) !=
1404  kSuccess) {
1405  g_warning("Failed to send pointer event");
1406  }
1407 }

References view_id, x, and y.

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

1269  {
1270  g_return_if_fail(FL_IS_ENGINE(self));
1271 
1272  if (self->engine == nullptr) {
1273  return;
1274  }
1275 
1276  FlutterPointerEvent event;
1277  event.timestamp = timestamp;
1278  event.x = x;
1279  event.y = y;
1280  event.device_kind = kFlutterPointerDeviceKindTouch;
1281  event.device = device;
1282  event.buttons = 0;
1283  event.view_id = view_id;
1284  event.phase = FlutterPointerPhase::kUp;
1285  event.struct_size = sizeof(event);
1286 
1287  if (self->embedder_api.SendPointerEvent(self->engine, &event, 1) !=
1288  kSuccess) {
1289  g_warning("Failed to send pointer event");
1290  }
1291 }

References view_id, x, and y.

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

1190  {
1191  g_return_if_fail(FL_IS_ENGINE(self));
1192 
1193  if (self->engine == nullptr) {
1194  return;
1195  }
1196 
1197  FlutterWindowMetricsEvent event = {};
1198  event.struct_size = sizeof(FlutterWindowMetricsEvent);
1199  event.width = min_width;
1200  event.height = min_height;
1201  event.pixel_ratio = pixel_ratio;
1202  event.display_id = display_id;
1203  event.view_id = view_id;
1204  event.has_constraints = true;
1205  event.min_width_constraint = min_width;
1206  event.min_height_constraint = min_height;
1207  event.max_width_constraint = max_width;
1208  event.max_height_constraint = max_height;
1209  if (self->embedder_api.SendWindowMetricsEvent(self->engine, &event) !=
1210  kSuccess) {
1211  g_warning("Failed to send window metrics");
1212  }
1213 }

References view_id.

Referenced by handle_geometry_changed(), and TEST_F().

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

957  {
958  set_renderable(self, flutter::kFlutterImplicitViewId, renderable);
959 }

References renderable, and set_renderable().

Referenced by fl_view_new(), and FlCompositorOpenGLTest::SetUp().

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

1065  {
1066  g_return_if_fail(FL_IS_ENGINE(self));
1067  g_return_if_fail(handler != nullptr);
1068 
1069  if (self->platform_message_handler_destroy_notify) {
1070  self->platform_message_handler_destroy_notify(
1071  self->platform_message_handler_data);
1072  }
1073 
1074  self->platform_message_handler = handler;
1075  self->platform_message_handler_data = user_data;
1076  self->platform_message_handler_destroy_notify = destroy_notify;
1077 }

References user_data.

Referenced by fl_binary_messenger_new().

◆ fl_engine_start()

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

fl_engine_start: @engine: an #FlEngine. @error: (allow-none): #GError location to store the error occurring, or NULL to ignore. 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 759 of file fl_engine.cc.

759  {
760  g_return_val_if_fail(FL_IS_ENGINE(self), FALSE);
761 
762  FlutterRendererConfig config = {};
763  config.type = self->renderer_type;
764  switch (config.type) {
765  case kSoftware:
766  config.software.struct_size = sizeof(FlutterSoftwareRendererConfig);
767  // No action required, as this is handled in
768  // compositor_present_view_callback.
769  config.software.surface_present_callback =
770  [](void* user_data, const void* allocation, size_t row_bytes,
771  size_t height) { return true; };
772  break;
773  case kOpenGL:
774  config.open_gl.struct_size = sizeof(FlutterOpenGLRendererConfig);
775  config.open_gl.gl_proc_resolver = fl_engine_gl_proc_resolver;
776  config.open_gl.make_current = fl_engine_gl_make_current;
777  config.open_gl.clear_current = fl_engine_gl_clear_current;
778  config.open_gl.fbo_callback = fl_engine_gl_get_fbo;
779  // No action required, as this is handled in
780  // compositor_present_view_callback.
781  config.open_gl.present = [](void* user_data) { return true; };
782  config.open_gl.make_resource_current = fl_engine_gl_make_resource_current;
783  config.open_gl.gl_external_texture_frame_callback =
785  break;
786  case kMetal:
787  case kVulkan:
788  default:
790  "Unsupported renderer type");
791  return FALSE;
792  }
793 
794  FlutterTaskRunnerDescription platform_task_runner = {};
795  platform_task_runner.struct_size = sizeof(FlutterTaskRunnerDescription);
796  platform_task_runner.user_data = self;
797  platform_task_runner.runs_task_on_current_thread_callback =
799  platform_task_runner.post_task_callback = fl_engine_post_task;
800  platform_task_runner.identifier = kPlatformTaskRunnerIdentifier;
801 
802  FlutterCustomTaskRunners custom_task_runners = {};
803  custom_task_runners.struct_size = sizeof(FlutterCustomTaskRunners);
804  custom_task_runners.platform_task_runner = &platform_task_runner;
805 
806  switch (fl_dart_project_get_ui_thread_policy(self->project)) {
808  break;
811  custom_task_runners.ui_task_runner = &platform_task_runner;
812  break;
813  }
814 
815  const std::vector<std::string> env_switches =
817 
818  gboolean enable_impeller = fl_dart_project_get_enable_impeller(self->project);
819  gboolean has_enable_impeller = FALSE;
820  for (const auto& env_switch : env_switches) {
821  if (env_switch == "--enable-impeller" ||
822  env_switch == "--enable-impeller=true") {
823  enable_impeller = TRUE;
824  has_enable_impeller = TRUE;
825  } else if (env_switch == "--enable-impeller=false") {
826  enable_impeller = FALSE;
827  has_enable_impeller = TRUE;
828  }
829  }
830 
831  g_autoptr(GPtrArray) command_line_args =
832  g_ptr_array_new_with_free_func(g_free);
833  g_ptr_array_insert(command_line_args, 0, g_strdup("flutter"));
834  for (const auto& env_switch : env_switches) {
835  g_ptr_array_add(command_line_args, g_strdup(env_switch.c_str()));
836  }
837  // Linux (and other desktop platforms) always uses SDFs.
838  g_ptr_array_add(command_line_args, g_strdup("--impeller-use-sdfs"));
839 
840  if (enable_impeller && !has_enable_impeller) {
841  g_ptr_array_add(command_line_args, g_strdup("--enable-impeller"));
842  }
843 
844  // Forward the project's Flutter GPU setting unless an environment switch
845  // already carries it (the switch is presence based, so it is only ever
846  // added, never negated).
847  if (fl_dart_project_get_enable_flutter_gpu(self->project)) {
848  gboolean has_enable_flutter_gpu = FALSE;
849  for (const auto& env_switch : env_switches) {
850  if (env_switch == "--enable-flutter-gpu" ||
851  env_switch == "--enable-flutter-gpu=true") {
852  has_enable_flutter_gpu = TRUE;
853  break;
854  }
855  }
856  if (!has_enable_flutter_gpu) {
857  g_ptr_array_add(command_line_args, g_strdup("--enable-flutter-gpu"));
858  }
859  }
860 
861  gchar** dart_entrypoint_args =
863 
864  FlutterProjectArgs args = {};
865  args.struct_size = sizeof(FlutterProjectArgs);
866  args.assets_path = fl_dart_project_get_assets_path(self->project);
867  args.icu_data_path = fl_dart_project_get_icu_data_path(self->project);
868  args.command_line_argc = command_line_args->len;
869  args.command_line_argv =
870  reinterpret_cast<const char* const*>(command_line_args->pdata);
871  args.platform_message_callback = fl_engine_platform_message_cb;
872  args.update_semantics_callback2 = fl_engine_update_semantics_cb;
873  args.custom_task_runners = &custom_task_runners;
874  args.shutdown_dart_vm_when_done = true;
875  args.on_pre_engine_restart_callback = fl_engine_on_pre_engine_restart_cb;
876  args.dart_entrypoint_argc =
877  dart_entrypoint_args != nullptr ? g_strv_length(dart_entrypoint_args) : 0;
878  args.dart_entrypoint_argv =
879  reinterpret_cast<const char* const*>(dart_entrypoint_args);
880  args.engine_id = reinterpret_cast<int64_t>(self);
881 
882  FlutterCompositor compositor = {};
883  compositor.struct_size = sizeof(FlutterCompositor);
884  compositor.user_data = self;
885  compositor.create_backing_store_callback =
887  compositor.collect_backing_store_callback =
889  compositor.present_view_callback = compositor_present_view_callback;
890  args.compositor = &compositor;
891 
892  if (self->embedder_api.RunsAOTCompiledDartCode()) {
893  FlutterEngineAOTDataSource source = {};
894  source.type = kFlutterEngineAOTDataSourceTypeElfPath;
895  source.elf_path = fl_dart_project_get_aot_library_path(self->project);
896  if (self->embedder_api.CreateAOTData(&source, &self->aot_data) !=
897  kSuccess) {
899  "Failed to create AOT data");
900  return FALSE;
901  }
902  args.aot_data = self->aot_data;
903  }
904 
905  FlutterEngineResult result = self->embedder_api.Initialize(
906  FLUTTER_ENGINE_VERSION, &config, &args, self, &self->engine);
907  if (result != kSuccess) {
909  "Failed to initialize Flutter engine");
910  return FALSE;
911  }
912 
913  result = self->embedder_api.RunInitialized(self->engine);
914  if (result != kSuccess) {
916  "Failed to run Flutter engine");
917  return FALSE;
918  }
919 
920  setup_locales(self);
921 
922  g_autoptr(FlSettings) settings = fl_settings_new();
923  self->settings_handler = fl_settings_handler_new(self);
924  fl_settings_handler_start(self->settings_handler, settings);
925 
926  self->platform_handler = fl_platform_handler_new(self->binary_messenger);
927 
928  setup_keyboard(self);
929 
930  result = self->embedder_api.UpdateSemanticsEnabled(self->engine, TRUE);
931  if (result != kSuccess) {
932  g_warning("Failed to enable accessibility features on Flutter engine");
933  }
934 
935  fl_display_monitor_start(self->display_monitor);
936 
937  return TRUE;
938 }
FlFramebuffer double double int int height
G_MODULE_EXPORT const gchar * fl_dart_project_get_aot_library_path(FlDartProject *self)
G_MODULE_EXPORT gboolean fl_dart_project_get_enable_impeller(FlDartProject *project)
G_MODULE_EXPORT gchar ** fl_dart_project_get_dart_entrypoint_arguments(FlDartProject *self)
G_MODULE_EXPORT gboolean fl_dart_project_get_enable_flutter_gpu(FlDartProject *project)
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:434
static bool fl_engine_runs_task_on_current_thread(void *user_data)
Definition: fl_engine.cc:475
static void fl_engine_on_pre_engine_restart_cb(void *user_data)
Definition: fl_engine.cc:541
static bool compositor_create_backing_store_callback(const FlutterBackingStoreConfig *config, FlutterBackingStore *backing_store_out, void *user_data)
Definition: fl_engine.cc:363
static bool fl_engine_gl_make_current(void *user_data)
Definition: fl_engine.cc:413
static bool compositor_present_view_callback(const FlutterPresentViewInfo *info)
Definition: fl_engine.cc:394
static bool compositor_collect_backing_store_callback(const FlutterBackingStore *backing_store, void *user_data)
Definition: fl_engine.cc:379
static void fl_engine_post_task(FlutterTask task, uint64_t target_time_nanos, void *user_data)
Definition: fl_engine.cc:481
static uint32_t fl_engine_gl_get_fbo(void *user_data)
Definition: fl_engine.cc:423
static void * fl_engine_gl_proc_resolver(void *user_data, const char *name)
Definition: fl_engine.cc:409
static void setup_keyboard(FlEngine *self)
Definition: fl_engine.cc:517
static void setup_locales(FlEngine *self)
Definition: fl_engine.cc:232
static void fl_engine_update_semantics_cb(const FlutterSemanticsUpdate2 *update, void *user_data)
Definition: fl_engine.cc:510
static bool fl_engine_gl_make_resource_current(void *user_data)
Definition: fl_engine.cc:428
static void fl_engine_platform_message_cb(const FlutterPlatformMessage *message, void *user_data)
Definition: fl_engine.cc:490
static constexpr size_t kPlatformTaskRunnerIdentifier
Definition: fl_engine.cc:31
static bool fl_engine_gl_clear_current(void *user_data)
Definition: fl_engine.cc:418
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_enable_flutter_gpu(), fl_dart_project_get_enable_impeller(), 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_F().

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

1536  {
1537  g_return_val_if_fail(FL_IS_ENGINE(self), FALSE);
1538  return self->embedder_api.UnregisterExternalTexture(self->engine,
1539  texture_id) == kSuccess;
1540 }

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

1566  {
1567  g_return_if_fail(FL_IS_ENGINE(self));
1568 
1569  if (self->engine == nullptr) {
1570  return;
1571  }
1572 
1573  if (self->embedder_api.UpdateAccessibilityFeatures(
1574  self->engine, static_cast<FlutterAccessibilityFeature>(flags)) !=
1575  kSuccess) {
1576  g_warning("Failed to update accessibility features");
1577  }
1578 }

Referenced by update_settings().