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