Flutter Engine Uber Docs
Docs for the entire Flutter Engine repo.
 
Loading...
Searching...
No Matches
fl_dart_project.cc File Reference

Go to the source code of this file.

Classes

struct  _FlDartProject
 

Functions

static gchar * get_executable_dir ()
 
static void fl_dart_project_dispose (GObject *object)
 
static void fl_dart_project_class_init (FlDartProjectClass *klass)
 
static void fl_dart_project_init (FlDartProject *self)
 
G_MODULE_EXPORT FlDartProject * fl_dart_project_new ()
 
G_MODULE_EXPORT void fl_dart_project_set_aot_library_path (FlDartProject *self, const gchar *path)
 
G_MODULE_EXPORT const gchar * fl_dart_project_get_aot_library_path (FlDartProject *self)
 
G_MODULE_EXPORT void fl_dart_project_set_assets_path (FlDartProject *self, gchar *path)
 
G_MODULE_EXPORT const gchar * fl_dart_project_get_assets_path (FlDartProject *self)
 
G_MODULE_EXPORT void fl_dart_project_set_icu_data_path (FlDartProject *self, gchar *path)
 
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 void fl_dart_project_set_dart_entrypoint_arguments (FlDartProject *self, char **argv)
 
G_MODULE_EXPORT void fl_dart_project_set_ui_thread_policy (FlDartProject *project, FlUIThreadPolicy policy)
 
G_MODULE_EXPORT FlUIThreadPolicy fl_dart_project_get_ui_thread_policy (FlDartProject *project)
 
G_MODULE_EXPORT void fl_dart_project_set_enable_impeller (FlDartProject *project, gboolean enable_impeller)
 
G_MODULE_EXPORT gboolean fl_dart_project_get_enable_impeller (FlDartProject *project)
 

Function Documentation

◆ fl_dart_project_class_init()

static void fl_dart_project_class_init ( FlDartProjectClass *  klass)
static

Definition at line 47 of file fl_dart_project.cc.

47 {
48 G_OBJECT_CLASS(klass)->dispose = fl_dart_project_dispose;
49}
static void fl_dart_project_dispose(GObject *object)

References fl_dart_project_dispose().

◆ fl_dart_project_dispose()

static void fl_dart_project_dispose ( GObject *  object)
static

Definition at line 36 of file fl_dart_project.cc.

36 {
37 FlDartProject* self = FL_DART_PROJECT(object);
38
39 g_clear_pointer(&self->aot_library_path, g_free);
40 g_clear_pointer(&self->assets_path, g_free);
41 g_clear_pointer(&self->icu_data_path, g_free);
42 g_clear_pointer(&self->dart_entrypoint_args, g_strfreev);
43
44 G_OBJECT_CLASS(fl_dart_project_parent_class)->dispose(object);
45}

References self.

Referenced by fl_dart_project_class_init().

◆ fl_dart_project_get_aot_library_path()

G_MODULE_EXPORT const gchar * fl_dart_project_get_aot_library_path ( FlDartProject *  project)

fl_dart_project_get_aot_library_path: @project: an #FlDartProject.

Gets the path to the AOT library in the Flutter application.

Returns: (type filename): an absolute file path, e.g. "/projects/my_dart_project/lib/libapp.so".

Definition at line 76 of file fl_dart_project.cc.

77 {
78 g_return_val_if_fail(FL_IS_DART_PROJECT(self), nullptr);
79 return self->aot_library_path;
80}

References self.

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

◆ fl_dart_project_get_assets_path()

G_MODULE_EXPORT const gchar * fl_dart_project_get_assets_path ( FlDartProject *  project)

fl_dart_project_get_assets_path: @project: an #FlDartProject.

Gets the path to the directory containing the assets used in the Flutter application.

Returns: (type filename): an absolute directory path, e.g. "/projects/my_dart_project/data/flutter_assets".

Definition at line 89 of file fl_dart_project.cc.

90 {
91 g_return_val_if_fail(FL_IS_DART_PROJECT(self), nullptr);
92 return self->assets_path;
93}

References self.

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

◆ fl_dart_project_get_dart_entrypoint_arguments()

G_MODULE_EXPORT gchar ** fl_dart_project_get_dart_entrypoint_arguments ( FlDartProject *  project)

fl_dart_project_get_dart_entrypoint_arguments: @project: an #FlDartProject.

Gets the command line arguments to be passed through to the Dart entrypoint function.

