| 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 <epoxy/egl.h>
8 #include <gmodule.h>
9
10 #include <cstring>
11
12 #include "flutter/common/constants.h"
13 #include "flutter/shell/platform/common/engine_switches.h"
14 #include "flutter/shell/platform/embedder/embedder.h"
15 #include "flutter/shell/platform/linux/fl_binary_messenger_private.h"
16 #include "flutter/shell/platform/linux/fl_dart_project_private.h"
17 #include "flutter/shell/platform/linux/fl_display_monitor.h"
18 #include "flutter/shell/platform/linux/fl_engine_private.h"
19 #include "flutter/shell/platform/linux/fl_framebuffer.h"
20 #include "flutter/shell/platform/linux/fl_keyboard_handler.h"
21 #include "flutter/shell/platform/linux/fl_opengl_manager.h"
22 #include "flutter/shell/platform/linux/fl_pixel_buffer_texture_private.h"
23 #include "flutter/shell/platform/linux/fl_platform_handler.h"
24 #include "flutter/shell/platform/linux/fl_plugin_registrar_private.h"
25 #include "flutter/shell/platform/linux/fl_settings_handler.h"
26 #include "flutter/shell/platform/linux/fl_texture_gl_private.h"
27 #include "flutter/shell/platform/linux/fl_texture_registrar_private.h"
28 #include "flutter/shell/platform/linux/fl_windowing_handler.h"
29 #include "flutter/shell/platform/linux/public/flutter_linux/fl_plugin_registry.h"
30
31 // Unique number associated with platform tasks.
32 static constexpr size_t kPlatformTaskRunnerIdentifier = 1;
33
34 // Use different device ID for mouse and pan/zoom events, since we can't
35 // differentiate the actual device (mouse v.s. trackpad)
36 static constexpr int32_t kMousePointerDeviceId = 0;
37 static constexpr int32_t kPointerPanZoomDeviceId = 1;
38
39 struct _FlEngine {
40 GObject parent_instance;
41
42 // Thread the GLib main loop is running on.
43 GThread* thread;
44
45 // The project this engine is running.
46 FlDartProject* project;
47
48 // Watches for monitors changes to update engine.
49 FlDisplayMonitor* display_monitor;
50
51 // Type of rendering performed.
52 FlutterRendererType renderer_type;
53
54 // Manages OpenGL contexts.
55 FlOpenGLManager* opengl_manager;
56
57 // Messenger used to send and receive platform messages.
58 FlBinaryMessenger* binary_messenger;
59
60 // Implements the flutter/settings channel.
61 FlSettingsHandler* settings_handler;
62
63 // Implements the flutter/platform channel.
64 FlPlatformHandler* platform_handler;
65
66 // Implements the flutter/windowing channel.
67 FlWindowingHandler* windowing_handler;
68
69 // Process keyboard events.
70 FlKeyboardManager* keyboard_manager;
71
72 // Implements the flutter/textinput channel.
73 FlTextInputHandler* text_input_handler;
74
75 // Implements the flutter/keyboard channel.
76 FlKeyboardHandler* keyboard_handler;
77
78 // Implements the flutter/mousecursor channel.
79 FlMouseCursorHandler* mouse_cursor_handler;
80
81 // Manages textures rendered by native code.
82 FlTextureRegistrar* texture_registrar;
83
84 // Schedules tasks to be run on the appropriate thread.
85 FlTaskRunner* task_runner;
86
87 // Ahead of time data used to make engine run faster.
88 FlutterEngineAOTData aot_data;
89
90 // The Flutter engine.
91 FLUTTER_API_SYMBOL(FlutterEngine) engine;
92
93 // Function table for engine API, used to intercept engine calls for testing
94 // purposes.
95 FlutterEngineProcTable embedder_api;
96
97 // Next ID to use for a view.
98 FlutterViewId next_view_id;
99
100 // Objects rendering the views.
101 GHashTable* renderables_by_view_id;
102
103 // Function to call when a platform message is received.
104 FlEnginePlatformMessageHandler platform_message_handler;
105 gpointer platform_message_handler_data;
106 GDestroyNotify platform_message_handler_destroy_notify;
107 };
108
109 G_DEFINE_QUARK(fl_engine_error_quark, fl_engine_error)
110
111 static void fl_engine_plugin_registry_iface_init(
112 FlPluginRegistryInterface* iface);
113
114 enum { SIGNAL_ON_PRE_ENGINE_RESTART, SIGNAL_UPDATE_SEMANTICS, LAST_SIGNAL };
115
116 static guint fl_engine_signals[LAST_SIGNAL];
117
118 G_DEFINE_TYPE_WITH_CODE(
119 FlEngine,
120 fl_engine,
121 G_TYPE_OBJECT,
122 G_IMPLEMENT_INTERFACE(fl_plugin_registry_get_type(),
123 fl_engine_plugin_registry_iface_init))
124
125 enum { PROP_0, PROP_BINARY_MESSENGER, PROP_LAST };
126
127 // Parse a locale into its components.
128 static void parse_locale(const gchar* locale,
129 gchar** language,
130 gchar** territory,
131 gchar** codeset,
132 gchar** modifier) {
133 gchar* l = g_strdup(locale);
134
135 // Locales are in the form "language[_territory][.codeset][@modifier]"
136 gchar* match = strrchr(l, '@');
137 if (match != nullptr) {
138 if (modifier != nullptr) {
139 *modifier = g_strdup(match + 1);
140 }
141 *match = '\0';
142 } else if (modifier != nullptr) {
143 *modifier = nullptr;
144 }
145
146 match = strrchr(l, '.');
147 if (match != nullptr) {
148 if (codeset != nullptr) {
149 *codeset = g_strdup(match + 1);
150 }
151 *match = '\0';
152 } else if (codeset != nullptr) {
153 *codeset = nullptr;
154 }
155
156 match = strrchr(l, '_');
157 if (match != nullptr) {
158 if (territory != nullptr) {
159 *territory = g_strdup(match + 1);
160 }
161 *match = '\0';
162 } else if (territory != nullptr) {
163 *territory = nullptr;
164 }
165
166 if (language != nullptr) {
167 *language = l;
168 }
169 }
170
171 static void view_added_cb(const FlutterAddViewResult* result) {
172 g_autoptr(GTask) task = G_TASK(result->user_data);
173
174 if (result->added) {
175 g_task_return_boolean(task, TRUE);
176 } else {
177 g_task_return_new_error(task, fl_engine_error_quark(),
178 FL_ENGINE_ERROR_FAILED, "Failed to add view");
179 }
180 }
181
182 static void view_removed_cb(const FlutterRemoveViewResult* result) {
183 g_autoptr(GTask) task = G_TASK(result->user_data);
184
185 if (result->removed) {
186 g_task_return_boolean(task, TRUE);
187 } else {
188 g_task_return_new_error(task, fl_engine_error_quark(),
189 FL_ENGINE_ERROR_FAILED, "Failed to remove view");
190 }
191 }
192
193 static void free_locale(FlutterLocale* locale) {
194 free(const_cast<gchar*>(locale->language_code));
195 free(const_cast<gchar*>(locale->country_code));
196 free(locale);
197 }
198
199 // Passes locale information to the Flutter engine.
200 static void setup_locales(FlEngine* self) {
201 const gchar* const* languages = g_get_language_names();
202 g_autoptr(GPtrArray) locales_array = g_ptr_array_new_with_free_func(
203 reinterpret_cast<GDestroyNotify>(free_locale));
204 for (int i = 0; languages[i] != nullptr; i++) {
205 g_autofree gchar* locale_string = g_strstrip(g_strdup(languages[i]));
206
207 // Ignore empty locales, caused by settings like `LANGUAGE=pt_BR:`
208 if (strcmp(locale_string, "") == 0) {
209 continue;
210 }
211
212 g_autofree gchar* language = nullptr;
213 g_autofree gchar* territory = nullptr;
214 parse_locale(locale_string, &language, &territory, nullptr, nullptr);
215
216 // Ignore duplicate locales, caused by settings like `LANGUAGE=C` (returns
217 // two "C") or `LANGUAGE=en:en`
218 gboolean has_locale = FALSE;
219 for (guint j = 0; !has_locale && j < locales_array->len; j++) {
220 FlutterLocale* locale =
221 reinterpret_cast<FlutterLocale*>(g_ptr_array_index(locales_array, j));
222 has_locale = g_strcmp0(locale->language_code, language) == 0 &&
223 g_strcmp0(locale->country_code, territory) == 0;
224 }
225 if (has_locale) {
226 continue;
227 }
228
229 FlutterLocale* locale =
230 static_cast<FlutterLocale*>(g_malloc0(sizeof(FlutterLocale)));
231 g_ptr_array_add(locales_array, locale);
232 locale->struct_size = sizeof(FlutterLocale);
233 locale->language_code =
234 reinterpret_cast<const gchar*>(g_steal_pointer(&language));
235 locale->country_code =
236 reinterpret_cast<const gchar*>(g_steal_pointer(&territory));
237 locale->script_code = nullptr;
238 locale->variant_code = nullptr;
239 }
240 FlutterLocale** locales =
241 reinterpret_cast<FlutterLocale**>(locales_array->pdata);
242 FlutterEngineResult result = self->embedder_api.UpdateLocales(
243 self->engine, const_cast<const FlutterLocale**>(locales),
244 locales_array->len);
245 if (result != kSuccess) {
246 g_warning("Failed to set up Flutter locales");
247 }
248 }
249
250 static bool create_opengl_backing_store(
251 FlEngine* self,
252 const FlutterBackingStoreConfig* config,
253 FlutterBackingStore* backing_store_out) {
254 fl_opengl_manager_make_current(self->opengl_manager);
255
256 GLint sized_format = GL_RGBA8;
257 GLint general_format = GL_RGBA;
258 if (epoxy_has_gl_extension("GL_EXT_texture_format_BGRA8888")) {
259 sized_format = GL_BGRA8_EXT;
260 general_format = GL_BGRA_EXT;
261 }
262
263 FlFramebuffer* framebuffer = fl_framebuffer_new(
264 general_format, config->size.width, config->size.height);
265 if (!framebuffer) {
266 g_warning("Failed to create backing store");
267 return false;
268 }
269
270 backing_store_out->type = kFlutterBackingStoreTypeOpenGL;
271 backing_store_out->open_gl.type = kFlutterOpenGLTargetTypeFramebuffer;
272 backing_store_out->open_gl.framebuffer.user_data = framebuffer;
273 backing_store_out->open_gl.framebuffer.name =
274 fl_framebuffer_get_id(framebuffer);
275 backing_store_out->open_gl.framebuffer.target = sized_format;
276 backing_store_out->open_gl.framebuffer.destruction_callback = [](void* p) {
277 // Backing store destroyed in fl_compositor_opengl_collect_backing_store(),
278 // set on FlutterCompositor.collect_backing_store_callback during engine
279 // start.
280 };
281
282 return true;
283 }
284
285 static bool collect_opengl_backing_store(
286 FlEngine* self,
287 const FlutterBackingStore* backing_store) {
288 fl_opengl_manager_make_current(self->opengl_manager);
289
290 // OpenGL context is required when destroying #FlFramebuffer.
291 g_object_unref(backing_store->open_gl.framebuffer.user_data);
292 return true;
293 }
294
295 static bool create_software_backing_store(
296 FlEngine* self,
297 const FlutterBackingStoreConfig* config,
298 FlutterBackingStore* backing_store_out) {
299 size_t allocation_length = config->size.width * config->size.height * 4;
300 uint8_t* allocation = static_cast<uint8_t*>(malloc(allocation_length));
301 if (allocation == nullptr) {
302 return false;
303 }
304
305 backing_store_out->type = kFlutterBackingStoreTypeSoftware;
306 backing_store_out->software.allocation = allocation;
307 backing_store_out->software.height = config->size.height;
308 backing_store_out->software.row_bytes = config->size.width * 4;
309 backing_store_out->software.user_data = nullptr;
310 backing_store_out->software.destruction_callback = [](void* p) {
311 // Backing store destroyed in
312 // fl_compositor_software_collect_backing_store(), set on
313 // FlutterCompositor.collect_backing_store_callback during engine start.
314 };
315
316 return true;
317 }
318
319 static bool collect_software_backing_store(
320 FlEngine* self,
321 const FlutterBackingStore* backing_store) {
322 free(const_cast<void*>(backing_store->software.allocation));
323 return true;
324 }
325
326 // Called when engine needs a backing store for a specific #FlutterLayer.
327 static bool compositor_create_backing_store_callback(
328 const FlutterBackingStoreConfig* config,
329 FlutterBackingStore* backing_store_out,
330 void* user_data) {
331 FlEngine* self = static_cast<FlEngine*>(user_data);
332 switch (self->renderer_type) {
333 case kOpenGL:
334 return create_opengl_backing_store(self, config, backing_store_out);
335 case kSoftware:
336 return create_software_backing_store(self, config, backing_store_out);
337 default:
338 return false;
339 }
340 }
341
342 // Called when the backing store is to be released.
343 static bool compositor_collect_backing_store_callback(
344 const FlutterBackingStore* backing_store,
345 void* user_data) {
346 FlEngine* self = static_cast<FlEngine*>(user_data);
347 switch (self->renderer_type) {
348 case kOpenGL:
349 return collect_opengl_backing_store(self, backing_store);
350 case kSoftware:
351 return collect_software_backing_store(self, backing_store);
352 default:
353 return false;
354 }
355 }
356
357 // Called when embedder should composite contents of each layer onto the screen.
358 static bool compositor_present_view_callback(
359 const FlutterPresentViewInfo* info) {
360 FlEngine* self = static_cast<FlEngine*>(info->user_data);
361
362 GWeakRef* ref = static_cast<GWeakRef*>(g_hash_table_lookup(
363 self->renderables_by_view_id, GINT_TO_POINTER(info->view_id)));
364 if (ref == nullptr) {
365 return true;
366 }
367 g_autoptr(FlRenderable) renderable = FL_RENDERABLE(g_weak_ref_get(ref));
368 if (renderable == nullptr) {
369 return true;
370 }
371
372 fl_renderable_present_layers(renderable, info->layers, info->layers_count);
373 return true;
374 }
375
376 // Flutter engine rendering callbacks.
377
378 static void* fl_engine_gl_proc_resolver(void* user_data, const char* name) {
379 return reinterpret_cast<void*>(eglGetProcAddress(name));
380 }
381
382 static bool fl_engine_gl_make_current(void* user_data) {
383 FlEngine* self = static_cast<FlEngine*>(user_data);
384 fl_opengl_manager_make_current(self->opengl_manager);
385 return true;
386 }
387
388 static bool fl_engine_gl_clear_current(void* user_data) {
389 FlEngine* self = static_cast<FlEngine*>(user_data);
390 fl_opengl_manager_clear_current(self->opengl_manager);
391 return true;
392 }
393
394 static uint32_t fl_engine_gl_get_fbo(void* user_data) {
395 // There is only one frame buffer object - always return that.
396 return 0;
397 }
398
399 static bool fl_engine_gl_make_resource_current(void* user_data) {
400 FlEngine* self = static_cast<FlEngine*>(user_data);
401 fl_opengl_manager_make_resource_current(self->opengl_manager);
402 return true;
403 }
404
405 // Called by the engine to retrieve an external texture.
406 static bool fl_engine_gl_external_texture_frame_callback(
407 void* user_data,
408 int64_t texture_id,
409 size_t width,
410 size_t height,
411 FlutterOpenGLTexture* opengl_texture) {
412 FlEngine* self = static_cast<FlEngine*>(user_data);
413 if (!self->texture_registrar) {
414 return false;
415 }
416
417 FlTexture* texture =
418 fl_texture_registrar_lookup_texture(self->texture_registrar, texture_id);
419 if (texture == nullptr) {
420 g_warning("Unable to find texture %" G_GINT64_FORMAT, texture_id);
421 return false;
422 }
423
424 gboolean result;
425 g_autoptr(GError) error = nullptr;
426 if (FL_IS_TEXTURE_GL(texture)) {
427 result = fl_texture_gl_populate(FL_TEXTURE_GL(texture), width, height,
428 opengl_texture, &error);
429 } else if (FL_IS_PIXEL_BUFFER_TEXTURE(texture)) {
430 result =
431 fl_pixel_buffer_texture_populate(FL_PIXEL_BUFFER_TEXTURE(texture),
432 width, height, opengl_texture, &error);
433 } else {
434 g_warning("Unsupported texture type %" G_GINT64_FORMAT, texture_id);
435 return false;
436 }
437
438 if (!result) {
439 g_warning("%s", error->message);
440 return false;
441 }
442
443 return true;
444 }
445
446 // Called by the engine to determine if it is on the GTK thread.
447 static bool fl_engine_runs_task_on_current_thread(void* user_data) {
448 FlEngine* self = static_cast<FlEngine*>(user_data);
449 return self->thread == g_thread_self();
450 }
451
452 // Called when the engine has a task to perform in the GTK thread.
453 static void fl_engine_post_task(FlutterTask task,
454 uint64_t target_time_nanos,
455 void* user_data) {
456 FlEngine* self = static_cast<FlEngine*>(user_data);
457
458 fl_task_runner_post_flutter_task(self->task_runner, task, target_time_nanos);
459 }
460
461 // Called when a platform message is received from the engine.
462 static void fl_engine_platform_message_cb(const FlutterPlatformMessage* message,
463 void* user_data) {
464 FlEngine* self = FL_ENGINE(user_data);
465
466 gboolean handled = FALSE;
467 if (self->platform_message_handler != nullptr) {
468 g_autoptr(GBytes) data =
469 g_bytes_new(message->message, message->message_size);
470 handled = self->platform_message_handler(
471 self, message->channel, data, message->response_handle,
472 self->platform_message_handler_data);
473 }
474
475 if (!handled) {
476 fl_engine_send_platform_message_response(self, message->response_handle,
477 nullptr, nullptr);
478 }
479 }
480
481 // Called when a semantic node update is received from the engine.
482 static void fl_engine_update_semantics_cb(const FlutterSemanticsUpdate2* update,
483 void* user_data) {
484 FlEngine* self = FL_ENGINE(user_data);
485
486 g_signal_emit(self, fl_engine_signals[SIGNAL_UPDATE_SEMANTICS], 0, update);
487 }
488
489 static void setup_keyboard(FlEngine* self) {
490 g_clear_object(&self->keyboard_manager);
491 self->keyboard_manager = fl_keyboard_manager_new(self);
492
493 g_clear_object(&self->keyboard_handler);
494 self->keyboard_handler =
495 fl_keyboard_handler_new(self->binary_messenger, self->keyboard_manager);
496
497 GtkWidget* widget =
498 self->text_input_handler != nullptr
499 ? fl_text_input_handler_get_widget(self->text_input_handler)
500 : nullptr;
501 g_clear_object(&self->text_input_handler);
502 self->text_input_handler = fl_text_input_handler_new(self->binary_messenger);
503 if (widget != nullptr) {
504 fl_text_input_handler_set_widget(self->text_input_handler, widget);
505 }
506 }
507
508 // Called right before the engine is restarted.
509 //
510 // This method should reset states to as if the engine has just been started,
511 // which usually indicates the user has requested a hot restart (Shift-R in the
512 // Flutter CLI.)
513 static void fl_engine_on_pre_engine_restart_cb(void* user_data) {
514 FlEngine* self = FL_ENGINE(user_data);
515
516 setup_keyboard(self);
517
518 g_signal_emit(self, fl_engine_signals[SIGNAL_ON_PRE_ENGINE_RESTART], 0);
519 }
520
521 // Called when a response to a sent platform message is received from the
522 // engine.
523 static void fl_engine_platform_message_response_cb(const uint8_t* data,
524 size_t data_length,
525 void* user_data) {
526 g_autoptr(GTask) task = G_TASK(user_data);
527 g_task_return_pointer(task, g_bytes_new(data, data_length),
528 reinterpret_cast<GDestroyNotify>(g_bytes_unref));
529 }
530
531 // Implements FlPluginRegistry::get_registrar_for_plugin.
532 static FlPluginRegistrar* fl_engine_get_registrar_for_plugin(
533 FlPluginRegistry* registry,
534 const gchar* name) {
535 FlEngine* self = FL_ENGINE(registry);
536
537 return fl_plugin_registrar_new(nullptr, self->binary_messenger,
538 self->texture_registrar);
539 }
540
541 static void fl_engine_plugin_registry_iface_init(
542 FlPluginRegistryInterface* iface) {
543 iface->get_registrar_for_plugin = fl_engine_get_registrar_for_plugin;
544 }
545
546 static void fl_engine_set_property(GObject* object,
547 guint prop_id,
548 const GValue* value,
549 GParamSpec* pspec) {
550 FlEngine* self = FL_ENGINE(object);
551 switch (prop_id) {
552 case PROP_BINARY_MESSENGER:
553 g_set_object(&self->binary_messenger,
554 FL_BINARY_MESSENGER(g_value_get_object(value)));
555 break;
556 default:
557 G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
558 break;
559 }
560 }
561
562 static void fl_engine_dispose(GObject* object) {
563 FlEngine* self = FL_ENGINE(object);
564
565 if (self->engine != nullptr) {
566 self->embedder_api.Shutdown(self->engine);
567 self->engine = nullptr;
568 }
569
570 if (self->aot_data != nullptr) {
571 self->embedder_api.CollectAOTData(self->aot_data);
572 self->aot_data = nullptr;
573 }
574
575 fl_binary_messenger_shutdown(self->binary_messenger);
576 fl_texture_registrar_shutdown(self->texture_registrar);
577
578 g_clear_object(&self->project);
579 g_clear_object(&self->display_monitor);
580 g_clear_object(&self->opengl_manager);
581 g_clear_object(&self->texture_registrar);
582 g_clear_object(&self->binary_messenger);
583 g_clear_object(&self->settings_handler);
584 g_clear_object(&self->platform_handler);
585 g_clear_object(&self->windowing_handler);
586 g_clear_object(&self->keyboard_manager);
587 g_clear_object(&self->text_input_handler);
588 g_clear_object(&self->keyboard_handler);
589 g_clear_object(&self->mouse_cursor_handler);
590 g_clear_object(&self->task_runner);
591 g_clear_pointer(&self->renderables_by_view_id, g_hash_table_unref);
592
593 if (self->platform_message_handler_destroy_notify) {
594 self->platform_message_handler_destroy_notify(
595 self->platform_message_handler_data);
596 }
597 self->platform_message_handler_data = nullptr;
598 self->platform_message_handler_destroy_notify = nullptr;
599
600 G_OBJECT_CLASS(fl_engine_parent_class)->dispose(object);
601 }
602
603 static void fl_engine_class_init(FlEngineClass* klass) {
604 G_OBJECT_CLASS(klass)->dispose = fl_engine_dispose;
605 G_OBJECT_CLASS(klass)->set_property = fl_engine_set_property;
606
607 g_object_class_install_property(
608 G_OBJECT_CLASS(klass), PROP_BINARY_MESSENGER,
609 g_param_spec_object(
610 "binary-messenger", "messenger", "Binary messenger",
611 fl_binary_messenger_get_type(),
612 static_cast<GParamFlags>(G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY |
613 G_PARAM_STATIC_STRINGS)));
614
615 fl_engine_signals[SIGNAL_ON_PRE_ENGINE_RESTART] = g_signal_new(
616 "on-pre-engine-restart", fl_engine_get_type(), G_SIGNAL_RUN_LAST, 0,
617 nullptr, nullptr, nullptr, G_TYPE_NONE, 0);
618 fl_engine_signals[SIGNAL_UPDATE_SEMANTICS] = g_signal_new(
619 "update-semantics", fl_engine_get_type(), G_SIGNAL_RUN_LAST, 0, nullptr,
620 nullptr, nullptr, G_TYPE_NONE, 1, G_TYPE_POINTER);
621 }
622
623 static void fl_engine_init(FlEngine* self) {
624 self->thread = g_thread_self();
625
626 self->embedder_api.struct_size = sizeof(FlutterEngineProcTable);
627 if (FlutterEngineGetProcAddresses(&self->embedder_api) != kSuccess) {
628 g_warning("Failed get get engine function pointers");
629 }
630
631 self->opengl_manager = fl_opengl_manager_new();
632
633 self->display_monitor =
634 fl_display_monitor_new(self, gdk_display_get_default());
635 self->task_runner = fl_task_runner_new(self);
636
637 // Implicit view is 0, so start at 1.
638 self->next_view_id = 1;
639 self->renderables_by_view_id = g_hash_table_new_full(
640 g_direct_hash, g_direct_equal, nullptr, [](gpointer value) {
641 GWeakRef* ref = static_cast<GWeakRef*>(value);
642 g_weak_ref_clear(ref);
643 free(ref);
644 });
645
646 self->texture_registrar = fl_texture_registrar_new(self);
647 }
648
649 static FlEngine* fl_engine_new_full(FlDartProject* project,
650 FlBinaryMessenger* binary_messenger) {
651 g_return_val_if_fail(FL_IS_DART_PROJECT(project), nullptr);
652
653 FlEngine* self = FL_ENGINE(g_object_new(fl_engine_get_type(), nullptr));
654
655 self->project = FL_DART_PROJECT(g_object_ref(project));
656 const gchar* renderer = g_getenv("FLUTTER_LINUX_RENDERER");
657 if (g_strcmp0(renderer, "software") == 0) {
658 self->renderer_type = kSoftware;
659 g_warning(
660 "Using the software renderer. Not all features are supported. This is "
661 "not recommended.\n"
662 "\n"
663 "To switch back to the default renderer, unset the "
664 "FLUTTER_LINUX_RENDERER environment variable.");
665 } else {
666 if (renderer != nullptr && strcmp(renderer, "opengl") != 0) {
667 g_warning("Unknown renderer type '%s', defaulting to opengl", renderer);
668 }
669 self->renderer_type = kOpenGL;
670 }
671 if (binary_messenger != nullptr) {
672 self->binary_messenger =
673 FL_BINARY_MESSENGER(g_object_ref(binary_messenger));
674 } else {
675 self->binary_messenger = fl_binary_messenger_new(self);
676 }
677 self->keyboard_manager = fl_keyboard_manager_new(self);
678 self->mouse_cursor_handler =
679 fl_mouse_cursor_handler_new(self->binary_messenger);
680 self->windowing_handler = fl_windowing_handler_new(self);
681
682 return self;
683 }
684
685 FlEngine* fl_engine_for_id(int64_t id) {
686 void* engine = reinterpret_cast<void*>(id);
687 g_return_val_if_fail(FL_IS_ENGINE(engine), nullptr);
688 return FL_ENGINE(engine);
689 }
690
691 G_MODULE_EXPORT FlEngine* fl_engine_new(FlDartProject* project) {
692 return fl_engine_new_full(project, nullptr);
693 }
694
695 FlEngine* fl_engine_new_with_binary_messenger(
696 FlBinaryMessenger* binary_messenger) {
697 g_autoptr(FlDartProject) project = fl_dart_project_new();
698 return fl_engine_new_full(project, binary_messenger);
699 }
700
701 G_MODULE_EXPORT FlEngine* fl_engine_new_headless(FlDartProject* project) {
702 return fl_engine_new(project);
703 }
704
705 FlutterRendererType fl_engine_get_renderer_type(FlEngine* self) {
706 g_return_val_if_fail(FL_IS_ENGINE(self), static_cast<FlutterRendererType>(0));
707 return self->renderer_type;
708 }
709
710 FlOpenGLManager* fl_engine_get_opengl_manager(FlEngine* self) {
711 g_return_val_if_fail(FL_IS_ENGINE(self), nullptr);
712 return self->opengl_manager;
713 }
714
715 FlDisplayMonitor* fl_engine_get_display_monitor(FlEngine* self) {
716 g_return_val_if_fail(FL_IS_ENGINE(self), nullptr);
717 return self->display_monitor;
718 }
719
720 gboolean fl_engine_start(FlEngine* self, GError** error) {
721 g_return_val_if_fail(FL_IS_ENGINE(self), FALSE);
722
723 FlutterRendererConfig config = {};
724 config.type = self->renderer_type;
725 switch (config.type) {
726 case kSoftware:
727 config.software.struct_size = sizeof(FlutterSoftwareRendererConfig);
728 // No action required, as this is handled in
729 // compositor_present_view_callback.
730 config.software.surface_present_callback =
731 [](void* user_data, const void* allocation, size_t row_bytes,
732 size_t height) { return true; };
733 break;
734 case kOpenGL:
735 config.open_gl.struct_size = sizeof(FlutterOpenGLRendererConfig);
736 config.open_gl.gl_proc_resolver = fl_engine_gl_proc_resolver;
737 config.open_gl.make_current = fl_engine_gl_make_current;
738 config.open_gl.clear_current = fl_engine_gl_clear_current;
739 config.open_gl.fbo_callback = fl_engine_gl_get_fbo;
740 // No action required, as this is handled in
741 // compositor_present_view_callback.
742 config.open_gl.present = [](void* user_data) { return true; };
743 config.open_gl.make_resource_current = fl_engine_gl_make_resource_current;
744 config.open_gl.gl_external_texture_frame_callback =
745 fl_engine_gl_external_texture_frame_callback;
746 break;
747 case kMetal:
748 case kVulkan:
749 default:
750 g_set_error(error, fl_engine_error_quark(), FL_ENGINE_ERROR_FAILED,
751 "Unsupported renderer type");
752 return FALSE;
753 }
754
755 FlutterTaskRunnerDescription platform_task_runner = {};
756 platform_task_runner.struct_size = sizeof(FlutterTaskRunnerDescription);
757 platform_task_runner.user_data = self;
758 platform_task_runner.runs_task_on_current_thread_callback =
759 fl_engine_runs_task_on_current_thread;
760 platform_task_runner.post_task_callback = fl_engine_post_task;
761 platform_task_runner.identifier = kPlatformTaskRunnerIdentifier;
762
763 FlutterCustomTaskRunners custom_task_runners = {};
764 custom_task_runners.struct_size = sizeof(FlutterCustomTaskRunners);
765 custom_task_runners.platform_task_runner = &platform_task_runner;
766
767 if (fl_dart_project_get_ui_thread_policy(self->project) ==
768 FL_UI_THREAD_POLICY_RUN_ON_PLATFORM_THREAD) {
769 custom_task_runners.ui_task_runner = &platform_task_runner;
770 }
771
772 g_autoptr(GPtrArray) command_line_args =
773 g_ptr_array_new_with_free_func(g_free);
774 g_ptr_array_insert(command_line_args, 0, g_strdup("flutter"));
775 for (const auto& env_switch : flutter::GetSwitchesFromEnvironment()) {
776 g_ptr_array_add(command_line_args, g_strdup(env_switch.c_str()));
777 }
778
779 gchar** dart_entrypoint_args =
780 fl_dart_project_get_dart_entrypoint_arguments(self->project);
781
782 FlutterProjectArgs args = {};
783 args.struct_size = sizeof(FlutterProjectArgs);
784 args.assets_path = fl_dart_project_get_assets_path(self->project);
785 args.icu_data_path = fl_dart_project_get_icu_data_path(self->project);
786 args.command_line_argc = command_line_args->len;
787 args.command_line_argv =
788 reinterpret_cast<const char* const*>(command_line_args->pdata);
789 args.platform_message_callback = fl_engine_platform_message_cb;
790 args.update_semantics_callback2 = fl_engine_update_semantics_cb;
791 args.custom_task_runners = &custom_task_runners;
792 args.shutdown_dart_vm_when_done = true;
793 args.on_pre_engine_restart_callback = fl_engine_on_pre_engine_restart_cb;
794 args.dart_entrypoint_argc =
795 dart_entrypoint_args != nullptr ? g_strv_length(dart_entrypoint_args) : 0;
796 args.dart_entrypoint_argv =
797 reinterpret_cast<const char* const*>(dart_entrypoint_args);
798 args.engine_id = reinterpret_cast<int64_t>(self);
799
800 FlutterCompositor compositor = {};
801 compositor.struct_size = sizeof(FlutterCompositor);
802 compositor.user_data = self;
803 compositor.create_backing_store_callback =
804 compositor_create_backing_store_callback;
805 compositor.collect_backing_store_callback =
806 compositor_collect_backing_store_callback;
807 compositor.present_view_callback = compositor_present_view_callback;
808 args.compositor = &compositor;
809
810 if (self->embedder_api.RunsAOTCompiledDartCode()) {
811 FlutterEngineAOTDataSource source = {};
812 source.type = kFlutterEngineAOTDataSourceTypeElfPath;
813 source.elf_path = fl_dart_project_get_aot_library_path(self->project);
814 if (self->embedder_api.CreateAOTData(&source, &self->aot_data) !=
815 kSuccess) {
816 g_set_error(error, fl_engine_error_quark(), FL_ENGINE_ERROR_FAILED,
817 "Failed to create AOT data");
818 return FALSE;
819 }
820 args.aot_data = self->aot_data;
821 }
822
823 FlutterEngineResult result = self->embedder_api.Initialize(
824 FLUTTER_ENGINE_VERSION, &config, &args, self, &self->engine);
825 if (result != kSuccess) {
826 g_set_error(error, fl_engine_error_quark(), FL_ENGINE_ERROR_FAILED,
827 "Failed to initialize Flutter engine");
828 return FALSE;
829 }
830
831 result = self->embedder_api.RunInitialized(self->engine);
832 if (result != kSuccess) {
833 g_set_error(error, fl_engine_error_quark(), FL_ENGINE_ERROR_FAILED,
834 "Failed to run Flutter engine");
835 return FALSE;
836 }
837
838 setup_locales(self);
839
840 g_autoptr(FlSettings) settings = fl_settings_new();
841 self->settings_handler = fl_settings_handler_new(self);
842 fl_settings_handler_start(self->settings_handler, settings);
843
844 self->platform_handler = fl_platform_handler_new(self->binary_messenger);
845
846 setup_keyboard(self);
847
848 result = self->embedder_api.UpdateSemanticsEnabled(self->engine, TRUE);
849 if (result != kSuccess) {
850 g_warning("Failed to enable accessibility features on Flutter engine");
851 }
852
853 fl_display_monitor_start(self->display_monitor);
854
855 return TRUE;
856 }
857
858 FlutterEngineProcTable* fl_engine_get_embedder_api(FlEngine* self) {
859 return &(self->embedder_api);
860 }
861
862 void fl_engine_notify_display_update(FlEngine* self,
863 const FlutterEngineDisplay* displays,
864 size_t displays_length) {
865 g_return_if_fail(FL_IS_ENGINE(self));
866
867 FlutterEngineResult result = self->embedder_api.NotifyDisplayUpdate(
868 self->engine, kFlutterEngineDisplaysUpdateTypeStartup, displays,
869 displays_length);
870 if (result != kSuccess) {
871 g_warning("Failed to notify display update to Flutter engine: %d", result);
872 }
873 }
874
875 void fl_engine_set_implicit_view(FlEngine* self, FlRenderable* renderable) {
876 GWeakRef* ref = g_new(GWeakRef, 1);
877 g_weak_ref_init(ref, G_OBJECT(renderable));
878 g_hash_table_insert(self->renderables_by_view_id,
879 GINT_TO_POINTER(flutter::kFlutterImplicitViewId), ref);
880 }
881
882 FlutterViewId fl_engine_add_view(FlEngine* self,
883 FlRenderable* renderable,
884 size_t width,
885 size_t height,
886 double pixel_ratio,
887 GCancellable* cancellable,
888 GAsyncReadyCallback callback,
889 gpointer user_data) {
890 g_return_val_if_fail(FL_IS_ENGINE(self), -1);
891
892 g_autoptr(GTask) task = g_task_new(self, cancellable, callback, user_data);
893
894 FlutterViewId view_id = self->next_view_id;
895 self->next_view_id++;
896
897 GWeakRef* ref = g_new(GWeakRef, 1);
898 g_weak_ref_init(ref, G_OBJECT(renderable));
899 g_hash_table_insert(self->renderables_by_view_id, GINT_TO_POINTER(view_id),
900 ref);
901
902 // We don't know which display this view will open on, so set to zero and this
903 // will be updated in a following FlutterWindowMetricsEvent
904 FlutterEngineDisplayId display_id = 0;
905
906 FlutterWindowMetricsEvent metrics = {};
907 metrics.struct_size = sizeof(FlutterWindowMetricsEvent);
908 metrics.width = width;
909 metrics.height = height;
910 metrics.pixel_ratio = pixel_ratio;
911 metrics.display_id = display_id;
912 metrics.view_id = view_id;
913 FlutterAddViewInfo info;
914 info.struct_size = sizeof(FlutterAddViewInfo);
915 info.view_id = view_id;
916 info.view_metrics = &metrics;
917 info.user_data = g_object_ref(task);
918 info.add_view_callback = view_added_cb;
919 FlutterEngineResult result = self->embedder_api.AddView(self->engine, &info);
920 if (result != kSuccess) {
921 g_task_return_new_error(task, fl_engine_error_quark(),
922 FL_ENGINE_ERROR_FAILED, "AddView returned %d",
923 result);
924 // This would have been done in the callback, but that won't occur now.
925 g_object_unref(task);
926 }
927
928 return view_id;
929 }
930
931 gboolean fl_engine_add_view_finish(FlEngine* self,
932 GAsyncResult* result,
933 GError** error) {
934 g_return_val_if_fail(FL_IS_ENGINE(self), FALSE);
935 return g_task_propagate_boolean(G_TASK(result), error);
936 }
937
938 FlRenderable* fl_engine_get_renderable(FlEngine* self, FlutterViewId view_id) {
939 g_return_val_if_fail(FL_IS_ENGINE(self), nullptr);
940
941 GWeakRef* ref = static_cast<GWeakRef*>(g_hash_table_lookup(
942 self->renderables_by_view_id, GINT_TO_POINTER(view_id)));
943 return FL_RENDERABLE(g_weak_ref_get(ref));
944 }
945
946 void fl_engine_remove_view(FlEngine* self,
947 FlutterViewId view_id,
948 GCancellable* cancellable,
949 GAsyncReadyCallback callback,
950 gpointer user_data) {
951 g_return_if_fail(FL_IS_ENGINE(self));
952
953 g_hash_table_remove(self->renderables_by_view_id, GINT_TO_POINTER(view_id));
954
955 g_autoptr(GTask) task = g_task_new(self, cancellable, callback, user_data);
956
957 FlutterRemoveViewInfo info;
958 info.struct_size = sizeof(FlutterRemoveViewInfo);
959 info.view_id = view_id;
960 info.user_data = g_object_ref(task);
961 info.remove_view_callback = view_removed_cb;
962 FlutterEngineResult result =
963 self->embedder_api.RemoveView(self->engine, &info);
964 if (result != kSuccess) {
965 g_task_return_new_error(task, fl_engine_error_quark(),
966 FL_ENGINE_ERROR_FAILED, "RemoveView returned %d",
967 result);
968 // This would have been done in the callback, but that won't occur now.
969 g_object_unref(task);
970 }
971 }
972
973 gboolean fl_engine_remove_view_finish(FlEngine* self,
974 GAsyncResult* result,
975 GError** error) {
976 g_return_val_if_fail(FL_IS_ENGINE(self), FALSE);
977 return g_task_propagate_boolean(G_TASK(result), error);
978 }
979
980 void fl_engine_set_platform_message_handler(
981 FlEngine* self,
982 FlEnginePlatformMessageHandler handler,
983 gpointer user_data,
984 GDestroyNotify destroy_notify) {
985 g_return_if_fail(FL_IS_ENGINE(self));
986 g_return_if_fail(handler != nullptr);
987
988 if (self->platform_message_handler_destroy_notify) {
989 self->platform_message_handler_destroy_notify(
990 self->platform_message_handler_data);
991 }
992
993 self->platform_message_handler = handler;
994 self->platform_message_handler_data = user_data;
995 self->platform_message_handler_destroy_notify = destroy_notify;
996 }
997
998 // Note: This function can be called from any thread.
999 gboolean fl_engine_send_platform_message_response(
1000 FlEngine* self,
1001 const FlutterPlatformMessageResponseHandle* handle,
1002 GBytes* response,
1003 GError** error) {
1004 g_return_val_if_fail(FL_IS_ENGINE(self), FALSE);
1005 g_return_val_if_fail(handle != nullptr, FALSE);
1006
1007 if (self->engine == nullptr) {
1008 g_set_error(error, fl_engine_error_quark(), FL_ENGINE_ERROR_FAILED,
1009 "No engine to send response to");
1010 return FALSE;
1011 }
1012
1013 gsize data_length = 0;
1014 const uint8_t* data = nullptr;
1015 if (response != nullptr) {
1016 data =
1017 static_cast<const uint8_t*>(g_bytes_get_data(response, &data_length));
1018 }
1019 FlutterEngineResult result = self->embedder_api.SendPlatformMessageResponse(
1020 self->engine, handle, data, data_length);
1021
1022 if (result != kSuccess) {
1023 g_set_error(error, fl_engine_error_quark(), FL_ENGINE_ERROR_FAILED,
1024 "Failed to send platform message response");
1025 return FALSE;
1026 }
1027
1028 return TRUE;
1029 }
1030
1031 void fl_engine_send_platform_message(FlEngine* self,
1032 const gchar* channel,
1033 GBytes* message,
1034 GCancellable* cancellable,
1035 GAsyncReadyCallback callback,
1036 gpointer user_data) {
1037 g_return_if_fail(FL_IS_ENGINE(self));
1038
1039 GTask* task = nullptr;
1040 FlutterPlatformMessageResponseHandle* response_handle = nullptr;
1041 if (callback != nullptr) {
1042 task = g_task_new(self, cancellable, callback, user_data);
1043
1044 if (self->engine == nullptr) {
1045 g_task_return_new_error(task, fl_engine_error_quark(),
1046 FL_ENGINE_ERROR_FAILED, "No engine to send to");
1047 return;
1048 }
1049
1050 FlutterEngineResult result =
1051 self->embedder_api.PlatformMessageCreateResponseHandle(
1052 self->engine, fl_engine_platform_message_response_cb, task,
1053 &response_handle);
1054 if (result != kSuccess) {
1055 g_task_return_new_error(task, fl_engine_error_quark(),
1056 FL_ENGINE_ERROR_FAILED,
1057 "Failed to create response handle");
1058 g_object_unref(task);
1059 return;
1060 }
1061 } else if (self->engine == nullptr) {
1062 return;
1063 }
1064
1065 FlutterPlatformMessage fl_message = {};
1066 fl_message.struct_size = sizeof(fl_message);
1067 fl_message.channel = channel;
1068 fl_message.message =
1069 message != nullptr
1070 ? static_cast<const uint8_t*>(g_bytes_get_data(message, nullptr))
1071 : nullptr;
1072 fl_message.message_size = message != nullptr ? g_bytes_get_size(message) : 0;
1073 fl_message.response_handle = response_handle;
1074 FlutterEngineResult result =
1075 self->embedder_api.SendPlatformMessage(self->engine, &fl_message);
1076
1077 if (result != kSuccess && task != nullptr) {
1078 g_task_return_new_error(task, fl_engine_error_quark(),
1079 FL_ENGINE_ERROR_FAILED,
1080 "Failed to send platform messages");
1081 g_object_unref(task);
1082 }
1083
1084 if (response_handle != nullptr) {
1085 self->embedder_api.PlatformMessageReleaseResponseHandle(self->engine,
1086 response_handle);
1087 }
1088 }
1089
1090 GBytes* fl_engine_send_platform_message_finish(FlEngine* self,
1091 GAsyncResult* result,
1092 GError** error) {
1093 g_return_val_if_fail(FL_IS_ENGINE(self), FALSE);
1094 g_return_val_if_fail(g_task_is_valid(result, self), FALSE);
1095
1096 return static_cast<GBytes*>(g_task_propagate_pointer(G_TASK(result), error));
1097 }
1098
1099 void fl_engine_send_window_metrics_event(FlEngine* self,
1100 FlutterEngineDisplayId display_id,
1101 FlutterViewId view_id,
1102 size_t width,
1103 size_t height,
1104 double pixel_ratio) {
1105 g_return_if_fail(FL_IS_ENGINE(self));
1106
1107 if (self->engine == nullptr) {
1108 return;
1109 }
1110
1111 FlutterWindowMetricsEvent event = {};
1112 event.struct_size = sizeof(FlutterWindowMetricsEvent);
1113 event.width = width;
1114 event.height = height;
1115 event.pixel_ratio = pixel_ratio;
1116 event.display_id = display_id;
1117 event.view_id = view_id;
1118 self->embedder_api.SendWindowMetricsEvent(self->engine, &event);
1119 }
1120
1121 void fl_engine_send_mouse_pointer_event(FlEngine* self,
1122 FlutterViewId view_id,
1123 FlutterPointerPhase phase,
1124 size_t timestamp,
1125 double x,
1126 double y,
1127 FlutterPointerDeviceKind device_kind,
1128 double scroll_delta_x,
1129 double scroll_delta_y,
1130 int64_t buttons) {
1131 g_return_if_fail(FL_IS_ENGINE(self));
1132
1133 if (self->engine == nullptr) {
1134 return;
1135 }
1136
1137 FlutterPointerEvent fl_event = {};
1138 fl_event.struct_size = sizeof(fl_event);
1139 fl_event.phase = phase;
1140 fl_event.timestamp = timestamp;
1141 fl_event.x = x;
1142 fl_event.y = y;
1143 if (scroll_delta_x != 0 || scroll_delta_y != 0) {
1144 fl_event.signal_kind = kFlutterPointerSignalKindScroll;
1145 }
1146 fl_event.scroll_delta_x = scroll_delta_x;
1147 fl_event.scroll_delta_y = scroll_delta_y;
1148 fl_event.device_kind = device_kind;
1149 fl_event.buttons = buttons;
1150 fl_event.device = kMousePointerDeviceId;
1151 fl_event.view_id = view_id;
1152 self->embedder_api.SendPointerEvent(self->engine, &fl_event, 1);
1153 }
1154
1155 void fl_engine_send_touch_up_event(FlEngine* self,
1156 FlutterViewId view_id,
1157 size_t timestamp,
1158 double x,
1159 double y,
1160 int32_t device) {
1161 g_return_if_fail(FL_IS_ENGINE(self));
1162
1163 if (self->engine == nullptr) {
1164 return;
1165 }
1166
1167 FlutterPointerEvent event;
1168 event.timestamp = timestamp;
1169 event.x = x;
1170 event.y = y;
1171 event.device_kind = kFlutterPointerDeviceKindTouch;
1172 event.device = device;
1173 event.buttons = 0;
1174 event.view_id = view_id;
1175 event.phase = FlutterPointerPhase::kUp;
1176 event.struct_size = sizeof(event);
1177
1178 self->embedder_api.SendPointerEvent(self->engine, &event, 1);
1179 }
1180
1181 void fl_engine_send_touch_down_event(FlEngine* self,
1182 FlutterViewId view_id,
1183 size_t timestamp,
1184 double x,
1185 double y,
1186 int32_t device) {
1187 g_return_if_fail(FL_IS_ENGINE(self));
1188
1189 if (self->engine == nullptr) {
1190 return;
1191 }
1192
1193 FlutterPointerEvent event;
1194 event.timestamp = timestamp;
1195 event.x = x;
1196 event.y = y;
1197 event.device_kind = kFlutterPointerDeviceKindTouch;
1198 event.device = device;
1199 event.buttons = FlutterPointerMouseButtons::kFlutterPointerButtonMousePrimary;
1200 event.view_id = view_id;
1201 event.phase = FlutterPointerPhase::kDown;
1202 event.struct_size = sizeof(event);
1203
1204 self->embedder_api.SendPointerEvent(self->engine, &event, 1);
1205 }
1206
1207 void fl_engine_send_touch_move_event(FlEngine* self,
1208 FlutterViewId view_id,
1209 size_t timestamp,
1210 double x,
1211 double y,
1212 int32_t device) {
1213 g_return_if_fail(FL_IS_ENGINE(self));
1214
1215 if (self->engine == nullptr) {
1216 return;
1217 }
1218
1219 FlutterPointerEvent event;
1220 event.timestamp = timestamp;
1221 event.x = x;
1222 event.y = y;
1223 event.device_kind = kFlutterPointerDeviceKindTouch;
1224 event.device = device;
1225 event.buttons = FlutterPointerMouseButtons::kFlutterPointerButtonMousePrimary;
1226 event.view_id = view_id;
1227 event.phase = FlutterPointerPhase::kMove;
1228 event.struct_size = sizeof(event);
1229
1230 self->embedder_api.SendPointerEvent(self->engine, &event, 1);
1231 }
1232
1233 void fl_engine_send_touch_add_event(FlEngine* self,
1234 FlutterViewId view_id,
1235 size_t timestamp,
1236 double x,
1237 double y,
1238 int32_t device) {
1239 g_return_if_fail(FL_IS_ENGINE(self));
1240
1241 if (self->engine == nullptr) {
1242 return;
1243 }
1244
1245 FlutterPointerEvent event;
1246 event.timestamp = timestamp;
1247 event.x = x;
1248 event.y = y;
1249 event.device_kind = kFlutterPointerDeviceKindTouch;
1250 event.device = device;
1251 event.buttons = 0;
1252 event.view_id = view_id;
1253 event.phase = FlutterPointerPhase::kAdd;
1254 event.struct_size = sizeof(event);
1255
1256 self->embedder_api.SendPointerEvent(self->engine, &event, 1);
1257 }
1258
1259 void fl_engine_send_touch_remove_event(FlEngine* self,
1260 FlutterViewId view_id,
1261 size_t timestamp,
1262 double x,
1263 double y,
1264 int32_t device) {
1265 g_return_if_fail(FL_IS_ENGINE(self));
1266
1267 if (self->engine == nullptr) {
1268 return;
1269 }
1270
1271 FlutterPointerEvent event;
1272 event.timestamp = timestamp;
1273 event.x = x;
1274 event.y = y;
1275 event.device_kind = kFlutterPointerDeviceKindTouch;
1276 event.device = device;
1277 event.buttons = 0;
1278 event.view_id = view_id;
1279 event.phase = FlutterPointerPhase::kRemove;
1280 event.struct_size = sizeof(event);
1281
1282 self->embedder_api.SendPointerEvent(self->engine, &event, 1);
1283 }
1284
1285 void fl_engine_send_pointer_pan_zoom_event(FlEngine* self,
1286 FlutterViewId view_id,
1287 size_t timestamp,
1288 double x,
1289 double y,
1290 FlutterPointerPhase phase,
1291 double pan_x,
1292 double pan_y,
1293 double scale,
1294 double rotation) {
1295 g_return_if_fail(FL_IS_ENGINE(self));
1296
1297 if (self->engine == nullptr) {
1298 return;
1299 }
1300
1301 FlutterPointerEvent fl_event = {};
1302 fl_event.struct_size = sizeof(fl_event);
1303 fl_event.timestamp = timestamp;
1304 fl_event.x = x;
1305 fl_event.y = y;
1306 fl_event.phase = phase;
1307 fl_event.pan_x = pan_x;
1308 fl_event.pan_y = pan_y;
1309 fl_event.scale = scale;
1310 fl_event.rotation = rotation;
1311 fl_event.device = kPointerPanZoomDeviceId;
1312 fl_event.device_kind = kFlutterPointerDeviceKindTrackpad;
1313 fl_event.view_id = view_id;
1314 self->embedder_api.SendPointerEvent(self->engine, &fl_event, 1);
1315 }
1316
1317 static void send_key_event_cb(bool handled, void* user_data) {
1318 g_autoptr(GTask) task = G_TASK(user_data);
1319 gboolean* return_value = g_new0(gboolean, 1);
1320 *return_value = handled;
1321 g_task_return_pointer(task, return_value, g_free);
1322 }
1323
1324 void fl_engine_send_key_event(FlEngine* self,
1325 const FlutterKeyEvent* event,
1326 GCancellable* cancellable,
1327 GAsyncReadyCallback callback,
1328 gpointer user_data) {
1329 g_return_if_fail(FL_IS_ENGINE(self));
1330
1331 g_autoptr(GTask) task = g_task_new(self, cancellable, callback, user_data);
1332
1333 if (self->engine == nullptr) {
1334 g_task_return_new_error(task, fl_engine_error_quark(),
1335 FL_ENGINE_ERROR_FAILED, "No engine");
1336 return;
1337 }
1338
1339 if (self->embedder_api.SendKeyEvent(self->engine, event, send_key_event_cb,
1340 g_object_ref(task)) != kSuccess) {
1341 g_task_return_new_error(task, fl_engine_error_quark(),
1342 FL_ENGINE_ERROR_FAILED, "Failed to send key event");
1343 g_object_unref(task);
1344 }
1345 }
1346
1347 gboolean fl_engine_send_key_event_finish(FlEngine* self,
1348 GAsyncResult* result,
1349 gboolean* handled,
1350 GError** error) {
1351 g_return_val_if_fail(FL_IS_ENGINE(self), FALSE);
1352 g_return_val_if_fail(g_task_is_valid(result, self), FALSE);
1353
1354 g_autofree gboolean* return_value =
1355 static_cast<gboolean*>(g_task_propagate_pointer(G_TASK(result), error));
1356 if (return_value == nullptr) {
1357 return FALSE;
1358 }
1359
1360 *handled = *return_value;
1361 return TRUE;
1362 }
1363
1364 void fl_engine_dispatch_semantics_action(FlEngine* self,
1365 FlutterViewId view_id,
1366 uint64_t node_id,
1367 FlutterSemanticsAction action,
1368 GBytes* data) {
1369 g_return_if_fail(FL_IS_ENGINE(self));
1370
1371 if (self->engine == nullptr) {
1372 return;
1373 }
1374
1375 const uint8_t* action_data = nullptr;
1376 size_t action_data_length = 0;
1377 if (data != nullptr) {
1378 action_data = static_cast<const uint8_t*>(
1379 g_bytes_get_data(data, &action_data_length));
1380 }
1381
1382 FlutterSendSemanticsActionInfo info;
1383 info.struct_size = sizeof(FlutterSendSemanticsActionInfo);
1384 info.view_id = view_id;
1385 info.node_id = node_id;
1386 info.action = action;
1387 info.data = action_data;
1388 info.data_length = action_data_length;
1389 self->embedder_api.SendSemanticsAction(self->engine, &info);
1390 }
1391
1392 gboolean fl_engine_mark_texture_frame_available(FlEngine* self,
1393 int64_t texture_id) {
1394 g_return_val_if_fail(FL_IS_ENGINE(self), FALSE);
1395 return self->embedder_api.MarkExternalTextureFrameAvailable(
1396 self->engine, texture_id) == kSuccess;
1397 }
1398
1399 gboolean fl_engine_register_external_texture(FlEngine* self,
1400 int64_t texture_id) {
1401 g_return_val_if_fail(FL_IS_ENGINE(self), FALSE);
1402 return self->embedder_api.RegisterExternalTexture(self->engine, texture_id) ==
1403 kSuccess;
1404 }
1405
1406 gboolean fl_engine_unregister_external_texture(FlEngine* self,
1407 int64_t texture_id) {
1408 g_return_val_if_fail(FL_IS_ENGINE(self), FALSE);
1409 return self->embedder_api.UnregisterExternalTexture(self->engine,
1410 texture_id) == kSuccess;
1411 }
1412
1413 G_MODULE_EXPORT FlBinaryMessenger* fl_engine_get_binary_messenger(
1414 FlEngine* self) {
1415 g_return_val_if_fail(FL_IS_ENGINE(self), nullptr);
1416 return self->binary_messenger;
1417 }
1418
1419 FlTaskRunner* fl_engine_get_task_runner(FlEngine* self) {
1420 g_return_val_if_fail(FL_IS_ENGINE(self), nullptr);
1421 return self->task_runner;
1422 }
1423
1424 void fl_engine_execute_task(FlEngine* self, FlutterTask* task) {
1425 g_return_if_fail(FL_IS_ENGINE(self));
1426 self->embedder_api.RunTask(self->engine, task);
1427 }
1428
1429 G_MODULE_EXPORT FlTextureRegistrar* fl_engine_get_texture_registrar(
1430 FlEngine* self) {
1431 g_return_val_if_fail(FL_IS_ENGINE(self), nullptr);
1432 return self->texture_registrar;
1433 }
1434
1435 void fl_engine_update_accessibility_features(FlEngine* self, int32_t flags) {
1436 g_return_if_fail(FL_IS_ENGINE(self));
1437
1438 if (self->engine == nullptr) {
1439 return;
1440 }
1441
1442 self->embedder_api.UpdateAccessibilityFeatures(
1443 self->engine, static_cast<FlutterAccessibilityFeature>(flags));
1444 }
1445
1446 void fl_engine_request_app_exit(FlEngine* self) {
1447 g_return_if_fail(FL_IS_ENGINE(self));
1448 fl_platform_handler_request_app_exit(self->platform_handler);
1449 }
1450
1451 FlWindowingHandler* fl_engine_get_windowing_handler(FlEngine* self) {
1452 g_return_val_if_fail(FL_IS_ENGINE(self), nullptr);
1453 return self->windowing_handler;
1454 }
1455
1456 FlKeyboardManager* fl_engine_get_keyboard_manager(FlEngine* self) {
1457 g_return_val_if_fail(FL_IS_ENGINE(self), nullptr);
1458 return self->keyboard_manager;
1459 }
1460
1461 FlTextInputHandler* fl_engine_get_text_input_handler(FlEngine* self) {
1462 g_return_val_if_fail(FL_IS_ENGINE(self), nullptr);
1463 return self->text_input_handler;
1464 }
1465
1466 FlMouseCursorHandler* fl_engine_get_mouse_cursor_handler(FlEngine* self) {
1467 g_return_val_if_fail(FL_IS_ENGINE(self), nullptr);
1468 return self->mouse_cursor_handler;
1469 }
engine_switches.h
PROP_LAST
@ PROP_LAST
Definition: fl_accessible_node.cc:64
PROP_0
@ PROP_0
Definition: fl_accessible_node.cc:64
action
FlutterSemanticsAction action
Definition: fl_accessible_node.cc:86
g_signal_emit
g_signal_emit(self, fl_application_signals[SIGNAL_CREATE_WINDOW], 0, view, &window)
G_DEFINE_QUARK
G_DEFINE_QUARK(fl_binary_messenger_codec_error_quark, fl_binary_messenger_codec_error) G_DECLARE_FINAL_TYPE(FlBinaryMessengerImpl
fl_binary_messenger_new
FlBinaryMessenger * fl_binary_messenger_new(FlEngine *engine)
Definition: fl_binary_messenger.cc:391
fl_binary_messenger_shutdown
void fl_binary_messenger_shutdown(FlBinaryMessenger *self)
Definition: fl_binary_messenger.cc:500
fl_binary_messenger_private.h
fl_dart_project_new
G_MODULE_EXPORT FlDartProject * fl_dart_project_new()
Definition: fl_dart_project.cc:52
fl_dart_project_get_aot_library_path
G_MODULE_EXPORT const gchar * fl_dart_project_get_aot_library_path(FlDartProject *self)
Definition: fl_dart_project.cc:74
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:106
fl_dart_project_get_icu_data_path
G_MODULE_EXPORT const gchar * fl_dart_project_get_icu_data_path(FlDartProject *self)
Definition: fl_dart_project.cc:100
fl_dart_project_get_assets_path
G_MODULE_EXPORT const gchar * fl_dart_project_get_assets_path(FlDartProject *self)
Definition: fl_dart_project.cc:87
fl_dart_project_get_ui_thread_policy
G_MODULE_EXPORT FlUIThreadPolicy fl_dart_project_get_ui_thread_policy(FlDartProject *project)
Definition: fl_dart_project.cc:128
FL_UI_THREAD_POLICY_RUN_ON_PLATFORM_THREAD
@ FL_UI_THREAD_POLICY_RUN_ON_PLATFORM_THREAD
Definition: fl_dart_project.h:143
fl_dart_project_private.h
fl_display_monitor_start
void fl_display_monitor_start(FlDisplayMonitor *self)
Definition: fl_display_monitor.cc:103
fl_display_monitor_new
FlDisplayMonitor * fl_display_monitor_new(FlEngine *engine, GdkDisplay *display)
Definition: fl_display_monitor.cc:94
fl_display_monitor.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:406
fl_engine_get_texture_registrar
G_MODULE_EXPORT FlTextureRegistrar * fl_engine_get_texture_registrar(FlEngine *self)
Definition: fl_engine.cc:1429
fl_engine_get_mouse_cursor_handler
FlMouseCursorHandler * fl_engine_get_mouse_cursor_handler(FlEngine *self)
Definition: fl_engine.cc:1466
fl_engine_runs_task_on_current_thread
static bool fl_engine_runs_task_on_current_thread(void *user_data)
Definition: fl_engine.cc:447
fl_engine_on_pre_engine_restart_cb
static void fl_engine_on_pre_engine_restart_cb(void *user_data)
Definition: fl_engine.cc:513
fl_engine_send_mouse_pointer_event
void fl_engine_send_mouse_pointer_event(FlEngine *self, FlutterViewId view_id, FlutterPointerPhase phase, size_t timestamp, double x, double y, FlutterPointerDeviceKind device_kind, double scroll_delta_x, double scroll_delta_y, int64_t buttons)
Definition: fl_engine.cc:1121
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:980
fl_engine_get_registrar_for_plugin
static FlPluginRegistrar * fl_engine_get_registrar_for_plugin(FlPluginRegistry *registry, const gchar *name)
Definition: fl_engine.cc:532
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:118
view_added_cb
static void view_added_cb(const FlutterAddViewResult *result)
Definition: fl_engine.cc:171
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:327
fl_engine_gl_make_current
static bool fl_engine_gl_make_current(void *user_data)
Definition: fl_engine.cc:382
fl_engine_send_key_event_finish
gboolean fl_engine_send_key_event_finish(FlEngine *self, GAsyncResult *result, gboolean *handled, GError **error)
Definition: fl_engine.cc:1347
fl_engine_get_embedder_api
FlutterEngineProcTable * fl_engine_get_embedder_api(FlEngine *self)
Definition: fl_engine.cc:858
fl_engine_dispatch_semantics_action
void fl_engine_dispatch_semantics_action(FlEngine *self, FlutterViewId view_id, uint64_t node_id, FlutterSemanticsAction action, GBytes *data)
Definition: fl_engine.cc:1364
fl_engine_new_full
static FlEngine * fl_engine_new_full(FlDartProject *project, FlBinaryMessenger *binary_messenger)
Definition: fl_engine.cc:649
parse_locale
static void parse_locale(const gchar *locale, gchar **language, gchar **territory, gchar **codeset, gchar **modifier)
Definition: fl_engine.cc:128
fl_engine_send_touch_up_event
void fl_engine_send_touch_up_event(FlEngine *self, FlutterViewId view_id, size_t timestamp, double x, double y, int32_t device)
Definition: fl_engine.cc:1155
fl_engine_notify_display_update
void fl_engine_notify_display_update(FlEngine *self, const FlutterEngineDisplay *displays, size_t displays_length)
Definition: fl_engine.cc:862
collect_opengl_backing_store
static bool collect_opengl_backing_store(FlEngine *self, const FlutterBackingStore *backing_store)
Definition: fl_engine.cc:285
compositor_present_view_callback
static bool compositor_present_view_callback(const FlutterPresentViewInfo *info)
Definition: fl_engine.cc:358
fl_engine_get_opengl_manager
FlOpenGLManager * fl_engine_get_opengl_manager(FlEngine *self)
Definition: fl_engine.cc:710
fl_engine_send_window_metrics_event
void fl_engine_send_window_metrics_event(FlEngine *self, FlutterEngineDisplayId display_id, FlutterViewId view_id, size_t width, size_t height, double pixel_ratio)
Definition: fl_engine.cc:1099
compositor_collect_backing_store_callback
static bool compositor_collect_backing_store_callback(const FlutterBackingStore *backing_store, void *user_data)
Definition: fl_engine.cc:343
fl_engine_get_renderer_type
FlutterRendererType fl_engine_get_renderer_type(FlEngine *self)
Definition: fl_engine.cc:705
fl_engine_dispose
static void fl_engine_dispose(GObject *object)
Definition: fl_engine.cc:562
fl_engine_mark_texture_frame_available
gboolean fl_engine_mark_texture_frame_available(FlEngine *self, int64_t texture_id)
Definition: fl_engine.cc:1392
fl_engine_get_windowing_handler
FlWindowingHandler * fl_engine_get_windowing_handler(FlEngine *self)
Definition: fl_engine.cc:1451
create_opengl_backing_store
static bool create_opengl_backing_store(FlEngine *self, const FlutterBackingStoreConfig *config, FlutterBackingStore *backing_store_out)
Definition: fl_engine.cc:250
fl_engine_remove_view_finish
gboolean fl_engine_remove_view_finish(FlEngine *self, GAsyncResult *result, GError **error)
Definition: fl_engine.cc:973
fl_engine_get_task_runner
FlTaskRunner * fl_engine_get_task_runner(FlEngine *self)
Definition: fl_engine.cc:1419
fl_engine_get_keyboard_manager
FlKeyboardManager * fl_engine_get_keyboard_manager(FlEngine *self)
Definition: fl_engine.cc:1456
fl_engine_get_display_monitor
FlDisplayMonitor * fl_engine_get_display_monitor(FlEngine *self)
Definition: fl_engine.cc:715
fl_engine_get_renderable
FlRenderable * fl_engine_get_renderable(FlEngine *self, FlutterViewId view_id)
Definition: fl_engine.cc:938
fl_engine_signals
static guint fl_engine_signals[LAST_SIGNAL]
Definition: fl_engine.cc:116
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:523
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:999
fl_engine_init
static void fl_engine_init(FlEngine *self)
Definition: fl_engine.cc:623
fl_engine_post_task
static void fl_engine_post_task(FlutterTask task, uint64_t target_time_nanos, void *user_data)
Definition: fl_engine.cc:453
fl_engine_get_text_input_handler
FlTextInputHandler * fl_engine_get_text_input_handler(FlEngine *self)
Definition: fl_engine.cc:1461
fl_engine_set_implicit_view
void fl_engine_set_implicit_view(FlEngine *self, FlRenderable *renderable)
Definition: fl_engine.cc:875
fl_engine_gl_get_fbo
static uint32_t fl_engine_gl_get_fbo(void *user_data)
Definition: fl_engine.cc:394
view_removed_cb
static void view_removed_cb(const FlutterRemoveViewResult *result)
Definition: fl_engine.cc:182
fl_engine_unregister_external_texture
gboolean fl_engine_unregister_external_texture(FlEngine *self, int64_t texture_id)
Definition: fl_engine.cc:1406
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:1031
fl_engine_register_external_texture
gboolean fl_engine_register_external_texture(FlEngine *self, int64_t texture_id)
Definition: fl_engine.cc:1399
fl_engine_for_id
FlEngine * fl_engine_for_id(int64_t id)
Definition: fl_engine.cc:685
fl_engine_gl_proc_resolver
static void * fl_engine_gl_proc_resolver(void *user_data, const char *name)
Definition: fl_engine.cc:378
fl_engine_send_touch_move_event
void fl_engine_send_touch_move_event(FlEngine *self, FlutterViewId view_id, size_t timestamp, double x, double y, int32_t device)
Definition: fl_engine.cc:1207
fl_engine_set_property
static void fl_engine_set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
Definition: fl_engine.cc:546
fl_engine_send_touch_add_event
void fl_engine_send_touch_add_event(FlEngine *self, FlutterViewId view_id, size_t timestamp, double x, double y, int32_t device)
Definition: fl_engine.cc:1233
LAST_SIGNAL
@ LAST_SIGNAL
Definition: fl_engine.cc:114
SIGNAL_UPDATE_SEMANTICS
@ SIGNAL_UPDATE_SEMANTICS
Definition: fl_engine.cc:114
SIGNAL_ON_PRE_ENGINE_RESTART
@ SIGNAL_ON_PRE_ENGINE_RESTART
Definition: fl_engine.cc:114
fl_engine_remove_view
void fl_engine_remove_view(FlEngine *self, FlutterViewId view_id, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data)
Definition: fl_engine.cc:946
fl_engine_get_binary_messenger
G_MODULE_EXPORT FlBinaryMessenger * fl_engine_get_binary_messenger(FlEngine *self)
Definition: fl_engine.cc:1413
fl_engine_add_view_finish
gboolean fl_engine_add_view_finish(FlEngine *self, GAsyncResult *result, GError **error)
Definition: fl_engine.cc:931
fl_engine_send_key_event
void fl_engine_send_key_event(FlEngine *self, const FlutterKeyEvent *event, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data)
Definition: fl_engine.cc:1324
setup_keyboard
static void setup_keyboard(FlEngine *self)
Definition: fl_engine.cc:489
free_locale
static void free_locale(FlutterLocale *locale)
Definition: fl_engine.cc:193
fl_engine_request_app_exit
void fl_engine_request_app_exit(FlEngine *self)
Definition: fl_engine.cc:1446
setup_locales
static void setup_locales(FlEngine *self)
Definition: fl_engine.cc:200
fl_engine_send_pointer_pan_zoom_event
void fl_engine_send_pointer_pan_zoom_event(FlEngine *self, FlutterViewId view_id, size_t timestamp, double x, double y, FlutterPointerPhase phase, double pan_x, double pan_y, double scale, double rotation)
Definition: fl_engine.cc:1285
fl_engine_add_view
FlutterViewId fl_engine_add_view(FlEngine *self, FlRenderable *renderable, size_t width, size_t height, double pixel_ratio, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data)
Definition: fl_engine.cc:882
fl_engine_update_semantics_cb
static void fl_engine_update_semantics_cb(const FlutterSemanticsUpdate2 *update, void *user_data)
Definition: fl_engine.cc:482
fl_engine_gl_make_resource_current
static bool fl_engine_gl_make_resource_current(void *user_data)
Definition: fl_engine.cc:399
fl_engine_new_headless
G_MODULE_EXPORT FlEngine * fl_engine_new_headless(FlDartProject *project)
Definition: fl_engine.cc:701
fl_engine_update_accessibility_features
void fl_engine_update_accessibility_features(FlEngine *self, int32_t flags)
Definition: fl_engine.cc:1435
fl_engine_platform_message_cb
static void fl_engine_platform_message_cb(const FlutterPlatformMessage *message, void *user_data)
Definition: fl_engine.cc:462
fl_engine_send_touch_remove_event
void fl_engine_send_touch_remove_event(FlEngine *self, FlutterViewId view_id, size_t timestamp, double x, double y, int32_t device)
Definition: fl_engine.cc:1259
fl_engine_execute_task
void fl_engine_execute_task(FlEngine *self, FlutterTask *task)
Definition: fl_engine.cc:1424
fl_engine_send_touch_down_event
void fl_engine_send_touch_down_event(FlEngine *self, FlutterViewId view_id, size_t timestamp, double x, double y, int32_t device)
Definition: fl_engine.cc:1181
fl_engine_start
gboolean fl_engine_start(FlEngine *self, GError **error)
Definition: fl_engine.cc:720
send_key_event_cb
static void send_key_event_cb(bool handled, void *user_data)
Definition: fl_engine.cc:1317
collect_software_backing_store
static bool collect_software_backing_store(FlEngine *self, const FlutterBackingStore *backing_store)
Definition: fl_engine.cc:319
kPlatformTaskRunnerIdentifier
static constexpr size_t kPlatformTaskRunnerIdentifier
Definition: fl_engine.cc:32
fl_engine_new_with_binary_messenger
FlEngine * fl_engine_new_with_binary_messenger(FlBinaryMessenger *binary_messenger)
Definition: fl_engine.cc:695
kPointerPanZoomDeviceId
static constexpr int32_t kPointerPanZoomDeviceId
Definition: fl_engine.cc:37
fl_engine_new
G_MODULE_EXPORT FlEngine * fl_engine_new(FlDartProject *project)
Definition: fl_engine.cc:691
kMousePointerDeviceId
static constexpr int32_t kMousePointerDeviceId
Definition: fl_engine.cc:36
fl_engine_class_init
static void fl_engine_class_init(FlEngineClass *klass)
Definition: fl_engine.cc:603
fl_engine_gl_clear_current
static bool fl_engine_gl_clear_current(void *user_data)
Definition: fl_engine.cc:388
fl_engine_send_platform_message_finish
GBytes * fl_engine_send_platform_message_finish(FlEngine *self, GAsyncResult *result, GError **error)
Definition: fl_engine.cc:1090
fl_engine_plugin_registry_iface_init
static void fl_engine_plugin_registry_iface_init(FlPluginRegistryInterface *iface)
Definition: fl_engine.cc:541
create_software_backing_store
static bool create_software_backing_store(FlEngine *self, const FlutterBackingStoreConfig *config, FlutterBackingStore *backing_store_out)
Definition: fl_engine.cc:295
fl_engine.h
fl_engine_private.h
fl_engine_error_quark
GQuark fl_engine_error_quark(void) G_GNUC_CONST
FL_ENGINE_ERROR_FAILED
@ FL_ENGINE_ERROR_FAILED
Definition: fl_engine_private.h:30
FlEnginePlatformMessageHandler
gboolean(* FlEnginePlatformMessageHandler)(FlEngine *engine, const gchar *channel, GBytes *message, const FlutterPlatformMessageResponseHandle *response_handle, gpointer user_data)
Definition: fl_engine_private.h:47
args
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
Definition: fl_event_channel.h:89
user_data
G_BEGIN_DECLS G_MODULE_EXPORT FlValue gpointer user_data
Definition: fl_event_channel.h:90
fl_framebuffer_get_id
GLuint fl_framebuffer_get_id(FlFramebuffer *self)
Definition: fl_framebuffer.cc:85
fl_framebuffer_new
FlFramebuffer * fl_framebuffer_new(GLint format, size_t width, size_t height)
Definition: fl_framebuffer.cc:46
fl_framebuffer.h
fl_keyboard_handler_new
FlKeyboardHandler * fl_keyboard_handler_new(FlBinaryMessenger *messenger, FlKeyboardManager *keyboard_manager)
Definition: fl_keyboard_handler.cc:63
fl_keyboard_handler.h
fl_keyboard_manager_new
FlKeyboardManager * fl_keyboard_manager_new(FlEngine *engine)
Definition: fl_keyboard_manager.cc:356
fl_mouse_cursor_handler_new
FlMouseCursorHandler * fl_mouse_cursor_handler_new(FlBinaryMessenger *messenger)
Definition: fl_mouse_cursor_handler.cc:134
fl_opengl_manager_clear_current
void fl_opengl_manager_clear_current(FlOpenGLManager *self)
Definition: fl_opengl_manager.cc:90
fl_opengl_manager_new
FlOpenGLManager * fl_opengl_manager_new()
Definition: fl_opengl_manager.cc:39
fl_opengl_manager_make_current
void fl_opengl_manager_make_current(FlOpenGLManager *self)
Definition: fl_opengl_manager.cc:82
fl_opengl_manager_make_resource_current
void fl_opengl_manager_make_resource_current(FlOpenGLManager *self)
Definition: fl_opengl_manager.cc:86
fl_opengl_manager.h
id
int64_t id
Definition: fl_pixel_buffer_texture.cc:28
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_pixel_buffer_texture_private.h
height
const uint8_t uint32_t uint32_t * height
Definition: fl_pixel_buffer_texture_test.cc:39
width
const uint8_t uint32_t * width
Definition: fl_pixel_buffer_texture_test.cc:38
TRUE
return TRUE
Definition: fl_pixel_buffer_texture_test.cc:53
error
const uint8_t uint32_t uint32_t GError ** error
Definition: fl_pixel_buffer_texture_test.cc:40
fl_platform_handler_new
FlPlatformHandler * fl_platform_handler_new(FlBinaryMessenger *messenger)
Definition: fl_platform_handler.cc:254
fl_platform_handler_request_app_exit
void fl_platform_handler_request_app_exit(FlPlatformHandler *self)
Definition: fl_platform_handler.cc:267
fl_platform_handler.h
fl_plugin_registrar_new
FlPluginRegistrar * fl_plugin_registrar_new(FlView *view, FlBinaryMessenger *messenger, FlTextureRegistrar *texture_registrar)
Definition: fl_plugin_registrar.cc:84
fl_plugin_registrar_private.h
fl_plugin_registry.h
fl_renderable_present_layers
void fl_renderable_present_layers(FlRenderable *self, const FlutterLayer **layers, size_t layers_count)
Definition: fl_renderable.cc:11
fl_settings_new
FlSettings * fl_settings_new()
Definition: fl_settings.cc:55
fl_settings_handler_start
void fl_settings_handler_start(FlSettingsHandler *self, FlSettings *settings)
Definition: fl_settings_handler.cc:88
fl_settings_handler_new
FlSettingsHandler * fl_settings_handler_new(FlEngine *engine)
Definition: fl_settings_handler.cc:74
fl_settings_handler.h
i
int i
Definition: fl_socket_accessible.cc:18
value
uint8_t value
Definition: fl_standard_message_codec.cc:36
prop_id
guint prop_id
Definition: fl_standard_method_codec.cc:31
pspec
guint const GValue GParamSpec * pspec
Definition: fl_standard_method_codec.cc:33
fl_task_runner_post_flutter_task
void fl_task_runner_post_flutter_task(FlTaskRunner *self, FlutterTask task, uint64_t target_time_nanos)
Definition: fl_task_runner.cc:174
fl_task_runner_new
FlTaskRunner * fl_task_runner_new(FlEngine *engine)
Definition: fl_task_runner.cc:167
fl_text_input_handler_new
FlTextInputHandler * fl_text_input_handler_new(FlBinaryMessenger *messenger)
Definition: fl_text_input_handler.cc:422
fl_text_input_handler_set_widget
void fl_text_input_handler_set_widget(FlTextInputHandler *self, GtkWidget *widget)
Definition: fl_text_input_handler.cc:464
fl_text_input_handler_get_widget
GtkWidget * fl_text_input_handler_get_widget(FlTextInputHandler *self)
Definition: fl_text_input_handler.cc:472
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_texture_gl_private.h
fl_texture_registrar_shutdown
void fl_texture_registrar_shutdown(FlTextureRegistrar *self)
Definition: fl_texture_registrar.cc:215
fl_texture_registrar_new
FlTextureRegistrar * fl_texture_registrar_new(FlEngine *engine)
Definition: fl_texture_registrar.cc:221
fl_texture_registrar_lookup_texture
FlTexture * fl_texture_registrar_lookup_texture(FlTextureRegistrar *self, int64_t texture_id)
Definition: fl_texture_registrar.cc:190
fl_texture_registrar_private.h
view_id
G_BEGIN_DECLS FlutterViewId view_id
Definition: fl_view_accessible.h:49
fl_windowing_handler_new
FlWindowingHandler * fl_windowing_handler_new(FlEngine *engine)
Definition: fl_windowing_handler.cc:260
fl_windowing_handler.h
flutter::GetSwitchesFromEnvironment
std::vector< std::string > GetSwitchesFromEnvironment()
Definition: engine_switches.cc:14
_FlEngine
Definition: fl_engine.cc:39
_FlEngine::task_runner
FlTaskRunner * task_runner
Definition: fl_engine.cc:85
_FlEngine::platform_message_handler
FlEnginePlatformMessageHandler platform_message_handler
Definition: fl_engine.cc:104
_FlEngine::mouse_cursor_handler
FlMouseCursorHandler * mouse_cursor_handler
Definition: fl_engine.cc:79
_FlEngine::platform_message_handler_destroy_notify
GDestroyNotify platform_message_handler_destroy_notify
Definition: fl_engine.cc:106
_FlEngine::next_view_id
FlutterViewId next_view_id
Definition: fl_engine.cc:98
_FlEngine::settings_handler
FlSettingsHandler * settings_handler
Definition: fl_engine.cc:61
_FlEngine::platform_message_handler_data
gpointer platform_message_handler_data
Definition: fl_engine.cc:105
_FlEngine::opengl_manager
FlOpenGLManager * opengl_manager
Definition: fl_engine.cc:55
_FlEngine::thread
GThread * thread
Definition: fl_engine.cc:43
_FlEngine::platform_handler
FlPlatformHandler * platform_handler
Definition: fl_engine.cc:64
_FlEngine::FLUTTER_API_SYMBOL
FLUTTER_API_SYMBOL(FlutterEngine) engine
_FlEngine::renderer_type
FlutterRendererType renderer_type
Definition: fl_engine.cc:52
_FlEngine::binary_messenger
FlBinaryMessenger * binary_messenger
Definition: fl_engine.cc:58
_FlEngine::display_monitor
FlDisplayMonitor * display_monitor
Definition: fl_engine.cc:49
_FlEngine::renderables_by_view_id
GHashTable * renderables_by_view_id
Definition: fl_engine.cc:101
_FlEngine::project
FlDartProject * project
Definition: fl_engine.cc:46
_FlEngine::keyboard_manager
FlKeyboardManager * keyboard_manager
Definition: fl_engine.cc:70
_FlEngine::windowing_handler
FlWindowingHandler * windowing_handler
Definition: fl_engine.cc:67
_FlEngine::parent_instance
GObject parent_instance
Definition: fl_engine.cc:40
_FlEngine::texture_registrar
FlTextureRegistrar * texture_registrar
Definition: fl_engine.cc:82
_FlEngine::aot_data
FlutterEngineAOTData aot_data
Definition: fl_engine.cc:88
_FlEngine::embedder_api
FlutterEngineProcTable embedder_api
Definition: fl_engine.cc:95
_FlEngine::text_input_handler
FlTextInputHandler * text_input_handler
Definition: fl_engine.cc:73
_FlEngine::keyboard_handler
FlKeyboardHandler * keyboard_handler
Definition: fl_engine.cc:76
texture_id
int64_t texture_id
Definition: texture_registrar_unittests.cc:24