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)
 
FlCompositor * fl_engine_get_compositor (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 width, size_t 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 width, size_t 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)
 
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)
 
FlWindowingHandler * fl_engine_get_windowing_handler (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 48 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 30 of file fl_engine_private.h.

30  {
FlEngineError
@ FL_ENGINE_ERROR_FAILED

Function Documentation

◆ fl_engine_add_view()

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

fl_engine_add_view: @engine: an #FlEngine. @renderable: the object that will render this view. @width: width of view in pixels. @height: height of view in pixels. @pixel_ratio: scale factor for view. @cancellable: (allow-none): a #GCancellable or NULL. @callback: (scope async): a #GAsyncReadyCallback to call when the view is added. @user_data: (closure): user data to pass to @callback.

Asynchronously add a new view. The returned view ID should not be used until this function completes.

Returns: the ID for the view.

Definition at line 750 of file fl_engine.cc.

757  {
758  g_return_val_if_fail(FL_IS_ENGINE(self), -1);
759 
760  g_autoptr(GTask) task = g_task_new(self, cancellable, callback, user_data);
761 
762  FlutterViewId view_id = self->next_view_id;
763  self->next_view_id++;
764 
765  GWeakRef* ref = g_new(GWeakRef, 1);
766  g_weak_ref_init(ref, G_OBJECT(renderable));
767  g_hash_table_insert(self->renderables_by_view_id, GINT_TO_POINTER(view_id),
768  ref);
769 
770  // We don't know which display this view will open on, so set to zero and this
771  // will be updated in a following FlutterWindowMetricsEvent
772  FlutterEngineDisplayId display_id = 0;
773 
774  FlutterWindowMetricsEvent metrics;
775  metrics.struct_size = sizeof(FlutterWindowMetricsEvent);
776  metrics.width = width;
777  metrics.height = height;
778  metrics.pixel_ratio = pixel_ratio;
779  metrics.display_id = display_id;
780  metrics.view_id = view_id;
781  FlutterAddViewInfo info;
782  info.struct_size = sizeof(FlutterAddViewInfo);
783  info.view_id = view_id;
784  info.view_metrics = &metrics;
785  info.user_data = g_object_ref(task);
786  info.add_view_callback = view_added_cb;
787  FlutterEngineResult result = self->embedder_api.AddView(self->engine, &info);
788  if (result != kSuccess) {
789  g_task_return_new_error(task, fl_engine_error_quark(),
790  FL_ENGINE_ERROR_FAILED, "AddView returned %d",
791  result);
792  // This would have been done in the callback, but that won't occur now.
793  g_object_unref(task);
794  }
795 
796  return view_id;
797 }
static void view_added_cb(const FlutterAddViewResult *result)
Definition: fl_engine.cc:171
GQuark fl_engine_error_quark(void) G_GNUC_CONST
G_BEGIN_DECLS G_MODULE_EXPORT FlValue gpointer user_data
const uint8_t uint32_t uint32_t * height
const uint8_t uint32_t * width
G_BEGIN_DECLS FlutterViewId view_id

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

Referenced by fl_view_new_for_engine(), and TEST().

◆ fl_engine_add_view_finish()

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

fl_engine_add_view_finish: @engine: an #FlEngine.

Returns
: a #GAsyncResult. @error: (allow-none): #GError location to store the error occurring, or NULL to ignore.

Completes request started with fl_engine_add_view().

Returns: TRUE on success.

Definition at line 799 of file fl_engine.cc.

801  {
802  g_return_val_if_fail(FL_IS_ENGINE(self), FALSE);
803  return g_task_propagate_boolean(G_TASK(result), error);
804 }
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 1232 of file fl_engine.cc.

1236  {
1237  g_return_if_fail(FL_IS_ENGINE(self));
1238 
1239  if (self->engine == nullptr) {
1240  return;
1241  }
1242 
1243  const uint8_t* action_data = nullptr;
1244  size_t action_data_length = 0;
1245  if (data != nullptr) {
1246  action_data = static_cast<const uint8_t*>(
1247  g_bytes_get_data(data, &action_data_length));
1248  }
1249 
1250  FlutterSendSemanticsActionInfo info;
1251  info.struct_size = sizeof(FlutterSendSemanticsActionInfo);
1252  info.view_id = view_id;
1253  info.node_id = node_id;
1254  info.action = action;
1255  info.data = action_data;
1256  info.data_length = action_data_length;
1257  self->embedder_api.SendSemanticsAction(self->engine, &info);
1258 }

References view_id.

Referenced by fl_accessible_node_perform_action_impl(), and TEST().

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

1292  {
1293  g_return_if_fail(FL_IS_ENGINE(self));
1294  self->embedder_api.RunTask(self->engine, task);
1295 }

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

578  {
579  void* engine = reinterpret_cast<void*>(id);
580  g_return_val_if_fail(FL_IS_ENGINE(engine), nullptr);
581  return FL_ENGINE(engine);
582 }
int64_t id

References id.

Referenced by TEST().

◆ fl_engine_get_compositor()

FlCompositor* fl_engine_get_compositor ( FlEngine *  engine)

fl_engine_get_compositor: @engine: an #FlEngine.

Gets the compositor used by this engine.

Returns: an #FlCompositor.

Definition at line 598 of file fl_engine.cc.

598  {
599  g_return_val_if_fail(FL_IS_ENGINE(self), nullptr);
600  return self->compositor;
601 }

Referenced by handle_geometry_changed(), realize_cb(), render_cb(), TEST(), and unrealize_cb().

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

608  {
609  g_return_val_if_fail(FL_IS_ENGINE(self), nullptr);
610  return self->display_monitor;
611 }

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

726  {
727  return &(self->embedder_api);
728 }

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

1324  {
1325  g_return_val_if_fail(FL_IS_ENGINE(self), nullptr);
1326  return self->keyboard_manager;
1327 }

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

1334  {
1335  g_return_val_if_fail(FL_IS_ENGINE(self), nullptr);
1336  return self->mouse_cursor_handler;
1337 }

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

603  {
604  g_return_val_if_fail(FL_IS_ENGINE(self), nullptr);
605  return self->opengl_manager;
606 }

Referenced by create_context_cb(), fl_compositor_opengl_new(), realize_cb(), and unrealize_cb().

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

806  {
807  g_return_val_if_fail(FL_IS_ENGINE(self), nullptr);
808 
809  GWeakRef* ref = static_cast<GWeakRef*>(g_hash_table_lookup(
810  self->renderables_by_view_id, GINT_TO_POINTER(view_id)));
811  return FL_RENDERABLE(g_weak_ref_get(ref));
812 }

References view_id.

Referenced by present_layers().

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

1287  {
1288  g_return_val_if_fail(FL_IS_ENGINE(self), nullptr);
1289  return self->task_runner;
1290 }

Referenced by fl_compositor_opengl_present_layers(), fl_compositor_opengl_unblock_main_thread(), fl_compositor_opengl_wait_for_frame(), 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 1329 of file fl_engine.cc.

1329  {
1330  g_return_val_if_fail(FL_IS_ENGINE(self), nullptr);
1331  return self->text_input_handler;
1332 }

Referenced by fl_view_focus_in_event(), and handle_key_event().

◆ fl_engine_get_windowing_handler()

FlWindowingHandler* fl_engine_get_windowing_handler ( FlEngine *  engine)

fl_engine_get_windowing_handler: @engine: an #FlEngine.

Gets the windowing handler used by this engine.

Returns: an #FlWindowingHandler.

Definition at line 1319 of file fl_engine.cc.

1319  {
1320  g_return_val_if_fail(FL_IS_ENGINE(self), nullptr);
1321  return self->windowing_handler;
1322 }

Referenced by fl_application_activate(), and TEST().

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

1261  {
1262  g_return_val_if_fail(FL_IS_ENGINE(self), FALSE);
1263  return self->embedder_api.MarkExternalTextureFrameAvailable(
1264  self->engine, texture_id) == kSuccess;
1265 }
int64_t 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 588 of file fl_engine.cc.

589  {
590  g_autoptr(FlDartProject) project = fl_dart_project_new();
591  return fl_engine_new_full(project, binary_messenger);
592 }
G_MODULE_EXPORT FlDartProject * fl_dart_project_new()
static FlEngine * fl_engine_new_full(FlDartProject *project, FlBinaryMessenger *binary_messenger)
Definition: fl_engine.cc:556

References fl_dart_project_new(), and fl_engine_new_full().

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

732  {
733  g_return_if_fail(FL_IS_ENGINE(self));
734 
735  FlutterEngineResult result = self->embedder_api.NotifyDisplayUpdate(
736  self->engine, kFlutterEngineDisplaysUpdateTypeStartup, displays,
737  displays_length);
738  if (result != kSuccess) {
739  g_warning("Failed to notify display update to Flutter engine: %d", result);
740  }
741 }

Referenced by notify_display_update(), and TEST().

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

1268  {
1269  g_return_val_if_fail(FL_IS_ENGINE(self), FALSE);
1270  return self->embedder_api.RegisterExternalTexture(self->engine, texture_id) ==
1271  kSuccess;
1272 }

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

818  {
819  g_return_if_fail(FL_IS_ENGINE(self));
820 
821  g_hash_table_remove(self->renderables_by_view_id, GINT_TO_POINTER(view_id));
822 
823  g_autoptr(GTask) task = g_task_new(self, cancellable, callback, user_data);
824 
825  FlutterRemoveViewInfo info;
826  info.struct_size = sizeof(FlutterRemoveViewInfo);
827  info.view_id = view_id;
828  info.user_data = g_object_ref(task);
829  info.remove_view_callback = view_removed_cb;
830  FlutterEngineResult result =
831  self->embedder_api.RemoveView(self->engine, &info);
832  if (result != kSuccess) {
833  g_task_return_new_error(task, fl_engine_error_quark(),
834  FL_ENGINE_ERROR_FAILED, "RemoveView returned %d",
835  result);
836  // This would have been done in the callback, but that won't occur now.
837  g_object_unref(task);
838  }
839 }
static void view_removed_cb(const FlutterRemoveViewResult *result)
Definition: fl_engine.cc:182

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

Referenced by fl_view_dispose(), and TEST().

◆ fl_engine_remove_view_finish()

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

fl_engine_remove_view_finish: @engine: an #FlEngine.

Returns
: a #GAsyncResult. @error: (allow-none): #GError location to store the error occurring, or NULL to ignore.

Completes request started with fl_engine_remove_view().

Returns: TRUE on succcess.

Definition at line 841 of file fl_engine.cc.

843  {
844  g_return_val_if_fail(FL_IS_ENGINE(self), FALSE);
845  return g_task_propagate_boolean(G_TASK(result), error);
846 }

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

1314  {
1315  g_return_if_fail(FL_IS_ENGINE(self));
1316  fl_platform_handler_request_app_exit(self->platform_handler);
1317 }
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 1192 of file fl_engine.cc.

1196  {
1197  g_return_if_fail(FL_IS_ENGINE(self));
1198 
1199  g_autoptr(GTask) task = g_task_new(self, cancellable, callback, user_data);
1200 
1201  if (self->engine == nullptr) {
1202  g_task_return_new_error(task, fl_engine_error_quark(),
1203  FL_ENGINE_ERROR_FAILED, "No engine");
1204  return;
1205  }
1206 
1207  if (self->embedder_api.SendKeyEvent(self->engine, event, send_key_event_cb,
1208  g_object_ref(task)) != kSuccess) {
1209  g_task_return_new_error(task, fl_engine_error_quark(),
1210  FL_ENGINE_ERROR_FAILED, "Failed to send key event");
1211  g_object_unref(task);
1212  }
1213 }
static void send_key_event_cb(bool handled, void *user_data)
Definition: fl_engine.cc:1185

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

Referenced by fl_key_embedder_responder_handle_event(), fl_key_embedder_responder_handle_event_impl(), synthesize_simple_event(), and TEST().

◆ fl_engine_send_key_event_finish()

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

fl_engine_send_key_event_finish: @engine: an #FlEngine.

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

Completes request started with fl_engine_send_key_event().

Returns: TRUE on success.

Definition at line 1215 of file fl_engine.cc.

1218  {
1219  g_return_val_if_fail(FL_IS_ENGINE(self), FALSE);
1220  g_return_val_if_fail(g_task_is_valid(result, self), FALSE);
1221 
1222  g_autofree gboolean* return_value =
1223  static_cast<gboolean*>(g_task_propagate_pointer(G_TASK(result), error));
1224  if (return_value == nullptr) {
1225  return FALSE;
1226  }
1227 
1228  *handled = *return_value;
1229  return TRUE;
1230 }

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

998  {
999  g_return_if_fail(FL_IS_ENGINE(self));
1000 
1001  if (self->engine == nullptr) {
1002  return;
1003  }
1004 
1005  FlutterPointerEvent fl_event = {};
1006  fl_event.struct_size = sizeof(fl_event);
1007  fl_event.phase = phase;
1008  fl_event.timestamp = timestamp;
1009  fl_event.x = x;
1010  fl_event.y = y;
1011  if (scroll_delta_x != 0 || scroll_delta_y != 0) {
1012  fl_event.signal_kind = kFlutterPointerSignalKindScroll;
1013  }
1014  fl_event.scroll_delta_x = scroll_delta_x;
1015  fl_event.scroll_delta_y = scroll_delta_y;
1016  fl_event.device_kind = device_kind;
1017  fl_event.buttons = buttons;
1018  fl_event.device = kMousePointerDeviceId;
1019  fl_event.view_id = view_id;
1020  self->embedder_api.SendPointerEvent(self->engine, &fl_event, 1);
1021 }
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 899 of file fl_engine.cc.

904  {
905  g_return_if_fail(FL_IS_ENGINE(self));
906 
907  GTask* task = nullptr;
908  FlutterPlatformMessageResponseHandle* response_handle = nullptr;
909  if (callback != nullptr) {
910  task = g_task_new(self, cancellable, callback, user_data);
911 
912  if (self->engine == nullptr) {
913  g_task_return_new_error(task, fl_engine_error_quark(),
914  FL_ENGINE_ERROR_FAILED, "No engine to send to");
915  return;
916  }
917 
918  FlutterEngineResult result =
919  self->embedder_api.PlatformMessageCreateResponseHandle(
920  self->engine, fl_engine_platform_message_response_cb, task,
921  &response_handle);
922  if (result != kSuccess) {
923  g_task_return_new_error(task, fl_engine_error_quark(),
925  "Failed to create response handle");
926  g_object_unref(task);
927  return;
928  }
929  } else if (self->engine == nullptr) {
930  return;
931  }
932 
933  FlutterPlatformMessage fl_message = {};
934  fl_message.struct_size = sizeof(fl_message);
935  fl_message.channel = channel;
936  fl_message.message =
937  message != nullptr
938  ? static_cast<const uint8_t*>(g_bytes_get_data(message, nullptr))
939  : nullptr;
940  fl_message.message_size = message != nullptr ? g_bytes_get_size(message) : 0;
941  fl_message.response_handle = response_handle;
942  FlutterEngineResult result =
943  self->embedder_api.SendPlatformMessage(self->engine, &fl_message);
944 
945  if (result != kSuccess && task != nullptr) {
946  g_task_return_new_error(task, fl_engine_error_quark(),
948  "Failed to send platform messages");
949  g_object_unref(task);
950  }
951 
952  if (response_handle != nullptr) {
953  self->embedder_api.PlatformMessageReleaseResponseHandle(self->engine,
954  response_handle);
955  }
956 }
static void fl_engine_platform_message_response_cb(const uint8_t *data, size_t data_length, void *user_data)
Definition: fl_engine.cc:429

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

Referenced by send_on_channel(), and TEST().

◆ fl_engine_send_platform_message_finish()

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

fl_engine_send_platform_message_finish: @engine: an #FlEngine.

Returns
: a #GAsyncResult. @error: (allow-none): #GError location to store the error occurring, or NULL to ignore.

Completes request started with fl_engine_send_platform_message().

Returns: message response on success or NULL on error.

Definition at line 958 of file fl_engine.cc.

960  {
961  g_return_val_if_fail(FL_IS_ENGINE(self), FALSE);
962  g_return_val_if_fail(g_task_is_valid(result, self), FALSE);
963 
964  return static_cast<GBytes*>(g_task_propagate_pointer(G_TASK(result), error));
965 }

References error.

Referenced by send_on_channel_finish().

◆ fl_engine_send_platform_message_response()

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

fl_engine_send_platform_message_response: @engine: an #FlEngine. @handle: handle that was provided in FlEnginePlatformMessageHandler. @response: (allow-none): response to send or NULL for an empty response. @error: (allow-none): #GError location to store the error occurring, or NULL to ignore.

Responds to a platform message.

Returns: TRUE on success.

Definition at line 867 of file fl_engine.cc.

871  {
872  g_return_val_if_fail(FL_IS_ENGINE(self), FALSE);
873  g_return_val_if_fail(handle != nullptr, FALSE);
874 
875  if (self->engine == nullptr) {
877  "No engine to send response to");
878  return FALSE;
879  }
880 
881  gsize data_length = 0;
882  const uint8_t* data = nullptr;
883  if (response != nullptr) {
884  data =
885  static_cast<const uint8_t*>(g_bytes_get_data(response, &data_length));
886  }
887  FlutterEngineResult result = self->embedder_api.SendPlatformMessageResponse(
888  self->engine, handle, data, data_length);
889 
890  if (result != kSuccess) {
892  "Failed to send platform message response");
893  return FALSE;
894  }
895 
896  return TRUE;
897 }

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

