243 {
244 if (!project_->HasValidPaths()) {
245 FML_LOG(
ERROR) <<
"Missing or unresolvable paths to assets.";
246 return false;
247 }
248 std::string assets_path_string = project_->assets_path().u8string();
249 std::string icu_path_string = project_->icu_path().u8string();
251 aot_data_ = project_->LoadAotData(embedder_api_);
252 if (!aot_data_) {
253 FML_LOG(
ERROR) <<
"Unable to start engine without AOT data.";
254 return false;
255 }
256 }
257
258
259
260
262 std::vector<const char*>
argv = {executable_name.c_str()};
263 std::vector<std::string> switches = project_->GetSwitches();
265 switches.begin(), switches.end(), std::back_inserter(
argv),
266 [](const std::string& arg) -> const char* { return arg.c_str(); });
267
268 const std::vector<std::string>& entrypoint_args =
269 project_->dart_entrypoint_arguments();
270 std::vector<const char*> entrypoint_argv;
272 entrypoint_args.begin(), entrypoint_args.end(),
273 std::back_inserter(entrypoint_argv),
274 [](const std::string& arg) -> const char* { return arg.c_str(); });
275
276
279 platform_task_runner.
user_data = task_runner_.get();
282 return static_cast<TaskRunner*
>(
user_data)->RunsTasksOnCurrentThread();
283 };
285 uint64_t target_time_nanos,
287 static_cast<TaskRunner*
>(
user_data)->PostFlutterTask(task,
288 target_time_nanos);
289 };
295
298 args.shutdown_dart_vm_when_done =
true;
299 args.assets_path = assets_path_string.c_str();
300 args.icu_data_path = icu_path_string.c_str();
301 args.command_line_argc =
static_cast<int>(
argv.size());
302 args.command_line_argv =
argv.empty() ? nullptr :
argv.data();
303
304
305
306
307
308
309
310 if (!project_->dart_entrypoint().empty() && !entrypoint.empty() &&
311 project_->dart_entrypoint() != entrypoint) {
312 FML_LOG(
ERROR) <<
"Conflicting entrypoints were specified in "
313 "FlutterDesktopEngineProperties.dart_entrypoint and "
314 "FlutterDesktopEngineRun(engine, entry_point). ";
315 return false;
316 }
317 if (!entrypoint.empty()) {
318 args.custom_dart_entrypoint = entrypoint.data();
319 } else if (!project_->dart_entrypoint().empty()) {
320 args.custom_dart_entrypoint = project_->dart_entrypoint().c_str();
321 }
322 args.dart_entrypoint_argc =
static_cast<int>(entrypoint_argv.size());
323 args.dart_entrypoint_argv =
324 entrypoint_argv.empty() ? nullptr : entrypoint_argv.data();
325 args.platform_message_callback =
329 return host->HandlePlatformMessage(engine_message);
330 };
331 args.vsync_callback = [](
void*
user_data, intptr_t baton) ->
void {
333 host->OnVsync(baton);
334 };
337 host->OnPreEngineRestart();
338 };
342
343
344
347 return;
348 }
349
351 if (!accessibility_bridge) {
352 return;
353 }
354
355 for (
size_t i = 0;
i <
update->node_count;
i++) {
357 accessibility_bridge->AddFlutterSemanticsNodeUpdate(*node);
358 }
359
360 for (
size_t i = 0;
i <
update->custom_action_count;
i++) {
362 accessibility_bridge->AddFlutterSemanticsCustomActionUpdate(*
action);
363 }
364
365 accessibility_bridge->CommitUpdates();
366 };
369 if (
host->root_isolate_create_callback_) {
370 host->root_isolate_create_callback_();
371 }
372 };
377 std::string channel_name(
update->channel);
378 host->OnChannelUpdate(std::move(channel_name),
380 }
381 };
382
383 args.custom_task_runners = &custom_task_runners;
384
385 if (!platform_view_plugin_) {
386 platform_view_plugin_ = std::make_unique<PlatformViewPlugin>(
387 messenger_wrapper_.get(), task_runner_.get());
388 }
389 if (egl_manager_) {
390 auto resolver = [](
const char*
name) ->
void* {
391 return reinterpret_cast<void*
>(::eglGetProcAddress(
name));
392 };
393
394
395
396 compositor_ = std::make_unique<CompositorOpenGL>(this, resolver);
397 } else {
398 compositor_ = std::make_unique<CompositorSoftware>();
399 }
400
408
409 return host->compositor_->CreateBackingStore(*config, backing_store_out);
410 };
411
415
416 return host->compositor_->CollectBackingStore(backing_store);
417 };
418
422
424 };
425 args.compositor = &compositor;
426
427 if (aot_data_) {
428 args.aot_data = aot_data_.get();
429 }
430
431
432
433 FML_DCHECK(!egl_manager_ || !egl_manager_->HasContextCurrent());
434
436
437 if (enable_impeller_) {
438
439
440 if (!egl_manager_) {
441 FML_LOG(
ERROR) <<
"Could not create surface manager. Impeller backend "
442 "does not support software rendering.";
443 return false;
444 }
445 renderer_config = GetOpenGLRendererConfig();
446 } else {
447 renderer_config =
448 egl_manager_ ? GetOpenGLRendererConfig() : GetSoftwareRendererConfig();
449 }
450
452 &
args,
this, &engine_);
453 if (
result != kSuccess || engine_ ==
nullptr) {
455 return false;
456 }
457
458
464 1.0 / (static_cast<double>(FrameInterval().count()) / 1000000000.0);
465
466 std::vector<FlutterEngineDisplay> displays = {display};
469 displays.data(), displays.size());
470
471 SendSystemLocales();
473
474 settings_plugin_->StartWatching();
475 settings_plugin_->SendSettings();
476
477 InitializeKeyboard();
478
479 return true;
480}
std::string GetExecutableName() const
std::weak_ptr< AccessibilityBridgeWindows > accessibility_bridge()
@ kFlutterEngineDisplaysUpdateTypeStartup
#define FLUTTER_ENGINE_VERSION
#define SAFE_ACCESS(pointer, member, default_value)
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service host
static void WindowsPlatformThreadPrioritySetter(FlutterThreadPriority priority)
static SkColor4f transform(SkColor4f c, SkColorSpace *src, SkColorSpace *dst)
An update to whether a message channel has a listener set or not.
FlutterBackingStoreCreateCallback create_backing_store_callback
size_t struct_size
This size of this struct. Must be sizeof(FlutterCompositor).
FlutterPresentViewCallback present_view_callback
FlutterBackingStoreCollectCallback collect_backing_store_callback
void(* thread_priority_setter)(FlutterThreadPriority)
const FlutterTaskRunnerDescription * platform_task_runner
size_t struct_size
The size of this struct. Must be sizeof(FlutterCustomTaskRunners).
size_t struct_size
This size of this struct. Must be sizeof(FlutterDisplay).
FlutterEngineDisplayId display_id
FlutterEngineRunsAOTCompiledDartCodeFnPtr RunsAOTCompiledDartCode
FlutterEngineNotifyDisplayUpdateFnPtr NotifyDisplayUpdate
FlutterEngineRunFnPtr Run
A batch of updates to semantics nodes and custom actions.
size_t struct_size
The size of this struct. Must be sizeof(FlutterTaskRunnerDescription).
BoolCallback runs_task_on_current_thread_callback
FlutterTaskRunnerPostTaskCallback post_task_callback