Flutter Engine
 
Loading...
Searching...
No Matches
fl_engine.cc File Reference

Go to the source code of this file.

Classes

struct  _FlEngine
 

Enumerations

enum  {
  SIGNAL_ON_PRE_ENGINE_RESTART ,
  SIGNAL_UPDATE_SEMANTICS ,
  LAST_SIGNAL
}
 

Functions

static void fl_engine_plugin_registry_iface_init (FlPluginRegistryInterface *iface)
 
 G_DEFINE_TYPE_WITH_CODE (FlEngine, fl_engine, G_TYPE_OBJECT, G_IMPLEMENT_INTERFACE(fl_plugin_registry_get_type(), fl_engine_plugin_registry_iface_init)) enum
 
static void parse_locale (const gchar *locale, gchar **language, gchar **territory, gchar **codeset, gchar **modifier)
 
static void view_added_cb (const FlutterAddViewResult *result)
 
static void view_removed_cb (const FlutterRemoveViewResult *result)
 
static void free_locale (FlutterLocale *locale)
 
static void setup_locales (FlEngine *self)
 
static bool create_opengl_backing_store (FlEngine *self, const FlutterBackingStoreConfig *config, FlutterBackingStore *backing_store_out)
 
static bool collect_opengl_backing_store (FlEngine *self, const FlutterBackingStore *backing_store)
 
static bool create_software_backing_store (FlEngine *self, const FlutterBackingStoreConfig *config, FlutterBackingStore *backing_store_out)
 
static bool collect_software_backing_store (FlEngine *self, const FlutterBackingStore *backing_store)
 
static bool compositor_create_backing_store_callback (const FlutterBackingStoreConfig *config, FlutterBackingStore *backing_store_out, void *user_data)
 
static bool compositor_collect_backing_store_callback (const FlutterBackingStore *backing_store, void *user_data)
 
static bool compositor_present_view_callback (const FlutterPresentViewInfo *info)
 
static void * fl_engine_gl_proc_resolver (void *user_data, const char *name)
 
static bool fl_engine_gl_make_current (void *user_data)
 
static bool fl_engine_gl_clear_current (void *user_data)
 
static uint32_t fl_engine_gl_get_fbo (void *user_data)
 
static bool fl_engine_gl_make_resource_current (void *user_data)
 
static bool fl_engine_gl_external_texture_frame_callback (void *user_data, int64_t texture_id, size_t width, size_t height, FlutterOpenGLTexture *opengl_texture)
 
static bool fl_engine_runs_task_on_current_thread (void *user_data)
 
static void fl_engine_post_task (FlutterTask task, uint64_t target_time_nanos, void *user_data)
 
static void fl_engine_platform_message_cb (const FlutterPlatformMessage *message, void *user_data)
 
static void fl_engine_update_semantics_cb (const FlutterSemanticsUpdate2 *update, void *user_data)
 
static void setup_keyboard (FlEngine *self)
 
static void fl_engine_on_pre_engine_restart_cb (void *user_data)
 
static void fl_engine_platform_message_response_cb (const uint8_t *data, size_t data_length, void *user_data)
 
static FlPluginRegistrar * fl_engine_get_registrar_for_plugin (FlPluginRegistry *registry, const gchar *name)
 
static void fl_engine_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
 
static void fl_engine_dispose (GObject *object)
 
static void fl_engine_class_init (FlEngineClass *klass)
 
static void fl_engine_init (FlEngine *self)
 
static FlEngine * fl_engine_new_full (FlDartProject *project, FlBinaryMessenger *binary_messenger)
 
FlEngine * fl_engine_for_id (int64_t id)
 
G_MODULE_EXPORT FlEngine * fl_engine_new (FlDartProject *project)
 
FlEngine * fl_engine_new_with_binary_messenger (FlBinaryMessenger *binary_messenger)
 
G_MODULE_EXPORT FlEngine * fl_engine_new_headless (FlDartProject *project)
 
FlutterRendererType fl_engine_get_renderer_type (FlEngine *self)
 
FlOpenGLManager * fl_engine_get_opengl_manager (FlEngine *self)
 
FlDisplayMonitor * fl_engine_get_display_monitor (FlEngine *self)
 
gboolean fl_engine_start (FlEngine *self, GError **error)
 
FlutterEngineProcTablefl_engine_get_embedder_api (FlEngine *self)
 
void fl_engine_notify_display_update (FlEngine *self, const FlutterEngineDisplay *displays, size_t displays_length)
 
void fl_engine_set_implicit_view (FlEngine *self, FlRenderable *renderable)
 
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)
 
gboolean fl_engine_add_view_finish (FlEngine *self, GAsyncResult *result, GError **error)
 
FlRenderable * fl_engine_get_renderable (FlEngine *self, FlutterViewId view_id)
 
void fl_engine_remove_view (FlEngine *self, FlutterViewId view_id, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data)
 
gboolean fl_engine_remove_view_finish (FlEngine *self, GAsyncResult *result, GError **error)
 
void fl_engine_set_platform_message_handler (FlEngine *self, FlEnginePlatformMessageHandler handler, gpointer user_data, GDestroyNotify destroy_notify)
 
gboolean fl_engine_send_platform_message_response (FlEngine *self, const FlutterPlatformMessageResponseHandle *handle, GBytes *response, GError **error)
 
void fl_engine_send_platform_message (FlEngine *self, const gchar *channel, GBytes *message, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data)
 
GBytes * fl_engine_send_platform_message_finish (FlEngine *self, GAsyncResult *result, GError **error)
 
void fl_engine_send_window_metrics_event (FlEngine *self, FlutterEngineDisplayId display_id, FlutterViewId view_id, size_t width, size_t height, double pixel_ratio)
 
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)
 
void fl_engine_send_touch_up_event (FlEngine *self, FlutterViewId view_id, size_t timestamp, double x, double y, int32_t device)
 
void fl_engine_send_touch_down_event (FlEngine *self, FlutterViewId view_id, size_t timestamp, double x, double y, int32_t device)
 
void fl_engine_send_touch_move_event (FlEngine *self, FlutterViewId view_id, size_t timestamp, double x, double y, int32_t device)
 
void fl_engine_send_touch_add_event (FlEngine *self, FlutterViewId view_id, size_t timestamp, double x, double y, int32_t device)
 
void fl_engine_send_touch_remove_event (FlEngine *self, FlutterViewId view_id, size_t timestamp, double x, double y, int32_t device)
 
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)
 
static void send_key_event_cb (bool handled, void *user_data)
 
void fl_engine_send_key_event (FlEngine *self, const FlutterKeyEvent *event, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data)
 
gboolean fl_engine_send_key_event_finish (FlEngine *self, GAsyncResult *result, gboolean *handled, GError **error)
 
void fl_engine_dispatch_semantics_action (FlEngine *self, FlutterViewId view_id, uint64_t node_id, FlutterSemanticsAction action, GBytes *data)
 
gboolean fl_engine_mark_texture_frame_available (FlEngine *self, int64_t texture_id)
 
gboolean fl_engine_register_external_texture (FlEngine *self, int64_t texture_id)
 
gboolean fl_engine_unregister_external_texture (FlEngine *self, int64_t texture_id)
 
G_MODULE_EXPORT FlBinaryMessenger * fl_engine_get_binary_messenger (FlEngine *self)
 
FlTaskRunner * fl_engine_get_task_runner (FlEngine *self)
 
void fl_engine_execute_task (FlEngine *self, FlutterTask *task)
 
G_MODULE_EXPORT FlTextureRegistrar * fl_engine_get_texture_registrar (FlEngine *self)
 
void fl_engine_update_accessibility_features (FlEngine *self, int32_t flags)
 
void fl_engine_request_app_exit (FlEngine *self)
 
FlWindowingHandler * fl_engine_get_windowing_handler (FlEngine *self)
 
FlKeyboardManager * fl_engine_get_keyboard_manager (FlEngine *self)
 
FlTextInputHandler * fl_engine_get_text_input_handler (FlEngine *self)
 
FlMouseCursorHandler * fl_engine_get_mouse_cursor_handler (FlEngine *self)
 

Variables

static constexpr size_t kPlatformTaskRunnerIdentifier = 1
 
static constexpr int32_t kMousePointerDeviceId = 0
 
static constexpr int32_t kPointerPanZoomDeviceId = 1
 
static guint fl_engine_signals [LAST_SIGNAL]
 

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
SIGNAL_ON_PRE_ENGINE_RESTART 
SIGNAL_UPDATE_SEMANTICS 
LAST_SIGNAL 

Definition at line 114 of file fl_engine.cc.

@ LAST_SIGNAL
Definition fl_engine.cc:114
@ SIGNAL_UPDATE_SEMANTICS
Definition fl_engine.cc:114
@ SIGNAL_ON_PRE_ENGINE_RESTART
Definition fl_engine.cc:114

Function Documentation

◆ collect_opengl_backing_store()

static bool collect_opengl_backing_store ( FlEngine *  self,
const FlutterBackingStore backing_store 
)
static

Definition at line 287 of file fl_engine.cc.

289 {
290 if (!fl_opengl_manager_make_current(self->opengl_manager)) {
291 return false;
292 }
293
294 // OpenGL context is required when destroying #FlFramebuffer.
295 g_object_unref(backing_store->open_gl.framebuffer.user_data);
296 return true;
297}
gboolean fl_opengl_manager_make_current(FlOpenGLManager *self)
FlutterOpenGLBackingStore open_gl
The description of the OpenGL backing store.
Definition embedder.h:2077
FlutterOpenGLFramebuffer framebuffer
Definition embedder.h:1920
void * user_data
User data to be returned on the invocation of the destruction callback.
Definition embedder.h:547

References fl_opengl_manager_make_current(), FlutterOpenGLBackingStore::framebuffer, FlutterBackingStore::open_gl, self, and FlutterOpenGLFramebuffer::user_data.

Referenced by compositor_collect_backing_store_callback().

◆ collect_software_backing_store()

static bool collect_software_backing_store ( FlEngine *  self,
const FlutterBackingStore backing_store 
)
static

Definition at line 323 of file fl_engine.cc.

325 {
326 free(const_cast<void*>(backing_store->software.allocation));
327 return true;
328}
FlutterSoftwareBackingStore software
The description of the software backing store.
Definition embedder.h:2079

References FlutterSoftwareBackingStore::allocation, and FlutterBackingStore::software.

Referenced by compositor_collect_backing_store_callback().

◆ compositor_collect_backing_store_callback()

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

Definition at line 347 of file fl_engine.cc.

349 {
350 FlEngine* self = static_cast<FlEngine*>(user_data);
351 switch (self->renderer_type) {
352 case kOpenGL:
353 return collect_opengl_backing_store(self, backing_store);
354 case kSoftware:
355 return collect_software_backing_store(self, backing_store);
356 default:
357 return false;
358 }
359}
@ kOpenGL
Definition embedder.h:80
@ kSoftware
Definition embedder.h:81
static bool collect_opengl_backing_store(FlEngine *self, const FlutterBackingStore *backing_store)
Definition fl_engine.cc:287
static bool collect_software_backing_store(FlEngine *self, const FlutterBackingStore *backing_store)
Definition fl_engine.cc:323

References collect_opengl_backing_store(), collect_software_backing_store(), kOpenGL, kSoftware, self, and user_data.

Referenced by fl_engine_start().

◆ compositor_create_backing_store_callback()

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

Definition at line 331 of file fl_engine.cc.

334 {
335 FlEngine* self = static_cast<FlEngine*>(user_data);
336 switch (self->renderer_type) {
337 case kOpenGL:
338 return create_opengl_backing_store(self, config, backing_store_out);
339 case kSoftware:
340 return create_software_backing_store(self, config, backing_store_out);
341 default:
342 return false;
343 }
344}
static bool create_opengl_backing_store(FlEngine *self, const FlutterBackingStoreConfig *config, FlutterBackingStore *backing_store_out)
Definition fl_engine.cc:250
static bool create_software_backing_store(FlEngine *self, const FlutterBackingStoreConfig *config, FlutterBackingStore *backing_store_out)
Definition fl_engine.cc:299

References create_opengl_backing_store(), create_software_backing_store(), kOpenGL, kSoftware, self, and user_data.

Referenced by fl_engine_start().

◆ compositor_present_view_callback()

static bool compositor_present_view_callback ( const FlutterPresentViewInfo info)
static

Definition at line 362 of file fl_engine.cc.

363 {
364 FlEngine* self = static_cast<FlEngine*>(info->user_data);
365
366 GWeakRef* ref = static_cast<GWeakRef*>(g_hash_table_lookup(
367 self->renderables_by_view_id, GINT_TO_POINTER(info->view_id)));
368 if (ref == nullptr) {
369 return true;
370 }
371 g_autoptr(FlRenderable) renderable = FL_RENDERABLE(g_weak_ref_get(ref));
372 if (renderable == nullptr) {
373 return true;
374 }
375
376 fl_renderable_present_layers(renderable, info->layers, info->layers_count);
377 return true;
378}
g_autoptr(GMutexLocker) locker
void fl_renderable_present_layers(FlRenderable *self, const FlutterLayer **layers, size_t layers_count)
size_t layers_count
The count of layers.
Definition embedder.h:2170
void * user_data
The |FlutterCompositor.user_data|.
Definition embedder.h:2173
FlutterViewId view_id
The identifier of the target view.
Definition embedder.h:2164
const FlutterLayer ** layers
The layers that should be composited onto the view.
Definition embedder.h:2167

