| Flutter Windows Embedder |

Public Member Functions | Static Public Member Functions | Protected Member Functions | Friends | List of all members
flutter::FlutterWindowsEngine Class Reference

`#include <flutter_windows_engine.h>`

## Public Member Functions
| FlutterWindowsEngine (const FlutterProjectBundle &project, std::shared_ptr< WindowsProcTable > windows_proc_table=nullptr)
virtual | ~FlutterWindowsEngine ()
bool | Run ()
bool | Run (std::string_view entrypoint)
virtual bool | running () const
virtual bool | Stop ()
std::unique_ptr< FlutterWindowsView > | CreateView (std::unique_ptr< WindowBindingHandler > window)
virtual void | RemoveView (FlutterViewId view_id)
FlutterWindowsView * | view (FlutterViewId view_id) const
FlutterDesktopPluginRegistrarRef | GetRegistrar ()
void | AddPluginRegistrarDestructionCallback (FlutterDesktopOnPluginRegistrarDestroyed callback, FlutterDesktopPluginRegistrarRef registrar)
void | SetSwitches (const std::vector< std::string > &switches)
FlutterDesktopMessengerRef | messenger ()
IncomingMessageDispatcher * | message_dispatcher ()
std::shared_ptr< DisplayManagerWin32 > | display_manager ()
void | UpdateDisplay (const std::vector< FlutterEngineDisplay > &displays)
TaskRunner * | task_runner ()
BinaryMessenger * | messenger_wrapper ()
FlutterWindowsTextureRegistrar * | texture_registrar ()
egl::Manager * | egl_manager () const
WindowProcDelegateManager * | window_proc_delegate_manager ()
void | SendWindowMetricsEvent (const FlutterWindowMetricsEvent &event)
void | SendPointerEvent (const FlutterPointerEvent &event)
void | SendKeyEvent (const FlutterKeyEvent &event, FlutterKeyEventCallback callback, void *user_data)
void | SendViewFocusEvent (const FlutterViewFocusEvent &event)
KeyboardHandlerBase * | keyboard_key_handler ()
TextInputPlugin * | text_input_plugin ()
bool | SendPlatformMessage (const char *channel, const uint8_t *message, const size_t message_size, const FlutterDesktopBinaryReply reply, void *user_data)
void | SendPlatformMessageResponse (const FlutterDesktopMessageResponseHandle *handle, const uint8_t *data, size_t data_length)
void | HandlePlatformMessage (const FlutterPlatformMessage *)
void | ReloadSystemFonts ()
void | ScheduleFrame ()
void | SetNextFrameCallback (fml::closure callback)
bool | RegisterExternalTexture (int64_t texture_id)
bool | UnregisterExternalTexture (int64_t texture_id)
bool | MarkExternalTextureFrameAvailable (int64_t texture_id)
virtual bool | PostRasterThreadTask (fml::closure callback) const
void | OnVsync (intptr_t baton)
bool | DispatchSemanticsAction (FlutterViewId view_id, uint64_t node_id, FlutterSemanticsAction action, fml::MallocMapping data)
void | UpdateSemanticsEnabled (bool enabled)
bool | semantics_enabled () const
void | UpdateAccessibilityFeatures ()
void | UpdateHighContrastMode ()
bool | high_contrast_enabled () const
void | SetRootIsolateCreateCallback (const fml::closure &callback)
std::string | GetExecutableName () const
void | OnQuit (std::optional< HWND > hwnd, std::optional< WPARAM > wparam, std::optional< LPARAM > lparam, UINT exit_code)
void | RequestApplicationQuit (HWND hwnd, WPARAM wparam, LPARAM lparam, AppExitType exit_type)
void | OnDwmCompositionChanged ()
void | OnWindowStateEvent (HWND hwnd, WindowStateEvent event)
std::optional< LRESULT > | ProcessExternalWindowMessage (HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam)
WindowsLifecycleManager * | lifecycle_manager ()
std::shared_ptr< WindowsProcTable > | windows_proc_table ()
void | UpdateFlutterCursor (const std::string &cursor_name) const
void | SetFlutterCursor (HCURSOR cursor) const
WindowManager * | window_manager ()
FlutterWindowsView * | GetViewFromTopLevelWindow (HWND hwnd) const

## Static Public Member Functions
static FlutterWindowsEngine * | GetEngineForId (int64_t engine_id)

## Protected Member Functions
virtual std::unique_ptr< KeyboardHandlerBase > | CreateKeyboardKeyHandler (BinaryMessenger *messenger, KeyboardKeyEmbedderHandler::GetKeyStateHandler get_key_state, KeyboardKeyEmbedderHandler::MapVirtualKeyToScanCode map_vk_to_scan)
virtual std::unique_ptr< TextInputPlugin > | CreateTextInputPlugin (BinaryMessenger *messenger)
void | OnPreEngineRestart ()
virtual void | OnChannelUpdate (std::string name, bool listening)
virtual void | OnViewFocusChangeRequest (const FlutterViewFocusChangeRequest *request)

## Friends
class | EngineModifier

## Detailed Description

Definition at line 92 of file flutter_windows_engine.h.

## Constructor & Destructor Documentation

## ◆ FlutterWindowsEngine()

flutter::FlutterWindowsEngine::FlutterWindowsEngine | ( | const FlutterProjectBundle & | project,
|  | std::shared_ptr< WindowsProcTable > | windows_proc_table = `nullptr`
| ) |  |

Definition at line 151 of file flutter_windows_engine.cc.

