Flutter Engine
fl_engine_private.h File Reference
#include <glib-object.h>
#include "flutter/shell/platform/embedder/embedder.h"
#include "flutter/shell/platform/linux/fl_renderer.h"
#include "flutter/shell/platform/linux/fl_task_runner.h"
#include "flutter/shell/platform/linux/public/flutter_linux/fl_dart_project.h"
#include "flutter/shell/platform/linux/public/flutter_linux/fl_engine.h"

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)
 
typedef void(* FlEngineUpdateSemanticsNodeHandler) (FlEngine *engine, const FlutterSemanticsNode *node, gpointer user_data)
 
typedef void(* FlEngineOnPreEngineRestartHandler) (FlEngine *engine, gpointer user_data)
 

Enumerations

enum  FlEngineError { FL_ENGINE_ERROR_FAILED }
 

Functions

GQuark fl_engine_error_quark (void) G_GNUC_CONST
 
FlEngine * fl_engine_new (FlDartProject *project, FlRenderer *renderer)
 
FlutterEngineProcTablefl_engine_get_embedder_api (FlEngine *engine)
 
void fl_engine_set_platform_message_handler (FlEngine *engine, FlEnginePlatformMessageHandler handler, gpointer user_data, GDestroyNotify destroy_notify)
 
void fl_engine_set_update_semantics_node_handler (FlEngine *engine, FlEngineUpdateSemanticsNodeHandler handler, gpointer user_data, GDestroyNotify destroy_notify)
 
void fl_engine_set_on_pre_engine_restart_handler (FlEngine *engine, FlEngineOnPreEngineRestartHandler handler, gpointer user_data, GDestroyNotify destroy_notify)
 
gboolean fl_engine_start (FlEngine *engine, GError **error)
 
void fl_engine_send_window_metrics_event (FlEngine *engine, size_t width, size_t height, double pixel_ratio)
 
void fl_engine_send_mouse_pointer_event (FlEngine *engine, FlutterPointerPhase phase, size_t timestamp, double x, double y, double scroll_delta_x, double scroll_delta_y, int64_t buttons)
 
void fl_engine_send_key_event (FlEngine *engine, const FlutterKeyEvent *event, FlutterKeyEventCallback callback, void *user_data)
 
void fl_engine_dispatch_semantics_action (FlEngine *engine, uint64_t 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)
 

Typedef Documentation

◆ FlEngineOnPreEngineRestartHandler

typedef void(* FlEngineOnPreEngineRestartHandler) (FlEngine *engine, gpointer user_data)

FlEngineOnPreEngineRestartHandler: : an #FlEngine. : semantic node information.

: (closure): data provided when registering this handler.

Definition at line 68 of file fl_engine_private.h.

◆ FlEnginePlatformMessageHandler

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

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

Function called when platform messages are received.

Returns: TRUE if message has been accepted.

Definition at line 41 of file fl_engine_private.h.

◆ FlEngineUpdateSemanticsNodeHandler

typedef void(* FlEngineUpdateSemanticsNodeHandler) (FlEngine *engine, const FlutterSemanticsNode *node, gpointer user_data)

FlEngineUpdateSemanticsNodeHandler: : an #FlEngine. : semantic node information. : (closure): data provided when registering this handler.

Function called when semantics node updates are received.

Definition at line 56 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 23 of file fl_engine_private.h.

Function Documentation

◆ fl_engine_dispatch_semantics_action()

void fl_engine_dispatch_semantics_action ( FlEngine *  engine,
uint64_t  id,
FlutterSemanticsAction  action,
GBytes *  data 
)

fl_engine_dispatch_semantics_action: : an #FlEngine. : the semantics action identifier. : the action being dispatched. : (allow-none): data associated with the action.

Definition at line 727 of file fl_engine.cc.

Referenced by fl_accessible_node_do_action(), and TEST().

730  {
731  g_return_if_fail(FL_IS_ENGINE(self));
732 
733  if (self->engine == nullptr) {
734  return;
735  }
736 
737  const uint8_t* action_data = nullptr;
738  size_t action_data_length = 0;
739  if (data != nullptr) {
740  action_data = static_cast<const uint8_t*>(
741  g_bytes_get_data(data, &action_data_length));
742  }
743 
744  self->embedder_api.DispatchSemanticsAction(self->engine, id, action,
745  action_data, action_data_length);
746 }
SemanticsAction action

