Flutter Engine
fl_engine.cc File Reference
#include "flutter/shell/platform/linux/public/flutter_linux/fl_engine.h"
#include <gmodule.h>
#include <cstring>
#include "flutter/shell/platform/embedder/embedder.h"
#include "flutter/shell/platform/linux/fl_binary_messenger_private.h"
#include "flutter/shell/platform/linux/fl_dart_project_private.h"
#include "flutter/shell/platform/linux/fl_engine_private.h"
#include "flutter/shell/platform/linux/fl_plugin_registrar_private.h"
#include "flutter/shell/platform/linux/fl_renderer.h"
#include "flutter/shell/platform/linux/fl_renderer_headless.h"
#include "flutter/shell/platform/linux/fl_settings_plugin.h"
#include "flutter/shell/platform/linux/fl_texture_registrar_private.h"
#include "flutter/shell/platform/linux/public/flutter_linux/fl_plugin_registry.h"

Go to the source code of this file.

Classes

struct  _FlEngine
 

Functions

static void fl_engine_plugin_registry_iface_init (FlPluginRegistryInterface *iface)
 
 G_DEFINE_TYPE_WITH_CODE (FlEngine, fl_engine, G_TYPE_OBJECT, G_IMPLEMENT_INTERFACE(fl_plugin_registry_get_type(), fl_engine_plugin_registry_iface_init)) static void parse_locale(const gchar *locale
 
 if (match !=nullptr)
 
static void setup_locales (FlEngine *self)
 
static bool compositor_create_backing_store_callback (const FlutterBackingStoreConfig *config, FlutterBackingStore *backing_store_out, void *user_data)
 
static bool compositor_collect_backing_store_callback (const FlutterBackingStore *renderer, void *user_data)
 
static bool compositor_present_layers_callback (const FlutterLayer **layers, size_t layers_count, void *user_data)
 
static void * fl_engine_gl_proc_resolver (void *user_data, const char *name)
 
static bool fl_engine_gl_make_current (void *user_data)
 
static bool fl_engine_gl_clear_current (void *user_data)
 
static uint32_t fl_engine_gl_get_fbo (void *user_data)
 
static bool fl_engine_gl_present (void *user_data)
 
static bool fl_engine_gl_make_resource_current (void *user_data)
 
static bool fl_engine_gl_external_texture_frame_callback (void *user_data, int64_t texture_id, size_t width, size_t height, FlutterOpenGLTexture *texture)
 
static bool fl_engine_runs_task_on_current_thread (void *user_data)
 
static void fl_engine_post_task (FlutterTask task, uint64_t target_time_nanos, void *user_data)
 
static void fl_engine_platform_message_cb (const FlutterPlatformMessage *message, void *user_data)
 
static void fl_engine_update_semantics_node_cb (const FlutterSemanticsNode *node, void *user_data)
 
static void fl_engine_on_pre_engine_restart_cb (void *user_data)
 
static void fl_engine_platform_message_response_cb (const uint8_t *data, size_t data_length, void *user_data)
 
static FlPluginRegistrar * fl_engine_get_registrar_for_plugin (FlPluginRegistry *registry, const gchar *name)
 
static void fl_engine_dispose (GObject *object)
 
static void fl_engine_class_init (FlEngineClass *klass)
 
static void fl_engine_init (FlEngine *self)
 
FlEngine * fl_engine_new (FlDartProject *project, FlRenderer *renderer)
 
G_MODULE_EXPORT FlEngine * fl_engine_new_headless (FlDartProject *project)
 
gboolean fl_engine_start (FlEngine *self, GError **error)
 
FlutterEngineProcTablefl_engine_get_embedder_api (FlEngine *self)
 
void fl_engine_set_platform_message_handler (FlEngine *self, FlEnginePlatformMessageHandler handler, gpointer user_data, GDestroyNotify destroy_notify)
 
void fl_engine_set_update_semantics_node_handler (FlEngine *self, FlEngineUpdateSemanticsNodeHandler handler, gpointer user_data, GDestroyNotify destroy_notify)
 
void fl_engine_set_on_pre_engine_restart_handler (FlEngine *self, FlEngineOnPreEngineRestartHandler handler, gpointer user_data, GDestroyNotify destroy_notify)
 
gboolean fl_engine_send_platform_message_response (FlEngine *self, const FlutterPlatformMessageResponseHandle *handle, GBytes *response, GError **error)
 
void fl_engine_send_platform_message (FlEngine *self, const gchar *channel, GBytes *message, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data)
 
GBytes * fl_engine_send_platform_message_finish (FlEngine *self, GAsyncResult *result, GError **error)
 
void fl_engine_send_window_metrics_event (FlEngine *self, size_t width, size_t height, double pixel_ratio)
 
void fl_engine_send_mouse_pointer_event (FlEngine *self, 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 *self, const FlutterKeyEvent *event, FlutterKeyEventCallback callback, void *user_data)
 
void fl_engine_dispatch_semantics_action (FlEngine *self, uint64_t id, FlutterSemanticsAction action, GBytes *data)
 
gboolean fl_engine_mark_texture_frame_available (FlEngine *self, int64_t texture_id)
 
gboolean fl_engine_register_external_texture (FlEngine *self, int64_t texture_id)
 
gboolean fl_engine_unregister_external_texture (FlEngine *self, int64_t texture_id)
 
G_MODULE_EXPORT FlBinaryMessenger * fl_engine_get_binary_messenger (FlEngine *self)
 
FlTaskRunner * fl_engine_get_task_runner (FlEngine *self)
 
void fl_engine_execute_task (FlEngine *self, FlutterTask *task)
 
G_MODULE_EXPORT FlTextureRegistrar * fl_engine_get_texture_registrar (FlEngine *self)
 

Variables

static constexpr size_t kPlatformTaskRunnerIdentifier = 1
 
gchar ** language = l
 
gchar gchar ** territory
 
gchar gchar gchar ** codeset
 
gchar gchar gchar gchar ** modifier
 
gchar * match = strrchr(l, '@')
 
 else
 

Function Documentation

◆ compositor_collect_backing_store_callback()

static bool compositor_collect_backing_store_callback ( const FlutterBackingStore renderer,
void *  user_data 
)
static

Definition at line 157 of file fl_engine.cc.

References fl_renderer_collect_backing_store().

Referenced by fl_engine_start().

159  {
160  g_return_val_if_fail(FL_IS_RENDERER(user_data), false);
161  return fl_renderer_collect_backing_store(FL_RENDERER(user_data), renderer);
162 }
void * user_data
gboolean fl_renderer_collect_backing_store(FlRenderer *self, const FlutterBackingStore *backing_store)
Definition: fl_renderer.cc:136

◆ compositor_create_backing_store_callback()

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

Definition at line 147 of file fl_engine.cc.

References fl_renderer_create_backing_store().

Referenced by fl_engine_start().

150  {
151  g_return_val_if_fail(FL_IS_RENDERER(user_data), false);
152  return fl_renderer_create_backing_store(FL_RENDERER(user_data), config,
153  backing_store_out);
154 }
void * user_data
gboolean fl_renderer_create_backing_store(FlRenderer *self, const FlutterBackingStoreConfig *config, FlutterBackingStore *backing_store_out)
Definition: fl_renderer.cc:128

◆ compositor_present_layers_callback()

static bool compositor_present_layers_callback ( const FlutterLayer **  layers,
size_t  layers_count,
void *  user_data 
)
static

Definition at line 165 of file fl_engine.cc.

References fl_renderer_present_layers().

Referenced by fl_engine_start().

167  {
168  g_return_val_if_fail(FL_IS_RENDERER(user_data), false);
169  return fl_renderer_present_layers(FL_RENDERER(user_data), layers,
170  layers_count);
171 }
void * user_data
gboolean fl_renderer_present_layers(FlRenderer *self, const FlutterLayer **layers, size_t layers_count)
Definition: fl_renderer.cc:160

◆ fl_engine_class_init()

static void fl_engine_class_init ( FlEngineClass *  klass)
static

Definition at line 374 of file fl_engine.cc.

References fl_engine_dispose().

374  {
375  G_OBJECT_CLASS(klass)->dispose = fl_engine_dispose;
376 }
static void fl_engine_dispose(GObject *object)
Definition: fl_engine.cc:330

◆ 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_dispose()

static void fl_engine_dispose ( GObject *  object)
static

Definition at line 330 of file fl_engine.cc.

Referenced by fl_engine_class_init().

330  {
331  FlEngine* self = FL_ENGINE(object);
332 
333  if (self->engine != nullptr) {
334  self->embedder_api.Shutdown(self->engine);
335  self->engine = nullptr;
336  }
337 
338  if (self->aot_data != nullptr) {
339  self->embedder_api.CollectAOTData(self->aot_data);
340  self->aot_data = nullptr;
341  }
342 
343  g_clear_object(&self->project);
344  g_clear_object(&self->renderer);
345  g_clear_object(&self->texture_registrar);
346  g_clear_object(&self->binary_messenger);
347  g_clear_object(&self->settings_plugin);
348  g_clear_object(&self->task_runner);
349 
350  if (self->platform_message_handler_destroy_notify) {
351  self->platform_message_handler_destroy_notify(
352  self->platform_message_handler_data);
353  }
354  self->platform_message_handler_data = nullptr;
355  self->platform_message_handler_destroy_notify = nullptr;
356 
357  if (self->update_semantics_node_handler_destroy_notify) {
358  self->update_semantics_node_handler_destroy_notify(
359  self->update_semantics_node_handler_data);
360  }
361  self->update_semantics_node_handler_data = nullptr;
362  self->update_semantics_node_handler_destroy_notify = nullptr;
363 
364  if (self->on_pre_engine_restart_handler_destroy_notify) {
365  self->on_pre_engine_restart_handler_destroy_notify(
366  self->on_pre_engine_restart_handler_data);
367  }
368  self->on_pre_engine_restart_handler_data = nullptr;
369  self->on_pre_engine_restart_handler_destroy_notify = nullptr;
370 
371  G_OBJECT_CLASS(fl_engine_parent_class)->dispose(object);
372 }

◆ 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_binary_messenger()

G_MODULE_EXPORT FlBinaryMessenger* fl_engine_get_binary_messenger ( FlEngine *  engine)

fl_engine_get_binary_messenger: : an #FlEngine.

Gets the messenger to communicate with this engine.

Returns: an #FlBinaryMessenger.

Definition at line 769 of file fl_engine.cc.

Referenced by fl_view_constructed(), fl_view_get_registrar_for_plugin(), and fl_view_init_keyboard().

770  {
771  g_return_val_if_fail(FL_IS_ENGINE(self), nullptr);
772  return self->binary_messenger;
773 }

◆ 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_registrar_for_plugin()

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

Definition at line 316 of file fl_engine.cc.

References fl_plugin_registrar_new().

Referenced by fl_engine_plugin_registry_iface_init().

318  {
319  FlEngine* self = FL_ENGINE(registry);
320 
321  return fl_plugin_registrar_new(nullptr, self->binary_messenger,
322  self->texture_registrar);
323 }
FlPluginRegistrar * fl_plugin_registrar_new(FlView *view, FlBinaryMessenger *messenger, FlTextureRegistrar *texture_registrar)

◆ 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_get_texture_registrar()

G_MODULE_EXPORT FlTextureRegistrar* fl_engine_get_texture_registrar ( FlEngine *  engine)

fl_engine_get_texture_registrar: : an #FlEngine.

Gets the texture registrar for registering textures.

Returns: an #FlTextureRegistrar.

Definition at line 785 of file fl_engine.cc.

Referenced by fl_view_get_registrar_for_plugin().

786  {
787  g_return_val_if_fail(FL_IS_ENGINE(self), nullptr);
788  return self->texture_registrar;
789 }

◆ fl_engine_gl_clear_current()

static bool fl_engine_gl_clear_current ( void *  user_data)
static

Definition at line 190 of file fl_engine.cc.

References error, fl_renderer_clear_current(), result, and user_data.

Referenced by fl_engine_start().

190  {
191  FlEngine* self = static_cast<FlEngine*>(user_data);
192  g_autoptr(GError) error = nullptr;
193  gboolean result = fl_renderer_clear_current(self->renderer, &error);
194  if (!result) {
195  g_warning("%s", error->message);
196  }
197  return result;
198 }
gboolean fl_renderer_clear_current(FlRenderer *self, GError **error)
Definition: fl_renderer.cc:114
const uint8_t uint32_t uint32_t GError ** error
void * user_data
GAsyncResult * result

◆ fl_engine_gl_external_texture_frame_callback()

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

Definition at line 226 of file fl_engine.cc.

References error, fl_texture_registrar_populate_gl_external_texture(), result, and user_data.

Referenced by fl_engine_start().

231  {
232  FlEngine* self = static_cast<FlEngine*>(user_data);
233  if (!self->texture_registrar) {
234  return false;
235  }
236  g_autoptr(GError) error = nullptr;
238  self->texture_registrar, texture_id, width, height, texture, &error);
239  if (!result) {
240  g_warning("%s", error->message);
241  }
242  return result;
243 }
gboolean fl_texture_registrar_populate_gl_external_texture(FlTextureRegistrar *self, int64_t texture_id, uint32_t width, uint32_t height, FlutterOpenGLTexture *opengl_texture, GError **error)
const uint8_t uint32_t uint32_t GError ** error
void * user_data
int64_t texture_id
GAsyncResult * result
int32_t width
int32_t height