154 : project_(std::make_unique<FlutterProjectBundle>(project)),
155 windows_proc_table_(std::move(windows_proc_table)),
156 aot_data_(nullptr, nullptr),
157 lifecycle_manager_(std::make_unique<WindowsLifecycleManager>(this)) {
158 if (windows_proc_table_ == nullptr) {
159 windows_proc_table_ = std::make_shared<WindowsProcTable>();
160 }
161
162 gl_ = egl::ProcTable::Create();
163
164 embedder_api_.struct_size = sizeof(FlutterEngineProcTable);
165 FlutterEngineGetProcAddresses(&embedder_api_);
166
167 task_runner_ =
168 std::make_unique<TaskRunner>(
169 embedder_api_.GetCurrentTime, [this](const auto* task) {
170 if (!engine_) {
171 FML_LOG(ERROR)
172 << "Cannot post an engine task when engine is not running.";
173 return;
174 }
175 if (embedder_api_.RunTask(engine_, task) != kSuccess) {
176 FML_LOG(ERROR) << "Failed to post an engine task.";
177 }
178 });
179
180 // Set up the legacy structs backing the API handles.
181 messenger_ =
182 fml::RefPtr<FlutterDesktopMessenger>(new FlutterDesktopMessenger());
183 messenger_->SetEngine(this);
184 plugin_registrar_ = std::make_unique<FlutterDesktopPluginRegistrar>();
185 plugin_registrar_->engine = this;
186
187 messenger_wrapper_ =
188 std::make_unique<BinaryMessengerImpl>(messenger_->ToRef());
189 message_dispatcher_ =
190 std::make_unique<IncomingMessageDispatcher>(messenger_->ToRef());
191
192 texture_registrar_ =
193 std::make_unique<FlutterWindowsTextureRegistrar>(this, gl_);
194
195 // Check for impeller support.
196 auto& switches = project_->GetSwitches();
197 enable_impeller_ = std::find(switches.begin(), switches.end(),
198 "--enable-impeller=true") != switches.end();
199
200 egl_manager_ = egl::Manager::Create(
201 static_cast<egl::GpuPreference>(project_->gpu_preference()));
202 window_proc_delegate_manager_ = std::make_unique<WindowProcDelegateManager>();
203
204 display_manager_ = std::make_shared<DisplayManagerWin32>(this);
205
206 window_proc_delegate_manager_->RegisterTopLevelWindowProcDelegate(
207 [](HWND hwnd, UINT msg, WPARAM wpar, LPARAM lpar, void* user_data,
208 LRESULT* result) {
209 BASE_DCHECK(user_data);
210 FlutterWindowsEngine* that =
211 static_cast<FlutterWindowsEngine*>(user_data);
212
213 BASE_DCHECK(that->display_manager_);
214 if (that->display_manager_->HandleWindowMessage(hwnd, msg, wpar, lpar,
215 result)) {
216 return true;
217 }
218
219 BASE_DCHECK(that->lifecycle_manager_);
220 bool handled =
221 that->lifecycle_manager_->WindowProc(hwnd, msg, wpar, lpar, result);
222 if (handled) {
223 return true;
224 }
225 auto message_result =
226 that->window_manager_->HandleMessage(hwnd, msg, wpar, lpar);
227 if (message_result) {
228 *result = *message_result;
229 return true;
230 }
231 return false;
232 },
233 static_cast<void*>(this));
234
235 // Set up internal channels.
236 // TODO: Replace this with an embedder.h API. See
237 // https://github.com/flutter/flutter/issues/71099
238 internal_plugin_registrar_ =
239 std::make_unique<PluginRegistrar>(plugin_registrar_.get());
240
241 accessibility_plugin_ = std::make_unique<AccessibilityPlugin>(this);
242 AccessibilityPlugin::SetUp(messenger_wrapper_.get(),
243 accessibility_plugin_.get());
244
245 cursor_handler_ =
246 std::make_unique<CursorHandler>(messenger_wrapper_.get(), this);
247 platform_handler_ =
248 std::make_unique<PlatformHandler>(messenger_wrapper_.get(), this);
249 window_manager_ = std::make_unique<WindowManager>(this);
250 settings_plugin_ = std::make_unique<SettingsPlugin>(messenger_wrapper_.get(),
251 task_runner_.get());
252 }
flutter::AccessibilityPlugin::SetUp
static void SetUp(BinaryMessenger *binary_messenger, AccessibilityPlugin *plugin)
Definition: accessibility_plugin.cc:90
flutter::FlutterWindowsEngine::windows_proc_table
std::shared_ptr< WindowsProcTable > windows_proc_table()
Definition: flutter_windows_engine.h:316
flutter::FlutterWindowsEngine::FlutterWindowsEngine
FlutterWindowsEngine(const FlutterProjectBundle &project, std::shared_ptr< WindowsProcTable > windows_proc_table=nullptr)
Definition: flutter_windows_engine.cc:151
flutter::egl::Manager::Create
static std::unique_ptr< Manager > Create(GpuPreference gpu_preference)
Definition: manager.cc:17
flutter::egl::ProcTable::Create
static std::shared_ptr< ProcTable > Create()
Definition: proc_table.cc:12
user_data
void * user_data
Definition: flutter_windows_view_unittests.cc:53
flutter::egl::GpuPreference
GpuPreference
Definition: manager.h:32

References flutter::egl::ProcTable::Create().

## ◆ ~FlutterWindowsEngine()

flutter::FlutterWindowsEngine::~FlutterWindowsEngine | ( |  | ) |
| virtual

Definition at line 254 of file flutter_windows_engine.cc.

254 {
255 messenger_->SetEngine(nullptr);
256 Stop();
257 }
flutter::FlutterWindowsEngine::Stop
virtual bool Stop()
Definition: flutter_windows_engine.cc:512

## Member Function Documentation

## ◆ AddPluginRegistrarDestructionCallback()

void flutter::FlutterWindowsEngine::AddPluginRegistrarDestructionCallback | ( | FlutterDesktopOnPluginRegistrarDestroyed | callback,
|  | FlutterDesktopPluginRegistrarRef | registrar
| ) |  |

Definition at line 704 of file flutter_windows_engine.cc.

706 {
707 plugin_registrar_destruction_callbacks_[callback] = registrar;
708 }
callback
FlutterDesktopBinaryReply callback
Definition: flutter_windows_view_unittests.cc:52

References callback.

Referenced by FlutterDesktopPluginRegistrarSetDestructionHandler().

## ◆ CreateKeyboardKeyHandler()

std::unique_ptr< KeyboardHandlerBase > flutter::FlutterWindowsEngine::CreateKeyboardKeyHandler | ( | BinaryMessenger * | messenger,
|  | KeyboardKeyEmbedderHandler::GetKeyStateHandler | get_key_state,
|  | KeyboardKeyEmbedderHandler::MapVirtualKeyToScanCode | map_vk_to_scan
| ) |  |
| protected virtual

Definition at line 911 of file flutter_windows_engine.cc.

914 {
915 auto keyboard_key_handler = std::make_unique<KeyboardKeyHandler>(messenger);
916 keyboard_key_handler->AddDelegate(
917 std::make_unique<KeyboardKeyEmbedderHandler>(
918 [this](const FlutterKeyEvent& event, FlutterKeyEventCallback callback,
919 void* user_data) {
920 return SendKeyEvent(event, callback, user_data);
921 },
922 get_key_state, map_vk_to_scan));
923 keyboard_key_handler->AddDelegate(
924 std::make_unique<KeyboardKeyChannelHandler>(messenger));
925 keyboard_key_handler->InitKeyboardChannel();
926 return keyboard_key_handler;
927 }
flutter::FlutterWindowsEngine::messenger
FlutterDesktopMessengerRef messenger()
Definition: flutter_windows_engine.h:157
flutter::FlutterWindowsEngine::keyboard_key_handler
KeyboardHandlerBase * keyboard_key_handler()
Definition: flutter_windows_engine.h:200
flutter::FlutterWindowsEngine::SendKeyEvent
void SendKeyEvent(const FlutterKeyEvent &event, FlutterKeyEventCallback callback, void *user_data)
Definition: flutter_windows_engine.cc:732

References callback, and user_data.

## ◆ CreateTextInputPlugin()

std::unique_ptr< TextInputPlugin > flutter::FlutterWindowsEngine::CreateTextInputPlugin | ( | BinaryMessenger * | messenger | ) |
| protected virtual

Definition at line 929 of file flutter_windows_engine.cc.

930 {
931 return std::make_unique<TextInputPlugin>(messenger, this);
932 }

## ◆ CreateView()

std::unique_ptr< FlutterWindowsView > flutter::FlutterWindowsEngine::CreateView | ( | std::unique_ptr< WindowBindingHandler > | window | ) |

Definition at line 526 of file flutter_windows_engine.cc.