◆ fl_engine_error_quark()

◆ fl_engine_execute_task()

void fl_engine_execute_task ( FlEngine *  engine,
FlutterTask task 
)

fl_engine_execute_task: : an #FlEngine. : a FlutterTask to execute.

Executes given Flutter task.

Definition at line 780 of file fl_engine.cc.

Referenced by fl_task_runner_process_expired_tasks_locked().

780  {
781  g_return_if_fail(FL_IS_ENGINE(self));
782  self->embedder_api.RunTask(self->engine, task);
783 }

◆ fl_engine_get_embedder_api()

FlutterEngineProcTable* fl_engine_get_embedder_api ( FlEngine *  engine)

fl_engine_get_embedder_api: : 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 510 of file fl_engine.cc.

Referenced by make_mock_engine_with_records(), and TEST().

510  {
511  return &(self->embedder_api);
512 }

◆ fl_engine_get_task_runner()

FlTaskRunner* fl_engine_get_task_runner ( FlEngine *  engine)

fl_engine_get_task_runner: : an #FlEngine.

Returns
: a #FlTaskRunner.

Returns: task runner responsible for scheduling Flutter tasks.

Definition at line 775 of file fl_engine.cc.

Referenced by fl_renderer_unblock_main_thread(), and fl_renderer_wait_for_frame().

775  {
776  g_return_val_if_fail(FL_IS_ENGINE(self), nullptr);
777  return self->task_runner;
778 }

◆ 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: : an #FlEngine. : 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 748 of file fl_engine.cc.

References FALSE, and kSuccess.

Referenced by fl_texture_registrar_mark_texture_frame_available().

749  {
750  g_return_val_if_fail(FL_IS_ENGINE(self), FALSE);
751  return self->embedder_api.MarkExternalTextureFrameAvailable(
752  self->engine, texture_id) == kSuccess;
753 }
int64_t texture_id
return FALSE

◆ fl_engine_new()

FlEngine* fl_engine_new ( FlDartProject *  project,
FlRenderer *  renderer 
)

fl_engine_new: : an #FlDartProject. : an #FlRenderer.

Creates new Flutter engine.

Returns: a new #FlEngine.

Definition at line 388 of file fl_engine.cc.

Referenced by fl_engine_new_headless(), fl_view_constructed(), make_mock_engine(), and make_mock_engine_with_project().

388  {
389  g_return_val_if_fail(FL_IS_DART_PROJECT(project), nullptr);
390  g_return_val_if_fail(FL_IS_RENDERER(renderer), nullptr);
391 
392  FlEngine* self = FL_ENGINE(g_object_new(fl_engine_get_type(), nullptr));
393  self->project = FL_DART_PROJECT(g_object_ref(project));
394  self->renderer = FL_RENDERER(g_object_ref(renderer));
395  return self;
396 }

◆ fl_engine_register_external_texture()

gboolean fl_engine_register_external_texture ( FlEngine *  engine,
int64_t  texture_id 
)

fl_engine_register_external_texture: : an #FlEngine. : 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 755 of file fl_engine.cc.

References FALSE, and kSuccess.

Referenced by fl_texture_registrar_register_texture().

756  {
757  g_return_val_if_fail(FL_IS_ENGINE(self), FALSE);
758  return self->embedder_api.RegisterExternalTexture(self->engine, texture_id) ==
759  kSuccess;
760 }
int64_t texture_id
return FALSE

◆ fl_engine_send_key_event()

void fl_engine_send_key_event ( FlEngine *  engine,
const FlutterKeyEvent event,
FlutterKeyEventCallback  callback,
void *  user_data 
)

fl_engine_send_key_event:

Definition at line 714 of file fl_engine.cc.

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

717  {
718  g_return_if_fail(FL_IS_ENGINE(self));
719 
720  if (self->engine == nullptr) {
721  return;
722  }
723 
724  self->embedder_api.SendKeyEvent(self->engine, event, callback, user_data);
725 }
void * user_data
FlKeyEvent FlKeyResponderAsyncCallback callback

◆ fl_engine_send_mouse_pointer_event()