Returns: a NULL-terminated array of strings containing the command line arguments to be passed to the Dart entrypoint.

Definition at line 108 of file fl_dart_project.cc.

109 {
110 g_return_val_if_fail(FL_IS_DART_PROJECT(self), nullptr);
111 return self->dart_entrypoint_args;
112}

References self.

Referenced by fl_engine_start(), and TEST().

◆ fl_dart_project_get_enable_impeller()

G_MODULE_EXPORT gboolean fl_dart_project_get_enable_impeller ( FlDartProject *  project)

fl_dart_project_get_enable_impeller: @project: an #FlDartProject.

Returns: TRUE if the Impeller renderer is enabled.

Definition at line 144 of file fl_dart_project.cc.

144 {
145 g_return_val_if_fail(FL_IS_DART_PROJECT(project), FALSE);
146 return project->enable_impeller;
147}

Referenced by fl_engine_start(), and TEST().

◆ fl_dart_project_get_icu_data_path()

G_MODULE_EXPORT const gchar * fl_dart_project_get_icu_data_path ( FlDartProject *  project)

fl_dart_project_get_icu_data_path: @project: an #FlDartProject.

Gets the path to the ICU data file in the Flutter application.

Returns: (type filename): an absolute file path, e.g. "/projects/my_dart_project/data/icudtl.dat".

Definition at line 102 of file fl_dart_project.cc.

103 {
104 g_return_val_if_fail(FL_IS_DART_PROJECT(self), nullptr);
105 return self->icu_data_path;
106}

References self.

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

◆ fl_dart_project_get_ui_thread_policy()

G_MODULE_EXPORT FlUIThreadPolicy fl_dart_project_get_ui_thread_policy ( FlDartProject *  project)

fl_dart_project_get_ui_thread_policy: @project: an #FlDartProject.

Returns: the thread policy used for running the UI isolate.

Definition at line 130 of file fl_dart_project.cc.