References fl_renderable_present_layers(), g_autoptr(), FlutterPresentViewInfo::layers, FlutterPresentViewInfo::layers_count, self, FlutterPresentViewInfo::user_data, and FlutterPresentViewInfo::view_id.

Referenced by fl_engine_start().

◆ create_opengl_backing_store()

static bool create_opengl_backing_store ( FlEngine *  self,
const FlutterBackingStoreConfig config,
FlutterBackingStore backing_store_out 
)
static

Definition at line 250 of file fl_engine.cc.

253 {
254 if (!fl_opengl_manager_make_current(self->opengl_manager)) {
255 return false;
256 }
257
258 GLint sized_format = GL_RGBA8;
259 GLint general_format = GL_RGBA;
260 if (epoxy_has_gl_extension("GL_EXT_texture_format_BGRA8888")) {
261 sized_format = GL_BGRA8_EXT;
262 general_format = GL_BGRA_EXT;
263 }
264
265 FlFramebuffer* framebuffer = fl_framebuffer_new(
266 general_format, config->size.width, config->size.height, FALSE);
267 if (!framebuffer) {
268 g_warning("Failed to create backing store");
269 return false;
270 }
271
272 backing_store_out->type = kFlutterBackingStoreTypeOpenGL;
274 backing_store_out->open_gl.framebuffer.user_data = framebuffer;
275 backing_store_out->open_gl.framebuffer.name =
276 fl_framebuffer_get_id(framebuffer);
277 backing_store_out->open_gl.framebuffer.target = sized_format;
278 backing_store_out->open_gl.framebuffer.destruction_callback = [](void* p) {
279 // Backing store destroyed in fl_compositor_opengl_collect_backing_store(),
280 // set on FlutterCompositor.collect_backing_store_callback during engine
281 // start.
282 };
283
284 return true;
285}
@ kFlutterOpenGLTargetTypeFramebuffer
Definition embedder.h:417
@ kFlutterBackingStoreTypeOpenGL
Definition embedder.h:2051
FlFramebuffer * fl_framebuffer_new(GLint format, size_t width, size_t height, gboolean shareable)
GLuint fl_framebuffer_get_id(FlFramebuffer *self)
bool epoxy_has_gl_extension(const char *extension)
FlutterSize size
The size of the render target the engine expects to render into.
Definition embedder.h:2093
FlutterBackingStoreType type
Specifies the type of backing store.
Definition embedder.h:2071
FlutterOpenGLTargetType type
Definition embedder.h:1914
uint32_t name
The name of the framebuffer.
Definition embedder.h:544
VoidCallback destruction_callback
Definition embedder.h:551
double height
Definition embedder.h:629
double width
Definition embedder.h:628

References FlutterOpenGLFramebuffer::destruction_callback, epoxy_has_gl_extension(), fl_framebuffer_get_id(), fl_framebuffer_new(), fl_opengl_manager_make_current(), FlutterOpenGLBackingStore::framebuffer, FlutterSize::height, kFlutterBackingStoreTypeOpenGL, kFlutterOpenGLTargetTypeFramebuffer, FlutterOpenGLFramebuffer::name, FlutterBackingStore::open_gl, self, FlutterBackingStoreConfig::size, FlutterOpenGLFramebuffer::target, FlutterOpenGLBackingStore::type, FlutterBackingStore::type, FlutterOpenGLFramebuffer::user_data, and FlutterSize::width.

Referenced by compositor_create_backing_store_callback().

◆ create_software_backing_store()

static bool create_software_backing_store ( FlEngine *  self,
const FlutterBackingStoreConfig config,
FlutterBackingStore backing_store_out 
)
static

Definition at line 299 of file fl_engine.cc.

302 {
303 size_t allocation_length = config->size.width * config->size.height * 4;
304 uint8_t* allocation = static_cast<uint8_t*>(malloc(allocation_length));
305 if (allocation == nullptr) {
306 return false;
307 }
308
309 backing_store_out->type = kFlutterBackingStoreTypeSoftware;
310 backing_store_out->software.allocation = allocation;
311 backing_store_out->software.height = config->size.height;
312 backing_store_out->software.row_bytes = config->size.width * 4;
313 backing_store_out->software.user_data = nullptr;
314 backing_store_out->software.destruction_callback = [](void* p) {
315 // Backing store destroyed in
316 // fl_compositor_software_collect_backing_store(), set on
317 // FlutterCompositor.collect_backing_store_callback during engine start.
318 };
319
320 return true;
321}
@ kFlutterBackingStoreTypeSoftware
Specified an software allocation for Flutter to render into using the CPU.
Definition embedder.h:2053
VoidCallback destruction_callback
Definition embedder.h:1941
size_t row_bytes
The number of bytes in a single row of the allocation.
Definition embedder.h:1932
size_t height
The number of rows in the allocation.
Definition embedder.h:1934

References FlutterSoftwareBackingStore::allocation, FlutterSoftwareBackingStore::destruction_callback, FlutterSize::height, FlutterSoftwareBackingStore::height, kFlutterBackingStoreTypeSoftware, FlutterSoftwareBackingStore::row_bytes, FlutterBackingStoreConfig::size, FlutterBackingStore::software, FlutterBackingStore::type, FlutterSoftwareBackingStore::user_data, and FlutterSize::width.

Referenced by compositor_create_backing_store_callback().

◆ fl_engine_add_view()

FlutterViewId fl_engine_add_view ( FlEngine *  engine,
FlRenderable *  renderable,
size_t  width,
size_t  height,
double  pixel_ratio,
GCancellable *  cancellable,
GAsyncReadyCallback  callback,
gpointer  user_data 
)

fl_engine_add_view: @engine: an #FlEngine. @renderable: the object that will render this view. @width: width of view in pixels. @height: height of view in pixels. @pixel_ratio: scale factor for view. @cancellable: (allow-none): a #GCancellable or NULL. @callback: (scope async): a #GAsyncReadyCallback to call when the view is added. @user_data: (closure): user data to pass to @callback.

Asynchronously add a new view. The returned view ID should not be used until this function completes.

Returns: the ID for the view.

Definition at line 892 of file fl_engine.cc.

899 {
900 g_return_val_if_fail(FL_IS_ENGINE(self), -1);
901
902 g_autoptr(GTask) task = g_task_new(self, cancellable, callback, user_data);
903
904 FlutterViewId view_id = self->next_view_id;
905 self->next_view_id++;
906
907 GWeakRef* ref = g_new(GWeakRef, 1);
908 g_weak_ref_init(ref, G_OBJECT(renderable));
909 g_hash_table_insert(self->renderables_by_view_id, GINT_TO_POINTER(view_id),
910 ref);
911
912 // We don't know which display this view will open on, so set to zero and this
913 // will be updated in a following FlutterWindowMetricsEvent
914 FlutterEngineDisplayId display_id = 0;
915
916 FlutterWindowMetricsEvent metrics = {};
917 metrics.struct_size = sizeof(FlutterWindowMetricsEvent);
918 metrics.width = width;
919 metrics.height = height;
920 metrics.pixel_ratio = pixel_ratio;
921 metrics.display_id = display_id;
922 metrics.view_id = view_id;
924 info.struct_size = sizeof(FlutterAddViewInfo);
925 info.view_id = view_id;
926 info.view_metrics = &metrics;
927 info.user_data = g_object_ref(task);
929 FlutterEngineResult result = self->embedder_api.AddView(self->engine, &info);
930 if (result != kSuccess) {
931 g_task_return_new_error(task, fl_engine_error_quark(),
932 FL_ENGINE_ERROR_FAILED, "AddView returned %d",
933 result);
934 // This would have been done in the callback, but that won't occur now.
935 g_object_unref(task);
936 }
937
938 return view_id;
939}
uint64_t FlutterEngineDisplayId
Definition embedder.h:1043
FlutterEngineResult
Definition embedder.h:72
@ kSuccess
Definition embedder.h:73
int64_t FlutterViewId
Definition embedder.h:386
static void view_added_cb(const FlutterAddViewResult *result)
Definition fl_engine.cc:171
GQuark fl_engine_error_quark(void) G_GNUC_CONST
@ FL_ENGINE_ERROR_FAILED
g_hash_table_insert(self->handlers, g_strdup(channel), handler_new(handler, user_data, destroy_notify))
G_BEGIN_DECLS FlutterViewId view_id
FlutterDesktopBinaryReply callback
int32_t height
int32_t width
FlutterAddViewCallback add_view_callback
Definition embedder.h:1117
FlutterViewId view_id
The identifier for the view to add. This must be unique.
Definition embedder.h:1097
const FlutterWindowMetricsEvent * view_metrics
Definition embedder.h:1102
FlutterEngineDisplayId display_id
The identifier of the display the view is rendering on.
Definition embedder.h:1067
size_t struct_size
The size of this struct. Must be sizeof(FlutterWindowMetricsEvent).
Definition embedder.h:1047
size_t height
Physical height of the window.
Definition embedder.h:1051
int64_t view_id
The view that this event is describing.
Definition embedder.h:1069
double pixel_ratio
Scale factor for the physical screen.
Definition embedder.h:1053
size_t width
Physical width of the window.
Definition embedder.h:1049

References FlutterAddViewInfo::add_view_callback, callback, FlutterWindowMetricsEvent::display_id, FL_ENGINE_ERROR_FAILED, fl_engine_error_quark(), g_autoptr(), g_hash_table_insert(), height, FlutterWindowMetricsEvent::height, kSuccess, FlutterWindowMetricsEvent::pixel_ratio, self, FlutterWindowMetricsEvent::struct_size, FlutterAddViewInfo::struct_size, user_data, FlutterAddViewInfo::user_data, view_added_cb(), FlutterWindowMetricsEvent::view_id, FlutterAddViewInfo::view_id, view_id, FlutterAddViewInfo::view_metrics, width, and FlutterWindowMetricsEvent::width.

Referenced by fl_view_new_for_engine(), TEST(), TEST(), and TEST().

◆ fl_engine_add_view_finish()

gboolean fl_engine_add_view_finish ( FlEngine *  engine,
GAsyncResult *  result,
GError **  error 
)

fl_engine_add_view_finish: @engine: an #FlEngine.

Returns
: a #GAsyncResult. @error: (allow-none): #GError location to store the error occurring, or NULL to ignore.

Completes request started with fl_engine_add_view().

Returns: TRUE on success.

Definition at line 941 of file fl_engine.cc.

943 {
944 g_return_val_if_fail(FL_IS_ENGINE(self), FALSE);
945 return g_task_propagate_boolean(G_TASK(result), error);
946}
const uint8_t uint32_t uint32_t GError ** error

References error, and self.

Referenced by add_view_cb(), add_view_engine_error_cb(), add_view_error_cb(), and view_added_cb().

◆ fl_engine_class_init()

static void fl_engine_class_init ( FlEngineClass *  klass)
static

Definition at line 608 of file fl_engine.cc.

608 {
609 G_OBJECT_CLASS(klass)->dispose = fl_engine_dispose;
610 G_OBJECT_CLASS(klass)->set_property = fl_engine_set_property;
611
612 g_object_class_install_property(
613 G_OBJECT_CLASS(klass), PROP_BINARY_MESSENGER,
614 g_param_spec_object(
615 "binary-messenger", "messenger", "Binary messenger",
616 fl_binary_messenger_get_type(),
617 static_cast<GParamFlags>(G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY |
618 G_PARAM_STATIC_STRINGS)));
619
621 "on-pre-engine-restart", fl_engine_get_type(), G_SIGNAL_RUN_LAST, 0,
622 nullptr, nullptr, nullptr, G_TYPE_NONE, 0);
624 "update-semantics", fl_engine_get_type(), G_SIGNAL_RUN_LAST, 0, nullptr,
625 nullptr, nullptr, G_TYPE_NONE, 1, G_TYPE_POINTER);
626}
static void fl_engine_dispose(GObject *object)
Definition fl_engine.cc:563
static guint fl_engine_signals[LAST_SIGNAL]
Definition fl_engine.cc:116
static void fl_engine_set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
Definition fl_engine.cc:547

References fl_engine_dispose(), fl_engine_set_property(), fl_engine_signals, SIGNAL_ON_PRE_ENGINE_RESTART, and SIGNAL_UPDATE_SEMANTICS.

◆ fl_engine_dispatch_semantics_action()

void fl_engine_dispatch_semantics_action ( FlEngine *  engine,
FlutterViewId  view_id,
uint64_t  node_id,
FlutterSemanticsAction  action,
GBytes *  data 
)

fl_engine_dispatch_semantics_action: @engine: an #FlEngine. @view_id: the view that the event occured on. @node_id: the semantics action identifier. @action: the action being dispatched. @data: (allow-none): data associated with the action.

Definition at line 1400 of file fl_engine.cc.

