| Flutter Windows Embedder |

Public Member Functions | Friends | List of all members
flutter::FlutterEngine Class Reference

`#include <flutter_engine.h>`

Inheritance diagram for flutter::FlutterEngine:

## Public Member Functions
| FlutterEngine (const DartProject &project)
virtual | ~FlutterEngine ()
| FlutterEngine (FlutterEngine const &)=delete
FlutterEngine & | operator= (FlutterEngine const &)=delete
bool | Run ()
bool | Run (const char *entry_point)
void | ShutDown ()
std::chrono::nanoseconds | ProcessMessages ()
void | ReloadSystemFonts ()
void | ReloadPlatformBrightness ()
FlutterDesktopPluginRegistrarRef | GetRegistrarForPlugin (const std::string &plugin_name) override
BinaryMessenger * | messenger ()
void | SetNextFrameCallback (std::function< void()> callback)
std::optional< LRESULT > | ProcessExternalWindowMessage (HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam)
Public Member Functions inherited from flutter::PluginRegistry
| PluginRegistry ()=default
virtual | ~PluginRegistry ()=default
| PluginRegistry (PluginRegistry const &)=delete
PluginRegistry & | operator= (PluginRegistry const &)=delete

## Friends
class | FlutterViewController

## Detailed Description

Definition at line 28 of file flutter_engine.h.

## Constructor & Destructor Documentation

## ◆ FlutterEngine() [1/2]

flutter::FlutterEngine::FlutterEngine | ( | const DartProject & | project | ) |
| explicit

Definition at line 15 of file flutter_engine.cc.

15 {
16 FlutterDesktopEngineProperties c_engine_properties = {};
17 c_engine_properties.assets_path = project.assets_path().c_str();
18 c_engine_properties.icu_data_path = project.icu_data_path().c_str();
19 c_engine_properties.aot_library_path = project.aot_library_path().c_str();
20 c_engine_properties.dart_entrypoint = project.dart_entrypoint().c_str();
21 c_engine_properties.gpu_preference =
22 static_cast<FlutterDesktopGpuPreference>(project.gpu_preference());
23 c_engine_properties.ui_thread_policy =
24 static_cast<FlutterDesktopUIThreadPolicy>(project.ui_thread_policy());
25
26 const std::vector<std::string>& entrypoint_args =
27 project.dart_entrypoint_arguments();
28 std::vector<const char*> entrypoint_argv;
29 std::transform(
30 entrypoint_args.begin(), entrypoint_args.end(),
31 std::back_inserter(entrypoint_argv),
32 [](const std::string& arg) -> const char* { return arg.c_str(); });
33
34 c_engine_properties.dart_entrypoint_argc =
35 static_cast<int>(entrypoint_argv.size());
36 c_engine_properties.dart_entrypoint_argv =
37 entrypoint_argv.empty() ? nullptr : entrypoint_argv.data();
38
39 engine_ = FlutterDesktopEngineCreate(&c_engine_properties);
40
41 auto core_messenger = FlutterDesktopEngineGetMessenger(engine_);
42 messenger_ = std::make_unique<BinaryMessengerImpl>(core_messenger);
43 }
FlutterDesktopEngineCreate
FlutterDesktopEngineRef FlutterDesktopEngineCreate(const FlutterDesktopEngineProperties *engine_properties)
Definition: flutter_windows.cc:183
FlutterDesktopEngineGetMessenger
FlutterDesktopMessengerRef FlutterDesktopEngineGetMessenger(FlutterDesktopEngineRef engine)
Definition: flutter_windows.cc:234
FlutterDesktopUIThreadPolicy
FlutterDesktopUIThreadPolicy
Definition: flutter_windows.h:49
FlutterDesktopGpuPreference
FlutterDesktopGpuPreference
Definition: flutter_windows.h:39
FlutterDesktopEngineProperties
Definition: flutter_windows.h:60
FlutterDesktopEngineProperties::dart_entrypoint
const char * dart_entrypoint
Definition: flutter_windows.h:83
FlutterDesktopEngineProperties::icu_data_path
const wchar_t * icu_data_path
Definition: flutter_windows.h:69
FlutterDesktopEngineProperties::dart_entrypoint_argc
int dart_entrypoint_argc
Definition: flutter_windows.h:86
FlutterDesktopEngineProperties::assets_path
const wchar_t * assets_path
Definition: flutter_windows.h:64
FlutterDesktopEngineProperties::dart_entrypoint_argv
const char ** dart_entrypoint_argv
Definition: flutter_windows.h:90
FlutterDesktopEngineProperties::ui_thread_policy
FlutterDesktopUIThreadPolicy ui_thread_policy
Definition: flutter_windows.h:96
FlutterDesktopEngineProperties::aot_library_path
const wchar_t * aot_library_path
Definition: flutter_windows.h:75
FlutterDesktopEngineProperties::gpu_preference
FlutterDesktopGpuPreference gpu_preference
Definition: flutter_windows.h:93

References FlutterDesktopEngineProperties::aot_library_path, FlutterDesktopEngineProperties::assets_path, flutter::DartProject::dart_entrypoint(), FlutterDesktopEngineProperties::dart_entrypoint, FlutterDesktopEngineProperties::dart_entrypoint_argc, flutter::DartProject::dart_entrypoint_arguments(), FlutterDesktopEngineProperties::dart_entrypoint_argv, FlutterDesktopEngineCreate(), FlutterDesktopEngineGetMessenger(), flutter::DartProject::gpu_preference(), FlutterDesktopEngineProperties::gpu_preference, FlutterDesktopEngineProperties::icu_data_path, flutter::DartProject::ui_thread_policy(), and FlutterDesktopEngineProperties::ui_thread_policy.

## ◆ ~FlutterEngine()

flutter::FlutterEngine::~FlutterEngine | ( |  | ) |
| virtual

Definition at line 45 of file flutter_engine.cc.

45 {
46 ShutDown();
47 }
flutter::FlutterEngine::ShutDown
void ShutDown()
Definition: flutter_engine.cc:70

References ShutDown().

## ◆ FlutterEngine() [2/2]

flutter::FlutterEngine::FlutterEngine | ( | FlutterEngine const & |  | ) |
| delete

## Member Function Documentation

## ◆ GetRegistrarForPlugin()

FlutterDesktopPluginRegistrarRef flutter::FlutterEngine::GetRegistrarForPlugin | ( | const std::string & | plugin_name | ) |
| overridevirtual

Implements flutter::PluginRegistry.

Definition at line 85 of file flutter_engine.cc.

86 {
87 if (!engine_) {
88 std::cerr << "Cannot get plugin registrar on an engine that isn't running; "
89 "call Run first."
90 << std::endl;
91 return nullptr;
92 }
93 return FlutterDesktopEngineGetPluginRegistrar(engine_, plugin_name.c_str());
94 }
FlutterDesktopEngineGetPluginRegistrar
FlutterDesktopPluginRegistrarRef FlutterDesktopEngineGetPluginRegistrar(FlutterDesktopEngineRef engine, const char *plugin_name)
Definition: flutter_windows.cc:224

References FlutterDesktopEngineGetPluginRegistrar().

## ◆ messenger()

BinaryMessenger* flutter::FlutterEngine::messenger | ( |  | ) |
| inline

Definition at line 80 of file flutter_engine.h.

80 { return messenger_.get(); }

Referenced by flutter::TEST().

## ◆ operator=()

FlutterEngine& flutter::FlutterEngine::operator= | ( | FlutterEngine const & |  | ) |
| delete

## ◆ ProcessExternalWindowMessage()

std::optional< LRESULT > flutter::FlutterEngine::ProcessExternalWindowMessage | ( | HWND | hwnd,
|  | UINT | message,
|  | WPARAM | wparam,
|  | LPARAM | lparam
| ) |  |

Definition at line 108 of file flutter_engine.cc.

112 {
113 LRESULT result;
114 if (FlutterDesktopEngineProcessExternalWindowMessage(
115 engine_, hwnd, message, wparam, lparam, &result)) {
116 return result;
117 }
118 return std::nullopt;
119 }
FlutterDesktopEngineProcessExternalWindowMessage
bool FlutterDesktopEngineProcessExternalWindowMessage(FlutterDesktopEngineRef engine, HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam, LRESULT *result)
Definition: flutter_windows.cc:272
message
Win32Message message
Definition: keyboard_unittests.cc:137

References FlutterDesktopEngineProcessExternalWindowMessage(), and message.

Referenced by flutter::TEST().

## ◆ ProcessMessages()

std::chrono::nanoseconds flutter::FlutterEngine::ProcessMessages | ( |  | ) |

Definition at line 77 of file flutter_engine.cc.

77 {
78 return std::chrono::nanoseconds(FlutterDesktopEngineProcessMessages(engine_));
79 }
FlutterDesktopEngineProcessMessages
uint64_t FlutterDesktopEngineProcessMessages(FlutterDesktopEngineRef engine)
Definition: flutter_windows.cc:216

References FlutterDesktopEngineProcessMessages().

Referenced by flutter::TEST().

## ◆ ReloadPlatformBrightness()

void flutter::FlutterEngine::ReloadPlatformBrightness | ( |  | ) |

## ◆ ReloadSystemFonts()

void flutter::FlutterEngine::ReloadSystemFonts | ( |  | ) |

Definition at line 81 of file flutter_engine.cc.

81 {
82 FlutterDesktopEngineReloadSystemFonts(engine_);
83 }
FlutterDesktopEngineReloadSystemFonts
void FlutterDesktopEngineReloadSystemFonts(FlutterDesktopEngineRef engine)
Definition: flutter_windows.cc:220

References FlutterDesktopEngineReloadSystemFonts().

Referenced by flutter::TEST().

## ◆ Run() [1/2]

bool flutter::FlutterEngine::Run | ( |  | ) |

Definition at line 49 of file flutter_engine.cc.

49 {
50 return Run(nullptr);
51 }
flutter::FlutterEngine::Run
bool Run()
Definition: flutter_engine.cc:49

Referenced by flutter::TEST(), and flutter::testing::TEST_F().

## ◆ Run() [2/2]

bool flutter::FlutterEngine::Run | ( | const char * | entry_point | ) |

Definition at line 53 of file flutter_engine.cc.

53 {
54 if (!engine_) {
55 std::cerr << "Cannot run an engine that failed creation." << std::endl;
56 return false;
57 }
58 if (run_succeeded_) {
59 std::cerr << "Cannot run an engine more than once." << std::endl;
60 return false;
61 }
62 bool run_succeeded = FlutterDesktopEngineRun(engine_, entry_point);
63 if (!run_succeeded) {
64 std::cerr << "Failed to start engine." << std::endl;
65 }
66 run_succeeded_ = true;
67 return run_succeeded;
68 }
FlutterDesktopEngineRun
bool FlutterDesktopEngineRun(FlutterDesktopEngineRef engine, const char *entry_point)
Definition: flutter_windows.cc:206

References FlutterDesktopEngineRun().

## ◆ SetNextFrameCallback()

void flutter::FlutterEngine::SetNextFrameCallback | ( | std::function< void()> | callback | ) |

Definition at line 96 of file flutter_engine.cc.

96 {
97 next_frame_callback_ = std::move(callback);
98 FlutterDesktopEngineSetNextFrameCallback(
99 engine_,
100 [](void* user_data) {
101 FlutterEngine* self = static_cast<FlutterEngine*>(user_data);
102 self->next_frame_callback_();
103 self->next_frame_callback_ = nullptr;
104 },
105 this);
106 }
flutter::FlutterEngine::FlutterEngine
FlutterEngine(const DartProject &project)
Definition: flutter_engine.cc:15
FlutterDesktopEngineSetNextFrameCallback
void FlutterDesktopEngineSetNextFrameCallback(FlutterDesktopEngineRef engine, VoidCallback callback, void *user_data)
Definition: flutter_windows.cc:245
user_data
void * user_data
Definition: flutter_windows_view_unittests.cc:53
callback
FlutterDesktopBinaryReply callback
Definition: flutter_windows_view_unittests.cc:52

References callback, FlutterDesktopEngineSetNextFrameCallback(), and user_data.

Referenced by flutter::TEST().

## ◆ ShutDown()

void flutter::FlutterEngine::ShutDown | ( |  | ) |

Definition at line 70 of file flutter_engine.cc.

70 {
71 if (engine_ && owns_engine_) {
72 FlutterDesktopEngineDestroy(engine_);
73 }
74 engine_ = nullptr;
75 }
FlutterDesktopEngineDestroy
bool FlutterDesktopEngineDestroy(FlutterDesktopEngineRef engine_ref)
Definition: flutter_windows.cc:190

References FlutterDesktopEngineDestroy().

Referenced by flutter::TEST(), and ~FlutterEngine().

## Friends And Related Function Documentation

## ◆ FlutterViewController

friend class FlutterViewController
| friend

Definition at line 99 of file flutter_engine.h.

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

- shell/platform/windows/client_wrapper/include/flutter/flutter_engine.h
- shell/platform/windows/client_wrapper/flutter_engine.cc