◆ fl_engine_gl_get_fbo()

static uint32_t fl_engine_gl_get_fbo ( void *  user_data)
static

Definition at line 200 of file fl_engine.cc.

References fl_renderer_get_fbo(), and user_data.

Referenced by fl_engine_start().

200  {
201  FlEngine* self = static_cast<FlEngine*>(user_data);
202  return fl_renderer_get_fbo(self->renderer);
203 }
void * user_data
guint32 fl_renderer_get_fbo(FlRenderer *self)
Definition: fl_renderer.cc:119

◆ fl_engine_gl_make_current()

static bool fl_engine_gl_make_current ( void *  user_data)
static

Definition at line 180 of file fl_engine.cc.

References error, fl_renderer_make_current(), result, and user_data.

Referenced by fl_engine_start().

180  {
181  FlEngine* self = static_cast<FlEngine*>(user_data);
182  g_autoptr(GError) error = nullptr;
183  gboolean result = fl_renderer_make_current(self->renderer, &error);
184  if (!result) {
185  g_warning("%s", error->message);
186  }
187  return result;
188 }
gboolean fl_renderer_make_current(FlRenderer *self, GError **error)
Definition: fl_renderer.cc:94
const uint8_t uint32_t uint32_t GError ** error
void * user_data
GAsyncResult * result