527 {
528 auto view_id = next_view_id_;
529 auto view = std::make_unique<FlutterWindowsView>(
530 view_id, this, std::move(window), windows_proc_table_);
531
532 view->CreateRenderSurface();
533 view->UpdateSemanticsEnabled(semantics_enabled_);
534
535 next_view_id_++;
536
537 {
538 // Add the view to the embedder. This must happen before the engine
539 // is notified the view exists and starts presenting to it.
540 std::unique_lock write_lock(views_mutex_);
541 FML_DCHECK(views_.find(view_id) == views_.end());
542 views_[view_id] = view.get();
543 }
544
545 if (!view->IsImplicitView()) {
546 FML_DCHECK(running());
547
548 struct Captures {
549 fml::AutoResetWaitableEvent latch;
550 bool added;
551 };
552 Captures captures = {};
553
554 FlutterWindowMetricsEvent metrics = view->CreateWindowMetricsEvent();
555
556 FlutterAddViewInfo info = {};
557 info.struct_size = sizeof(FlutterAddViewInfo);
558 info.view_id = view_id;
559 info.view_metrics = &metrics;
560 info.user_data = &captures;
561 info.add_view_callback = [](const FlutterAddViewResult* result) {
562 Captures* captures = reinterpret_cast<Captures*>(result->user_data);
563 captures->added = result->added;
564 captures->latch.Signal();
565 };
566
567 FlutterEngineResult result = embedder_api_.AddView(engine_, &info);
568 if (result != kSuccess) {
569 FML_LOG(ERROR)
570 << "Starting the add view operation failed. FlutterEngineAddView "
571 "returned an unexpected result: "
572 << result << ". This indicates a bug in the Windows embedder.";
573 FML_DCHECK(false);
574 return nullptr;
575 }
576
577 // Block the platform thread until the engine has added the view.
578 // TODO(loicsharma): This blocks the platform thread eagerly and can
579 // cause unnecessary delay in input processing. Instead, this should block
580 // lazily only when the app does an operation which needs the view.
581 // https://github.com/flutter/flutter/issues/146248
582 captures.latch.Wait();
583
584 if (!captures.added) {
585 // Adding the view failed. Update the embedder's state to match the
586 // engine's state. This is unexpected and indicates a bug in the Windows
587 // embedder.
588 FML_LOG(ERROR) << "FlutterEngineAddView failed to add view";
589 std::unique_lock write_lock(views_mutex_);
590 views_.erase(view_id);
591 return nullptr;
592 }
593 }
594
595 return std::move(view);
596 }
flutter::FlutterWindowsEngine::view
FlutterWindowsView * view(FlutterViewId view_id) const
Definition: flutter_windows_engine.cc:688
flutter::FlutterWindowsEngine::running
virtual bool running() const
Definition: flutter_windows_engine.h:125
flutter::FlutterWindowsView::CreateRenderSurface
void CreateRenderSurface()
Definition: flutter_windows_view.cc:719
flutter::FlutterWindowsView::UpdateSemanticsEnabled
virtual void UpdateSemanticsEnabled(bool enabled)
Definition: flutter_windows_view.cc:818
flutter::FlutterWindowsView::IsImplicitView
bool IsImplicitView() const
Definition: flutter_windows_view.cc:715
flutter::FlutterWindowsView::CreateWindowMetricsEvent
FlutterWindowMetricsEvent CreateWindowMetricsEvent() const
Definition: flutter_windows_view.cc:381

Referenced by flutter::HostWindow::CreateRegularWindow(), CreateViewController(), and flutter::testing::TEST_F().

## ◆ DispatchSemanticsAction()

bool flutter::FlutterWindowsEngine::DispatchSemanticsAction | ( | FlutterViewId | view_id,
|  | uint64_t | node_id,
|  | FlutterSemanticsAction | action,
|  | fml::MallocMapping | data
| ) |  |

Definition at line 970 of file flutter_windows_engine.cc.

974 {
975 FlutterSendSemanticsActionInfo info{
976 .struct_size = sizeof(FlutterSendSemanticsActionInfo),
977 .view_id = view_id,
978 .node_id = target,
979 .action = action,
980 .data = data.GetMapping(),
981 .data_length = data.GetSize(),
982 };
983 return (embedder_api_.SendSemanticsAction(engine_, &info));
984 }
action
int action
Definition: keyboard_key_handler_unittests.cc:116

References action.

Referenced by flutter::AccessibilityBridgeWindows::DispatchAccessibilityAction().

## ◆ display_manager()

std::shared_ptr<DisplayManagerWin32> flutter::FlutterWindowsEngine::display_manager | ( |  | ) |
| inline

Definition at line 163 of file flutter_windows_engine.h.

163 {
164 return display_manager_;
165 }

Referenced by flutter::HostWindow::CreateRegularWindow(), CreateViewController(), and flutter::HostWindow::SetFullscreen().

## ◆ egl_manager()

egl::Manager* flutter::FlutterWindowsEngine::egl_manager | ( |  | ) | const
| inline

Definition at line 180 of file flutter_windows_engine.h.

180 { return egl_manager_.get(); }

Referenced by flutter::FlutterWindowsView::CreateRenderSurface(), FlutterDesktopViewGetGraphicsAdapter(), flutter::FlutterWindowsView::OnWindowSizeChanged(), and flutter::FlutterWindowsTextureRegistrar::RegisterTexture().

## ◆ GetEngineForId()

FlutterWindowsEngine * flutter::FlutterWindowsEngine::GetEngineForId | ( | int64_t | engine_id | ) |
| static

Definition at line 259 of file flutter_windows_engine.cc.

259 {
260 return reinterpret_cast<FlutterWindowsEngine*>(engine_id);
261 }

Referenced by FlutterDesktopEngineForId(), InternalFlutterWindows_WindowManager_CreateRegularWindow(), InternalFlutterWindows_WindowManager_GetTopLevelWindowHandle(), InternalFlutterWindows_WindowManager_HasTopLevelWindows(), and InternalFlutterWindows_WindowManager_Initialize().

## ◆ GetExecutableName()

std::string flutter::FlutterWindowsEngine::GetExecutableName | ( |  | ) | const

Definition at line 1003 of file flutter_windows_engine.cc.

1003 {
1004 std::pair<bool, std::string> result = fml::paths::GetExecutablePath();
1005 if (result.first) {
1006 const std::string& executable_path = result.second;
1007 size_t last_separator = executable_path.find_last_of("/\\");
1008 if (last_separator == std::string::npos ||
1009 last_separator == executable_path.size() - 1) {
1010 return executable_path;
1011 }
1012 return executable_path.substr(last_separator + 1);
1013 }
1014 return "Flutter";
1015 }

## ◆ GetRegistrar()

FlutterDesktopPluginRegistrarRef flutter::FlutterWindowsEngine::GetRegistrar | ( |  | ) |

Definition at line 700 of file flutter_windows_engine.cc.

700 {
701 return plugin_registrar_.get();
702 }

Referenced by FlutterDesktopEngineGetPluginRegistrar().

## ◆ GetViewFromTopLevelWindow()

FlutterWindowsView * flutter::FlutterWindowsEngine::GetViewFromTopLevelWindow | ( | HWND | hwnd | ) | const

Definition at line 864 of file flutter_windows_engine.cc.

865 {
866 std::shared_lock read_lock(views_mutex_);
867 auto const iterator =
868 std::find_if(views_.begin(), views_.end(), [hwnd](auto const& pair) {
869 FlutterWindowsView* const view = pair.second;
870 return GetAncestor(view->GetWindowHandle(), GA_ROOT) == hwnd;
871 });
872 if (iterator != views_.end()) {
873 return iterator->second;
874 }
875 return nullptr;
876 }

Referenced by flutter::WindowManager::HandleMessage().

## ◆ HandlePlatformMessage()

