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