◆ fl_engine_gl_make_resource_current()

static bool fl_engine_gl_make_resource_current ( void *  user_data)
static

Definition at line 215 of file fl_engine.cc.

References error, fl_renderer_make_resource_current(), result, and user_data.

Referenced by fl_engine_start().

215  {
216  FlEngine* self = static_cast<FlEngine*>(user_data);
217  g_autoptr(GError) error = nullptr;
218  gboolean result = fl_renderer_make_resource_current(self->renderer, &error);
219  if (!result) {
220  g_warning("%s", error->message);
221  }
222  return result;
223 }
const uint8_t uint32_t uint32_t GError ** error
gboolean fl_renderer_make_resource_current(FlRenderer *self, GError **error)
Definition: fl_renderer.cc:104
void * user_data
GAsyncResult * result

◆ fl_engine_gl_present()

static bool fl_engine_gl_present ( void *  user_data)
static

Definition at line 205 of file fl_engine.cc.

References error, fl_renderer_present(), result, and user_data.

Referenced by fl_engine_start().

205  {
206  FlEngine* self = static_cast<FlEngine*>(user_data);
207  g_autoptr(GError) error = nullptr;
208  gboolean result = fl_renderer_present(self->renderer, &error);
209  if (!result) {
210  g_warning("%s", error->message);
211  }
212  return result;
213 }
const uint8_t uint32_t uint32_t GError ** error
void * user_data
GAsyncResult * result
gboolean fl_renderer_present(FlRenderer *self, GError **error)
Definition: fl_renderer.cc:124