void flutter::FlutterWindowsEngine::HandlePlatformMessage | ( | const FlutterPlatformMessage * | engine_message | ) |

Definition at line 788 of file flutter_windows_engine.cc.

789 {
790 if (engine_message->struct_size != sizeof(FlutterPlatformMessage)) {
791 FML_LOG(ERROR) << "Invalid message size received. Expected: "
792 << sizeof(FlutterPlatformMessage) << " but received "
793 << engine_message->struct_size;
794 return;
795 }
796
797 auto message = ConvertToDesktopMessage(*engine_message);
798
799 message_dispatcher_->HandleMessage(message, [this] {}, [this] {});
800 }
message
Win32Message message
Definition: keyboard_unittests.cc:137

References message.

Referenced by Run().

## ◆ high_contrast_enabled()

bool flutter::FlutterWindowsEngine::high_contrast_enabled | ( |  | ) | const
| inline

Definition at line 267 of file flutter_windows_engine.h.

267 { return high_contrast_enabled_; }

## ◆ keyboard_key_handler()

KeyboardHandlerBase* flutter::FlutterWindowsEngine::keyboard_key_handler | ( |  | ) |
| inline

Definition at line 200 of file flutter_windows_engine.h.

200 {
201 return keyboard_key_handler_.get();
202 }

Referenced by flutter::FlutterWindowsView::OnPointerMove().

## ◆ lifecycle_manager()

WindowsLifecycleManager* flutter::FlutterWindowsEngine::lifecycle_manager | ( |  | ) |
| inline

Definition at line 312 of file flutter_windows_engine.h.

312 {
313 return lifecycle_manager_.get();
314 }

## ◆ MarkExternalTextureFrameAvailable()

bool flutter::FlutterWindowsEngine::MarkExternalTextureFrameAvailable | ( | int64_t | texture_id | ) |

Definition at line 944 of file flutter_windows_engine.cc.

945 {
946 return (embedder_api_.MarkExternalTextureFrameAvailable(
947 engine_, texture_id) == kSuccess);
948 }
texture_id
uint32_t texture_id
Definition: compositor_opengl.cc:20

## ◆ message_dispatcher()

IncomingMessageDispatcher* flutter::FlutterWindowsEngine::message_dispatcher | ( |  | ) |
| inline

Definition at line 159 of file flutter_windows_engine.h.

159 {
160 return message_dispatcher_.get();
161 }

Referenced by FlutterDesktopMessengerSetCallback().

## ◆ messenger()

FlutterDesktopMessengerRef flutter::FlutterWindowsEngine::messenger | ( |  | ) |
| inline

Definition at line 157 of file flutter_windows_engine.h.

157 { return messenger_->ToRef(); }

Referenced by FlutterDesktopEngineGetMessenger(), and FlutterDesktopPluginRegistrarGetMessenger().

## ◆ messenger_wrapper()

BinaryMessenger* flutter::FlutterWindowsEngine::messenger_wrapper | ( |  | ) |
| inline

Definition at line 172 of file flutter_windows_engine.h.

172 { return messenger_wrapper_.get(); }

## ◆ OnChannelUpdate()

void flutter::FlutterWindowsEngine::OnChannelUpdate | ( | std::string | name,
|  | bool | listening
| ) |  |
| protected virtual

Definition at line 1091 of file flutter_windows_engine.cc.

1091 {
1092 if (name == "flutter/platform" && listening) {
1093 lifecycle_manager_->BeginProcessingExit();
1094 } else if (name == "flutter/lifecycle" && listening) {
1095 lifecycle_manager_->BeginProcessingLifecycle();
1096 }
1097 }

## ◆ OnDwmCompositionChanged()

void flutter::FlutterWindowsEngine::OnDwmCompositionChanged | ( |  | ) |

Definition at line 1054 of file flutter_windows_engine.cc.

1054 {
1055 if (display_manager_) {
1056 display_manager_->UpdateDisplays();
1057 }
1058
1059 std::shared_lock read_lock(views_mutex_);
1060 for (auto iterator = views_.begin(); iterator != views_.end(); iterator++) {
1061 iterator->second->OnDwmCompositionChanged();
1062 }
1063 }

Referenced by flutter::WindowsLifecycleManager::WindowProc().

## ◆ OnPreEngineRestart()

void flutter::FlutterWindowsEngine::OnPreEngineRestart | ( |  | ) |
| protected

Definition at line 998 of file flutter_windows_engine.cc.

998 {
999 // Reset the keyboard's state on hot restart.
1000 InitializeKeyboard();
1001 }

Referenced by Run().

## ◆ OnQuit()

void flutter::FlutterWindowsEngine::OnQuit | ( | std::optional< HWND > | hwnd,
|  | std::optional< WPARAM > | wparam,
|  | std::optional< LPARAM > | lparam,
|  | UINT | exit_code
| ) |  |

Definition at line 1047 of file flutter_windows_engine.cc.

1050 {
1051 lifecycle_manager_->Quit(hwnd, wparam, lparam, exit_code);
1052 }

Referenced by flutter::PlatformHandler::QuitApplication().

## ◆ OnViewFocusChangeRequest()

void flutter::FlutterWindowsEngine::OnViewFocusChangeRequest | ( | const FlutterViewFocusChangeRequest * | request | ) |
| protected virtual

Definition at line 1099 of file flutter_windows_engine.cc.

1100 {
1101 std::shared_lock read_lock(views_mutex_);
1102
1103 auto iterator = views_.find(request->view_id);
1104 if (iterator == views_.end()) {
1105 return;
1106 }
1107
1108 FlutterWindowsView* view = iterator->second;
1109 view->Focus();
1110 }
flutter::FlutterWindowsView::Focus
virtual bool Focus()
Definition: flutter_windows_view.cc:838

References flutter::FlutterWindowsView::Focus().

Referenced by Run().

## ◆ OnVsync()

void flutter::FlutterWindowsEngine::OnVsync | ( | intptr_t | baton | ) |

Definition at line 660 of file flutter_windows_engine.cc.

660 {
661 std::chrono::nanoseconds current_time =
662 std::chrono::nanoseconds(embedder_api_.GetCurrentTime());
663 std::chrono::nanoseconds frame_interval = FrameInterval();
664 auto next = SnapToNextTick(current_time, start_time_, frame_interval);
665 embedder_api_.OnVsync(engine_, baton, next.count(),
666 (next + frame_interval).count());
667 }

Referenced by Run().

## ◆ OnWindowStateEvent()

void flutter::FlutterWindowsEngine::OnWindowStateEvent | ( | HWND | hwnd,
|  | WindowStateEvent | event
| ) |  |

Definition at line 1065 of file flutter_windows_engine.cc.

1066 {
1067 lifecycle_manager_->OnWindowStateEvent(hwnd, event);
1068 }

Referenced by flutter::FlutterWindowsView::OnWindowStateEvent(), and flutter::FlutterWindowsView::~FlutterWindowsView().

## ◆ PostRasterThreadTask()

bool flutter::FlutterWindowsEngine::PostRasterThreadTask | ( | fml::closure | callback | ) | const
| virtual

Definition at line 950 of file flutter_windows_engine.cc.

950 {
951 struct Captures {
952 fml::closure callback;
953 };
954 auto captures = new Captures();
955 captures->callback = std::move(callback);
956 if (embedder_api_.PostRenderThreadTask(
957 engine_,
958 [](void* opaque) {
959 auto captures = reinterpret_cast<Captures*>(opaque);
960 captures->callback();
961 delete captures;
962 },
963 captures) == kSuccess) {
964 return true;
965 }
966 delete captures;
967 return false;
968 }

