Flutter Windows Embedder
flutter::FlutterProjectBundle Class Reference

#include <flutter_project_bundle.h>

Public Member Functions

 FlutterProjectBundle (const FlutterDesktopEngineProperties &properties)
 
 ~FlutterProjectBundle ()
 
bool HasValidPaths ()
 
const std::filesystem::path & assets_path ()
 
const std::filesystem::path & icu_path ()
 
const std::vector< std::string > GetSwitches ()
 
void SetSwitches (const std::vector< std::string > &switches)
 
UniqueAotDataPtr LoadAotData (const FlutterEngineProcTable &engine_procs)
 
const std::string & dart_entrypoint () const
 
const std::vector< std::string > & dart_entrypoint_arguments () const
 
FlutterGpuPreference gpu_preference () const
 
FlutterUIThreadPolicy ui_thread_policy ()
 
FlutterAccessibilityMode accessibility_mode () const
 
FlutterImpellerSwitch impeller_switch () const
 
bool enable_flutter_gpu () const
 

Detailed Description

Definition at line 45 of file flutter_project_bundle.h.

Constructor & Destructor Documentation

◆ FlutterProjectBundle()

flutter::FlutterProjectBundle::FlutterProjectBundle ( const FlutterDesktopEngineProperties properties)
explicit

Definition at line 16 of file flutter_project_bundle.cc.

18  : assets_path_(properties.assets_path),
19  icu_path_(properties.icu_data_path) {
20  if (properties.aot_library_path != nullptr) {
21  aot_library_path_ = std::filesystem::path(properties.aot_library_path);
22  }
23 
24  if (properties.dart_entrypoint && properties.dart_entrypoint[0] != '\0') {
25  dart_entrypoint_ = properties.dart_entrypoint;
26  }
27 
28  for (int i = 0; i < properties.dart_entrypoint_argc; i++) {
29  dart_entrypoint_arguments_.push_back(
30  std::string(properties.dart_entrypoint_argv[i]));
31  }
32 
33  gpu_preference_ =
34  static_cast<FlutterGpuPreference>(properties.gpu_preference);
35 
36  ui_thread_policy_ =
37  static_cast<FlutterUIThreadPolicy>(properties.ui_thread_policy);
38 
39  accessibility_mode_ =
40  static_cast<FlutterAccessibilityMode>(properties.accessibility_mode);
41 
42  impeller_switch_ =
43  static_cast<FlutterImpellerSwitch>(properties.impeller_switch);
44 
45  enable_flutter_gpu_ = properties.enable_flutter_gpu;
46 
47  // Resolve any relative paths.
48  if (assets_path_.is_relative() || icu_path_.is_relative() ||
49  (!aot_library_path_.empty() && aot_library_path_.is_relative())) {
50  std::filesystem::path executable_location = GetExecutableDirectory();
51  if (executable_location.empty()) {
52  FML_LOG(ERROR)
53  << "Unable to find executable location to resolve resource paths.";
54  assets_path_ = std::filesystem::path();
55  icu_path_ = std::filesystem::path();
56  } else {
57  assets_path_ = std::filesystem::path(executable_location) / assets_path_;
58  icu_path_ = std::filesystem::path(executable_location) / icu_path_;
59  if (!aot_library_path_.empty()) {
60  aot_library_path_ =
61  std::filesystem::path(executable_location) / aot_library_path_;
62  }
63  }
64  }
65 }
std::filesystem::path GetExecutableDirectory()
Definition: path_utils.cc:16
FlutterDesktopAccessibilityMode accessibility_mode
FlutterDesktopImpellerSwitch impeller_switch
FlutterDesktopUIThreadPolicy ui_thread_policy
FlutterDesktopGpuPreference gpu_preference

References FlutterDesktopEngineProperties::accessibility_mode, FlutterDesktopEngineProperties::aot_library_path, FlutterDesktopEngineProperties::dart_entrypoint, FlutterDesktopEngineProperties::dart_entrypoint_argc, FlutterDesktopEngineProperties::dart_entrypoint_argv, FlutterDesktopEngineProperties::enable_flutter_gpu, flutter::GetExecutableDirectory(), FlutterDesktopEngineProperties::gpu_preference, FlutterDesktopEngineProperties::impeller_switch, and FlutterDesktopEngineProperties::ui_thread_policy.

◆ ~FlutterProjectBundle()

flutter::FlutterProjectBundle::~FlutterProjectBundle ( )

Definition at line 98 of file flutter_project_bundle.cc.

98 {}

Member Function Documentation

◆ accessibility_mode()

FlutterAccessibilityMode flutter::FlutterProjectBundle::accessibility_mode ( ) const
inline

Definition at line 93 of file flutter_project_bundle.h.

93  {
94  return accessibility_mode_;
95  }

◆ assets_path()