◆ fl_engine_gl_proc_resolver()

static void* fl_engine_gl_proc_resolver ( void *  user_data,
const char *  name 
)
static

Definition at line 175 of file fl_engine.cc.

References fl_renderer_get_proc_address(), and user_data.

Referenced by fl_engine_start().

175  {
176  FlEngine* self = static_cast<FlEngine*>(user_data);
177  return fl_renderer_get_proc_address(self->renderer, name);
178 }
void * user_data
void * fl_renderer_get_proc_address(FlRenderer *self, const char *name)
Definition: fl_renderer.cc:90
const char * name
Definition: fuchsia.cc:50

◆ fl_engine_init()

static void fl_engine_init ( FlEngine *  self)
static

Definition at line 378 of file fl_engine.cc.

References fl_binary_messenger_new(), fl_texture_registrar_new(), and FlutterEngineGetProcAddresses().

378  {
379  self->thread = g_thread_self();
380 
381  self->embedder_api.struct_size = sizeof(FlutterEngineProcTable);
382  FlutterEngineGetProcAddresses(&self->embedder_api);
383 
384  self->texture_registrar = fl_texture_registrar_new(self);
385  self->binary_messenger = fl_binary_messenger_new(self);
386 }
Function-pointer-based versions of the APIs above.
Definition: embedder.h:2372
FlutterEngineResult FlutterEngineGetProcAddresses(FlutterEngineProcTable *table)
Gets the table of engine function pointers.
Definition: embedder.cc:2291
FlTextureRegistrar * fl_texture_registrar_new(FlEngine *engine)
FlBinaryMessenger * fl_binary_messenger_new(FlEngine *engine)