void fl_engine_send_mouse_pointer_event ( FlEngine *  engine,
FlutterPointerPhase  phase,
size_t  timestamp,
double  x,
double  y,
double  scroll_delta_x,
double  scroll_delta_y,
int64_t  buttons 
)

fl_engine_send_mouse_pointer_event: : an #FlEngine. : mouse phase. : time when event occurred in microseconds. : x location of mouse cursor. : y location of mouse cursor. : x offset of scroll. : y offset of scroll. : buttons that are pressed.

Sends a mouse pointer event to the engine.

Definition at line 684 of file fl_engine.cc.

References FlutterPointerEvent::buttons, FlutterPointerEvent::device_kind, kFlutterPointerDeviceKindMouse, kFlutterPointerSignalKindScroll, FlutterPointerEvent::phase, FlutterPointerEvent::scroll_delta_x, FlutterPointerEvent::scroll_delta_y, FlutterPointerEvent::signal_kind, FlutterPointerEvent::struct_size, FlutterPointerEvent::timestamp, FlutterPointerEvent::x, and FlutterPointerEvent::y.

Referenced by check_pointer_inside(), event_box_leave_notify_event(), event_box_motion_notify_event(), event_box_scroll_event(), fl_view_send_pointer_button_event(), and TEST().

691  {
692  g_return_if_fail(FL_IS_ENGINE(self));
693 
694  if (self->engine == nullptr) {
695  return;
696  }
697 
698  FlutterPointerEvent fl_event = {};
699  fl_event.struct_size = sizeof(fl_event);
700  fl_event.phase = phase;
701  fl_event.timestamp = timestamp;
702  fl_event.x = x;
703  fl_event.y = y;
704  if (scroll_delta_x != 0 || scroll_delta_y != 0) {
706  }
707  fl_event.scroll_delta_x = scroll_delta_x;
708  fl_event.scroll_delta_y = scroll_delta_y;
710  fl_event.buttons = buttons;
711  self->embedder_api.SendPointerEvent(self->engine, &fl_event, 1);
712 }
double scroll_delta_y
The y offset of the scroll in physical pixels.
Definition: embedder.h:666
double y
The y coordinate of the pointer event in physical pixels.
Definition: embedder.h:658
double scroll_delta_x
The x offset of the scroll in physical pixels.
Definition: embedder.h:664
size_t struct_size
The size of this struct. Must be sizeof(FlutterPointerEvent).
Definition: embedder.h:649
double x
The x coordinate of the pointer event in physical pixels.
Definition: embedder.h:656
int64_t buttons
The buttons currently pressed, if any.
Definition: embedder.h:674
FlutterPointerSignalKind signal_kind
Definition: embedder.h:662
FlutterPointerDeviceKind device_kind
Definition: embedder.h:672
FlutterPointerPhase phase
Definition: embedder.h:650

◆ 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: : an #FlEngine. : channel to send to. : (allow-none): message buffer to send or NULL for an empty message : (allow-none): a #GCancellable or NULL. : (scope async): a #GAsyncReadyCallback to call when the request is satisfied. : (closure): user data to pass to .

Asynchronously sends a platform message.

Definition at line 598 of file fl_engine.cc.

References FlutterPlatformMessage::channel, FL_ENGINE_ERROR_FAILED, fl_engine_error_quark(), fl_engine_platform_message_response_cb(), kSuccess, FlutterPlatformMessage::message, FlutterPlatformMessage::message_size, FlutterPlatformMessage::response_handle, result, and FlutterPlatformMessage::struct_size.

Referenced by fl_binary_messenger_send_on_channel(), and TEST().