References callback.

Referenced by flutter::FlutterWindowsTextureRegistrar::UnregisterTexture().

## ◆ ProcessExternalWindowMessage()

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

Definition at line 1070 of file flutter_windows_engine.cc.

1074 {
1075 if (lifecycle_manager_) {
1076 return lifecycle_manager_->ExternalWindowMessage(hwnd, message, wparam,
1077 lparam);
1078 }
1079 return std::nullopt;
1080 }

References message.

Referenced by FlutterDesktopEngineProcessExternalWindowMessage().

## ◆ RegisterExternalTexture()

bool flutter::FlutterWindowsEngine::RegisterExternalTexture | ( | int64_t | texture_id | ) |

Definition at line 934 of file flutter_windows_engine.cc.

934 {
935 return (embedder_api_.RegisterExternalTexture(engine_, texture_id) ==
936 kSuccess);
937 }

## ◆ ReloadSystemFonts()

void flutter::FlutterWindowsEngine::ReloadSystemFonts | ( |  | ) |

Definition at line 802 of file flutter_windows_engine.cc.

802 {
803 embedder_api_.ReloadSystemFonts(engine_);
804 }

Referenced by FlutterDesktopEngineReloadSystemFonts().

## ◆ RemoveView()

void flutter::FlutterWindowsEngine::RemoveView | ( | FlutterViewId | view_id | ) |
| virtual

Definition at line 598 of file flutter_windows_engine.cc.

598 {
599 FML_DCHECK(running());
600
601 // Notify the engine to stop rendering to the view if it isn't the implicit
602 // view. The engine and framework assume the implicit view always exists and
603 // can continue presenting.
604 if (view_id != kImplicitViewId) {
605 struct Captures {
606 fml::AutoResetWaitableEvent latch;
607 bool removed;
608 };
609 Captures captures = {};
610
611 FlutterRemoveViewInfo info = {};
612 info.struct_size = sizeof(FlutterRemoveViewInfo);
613 info.view_id = view_id;
614 info.user_data = &captures;
615 info.remove_view_callback = [](const FlutterRemoveViewResult* result) {
616 // This is invoked on an engine thread. If
617 // |FlutterRemoveViewResult.removed| is `true`, the engine guarantees the
618 // view won't be presented.
619 Captures* captures = reinterpret_cast<Captures*>(result->user_data);
620 captures->removed = result->removed;
621 captures->latch.Signal();
622 };
623
624 FlutterEngineResult result = embedder_api_.RemoveView(engine_, &info);
625 if (result != kSuccess) {
626 FML_LOG(ERROR) << "Starting the remove view operation failed. "
627 "FlutterEngineRemoveView "
628 "returned an unexpected result: "
629 << result
630 << ". This indicates a bug in the Windows embedder.";
631 FML_DCHECK(false);
632 return;
633 }
634
635 // Block the platform thread until the engine has removed the view.
636 // TODO(loicsharma): This blocks the platform thread eagerly and can
637 // cause unnecessary delay in input processing. Instead, this should block
638 // lazily only when an operation needs the view.
639 // https://github.com/flutter/flutter/issues/146248
640 captures.latch.Wait();
641
642 if (!captures.removed) {
643 // Removing the view failed. This is unexpected and indicates a bug in the
644 // Windows embedder.
645 FML_LOG(ERROR) << "FlutterEngineRemoveView failed to remove view";
646 return;
647 }
648 }
649
650 {
651 // The engine no longer presents to the view. Remove the view from the
652 // embedder.
653 std::unique_lock write_lock(views_mutex_);
654
655 FML_DCHECK(views_.find(view_id) != views_.end());
656 views_.erase(view_id);
657 }
658 }
flutter::kImplicitViewId
constexpr FlutterViewId kImplicitViewId
Definition: flutter_windows_engine.h:56

References flutter::kImplicitViewId.

## ◆ RequestApplicationQuit()

void flutter::FlutterWindowsEngine::RequestApplicationQuit | ( | HWND | hwnd,
|  | WPARAM | wparam,
|  | LPARAM | lparam,
|  | AppExitType | exit_type
| ) |  |

Definition at line 1040 of file flutter_windows_engine.cc.

1043 {
1044 platform_handler_->RequestAppExit(hwnd, wparam, lparam, exit_type, 0);
1045 }

## ◆ Run() [1/2]

bool flutter::FlutterWindowsEngine::Run | ( |  | ) |

Definition at line 268 of file flutter_windows_engine.cc.

268 {
269 return Run("");
270 }
flutter::FlutterWindowsEngine::Run
bool Run()
Definition: flutter_windows_engine.cc:268

Referenced by FlutterDesktopEngineRun().

## ◆ Run() [2/2]

bool flutter::FlutterWindowsEngine::Run | ( | std::string_view | entrypoint | ) |

Definition at line 272 of file flutter_windows_engine.cc.