1162  {
1163  g_return_if_fail(FL_IS_ENGINE(self));
1164 
1165  if (self->engine == nullptr) {
1166  return;
1167  }
1168 
1169  FlutterPointerEvent fl_event = {};
1170  fl_event.struct_size = sizeof(fl_event);
1171  fl_event.timestamp = timestamp;
1172  fl_event.x = x;
1173  fl_event.y = y;
1174  fl_event.phase = phase;
1175  fl_event.pan_x = pan_x;
1176  fl_event.pan_y = pan_y;
1177  fl_event.scale = scale;
1178  fl_event.rotation = rotation;
1179  fl_event.device = kPointerPanZoomDeviceId;
1180  fl_event.device_kind = kFlutterPointerDeviceKindTrackpad;
1181  fl_event.view_id = view_id;
1182  self->embedder_api.SendPointerEvent(self->engine, &fl_event, 1);
1183 }
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 1101 of file fl_engine.cc.

1106  {
1107  g_return_if_fail(FL_IS_ENGINE(self));
1108 
1109  if (self->engine == nullptr) {
1110  return;
1111  }
1112 
1113  FlutterPointerEvent event;
1114  event.timestamp = timestamp;
1115  event.x = x;
1116  event.y = y;
1117  event.device_kind = kFlutterPointerDeviceKindTouch;
1118  event.device = device;
1119  event.buttons = 0;
1120  event.view_id = view_id;
1121  event.phase = FlutterPointerPhase::kAdd;
1122  event.struct_size = sizeof(event);
1123 
1124  self->embedder_api.SendPointerEvent(self->engine, &event, 1);
1125 }

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