◆ 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_new_headless()

G_MODULE_EXPORT FlEngine* fl_engine_new_headless ( FlDartProject *  project)

FlEngine:

#FlEngine is an object that contains a running Flutter engine. fl_engine_new_headless: : an #FlDartProject.

Creates new Flutter engine running in headless mode.

Returns: a new #FlEngine.

Definition at line 398 of file fl_engine.cc.

References fl_engine_new(), fl_renderer_headless_new(), and _FlEngine::renderer.

398  {
399  g_autoptr(FlRendererHeadless) renderer = fl_renderer_headless_new();
400  return fl_engine_new(project, FL_RENDERER(renderer));
401 }
FlRendererHeadless * fl_renderer_headless_new()
FlEngine * fl_engine_new(FlDartProject *project, FlRenderer *renderer)
Definition: fl_engine.cc:388

◆ fl_engine_on_pre_engine_restart_cb()

static void fl_engine_on_pre_engine_restart_cb ( void *  user_data)
static

Definition at line 296 of file fl_engine.cc.

Referenced by fl_engine_start().

296  {
297  FlEngine* self = FL_ENGINE(user_data);
298 
299  if (self->on_pre_engine_restart_handler != nullptr) {
300  self->on_pre_engine_restart_handler(
301  self, self->on_pre_engine_restart_handler_data);
302  }
303 }
void * user_data

◆ fl_engine_platform_message_cb()

static void fl_engine_platform_message_cb ( const FlutterPlatformMessage message,
void *  user_data 
)
static

Definition at line 261 of file fl_engine.cc.

References FlutterPlatformMessage::channel, FALSE, fl_engine_send_platform_message_response(), FlutterPlatformMessage::message, FlutterPlatformMessage::message_size, and FlutterPlatformMessage::response_handle.

Referenced by fl_engine_start().