272 {
273 if (!project_->HasValidPaths()) {
274 FML_LOG(ERROR) << "Missing or unresolvable paths to assets.";
275 return false;
276 }
277 std::string assets_path_string = project_->assets_path().string();
278 std::string icu_path_string = project_->icu_path().string();
279 if (embedder_api_.RunsAOTCompiledDartCode()) {
280 aot_data_ = project_->LoadAotData(embedder_api_);
281 if (!aot_data_) {
282 FML_LOG(ERROR) << "Unable to start engine without AOT data.";
283 return false;
284 }
285 }
286
287 // FlutterProjectArgs is expecting a full argv, so when processing it for
288 // flags the first item is treated as the executable and ignored. Add a dummy
289 // value so that all provided arguments are used.
290 std::string executable_name = GetExecutableName();
291 std::vector<const char*> argv = {executable_name.c_str()};
292 std::vector<std::string> switches = project_->GetSwitches();
293 std::transform(
294 switches.begin(), switches.end(), std::back_inserter(argv),
295 [](const std::string& arg) -> const char* { return arg.c_str(); });
296
297 const std::vector<std::string>& entrypoint_args =
298 project_->dart_entrypoint_arguments();
299 std::vector<const char*> entrypoint_argv;
300 std::transform(
301 entrypoint_args.begin(), entrypoint_args.end(),
302 std::back_inserter(entrypoint_argv),
303 [](const std::string& arg) -> const char* { return arg.c_str(); });
304
305 // Configure task runners.
306 FlutterTaskRunnerDescription platform_task_runner = {};
307 platform_task_runner.struct_size = sizeof(FlutterTaskRunnerDescription);
308 platform_task_runner.user_data = task_runner_.get();
309 platform_task_runner.runs_task_on_current_thread_callback =
310 [](void* user_data) -> bool {
311 return static_cast<TaskRunner*>(user_data)->RunsTasksOnCurrentThread();
312 };
313 platform_task_runner.post_task_callback = [](FlutterTask task,
314 uint64_t target_time_nanos,
315 void* user_data) -> void {
316 static_cast<TaskRunner*>(user_data)->PostFlutterTask(task,
317 target_time_nanos);
318 };
319 FlutterCustomTaskRunners custom_task_runners = {};
320 custom_task_runners.struct_size = sizeof(FlutterCustomTaskRunners);
321 custom_task_runners.platform_task_runner = &platform_task_runner;
322 custom_task_runners.thread_priority_setter =
323 &WindowsPlatformThreadPrioritySetter;
324
325 if (project_->ui_thread_policy() !=
326 FlutterUIThreadPolicy::RunOnSeparateThread) {
327 custom_task_runners.ui_task_runner = &platform_task_runner;
328 } else {
329 FML_LOG(WARNING) << "Running with unmerged platform and UI threads. This "
330 "will be removed in future.";
331 }
332
333 FlutterProjectArgs args = {};
334 args.struct_size = sizeof(FlutterProjectArgs);
335 args.shutdown_dart_vm_when_done = true;
336 args.assets_path = assets_path_string.c_str();
337 args.icu_data_path = icu_path_string.c_str();
338 args.command_line_argc = static_cast<int>(argv.size());
339 args.command_line_argv = argv.empty() ? nullptr : argv.data();
340 args.engine_id = reinterpret_cast<int64_t>(this);
341
342 // Fail if conflicting non-default entrypoints are specified in the method
343 // argument and the project.
344 //
345 // TODO(cbracken): https://github.com/flutter/flutter/issues/109285
346 // The entrypoint method parameter should eventually be removed from this
347 // method and only the entrypoint specified in project_ should be used.
348 if (!project_->dart_entrypoint().empty() && !entrypoint.empty() &&
349 project_->dart_entrypoint() != entrypoint) {
350 FML_LOG(ERROR) << "Conflicting entrypoints were specified in "
351 "FlutterDesktopEngineProperties.dart_entrypoint and "
352 "FlutterDesktopEngineRun(engine, entry_point). ";
353 return false;
354 }
355 if (!entrypoint.empty()) {
356 args.custom_dart_entrypoint = entrypoint.data();
357 } else if (!project_->dart_entrypoint().empty()) {
358 args.custom_dart_entrypoint = project_->dart_entrypoint().c_str();
359 }
360 args.dart_entrypoint_argc = static_cast<int>(entrypoint_argv.size());
361 args.dart_entrypoint_argv =
362 entrypoint_argv.empty() ? nullptr : entrypoint_argv.data();
363 args.platform_message_callback =
364 [](const FlutterPlatformMessage* engine_message,
365 void* user_data) -> void {
366 auto host = static_cast<FlutterWindowsEngine*>(user_data);
367 return host->HandlePlatformMessage(engine_message);
368 };
369 args.vsync_callback = [](void* user_data, intptr_t baton) -> void {
370 auto host = static_cast<FlutterWindowsEngine*>(user_data);
371 host->OnVsync(baton);
372 };
373 args.on_pre_engine_restart_callback = [](void* user_data) {
374 auto host = static_cast<FlutterWindowsEngine*>(user_data);
375 host->OnPreEngineRestart();
376 };
377 args.update_semantics_callback2 = [](const FlutterSemanticsUpdate2* update,
378 void* user_data) {
379 auto host = static_cast<FlutterWindowsEngine*>(user_data);
380
381 auto view = host->view(update->view_id);
382 if (!view) {
383 return;
384 }
385
386 auto accessibility_bridge = view->accessibility_bridge().lock();
387 if (!accessibility_bridge) {
388 return;
389 }
390
391 for (size_t i = 0; i < update->node_count; i++) {
392 const FlutterSemanticsNode2* node = update->nodes[i];
393 accessibility_bridge->AddFlutterSemanticsNodeUpdate(*node);
394 }
395
396 for (size_t i = 0; i < update->custom_action_count; i++) {
397 const FlutterSemanticsCustomAction2* action = update->custom_actions[i];
398 accessibility_bridge->AddFlutterSemanticsCustomActionUpdate(*action);
399 }
400
401 accessibility_bridge->CommitUpdates();
402 };
403 args.root_isolate_create_callback = [](void* user_data) {
404 auto host = static_cast<FlutterWindowsEngine*>(user_data);
405 if (host->root_isolate_create_callback_) {
406 host->root_isolate_create_callback_();
407 }
408 };
409 args.channel_update_callback = [](const FlutterChannelUpdate* update,
410 void* user_data) {
411 auto host = static_cast<FlutterWindowsEngine*>(user_data);
412 if (SAFE_ACCESS(update, channel, nullptr) != nullptr) {
413 std::string channel_name(update->channel);
414 host->OnChannelUpdate(std::move(channel_name),
415 SAFE_ACCESS(update, listening, false));
416 }
417 };
418 args.view_focus_change_request_callback =
419 [](const FlutterViewFocusChangeRequest* request, void* user_data) {
420 auto host = static_cast<FlutterWindowsEngine*>(user_data);
421 host->OnViewFocusChangeRequest(request);
422 };
423
424 args.custom_task_runners = &custom_task_runners;
425
426 if (!platform_view_plugin_) {
427 platform_view_plugin_ = std::make_unique<PlatformViewPlugin>(
428 messenger_wrapper_.get(), task_runner_.get());
429 }
430 if (egl_manager_) {
431 auto resolver = [](const char* name) -> void* {
432 return reinterpret_cast<void*>(::eglGetProcAddress(name));
433 };
434
435 // TODO(schectman) Pass the platform view manager to the compositor
436 // constructors: https://github.com/flutter/flutter/issues/143375
437 compositor_ =
438 std::make_unique<CompositorOpenGL>(this, resolver, enable_impeller_);
439 } else {
440 compositor_ = std::make_unique<CompositorSoftware>();
441 }
442
443 FlutterCompositor compositor = {};
444 compositor.struct_size = sizeof(FlutterCompositor);
445 compositor.user_data = this;
446 compositor.create_backing_store_callback =
447 [](const FlutterBackingStoreConfig* config,
448 FlutterBackingStore* backing_store_out, void* user_data) -> bool {
449 auto host = static_cast<FlutterWindowsEngine*>(user_data);
450
451 return host->compositor_->CreateBackingStore(*config, backing_store_out);
452 };
453
454 compositor.collect_backing_store_callback =
455 [](const FlutterBackingStore* backing_store, void* user_data) -> bool {
456 auto host = static_cast<FlutterWindowsEngine*>(user_data);
457
458 return host->compositor_->CollectBackingStore(backing_store);
459 };
460
461 compositor.present_view_callback =
462 [](const FlutterPresentViewInfo* info) -> bool {
463 auto host = static_cast<FlutterWindowsEngine*>(info->user_data);
464
465 return host->Present(info);
466 };
467 args.compositor = &compositor;
468
469 if (aot_data_) {
470 args.aot_data = aot_data_.get();
471 }
472
473 // The platform thread creates OpenGL contexts. These
474 // must be released to be used by the engine's threads.
475 FML_DCHECK(!egl_manager_ || !egl_manager_->HasContextCurrent());
476
477 FlutterRendererConfig renderer_config;
478
479 if (enable_impeller_) {
480 // Impeller does not support a Software backend. Avoid falling back and
481 // confusing the engine on which renderer is selected.
482 if (!egl_manager_) {
483 FML_LOG(ERROR) << "Could not create surface manager. Impeller backend "
484 "does not support software rendering.";
485 return false;
486 }
487 renderer_config = GetOpenGLRendererConfig();
488 } else {
489 renderer_config =
490 egl_manager_ ? GetOpenGLRendererConfig() : GetSoftwareRendererConfig();
491 }
492
493 auto result = embedder_api_.Run(FLUTTER_ENGINE_VERSION, &renderer_config,
494 &args, this, &engine_);
495 if (result != kSuccess || engine_ == nullptr) {
496 FML_LOG(ERROR) << "Failed to start Flutter engine: error " << result;
497 return false;
498 }
499
500 display_manager_->UpdateDisplays();
501
502 SendSystemLocales();
503
504 settings_plugin_->StartWatching();
505 settings_plugin_->SendSettings();
506
507 InitializeKeyboard();
508
509 return true;
510 }
flutter::FlutterWindowsEngine::GetExecutableName
std::string GetExecutableName() const
Definition: flutter_windows_engine.cc:1003
flutter::FlutterWindowsView::accessibility_bridge
std::weak_ptr< AccessibilityBridgeWindows > accessibility_bridge()
Definition: flutter_windows_view.h:239
flutter::FlutterUIThreadPolicy::RunOnSeparateThread
@ RunOnSeparateThread
flutter::WindowsPlatformThreadPrioritySetter
static void WindowsPlatformThreadPrioritySetter(FlutterThreadPriority priority)
Definition: flutter_windows_engine.h:62