1054  {
1055  g_return_if_fail(FL_IS_ENGINE(self));
1056 
1057  if (self->engine == nullptr) {
1058  return;
1059  }
1060 
1061  FlutterPointerEvent event;
1062  event.timestamp = timestamp;
1063  event.x = x;
1064  event.y = y;
1065  event.device_kind = kFlutterPointerDeviceKindTouch;
1066  event.device = device;
1067  event.buttons = FlutterPointerMouseButtons::kFlutterPointerButtonMousePrimary;
1068  event.view_id = view_id;
1069  event.phase = FlutterPointerPhase::kDown;
1070  event.struct_size = sizeof(event);
1071 
1072  self->embedder_api.SendPointerEvent(self->engine, &event, 1);
1073 }

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

1080  {
1081  g_return_if_fail(FL_IS_ENGINE(self));
1082 
1083  if (self->engine == nullptr) {
1084  return;
1085  }
1086 
1087  FlutterPointerEvent event;
1088  event.timestamp = timestamp;
1089  event.x = x;
1090  event.y = y;
1091  event.device_kind = kFlutterPointerDeviceKindTouch;
1092  event.device = device;
1093  event.buttons = FlutterPointerMouseButtons::kFlutterPointerButtonMousePrimary;
1094  event.view_id = view_id;
1095  event.phase = FlutterPointerPhase::kMove;
1096  event.struct_size = sizeof(event);
1097 
1098  self->embedder_api.SendPointerEvent(self->engine, &event, 1);
1099 }

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