262  {
263  FlEngine* self = FL_ENGINE(user_data);
264 
265  gboolean handled = FALSE;
266  if (self->platform_message_handler != nullptr) {
267  g_autoptr(GBytes) data =
268  g_bytes_new(message->message, message->message_size);
269  handled = self->platform_message_handler(
270  self, message->channel, data, message->response_handle,
271  self->platform_message_handler_data);
272  }
273 
274  if (!handled) {
276  nullptr, nullptr);
277  }
278 }
const char * channel
Definition: embedder.h:758
const FlutterPlatformMessageResponseHandle * response_handle
Definition: embedder.h:767
void * user_data
const uint8_t * message
Definition: embedder.h:759
gboolean fl_engine_send_platform_message_response(FlEngine *self, const FlutterPlatformMessageResponseHandle *handle, GBytes *response, GError **error)
Definition: fl_engine.cc:566
return FALSE

◆ fl_engine_platform_message_response_cb()

static void fl_engine_platform_message_response_cb ( const uint8_t *  data,
size_t  data_length,
void *  user_data 
)
static

Definition at line 307 of file fl_engine.cc.

Referenced by fl_engine_send_platform_message().

309  {
310  g_autoptr(GTask) task = G_TASK(user_data);
311  g_task_return_pointer(task, g_bytes_new(data, data_length),
312  reinterpret_cast<GDestroyNotify>(g_bytes_unref));
313 }
void * user_data

◆ fl_engine_plugin_registry_iface_init()

static void fl_engine_plugin_registry_iface_init ( FlPluginRegistryInterface *  iface)
static

Definition at line 325 of file fl_engine.cc.

References fl_engine_get_registrar_for_plugin().

326  {
327  iface->get_registrar_for_plugin = fl_engine_get_registrar_for_plugin;
328 }
static FlPluginRegistrar * fl_engine_get_registrar_for_plugin(FlPluginRegistry *registry, const gchar *name)
Definition: fl_engine.cc:316

◆ fl_engine_post_task()

static void fl_engine_post_task ( FlutterTask  task,
uint64_t  target_time_nanos,
void *  user_data 
)
static

Definition at line 252 of file fl_engine.cc.

References fl_task_runner_post_task(), and user_data.

Referenced by fl_engine_start().

254  {
255  FlEngine* self = static_cast<FlEngine*>(user_data);
256 
257  fl_task_runner_post_task(self->task_runner, task, target_time_nanos);
258 }
void * user_data
void fl_task_runner_post_task(FlTaskRunner *self, FlutterTask task, uint64_t target_time_nanos)

◆ 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_runs_task_on_current_thread()

static bool fl_engine_runs_task_on_current_thread ( void *  user_data)
static

Definition at line 246 of file fl_engine.cc.

References user_data.

Referenced by fl_engine_start().

246  {
247  FlEngine* self = static_cast<FlEngine*>(user_data);
248  return self->thread == g_thread_self();
249 }
void * user_data

◆ 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

◆ fl_engine_update_semantics_node_cb()

static void fl_engine_update_semantics_node_cb ( const FlutterSemanticsNode node,
void *  user_data 
)
static

Definition at line 281 of file fl_engine.cc.

Referenced by fl_engine_start().

282  {
283  FlEngine* self = FL_ENGINE(user_data);
284 
285  if (self->update_semantics_node_handler != nullptr) {
286  self->update_semantics_node_handler(
287  self, node, self->update_semantics_node_handler_data);
288  }
289 }
void * user_data

◆ G_DEFINE_TYPE_WITH_CODE()