1404 {
1405 g_return_if_fail(FL_IS_ENGINE(self));
1406
1407 if (self->engine == nullptr) {
1408 return;
1409 }
1410
1411 const uint8_t* action_data = nullptr;
1412 size_t action_data_length = 0;
1413 if (data != nullptr) {
1414 action_data = static_cast<const uint8_t*>(
1415 g_bytes_get_data(data, &action_data_length));
1416 }
1417
1420 info.view_id = view_id;
1421 info.node_id = node_id;
1422 info.action = action;
1423 info.data = action_data;
1424 info.data_length = action_data_length;
1425 if (self->embedder_api.SendSemanticsAction(self->engine, &info) != kSuccess) {
1426 g_warning("Failed to send semantics action");
1427 }
1428}
FlutterViewId view_id
The ID of the view that includes the node.
Definition embedder.h:2774
FlutterSemanticsAction action
The semantics action.
Definition embedder.h:2780
size_t data_length
The data length.
Definition embedder.h:2786
uint64_t node_id
The semantics node identifier.
Definition embedder.h:2777
const uint8_t * data
Data associated with the action.
Definition embedder.h:2783
std::shared_ptr< const fml::Mapping > data

References FlutterSendSemanticsActionInfo::action, action, data, FlutterSendSemanticsActionInfo::data, FlutterSendSemanticsActionInfo::data_length, kSuccess, FlutterSendSemanticsActionInfo::node_id, self, FlutterSendSemanticsActionInfo::struct_size, FlutterSendSemanticsActionInfo::view_id, and view_id.

Referenced by fl_accessible_node_perform_action_impl(), and TEST().

◆ fl_engine_dispose()

static void fl_engine_dispose ( GObject *  object)
static

Definition at line 563 of file fl_engine.cc.

563 {
564 FlEngine* self = FL_ENGINE(object);
565
566 if (self->engine != nullptr) {
567 if (self->embedder_api.Shutdown(self->engine) != kSuccess) {
568 g_warning("Failed to shutdown Flutter engine");
569 }
570 self->engine = nullptr;
571 }
572
573 if (self->aot_data != nullptr) {
574 if (self->embedder_api.CollectAOTData(self->aot_data) != kSuccess) {
575 g_warning("Failed to send collect AOT data");
576 }
577 self->aot_data = nullptr;
578 }
579
580 fl_binary_messenger_shutdown(self->binary_messenger);
581 fl_texture_registrar_shutdown(self->texture_registrar);
582
583 g_clear_object(&self->project);
584 g_clear_object(&self->display_monitor);
585 g_clear_object(&self->opengl_manager);
586 g_clear_object(&self->texture_registrar);
587 g_clear_object(&self->binary_messenger);
588 g_clear_object(&self->settings_handler);
589 g_clear_object(&self->platform_handler);
590 g_clear_object(&self->windowing_handler);
591 g_clear_object(&self->keyboard_manager);
592 g_clear_object(&self->text_input_handler);
593 g_clear_object(&self->keyboard_handler);
594 g_clear_object(&self->mouse_cursor_handler);
595 g_clear_object(&self->task_runner);
596 g_clear_pointer(&self->renderables_by_view_id, g_hash_table_unref);
597
598 if (self->platform_message_handler_destroy_notify) {
599 self->platform_message_handler_destroy_notify(
600 self->platform_message_handler_data);
601 }
602 self->platform_message_handler_data = nullptr;
603 self->platform_message_handler_destroy_notify = nullptr;
604
605 G_OBJECT_CLASS(fl_engine_parent_class)->dispose(object);
606}
void fl_binary_messenger_shutdown(FlBinaryMessenger *self)
void fl_texture_registrar_shutdown(FlTextureRegistrar *self)

References fl_binary_messenger_shutdown(), fl_texture_registrar_shutdown(), kSuccess, and self.

Referenced by fl_engine_class_init().

◆ fl_engine_execute_task()

void fl_engine_execute_task ( FlEngine *  engine,
FlutterTask task 
)

fl_engine_execute_task: @engine: an #FlEngine. @task: a FlutterTask to execute.

Executes given Flutter task.

Definition at line 1462 of file fl_engine.cc.

1462 {
1463 g_return_if_fail(FL_IS_ENGINE(self));
1464 if (self->embedder_api.RunTask(self->engine, task) != kSuccess) {
1465 g_warning("Failed to run task");
1466 }
1467}

References kSuccess, and self.

Referenced by fl_task_runner_process_expired_tasks_locked().

◆ fl_engine_for_id()

FlEngine * fl_engine_for_id ( int64_t  handle)

fl_engine_for_id: @handle: an engine identifier obtained through PlatformDispatcher.instance.engineId.

Returns Flutter engine associated with the identifier. The identifier must be valid and for a running engine otherwise the behavior is undefined. Must be called from the main thread.

Returns: a #FlEngine or NULL.

Definition at line 691 of file fl_engine.cc.

691 {
692 void* engine = reinterpret_cast<void*>(id);
693 g_return_val_if_fail(FL_IS_ENGINE(engine), nullptr);
694 return FL_ENGINE(engine);
695}
FlutterEngine engine
Definition main.cc:84
const uintptr_t id

References engine, and id.

Referenced by TEST().

◆ fl_engine_get_binary_messenger()

G_MODULE_EXPORT FlBinaryMessenger * fl_engine_get_binary_messenger ( FlEngine *  engine)

fl_engine_get_binary_messenger: @engine: an #FlEngine.

Gets the messenger to communicate with this engine.

Returns: an #FlBinaryMessenger.

Definition at line 1451 of file fl_engine.cc.

1452 {
1453 g_return_val_if_fail(FL_IS_ENGINE(self), nullptr);
1454 return self->binary_messenger;
1455}

References self.

Referenced by fl_keyboard_manager_new(), fl_settings_handler_new(), fl_view_get_registrar_for_plugin(), fl_windowing_handler_new(), realize_cb(), TEST(), TEST(), TEST(), and TEST().

◆ fl_engine_get_display_monitor()

FlDisplayMonitor * fl_engine_get_display_monitor ( FlEngine *  engine)

fl_engine_get_display_monitor: @engine: an #FlEngine.

Gets the display monitor used by this engine.

Returns: an #FlDisplayMonitor.

Definition at line 721 of file fl_engine.cc.

721 {
722 g_return_val_if_fail(FL_IS_ENGINE(self), nullptr);
723 return self->display_monitor;
724}

References self.

Referenced by handle_geometry_changed(), and TEST().

◆ fl_engine_get_embedder_api()

FlutterEngineProcTable * fl_engine_get_embedder_api ( FlEngine *  engine)

fl_engine_get_embedder_api: @engine: an #FlEngine.

Gets the embedder API proc table, allowing modificiations for unit testing.

Returns: a mutable pointer to the embedder API proc table.

Definition at line 868 of file fl_engine.cc.

868 {
869 return &(self->embedder_api);
870}

References self.

Referenced by TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), and TEST().

◆ fl_engine_get_keyboard_manager()

FlKeyboardManager * fl_engine_get_keyboard_manager ( FlEngine *  engine)

fl_engine_get_keyboard_manager: @engine: an #FlEngine.

Gets the keyboard manager used by this engine.

Returns: an #FlKeyboardManager.

Definition at line 1499 of file fl_engine.cc.

1499 {
1500 g_return_val_if_fail(FL_IS_ENGINE(self), nullptr);
1501 return self->keyboard_manager;
1502}

References self.

Referenced by handle_key_event(), sync_modifier_if_needed(), and TEST().

◆ fl_engine_get_mouse_cursor_handler()

FlMouseCursorHandler * fl_engine_get_mouse_cursor_handler ( FlEngine *  engine)

fl_engine_get_mouse_cursor_handler: @engine: an #FlEngine.

Gets the mouse cursor handler used by this engine.

Returns: an #FlMouseCursorHandler.

Definition at line 1509 of file fl_engine.cc.

1509 {
1510 g_return_val_if_fail(FL_IS_ENGINE(self), nullptr);
1511 return self->mouse_cursor_handler;
1512}

References self.

Referenced by cursor_changed_cb(), fl_view_dispose(), setup_cursor(), and TEST().

◆ fl_engine_get_opengl_manager()

FlOpenGLManager * fl_engine_get_opengl_manager ( FlEngine *  engine)

fl_engine_get_opengl_manager: @engine: an #FlEngine.

Gets the OpenGL manager used by this engine.

Returns: an #FlOpenGLManager.

Definition at line 716 of file fl_engine.cc.

716 {
717 g_return_val_if_fail(FL_IS_ENGINE(self), nullptr);
718 return self->opengl_manager;
719}

References self.

Referenced by realize_cb(), and setup_opengl().

◆ fl_engine_get_registrar_for_plugin()

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

Definition at line 533 of file fl_engine.cc.

535 {
536 FlEngine* self = FL_ENGINE(registry);
537
538 return fl_plugin_registrar_new(nullptr, self->binary_messenger,
539 self->texture_registrar);
540}
FlPluginRegistrar * fl_plugin_registrar_new(FlView *view, FlBinaryMessenger *messenger, FlTextureRegistrar *texture_registrar)

References fl_plugin_registrar_new(), and self.

Referenced by fl_engine_plugin_registry_iface_init().

◆ fl_engine_get_renderable()

FlRenderable * fl_engine_get_renderable ( FlEngine *  engine,
FlutterViewId  view_id 
)

fl_engine_get_renderable: @engine: an #FlEngine. @view_id: ID to check.

Gets the renderable associated with the give view ID.

Returns: (transfer full): a reference to an #FlRenderable or NULL if none for this ID.

Definition at line 948 of file fl_engine.cc.

948 {
949 g_return_val_if_fail(FL_IS_ENGINE(self), nullptr);
950
951 GWeakRef* ref = static_cast<GWeakRef*>(g_hash_table_lookup(
952 self->renderables_by_view_id, GINT_TO_POINTER(view_id)));
953 return FL_RENDERABLE(g_weak_ref_get(ref));
954}

References self, and view_id.

◆ fl_engine_get_renderer_type()

FlutterRendererType fl_engine_get_renderer_type ( FlEngine *  engine)

fl_engine_get_renderer_type: @engine: an #FlEngine.

Gets the rendering type used by this engine.

Returns: type of rendering used.

Definition at line 711 of file fl_engine.cc.

711 {
712 g_return_val_if_fail(FL_IS_ENGINE(self), static_cast<FlutterRendererType>(0));
713 return self->renderer_type;
714}
FlutterRendererType
Definition embedder.h:79

References self.

Referenced by realize_cb().

◆ fl_engine_get_task_runner()

FlTaskRunner * fl_engine_get_task_runner ( FlEngine *  engine)

fl_engine_get_task_runner: @engine: an #FlEngine.

Returns
: a #FlTaskRunner.

Returns: task runner responsible for scheduling Flutter tasks.

Definition at line 1457 of file fl_engine.cc.

1457 {
1458 g_return_val_if_fail(FL_IS_ENGINE(self), nullptr);
1459 return self->task_runner;
1460}

References self.

Referenced by setup_opengl(), setup_software(), and TEST().

◆ fl_engine_get_text_input_handler()

FlTextInputHandler * fl_engine_get_text_input_handler ( FlEngine *  engine)

fl_engine_get_text_input_handler: @engine: an #FlEngine.

Gets the text input handler used by this engine.

Returns: an #FlTextInputHandler.

Definition at line 1504 of file fl_engine.cc.

1504 {
1505 g_return_val_if_fail(FL_IS_ENGINE(self), nullptr);
1506 return self->text_input_handler;
1507}

References self.

Referenced by fl_view_focus_in_event(), and handle_key_event().

◆ fl_engine_get_texture_registrar()

G_MODULE_EXPORT FlTextureRegistrar * fl_engine_get_texture_registrar ( FlEngine *  engine)

fl_engine_get_texture_registrar: @engine: an #FlEngine.

Gets the texture registrar for registering textures.

Returns: an #FlTextureRegistrar.

Definition at line 1469 of file fl_engine.cc.

1470 {
1471 g_return_val_if_fail(FL_IS_ENGINE(self), nullptr);
1472 return self->texture_registrar;
1473}

References self.

Referenced by fl_view_get_registrar_for_plugin().

◆ fl_engine_get_windowing_handler()

FlWindowingHandler * fl_engine_get_windowing_handler ( FlEngine *  engine)

fl_engine_get_windowing_handler: @engine: an #FlEngine.

Gets the windowing handler used by this engine.

Returns: an #FlWindowingHandler.

Definition at line 1494 of file fl_engine.cc.

1494 {
1495 g_return_val_if_fail(FL_IS_ENGINE(self), nullptr);
1496 return self->windowing_handler;
1497}

References self.

Referenced by fl_application_activate(), and TEST().

◆ fl_engine_gl_clear_current()

static bool fl_engine_gl_clear_current ( void *  user_data)
static

Definition at line 391 of file fl_engine.cc.

391 {
392 FlEngine* self = static_cast<FlEngine*>(user_data);
393 return fl_opengl_manager_clear_current(self->opengl_manager);
394}
gboolean fl_opengl_manager_clear_current(FlOpenGLManager *self)

References fl_opengl_manager_clear_current(), self, and user_data.

Referenced by fl_engine_start().

◆ 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 
)
static

Definition at line 407 of file fl_engine.cc.