1132  {
1133  g_return_if_fail(FL_IS_ENGINE(self));
1134 
1135  if (self->engine == nullptr) {
1136  return;
1137  }
1138 
1139  FlutterPointerEvent event;
1140  event.timestamp = timestamp;
1141  event.x = x;
1142  event.y = y;
1143  event.device_kind = kFlutterPointerDeviceKindTouch;
1144  event.device = device;
1145  event.buttons = 0;
1146  event.view_id = view_id;
1147  event.phase = FlutterPointerPhase::kRemove;
1148  event.struct_size = sizeof(event);
1149 
1150  self->embedder_api.SendPointerEvent(self->engine, &event, 1);
1151 }

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

1028  {
1029  g_return_if_fail(FL_IS_ENGINE(self));
1030 
1031  if (self->engine == nullptr) {
1032  return;
1033  }
1034 
1035  FlutterPointerEvent event;
1036  event.timestamp = timestamp;
1037  event.x = x;
1038  event.y = y;
1039  event.device_kind = kFlutterPointerDeviceKindTouch;
1040  event.device = device;
1041  event.buttons = 0;
1042  event.view_id = view_id;
1043  event.phase = FlutterPointerPhase::kUp;
1044  event.struct_size = sizeof(event);
1045 
1046  self->embedder_api.SendPointerEvent(self->engine, &event, 1);
1047 }

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  width,
size_t  height,
double  pixel_ratio 
)