References flutter::FlutterWindowsView::accessibility_bridge(), action, HandlePlatformMessage(), OnPreEngineRestart(), OnViewFocusChangeRequest(), OnVsync(), RunOnSeparateThread, user_data, view(), and flutter::WindowsPlatformThreadPrioritySetter().

## ◆ running()

virtual bool flutter::FlutterWindowsEngine::running | ( |  | ) | const
| inline virtual

Definition at line 125 of file flutter_windows_engine.h.

125 { return engine_ != nullptr; }

Referenced by flutter::HostWindow::CreateRegularWindow(), and FlutterDesktopEngineDestroy().

## ◆ ScheduleFrame()

void flutter::FlutterWindowsEngine::ScheduleFrame | ( |  | ) |

Definition at line 806 of file flutter_windows_engine.cc.

806 {
807 embedder_api_.ScheduleFrame(engine_);
808 }

Referenced by flutter::FlutterWindowsView::ForceRedraw().

## ◆ semantics_enabled()

bool flutter::FlutterWindowsEngine::semantics_enabled | ( |  | ) | const
| inline

Definition at line 258 of file flutter_windows_engine.h.

258 { return semantics_enabled_; }

Referenced by flutter::AccessibilityPlugin::Announce().

## ◆ SendKeyEvent()

void flutter::FlutterWindowsEngine::SendKeyEvent | ( | const FlutterKeyEvent & | event,
|  | FlutterKeyEventCallback | callback,
|  | void * | user_data
| ) |  |

Definition at line 732 of file flutter_windows_engine.cc.

734 {
735 if (engine_) {
736 embedder_api_.SendKeyEvent(engine_, &event, callback, user_data);
737 }
738 }

## ◆ SendPlatformMessage()

bool flutter::FlutterWindowsEngine::SendPlatformMessage | ( | const char * | channel,
|  | const uint8_t * | message,
|  | const size_t | message_size,
|  | const FlutterDesktopBinaryReply | reply,
|  | void * | user_data
| ) |  |

Definition at line 747 of file flutter_windows_engine.cc.

752 {
753 FlutterPlatformMessageResponseHandle* response_handle = nullptr;
754 if (reply != nullptr && user_data != nullptr) {
755 FlutterEngineResult result =
756 embedder_api_.PlatformMessageCreateResponseHandle(
757 engine_, reply, user_data, &response_handle);
758 if (result != kSuccess) {
759 FML_LOG(ERROR) << "Failed to create response handle";
760 return false;
761 }
762 }
763
764 FlutterPlatformMessage platform_message = {
765 sizeof(FlutterPlatformMessage),
766 channel,
767 message,
768 message_size,
769 response_handle,
770 };
771
772 FlutterEngineResult message_result =
773 embedder_api_.SendPlatformMessage(engine_, &platform_message);
774 if (response_handle != nullptr) {
775 embedder_api_.PlatformMessageReleaseResponseHandle(engine_,
776 response_handle);
777 }
778 return message_result == kSuccess;
779 }

References user_data.

Referenced by FlutterDesktopMessengerSendWithReply().

## ◆ SendPlatformMessageResponse()

void flutter::FlutterWindowsEngine::SendPlatformMessageResponse | ( | const FlutterDesktopMessageResponseHandle * | handle,
|  | const uint8_t * | data,
|  | size_t | data_length
| ) |  |

Definition at line 781 of file flutter_windows_engine.cc.

784 {
785 embedder_api_.SendPlatformMessageResponse(engine_, handle, data, data_length);
786 }

Referenced by FlutterDesktopMessengerSendResponse().

## ◆ SendPointerEvent()

void flutter::FlutterWindowsEngine::SendPointerEvent | ( | const FlutterPointerEvent & | event | ) |

Definition at line 726 of file flutter_windows_engine.cc.

726 {
727 if (engine_) {
728 embedder_api_.SendPointerEvent(engine_, &event, 1);
729 }
730 }

## ◆ SendViewFocusEvent()

void flutter::FlutterWindowsEngine::SendViewFocusEvent | ( | const FlutterViewFocusEvent & | event | ) |

Definition at line 740 of file flutter_windows_engine.cc.

741 {
742 if (engine_) {
743 embedder_api_.SendViewFocusEvent(engine_, &event);
744 }
745 }

## ◆ SendWindowMetricsEvent()

void flutter::FlutterWindowsEngine::SendWindowMetricsEvent | ( | const FlutterWindowMetricsEvent & | event | ) |

Definition at line 719 of file flutter_windows_engine.cc.

720 {
721 if (engine_) {
722 embedder_api_.SendWindowMetricsEvent(engine_, &event);
723 }
724 }

Referenced by flutter::FlutterWindowsView::SendInitialBounds().

## ◆ SetFlutterCursor()

void flutter::FlutterWindowsEngine::SetFlutterCursor | ( | HCURSOR | cursor | ) | const

Definition at line 1087 of file flutter_windows_engine.cc.

1087 {
1088 windows_proc_table_->SetCursor(cursor);
1089 }

## ◆ SetNextFrameCallback()

void flutter::FlutterWindowsEngine::SetNextFrameCallback | ( | fml::closure | callback | ) |

Definition at line 810 of file flutter_windows_engine.cc.

810 {
811 next_frame_callback_ = std::move(callback);
812
813 embedder_api_.SetNextFrameCallback(
814 engine_,
815 [](void* user_data) {
816 // Embedder callback runs on raster thread. Switch back to platform
817 // thread.
818 FlutterWindowsEngine* self =
819 static_cast<FlutterWindowsEngine*>(user_data);
820
821 self->task_runner_->PostTask(std::move(self->next_frame_callback_));
822 },
823 this);
824 }

Referenced by FlutterDesktopEngineSetNextFrameCallback().

## ◆ SetRootIsolateCreateCallback()

void flutter::FlutterWindowsEngine::SetRootIsolateCreateCallback | ( | const fml::closure & | callback | ) |
| inline

Definition at line 278 of file flutter_windows_engine.h.

278 {
279 root_isolate_create_callback_ = callback;
280 }

References callback.

## ◆ SetSwitches()

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

Definition at line 263 of file flutter_windows_engine.cc.

264 {
265 project_->SetSwitches(switches);
266 }

References SetSwitches().

Referenced by SetSwitches().

## ◆ Stop()