412 {
413 FlEngine* self = static_cast<FlEngine*>(user_data);
414 if (!self->texture_registrar) {
415 return false;
416 }
417
418 FlTexture* texture =
420 if (texture == nullptr) {
421 g_warning("Unable to find texture %" G_GINT64_FORMAT, texture_id);
422 return false;
423 }
424
425 gboolean result;
426 g_autoptr(GError) error = nullptr;
427 if (FL_IS_TEXTURE_GL(texture)) {
428 result = fl_texture_gl_populate(FL_TEXTURE_GL(texture), width, height,
429 opengl_texture, &error);
430 } else if (FL_IS_PIXEL_BUFFER_TEXTURE(texture)) {
431 result =
432 fl_pixel_buffer_texture_populate(FL_PIXEL_BUFFER_TEXTURE(texture),
433 width, height, opengl_texture, &error);
434 } else {
435 g_warning("Unsupported texture type %" G_GINT64_FORMAT, texture_id);
436 return false;
437 }
438
439 if (!result) {
440 g_warning("%s", error->message);
441 return false;
442 }
443
444 return true;
445}
gboolean fl_pixel_buffer_texture_populate(FlPixelBufferTexture *texture, uint32_t width, uint32_t height, FlutterOpenGLTexture *opengl_texture, GError **error)
gboolean fl_texture_gl_populate(FlTextureGL *self, uint32_t width, uint32_t height, FlutterOpenGLTexture *opengl_texture, GError **error)
FlTexture * fl_texture_registrar_lookup_texture(FlTextureRegistrar *self, int64_t texture_id)
FlTexture * texture
int64_t texture_id

References error, fl_pixel_buffer_texture_populate(), fl_texture_gl_populate(), fl_texture_registrar_lookup_texture(), g_autoptr(), height, self, texture, texture_id, user_data, and width.

Referenced by fl_engine_start().

◆ fl_engine_gl_get_fbo()

static uint32_t fl_engine_gl_get_fbo ( void *  user_data)
static

Definition at line 396 of file fl_engine.cc.

396 {
397 // There is only one frame buffer object - always return that.
398 return 0;
399}

Referenced by fl_engine_start().

◆ fl_engine_gl_make_current()

static bool fl_engine_gl_make_current ( void *  user_data)
static

Definition at line 386 of file fl_engine.cc.

386 {
387 FlEngine* self = static_cast<FlEngine*>(user_data);
388 return fl_opengl_manager_make_current(self->opengl_manager);
389}

References fl_opengl_manager_make_current(), self, and user_data.

Referenced by fl_engine_start().

◆ fl_engine_gl_make_resource_current()

static bool fl_engine_gl_make_resource_current ( void *  user_data)
static

Definition at line 401 of file fl_engine.cc.

401 {
402 FlEngine* self = static_cast<FlEngine*>(user_data);
403 return fl_opengl_manager_make_resource_current(self->opengl_manager);
404}
gboolean fl_opengl_manager_make_resource_current(FlOpenGLManager *self)

References fl_opengl_manager_make_resource_current(), self, and user_data.

Referenced by fl_engine_start().

◆ fl_engine_gl_proc_resolver()

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

Definition at line 382 of file fl_engine.cc.

382 {
383 return reinterpret_cast<void*>(eglGetProcAddress(name));
384}
const char * name
Definition fuchsia.cc:49

References name.

Referenced by fl_engine_start().

◆ fl_engine_init()

static void fl_engine_init ( FlEngine *  self)
static

Definition at line 628 of file fl_engine.cc.

628 {
629 self->thread = g_thread_self();
630
631 self->embedder_api.struct_size = sizeof(FlutterEngineProcTable);
632 if (FlutterEngineGetProcAddresses(&self->embedder_api) != kSuccess) {
633 g_warning("Failed get get engine function pointers");
634 }
635
636 self->opengl_manager = fl_opengl_manager_new();
637
638 self->display_monitor =
640 self->task_runner = fl_task_runner_new(self);
641
642 // Implicit view is 0, so start at 1.
643 self->next_view_id = 1;
644 self->renderables_by_view_id = g_hash_table_new_full(
645 g_direct_hash, g_direct_equal, nullptr, [](gpointer value) {
646 GWeakRef* ref = static_cast<GWeakRef*>(value);
647 g_weak_ref_clear(ref);
648 free(ref);
649 });
650
651 self->texture_registrar = fl_texture_registrar_new(self);
652}
int32_t value
FlutterEngineResult FlutterEngineGetProcAddresses(FlutterEngineProcTable *table)
Gets the table of engine function pointers.
Definition embedder.cc:3696
FlDisplayMonitor * fl_display_monitor_new(FlEngine *engine, GdkDisplay *display)
FlOpenGLManager * fl_opengl_manager_new()
FlTaskRunner * fl_task_runner_new(FlEngine *engine)
FlTextureRegistrar * fl_texture_registrar_new(FlEngine *engine)
GdkDisplay * gdk_display_get_default()
Definition mock_gtk.cc:65
Function-pointer-based versions of the APIs above.
Definition embedder.h:3704

References fl_display_monitor_new(), fl_opengl_manager_new(), fl_task_runner_new(), fl_texture_registrar_new(), FlutterEngineGetProcAddresses(), gdk_display_get_default(), kSuccess, self, and value.

◆ fl_engine_mark_texture_frame_available()

gboolean fl_engine_mark_texture_frame_available ( FlEngine *  engine,
int64_t  texture_id 
)

fl_engine_mark_texture_frame_available: @engine: an #FlEngine. @texture_id: the identifier of the texture whose frame has been updated.

Tells the Flutter engine that a new texture frame is available for the given texture.

Returns: TRUE on success.

Definition at line 1430 of file fl_engine.cc.

1431 {
1432 g_return_val_if_fail(FL_IS_ENGINE(self), FALSE);
1433 return self->embedder_api.MarkExternalTextureFrameAvailable(
1434 self->engine, texture_id) == kSuccess;
1435}

References kSuccess, self, and texture_id.

Referenced by mark_texture_frame_available().

◆ fl_engine_new()

G_MODULE_EXPORT FlEngine * fl_engine_new ( FlDartProject *  project)

FlEngine:

#FlEngine is an object that contains a running Flutter engine. fl_engine_new: @project: an #FlDartProject.

Creates new Flutter engine.

Returns: a new #FlEngine.

Definition at line 697 of file fl_engine.cc.

697 {
698 return fl_engine_new_full(project, nullptr);
699}
static FlEngine * fl_engine_new_full(FlDartProject *project, FlBinaryMessenger *binary_messenger)
Definition fl_engine.cc:654

References fl_engine_new_full().

Referenced by fl_engine_new_headless(), fl_view_new(), FlAccessibleNodeTest::SetUp(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), and TEST().

◆ fl_engine_new_full()

static FlEngine * fl_engine_new_full ( FlDartProject *  project,
FlBinaryMessenger *  binary_messenger 
)
static

Definition at line 654 of file fl_engine.cc.

655 {
656 g_return_val_if_fail(FL_IS_DART_PROJECT(project), nullptr);
657
658 FlEngine* self = FL_ENGINE(g_object_new(fl_engine_get_type(), nullptr));
659
660 self->project = FL_DART_PROJECT(g_object_ref(project));
661 const gchar* renderer = g_getenv("FLUTTER_LINUX_RENDERER");
662 if (g_strcmp0(renderer, "software") == 0) {
663 self->renderer_type = kSoftware;
664 g_warning(
665 "Using the software renderer. Not all features are supported. This is "
666 "not recommended.\n"
667 "\n"
668 "To switch back to the default renderer, unset the "
669 "FLUTTER_LINUX_RENDERER environment variable.");
670 } else {
671 if (renderer != nullptr && strcmp(renderer, "opengl") != 0) {
672 g_warning("Unknown renderer type '%s', defaulting to opengl", renderer);
673 }
674 self->renderer_type = kOpenGL;
675 }
676
677 if (binary_messenger != nullptr) {
678 self->binary_messenger =
679 FL_BINARY_MESSENGER(g_object_ref(binary_messenger));
680 } else {
681 self->binary_messenger = fl_binary_messenger_new(self);
682 }
683 self->keyboard_manager = fl_keyboard_manager_new(self);
684 self->mouse_cursor_handler =
685 fl_mouse_cursor_handler_new(self->binary_messenger);
686 self->windowing_handler = fl_windowing_handler_new(self);
687
688 return self;
689}
FlBinaryMessenger * fl_binary_messenger_new(FlEngine *engine)
FlKeyboardManager * fl_keyboard_manager_new(FlEngine *engine)
FlMouseCursorHandler * fl_mouse_cursor_handler_new(FlBinaryMessenger *messenger)
FlWindowingHandler * fl_windowing_handler_new(FlEngine *engine)

References fl_binary_messenger_new(), fl_keyboard_manager_new(), fl_mouse_cursor_handler_new(), fl_windowing_handler_new(), kOpenGL, kSoftware, and self.

Referenced by fl_engine_new(), and fl_engine_new_with_binary_messenger().

◆ fl_engine_new_headless()

G_MODULE_EXPORT FlEngine * fl_engine_new_headless ( FlDartProject *  project)

fl_engine_new_headless: @project: an #FlDartProject.

Creates new Flutter engine running in headless mode.

Returns: a new #FlEngine.

Definition at line 707 of file fl_engine.cc.

707 {
708 return fl_engine_new(project);
709}
G_MODULE_EXPORT FlEngine * fl_engine_new(FlDartProject *project)
Definition fl_engine.cc:697

References fl_engine_new().

◆ fl_engine_new_with_binary_messenger()

FlEngine * fl_engine_new_with_binary_messenger ( FlBinaryMessenger *  binary_messenger)

fl_engine_new_with_binary_messenger: @binary_messenger: an #FlBinaryMessenger.

Creates a new engine with a custom binary messenger. Used for testing.

Returns: a new #FlEngine.

Definition at line 701 of file fl_engine.cc.

702 {
703 g_autoptr(FlDartProject) project = fl_dart_project_new();
704 return fl_engine_new_full(project, binary_messenger);
705}
G_MODULE_EXPORT FlDartProject * fl_dart_project_new()

References fl_dart_project_new(), fl_engine_new_full(), and g_autoptr().

Referenced by TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), and TEST().

◆ fl_engine_notify_display_update()

void fl_engine_notify_display_update ( FlEngine *  engine,
const FlutterEngineDisplay displays,
size_t  displays_length 
)

fl_engine_notify_display_update: @engine: an #FlEngine. @displays: displays present on the system. @displays_length: length of @displays.

Notify the current displays that are in the system.

Definition at line 872 of file fl_engine.cc.

874 {
875 g_return_if_fail(FL_IS_ENGINE(self));
876
877 FlutterEngineResult result = self->embedder_api.NotifyDisplayUpdate(
879 displays_length);
880 if (result != kSuccess) {
881 g_warning("Failed to notify display update to Flutter engine: %d", result);
882 }
883}
@ kFlutterEngineDisplaysUpdateTypeStartup
Definition embedder.h:2324
std::vector< FlutterEngineDisplay > * displays

References displays, kFlutterEngineDisplaysUpdateTypeStartup, kSuccess, and self.

Referenced by notify_display_update(), and TEST().

◆ fl_engine_on_pre_engine_restart_cb()

static void fl_engine_on_pre_engine_restart_cb ( void *  user_data)
static

Definition at line 514 of file fl_engine.cc.

514 {
515 FlEngine* self = FL_ENGINE(user_data);
516
518
520}
g_signal_emit(self, fl_application_signals[SIGNAL_CREATE_WINDOW], 0, view, &window)
static void setup_keyboard(FlEngine *self)
Definition fl_engine.cc:490

References fl_engine_signals, g_signal_emit(), self, setup_keyboard(), SIGNAL_ON_PRE_ENGINE_RESTART, and user_data.

Referenced by fl_engine_start().

◆ fl_engine_platform_message_cb()

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

Definition at line 463 of file fl_engine.cc.

464 {
465 FlEngine* self = FL_ENGINE(user_data);
466
467 gboolean handled = FALSE;
468 if (self->platform_message_handler != nullptr) {
469 g_autoptr(GBytes) data =
470 g_bytes_new(message->message, message->message_size);
471 handled = self->platform_message_handler(
472 self, message->channel, data, message->response_handle,
473 self->platform_message_handler_data);
474 }
475
476 if (!handled) {
478 nullptr, nullptr);
479 }
480}
gboolean fl_engine_send_platform_message_response(FlEngine *self, const FlutterPlatformMessageResponseHandle *handle, GBytes *response, GError **error)
G_BEGIN_DECLS GBytes * message

References data, fl_engine_send_platform_message_response(), g_autoptr(), message, self, and user_data.

Referenced by fl_engine_start().

◆ fl_engine_platform_message_response_cb()

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

Definition at line 524 of file fl_engine.cc.

526 {
527 g_autoptr(GTask) task = G_TASK(user_data);
528 g_task_return_pointer(task, g_bytes_new(data, data_length),
529 reinterpret_cast<GDestroyNotify>(g_bytes_unref));
530}

References data, g_autoptr(), and user_data.

Referenced by fl_engine_send_platform_message().

◆ fl_engine_plugin_registry_iface_init()

static void fl_engine_plugin_registry_iface_init ( FlPluginRegistryInterface *  iface)
static

Definition at line 542 of file fl_engine.cc.

543 {
544 iface->get_registrar_for_plugin = fl_engine_get_registrar_for_plugin;
545}
static FlPluginRegistrar * fl_engine_get_registrar_for_plugin(FlPluginRegistry *registry, const gchar *name)
Definition fl_engine.cc:533

References fl_engine_get_registrar_for_plugin().

◆ fl_engine_post_task()

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

Definition at line 454 of file fl_engine.cc.

456 {
457 FlEngine* self = static_cast<FlEngine*>(user_data);
458
459 fl_task_runner_post_flutter_task(self->task_runner, task, target_time_nanos);
460}
void fl_task_runner_post_flutter_task(FlTaskRunner *self, FlutterTask task, uint64_t target_time_nanos)