130 {
131 g_return_val_if_fail(FL_IS_DART_PROJECT(project),
133 return project->ui_thread_policy;
134}
@ FL_UI_THREAD_POLICY_DEFAULT

References FL_UI_THREAD_POLICY_DEFAULT.

Referenced by fl_engine_start().

◆ fl_dart_project_init()

static void fl_dart_project_init ( FlDartProject *  self)
static

Definition at line 51 of file fl_dart_project.cc.

51{}

◆ fl_dart_project_new()

G_MODULE_EXPORT FlDartProject * fl_dart_project_new ( )

FlDartProject:

#FlDartProject represents a Dart project. It is used to provide information about the application when creating an #FlView. fl_dart_project_new:

Creates a Flutter project for the currently running executable. The following data files are required relative to the location of the executable:

  • data/flutter_assets/ (as built by the Flutter tool).
  • data/icudtl.dat (provided as a resource by the Flutter tool).
  • lib/libapp.so (as built by the Flutter tool when in AOT mode).

Returns: a new #FlDartProject.

Definition at line 53 of file fl_dart_project.cc.

53 {
54 FlDartProject* self =
55 FL_DART_PROJECT(g_object_new(fl_dart_project_get_type(), nullptr));
56
57 g_autofree gchar* executable_dir = get_executable_dir();
58 self->aot_library_path =
59 g_build_filename(executable_dir, "lib", "libapp.so", nullptr);
60 self->assets_path =
61 g_build_filename(executable_dir, "data", "flutter_assets", nullptr);
62 self->icu_data_path =
63 g_build_filename(executable_dir, "data", "icudtl.dat", nullptr);
64 self->enable_impeller = FALSE;
65
66 return self;
67}
static gchar * get_executable_dir()

References get_executable_dir(), and self.

Referenced by fl_application_activate(), fl_engine_new_with_binary_messenger(), 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(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), and TEST().

◆ fl_dart_project_set_aot_library_path()

G_MODULE_EXPORT void fl_dart_project_set_aot_library_path ( FlDartProject *  project,
const gchar *  path 
)

fl_dart_project_set_aot_library_path: @project: an #FlDartProject. @path: the absolute path to the AOT library in the Flutter application.

Sets the path to the AOT library in the Flutter application, which is the path to libapp.so. By default this is lib/libapp.so relative to the executable directory.

Definition at line 69 of file fl_dart_project.cc.

70 {
71 g_return_if_fail(FL_IS_DART_PROJECT(self));
72 g_clear_pointer(&self->aot_library_path, g_free);
73 self->aot_library_path = g_strdup(path);
74}

References self.

Referenced by TEST().

◆ fl_dart_project_set_assets_path()

G_MODULE_EXPORT void fl_dart_project_set_assets_path ( FlDartProject *  project,
gchar *  path 
)

fl_dart_project_set_assets_path: @project: an #FlDartProject. @path: the absolute path to the assets directory.

Sets the path to the directory containing the assets used in the Flutter application. By default, this is the data/flutter_assets subdirectory relative to the executable directory.

Definition at line 82 of file fl_dart_project.cc.

83 {
84 g_return_if_fail(FL_IS_DART_PROJECT(self));
85 g_clear_pointer(&self->assets_path, g_free);
86 self->assets_path = g_strdup(path);
87}

References self.

Referenced by TEST().

◆ fl_dart_project_set_dart_entrypoint_arguments()

G_MODULE_EXPORT void fl_dart_project_set_dart_entrypoint_arguments ( FlDartProject *  project,
char **  argv 
)

fl_dart_project_set_dart_entrypoint_arguments: @project: an #FlDartProject. @argv: a pointer to a NULL-terminated array of C strings containing the command line arguments.

Sets the command line arguments to be passed through to the Dart entrypoint function.

Definition at line 114 of file fl_dart_project.cc.

116 {
117 g_return_if_fail(FL_IS_DART_PROJECT(self));
118 g_clear_pointer(&self->dart_entrypoint_args, g_strfreev);
119 self->dart_entrypoint_args = g_strdupv(argv);
120}
char ** argv
Definition library.h:9

References argv, and self.

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

◆ fl_dart_project_set_enable_impeller()

G_MODULE_EXPORT void fl_dart_project_set_enable_impeller ( FlDartProject *  project,
gboolean  enable_impeller 
)

fl_dart_project_set_enable_impeller: @project: an #FlDartProject. @enable_impeller: whether to enable the Impeller renderer.

Sets whether the Impeller renderer should be enabled.

Definition at line 137 of file fl_dart_project.cc.

138 {
139 g_return_if_fail(FL_IS_DART_PROJECT(project));
140 project->enable_impeller = enable_impeller;
141}

Referenced by TEST(), and TEST().

◆ fl_dart_project_set_icu_data_path()

G_MODULE_EXPORT void fl_dart_project_set_icu_data_path ( FlDartProject *  project,
gchar *  path 
)

fl_dart_project_set_icu_data_path: @project: an #FlDartProject. @path: the absolute path to the ICU data file.

Sets the path to the ICU data file used in the Flutter application. By default, this is data/icudtl.dat relative to the executable directory.

Definition at line 95 of file fl_dart_project.cc.

96 {
97 g_return_if_fail(FL_IS_DART_PROJECT(self));
98 g_clear_pointer(&self->icu_data_path, g_free);
99 self->icu_data_path = g_strdup(path);
100}

References self.

Referenced by TEST().

◆ fl_dart_project_set_ui_thread_policy()

G_MODULE_EXPORT void fl_dart_project_set_ui_thread_policy ( FlDartProject *  project,
FlUIThreadPolicy  policy 
)

fl_dart_project_set_ui_thread_policy: @project: an #FlDartProject. @policy: the thread policy to use for running the UI isolate.

Definition at line 123 of file fl_dart_project.cc.

124 {
125 g_return_if_fail(FL_IS_DART_PROJECT(project));
126 project->ui_thread_policy = policy;
127}
it will be possible to load the file into Perfetto s trace viewer use test Running tests that layout and measure text will not yield consistent results across various platforms Enabling this option will make font resolution default to the Ahem test font on all disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network policy

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

◆ get_executable_dir()

static gchar * get_executable_dir ( )
static

Definition at line 24 of file fl_dart_project.cc.

24 {
25 g_autoptr(GError) error = nullptr;
26 g_autofree gchar* exe_path = g_file_read_link("/proc/self/exe", &error);
27 if (exe_path == nullptr) {
28 g_critical("Failed to determine location of executable: %s",
29 error->message);
30 return nullptr;
31 }
32
33 return g_path_get_dirname(exe_path);
34}
g_autoptr(FlEngine) engine
const uint8_t uint32_t uint32_t GError ** error

References error, and g_autoptr().

Referenced by fl_dart_project_new().