fl_engine_send_window_metrics_event: @engine: an #FlEngine. @display_id: the display this view is rendering on. @view_id: the view that the event occured on. @width: width of the window in pixels. @height: height of the window in pixels. @pixel_ratio: scale factor for window.

Sends a window metrics event to the engine.

Definition at line 967 of file fl_engine.cc.

972  {
973  g_return_if_fail(FL_IS_ENGINE(self));
974 
975  if (self->engine == nullptr) {
976  return;
977  }
978 
979  FlutterWindowMetricsEvent event = {};
980  event.struct_size = sizeof(FlutterWindowMetricsEvent);
981  event.width = width;
982  event.height = height;
983  event.pixel_ratio = pixel_ratio;
984  event.display_id = display_id;
985  event.view_id = view_id;
986  self->embedder_api.SendWindowMetricsEvent(self->engine, &event);
987 }

References height, view_id, and width.

Referenced by handle_geometry_changed(), and TEST().

◆ fl_engine_set_implicit_view()

void fl_engine_set_implicit_view ( FlEngine *  engine,
FlRenderable *  renderable 
)

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

Sets the object to render the implicit view.

Definition at line 743 of file fl_engine.cc.

743  {
744  GWeakRef* ref = g_new(GWeakRef, 1);
745  g_weak_ref_init(ref, G_OBJECT(renderable));
746  g_hash_table_insert(self->renderables_by_view_id,
747  GINT_TO_POINTER(flutter::kFlutterImplicitViewId), ref);
748 }

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