References fl_task_runner_post_flutter_task(), self, and user_data.

Referenced by fl_engine_start().

◆ fl_engine_register_external_texture()

gboolean fl_engine_register_external_texture ( FlEngine *  engine,
int64_t  texture_id 
)

fl_engine_register_external_texture: @engine: an #FlEngine. @texture_id: the identifier of the texture that is available.

Tells the Flutter engine that a new external texture is available.

Returns: TRUE on success.

Definition at line 1437 of file fl_engine.cc.

1438 {
1439 g_return_val_if_fail(FL_IS_ENGINE(self), FALSE);
1440 return self->embedder_api.RegisterExternalTexture(self->engine, texture_id) ==
1441 kSuccess;
1442}

References kSuccess, self, and texture_id.

Referenced by register_texture().

◆ fl_engine_remove_view()

void fl_engine_remove_view ( FlEngine *  engine,
FlutterViewId  view_id,
GCancellable *  cancellable,
GAsyncReadyCallback  callback,
gpointer  user_data 
)

fl_engine_remove_view: @engine: an #FlEngine. @view_id: ID to remove. @cancellable: (allow-none): a #GCancellable or NULL. @callback: (scope async): a #GAsyncReadyCallback to call when the view is added. @user_data: (closure): user data to pass to @callback.

Removes a view previously added with fl_engine_add_view().

Definition at line 956 of file fl_engine.cc.

960 {
961 g_return_if_fail(FL_IS_ENGINE(self));
962
963 g_hash_table_remove(self->renderables_by_view_id, GINT_TO_POINTER(view_id));
964
965 g_autoptr(GTask) task = g_task_new(self, cancellable, callback, user_data);
966
968 info.struct_size = sizeof(FlutterRemoveViewInfo);
969 info.view_id = view_id;
970 info.user_data = g_object_ref(task);
972 FlutterEngineResult result =
973 self->embedder_api.RemoveView(self->engine, &info);
974 if (result != kSuccess) {
975 g_task_return_new_error(task, fl_engine_error_quark(),
976 FL_ENGINE_ERROR_FAILED, "RemoveView returned %d",
977 result);
978 // This would have been done in the callback, but that won't occur now.
979 g_object_unref(task);
980 }
981}
static void view_removed_cb(const FlutterRemoveViewResult *result)
Definition fl_engine.cc:182
FlutterRemoveViewCallback remove_view_callback
Definition embedder.h:1165
FlutterViewId view_id
Definition embedder.h:1148

References callback, FL_ENGINE_ERROR_FAILED, fl_engine_error_quark(), g_autoptr(), kSuccess, FlutterRemoveViewInfo::remove_view_callback, self, FlutterRemoveViewInfo::struct_size, user_data, FlutterRemoveViewInfo::user_data, FlutterRemoveViewInfo::view_id, view_id, and view_removed_cb().

Referenced by fl_view_dispose(), TEST(), TEST(), and TEST().

◆ fl_engine_remove_view_finish()

gboolean fl_engine_remove_view_finish ( FlEngine *  engine,
GAsyncResult *  result,
GError **  error 
)

fl_engine_remove_view_finish: @engine: an #FlEngine.

Returns
: a #GAsyncResult. @error: (allow-none): #GError location to store the error occurring, or NULL to ignore.

Completes request started with fl_engine_remove_view().

Returns: TRUE on succcess.

Definition at line 983 of file fl_engine.cc.

985 {
986 g_return_val_if_fail(FL_IS_ENGINE(self), FALSE);
987 return g_task_propagate_boolean(G_TASK(result), error);
988}

References error, and self.

Referenced by remove_view_cb(), remove_view_engine_error_cb(), and remove_view_error_cb().

◆ fl_engine_request_app_exit()

void fl_engine_request_app_exit ( FlEngine *  engine)

fl_engine_request_app_exit: @engine: an #FlEngine.

Request the application exits.

Definition at line 1489 of file fl_engine.cc.

1489 {
1490 g_return_if_fail(FL_IS_ENGINE(self));
1491 fl_platform_handler_request_app_exit(self->platform_handler);
1492}
void fl_platform_handler_request_app_exit(FlPlatformHandler *self)

References fl_platform_handler_request_app_exit(), and self.

Referenced by window_delete_event_cb().

◆ fl_engine_runs_task_on_current_thread()

static bool fl_engine_runs_task_on_current_thread ( void *  user_data)
static

Definition at line 448 of file fl_engine.cc.

448 {
449 FlEngine* self = static_cast<FlEngine*>(user_data);
450 return self->thread == g_thread_self();
451}

References self, and user_data.

Referenced by fl_engine_start().

◆ fl_engine_send_key_event()

void fl_engine_send_key_event ( FlEngine *  engine,
const FlutterKeyEvent event,
GCancellable *  cancellable,
GAsyncReadyCallback  callback,
gpointer  user_data 
)

fl_engine_send_key_event: @engine: an #FlEngine. @event: key event to send. @cancellable: (allow-none): a #GCancellable or NULL. @callback: (scope async): a #GAsyncReadyCallback to call when the request is satisfied. @user_data: (closure): user data to pass to @callback.

Send a key event to the engine.

Definition at line 1360 of file fl_engine.cc.

1364 {
1365 g_return_if_fail(FL_IS_ENGINE(self));
1366
1367 g_autoptr(GTask) task = g_task_new(self, cancellable, callback, user_data);
1368
1369 if (self->engine == nullptr) {
1370 g_task_return_new_error(task, fl_engine_error_quark(),
1371 FL_ENGINE_ERROR_FAILED, "No engine");
1372 return;
1373 }
1374
1375 if (self->embedder_api.SendKeyEvent(self->engine, event, send_key_event_cb,
1376 g_object_ref(task)) != kSuccess) {
1377 g_task_return_new_error(task, fl_engine_error_quark(),
1378 FL_ENGINE_ERROR_FAILED, "Failed to send key event");
1379 g_object_unref(task);
1380 }
1381}
static void send_key_event_cb(bool handled, void *user_data)

References callback, FL_ENGINE_ERROR_FAILED, fl_engine_error_quark(), g_autoptr(), kSuccess, self, send_key_event_cb(), and user_data.

Referenced by fl_key_embedder_responder_handle_event(), fl_key_embedder_responder_handle_event_impl(), synthesize_simple_event(), TEST(), TEST(), and TEST().

◆ fl_engine_send_key_event_finish()

gboolean fl_engine_send_key_event_finish ( FlEngine *  engine,
GAsyncResult *  result,
gboolean *  handled,
GError **  error 
)

fl_engine_send_key_event_finish: @engine: an #FlEngine.

Returns
: a #GAsyncResult. @handled: location to write if this event was handled by the engine. @error: (allow-none): #GError location to store the error occurring, or NULL to ignore.

Completes request started with fl_engine_send_key_event().

Returns: TRUE on success.

Definition at line 1383 of file fl_engine.cc.

1386 {
1387 g_return_val_if_fail(FL_IS_ENGINE(self), FALSE);
1388 g_return_val_if_fail(g_task_is_valid(result, self), FALSE);
1389
1390 g_autofree gboolean* return_value =
1391 static_cast<gboolean*>(g_task_propagate_pointer(G_TASK(result), error));
1392 if (return_value == nullptr) {
1393 return FALSE;
1394 }
1395
1396 *handled = *return_value;
1397 return TRUE;
1398}
return TRUE

References error, self, and TRUE.

Referenced by TEST(), TEST(), and TEST().

◆ fl_engine_send_mouse_pointer_event()

void fl_engine_send_mouse_pointer_event ( FlEngine *  engine,
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 
)

fl_engine_send_mouse_pointer_event: @engine: an #FlEngine. @view_id: the view that the event occured on. @phase: mouse phase. @timestamp: time when event occurred in microseconds. @x: x location of mouse cursor. @y: y location of mouse cursor. @device_kind: kind of pointing device. @scroll_delta_x: x offset of scroll. @scroll_delta_y: y offset of scroll. @buttons: buttons that are pressed.

Sends a mouse pointer event to the engine.

Definition at line 1136 of file fl_engine.cc.

1145 {
1146 g_return_if_fail(FL_IS_ENGINE(self));
1147
1148 if (self->engine == nullptr) {
1149 return;
1150 }
1151
1152 FlutterPointerEvent fl_event = {};
1153 fl_event.struct_size = sizeof(fl_event);
1154 fl_event.phase = phase;
1155 fl_event.timestamp = timestamp;
1156 fl_event.x = x;
1157 fl_event.y = y;
1158 if (scroll_delta_x != 0 || scroll_delta_y != 0) {
1160 }
1161 fl_event.scroll_delta_x = scroll_delta_x;
1162 fl_event.scroll_delta_y = scroll_delta_y;
1163 fl_event.device_kind = device_kind;
1164 fl_event.buttons = buttons;
1165 fl_event.device = kMousePointerDeviceId;
1166 fl_event.view_id = view_id;
1167 if (self->embedder_api.SendPointerEvent(self->engine, &fl_event, 1) !=
1168 kSuccess) {
1169 g_warning("Failed to send pointer event");
1170 }
1171}
int32_t x
@ kFlutterPointerSignalKindScroll
Definition embedder.h:1301
static constexpr int32_t kMousePointerDeviceId
Definition fl_engine.cc:36
double y
double scroll_delta_y
The y offset of the scroll in physical pixels.
Definition embedder.h:1325
int64_t buttons
The buttons currently pressed, if any.
Definition embedder.h:1333
size_t struct_size
The size of this struct. Must be sizeof(FlutterPointerEvent).
Definition embedder.h:1308
FlutterViewId view_id
The identifier of the view that received the pointer event.
Definition embedder.h:1343
FlutterPointerSignalKind signal_kind
Definition embedder.h:1321
double scroll_delta_x
The x offset of the scroll in physical pixels.
Definition embedder.h:1323
double y
The y coordinate of the pointer event in physical pixels.
Definition embedder.h:1317
double x
The x coordinate of the pointer event in physical pixels.
Definition embedder.h:1315
FlutterPointerDeviceKind device_kind
Definition embedder.h:1331
FlutterPointerPhase phase
Definition embedder.h:1309

References FlutterPointerEvent::buttons, FlutterPointerEvent::device, FlutterPointerEvent::device_kind, kFlutterPointerSignalKindScroll, kMousePointerDeviceId, kSuccess, FlutterPointerEvent::phase, FlutterPointerEvent::scroll_delta_x, FlutterPointerEvent::scroll_delta_y, self, FlutterPointerEvent::signal_kind, FlutterPointerEvent::struct_size, FlutterPointerEvent::timestamp, FlutterPointerEvent::view_id, view_id, x, FlutterPointerEvent::x, FlutterPointerEvent::y, and y.

Referenced by ensure_pointer_added(), fl_pointer_manager_handle_button_press(), fl_pointer_manager_handle_button_release(), fl_pointer_manager_handle_leave(), fl_pointer_manager_handle_motion(), fl_scrolling_manager_handle_scroll_event(), and TEST().

◆ fl_engine_send_platform_message()

void fl_engine_send_platform_message ( FlEngine *  engine,
const gchar *  channel,
GBytes *  message,
GCancellable *  cancellable,
GAsyncReadyCallback  callback,
gpointer  user_data 
)

fl_engine_send_platform_message: @engine: an #FlEngine. @channel: channel to send to. @message: (allow-none): message buffer to send or NULL for an empty message @cancellable: (allow-none): a #GCancellable or NULL. @callback: (scope async): a #GAsyncReadyCallback to call when the request is satisfied. @user_data: (closure): user data to pass to @callback.

Asynchronously sends a platform message.

Definition at line 1041 of file fl_engine.cc.

1046 {
1047 g_return_if_fail(FL_IS_ENGINE(self));
1048
1049 GTask* task = nullptr;
1050 FlutterPlatformMessageResponseHandle* response_handle = nullptr;
1051 if (callback != nullptr) {
1052 task = g_task_new(self, cancellable, callback, user_data);
1053
1054 if (self->engine == nullptr) {
1055 g_task_return_new_error(task, fl_engine_error_quark(),
1056 FL_ENGINE_ERROR_FAILED, "No engine to send to");
1057 return;
1058 }
1059
1060 FlutterEngineResult result =
1061 self->embedder_api.PlatformMessageCreateResponseHandle(
1063 &response_handle);
1064 if (result != kSuccess) {
1065 g_task_return_new_error(task, fl_engine_error_quark(),
1067 "Failed to create response handle");
1068 g_object_unref(task);
1069 return;
1070 }
1071 } else if (self->engine == nullptr) {
1072 return;
1073 }
1074
1075 FlutterPlatformMessage fl_message = {};
1076 fl_message.struct_size = sizeof(fl_message);
1077 fl_message.channel = channel;
1078 fl_message.message =
1079 message != nullptr
1080 ? static_cast<const uint8_t*>(g_bytes_get_data(message, nullptr))
1081 : nullptr;
1082 fl_message.message_size = message != nullptr ? g_bytes_get_size(message) : 0;
1083 fl_message.response_handle = response_handle;
1084 FlutterEngineResult result =
1085 self->embedder_api.SendPlatformMessage(self->engine, &fl_message);
1086
1087 if (result != kSuccess && task != nullptr) {
1088 g_task_return_new_error(task, fl_engine_error_quark(),
1090 "Failed to send platform messages");
1091 g_object_unref(task);
1092 }
1093
1094 if (response_handle != nullptr) {
1095 if (self->embedder_api.PlatformMessageReleaseResponseHandle(
1096 self->engine, response_handle) != kSuccess) {
1097 g_warning("Failed to release response handle");
1098 }
1099 }
1100}
static void fl_engine_platform_message_response_cb(const uint8_t *data, size_t data_length, void *user_data)
Definition fl_engine.cc:524
const gchar * channel
size_t struct_size
The size of this struct. Must be sizeof(FlutterPlatformMessage).
Definition embedder.h:1436
const FlutterPlatformMessageResponseHandle * response_handle
Definition embedder.h:1446
const char * channel
Definition embedder.h:1437
const uint8_t * message
Definition embedder.h:1438