603  {
604  g_return_if_fail(FL_IS_ENGINE(self));
605 
606  GTask* task = nullptr;
607  FlutterPlatformMessageResponseHandle* response_handle = nullptr;
608  if (callback != nullptr) {
609  task = g_task_new(self, cancellable, callback, user_data);
610 
611  if (self->engine == nullptr) {
612  g_task_return_new_error(task, fl_engine_error_quark(),
613  FL_ENGINE_ERROR_FAILED, "No engine to send to");
614  return;
615  }
616 
618  self->embedder_api.PlatformMessageCreateResponseHandle(
619  self->engine, fl_engine_platform_message_response_cb, task,
620  &response_handle);
621  if (result != kSuccess) {
622  g_task_return_new_error(task, fl_engine_error_quark(),
624  "Failed to create response handle");
625  g_object_unref(task);
626  return;
627  }
628  } else if (self->engine == nullptr) {
629  return;
630  }
631 
632  FlutterPlatformMessage fl_message = {};
633  fl_message.struct_size = sizeof(fl_message);
634  fl_message.channel = channel;
635  fl_message.message =
636  message != nullptr
637  ? static_cast<const uint8_t*>(g_bytes_get_data(message, nullptr))
638  : nullptr;
639  fl_message.message_size = message != nullptr ? g_bytes_get_size(message) : 0;
640  fl_message.response_handle = response_handle;
641  FlutterEngineResult result =
642  self->embedder_api.SendPlatformMessage(self->engine, &fl_message);
643 
644  if (result != kSuccess && task != nullptr) {
645  g_task_return_new_error(task, fl_engine_error_quark(),
647  "Failed to send platform messages");
648  g_object_unref(task);
649  }
650 
651  if (response_handle != nullptr) {
652  self->embedder_api.PlatformMessageReleaseResponseHandle(self->engine,
653  response_handle);
654  }
655 }
const char * channel
Definition: embedder.h:758
const FlutterPlatformMessageResponseHandle * response_handle
Definition: embedder.h:767
void * user_data
GAsyncResult * result
FlKeyEvent FlKeyResponderAsyncCallback callback
const uint8_t * message
Definition: embedder.h:759
FlutterEngineResult
Definition: embedder.h:65
static void fl_engine_platform_message_response_cb(const uint8_t *data, size_t data_length, void *user_data)
Definition: fl_engine.cc:307
size_t struct_size
The size of this struct. Must be sizeof(FlutterPlatformMessage).
Definition: embedder.h:757
GQuark fl_engine_error_quark(void) G_GNUC_CONST

◆ 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: : an #FlEngine.

Returns
: a #GAsyncResult. : (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 657 of file fl_engine.cc.

References FALSE.

Referenced by fl_binary_messenger_send_on_channel_finish().

659  {
660  g_return_val_if_fail(FL_IS_ENGINE(self), FALSE);
661  g_return_val_if_fail(g_task_is_valid(result, self), FALSE);
662 
663  return static_cast<GBytes*>(g_task_propagate_pointer(G_TASK(result), error));
664 }
const uint8_t uint32_t uint32_t GError ** error
GAsyncResult * result
return FALSE

◆ 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: : an #FlEngine. : handle that was provided in FlEnginePlatformMessageHandler. : (allow-none): response to send or NULL for an empty response. : (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 566 of file fl_engine.cc.

References FALSE, FL_ENGINE_ERROR_FAILED, fl_engine_error_quark(), kSuccess, result, and TRUE.

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

570  {
571  g_return_val_if_fail(FL_IS_ENGINE(self), FALSE);
572  g_return_val_if_fail(handle != nullptr, FALSE);
573 
574  if (self->engine == nullptr) {
576  "No engine to send response to");
577  return FALSE;
578  }
579 
580  gsize data_length = 0;
581  const uint8_t* data = nullptr;
582  if (response != nullptr) {
583  data =
584  static_cast<const uint8_t*>(g_bytes_get_data(response, &data_length));
585  }
586  FlutterEngineResult result = self->embedder_api.SendPlatformMessageResponse(
587  self->engine, handle, data, data_length);
588 
589  if (result != kSuccess) {
591  "Failed to send platform message response");
592  return FALSE;
593  }
594 
595  return TRUE;
596 }
const uint8_t uint32_t uint32_t GError ** error
GAsyncResult * result
FlutterEngineResult
Definition: embedder.h:65
return FALSE
GQuark fl_engine_error_quark(void) G_GNUC_CONST

◆ fl_engine_send_window_metrics_event()

void fl_engine_send_window_metrics_event ( FlEngine *  engine,
size_t  width,
size_t  height,
double  pixel_ratio 
)

fl_engine_send_window_metrics_event: : an #FlEngine. : width of the window in pixels. : height of the window in pixels. : scale factor for window.

Sends a window metrics event to the engine.

Definition at line 666 of file fl_engine.cc.

References event, height, FlutterWindowMetricsEvent::struct_size, and width.

Referenced by fl_view_geometry_changed(), and TEST().