const std::filesystem::path& flutter::FlutterProjectBundle::assets_path ( )
inline

Definition at line 60 of file flutter_project_bundle.h.

60 { return assets_path_; }

Referenced by flutter::testing::TEST().

◆ dart_entrypoint()

const std::string& flutter::FlutterProjectBundle::dart_entrypoint ( ) const
inline

Definition at line 78 of file flutter_project_bundle.h.

78 { return dart_entrypoint_; }

◆ dart_entrypoint_arguments()

const std::vector<std::string>& flutter::FlutterProjectBundle::dart_entrypoint_arguments ( ) const
inline

Definition at line 82 of file flutter_project_bundle.h.

82  {
83  return dart_entrypoint_arguments_;
84  }

Referenced by flutter::testing::TEST().

◆ enable_flutter_gpu()

bool flutter::FlutterProjectBundle::enable_flutter_gpu ( ) const
inline

Definition at line 101 of file flutter_project_bundle.h.

101 { return enable_flutter_gpu_; }

Referenced by flutter::testing::TEST().

◆ GetSwitches()

const std::vector< std::string > flutter::FlutterProjectBundle::GetSwitches ( )

Definition at line 105 of file flutter_project_bundle.cc.

105  {
106  if (engine_switches_.size() == 0) {
108  }
109  std::vector<std::string> switches;
110  switches.insert(switches.end(), engine_switches_.begin(),
111  engine_switches_.end());
112 
113  auto env_switches = GetSwitchesFromEnvironment();
114  switches.insert(switches.end(), env_switches.begin(), env_switches.end());
115 
116  return switches;
117 }
std::vector< std::string > GetSwitchesFromEnvironment()

References flutter::GetSwitchesFromEnvironment().

Referenced by flutter::testing::TEST().

◆ gpu_preference()

FlutterGpuPreference flutter::FlutterProjectBundle::gpu_preference ( ) const
inline

Definition at line 87 of file flutter_project_bundle.h.

87 { return gpu_preference_; }

◆ HasValidPaths()

bool flutter::FlutterProjectBundle::HasValidPaths ( )

Definition at line 67 of file flutter_project_bundle.cc.

67  {
68  return !assets_path_.empty() && !icu_path_.empty();
69 }

Referenced by flutter::testing::TEST().

◆ icu_path()

const std::filesystem::path& flutter::FlutterProjectBundle::icu_path ( )
inline

Definition at line 63 of file flutter_project_bundle.h.

63 { return icu_path_; }

Referenced by flutter::testing::TEST().

◆ impeller_switch()

FlutterImpellerSwitch flutter::FlutterProjectBundle::impeller_switch ( ) const
inline

Definition at line 98 of file flutter_project_bundle.h.

98 { return impeller_switch_; }

◆ LoadAotData()

UniqueAotDataPtr flutter::FlutterProjectBundle::LoadAotData ( const FlutterEngineProcTable &  engine_procs)

Definition at line 73 of file flutter_project_bundle.cc.

74  {
75  if (aot_library_path_.empty()) {
76  FML_LOG(ERROR)
77  << "Attempted to load AOT data, but no aot_library_path was provided.";
78  return UniqueAotDataPtr(nullptr, nullptr);
79  }
80  if (!std::filesystem::exists(aot_library_path_)) {
81  FML_LOG(ERROR) << "Can't load AOT data from " << aot_library_path_
82  << "; no such file.";
83  return UniqueAotDataPtr(nullptr, nullptr);
84  }
85  std::string path_string = fml::PathToUtf8(aot_library_path_);
86  FlutterEngineAOTDataSource source = {};
87  source.type = kFlutterEngineAOTDataSourceTypeElfPath;
88  source.elf_path = path_string.c_str();
89  FlutterEngineAOTData data = nullptr;
90  auto result = engine_procs.CreateAOTData(&source, &data);
91  if (result != kSuccess) {
92  FML_LOG(ERROR) << "Failed to load AOT data from: " << path_string;
93  return UniqueAotDataPtr(nullptr, nullptr);
94  }
95  return UniqueAotDataPtr(data, engine_procs.CollectAOTData);
96 }
std::unique_ptr< _FlutterEngineAOTData, FlutterEngineCollectAOTDataFnPtr > UniqueAotDataPtr

◆ SetSwitches()

void flutter::FlutterProjectBundle::SetSwitches ( const std::vector< std::string > &  switches)

Definition at line 100 of file flutter_project_bundle.cc.

101  {
102  engine_switches_ = switches;
103 }

◆ ui_thread_policy()

FlutterUIThreadPolicy flutter::FlutterProjectBundle::ui_thread_policy ( )
inline

Definition at line 90 of file flutter_project_bundle.h.

90 { return ui_thread_policy_; }

The documentation for this class was generated from the following files: