Flutter Linux Embedder
fl_engine.cc
Go to the documentation of this file.
1 // Copyright 2013 The Flutter Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
6 
7 #include <gmodule.h>
8 
9 #include <cstring>
10 #include <string>
11 #include <vector>
12 
13 #include "flutter/common/constants.h"
15 #include "flutter/shell/platform/embedder/embedder.h"
28 
29 // Unique number associated with platform tasks.
30 static constexpr size_t kPlatformTaskRunnerIdentifier = 1;
31 
32 // Use different device ID for mouse and pan/zoom events, since we can't
33 // differentiate the actual device (mouse v.s. trackpad)
34 static constexpr int32_t kMousePointerDeviceId = 0;
35 static constexpr int32_t kPointerPanZoomDeviceId = 1;
36 
37 struct _FlEngine {
38  GObject parent_instance;
39 
40  // Thread the GLib main loop is running on.
41  GThread* thread;
42 
43  FlDartProject* project;
44  FlRenderer* renderer;
45  FlBinaryMessenger* binary_messenger;
46  FlSettingsHandler* settings_handler;
47  FlTextureRegistrar* texture_registrar;
48  FlTaskRunner* task_runner;
49  FlutterEngineAOTData aot_data;
50  FLUTTER_API_SYMBOL(FlutterEngine) engine;
51  FlutterEngineProcTable embedder_api;
52 
53  // Next ID to use for a view.
54  FlutterViewId next_view_id;
55 
56  // Function to call when a platform message is received.
60 
61  // Function to call when a semantic node is received.
65 };
66 
67 G_DEFINE_QUARK(fl_engine_error_quark, fl_engine_error)
68 
70  FlPluginRegistryInterface* iface);
71 
73 
75 
77  FlEngine,
78  fl_engine,
79  G_TYPE_OBJECT,
80  G_IMPLEMENT_INTERFACE(fl_plugin_registry_get_type(),
82 
83 enum { kProp0, kPropBinaryMessenger, kPropLast };
84 
85 // Parse a locale into its components.
86 static void parse_locale(const gchar* locale,
87  gchar** language,
88  gchar** territory,
89  gchar** codeset,
90  gchar** modifier) {
91  gchar* l = g_strdup(locale);
92 
93  // Locales are in the form "language[_territory][.codeset][@modifier]"
94  gchar* match = strrchr(l, '@');
95  if (match != nullptr) {
96  if (modifier != nullptr) {
97  *modifier = g_strdup(match + 1);
98  }
99  *match = '\0';
100  } else if (modifier != nullptr) {
101  *modifier = nullptr;
102  }
103 
104  match = strrchr(l, '.');
105  if (match != nullptr) {
106  if (codeset != nullptr) {
107  *codeset = g_strdup(match + 1);
108  }
109  *match = '\0';
110  } else if (codeset != nullptr) {
111  *codeset = nullptr;
112  }
113 
114  match = strrchr(l, '_');
115  if (match != nullptr) {
116  if (territory != nullptr) {
117  *territory = g_strdup(match + 1);
118  }
119  *match = '\0';
120  } else if (territory != nullptr) {
121  *territory = nullptr;
122  }
123 
124  if (language != nullptr) {
125  *language = l;
126  }
127 }
128 
129 static void view_added_cb(const FlutterAddViewResult* result) {
130  g_autoptr(GTask) task = G_TASK(result->user_data);
131 
132  if (result->added) {
133  g_task_return_boolean(task, TRUE);
134  } else {
135  g_task_return_new_error(task, fl_engine_error_quark(),
136  FL_ENGINE_ERROR_FAILED, "Failed to add view");
137  }
138 }
139 
140 static void view_removed_cb(const FlutterRemoveViewResult* result) {
141  g_autoptr(GTask) task = G_TASK(result->user_data);
142 
143  if (result->removed) {
144  g_task_return_boolean(task, TRUE);
145  } else {
146  g_task_return_new_error(task, fl_engine_error_quark(),
147  FL_ENGINE_ERROR_FAILED, "Failed to remove view");
148  }
149 }
150 
151 static void free_locale(FlutterLocale* locale) {
152  free(const_cast<gchar*>(locale->language_code));
153  free(const_cast<gchar*>(locale->country_code));
154  free(locale);
155 }
156 
157 // Passes locale information to the Flutter engine.
158 static void setup_locales(FlEngine* self) {
159  const gchar* const* languages = g_get_language_names();
160  g_autoptr(GPtrArray) locales_array = g_ptr_array_new_with_free_func(
161  reinterpret_cast<GDestroyNotify>(free_locale));
162  for (int i = 0; languages[i] != nullptr; i++) {
163  g_autofree gchar* locale_string = g_strstrip(g_strdup(languages[i]));
164 
165  // Ignore empty locales, caused by settings like `LANGUAGE=pt_BR:`
166  if (strcmp(locale_string, "") == 0) {
167  continue;
168  }
169 
170  g_autofree gchar* language = nullptr;
171  g_autofree gchar* territory = nullptr;
172  parse_locale(locale_string, &language, &territory, nullptr, nullptr);
173 
174  // Ignore duplicate locales, caused by settings like `LANGUAGE=C` (returns
175  // two "C") or `LANGUAGE=en:en`
176  gboolean has_locale = FALSE;
177  for (guint j = 0; !has_locale && j < locales_array->len; j++) {
178  FlutterLocale* locale =
179  reinterpret_cast<FlutterLocale*>(g_ptr_array_index(locales_array, j));
180  has_locale = g_strcmp0(locale->language_code, language) == 0 &&
181  g_strcmp0(locale->country_code, territory) == 0;
182  }
183  if (has_locale) {
184  continue;
185  }
186 
187  FlutterLocale* locale =
188  static_cast<FlutterLocale*>(g_malloc0(sizeof(FlutterLocale)));
189  g_ptr_array_add(locales_array, locale);
190  locale->struct_size = sizeof(FlutterLocale);
191  locale->language_code =
192  reinterpret_cast<const gchar*>(g_steal_pointer(&language));
193  locale->country_code =
194  reinterpret_cast<const gchar*>(g_steal_pointer(&territory));
195  locale->script_code = nullptr;
196  locale->variant_code = nullptr;
197  }
198  FlutterLocale** locales =
199  reinterpret_cast<FlutterLocale**>(locales_array->pdata);
200  FlutterEngineResult result = self->embedder_api.UpdateLocales(
201  self->engine, const_cast<const FlutterLocale**>(locales),
202  locales_array->len);
203  if (result != kSuccess) {
204  g_warning("Failed to set up Flutter locales");
205  }
206 }
207 
208 // Called when engine needs a backing store for a specific #FlutterLayer.
210  const FlutterBackingStoreConfig* config,
211  FlutterBackingStore* backing_store_out,
212  void* user_data) {
213  g_return_val_if_fail(FL_IS_RENDERER(user_data), false);
214  return fl_renderer_create_backing_store(FL_RENDERER(user_data), config,
215  backing_store_out);
216 }
217 
218 // Called when the backing store is to be released.
220  const FlutterBackingStore* backing_store,
221  void* user_data) {
222  g_return_val_if_fail(FL_IS_RENDERER(user_data), false);
223  return fl_renderer_collect_backing_store(FL_RENDERER(user_data),
224  backing_store);
225 }
226 
227 // Called when embedder should composite contents of each layer onto the screen.
229  const FlutterPresentViewInfo* info) {
230  g_return_val_if_fail(FL_IS_RENDERER(info->user_data), false);
231  return fl_renderer_present_layers(FL_RENDERER(info->user_data), info->view_id,
232  info->layers, info->layers_count);
233 }
234 
235 // Flutter engine rendering callbacks.
236 
237 static void* fl_engine_gl_proc_resolver(void* user_data, const char* name) {
238  FlEngine* self = static_cast<FlEngine*>(user_data);
239  return fl_renderer_get_proc_address(self->renderer, name);
240 }
241 
243  FlEngine* self = static_cast<FlEngine*>(user_data);
244  fl_renderer_make_current(self->renderer);
245  return true;
246 }
247 
249  FlEngine* self = static_cast<FlEngine*>(user_data);
250  fl_renderer_clear_current(self->renderer);
251  return true;
252 }
253 
254 static uint32_t fl_engine_gl_get_fbo(void* user_data) {
255  FlEngine* self = static_cast<FlEngine*>(user_data);
256  return fl_renderer_get_fbo(self->renderer);
257 }
258 
259 static bool fl_engine_gl_present(void* user_data) {
260  // No action required, as this is handled in
261  // compositor_present_view_callback.
262  return true;
263 }
264 
266  FlEngine* self = static_cast<FlEngine*>(user_data);
267  fl_renderer_make_resource_current(self->renderer);
268  return true;
269 }
270 
271 // Called by the engine to retrieve an external texture.
273  void* user_data,
274  int64_t texture_id,
275  size_t width,
276  size_t height,
277  FlutterOpenGLTexture* opengl_texture) {
278  FlEngine* self = static_cast<FlEngine*>(user_data);
279  if (!self->texture_registrar) {
280  return false;
281  }
282 
283  FlTexture* texture =
284  fl_texture_registrar_lookup_texture(self->texture_registrar, texture_id);
285  if (texture == nullptr) {
286  g_warning("Unable to find texture %" G_GINT64_FORMAT, texture_id);
287  return false;
288  }
289 
290  gboolean result;
291  g_autoptr(GError) error = nullptr;
292  if (FL_IS_TEXTURE_GL(texture)) {
293  result = fl_texture_gl_populate(FL_TEXTURE_GL(texture), width, height,
294  opengl_texture, &error);
295  } else if (FL_IS_PIXEL_BUFFER_TEXTURE(texture)) {
296  result =
297  fl_pixel_buffer_texture_populate(FL_PIXEL_BUFFER_TEXTURE(texture),
298  width, height, opengl_texture, &error);
299  } else {
300  g_warning("Unsupported texture type %" G_GINT64_FORMAT, texture_id);
301  return false;
302  }
303 
304  if (!result) {
305  g_warning("%s", error->message);
306  return false;
307  }
308 
309  return true;
310 }
311 
312 // Called by the engine to determine if it is on the GTK thread.
314  FlEngine* self = static_cast<FlEngine*>(user_data);
315  return self->thread == g_thread_self();
316 }
317 
318 // Called when the engine has a task to perform in the GTK thread.
319 static void fl_engine_post_task(FlutterTask task,
320  uint64_t target_time_nanos,
321  void* user_data) {
322  FlEngine* self = static_cast<FlEngine*>(user_data);
323 
324  fl_task_runner_post_task(self->task_runner, task, target_time_nanos);
325 }
326 
327 // Called when a platform message is received from the engine.
328 static void fl_engine_platform_message_cb(const FlutterPlatformMessage* message,
329  void* user_data) {
330  FlEngine* self = FL_ENGINE(user_data);
331 
332  gboolean handled = FALSE;
333  if (self->platform_message_handler != nullptr) {
334  g_autoptr(GBytes) data =
335  g_bytes_new(message->message, message->message_size);
336  handled = self->platform_message_handler(
337  self, message->channel, data, message->response_handle,
338  self->platform_message_handler_data);
339  }
340 
341  if (!handled) {
342  fl_engine_send_platform_message_response(self, message->response_handle,
343  nullptr, nullptr);
344  }
345 }
346 
347 // Called when a semantic node update is received from the engine.
348 static void fl_engine_update_semantics_cb(const FlutterSemanticsUpdate2* update,
349  void* user_data) {
350  FlEngine* self = FL_ENGINE(user_data);
351 
352  if (self->update_semantics_handler != nullptr) {
353  self->update_semantics_handler(self, update,
354  self->update_semantics_handler_data);
355  }
356 }
357 
358 // Called right before the engine is restarted.
359 //
360 // This method should reset states to as if the engine has just been started,
361 // which usually indicates the user has requested a hot restart (Shift-R in the
362 // Flutter CLI.)
364  FlEngine* self = FL_ENGINE(user_data);
365 
366  g_signal_emit(self, fl_engine_signals[kSignalOnPreEngineRestart], 0);
367 }
368 
369 // Called when a response to a sent platform message is received from the
370 // engine.
371 static void fl_engine_platform_message_response_cb(const uint8_t* data,
372  size_t data_length,
373  void* user_data) {
374  g_autoptr(GTask) task = G_TASK(user_data);
375  g_task_return_pointer(task, g_bytes_new(data, data_length),
376  reinterpret_cast<GDestroyNotify>(g_bytes_unref));
377 }
378 
379 // Implements FlPluginRegistry::get_registrar_for_plugin.
380 static FlPluginRegistrar* fl_engine_get_registrar_for_plugin(
381  FlPluginRegistry* registry,
382  const gchar* name) {
383  FlEngine* self = FL_ENGINE(registry);
384 
385  return fl_plugin_registrar_new(nullptr, self->binary_messenger,
386  self->texture_registrar);
387 }
388 
390  FlPluginRegistryInterface* iface) {
391  iface->get_registrar_for_plugin = fl_engine_get_registrar_for_plugin;
392 }
393 
394 static void fl_engine_set_property(GObject* object,
395  guint prop_id,
396  const GValue* value,
397  GParamSpec* pspec) {
398  FlEngine* self = FL_ENGINE(object);
399  switch (prop_id) {
400  case kPropBinaryMessenger:
401  g_set_object(&self->binary_messenger,
402  FL_BINARY_MESSENGER(g_value_get_object(value)));
403  break;
404  default:
405  G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
406  break;
407  }
408 }
409 
410 static void fl_engine_dispose(GObject* object) {
411  FlEngine* self = FL_ENGINE(object);
412 
413  if (self->engine != nullptr) {
414  self->embedder_api.Shutdown(self->engine);
415  self->engine = nullptr;
416  }
417 
418  if (self->aot_data != nullptr) {
419  self->embedder_api.CollectAOTData(self->aot_data);
420  self->aot_data = nullptr;
421  }
422 
423  fl_binary_messenger_shutdown(self->binary_messenger);
424  fl_texture_registrar_shutdown(self->texture_registrar);
425 
426  g_clear_object(&self->project);
427  g_clear_object(&self->renderer);
428  g_clear_object(&self->texture_registrar);
429  g_clear_object(&self->binary_messenger);
430  g_clear_object(&self->settings_handler);
431  g_clear_object(&self->task_runner);
432 
433  if (self->platform_message_handler_destroy_notify) {
434  self->platform_message_handler_destroy_notify(
435  self->platform_message_handler_data);
436  }
437  self->platform_message_handler_data = nullptr;
438  self->platform_message_handler_destroy_notify = nullptr;
439 
440  if (self->update_semantics_handler_destroy_notify) {
441  self->update_semantics_handler_destroy_notify(
442  self->update_semantics_handler_data);
443  }
444  self->update_semantics_handler_data = nullptr;
445  self->update_semantics_handler_destroy_notify = nullptr;
446 
447  G_OBJECT_CLASS(fl_engine_parent_class)->dispose(object);
448 }
449 
450 static void fl_engine_class_init(FlEngineClass* klass) {
451  G_OBJECT_CLASS(klass)->dispose = fl_engine_dispose;
452  G_OBJECT_CLASS(klass)->set_property = fl_engine_set_property;
453 
454  g_object_class_install_property(
455  G_OBJECT_CLASS(klass), kPropBinaryMessenger,
456  g_param_spec_object(
457  "binary-messenger", "messenger", "Binary messenger",
458  fl_binary_messenger_get_type(),
459  static_cast<GParamFlags>(G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY |
460  G_PARAM_STATIC_STRINGS)));
461 
463  "on-pre-engine-restart", fl_engine_get_type(), G_SIGNAL_RUN_LAST, 0,
464  nullptr, nullptr, nullptr, G_TYPE_NONE, 0);
465 }
466 
467 static void fl_engine_init(FlEngine* self) {
468  self->thread = g_thread_self();
469 
470  self->embedder_api.struct_size = sizeof(FlutterEngineProcTable);
471  FlutterEngineGetProcAddresses(&self->embedder_api);
472 
473  // Implicit view is 0, so start at 1.
474  self->next_view_id = 1;
475 
476  self->texture_registrar = fl_texture_registrar_new(self);
477 }
478 
479 FlEngine* fl_engine_new_with_renderer(FlDartProject* project,
480  FlRenderer* renderer) {
481  g_return_val_if_fail(FL_IS_DART_PROJECT(project), nullptr);
482  g_return_val_if_fail(FL_IS_RENDERER(renderer), nullptr);
483 
484  FlEngine* self = FL_ENGINE(g_object_new(fl_engine_get_type(), nullptr));
485  self->project = FL_DART_PROJECT(g_object_ref(project));
486  self->renderer = FL_RENDERER(g_object_ref(renderer));
487  self->binary_messenger = fl_binary_messenger_new(self);
488 
489  fl_renderer_set_engine(self->renderer, self);
490 
491  return self;
492 }
493 
494 G_MODULE_EXPORT FlEngine* fl_engine_new(FlDartProject* project) {
495  g_autoptr(FlRendererGdk) renderer = fl_renderer_gdk_new();
496  return fl_engine_new_with_renderer(project, FL_RENDERER(renderer));
497 }
498 
499 G_MODULE_EXPORT FlEngine* fl_engine_new_headless(FlDartProject* project) {
500  g_autoptr(FlRendererHeadless) renderer = fl_renderer_headless_new();
501  return fl_engine_new_with_renderer(project, FL_RENDERER(renderer));
502 }
503 
504 FlRenderer* fl_engine_get_renderer(FlEngine* self) {
505  g_return_val_if_fail(FL_IS_ENGINE(self), nullptr);
506  return self->renderer;
507 }
508 
509 gboolean fl_engine_start(FlEngine* self, GError** error) {
510  g_return_val_if_fail(FL_IS_ENGINE(self), FALSE);
511 
512  self->task_runner = fl_task_runner_new(self);
513 
514  FlutterRendererConfig config = {};
515  config.type = kOpenGL;
516  config.open_gl.struct_size = sizeof(FlutterOpenGLRendererConfig);
517  config.open_gl.gl_proc_resolver = fl_engine_gl_proc_resolver;
518  config.open_gl.make_current = fl_engine_gl_make_current;
519  config.open_gl.clear_current = fl_engine_gl_clear_current;
520  config.open_gl.fbo_callback = fl_engine_gl_get_fbo;
521  config.open_gl.present = fl_engine_gl_present;
522  config.open_gl.make_resource_current = fl_engine_gl_make_resource_current;
523  config.open_gl.gl_external_texture_frame_callback =
525 
526  FlutterTaskRunnerDescription platform_task_runner = {};
527  platform_task_runner.struct_size = sizeof(FlutterTaskRunnerDescription);
528  platform_task_runner.user_data = self;
529  platform_task_runner.runs_task_on_current_thread_callback =
531  platform_task_runner.post_task_callback = fl_engine_post_task;
532  platform_task_runner.identifier = kPlatformTaskRunnerIdentifier;
533 
534  FlutterCustomTaskRunners custom_task_runners = {};
535  custom_task_runners.struct_size = sizeof(FlutterCustomTaskRunners);
536  custom_task_runners.platform_task_runner = &platform_task_runner;
537  custom_task_runners.render_task_runner = &platform_task_runner;
538 
539  g_autoptr(GPtrArray) command_line_args = fl_engine_get_switches(self);
540  // FlutterProjectArgs expects a full argv, so when processing it for flags
541  // the first item is treated as the executable and ignored. Add a dummy value
542  // so that all switches are used.
543  g_ptr_array_insert(command_line_args, 0, g_strdup("flutter"));
544 
545  gchar** dart_entrypoint_args =
547 
548  FlutterProjectArgs args = {};
549  args.struct_size = sizeof(FlutterProjectArgs);
550  args.assets_path = fl_dart_project_get_assets_path(self->project);
551  args.icu_data_path = fl_dart_project_get_icu_data_path(self->project);
552  args.command_line_argc = command_line_args->len;
553  args.command_line_argv =
554  reinterpret_cast<const char* const*>(command_line_args->pdata);
555  args.platform_message_callback = fl_engine_platform_message_cb;
556  args.update_semantics_callback2 = fl_engine_update_semantics_cb;
557  args.custom_task_runners = &custom_task_runners;
558  args.shutdown_dart_vm_when_done = true;
559  args.on_pre_engine_restart_callback = fl_engine_on_pre_engine_restart_cb;
560  args.dart_entrypoint_argc =
561  dart_entrypoint_args != nullptr ? g_strv_length(dart_entrypoint_args) : 0;
562  args.dart_entrypoint_argv =
563  reinterpret_cast<const char* const*>(dart_entrypoint_args);
564 
565  FlutterCompositor compositor = {};
566  compositor.struct_size = sizeof(FlutterCompositor);
567  compositor.user_data = self->renderer;
568  compositor.create_backing_store_callback =
570  compositor.collect_backing_store_callback =
572  compositor.present_view_callback = compositor_present_view_callback;
573  args.compositor = &compositor;
574 
575  if (self->embedder_api.RunsAOTCompiledDartCode()) {
576  FlutterEngineAOTDataSource source = {};
577  source.type = kFlutterEngineAOTDataSourceTypeElfPath;
578  source.elf_path = fl_dart_project_get_aot_library_path(self->project);
579  if (self->embedder_api.CreateAOTData(&source, &self->aot_data) !=
580  kSuccess) {
582  "Failed to create AOT data");
583  return FALSE;
584  }
585  args.aot_data = self->aot_data;
586  }
587 
588  FlutterEngineResult result = self->embedder_api.Initialize(
589  FLUTTER_ENGINE_VERSION, &config, &args, self, &self->engine);
590  if (result != kSuccess) {
592  "Failed to initialize Flutter engine");
593  return FALSE;
594  }
595 
596  result = self->embedder_api.RunInitialized(self->engine);
597  if (result != kSuccess) {
599  "Failed to run Flutter engine");
600  return FALSE;
601  }
602 
603  setup_locales(self);
604 
605  g_autoptr(FlSettings) settings = fl_settings_new();
606  self->settings_handler = fl_settings_handler_new(self);
607  fl_settings_handler_start(self->settings_handler, settings);
608 
609  result = self->embedder_api.UpdateSemanticsEnabled(self->engine, TRUE);
610  if (result != kSuccess) {
611  g_warning("Failed to enable accessibility features on Flutter engine");
612  }
613 
614  gdouble refresh_rate = fl_renderer_get_refresh_rate(self->renderer);
615  // FlutterEngineDisplay::refresh_rate expects 0 if the refresh rate is
616  // unknown.
617  if (refresh_rate <= 0.0) {
618  refresh_rate = 0.0;
619  }
620  FlutterEngineDisplay display = {};
621  display.struct_size = sizeof(FlutterEngineDisplay);
622  display.display_id = 0;
623  display.single_display = true;
624  display.refresh_rate = refresh_rate;
625 
626  std::vector displays = {display};
627  result = self->embedder_api.NotifyDisplayUpdate(
628  self->engine, kFlutterEngineDisplaysUpdateTypeStartup, displays.data(),
629  displays.size());
630  if (result != kSuccess) {
631  g_warning("Failed to notify display update to Flutter engine: %d", result);
632  }
633 
634  return TRUE;
635 }
636 
637 FlutterEngineProcTable* fl_engine_get_embedder_api(FlEngine* self) {
638  return &(self->embedder_api);
639 }
640 
641 FlutterViewId fl_engine_add_view(FlEngine* self,
642  size_t width,
643  size_t height,
644  double pixel_ratio,
645  GCancellable* cancellable,
646  GAsyncReadyCallback callback,
647  gpointer user_data) {
648  g_return_val_if_fail(FL_IS_ENGINE(self), -1);
649 
650  g_autoptr(GTask) task = g_task_new(self, cancellable, callback, user_data);
651 
652  FlutterViewId view_id = self->next_view_id;
653  self->next_view_id++;
654 
655  FlutterWindowMetricsEvent metrics;
656  metrics.struct_size = sizeof(FlutterWindowMetricsEvent);
657  metrics.width = width;
658  metrics.height = height;
659  metrics.pixel_ratio = pixel_ratio;
660  metrics.view_id = view_id;
661  FlutterAddViewInfo info;
662  info.struct_size = sizeof(FlutterAddViewInfo);
663  info.view_id = view_id;
664  info.view_metrics = &metrics;
665  info.user_data = g_object_ref(task);
666  info.add_view_callback = view_added_cb;
667  FlutterEngineResult result = self->embedder_api.AddView(self->engine, &info);
668  if (result != kSuccess) {
669  g_task_return_new_error(task, fl_engine_error_quark(),
670  FL_ENGINE_ERROR_FAILED, "AddView returned %d",
671  result);
672  // This would have been done in the callback, but that won't occur now.
673  g_object_unref(task);
674  }
675 
676  return view_id;
677 }
678 
679 gboolean fl_engine_add_view_finish(FlEngine* self,
680  GAsyncResult* result,
681  GError** error) {
682  g_return_val_if_fail(FL_IS_ENGINE(self), FALSE);
683  return g_task_propagate_boolean(G_TASK(result), error);
684 }
685 
686 void fl_engine_remove_view(FlEngine* self,
687  FlutterViewId view_id,
688  GCancellable* cancellable,
689  GAsyncReadyCallback callback,
690  gpointer user_data) {
691  g_return_if_fail(FL_IS_ENGINE(self));
692 
693  g_autoptr(GTask) task = g_task_new(self, cancellable, callback, user_data);
694 
695  FlutterRemoveViewInfo info;
696  info.struct_size = sizeof(FlutterRemoveViewInfo);
697  info.view_id = view_id;
698  info.user_data = g_object_ref(task);
699  info.remove_view_callback = view_removed_cb;
700  FlutterEngineResult result =
701  self->embedder_api.RemoveView(self->engine, &info);
702  if (result != kSuccess) {
703  g_task_return_new_error(task, fl_engine_error_quark(),
704  FL_ENGINE_ERROR_FAILED, "RemoveView returned %d",
705  result);
706  // This would have been done in the callback, but that won't occur now.
707  g_object_unref(task);
708  }
709 }
710 
711 gboolean fl_engine_remove_view_finish(FlEngine* self,
712  GAsyncResult* result,
713  GError** error) {
714  g_return_val_if_fail(FL_IS_ENGINE(self), FALSE);
715  return g_task_propagate_boolean(G_TASK(result), error);
716 }
717 
719  FlEngine* self,
721  gpointer user_data,
722  GDestroyNotify destroy_notify) {
723  g_return_if_fail(FL_IS_ENGINE(self));
724  g_return_if_fail(handler != nullptr);
725 
726  if (self->platform_message_handler_destroy_notify) {
727  self->platform_message_handler_destroy_notify(
728  self->platform_message_handler_data);
729  }
730 
731  self->platform_message_handler = handler;
732  self->platform_message_handler_data = user_data;
733  self->platform_message_handler_destroy_notify = destroy_notify;
734 }
735 
737  FlEngine* self,
739  gpointer user_data,
740  GDestroyNotify destroy_notify) {
741  g_return_if_fail(FL_IS_ENGINE(self));
742 
743  if (self->update_semantics_handler_destroy_notify) {
744  self->update_semantics_handler_destroy_notify(
745  self->update_semantics_handler_data);
746  }
747 
748  self->update_semantics_handler = handler;
749  self->update_semantics_handler_data = user_data;
750  self->update_semantics_handler_destroy_notify = destroy_notify;
751 }
752 
753 // Note: This function can be called from any thread.
755  FlEngine* self,
756  const FlutterPlatformMessageResponseHandle* handle,
757  GBytes* response,
758  GError** error) {
759  g_return_val_if_fail(FL_IS_ENGINE(self), FALSE);
760  g_return_val_if_fail(handle != nullptr, FALSE);
761 
762  if (self->engine == nullptr) {
764  "No engine to send response to");
765  return FALSE;
766  }
767 
768  gsize data_length = 0;
769  const uint8_t* data = nullptr;
770  if (response != nullptr) {
771  data =
772  static_cast<const uint8_t*>(g_bytes_get_data(response, &data_length));
773  }
774  FlutterEngineResult result = self->embedder_api.SendPlatformMessageResponse(
775  self->engine, handle, data, data_length);
776 
777  if (result != kSuccess) {
779  "Failed to send platform message response");
780  return FALSE;
781  }
782 
783  return TRUE;
784 }
785 
787  const gchar* channel,
788  GBytes* message,
789  GCancellable* cancellable,
790  GAsyncReadyCallback callback,
791  gpointer user_data) {
792  g_return_if_fail(FL_IS_ENGINE(self));
793 
794  GTask* task = nullptr;
795  FlutterPlatformMessageResponseHandle* response_handle = nullptr;
796  if (callback != nullptr) {
797  task = g_task_new(self, cancellable, callback, user_data);
798 
799  if (self->engine == nullptr) {
800  g_task_return_new_error(task, fl_engine_error_quark(),
801  FL_ENGINE_ERROR_FAILED, "No engine to send to");
802  return;
803  }
804 
805  FlutterEngineResult result =
806  self->embedder_api.PlatformMessageCreateResponseHandle(
807  self->engine, fl_engine_platform_message_response_cb, task,
808  &response_handle);
809  if (result != kSuccess) {
810  g_task_return_new_error(task, fl_engine_error_quark(),
812  "Failed to create response handle");
813  g_object_unref(task);
814  return;
815  }
816  } else if (self->engine == nullptr) {
817  return;
818  }
819 
820  FlutterPlatformMessage fl_message = {};
821  fl_message.struct_size = sizeof(fl_message);
822  fl_message.channel = channel;
823  fl_message.message =
824  message != nullptr
825  ? static_cast<const uint8_t*>(g_bytes_get_data(message, nullptr))
826  : nullptr;
827  fl_message.message_size = message != nullptr ? g_bytes_get_size(message) : 0;
828  fl_message.response_handle = response_handle;
829  FlutterEngineResult result =
830  self->embedder_api.SendPlatformMessage(self->engine, &fl_message);
831 
832  if (result != kSuccess && task != nullptr) {
833  g_task_return_new_error(task, fl_engine_error_quark(),
835  "Failed to send platform messages");
836  g_object_unref(task);
837  }
838 
839  if (response_handle != nullptr) {
840  self->embedder_api.PlatformMessageReleaseResponseHandle(self->engine,
841  response_handle);
842  }
843 }
844 
846  GAsyncResult* result,
847  GError** error) {
848  g_return_val_if_fail(FL_IS_ENGINE(self), FALSE);
849  g_return_val_if_fail(g_task_is_valid(result, self), FALSE);
850 
851  return static_cast<GBytes*>(g_task_propagate_pointer(G_TASK(result), error));
852 }
853 
855  FlutterViewId view_id,
856  size_t width,
857  size_t height,
858  double pixel_ratio) {
859  g_return_if_fail(FL_IS_ENGINE(self));
860 
861  if (self->engine == nullptr) {
862  return;
863  }
864 
865  FlutterWindowMetricsEvent event = {};
866  event.struct_size = sizeof(FlutterWindowMetricsEvent);
867  event.width = width;
868  event.height = height;
869  event.pixel_ratio = pixel_ratio;
870  event.view_id = view_id;
871  self->embedder_api.SendWindowMetricsEvent(self->engine, &event);
872 }
873 
875  FlutterViewId view_id,
876  FlutterPointerPhase phase,
877  size_t timestamp,
878  double x,
879  double y,
880  FlutterPointerDeviceKind device_kind,
881  double scroll_delta_x,
882  double scroll_delta_y,
883  int64_t buttons) {
884  g_return_if_fail(FL_IS_ENGINE(self));
885 
886  if (self->engine == nullptr) {
887  return;
888  }
889 
890  FlutterPointerEvent fl_event = {};
891  fl_event.struct_size = sizeof(fl_event);
892  fl_event.phase = phase;
893  fl_event.timestamp = timestamp;
894  fl_event.x = x;
895  fl_event.y = y;
896  if (scroll_delta_x != 0 || scroll_delta_y != 0) {
897  fl_event.signal_kind = kFlutterPointerSignalKindScroll;
898  }
899  fl_event.scroll_delta_x = scroll_delta_x;
900  fl_event.scroll_delta_y = scroll_delta_y;
901  fl_event.device_kind = device_kind;
902  fl_event.buttons = buttons;
903  fl_event.device = kMousePointerDeviceId;
904  fl_event.view_id = view_id;
905  self->embedder_api.SendPointerEvent(self->engine, &fl_event, 1);
906 }
907 
909  FlutterViewId view_id,
910  size_t timestamp,
911  double x,
912  double y,
913  FlutterPointerPhase phase,
914  double pan_x,
915  double pan_y,
916  double scale,
917  double rotation) {
918  g_return_if_fail(FL_IS_ENGINE(self));
919 
920  if (self->engine == nullptr) {
921  return;
922  }
923 
924  FlutterPointerEvent fl_event = {};
925  fl_event.struct_size = sizeof(fl_event);
926  fl_event.timestamp = timestamp;
927  fl_event.x = x;
928  fl_event.y = y;
929  fl_event.phase = phase;
930  fl_event.pan_x = pan_x;
931  fl_event.pan_y = pan_y;
932  fl_event.scale = scale;
933  fl_event.rotation = rotation;
934  fl_event.device = kPointerPanZoomDeviceId;
935  fl_event.device_kind = kFlutterPointerDeviceKindTrackpad;
936  fl_event.view_id = view_id;
937  self->embedder_api.SendPointerEvent(self->engine, &fl_event, 1);
938 }
939 
940 void fl_engine_send_key_event(FlEngine* self,
941  const FlutterKeyEvent* event,
942  FlutterKeyEventCallback callback,
943  void* user_data) {
944  g_return_if_fail(FL_IS_ENGINE(self));
945 
946  if (self->engine == nullptr) {
947  return;
948  }
949 
950  self->embedder_api.SendKeyEvent(self->engine, event, callback, user_data);
951 }
952 
954  uint64_t id,
955  FlutterSemanticsAction action,
956  GBytes* data) {
957  g_return_if_fail(FL_IS_ENGINE(self));
958 
959  if (self->engine == nullptr) {
960  return;
961  }
962 
963  const uint8_t* action_data = nullptr;
964  size_t action_data_length = 0;
965  if (data != nullptr) {
966  action_data = static_cast<const uint8_t*>(
967  g_bytes_get_data(data, &action_data_length));
968  }
969 
970  self->embedder_api.DispatchSemanticsAction(self->engine, id, action,
971  action_data, action_data_length);
972 }
973 
975  int64_t texture_id) {
976  g_return_val_if_fail(FL_IS_ENGINE(self), FALSE);
977  return self->embedder_api.MarkExternalTextureFrameAvailable(
978  self->engine, texture_id) == kSuccess;
979 }
980 
981 gboolean fl_engine_register_external_texture(FlEngine* self,
982  int64_t texture_id) {
983  g_return_val_if_fail(FL_IS_ENGINE(self), FALSE);
984  return self->embedder_api.RegisterExternalTexture(self->engine, texture_id) ==
985  kSuccess;
986 }
987 
989  int64_t texture_id) {
990  g_return_val_if_fail(FL_IS_ENGINE(self), FALSE);
991  return self->embedder_api.UnregisterExternalTexture(self->engine,
992  texture_id) == kSuccess;
993 }
994 
995 G_MODULE_EXPORT FlBinaryMessenger* fl_engine_get_binary_messenger(
996  FlEngine* self) {
997  g_return_val_if_fail(FL_IS_ENGINE(self), nullptr);
998  return self->binary_messenger;
999 }
1000 
1001 FlTaskRunner* fl_engine_get_task_runner(FlEngine* self) {
1002  g_return_val_if_fail(FL_IS_ENGINE(self), nullptr);
1003  return self->task_runner;
1004 }
1005 
1006 void fl_engine_execute_task(FlEngine* self, FlutterTask* task) {
1007  g_return_if_fail(FL_IS_ENGINE(self));
1008  self->embedder_api.RunTask(self->engine, task);
1009 }
1010 
1011 G_MODULE_EXPORT FlTextureRegistrar* fl_engine_get_texture_registrar(
1012  FlEngine* self) {
1013  g_return_val_if_fail(FL_IS_ENGINE(self), nullptr);
1014  return self->texture_registrar;
1015 }
1016 
1017 void fl_engine_update_accessibility_features(FlEngine* self, int32_t flags) {
1018  g_return_if_fail(FL_IS_ENGINE(self));
1019 
1020  if (self->engine == nullptr) {
1021  return;
1022  }
1023 
1024  self->embedder_api.UpdateAccessibilityFeatures(
1025  self->engine, static_cast<FlutterAccessibilityFeature>(flags));
1026 }
1027 
1028 GPtrArray* fl_engine_get_switches(FlEngine* self) {
1029  GPtrArray* switches = g_ptr_array_new_with_free_func(g_free);
1030  for (const auto& env_switch : flutter::GetSwitchesFromEnvironment()) {
1031  g_ptr_array_add(switches, g_strdup(env_switch.c_str()));
1032  }
1033  return switches;
1034 }
_FlEngine::platform_message_handler_data
gpointer platform_message_handler_data
Definition: fl_engine.cc:58
fl_engine_set_platform_message_handler
void fl_engine_set_platform_message_handler(FlEngine *self, FlEnginePlatformMessageHandler handler, gpointer user_data, GDestroyNotify destroy_notify)
Definition: fl_engine.cc:718
prop_id
guint prop_id
Definition: fl_standard_method_codec.cc:31
fl_dart_project_get_aot_library_path
const G_MODULE_EXPORT gchar * fl_dart_project_get_aot_library_path(FlDartProject *self)
Definition: fl_dart_project.cc:72
fl_binary_messenger_shutdown
void fl_binary_messenger_shutdown(FlBinaryMessenger *self)
Definition: fl_binary_messenger.cc:486
fl_settings_handler_new
FlSettingsHandler * fl_settings_handler_new(FlEngine *engine)
Definition: fl_settings_handler.cc:94
fl_renderer_present_layers
gboolean fl_renderer_present_layers(FlRenderer *self, FlutterViewId view_id, const FlutterLayer **layers, size_t layers_count)
Definition: fl_renderer.cc:429
FlEnginePlatformMessageHandler
gboolean(* FlEnginePlatformMessageHandler)(FlEngine *engine, const gchar *channel, GBytes *message, const FlutterPlatformMessageResponseHandle *response_handle, gpointer user_data)
Definition: fl_engine_private.h:43
event
FlKeyEvent * event
Definition: fl_key_channel_responder.cc:118
fl_engine_get_embedder_api
FlutterEngineProcTable * fl_engine_get_embedder_api(FlEngine *self)
Definition: fl_engine.cc:637
_FlEngine::embedder_api
FlutterEngineProcTable embedder_api
Definition: fl_engine.cc:51
fl_engine_init
static void fl_engine_init(FlEngine *self)
Definition: fl_engine.cc:467
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)
Definition: fl_engine.cc:371
fl_engine_gl_get_fbo
static uint32_t fl_engine_gl_get_fbo(void *user_data)
Definition: fl_engine.cc:254
_FlEngine::renderer
FlRenderer * renderer
Definition: fl_engine.cc:44
fl_engine_send_key_event
void fl_engine_send_key_event(FlEngine *self, const FlutterKeyEvent *event, FlutterKeyEventCallback callback, void *user_data)
Definition: fl_engine.cc:940
fl_engine_gl_make_resource_current
static bool fl_engine_gl_make_resource_current(void *user_data)
Definition: fl_engine.cc:265
FL_ENGINE_ERROR_FAILED
@ FL_ENGINE_ERROR_FAILED
Definition: fl_engine_private.h:25
kMousePointerDeviceId
static constexpr int32_t kMousePointerDeviceId
Definition: fl_engine.cc:34
fl_engine_update_accessibility_features
void fl_engine_update_accessibility_features(FlEngine *self, int32_t flags)
Definition: fl_engine.cc:1017
_FlEngine::next_view_id
FlutterViewId next_view_id
Definition: fl_engine.cc:54
fl_renderer_get_refresh_rate
gdouble fl_renderer_get_refresh_rate(FlRenderer *self)
Definition: fl_renderer.cc:355
fl_plugin_registrar_private.h
fl_texture_gl_private.h
_FlEngine::update_semantics_handler_data
gpointer update_semantics_handler_data
Definition: fl_engine.cc:63
fl_texture_registrar_lookup_texture
FlTexture * fl_texture_registrar_lookup_texture(FlTextureRegistrar *self, int64_t texture_id)
Definition: fl_texture_registrar.cc:190
compositor_present_view_callback
static bool compositor_present_view_callback(const FlutterPresentViewInfo *info)
Definition: fl_engine.cc:228
FlEngineUpdateSemanticsHandler
void(* FlEngineUpdateSemanticsHandler)(FlEngine *engine, const FlutterSemanticsUpdate2 *update, gpointer user_data)
Definition: fl_engine_private.h:58
fl_engine_new_headless
G_MODULE_EXPORT FlEngine * fl_engine_new_headless(FlDartProject *project)
Definition: fl_engine.cc:499
i
int i
Definition: fl_socket_accessible.cc:18
fl_engine_get_renderer
FlRenderer * fl_engine_get_renderer(FlEngine *self)
Definition: fl_engine.cc:504
fl_settings_new
FlSettings * fl_settings_new()
Definition: fl_settings.cc:55
_FlEngine::aot_data
FlutterEngineAOTData aot_data
Definition: fl_engine.cc:49
fl_engine_gl_present
static bool fl_engine_gl_present(void *user_data)
Definition: fl_engine.cc:259
flags
FlutterSemanticsFlag flags
Definition: fl_accessible_node.cc:106
fl_engine_dispose
static void fl_engine_dispose(GObject *object)
Definition: fl_engine.cc:410
fl_engine_mark_texture_frame_available
gboolean fl_engine_mark_texture_frame_available(FlEngine *self, int64_t texture_id)
Definition: fl_engine.cc:974
fl_engine_remove_view
void fl_engine_remove_view(FlEngine *self, FlutterViewId view_id, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data)
Definition: fl_engine.cc:686
user_data
FlKeyEvent uint64_t FlKeyResponderAsyncCallback gpointer user_data
Definition: fl_key_channel_responder.cc:121
fl_engine_dispatch_semantics_action
void fl_engine_dispatch_semantics_action(FlEngine *self, uint64_t id, FlutterSemanticsAction action, GBytes *data)
Definition: fl_engine.cc:953
fl_texture_registrar_new
FlTextureRegistrar * fl_texture_registrar_new(FlEngine *engine)
Definition: fl_texture_registrar.cc:221
pspec
guint const GValue GParamSpec * pspec
Definition: fl_standard_method_codec.cc:33
kSignalLastSignal
@ kSignalLastSignal
Definition: fl_engine.cc:72
fl_engine_on_pre_engine_restart_cb
static void fl_engine_on_pre_engine_restart_cb(void *user_data)
Definition: fl_engine.cc:363
fl_renderer_headless.h
fl_dart_project_get_assets_path
const G_MODULE_EXPORT gchar * fl_dart_project_get_assets_path(FlDartProject *self)
Definition: fl_dart_project.cc:85
fl_renderer_clear_current
void fl_renderer_clear_current(FlRenderer *self)
Definition: fl_renderer.cc:350
fl_engine_send_window_metrics_event
void fl_engine_send_window_metrics_event(FlEngine *self, FlutterViewId view_id, size_t width, size_t height, double pixel_ratio)
Definition: fl_engine.cc:854
kSignalOnPreEngineRestart
@ kSignalOnPreEngineRestart
Definition: fl_engine.cc:72
fl_engine_get_binary_messenger
G_MODULE_EXPORT FlBinaryMessenger * fl_engine_get_binary_messenger(FlEngine *self)
Definition: fl_engine.cc:995
fl_renderer_get_proc_address
void * fl_renderer_get_proc_address(FlRenderer *self, const char *name)
Definition: fl_renderer.cc:334
fl_binary_messenger_new
FlBinaryMessenger * fl_binary_messenger_new(FlEngine *engine)
Definition: fl_binary_messenger.cc:399
kPlatformTaskRunnerIdentifier
static constexpr size_t kPlatformTaskRunnerIdentifier
Definition: fl_engine.cc:30
_FlEngine::update_semantics_handler_destroy_notify
GDestroyNotify update_semantics_handler_destroy_notify
Definition: fl_engine.cc:64
fl_engine_new_with_renderer
FlEngine * fl_engine_new_with_renderer(FlDartProject *project, FlRenderer *renderer)
Definition: fl_engine.cc:479
fl_renderer_set_engine
void fl_renderer_set_engine(FlRenderer *self, FlEngine *engine)
Definition: fl_renderer.cc:305
kPropLast
@ kPropLast
Definition: fl_accessible_node.cc:84
view_removed_cb
static void view_removed_cb(const FlutterRemoveViewResult *result)
Definition: fl_engine.cc:140
_FlEngine::project
FlDartProject * project
Definition: fl_engine.cc:43
fl_engine_set_property
static void fl_engine_set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
Definition: fl_engine.cc:394
_FlEngine
Definition: fl_engine.cc:37
G_DEFINE_QUARK
G_DEFINE_QUARK(fl_binary_messenger_codec_error_quark, fl_binary_messenger_codec_error) G_DECLARE_FINAL_TYPE(FlBinaryMessengerImpl
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)) enum
Definition: fl_engine.cc:76
fl_engine_update_semantics_cb
static void fl_engine_update_semantics_cb(const FlutterSemanticsUpdate2 *update, void *user_data)
Definition: fl_engine.cc:348
fl_engine_add_view_finish
gboolean fl_engine_add_view_finish(FlEngine *self, GAsyncResult *result, GError **error)
Definition: fl_engine.cc:679
free_locale
static void free_locale(FlutterLocale *locale)
Definition: fl_engine.cc:151
fl_renderer_collect_backing_store
gboolean fl_renderer_collect_backing_store(FlRenderer *self, const FlutterBackingStore *backing_store)
Definition: fl_renderer.cc:399
fl_engine_remove_view_finish
gboolean fl_engine_remove_view_finish(FlEngine *self, GAsyncResult *result, GError **error)
Definition: fl_engine.cc:711
fl_pixel_buffer_texture_populate
gboolean fl_pixel_buffer_texture_populate(FlPixelBufferTexture *texture, uint32_t width, uint32_t height, FlutterOpenGLTexture *opengl_texture, GError **error)
Definition: fl_pixel_buffer_texture.cc:71
fl_renderer_headless_new
FlRendererHeadless * fl_renderer_headless_new()
Definition: fl_renderer_headless.cc:38
fl_texture_registrar_shutdown
void fl_texture_registrar_shutdown(FlTextureRegistrar *self)
Definition: fl_texture_registrar.cc:215
fl_task_runner_post_task
void fl_task_runner_post_task(FlTaskRunner *self, FlutterTask task, uint64_t target_time_nanos)
Definition: fl_task_runner.cc:161
fl_engine_plugin_registry_iface_init
static void fl_engine_plugin_registry_iface_init(FlPluginRegistryInterface *iface)
Definition: fl_engine.cc:389
fl_settings_handler.h
kProp0
@ kProp0
Definition: fl_accessible_node.cc:84
fl_engine_private.h
fl_engine_gl_external_texture_frame_callback
static bool fl_engine_gl_external_texture_frame_callback(void *user_data, int64_t texture_id, size_t width, size_t height, FlutterOpenGLTexture *opengl_texture)
Definition: fl_engine.cc:272
TRUE
return TRUE
Definition: fl_pixel_buffer_texture_test.cc:53
flutter::GetSwitchesFromEnvironment
std::vector< std::string > GetSwitchesFromEnvironment()
Definition: engine_switches.cc:14
_FlEngine::FLUTTER_API_SYMBOL
FLUTTER_API_SYMBOL(FlutterEngine) engine
_FlEngine::platform_message_handler_destroy_notify
GDestroyNotify platform_message_handler_destroy_notify
Definition: fl_engine.cc:59
engine_switches.h
_FlEngine::settings_handler
FlSettingsHandler * settings_handler
Definition: fl_engine.cc:46
fl_dart_project_get_dart_entrypoint_arguments
G_MODULE_EXPORT gchar ** fl_dart_project_get_dart_entrypoint_arguments(FlDartProject *self)
Definition: fl_dart_project.cc:104
fl_renderer.h
fl_renderer_make_resource_current
void fl_renderer_make_resource_current(FlRenderer *self)
Definition: fl_renderer.cc:345
fl_engine_send_platform_message_finish
GBytes * fl_engine_send_platform_message_finish(FlEngine *self, GAsyncResult *result, GError **error)
Definition: fl_engine.cc:845
fl_engine_signals
static guint fl_engine_signals[kSignalLastSignal]
Definition: fl_engine.cc:74
fl_engine_add_view
FlutterViewId fl_engine_add_view(FlEngine *self, size_t width, size_t height, double pixel_ratio, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data)
Definition: fl_engine.cc:641
fl_settings_handler_start
void fl_settings_handler_start(FlSettingsHandler *self, FlSettings *settings)
Definition: fl_settings_handler.cc:112
fl_engine_runs_task_on_current_thread
static bool fl_engine_runs_task_on_current_thread(void *user_data)
Definition: fl_engine.cc:313
fl_renderer_gdk.h
height
const uint8_t uint32_t uint32_t * height
Definition: fl_pixel_buffer_texture_test.cc:39
fl_texture_gl_populate
gboolean fl_texture_gl_populate(FlTextureGL *self, uint32_t width, uint32_t height, FlutterOpenGLTexture *opengl_texture, GError **error)
Definition: fl_texture_gl.cc:50
result
GAsyncResult * result
Definition: fl_text_input_handler.cc:106
fl_binary_messenger_private.h
fl_engine_get_registrar_for_plugin
static FlPluginRegistrar * fl_engine_get_registrar_for_plugin(FlPluginRegistry *registry, const gchar *name)
Definition: fl_engine.cc:380
fl_pixel_buffer_texture_private.h
view_added_cb
static void view_added_cb(const FlutterAddViewResult *result)
Definition: fl_engine.cc:129
_FlEngine::update_semantics_handler
FlEngineUpdateSemanticsHandler update_semantics_handler
Definition: fl_engine.cc:62
fl_engine_new
G_MODULE_EXPORT FlEngine * fl_engine_new(FlDartProject *project)
Definition: fl_engine.cc:494
args
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
Definition: fl_event_channel.h:89
fl_engine.h
error
const uint8_t uint32_t uint32_t GError ** error
Definition: fl_pixel_buffer_texture_test.cc:40
compositor_collect_backing_store_callback
static bool compositor_collect_backing_store_callback(const FlutterBackingStore *backing_store, void *user_data)
Definition: fl_engine.cc:219
fl_engine_get_task_runner
FlTaskRunner * fl_engine_get_task_runner(FlEngine *self)
Definition: fl_engine.cc:1001
fl_renderer_make_current
void fl_renderer_make_current(FlRenderer *self)
Definition: fl_renderer.cc:340
fl_engine_set_update_semantics_handler
void fl_engine_set_update_semantics_handler(FlEngine *self, FlEngineUpdateSemanticsHandler handler, gpointer user_data, GDestroyNotify destroy_notify)
Definition: fl_engine.cc:736
fl_engine_gl_proc_resolver
static void * fl_engine_gl_proc_resolver(void *user_data, const char *name)
Definition: fl_engine.cc:237
fl_engine_send_pointer_pan_zoom_event
void fl_engine_send_pointer_pan_zoom_event(FlEngine *self, FlutterViewId view_id, size_t timestamp, double x, double y, FlutterPointerPhase phase, double pan_x, double pan_y, double scale, double rotation)
Definition: fl_engine.cc:908
_FlEngine::thread
GThread * thread
Definition: fl_engine.cc:41
_FlEngine::binary_messenger
FlBinaryMessenger * binary_messenger
Definition: fl_engine.cc:45
fl_engine_send_platform_message
void fl_engine_send_platform_message(FlEngine *self, const gchar *channel, GBytes *message, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data)
Definition: fl_engine.cc:786
setup_locales
static void setup_locales(FlEngine *self)
Definition: fl_engine.cc:158
fl_renderer_gdk_new
FlRendererGdk * fl_renderer_gdk_new()
Definition: fl_renderer_gdk.cc:82
parse_locale
static void parse_locale(const gchar *locale, gchar **language, gchar **territory, gchar **codeset, gchar **modifier)
Definition: fl_engine.cc:86
fl_renderer_create_backing_store
gboolean fl_renderer_create_backing_store(FlRenderer *self, const FlutterBackingStoreConfig *config, FlutterBackingStore *backing_store_out)
Definition: fl_renderer.cc:367
compositor_create_backing_store_callback
static bool compositor_create_backing_store_callback(const FlutterBackingStoreConfig *config, FlutterBackingStore *backing_store_out, void *user_data)
Definition: fl_engine.cc:209
_FlEngine::texture_registrar
FlTextureRegistrar * texture_registrar
Definition: fl_engine.cc:47
fl_dart_project_private.h
fl_engine_start
gboolean fl_engine_start(FlEngine *self, GError **error)
Definition: fl_engine.cc:509
fl_texture_registrar_private.h
_FlEngine::task_runner
FlTaskRunner * task_runner
Definition: fl_engine.cc:48
fl_engine_register_external_texture
gboolean fl_engine_register_external_texture(FlEngine *self, int64_t texture_id)
Definition: fl_engine.cc:981
fl_plugin_registrar_new
FlPluginRegistrar * fl_plugin_registrar_new(FlView *view, FlBinaryMessenger *messenger, FlTextureRegistrar *texture_registrar)
Definition: fl_plugin_registrar.cc:87
fl_plugin_registry.h
callback
FlKeyEvent uint64_t FlKeyResponderAsyncCallback callback
Definition: fl_key_channel_responder.cc:120
fl_engine_execute_task
void fl_engine_execute_task(FlEngine *self, FlutterTask *task)
Definition: fl_engine.cc:1006
fl_engine_error_quark
GQuark fl_engine_error_quark(void) G_GNUC_CONST
fl_engine_unregister_external_texture
gboolean fl_engine_unregister_external_texture(FlEngine *self, int64_t texture_id)
Definition: fl_engine.cc:988
fl_dart_project_get_icu_data_path
const G_MODULE_EXPORT gchar * fl_dart_project_get_icu_data_path(FlDartProject *self)
Definition: fl_dart_project.cc:98
texture_id
int64_t texture_id
Definition: texture_registrar_unittests.cc:24
width
const uint8_t uint32_t * width
Definition: fl_pixel_buffer_texture_test.cc:38
fl_engine_gl_make_current
static bool fl_engine_gl_make_current(void *user_data)
Definition: fl_engine.cc:242
fl_engine_send_mouse_pointer_event
void fl_engine_send_mouse_pointer_event(FlEngine *self, FlutterViewId view_id, FlutterPointerPhase phase, size_t timestamp, double x, double y, FlutterPointerDeviceKind device_kind, double scroll_delta_x, double scroll_delta_y, int64_t buttons)
Definition: fl_engine.cc:874
fl_engine_get_switches
GPtrArray * fl_engine_get_switches(FlEngine *self)
Definition: fl_engine.cc:1028
fl_renderer_get_fbo
guint32 fl_renderer_get_fbo(FlRenderer *self)
Definition: fl_renderer.cc:360
fl_engine_post_task
static void fl_engine_post_task(FlutterTask task, uint64_t target_time_nanos, void *user_data)
Definition: fl_engine.cc:319
value
uint8_t value
Definition: fl_standard_message_codec.cc:36
fl_task_runner_new
FlTaskRunner * fl_task_runner_new(FlEngine *engine)
Definition: fl_task_runner.cc:154
fl_engine_get_texture_registrar
G_MODULE_EXPORT FlTextureRegistrar * fl_engine_get_texture_registrar(FlEngine *self)
Definition: fl_engine.cc:1011
fl_engine_send_platform_message_response
gboolean fl_engine_send_platform_message_response(FlEngine *self, const FlutterPlatformMessageResponseHandle *handle, GBytes *response, GError **error)
Definition: fl_engine.cc:754
_FlEngine::platform_message_handler
FlEnginePlatformMessageHandler platform_message_handler
Definition: fl_engine.cc:57
fl_engine_class_init
static void fl_engine_class_init(FlEngineClass *klass)
Definition: fl_engine.cc:450
fl_engine_platform_message_cb
static void fl_engine_platform_message_cb(const FlutterPlatformMessage *message, void *user_data)
Definition: fl_engine.cc:328
kPointerPanZoomDeviceId
static constexpr int32_t kPointerPanZoomDeviceId
Definition: fl_engine.cc:35
_FlEngine::parent_instance
GObject parent_instance
Definition: fl_engine.cc:38
fl_engine_gl_clear_current
static bool fl_engine_gl_clear_current(void *user_data)
Definition: fl_engine.cc:248