669  {
670  g_return_if_fail(FL_IS_ENGINE(self));
671 
672  if (self->engine == nullptr) {
673  return;
674  }
675 
676  FlutterWindowMetricsEvent event = {};
677  event.struct_size = sizeof(FlutterWindowMetricsEvent);
678  event.width = width;
679  event.height = height;
680  event.pixel_ratio = pixel_ratio;
681  self->embedder_api.SendWindowMetricsEvent(self->engine, &event);
682 }
FlKeyEvent * event
int32_t width
size_t struct_size
The size of this struct. Must be sizeof(FlutterWindowMetricsEvent).
Definition: embedder.h:565
int32_t height

◆ fl_engine_set_on_pre_engine_restart_handler()

void fl_engine_set_on_pre_engine_restart_handler ( FlEngine *  engine,
FlEngineOnPreEngineRestartHandler  handler,
gpointer  user_data,
GDestroyNotify  destroy_notify 
)

fl_engine_set_on_pre_engine_restart_handler: : an #FlEngine. : function to call when the engine is restarted. : (closure): user data to pass to . : (allow-none): a function which gets called to free , or NULL.

Registers the function called when the engine is restarted.

Definition at line 549 of file fl_engine.cc.

References user_data.

Referenced by fl_view_constructed(), fl_view_dispose(), and TEST().

553  {
554  g_return_if_fail(FL_IS_ENGINE(self));
555 
556  if (self->on_pre_engine_restart_handler_destroy_notify) {
557  self->on_pre_engine_restart_handler_destroy_notify(
558  self->on_pre_engine_restart_handler_data);
559  }
560 
561  self->on_pre_engine_restart_handler = handler;
562  self->on_pre_engine_restart_handler_data = user_data;
563  self->on_pre_engine_restart_handler_destroy_notify = destroy_notify;
564 }
void * user_data

◆ 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: : an #FlEngine. : function to call when a platform message is received. : (closure): user data to pass to . : (allow-none): a function which gets called to free , 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 to avoid memory leaks.

Definition at line 514 of file fl_engine.cc.

References user_data.

Referenced by fl_binary_messenger_new().

518  {
519  g_return_if_fail(FL_IS_ENGINE(self));
520  g_return_if_fail(handler != nullptr);
521 
522  if (self->platform_message_handler_destroy_notify) {
523  self->platform_message_handler_destroy_notify(
524  self->platform_message_handler_data);
525  }
526 
527  self->platform_message_handler = handler;
528  self->platform_message_handler_data = user_data;
529  self->platform_message_handler_destroy_notify = destroy_notify;
530 }
void * user_data

◆ fl_engine_set_update_semantics_node_handler()

void fl_engine_set_update_semantics_node_handler ( FlEngine *  engine,
FlEngineUpdateSemanticsNodeHandler  handler,
gpointer  user_data,
GDestroyNotify  destroy_notify 
)

fl_engine_set_update_semantics_node_handler: : an #FlEngine. : function to call when a semantics node update is received. : (closure): user data to pass to . : (allow-none): a function which gets called to free , or NULL.

Registers the function called when a semantics node update is reveived.

Definition at line 532 of file fl_engine.cc.

References user_data.

Referenced by fl_view_constructed(), and fl_view_dispose().

536  {
537  g_return_if_fail(FL_IS_ENGINE(self));
538 
539  if (self->update_semantics_node_handler_destroy_notify) {
540  self->update_semantics_node_handler_destroy_notify(
541  self->update_semantics_node_handler_data);
542  }
543 
544  self->update_semantics_node_handler = handler;
545  self->update_semantics_node_handler_data = user_data;
546  self->update_semantics_node_handler_destroy_notify = destroy_notify;
547 }
void * user_data

◆ fl_engine_start()

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

fl_engine_start: : an #FlEngine. : (allow-none): #GError location to store the error occurring, or NULL to ignore.

Starts the Flutter engine.

Returns: TRUE on success.

Definition at line 403 of file fl_engine.cc.

