| Flutter Windows Embedder |

flutter_project_bundle.h
Go to the documentation of this file.
1 // Copyright 2013 The Flutter Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef FLUTTER_SHELL_PLATFORM_WINDOWS_FLUTTER_PROJECT_BUNDLE_H_
6 #define FLUTTER_SHELL_PLATFORM_WINDOWS_FLUTTER_PROJECT_BUNDLE_H_
7
8 #include <filesystem>
9 #include <string>
10 #include <vector>
11
12 #include "flutter/shell/platform/embedder/embedder.h"
13 #include "flutter/shell/platform/windows/public/flutter_windows.h"
14
15 namespace flutter {
16
17 using UniqueAotDataPtr =
18 std::unique_ptr<_FlutterEngineAOTData, FlutterEngineCollectAOTDataFnPtr>;
19
20 enum class FlutterGpuPreference {
21 NoPreference,
22 LowPowerPreference,
23 HighPerformancePreference,
24 };
25
26 enum class FlutterUIThreadPolicy {
27 Default,
28 RunOnPlatformThread,
29 RunOnSeparateThread,
30 };
31
32 enum class FlutterAccessibilityMode {
33 Default,
34 IAccessible,
35 IAccessibleEx,
36 };
37
38 // The data associated with a Flutter project needed to run it in an engine.
39 class FlutterProjectBundle {
40 public:
41 // Creates a new project bundle from the given properties.
42 //
43 // Treats any relative paths as relative to the directory of this executable.
44 explicit FlutterProjectBundle(
45 const FlutterDesktopEngineProperties& properties);
46
47 ~FlutterProjectBundle();
48
49 // Whether or not the bundle is valid. This does not check that the paths
50 // exist, or contain valid data, just that paths were able to be constructed.
51 bool HasValidPaths();
52
53 // Returns the path to the assets directory.
54 const std::filesystem::path& assets_path() { return assets_path_; }
55
56 // Returns the path to the ICU data file.
57 const std::filesystem::path& icu_path() { return icu_path_; }
58
59 // Returns any switches that should be passed to the engine.
60 const std::vector<std::string> GetSwitches();
61
62 // Sets engine switches.
63 void SetSwitches(const std::vector<std::string>& switches);
64
65 // Attempts to load AOT data for this bundle. The returned data must be
66 // retained until any engine instance it is passed to has been shut down.
67 //
68 // Logs and returns nullptr on failure.
69 UniqueAotDataPtr LoadAotData(const FlutterEngineProcTable& engine_procs);
70
71 // Returns the Dart entrypoint.
72 const std::string& dart_entrypoint() const { return dart_entrypoint_; }
73
74 // Returns the command line arguments to be passed through to the Dart
75 // entrypoint.
76 const std::vector<std::string>& dart_entrypoint_arguments() const {
77 return dart_entrypoint_arguments_;
78 }
79
80 // Returns the app's GPU preference.
81 FlutterGpuPreference gpu_preference() const { return gpu_preference_; }
82
83 // Returns thread policy for running the UI isolate.
84 FlutterUIThreadPolicy ui_thread_policy() { return ui_thread_policy_; }
85
86 // Returns the accessibility mode.
87 FlutterAccessibilityMode accessibility_mode() const {
88 return accessibility_mode_;
89 }
90
91 private:
92 std::filesystem::path assets_path_;
93 std::filesystem::path icu_path_;
94
95 // Path to the AOT library file, if any.
96 std::filesystem::path aot_library_path_;
97
98 // The Dart entrypoint to launch.
99 std::string dart_entrypoint_;
100
101 // Dart entrypoint arguments.
102 std::vector<std::string> dart_entrypoint_arguments_;
103
104 // Engine switches.
105 std::vector<std::string> engine_switches_;
106
107 // App's GPU preference.
108 FlutterGpuPreference gpu_preference_;
109
110 // Thread policy for running the UI isolate.
111 FlutterUIThreadPolicy ui_thread_policy_;
112
113 // The current accessibility mode.
114 FlutterAccessibilityMode accessibility_mode_;
115 };
116
117 } // namespace flutter
118
119 #endif // FLUTTER_SHELL_PLATFORM_WINDOWS_FLUTTER_PROJECT_BUNDLE_H_
flutter::FlutterProjectBundle
Definition: flutter_project_bundle.h:39
flutter::FlutterProjectBundle::gpu_preference
FlutterGpuPreference gpu_preference() const
Definition: flutter_project_bundle.h:81
flutter::FlutterProjectBundle::assets_path
const std::filesystem::path & assets_path()
Definition: flutter_project_bundle.h:54
flutter::FlutterProjectBundle::HasValidPaths
bool HasValidPaths()
Definition: flutter_project_bundle.cc:62
flutter::FlutterProjectBundle::GetSwitches
const std::vector< std::string > GetSwitches()
Definition: flutter_project_bundle.cc:100
flutter::FlutterProjectBundle::icu_path
const std::filesystem::path & icu_path()
Definition: flutter_project_bundle.h:57
flutter::FlutterProjectBundle::~FlutterProjectBundle
~FlutterProjectBundle()
Definition: flutter_project_bundle.cc:93
flutter::FlutterProjectBundle::FlutterProjectBundle
FlutterProjectBundle(const FlutterDesktopEngineProperties &properties)
Definition: flutter_project_bundle.cc:16
flutter::FlutterProjectBundle::accessibility_mode
FlutterAccessibilityMode accessibility_mode() const
Definition: flutter_project_bundle.h:87
flutter::FlutterProjectBundle::LoadAotData
UniqueAotDataPtr LoadAotData(const FlutterEngineProcTable &engine_procs)
Definition: flutter_project_bundle.cc:68
flutter::FlutterProjectBundle::dart_entrypoint_arguments
const std::vector< std::string > & dart_entrypoint_arguments() const
Definition: flutter_project_bundle.h:76
flutter::FlutterProjectBundle::ui_thread_policy
FlutterUIThreadPolicy ui_thread_policy()
Definition: flutter_project_bundle.h:84
flutter::FlutterProjectBundle::SetSwitches
void SetSwitches(const std::vector< std::string > &switches)
Definition: flutter_project_bundle.cc:95
flutter::FlutterProjectBundle::dart_entrypoint
const std::string & dart_entrypoint() const
Definition: flutter_project_bundle.h:72
flutter_windows.h
flutter
Definition: accessibility_bridge_windows.cc:11
flutter::FlutterAccessibilityMode
FlutterAccessibilityMode
Definition: flutter_project_bundle.h:32
flutter::FlutterAccessibilityMode::IAccessibleEx
@ IAccessibleEx
flutter::FlutterAccessibilityMode::IAccessible
@ IAccessible
flutter::FlutterAccessibilityMode::Default
@ Default
flutter::FlutterUIThreadPolicy
FlutterUIThreadPolicy
Definition: flutter_project_bundle.h:26
flutter::FlutterUIThreadPolicy::RunOnPlatformThread
@ RunOnPlatformThread
flutter::FlutterUIThreadPolicy::Default
@ Default
flutter::FlutterUIThreadPolicy::RunOnSeparateThread
@ RunOnSeparateThread
flutter::FlutterGpuPreference
FlutterGpuPreference
Definition: flutter_project_bundle.h:20
flutter::FlutterGpuPreference::HighPerformancePreference
@ HighPerformancePreference
flutter::FlutterGpuPreference::NoPreference
@ NoPreference
flutter::FlutterGpuPreference::LowPowerPreference
@ LowPowerPreference
flutter::UniqueAotDataPtr
std::unique_ptr< _FlutterEngineAOTData, FlutterEngineCollectAOTDataFnPtr > UniqueAotDataPtr
Definition: flutter_project_bundle.h:18
FlutterDesktopEngineProperties
Definition: flutter_windows.h:75