References callback, FlutterPlatformMessage::channel, channel, FL_ENGINE_ERROR_FAILED, fl_engine_error_quark(), fl_engine_platform_message_response_cb(), kSuccess, FlutterPlatformMessage::message, message, FlutterPlatformMessage::message_size, FlutterPlatformMessage::response_handle, self, FlutterPlatformMessage::struct_size, and user_data.

Referenced by send_on_channel(), and TEST().

◆ fl_engine_send_platform_message_finish()

GBytes * fl_engine_send_platform_message_finish ( FlEngine *  engine,
GAsyncResult *  result,
GError **  error 
)

fl_engine_send_platform_message_finish: @engine: an #FlEngine.

Returns
: a #GAsyncResult. @error: (allow-none): #GError location to store the error occurring, or NULL to ignore.

Completes request started with fl_engine_send_platform_message().

Returns: message response on success or NULL on error.

Definition at line 1102 of file fl_engine.cc.

1104 {
1105 g_return_val_if_fail(FL_IS_ENGINE(self), FALSE);
1106 g_return_val_if_fail(g_task_is_valid(result, self), FALSE);
1107
1108 return static_cast<GBytes*>(g_task_propagate_pointer(G_TASK(result), error));
1109}

References error, and self.

Referenced by send_on_channel_finish().

◆ fl_engine_send_platform_message_response()

gboolean fl_engine_send_platform_message_response ( FlEngine *  engine,
const FlutterPlatformMessageResponseHandle handle,
GBytes *  response,
GError **  error 
)

fl_engine_send_platform_message_response: @engine: an #FlEngine. @handle: handle that was provided in FlEnginePlatformMessageHandler. @response: (allow-none): response to send or NULL for an empty response. @error: (allow-none): #GError location to store the error occurring, or NULL to ignore.

Responds to a platform message.

Returns: TRUE on success.

Definition at line 1009 of file fl_engine.cc.

1013 {
1014 g_return_val_if_fail(FL_IS_ENGINE(self), FALSE);
1015 g_return_val_if_fail(handle != nullptr, FALSE);
1016
1017 if (self->engine == nullptr) {
1019 "No engine to send response to");
1020 return FALSE;
1021 }
1022
1023 gsize data_length = 0;
1024 const uint8_t* data = nullptr;
1025 if (response != nullptr) {
1026 data =
1027 static_cast<const uint8_t*>(g_bytes_get_data(response, &data_length));
1028 }
1029 FlutterEngineResult result = self->embedder_api.SendPlatformMessageResponse(
1030 self->engine, handle, data, data_length);
1031
1032 if (result != kSuccess) {
1034 "Failed to send platform message response");
1035 return FALSE;
1036 }
1037
1038 return TRUE;
1039}

References data, error, FL_ENGINE_ERROR_FAILED, fl_engine_error_quark(), kSuccess, self, and TRUE.

Referenced by fl_engine_platform_message_cb(), send_response(), and TEST().

◆ fl_engine_send_pointer_pan_zoom_event()

void fl_engine_send_pointer_pan_zoom_event ( FlEngine *  engine,
FlutterViewId  view_id,
size_t  timestamp,
double  x,
double  y,
FlutterPointerPhase  phase,
double  pan_x,
double  pan_y,
double  scale,
double  rotation 
)

fl_engine_send_pointer_pan_zoom_event: @engine: an #FlEngine. @view_id: the view that the event occured on. @timestamp: time when event occurred in microseconds. @x: x location of mouse cursor. @y: y location of mouse cursor. @phase: mouse phase. @pan_x: x offset of the pan/zoom in pixels. @pan_y: y offset of the pan/zoom in pixels. @scale: scale of the pan/zoom. @rotation: rotation of the pan/zoom in radians.

Sends a pan/zoom pointer event to the engine.

Definition at line 1318 of file fl_engine.cc.

1327 {
1328 g_return_if_fail(FL_IS_ENGINE(self));
1329
1330 if (self->engine == nullptr) {
1331 return;
1332 }
1333
1334 FlutterPointerEvent fl_event = {};
1335 fl_event.struct_size = sizeof(fl_event);
1336 fl_event.timestamp = timestamp;
1337 fl_event.x = x;
1338 fl_event.y = y;
1339 fl_event.phase = phase;
1340 fl_event.pan_x = pan_x;
1341 fl_event.pan_y = pan_y;
1342 fl_event.scale = scale;
1343 fl_event.rotation = rotation;
1346 fl_event.view_id = view_id;
1347 if (self->embedder_api.SendPointerEvent(self->engine, &fl_event, 1) !=
1348 kSuccess) {
1349 g_warning("Failed to send pointer event");
1350 }
1351}
@ kFlutterPointerDeviceKindTrackpad
Definition embedder.h:1283
static constexpr int32_t kPointerPanZoomDeviceId
Definition fl_engine.cc:37
double scale
The scale of the pan/zoom, where 1.0 is the initial scale.
Definition embedder.h:1339
double rotation
The rotation of the pan/zoom in radians, where 0.0 is the initial angle.
Definition embedder.h:1341
double pan_x
The x offset of the pan/zoom in physical pixels.
Definition embedder.h:1335
double pan_y
The y offset of the pan/zoom in physical pixels.
Definition embedder.h:1337

References FlutterPointerEvent::device, FlutterPointerEvent::device_kind, kFlutterPointerDeviceKindTrackpad, kPointerPanZoomDeviceId, kSuccess, FlutterPointerEvent::pan_x, FlutterPointerEvent::pan_y, FlutterPointerEvent::phase, FlutterPointerEvent::rotation, FlutterPointerEvent::scale, self, FlutterPointerEvent::struct_size, FlutterPointerEvent::timestamp, FlutterPointerEvent::view_id, view_id, x, FlutterPointerEvent::x, FlutterPointerEvent::y, and y.

Referenced by fl_scrolling_manager_handle_rotation_begin(), fl_scrolling_manager_handle_rotation_end(), fl_scrolling_manager_handle_rotation_update(), fl_scrolling_manager_handle_scroll_event(), fl_scrolling_manager_handle_zoom_begin(), fl_scrolling_manager_handle_zoom_end(), fl_scrolling_manager_handle_zoom_update(), and TEST().

◆ fl_engine_send_touch_add_event()

void fl_engine_send_touch_add_event ( FlEngine *  engine,
FlutterViewId  view_id,
size_t  timestamp,
double  x,
double  y,
int32_t  device 
)

fl_engine_send_touch_add_event: @engine: an #FlEngine. @view_id: the view that the event occured on. @timestamp: time when event occurred in microseconds. @x: x location of mouse cursor. @y: y location of mouse cursor. @device: device id.

Sends a touch add event to the engine.

Definition at line 1260 of file fl_engine.cc.

1265 {
1266 g_return_if_fail(FL_IS_ENGINE(self));
1267
1268 if (self->engine == nullptr) {
1269 return;
1270 }
1271
1272 FlutterPointerEvent event;
1273 event.timestamp = timestamp;
1274 event.x = x;
1275 event.y = y;
1276 event.device_kind = kFlutterPointerDeviceKindTouch;
1277 event.device = device;
1278 event.buttons = 0;
1279 event.view_id = view_id;
1280 event.phase = FlutterPointerPhase::kAdd;
1281 event.struct_size = sizeof(event);
1282
1283 if (self->embedder_api.SendPointerEvent(self->engine, &event, 1) !=
1284 kSuccess) {
1285 g_warning("Failed to send pointer event");
1286 }
1287}
@ kAdd
Definition embedder.h:1262
@ kFlutterPointerDeviceKindTouch
Definition embedder.h:1281
VkDevice device
Definition main.cc:69

References device, kAdd, kFlutterPointerDeviceKindTouch, kSuccess, self, FlutterPointerEvent::timestamp, view_id, x, and y.

Referenced by ensure_touch_added().

◆ fl_engine_send_touch_down_event()

void fl_engine_send_touch_down_event ( FlEngine *  engine,
FlutterViewId  view_id,
size_t  timestamp,
double  x,
double  y,
int32_t  device 
)

fl_engine_send_touch_down_event: @engine: an #FlEngine. @view_id: the view that the event occured on. @timestamp: time when event occurred in microseconds. @x: x location of mouse cursor. @y: y location of mouse cursor. @device: device id.

Sends a touch down event to the engine.

Definition at line 1202 of file fl_engine.cc.

1207 {
1208 g_return_if_fail(FL_IS_ENGINE(self));
1209
1210 if (self->engine == nullptr) {
1211 return;
1212 }
1213
1214 FlutterPointerEvent event;
1215 event.timestamp = timestamp;
1216 event.x = x;
1217 event.y = y;
1218 event.device_kind = kFlutterPointerDeviceKindTouch;
1219 event.device = device;
1221 event.view_id = view_id;
1222 event.phase = FlutterPointerPhase::kDown;
1223 event.struct_size = sizeof(event);
1224
1225 if (self->embedder_api.SendPointerEvent(self->engine, &event, 1) !=
1226 kSuccess) {
1227 g_warning("Failed to send pointer event");
1228 }
1229}
@ kDown
Definition embedder.h:1252
@ kFlutterPointerButtonMousePrimary
Definition embedder.h:1289

References device, kDown, kFlutterPointerButtonMousePrimary, kFlutterPointerDeviceKindTouch, kSuccess, self, FlutterPointerEvent::timestamp, view_id, x, and y.

Referenced by fl_touch_manager_handle_touch_event().

◆ fl_engine_send_touch_move_event()

void fl_engine_send_touch_move_event ( FlEngine *  engine,
FlutterViewId  view_id,
size_t  timestamp,
double  x,
double  y,
int32_t  device 
)

fl_engine_send_touch_move_event: @engine: an #FlEngine. @view_id: the view that the event occured on. @timestamp: time when event occurred in microseconds. @x: x location of mouse cursor. @y: y location of mouse cursor. @device: device id.

Sends a touch move event to the engine.

Definition at line 1231 of file fl_engine.cc.

1236 {
1237 g_return_if_fail(FL_IS_ENGINE(self));
1238
1239 if (self->engine == nullptr) {
1240 return;
1241 }
1242
1243 FlutterPointerEvent event;
1244 event.timestamp = timestamp;
1245 event.x = x;
1246 event.y = y;
1247 event.device_kind = kFlutterPointerDeviceKindTouch;
1248 event.device = device;
1250 event.view_id = view_id;
1251 event.phase = FlutterPointerPhase::kMove;
1252 event.struct_size = sizeof(event);
1253
1254 if (self->embedder_api.SendPointerEvent(self->engine, &event, 1) !=
1255 kSuccess) {
1256 g_warning("Failed to send pointer event");
1257 }
1258}
@ kMove
Definition embedder.h:1257

References device, kFlutterPointerButtonMousePrimary, kFlutterPointerDeviceKindTouch, kMove, kSuccess, self, FlutterPointerEvent::timestamp, view_id, x, and y.

Referenced by fl_touch_manager_handle_touch_event().

◆ fl_engine_send_touch_remove_event()

void fl_engine_send_touch_remove_event ( FlEngine *  engine,
FlutterViewId  view_id,
size_t  timestamp,
double  x,
double  y,
int32_t  device 
)

fl_engine_send_touch_remove_event: @engine: an #FlEngine. @view_id: the view that the event occured on. @timestamp: time when event occurred in microseconds. @x: x location of mouse cursor. @y: y location of mouse cursor. @device: device id.

Sends a touch remove event to the engine.

Definition at line 1289 of file fl_engine.cc.

1294 {
1295 g_return_if_fail(FL_IS_ENGINE(self));
1296
1297 if (self->engine == nullptr) {
1298 return;
1299 }
1300
1301 FlutterPointerEvent event;
1302 event.timestamp = timestamp;
1303 event.x = x;
1304 event.y = y;
1305 event.device_kind = kFlutterPointerDeviceKindTouch;
1306 event.device = device;
1307 event.buttons = 0;
1308 event.view_id = view_id;
1309 event.phase = FlutterPointerPhase::kRemove;
1310 event.struct_size = sizeof(event);
1311
1312 if (self->embedder_api.SendPointerEvent(self->engine, &event, 1) !=
1313 kSuccess) {
1314 g_warning("Failed to send pointer event");
1315 }
1316}
@ kRemove
Definition embedder.h:1267

References device, kFlutterPointerDeviceKindTouch, kRemove, kSuccess, self, FlutterPointerEvent::timestamp, view_id, x, and y.

Referenced by fl_touch_manager_handle_touch_event().

◆ fl_engine_send_touch_up_event()

void fl_engine_send_touch_up_event ( FlEngine *  engine,
FlutterViewId  view_id,
size_t  timestamp,
double  x,
double  y,
int32_t  device 
)

fl_engine_send_touch_up_event: @engine: an #FlEngine. @view_id: the view that the event occured on. @timestamp: time when event occurred in microseconds. @x: x location of mouse cursor. @y: y location of mouse cursor. @device: device id.

Sends a touch up event to the engine.

Definition at line 1173 of file fl_engine.cc.

1178 {
1179 g_return_if_fail(FL_IS_ENGINE(self));
1180
1181 if (self->engine == nullptr) {
1182 return;
1183 }
1184
1185 FlutterPointerEvent event;
1186 event.timestamp = timestamp;
1187 event.x = x;
1188 event.y = y;
1189 event.device_kind = kFlutterPointerDeviceKindTouch;
1190 event.device = device;
1191 event.buttons = 0;
1192 event.view_id = view_id;
1193 event.phase = FlutterPointerPhase::kUp;
1194 event.struct_size = sizeof(event);
1195
1196 if (self->embedder_api.SendPointerEvent(self->engine, &event, 1) !=
1197 kSuccess) {
1198 g_warning("Failed to send pointer event");
1199 }
1200}
@ kUp
Definition embedder.h:1245

References device, kFlutterPointerDeviceKindTouch, kSuccess, kUp, self, FlutterPointerEvent::timestamp, view_id, x, and y.

Referenced by fl_touch_manager_handle_touch_event().

◆ fl_engine_send_window_metrics_event()

void fl_engine_send_window_metrics_event ( FlEngine *  engine,
FlutterEngineDisplayId  display_id,
FlutterViewId  view_id,
size_t  width,
size_t  height,
double  pixel_ratio 
)

fl_engine_send_window_metrics_event: @engine: an #FlEngine. @display_id: the display this view is rendering on. @view_id: the view that the event occured on. @width: width of the window in pixels. @height: height of the window in pixels. @pixel_ratio: scale factor for window.

Sends a window metrics event to the engine.

Definition at line 1111 of file fl_engine.cc.

1116 {
1117 g_return_if_fail(FL_IS_ENGINE(self));
1118
1119 if (self->engine == nullptr) {
1120 return;
1121 }
1122
1123 FlutterWindowMetricsEvent event = {};
1124 event.struct_size = sizeof(FlutterWindowMetricsEvent);
1125 event.width = width;
1126 event.height = height;
1127 event.pixel_ratio = pixel_ratio;
1128 event.display_id = display_id;
1129 event.view_id = view_id;
1130 if (self->embedder_api.SendWindowMetricsEvent(self->engine, &event) !=
1131 kSuccess) {
1132 g_warning("Failed to send window metrics");
1133 }
1134}

References height, kSuccess, self, FlutterWindowMetricsEvent::struct_size, view_id, and width.

Referenced by handle_geometry_changed(), and TEST().

◆ fl_engine_set_implicit_view()

void fl_engine_set_implicit_view ( FlEngine *  engine,
FlRenderable *  renderable 
)

fl_engine_set_implicit_view: @engine: an #FlEngine. @renderable: the object that will render the implicit view.

Sets the object to render the implicit view.

Definition at line 885 of file fl_engine.cc.

885 {
886 GWeakRef* ref = g_new(GWeakRef, 1);
887 g_weak_ref_init(ref, G_OBJECT(renderable));
888 g_hash_table_insert(self->renderables_by_view_id,
889 GINT_TO_POINTER(flutter::kFlutterImplicitViewId), ref);
890}
constexpr int64_t kFlutterImplicitViewId
Definition constants.h:35

References g_hash_table_insert(), flutter::kFlutterImplicitViewId, and self.

Referenced by fl_view_new(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), and TEST().

◆ fl_engine_set_platform_message_handler()

void fl_engine_set_platform_message_handler ( FlEngine *  engine,
FlEnginePlatformMessageHandler  handler,
gpointer  user_data,
GDestroyNotify  destroy_notify 
)

fl_engine_set_platform_message_handler: @engine: an #FlEngine. @handler: function to call when a platform message is received. @user_data: (closure): user data to pass to @handler. @destroy_notify: (allow-none): a function which gets called to free @user_data, or NULL.

Registers the function called when a platform message is received. Call fl_engine_send_platform_message_response() with the response to this message. Ownership of FlutterPlatformMessageResponseHandle is transferred to the caller, and the message must be responded to avoid memory leaks.

Definition at line 990 of file fl_engine.cc.

994 {
995 g_return_if_fail(FL_IS_ENGINE(self));
996 g_return_if_fail(handler != nullptr);
997
998 if (self->platform_message_handler_destroy_notify) {
999 self->platform_message_handler_destroy_notify(
1000 self->platform_message_handler_data);
1001 }
1002
1003 self->platform_message_handler = handler;
1004 self->platform_message_handler_data = user_data;
1005 self->platform_message_handler_destroy_notify = destroy_notify;
1006}
const gchar FlBinaryMessengerMessageHandler gpointer GDestroyNotify destroy_notify
const gchar FlBinaryMessengerMessageHandler handler

References destroy_notify, handler, self, and user_data.

Referenced by fl_binary_messenger_new().

◆ fl_engine_set_property()

static void fl_engine_set_property ( GObject *  object,
guint  prop_id,
const GValue *  value,
GParamSpec *  pspec 
)
static

Definition at line 547 of file fl_engine.cc.

550 {
551 FlEngine* self = FL_ENGINE(object);
552 switch (prop_id) {
553 case PROP_BINARY_MESSENGER:
554 g_set_object(&self->binary_messenger,
555 FL_BINARY_MESSENGER(g_value_get_object(value)));
556 break;
557 default:
558 G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
559 break;
560 }
561}
guint const GValue GParamSpec * pspec

References prop_id, pspec, self, and value.

Referenced by fl_engine_class_init().

◆ fl_engine_start()

gboolean fl_engine_start ( FlEngine *  engine,
GError **  error 
)

fl_engine_start: @engine: an #FlEngine. @error: (allow-none): #GError location to store the error occurring, or NULL to ignore.

Starts the Flutter engine.

Returns: TRUE on success.

Definition at line 726 of file fl_engine.cc.

726 {
727 g_return_val_if_fail(FL_IS_ENGINE(self), FALSE);
728
729 FlutterRendererConfig config = {};
730 config.type = self->renderer_type;
731 switch (config.type) {
732 case kSoftware:
734 // No action required, as this is handled in
735 // compositor_present_view_callback.
737 [](void* user_data, const void* allocation, size_t row_bytes,
738 size_t height) { return true; };
739 break;
740 case kOpenGL:
746 // No action required, as this is handled in
747 // compositor_present_view_callback.
748 config.open_gl.present = [](void* user_data) { return true; };
752 break;
753 case kMetal:
754 case kVulkan:
755 default:
757 "Unsupported renderer type");
758 return FALSE;
759 }
760
761 FlutterTaskRunnerDescription platform_task_runner = {};
762 platform_task_runner.struct_size = sizeof(FlutterTaskRunnerDescription);
763 platform_task_runner.user_data = self;
764 platform_task_runner.runs_task_on_current_thread_callback =
766 platform_task_runner.post_task_callback = fl_engine_post_task;
767 platform_task_runner.identifier = kPlatformTaskRunnerIdentifier;
768
769 FlutterCustomTaskRunners custom_task_runners = {};
770 custom_task_runners.struct_size = sizeof(FlutterCustomTaskRunners);
771 custom_task_runners.platform_task_runner = &platform_task_runner;
772
773 switch (fl_dart_project_get_ui_thread_policy(self->project)) {
775 break;
778 custom_task_runners.ui_task_runner = &platform_task_runner;
779 break;
780 }
781
782 g_autoptr(GPtrArray) command_line_args =
783 g_ptr_array_new_with_free_func(g_free);
784 g_ptr_array_insert(command_line_args, 0, g_strdup("flutter"));
785 for (const auto& env_switch : flutter::GetSwitchesFromEnvironment()) {
786 g_ptr_array_add(command_line_args, g_strdup(env_switch.c_str()));
787 }
788
789 gchar** dart_entrypoint_args =
791
794 args.assets_path = fl_dart_project_get_assets_path(self->project);
795 args.icu_data_path = fl_dart_project_get_icu_data_path(self->project);
796 args.command_line_argc = command_line_args->len;
797 args.command_line_argv =
798 reinterpret_cast<const char* const*>(command_line_args->pdata);
799 args.platform_message_callback = fl_engine_platform_message_cb;
800 args.update_semantics_callback2 = fl_engine_update_semantics_cb;
801 args.custom_task_runners = &custom_task_runners;
802 args.shutdown_dart_vm_when_done = true;
803 args.on_pre_engine_restart_callback = fl_engine_on_pre_engine_restart_cb;
804 args.dart_entrypoint_argc =
805 dart_entrypoint_args != nullptr ? g_strv_length(dart_entrypoint_args) : 0;
806 args.dart_entrypoint_argv =
807 reinterpret_cast<const char* const*>(dart_entrypoint_args);
808 args.engine_id = reinterpret_cast<int64_t>(self);
809
810 FlutterCompositor compositor = {};
811 compositor.struct_size = sizeof(FlutterCompositor);
812 compositor.user_data = self;
818 args.compositor = &compositor;
819
820 if (self->embedder_api.RunsAOTCompiledDartCode()) {
821 FlutterEngineAOTDataSource source = {};
824 if (self->embedder_api.CreateAOTData(&source, &self->aot_data) !=
825 kSuccess) {
827 "Failed to create AOT data");
828 return FALSE;
829 }
830 args.aot_data = self->aot_data;
831 }
832
833 FlutterEngineResult result = self->embedder_api.Initialize(
834 FLUTTER_ENGINE_VERSION, &config, &args, self, &self->engine);
835 if (result != kSuccess) {
837 "Failed to initialize Flutter engine");
838 return FALSE;
839 }
840
841 result = self->embedder_api.RunInitialized(self->engine);
842 if (result != kSuccess) {
844 "Failed to run Flutter engine");
845 return FALSE;
846 }
847
849
850 g_autoptr(FlSettings) settings = fl_settings_new();
851 self->settings_handler = fl_settings_handler_new(self);
852 fl_settings_handler_start(self->settings_handler, settings);
853
854 self->platform_handler = fl_platform_handler_new(self->binary_messenger);
855
857
858 result = self->embedder_api.UpdateSemanticsEnabled(self->engine, TRUE);
859 if (result != kSuccess) {
860 g_warning("Failed to enable accessibility features on Flutter engine");
861 }
862
863 fl_display_monitor_start(self->display_monitor);
864
865 return TRUE;
866}
@ kFlutterEngineAOTDataSourceTypeElfPath
Definition embedder.h:2428
@ kVulkan
Definition embedder.h:86
@ kMetal
Definition embedder.h:85
#define FLUTTER_ENGINE_VERSION
Definition embedder.h:70
G_MODULE_EXPORT const gchar * fl_dart_project_get_assets_path(FlDartProject *self)
G_MODULE_EXPORT const gchar * fl_dart_project_get_aot_library_path(FlDartProject *self)
G_MODULE_EXPORT const gchar * fl_dart_project_get_icu_data_path(FlDartProject *self)
G_MODULE_EXPORT gchar ** fl_dart_project_get_dart_entrypoint_arguments(FlDartProject *self)
G_MODULE_EXPORT FlUIThreadPolicy fl_dart_project_get_ui_thread_policy(FlDartProject *project)
@ FL_UI_THREAD_POLICY_RUN_ON_PLATFORM_THREAD
@ FL_UI_THREAD_POLICY_RUN_ON_SEPARATE_THREAD
@ FL_UI_THREAD_POLICY_DEFAULT
void fl_display_monitor_start(FlDisplayMonitor *self)
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:407
static bool fl_engine_runs_task_on_current_thread(void *user_data)
Definition fl_engine.cc:448
static void fl_engine_on_pre_engine_restart_cb(void *user_data)
Definition fl_engine.cc:514
static bool compositor_create_backing_store_callback(const FlutterBackingStoreConfig *config, FlutterBackingStore *backing_store_out, void *user_data)
Definition fl_engine.cc:331
static bool fl_engine_gl_make_current(void *user_data)
Definition fl_engine.cc:386
static void * fl_engine_gl_proc_resolver(void *user_data, const char *name)
Definition fl_engine.cc:382
static bool compositor_present_view_callback(const FlutterPresentViewInfo *info)
Definition fl_engine.cc:362
static bool compositor_collect_backing_store_callback(const FlutterBackingStore *backing_store, void *user_data)
Definition fl_engine.cc:347
static void fl_engine_post_task(FlutterTask task, uint64_t target_time_nanos, void *user_data)
Definition fl_engine.cc:454
static uint32_t fl_engine_gl_get_fbo(void *user_data)
Definition fl_engine.cc:396
static void setup_locales(FlEngine *self)
Definition fl_engine.cc:200
static void fl_engine_update_semantics_cb(const FlutterSemanticsUpdate2 *update, void *user_data)
Definition fl_engine.cc:483
static bool fl_engine_gl_make_resource_current(void *user_data)
Definition fl_engine.cc:401
static void fl_engine_platform_message_cb(const FlutterPlatformMessage *message, void *user_data)
Definition fl_engine.cc:463
static constexpr size_t kPlatformTaskRunnerIdentifier
Definition fl_engine.cc:32
static bool fl_engine_gl_clear_current(void *user_data)
Definition fl_engine.cc:391
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
FlPlatformHandler * fl_platform_handler_new(FlBinaryMessenger *messenger)
FlSettings * fl_settings_new()
void fl_settings_handler_start(FlSettingsHandler *self, FlSettings *settings)
FlSettingsHandler * fl_settings_handler_new(FlEngine *engine)
std::vector< std::string > GetSwitchesFromEnvironment()
FlutterBackingStoreCreateCallback create_backing_store_callback
Definition embedder.h:2213
size_t struct_size
This size of this struct. Must be sizeof(FlutterCompositor).
Definition embedder.h:2197
FlutterPresentViewCallback present_view_callback
Definition embedder.h:2250
FlutterBackingStoreCollectCallback collect_backing_store_callback
Definition embedder.h:2218
const FlutterTaskRunnerDescription * ui_task_runner
Definition embedder.h:1908
const FlutterTaskRunnerDescription * platform_task_runner
Definition embedder.h:1896
size_t struct_size
The size of this struct. Must be sizeof(FlutterCustomTaskRunners).
Definition embedder.h:1891
FlutterEngineAOTDataSourceType type
Definition embedder.h:2434
const char * elf_path
Absolute path to an ELF library file.
Definition embedder.h:2437
ProcResolver gl_proc_resolver
Definition embedder.h:758
size_t struct_size
The size of this struct. Must be sizeof(FlutterOpenGLRendererConfig).
Definition embedder.h:719
TextureFrameCallback gl_external_texture_frame_callback
Definition embedder.h:763
BoolCallback make_resource_current
Definition embedder.h:741
size_t struct_size
The size of this struct. Must be sizeof(FlutterProjectArgs).
Definition embedder.h:2458
FlutterSoftwareRendererConfig software
Definition embedder.h:1034
FlutterOpenGLRendererConfig open_gl
Definition embedder.h:1033
FlutterRendererType type
Definition embedder.h:1031
size_t struct_size
The size of this struct. Must be sizeof(FlutterSoftwareRendererConfig).
Definition embedder.h:1022
SoftwareSurfacePresentCallback surface_present_callback
Definition embedder.h:1027
size_t struct_size
The size of this struct. Must be sizeof(FlutterTaskRunnerDescription).
Definition embedder.h:1864
BoolCallback runs_task_on_current_thread_callback
Definition embedder.h:1870
FlutterTaskRunnerPostTaskCallback post_task_callback
Definition embedder.h:1881

References args, FlutterOpenGLRendererConfig::clear_current, FlutterCompositor::collect_backing_store_callback, compositor_collect_backing_store_callback(), compositor_create_backing_store_callback(), compositor_present_view_callback(), FlutterCompositor::create_backing_store_callback, FlutterEngineAOTDataSource::elf_path, error, FlutterOpenGLRendererConfig::fbo_callback, fl_dart_project_get_aot_library_path(), fl_dart_project_get_assets_path(), fl_dart_project_get_dart_entrypoint_arguments(), fl_dart_project_get_icu_data_path(), fl_dart_project_get_ui_thread_policy(), fl_display_monitor_start(), FL_ENGINE_ERROR_FAILED, fl_engine_error_quark(), fl_engine_gl_clear_current(), fl_engine_gl_external_texture_frame_callback(), fl_engine_gl_get_fbo(), fl_engine_gl_make_current(), fl_engine_gl_make_resource_current(), fl_engine_gl_proc_resolver(), fl_engine_on_pre_engine_restart_cb(), fl_engine_platform_message_cb(), fl_engine_post_task(), fl_engine_runs_task_on_current_thread(), fl_engine_update_semantics_cb(), fl_platform_handler_new(), fl_settings_handler_new(), fl_settings_handler_start(), fl_settings_new(), FL_UI_THREAD_POLICY_DEFAULT, FL_UI_THREAD_POLICY_RUN_ON_PLATFORM_THREAD, FL_UI_THREAD_POLICY_RUN_ON_SEPARATE_THREAD, FLUTTER_ENGINE_VERSION, g_autoptr(), flutter::GetSwitchesFromEnvironment(), FlutterOpenGLRendererConfig::gl_external_texture_frame_callback, FlutterOpenGLRendererConfig::gl_proc_resolver, height, FlutterTaskRunnerDescription::identifier, kFlutterEngineAOTDataSourceTypeElfPath, kMetal, kOpenGL, kPlatformTaskRunnerIdentifier, kSoftware, kSuccess, kVulkan, FlutterOpenGLRendererConfig::make_current, FlutterOpenGLRendererConfig::make_resource_current, FlutterRendererConfig::open_gl, FlutterCustomTaskRunners::platform_task_runner, FlutterTaskRunnerDescription::post_task_callback, FlutterOpenGLRendererConfig::present, FlutterCompositor::present_view_callback, FlutterTaskRunnerDescription::runs_task_on_current_thread_callback, self, setup_keyboard(), setup_locales(), FlutterRendererConfig::software, FlutterOpenGLRendererConfig::struct_size, FlutterSoftwareRendererConfig::struct_size, FlutterTaskRunnerDescription::struct_size, FlutterCustomTaskRunners::struct_size, FlutterCompositor::struct_size, FlutterProjectArgs::struct_size, FlutterSoftwareRendererConfig::surface_present_callback, TRUE, FlutterRendererConfig::type, FlutterEngineAOTDataSource::type, FlutterCustomTaskRunners::ui_task_runner, user_data, FlutterTaskRunnerDescription::user_data, and FlutterCompositor::user_data.

Referenced by realize_cb(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), and TEST().

◆ fl_engine_unregister_external_texture()

gboolean fl_engine_unregister_external_texture ( FlEngine *  engine,
int64_t  texture_id 
)

fl_engine_unregister_external_texture: @engine: an #FlEngine. @texture_id: the identifier of the texture that is not available anymore.

Tells the Flutter engine that an existing external texture is not available anymore.

Returns: TRUE on success.

Definition at line 1444 of file fl_engine.cc.

1445 {
1446 g_return_val_if_fail(FL_IS_ENGINE(self), FALSE);
1447 return self->embedder_api.UnregisterExternalTexture(self->engine,
1448 texture_id) == kSuccess;
1449}

References kSuccess, self, and texture_id.

Referenced by unregister_texture().

◆ fl_engine_update_accessibility_features()

void fl_engine_update_accessibility_features ( FlEngine *  engine,
int32_t  flags 
)

fl_engine_update_accessibility_features: @engine: an #FlEngine. @flags: the features to enable in the accessibility tree.

Tells the Flutter engine to update the flags on the accessibility tree.

Definition at line 1475 of file fl_engine.cc.

1475 {
1476 g_return_if_fail(FL_IS_ENGINE(self));
1477
1478 if (self->engine == nullptr) {
1479 return;
1480 }
1481
1482 if (self->embedder_api.UpdateAccessibilityFeatures(
1483 self->engine, static_cast<FlutterAccessibilityFeature>(flags)) !=
1484 kSuccess) {
1485 g_warning("Failed to update accessibility features");
1486 }
1487}
FlutterAccessibilityFeature
Definition embedder.h:91

References kSuccess, and self.

Referenced by update_settings().

◆ fl_engine_update_semantics_cb()

static void fl_engine_update_semantics_cb ( const FlutterSemanticsUpdate2 update,
void *  user_data 
)
static

Definition at line 483 of file fl_engine.cc.

484 {
485 FlEngine* self = FL_ENGINE(user_data);
486
488}

References fl_engine_signals, g_signal_emit(), self, SIGNAL_UPDATE_SEMANTICS, and user_data.

Referenced by fl_engine_start().

◆ free_locale()

static void free_locale ( FlutterLocale locale)
static

Definition at line 193 of file fl_engine.cc.

193 {
194 free(const_cast<gchar*>(locale->language_code));
195 free(const_cast<gchar*>(locale->country_code));
196 free(locale);
197}
const char * language_code
Definition embedder.h:2259
const char * country_code
Definition embedder.h:2264

References FlutterLocale::country_code, and FlutterLocale::language_code.

Referenced by setup_locales().

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

Definition at line 118 of file fl_engine.cc.

125 { PROP_0, PROP_BINARY_MESSENGER, PROP_LAST };
@ PROP_LAST

References PROP_0, and PROP_LAST.

◆ parse_locale()

static void parse_locale ( const gchar *  locale,
gchar **  language,
gchar **  territory,
gchar **  codeset,
gchar **  modifier 
)
static

Definition at line 128 of file fl_engine.cc.

132 {
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}

Referenced by setup_locales().

◆ send_key_event_cb()

static void send_key_event_cb ( bool  handled,
void *  user_data 
)
static

Definition at line 1353 of file fl_engine.cc.

1353 {
1354 g_autoptr(GTask) task = G_TASK(user_data);
1355 gboolean* return_value = g_new0(gboolean, 1);
1356 *return_value = handled;
1357 g_task_return_pointer(task, return_value, g_free);
1358}

References g_autoptr(), and user_data.

Referenced by fl_engine_send_key_event().

◆ setup_keyboard()

static void setup_keyboard ( FlEngine *  self)
static

Definition at line 490 of file fl_engine.cc.

490 {
491 g_clear_object(&self->keyboard_manager);
492 self->keyboard_manager = fl_keyboard_manager_new(self);
493
494 g_clear_object(&self->keyboard_handler);
495 self->keyboard_handler =
496 fl_keyboard_handler_new(self->binary_messenger, self->keyboard_manager);
497
498 GtkWidget* widget =
499 self->text_input_handler != nullptr
500 ? fl_text_input_handler_get_widget(self->text_input_handler)
501 : nullptr;
502 g_clear_object(&self->text_input_handler);
503 self->text_input_handler = fl_text_input_handler_new(self->binary_messenger);
504 if (widget != nullptr) {
505 fl_text_input_handler_set_widget(self->text_input_handler, widget);
506 }
507}
FlKeyboardHandler * fl_keyboard_handler_new(FlBinaryMessenger *messenger, FlKeyboardManager *keyboard_manager)
FlTextInputHandler * fl_text_input_handler_new(FlBinaryMessenger *messenger)
void fl_text_input_handler_set_widget(FlTextInputHandler *self, GtkWidget *widget)
GtkWidget * fl_text_input_handler_get_widget(FlTextInputHandler *self)

References fl_keyboard_handler_new(), fl_keyboard_manager_new(), fl_text_input_handler_get_widget(), fl_text_input_handler_new(), fl_text_input_handler_set_widget(), and self.

Referenced by fl_engine_on_pre_engine_restart_cb(), and fl_engine_start().

◆ setup_locales()

static void setup_locales ( FlEngine *  self)
static

Definition at line 200 of file fl_engine.cc.

200 {
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}
static void parse_locale(const gchar *locale, gchar **language, gchar **territory, gchar **codeset, gchar **modifier)
Definition fl_engine.cc:128
static void free_locale(FlutterLocale *locale)
Definition fl_engine.cc:193
size_t struct_size
This size of this struct. Must be sizeof(FlutterLocale).
Definition embedder.h:2255
const char * script_code
Definition embedder.h:2269
const char * variant_code
Definition embedder.h:2274

References FlutterLocale::country_code, free_locale(), g_autoptr(), i, kSuccess, FlutterLocale::language_code, parse_locale(), FlutterLocale::script_code, self, FlutterLocale::struct_size, and FlutterLocale::variant_code.

Referenced by fl_engine_start().

◆ view_added_cb()

static void view_added_cb ( const FlutterAddViewResult result)
static

Definition at line 171 of file fl_engine.cc.

171 {
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}
void * user_data
The |FlutterAddViewInfo.user_data|.
Definition embedder.h:1081
bool added
True if the add view operation succeeded.
Definition embedder.h:1078

References FlutterAddViewResult::added, FL_ENGINE_ERROR_FAILED, fl_engine_error_quark(), g_autoptr(), TRUE, and FlutterAddViewResult::user_data.

Referenced by fl_engine_add_view().

◆ view_removed_cb()

static void view_removed_cb ( const FlutterRemoveViewResult result)
static

Definition at line 182 of file fl_engine.cc.

182 {
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}
void * user_data
The |FlutterRemoveViewInfo.user_data|.
Definition embedder.h:1129
bool removed
True if the remove view operation succeeded.
Definition embedder.h:1126

References FL_ENGINE_ERROR_FAILED, fl_engine_error_quark(), g_autoptr(), FlutterRemoveViewResult::removed, TRUE, and FlutterRemoveViewResult::user_data.

Referenced by fl_engine_remove_view().

Variable Documentation

◆ fl_engine_signals

guint fl_engine_signals[LAST_SIGNAL]
static

◆ kMousePointerDeviceId

constexpr int32_t kMousePointerDeviceId = 0
staticconstexpr

Definition at line 36 of file fl_engine.cc.

Referenced by fl_engine_send_mouse_pointer_event().

◆ kPlatformTaskRunnerIdentifier

constexpr size_t kPlatformTaskRunnerIdentifier = 1
staticconstexpr

Definition at line 32 of file fl_engine.cc.

Referenced by fl_engine_start().

◆ kPointerPanZoomDeviceId

constexpr int32_t kPointerPanZoomDeviceId = 1
staticconstexpr

Definition at line 37 of file fl_engine.cc.

Referenced by fl_engine_send_pointer_pan_zoom_event().