References FlutterProjectArgs::aot_data, args, FlutterProjectArgs::assets_path, FlutterOpenGLRendererConfig::clear_current, FlutterCompositor::collect_backing_store_callback, FlutterProjectArgs::command_line_argc, FlutterProjectArgs::command_line_argv, FlutterProjectArgs::compositor, compositor_collect_backing_store_callback(), compositor_create_backing_store_callback(), compositor_present_layers_callback(), FlutterCompositor::create_backing_store_callback, FlutterProjectArgs::custom_task_runners, FlutterProjectArgs::dart_entrypoint_argc, FlutterProjectArgs::dart_entrypoint_argv, FlutterEngineAOTDataSource::elf_path, FALSE, FlutterOpenGLRendererConfig::fbo_callback, fl_dart_project_get_aot_library_path(), fl_dart_project_get_assets_path(), fl_dart_project_get_dart_entrypoint_arguments(), fl_dart_project_get_icu_data_path(), fl_dart_project_get_switches(), 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_node_cb(), fl_settings_plugin_new(), fl_settings_plugin_start(), fl_task_runner_new(), FLUTTER_ENGINE_VERSION, FlutterOpenGLRendererConfig::gl_external_texture_frame_callback, FlutterOpenGLRendererConfig::gl_proc_resolver, FlutterProjectArgs::icu_data_path, FlutterTaskRunnerDescription::identifier, kFlutterEngineAOTDataSourceTypeElfPath, kOpenGL, kPlatformTaskRunnerIdentifier, kSuccess, FlutterOpenGLRendererConfig::make_current, FlutterOpenGLRendererConfig::make_resource_current, FlutterProjectArgs::on_pre_engine_restart_callback, FlutterRendererConfig::open_gl, FlutterProjectArgs::platform_message_callback, FlutterCustomTaskRunners::platform_task_runner, FlutterTaskRunnerDescription::post_task_callback, FlutterOpenGLRendererConfig::present, FlutterCompositor::present_layers_callback, FlutterCustomTaskRunners::render_task_runner, result, FlutterTaskRunnerDescription::runs_task_on_current_thread_callback, setup_locales(), FlutterProjectArgs::shutdown_dart_vm_when_done, FlutterOpenGLRendererConfig::struct_size, FlutterTaskRunnerDescription::struct_size, FlutterCustomTaskRunners::struct_size, FlutterCompositor::struct_size, FlutterProjectArgs::struct_size, TRUE, FlutterRendererConfig::type, FlutterEngineAOTDataSource::type, FlutterProjectArgs::update_semantics_node_callback, FlutterTaskRunnerDescription::user_data, and FlutterCompositor::user_data.

Referenced by fl_view_realize(), make_mock_engine(), make_mock_engine_with_project(), and TEST().