bool flutter::FlutterWindowsEngine::Stop | ( |  | ) |
| virtual

Definition at line 512 of file flutter_windows_engine.cc.

512 {
513 if (engine_) {
514 window_manager_->OnEngineShutdown();
515 for (const auto& [callback, registrar] :
516 plugin_registrar_destruction_callbacks_) {
517 callback(registrar);
518 }
519 FlutterEngineResult result = embedder_api_.Shutdown(engine_);
520 engine_ = nullptr;
521 return (result == kSuccess);
522 }
523 return false;
524 }

Referenced by FlutterDesktopEngineDestroy().

## ◆ task_runner()

TaskRunner* flutter::FlutterWindowsEngine::task_runner | ( |  | ) |
| inline

Definition at line 170 of file flutter_windows_engine.h.

170 { return task_runner_.get(); }

Referenced by flutter::FlutterWindowsTextureRegistrar::MarkTextureFrameAvailable(), flutter::FlutterWindowsView::OnFramePresented(), flutter::FlutterWindowsView::OnWindowSizeChanged(), and flutter::FlutterWindowsTextureRegistrar::UnregisterTexture().

## ◆ text_input_plugin()

TextInputPlugin* flutter::FlutterWindowsEngine::text_input_plugin | ( |  | ) |
| inline

Definition at line 203 of file flutter_windows_engine.h.

203 { return text_input_plugin_.get(); }

## ◆ texture_registrar()

FlutterWindowsTextureRegistrar* flutter::FlutterWindowsEngine::texture_registrar | ( |  | ) |
| inline

Definition at line 174 of file flutter_windows_engine.h.

174 {
175 return texture_registrar_.get();
176 }

Referenced by FlutterDesktopRegistrarGetTextureRegistrar().

## ◆ UnregisterExternalTexture()

bool flutter::FlutterWindowsEngine::UnregisterExternalTexture | ( | int64_t | texture_id | ) |

Definition at line 939 of file flutter_windows_engine.cc.

939 {
940 return (embedder_api_.UnregisterExternalTexture(engine_, texture_id) ==
941 kSuccess);
942 }

## ◆ UpdateAccessibilityFeatures()

void flutter::FlutterWindowsEngine::UpdateAccessibilityFeatures | ( |  | ) |

Definition at line 1017 of file flutter_windows_engine.cc.

1017 {
1018 UpdateHighContrastMode();
1019 }
flutter::FlutterWindowsEngine::UpdateHighContrastMode
void UpdateHighContrastMode()
Definition: flutter_windows_engine.cc:1021

Referenced by flutter::HostWindow::CreateRegularWindow(), and flutter::testing::TEST_F().

## ◆ UpdateDisplay()

void flutter::FlutterWindowsEngine::UpdateDisplay | ( | const std::vector< FlutterEngineDisplay > & | displays | ) |

Definition at line 710 of file flutter_windows_engine.cc.

711 {
712 if (engine_) {
713 embedder_api_.NotifyDisplayUpdate(engine_,
714 kFlutterEngineDisplaysUpdateTypeStartup,
715 displays.data(), displays.size());
716 }
717 }
displays
std::vector< FlutterEngineDisplay > * displays
Definition: display_manager.cc:19

Referenced by flutter::DisplayManagerWin32::UpdateDisplays().

## ◆ UpdateFlutterCursor()

void flutter::FlutterWindowsEngine::UpdateFlutterCursor | ( | const std::string & | cursor_name | ) | const

Definition at line 1082 of file flutter_windows_engine.cc.

1083 {
1084 SetFlutterCursor(GetCursorByName(cursor_name));
1085 }
flutter::FlutterWindowsEngine::SetFlutterCursor
void SetFlutterCursor(HCURSOR cursor) const
Definition: flutter_windows_engine.cc:1087

## ◆ UpdateHighContrastMode()

void flutter::FlutterWindowsEngine::UpdateHighContrastMode | ( |  | ) |

Definition at line 1021 of file flutter_windows_engine.cc.

1021 {
1022 high_contrast_enabled_ = windows_proc_table_->GetHighContrastEnabled();
1023
1024 SendAccessibilityFeatures();
1025 settings_plugin_->UpdateHighContrastMode(high_contrast_enabled_);
1026 }

Referenced by flutter::FlutterWindowsView::OnHighContrastChanged().

## ◆ UpdateSemanticsEnabled()

void flutter::FlutterWindowsEngine::UpdateSemanticsEnabled | ( | bool | enabled | ) |

Definition at line 986 of file flutter_windows_engine.cc.

986 {
987 if (engine_ && semantics_enabled_ != enabled) {
988 std::shared_lock read_lock(views_mutex_);
989
990 semantics_enabled_ = enabled;
991 embedder_api_.UpdateSemanticsEnabled(engine_, enabled);
992 for (auto iterator = views_.begin(); iterator != views_.end(); iterator++) {
993 iterator->second->UpdateSemanticsEnabled(enabled);
994 }
995 }
996 }

Referenced by flutter::FlutterWindowsView::OnUpdateSemanticsEnabled(), and flutter::testing::TEST_F().

## ◆ view()

FlutterWindowsView * flutter::FlutterWindowsEngine::view | ( | FlutterViewId | view_id | ) | const

Definition at line 688 of file flutter_windows_engine.cc.

688 {
689 std::shared_lock read_lock(views_mutex_);
690
691 auto iterator = views_.find(view_id);
692 if (iterator == views_.end()) {
693 return nullptr;
694 }
695
696 return iterator->second;
697 }

Referenced by flutter::AccessibilityPlugin::Announce(), FlutterDesktopPluginRegistrarGetView(), FlutterDesktopPluginRegistrarGetViewById(), InternalFlutterWindows_WindowManager_GetTopLevelWindowHandle(), and Run().

## ◆ window_manager()

WindowManager* flutter::FlutterWindowsEngine::window_manager | ( |  | ) |
| inline

Definition at line 327 of file flutter_windows_engine.h.

327 { return window_manager_.get(); }

Referenced by InternalFlutterWindows_WindowManager_CreateRegularWindow(), InternalFlutterWindows_WindowManager_HasTopLevelWindows(), and InternalFlutterWindows_WindowManager_Initialize().

## ◆ window_proc_delegate_manager()

WindowProcDelegateManager* flutter::FlutterWindowsEngine::window_proc_delegate_manager | ( |  | ) |
| inline

Definition at line 182 of file flutter_windows_engine.h.

182 {
183 return window_proc_delegate_manager_.get();
184 }

Referenced by FlutterDesktopPluginRegistrarRegisterTopLevelWindowProcDelegate(), and FlutterDesktopPluginRegistrarUnregisterTopLevelWindowProcDelegate().

## ◆ windows_proc_table()

std::shared_ptr<WindowsProcTable> flutter::FlutterWindowsEngine::windows_proc_table | ( |  | ) |
| inline

Definition at line 316 of file flutter_windows_engine.h.

316 {
317 return windows_proc_table_;
318 }

Referenced by flutter::HostWindow::CreateRegularWindow(), CreateViewController(), flutter::HostWindow::SetConstraints(), and flutter::HostWindow::SetContentSize().

## Friends And Related Function Documentation

## ◆ EngineModifier

friend class EngineModifier
| friend

Definition at line 365 of file flutter_windows_engine.h.

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

- shell/platform/windows/flutter_windows_engine.h
- shell/platform/windows/flutter_windows_engine.cc