852  {
853  g_return_if_fail(FL_IS_ENGINE(self));
854  g_return_if_fail(handler != nullptr);
855 
856  if (self->platform_message_handler_destroy_notify) {
857  self->platform_message_handler_destroy_notify(
858  self->platform_message_handler_data);
859  }
860 
861  self->platform_message_handler = handler;
862  self->platform_message_handler_data = user_data;
863  self->platform_message_handler_destroy_notify = destroy_notify;
864 }

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.

Starts the Flutter engine.

Returns: TRUE on success.

Definition at line 613 of file fl_engine.cc.

613  {
614  g_return_val_if_fail(FL_IS_ENGINE(self), FALSE);
615 
616  FlutterRendererConfig config = {};
617  config.type = kOpenGL;
618  config.open_gl.struct_size = sizeof(FlutterOpenGLRendererConfig);
619  config.open_gl.gl_proc_resolver = fl_engine_gl_proc_resolver;
620  config.open_gl.make_current = fl_engine_gl_make_current;
621  config.open_gl.clear_current = fl_engine_gl_clear_current;
622  config.open_gl.fbo_callback = fl_engine_gl_get_fbo;
623  config.open_gl.present = fl_engine_gl_present;
624  config.open_gl.make_resource_current = fl_engine_gl_make_resource_current;
625  config.open_gl.gl_external_texture_frame_callback =
627 
628  FlutterTaskRunnerDescription platform_task_runner = {};
629  platform_task_runner.struct_size = sizeof(FlutterTaskRunnerDescription);
630  platform_task_runner.user_data = self;
631  platform_task_runner.runs_task_on_current_thread_callback =
633  platform_task_runner.post_task_callback = fl_engine_post_task;
634  platform_task_runner.identifier = kPlatformTaskRunnerIdentifier;
635 
636  FlutterCustomTaskRunners custom_task_runners = {};
637  custom_task_runners.struct_size = sizeof(FlutterCustomTaskRunners);
638  custom_task_runners.platform_task_runner = &platform_task_runner;
639 
640  g_autoptr(GPtrArray) command_line_args =
641  g_ptr_array_new_with_free_func(g_free);
642  g_ptr_array_insert(command_line_args, 0, g_strdup("flutter"));
643  for (const auto& env_switch : flutter::GetSwitchesFromEnvironment()) {
644  g_ptr_array_add(command_line_args, g_strdup(env_switch.c_str()));
645  }
646 
647  gchar** dart_entrypoint_args =
649 
650  FlutterProjectArgs args = {};
651  args.struct_size = sizeof(FlutterProjectArgs);
652  args.assets_path = fl_dart_project_get_assets_path(self->project);
653  args.icu_data_path = fl_dart_project_get_icu_data_path(self->project);
654  args.command_line_argc = command_line_args->len;
655  args.command_line_argv =
656  reinterpret_cast<const char* const*>(command_line_args->pdata);
657  args.platform_message_callback = fl_engine_platform_message_cb;
658  args.update_semantics_callback2 = fl_engine_update_semantics_cb;
659  args.custom_task_runners = &custom_task_runners;
660  args.shutdown_dart_vm_when_done = true;
661  args.on_pre_engine_restart_callback = fl_engine_on_pre_engine_restart_cb;
662  args.dart_entrypoint_argc =
663  dart_entrypoint_args != nullptr ? g_strv_length(dart_entrypoint_args) : 0;
664  args.dart_entrypoint_argv =
665  reinterpret_cast<const char* const*>(dart_entrypoint_args);
666  args.engine_id = reinterpret_cast<int64_t>(self);
667 
668  FlutterCompositor compositor = {};
669  compositor.struct_size = sizeof(FlutterCompositor);
670  compositor.user_data = self;
671  compositor.create_backing_store_callback =
673  compositor.collect_backing_store_callback =
675  compositor.present_view_callback = compositor_present_view_callback;
676  args.compositor = &compositor;
677 
678  if (self->embedder_api.RunsAOTCompiledDartCode()) {
679  FlutterEngineAOTDataSource source = {};
680  source.type = kFlutterEngineAOTDataSourceTypeElfPath;
681  source.elf_path = fl_dart_project_get_aot_library_path(self->project);
682  if (self->embedder_api.CreateAOTData(&source, &self->aot_data) !=
683  kSuccess) {
685  "Failed to create AOT data");
686  return FALSE;
687  }
688  args.aot_data = self->aot_data;
689  }
690 
691  FlutterEngineResult result = self->embedder_api.Initialize(
692  FLUTTER_ENGINE_VERSION, &config, &args, self, &self->engine);
693  if (result != kSuccess) {
695  "Failed to initialize Flutter engine");
696  return FALSE;
697  }
698 
699  result = self->embedder_api.RunInitialized(self->engine);
700  if (result != kSuccess) {
702  "Failed to run Flutter engine");
703  return FALSE;
704  }
705 
706  setup_locales(self);
707 
708  g_autoptr(FlSettings) settings = fl_settings_new();
709  self->settings_handler = fl_settings_handler_new(self);
710  fl_settings_handler_start(self->settings_handler, settings);
711 
712  self->platform_handler = fl_platform_handler_new(self->binary_messenger);
713 
714  setup_keyboard(self);
715 
716  result = self->embedder_api.UpdateSemanticsEnabled(self->engine, TRUE);
717  if (result != kSuccess) {
718  g_warning("Failed to enable accessibility features on Flutter engine");
719  }
720 
721  fl_display_monitor_start(self->display_monitor);
722 
723  return TRUE;
724 }
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)
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:312
static bool fl_engine_runs_task_on_current_thread(void *user_data)
Definition: fl_engine.cc:353
static void fl_engine_on_pre_engine_restart_cb(void *user_data)
Definition: fl_engine.cc:419
static bool compositor_create_backing_store_callback(const FlutterBackingStoreConfig *config, FlutterBackingStore *backing_store_out, void *user_data)
Definition: fl_engine.cc:251
static bool fl_engine_gl_make_current(void *user_data)
Definition: fl_engine.cc:282
static bool compositor_present_view_callback(const FlutterPresentViewInfo *info)
Definition: fl_engine.cc:269
static bool compositor_collect_backing_store_callback(const FlutterBackingStore *backing_store, void *user_data)
Definition: fl_engine.cc:261
static void fl_engine_post_task(FlutterTask task, uint64_t target_time_nanos, void *user_data)
Definition: fl_engine.cc:359
static uint32_t fl_engine_gl_get_fbo(void *user_data)
Definition: fl_engine.cc:294
static void * fl_engine_gl_proc_resolver(void *user_data, const char *name)
Definition: fl_engine.cc:278
static bool fl_engine_gl_present(void *user_data)
Definition: fl_engine.cc:299
static void setup_keyboard(FlEngine *self)
Definition: fl_engine.cc:395
static void setup_locales(FlEngine *self)
Definition: fl_engine.cc:200
static void fl_engine_update_semantics_cb(const FlutterSemanticsUpdate2 *update, void *user_data)
Definition: fl_engine.cc:388
static bool fl_engine_gl_make_resource_current(void *user_data)
Definition: fl_engine.cc:305
static void fl_engine_platform_message_cb(const FlutterPlatformMessage *message, void *user_data)
Definition: fl_engine.cc:368
static constexpr size_t kPlatformTaskRunnerIdentifier
Definition: fl_engine.cc:32
static bool fl_engine_gl_clear_current(void *user_data)
Definition: fl_engine.cc:288
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_display_monitor_start(), FL_ENGINE_ERROR_FAILED, fl_engine_error_quark(), fl_engine_gl_clear_current(), fl_engine_gl_external_texture_frame_callback(), fl_engine_gl_get_fbo(), fl_engine_gl_make_current(), fl_engine_gl_make_resource_current(), fl_engine_gl_present(), fl_engine_gl_proc_resolver(), fl_engine_on_pre_engine_restart_cb(), fl_engine_platform_message_cb(), fl_engine_post_task(), fl_engine_runs_task_on_current_thread(), fl_engine_update_semantics_cb(), fl_platform_handler_new(), fl_settings_handler_new(), fl_settings_handler_start(), fl_settings_new(), flutter::GetSwitchesFromEnvironment(), kPlatformTaskRunnerIdentifier, setup_keyboard(), setup_locales(), and TRUE.

Referenced by realize_cb(), and TEST().

◆ fl_engine_unregister_external_texture()

gboolean fl_engine_unregister_external_texture ( FlEngine *  engine,
int64_t  texture_id 
)

fl_engine_unregister_external_texture: @engine: an #FlEngine. @texture_id: the identifier of the texture that is not available anymore.

Tells the Flutter engine that an existing external texture is not available anymore.

Returns: TRUE on success.

Definition at line 1274 of file fl_engine.cc.

1275  {
1276  g_return_val_if_fail(FL_IS_ENGINE(self), FALSE);
1277  return self->embedder_api.UnregisterExternalTexture(self->engine,
1278  texture_id) == kSuccess;
1279 }

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

1303  {
1304  g_return_if_fail(FL_IS_ENGINE(self));
1305 
1306  if (self->engine == nullptr) {
1307  return;
1308  }
1309 
1310  self->embedder_api.UpdateAccessibilityFeatures(
1311  self->engine, static_cast<FlutterAccessibilityFeature>(flags));
1312 }
FlutterSemanticsFlag flags

References flags.

Referenced by update_settings().