403  {
404  g_return_val_if_fail(FL_IS_ENGINE(self), FALSE);
405 
406  self->task_runner = fl_task_runner_new(self);
407 
408  FlutterRendererConfig config = {};
409  config.type = kOpenGL;
419 
420  FlutterTaskRunnerDescription platform_task_runner = {};
421  platform_task_runner.struct_size = sizeof(FlutterTaskRunnerDescription);
422  platform_task_runner.user_data = self;
423  platform_task_runner.runs_task_on_current_thread_callback =
425  platform_task_runner.post_task_callback = fl_engine_post_task;
426  platform_task_runner.identifier = kPlatformTaskRunnerIdentifier;
427 
428  FlutterCustomTaskRunners custom_task_runners = {};
429  custom_task_runners.struct_size = sizeof(FlutterCustomTaskRunners);
430  custom_task_runners.platform_task_runner = &platform_task_runner;
431  custom_task_runners.render_task_runner = &platform_task_runner;
432 
433  g_autoptr(GPtrArray) command_line_args =
434  fl_dart_project_get_switches(self->project);
435  // FlutterProjectArgs expects a full argv, so when processing it for flags
436  // the first item is treated as the executable and ignored. Add a dummy value
437  // so that all switches are used.
438  g_ptr_array_insert(command_line_args, 0, g_strdup("flutter"));
439 
440  gchar** dart_entrypoint_args =
442 
444  args.struct_size = sizeof(FlutterProjectArgs);
445  args.assets_path = fl_dart_project_get_assets_path(self->project);
446  args.icu_data_path = fl_dart_project_get_icu_data_path(self->project);
447  args.command_line_argc = command_line_args->len;
448  args.command_line_argv =
449  reinterpret_cast<const char* const*>(command_line_args->pdata);
452  args.custom_task_runners = &custom_task_runners;
453  args.shutdown_dart_vm_when_done = true;
455  args.dart_entrypoint_argc =
456  dart_entrypoint_args != nullptr ? g_strv_length(dart_entrypoint_args) : 0;
457  args.dart_entrypoint_argv =
458  reinterpret_cast<const char* const*>(dart_entrypoint_args);
459 
460  FlutterCompositor compositor = {};
461  compositor.struct_size = sizeof(FlutterCompositor);
462  compositor.user_data = self->renderer;
463  compositor.create_backing_store_callback =
465  compositor.collect_backing_store_callback =
468  args.compositor = &compositor;
469 
470  if (self->embedder_api.RunsAOTCompiledDartCode()) {
471  FlutterEngineAOTDataSource source = {};
473  source.elf_path = fl_dart_project_get_aot_library_path(self->project);
474  if (self->embedder_api.CreateAOTData(&source, &self->aot_data) !=
475  kSuccess) {
477  "Failed to create AOT data");
478  return FALSE;
479  }
480  args.aot_data = self->aot_data;
481  }
482 
483  FlutterEngineResult result = self->embedder_api.Initialize(
484  FLUTTER_ENGINE_VERSION, &config, &args, self, &self->engine);
485  if (result != kSuccess) {
487  "Failed to initialize Flutter engine");
488  return FALSE;
489  }
490 
491  result = self->embedder_api.RunInitialized(self->engine);
492  if (result != kSuccess) {
494  "Failed to run Flutter engine");
495  return FALSE;
496  }
497 
498  setup_locales(self);
499 
500  self->settings_plugin = fl_settings_plugin_new(self->binary_messenger);
501  fl_settings_plugin_start(self->settings_plugin);
502 
503  result = self->embedder_api.UpdateSemanticsEnabled(self->engine, TRUE);
504  if (result != kSuccess)
505  g_warning("Failed to enable accessibility features on Flutter engine");
506 
507  return TRUE;
508 }
static void fl_engine_post_task(FlutterTask task, uint64_t target_time_nanos, void *user_data)
Definition: fl_engine.cc:252
G_BEGIN_DECLS FlValue * args
G_MODULE_EXPORT const gchar * fl_dart_project_get_icu_data_path(FlDartProject *self)
const FlutterCompositor * compositor
Definition: embedder.h:1528
static bool fl_engine_gl_external_texture_frame_callback(void *user_data, int64_t texture_id, size_t width, size_t height, FlutterOpenGLTexture *texture)
Definition: fl_engine.cc:226
static bool compositor_create_backing_store_callback(const FlutterBackingStoreConfig *config, FlutterBackingStore *backing_store_out, void *user_data)
Definition: fl_engine.cc:147
static bool compositor_collect_backing_store_callback(const FlutterBackingStore *renderer, void *user_data)
Definition: fl_engine.cc:157
const uint8_t uint32_t uint32_t GError ** error
const FlutterTaskRunnerDescription * render_task_runner
Definition: embedder.h:948
const char * icu_data_path
Definition: embedder.h:1378
size_t struct_size
The size of this struct. Must be sizeof(FlutterTaskRunnerDescription).
Definition: embedder.h:913
const FlutterCustomTaskRunners * custom_task_runners
Definition: embedder.h:1493
G_MODULE_EXPORT gchar ** fl_dart_project_get_dart_entrypoint_arguments(FlDartProject *self)
G_MODULE_EXPORT const gchar * fl_dart_project_get_aot_library_path(FlDartProject *self)
FlTaskRunner * fl_task_runner_new(FlEngine *engine)
OnPreEngineRestartCallback on_pre_engine_restart_callback
Definition: embedder.h:1591
GPtrArray * fl_dart_project_get_switches(FlDartProject *self)
GAsyncResult * result
static bool fl_engine_gl_make_resource_current(void *user_data)
Definition: fl_engine.cc:215
FlutterPlatformMessageCallback platform_message_callback
Definition: embedder.h:1402
static void setup_locales(FlEngine *self)
Definition: fl_engine.cc:106
static void fl_engine_platform_message_cb(const FlutterPlatformMessage *message, void *user_data)
Definition: fl_engine.cc:261
const char *const * command_line_argv
Definition: embedder.h:1396
static bool fl_engine_gl_clear_current(void *user_data)
Definition: fl_engine.cc:190
bool shutdown_dart_vm_when_done
Definition: embedder.h:1512
const char *const * dart_entrypoint_argv
Definition: embedder.h:1566
static bool fl_engine_gl_present(void *user_data)
Definition: fl_engine.cc:205
#define FLUTTER_ENGINE_VERSION
Definition: embedder.h:63
FlutterRendererType type
Definition: embedder.h:555
FlutterUpdateSemanticsNodeCallback update_semantics_node_callback
Definition: embedder.h:1446
size_t struct_size
The size of this struct. Must be sizeof(FlutterOpenGLRendererConfig).
Definition: embedder.h:388
static void fl_engine_update_semantics_node_cb(const FlutterSemanticsNode *node, void *user_data)
Definition: fl_engine.cc:281
BoolCallback make_resource_current
Definition: embedder.h:407
BoolCallback clear_current
Definition: embedder.h:390
TextureFrameCallback gl_external_texture_frame_callback
Definition: embedder.h:429
static constexpr size_t kPlatformTaskRunnerIdentifier
Definition: fl_engine.cc:23
void fl_settings_plugin_start(FlSettingsPlugin *self)
static bool fl_engine_gl_make_current(void *user_data)
Definition: fl_engine.cc:180
FlutterBackingStoreCollectCallback collect_backing_store_callback
Definition: embedder.h:1142
static void fl_engine_on_pre_engine_restart_cb(void *user_data)
Definition: fl_engine.cc:296
const char * assets_path
Definition: embedder.h:1354
BoolCallback make_current
Definition: embedder.h:389
FlutterOpenGLRendererConfig open_gl
Definition: embedder.h:557
FlutterEngineResult
Definition: embedder.h:65
size_t struct_size
The size of this struct. Must be sizeof(FlutterProjectArgs).
Definition: embedder.h:1350
FlSettingsPlugin * fl_settings_plugin_new(FlBinaryMessenger *messenger)
FlutterLayersPresentCallback present_layers_callback
Definition: embedder.h:1145
UIntCallback fbo_callback
Definition: embedder.h:400
const FlutterTaskRunnerDescription * platform_task_runner
Definition: embedder.h:943
static bool fl_engine_runs_task_on_current_thread(void *user_data)
Definition: fl_engine.cc:246
FlutterTaskRunnerPostTaskCallback post_task_callback
Definition: embedder.h:930
size_t struct_size
This size of this struct. Must be sizeof(FlutterCompositor).
Definition: embedder.h:1126
FlutterEngineAOTDataSourceType type
Definition: embedder.h:1326
FlutterEngineAOTData aot_data
Definition: embedder.h:1543
static uint32_t fl_engine_gl_get_fbo(void *user_data)
Definition: fl_engine.cc:200
return FALSE
ProcResolver gl_proc_resolver
Definition: embedder.h:424
size_t struct_size
The size of this struct. Must be sizeof(FlutterCustomTaskRunners).
Definition: embedder.h:938
G_MODULE_EXPORT const gchar * fl_dart_project_get_assets_path(FlDartProject *self)
BoolCallback runs_task_on_current_thread_callback
Definition: embedder.h:919
GQuark fl_engine_error_quark(void) G_GNUC_CONST
int command_line_argc
The command line argument count used to initialize the project.
Definition: embedder.h:1380
const char * elf_path
Absolute path to an ELF library file.
Definition: embedder.h:1329
static bool compositor_present_layers_callback(const FlutterLayer **layers, size_t layers_count, void *user_data)
Definition: fl_engine.cc:165
static void * fl_engine_gl_proc_resolver(void *user_data, const char *name)
Definition: fl_engine.cc:175
FlutterBackingStoreCreateCallback create_backing_store_callback
Definition: embedder.h:1139

◆ fl_engine_unregister_external_texture()

gboolean fl_engine_unregister_external_texture ( FlEngine *  engine,
int64_t  texture_id 
)

fl_engine_unregister_external_texture: : an #FlEngine. : 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 762 of file fl_engine.cc.

References FALSE, and kSuccess.

Referenced by fl_texture_registrar_unregister_texture().

763  {
764  g_return_val_if_fail(FL_IS_ENGINE(self), FALSE);
765  return self->embedder_api.UnregisterExternalTexture(self->engine,
766  texture_id) == kSuccess;
767 }
int64_t texture_id
return FALSE