G_DEFINE_TYPE_WITH_CODE ( FlEngine  ,
fl_engine  ,
G_TYPE_OBJECT  ,
G_IMPLEMENT_INTERFACE(fl_plugin_registry_get_type(), fl_engine_plugin_registry_iface_init  
) const

◆ if()

if ( match = nullptr)

Definition at line 79 of file fl_engine.cc.

Referenced by flutter::FlutterWindowsEngine::FlutterWindowsEngine(), txt::ParagraphTxt::GetGlyphPositionAtCoordinate(), flutter::normalizeScancode(), and txt::ParagraphTxt::Paint().

79  {
80  *modifier = g_strdup(match + 1);
81  *match = '\0';
82  } else {
gchar * match
Definition: fl_engine.cc:78
gchar gchar gchar gchar ** modifier
Definition: fl_engine.cc:74

◆ setup_locales()

static void setup_locales ( FlEngine *  self)
static

Definition at line 106 of file fl_engine.cc.

References codeset, FlutterLocale::country_code, kSuccess, language, FlutterLocale::language_code, modifier, result, FlutterLocale::script_code, FlutterLocale::struct_size, territory, and FlutterLocale::variant_code.

Referenced by fl_engine_start().

106  {
107  const gchar* const* languages = g_get_language_names();
108  g_autoptr(GPtrArray) locales_array = g_ptr_array_new_with_free_func(g_free);
109  // Helper array to take ownership of the strings passed to Flutter.
110  g_autoptr(GPtrArray) locale_strings = g_ptr_array_new_with_free_func(g_free);
111  for (int i = 0; languages[i] != nullptr; i++) {
112  gchar *language, *territory, *codeset, *modifier;
113  parse_locale(languages[i], &language, &territory, &codeset, &modifier);
114  if (language != nullptr) {
115  g_ptr_array_add(locale_strings, language);
116  }
117  if (territory != nullptr) {
118  g_ptr_array_add(locale_strings, territory);
119  }
120  if (codeset != nullptr) {
121  g_ptr_array_add(locale_strings, codeset);
122  }
123  if (modifier != nullptr) {
124  g_ptr_array_add(locale_strings, modifier);
125  }
126 
127  FlutterLocale* locale =
128  static_cast<FlutterLocale*>(g_malloc0(sizeof(FlutterLocale)));
129  g_ptr_array_add(locales_array, locale);
130  locale->struct_size = sizeof(FlutterLocale);
131  locale->language_code = language;
132  locale->country_code = territory;
133  locale->script_code = codeset;
134  locale->variant_code = modifier;
135  }
136  FlutterLocale** locales =
137  reinterpret_cast<FlutterLocale**>(locales_array->pdata);
138  FlutterEngineResult result = self->embedder_api.UpdateLocales(
139  self->engine, const_cast<const FlutterLocale**>(locales),
140  locales_array->len);
141  if (result != kSuccess) {
142  g_warning("Failed to set up Flutter locales");
143  }
144 }
size_t struct_size
This size of this struct. Must be sizeof(FlutterLocale).
Definition: embedder.h:1152
const char * variant_code
Definition: embedder.h:1171
GAsyncResult * result
const char * script_code
Definition: embedder.h:1166
const char * country_code
Definition: embedder.h:1161
gchar gchar gchar gchar ** modifier
Definition: fl_engine.cc:74
gchar ** language
Definition: fl_engine.cc:71
FlutterEngineResult
Definition: embedder.h:65
gchar gchar gchar ** codeset
Definition: fl_engine.cc:71
gchar gchar ** territory
Definition: fl_engine.cc:71
const char * language_code
Definition: embedder.h:1156

Variable Documentation

◆ codeset

gchar gchar gchar** codeset

Definition at line 71 of file fl_engine.cc.

Referenced by setup_locales().

◆ else

else
Initial value:
{
*modifier = nullptr
gchar gchar gchar gchar ** modifier
Definition: fl_engine.cc:74

Definition at line 82 of file fl_engine.cc.

◆ kPlatformTaskRunnerIdentifier

constexpr size_t kPlatformTaskRunnerIdentifier = 1
static

Definition at line 23 of file fl_engine.cc.

Referenced by fl_engine_start().

◆ language

◆ match

match = strrchr(l, '@')

Definition at line 78 of file fl_engine.cc.

Referenced by txt::FontCollection::MatchFallbackFont().

◆ modifier

gchar gchar gchar gchar** modifier
Initial value:
{
gchar* l = g_strdup(locale)

Definition at line 74 of file fl_engine.cc.

Referenced by setup_locales(), and flutter::testing::TEST().

◆ territory

gchar gchar** territory

Definition at line 71 of file fl_engine.cc.

Referenced by setup_locales().