| 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 ()
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 91 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 150 of file flutter_windows_engine.cc.

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

243 {
244 messenger_->SetEngine(nullptr);
245 Stop();
246 }
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
| ) |  |
| protectedvirtual

Definition at line 902 of file flutter_windows_engine.cc.

905 {
906 auto keyboard_key_handler = std::make_unique<KeyboardKeyHandler>(messenger);
907 keyboard_key_handler->AddDelegate(
908 std::make_unique<KeyboardKeyEmbedderHandler>(
909 [this](const FlutterKeyEvent& event, FlutterKeyEventCallback callback,
910 void* user_data) {
911 return SendKeyEvent(event, callback, user_data);
912 },
913 get_key_state, map_vk_to_scan));
914 keyboard_key_handler->AddDelegate(
915 std::make_unique<KeyboardKeyChannelHandler>(messenger));
916 keyboard_key_handler->InitKeyboardChannel();
917 return keyboard_key_handler;
918 }
flutter::FlutterWindowsEngine::messenger
FlutterDesktopMessengerRef messenger()
Definition: flutter_windows_engine.h:156
flutter::FlutterWindowsEngine::keyboard_key_handler
KeyboardHandlerBase * keyboard_key_handler()
Definition: flutter_windows_engine.h:192
flutter::FlutterWindowsEngine::SendKeyEvent
void SendKeyEvent(const FlutterKeyEvent &event, FlutterKeyEventCallback callback, void *user_data)
Definition: flutter_windows_engine.cc:723

References callback, and user_data.

## ◆ CreateTextInputPlugin()

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

Definition at line 920 of file flutter_windows_engine.cc.

921 {
922 return std::make_unique<TextInputPlugin>(messenger, this);
923 }

## ◆ 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:124
flutter::FlutterWindowsView::CreateRenderSurface
void CreateRenderSurface()
Definition: flutter_windows_view.cc:717
flutter::FlutterWindowsView::UpdateSemanticsEnabled
virtual void UpdateSemanticsEnabled(bool enabled)
Definition: flutter_windows_view.cc:816
flutter::FlutterWindowsView::IsImplicitView
bool IsImplicitView() const
Definition: flutter_windows_view.cc:713
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 961 of file flutter_windows_engine.cc.

965 {
966 FlutterSendSemanticsActionInfo info{
967 .struct_size = sizeof(FlutterSendSemanticsActionInfo),
968 .view_id = view_id,
969 .node_id = target,
970 .action = action,
971 .data = data.GetMapping(),
972 .data_length = data.GetSize(),
973 };
974 return (embedder_api_.SendSemanticsAction(engine_, &info));
975 }
action
int action
Definition: keyboard_key_handler_unittests.cc:116

References action.

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

## ◆ egl_manager()

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

Definition at line 172 of file flutter_windows_engine.h.

172 { 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 248 of file flutter_windows_engine.cc.

248 {
249 return reinterpret_cast<FlutterWindowsEngine*>(engine_id);
250 }

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 994 of file flutter_windows_engine.cc.

994 {
995 std::pair<bool, std::string> result = fml::paths::GetExecutablePath();
996 if (result.first) {
997 const std::string& executable_path = result.second;
998 size_t last_separator = executable_path.find_last_of("/\\");
999 if (last_separator == std::string::npos ||
1000 last_separator == executable_path.size() - 1) {
1001 return executable_path;
1002 }
1003 return executable_path.substr(last_separator + 1);
1004 }
1005 return "Flutter";
1006 }

## ◆ 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 855 of file flutter_windows_engine.cc.

856 {
857 std::shared_lock read_lock(views_mutex_);
858 auto const iterator =
859 std::find_if(views_.begin(), views_.end(), [hwnd](auto const& pair) {
860 FlutterWindowsView* const view = pair.second;
861 return GetAncestor(view->GetWindowHandle(), GA_ROOT) == hwnd;
862 });
863 if (iterator != views_.end()) {
864 return iterator->second;
865 }
866 return nullptr;
867 }

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

## ◆ HandlePlatformMessage()

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

Definition at line 779 of file flutter_windows_engine.cc.

780 {
781 if (engine_message->struct_size != sizeof(FlutterPlatformMessage)) {
782 FML_LOG(ERROR) << "Invalid message size received. Expected: "
783 << sizeof(FlutterPlatformMessage) << " but received "
784 << engine_message->struct_size;
785 return;
786 }
787
788 auto message = ConvertToDesktopMessage(*engine_message);
789
790 message_dispatcher_->HandleMessage(message, [this] {}, [this] {});
791 }
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 259 of file flutter_windows_engine.h.

259 { return high_contrast_enabled_; }

## ◆ keyboard_key_handler()

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

Definition at line 192 of file flutter_windows_engine.h.

192 {
193 return keyboard_key_handler_.get();
194 }

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

## ◆ lifecycle_manager()

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

Definition at line 304 of file flutter_windows_engine.h.

304 {
305 return lifecycle_manager_.get();
306 }

## ◆ MarkExternalTextureFrameAvailable()

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

Definition at line 935 of file flutter_windows_engine.cc.

936 {
937 return (embedder_api_.MarkExternalTextureFrameAvailable(
938 engine_, texture_id) == kSuccess);
939 }
texture_id
uint32_t texture_id
Definition: compositor_opengl.cc:20

## ◆ message_dispatcher()

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

Definition at line 158 of file flutter_windows_engine.h.

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

Referenced by FlutterDesktopMessengerSetCallback().

## ◆ messenger()

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

Definition at line 156 of file flutter_windows_engine.h.

156 { return messenger_->ToRef(); }

Referenced by FlutterDesktopEngineGetMessenger(), and FlutterDesktopPluginRegistrarGetMessenger().

## ◆ messenger_wrapper()

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

Definition at line 164 of file flutter_windows_engine.h.

164 { return messenger_wrapper_.get(); }

## ◆ OnChannelUpdate()

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

Definition at line 1079 of file flutter_windows_engine.cc.

1079 {
1080 if (name == "flutter/platform" && listening) {
1081 lifecycle_manager_->BeginProcessingExit();
1082 } else if (name == "flutter/lifecycle" && listening) {
1083 lifecycle_manager_->BeginProcessingLifecycle();
1084 }
1085 }

## ◆ OnDwmCompositionChanged()

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

Definition at line 1045 of file flutter_windows_engine.cc.

1045 {
1046 std::shared_lock read_lock(views_mutex_);
1047
1048 for (auto iterator = views_.begin(); iterator != views_.end(); iterator++) {
1049 iterator->second->OnDwmCompositionChanged();
1050 }
1051 }

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

## ◆ OnPreEngineRestart()

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

Definition at line 989 of file flutter_windows_engine.cc.

989 {
990 // Reset the keyboard's state on hot restart.
991 InitializeKeyboard();
992 }

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 1038 of file flutter_windows_engine.cc.

1041 {
1042 lifecycle_manager_->Quit(hwnd, wparam, lparam, exit_code);
1043 }

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

## ◆ OnViewFocusChangeRequest()

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

Definition at line 1087 of file flutter_windows_engine.cc.

1088 {
1089 std::shared_lock read_lock(views_mutex_);
1090
1091 auto iterator = views_.find(request->view_id);
1092 if (iterator == views_.end()) {
1093 return;
1094 }
1095
1096 FlutterWindowsView* view = iterator->second;
1097 view->Focus();
1098 }
flutter::FlutterWindowsView::Focus
virtual bool Focus()
Definition: flutter_windows_view.cc:836

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 1053 of file flutter_windows_engine.cc.

1054 {
1055 lifecycle_manager_->OnWindowStateEvent(hwnd, event);
1056 }

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

## ◆ PostRasterThreadTask()

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

Definition at line 941 of file flutter_windows_engine.cc.

941 {
942 struct Captures {
943 fml::closure callback;
944 };
945 auto captures = new Captures();
946 captures->callback = std::move(callback);
947 if (embedder_api_.PostRenderThreadTask(
948 engine_,
949 [](void* opaque) {
950 auto captures = reinterpret_cast<Captures*>(opaque);
951 captures->callback();
952 delete captures;
953 },
954 captures) == kSuccess) {
955 return true;
956 }
957 delete captures;
958 return false;
959 }

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 1058 of file flutter_windows_engine.cc.

1062 {
1063 if (lifecycle_manager_) {
1064 return lifecycle_manager_->ExternalWindowMessage(hwnd, message, wparam,
1065 lparam);
1066 }
1067 return std::nullopt;
1068 }

References message.

Referenced by FlutterDesktopEngineProcessExternalWindowMessage().

## ◆ RegisterExternalTexture()

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

Definition at line 925 of file flutter_windows_engine.cc.

925 {
926 return (embedder_api_.RegisterExternalTexture(engine_, texture_id) ==
927 kSuccess);
928 }

## ◆ ReloadSystemFonts()

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

Definition at line 793 of file flutter_windows_engine.cc.

793 {
794 embedder_api_.ReloadSystemFonts(engine_);
795 }

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 1031 of file flutter_windows_engine.cc.

1034 {
1035 platform_handler_->RequestAppExit(hwnd, wparam, lparam, exit_type, 0);
1036 }

## ◆ Run() [1/2]

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

Definition at line 257 of file flutter_windows_engine.cc.

257 {
258 return Run("");
259 }
flutter::FlutterWindowsEngine::Run
bool Run()
Definition: flutter_windows_engine.cc:257

Referenced by FlutterDesktopEngineRun().

## ◆ Run() [2/2]

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

Definition at line 261 of file flutter_windows_engine.cc.

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

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

## ◆ running()

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

Definition at line 124 of file flutter_windows_engine.h.

124 { return engine_ != nullptr; }

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

## ◆ ScheduleFrame()

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

Definition at line 797 of file flutter_windows_engine.cc.

797 {
798 embedder_api_.ScheduleFrame(engine_);
799 }

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

## ◆ semantics_enabled()

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

Definition at line 250 of file flutter_windows_engine.h.

250 { return semantics_enabled_; }

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

## ◆ SendKeyEvent()

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

Definition at line 723 of file flutter_windows_engine.cc.

725 {
726 if (engine_) {
727 embedder_api_.SendKeyEvent(engine_, &event, callback, user_data);
728 }
729 }

## ◆ 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 738 of file flutter_windows_engine.cc.

743 {
744 FlutterPlatformMessageResponseHandle* response_handle = nullptr;
745 if (reply != nullptr && user_data != nullptr) {
746 FlutterEngineResult result =
747 embedder_api_.PlatformMessageCreateResponseHandle(
748 engine_, reply, user_data, &response_handle);
749 if (result != kSuccess) {
750 FML_LOG(ERROR) << "Failed to create response handle";
751 return false;
752 }
753 }
754
755 FlutterPlatformMessage platform_message = {
756 sizeof(FlutterPlatformMessage),
757 channel,
758 message,
759 message_size,
760 response_handle,
761 };
762
763 FlutterEngineResult message_result =
764 embedder_api_.SendPlatformMessage(engine_, &platform_message);
765 if (response_handle != nullptr) {
766 embedder_api_.PlatformMessageReleaseResponseHandle(engine_,
767 response_handle);
768 }
769 return message_result == kSuccess;
770 }

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 772 of file flutter_windows_engine.cc.

775 {
776 embedder_api_.SendPlatformMessageResponse(engine_, handle, data, data_length);
777 }

Referenced by FlutterDesktopMessengerSendResponse().

## ◆ SendPointerEvent()

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

Definition at line 717 of file flutter_windows_engine.cc.

717 {
718 if (engine_) {
719 embedder_api_.SendPointerEvent(engine_, &event, 1);
720 }
721 }

## ◆ SendViewFocusEvent()

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

Definition at line 731 of file flutter_windows_engine.cc.

732 {
733 if (engine_) {
734 embedder_api_.SendViewFocusEvent(engine_, &event);
735 }
736 }

## ◆ SendWindowMetricsEvent()

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

Definition at line 710 of file flutter_windows_engine.cc.

711 {
712 if (engine_) {
713 embedder_api_.SendWindowMetricsEvent(engine_, &event);
714 }
715 }

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

## ◆ SetFlutterCursor()

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

Definition at line 1075 of file flutter_windows_engine.cc.

1075 {
1076 windows_proc_table_->SetCursor(cursor);
1077 }

## ◆ SetNextFrameCallback()

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

Definition at line 801 of file flutter_windows_engine.cc.

801 {
802 next_frame_callback_ = std::move(callback);
803
804 embedder_api_.SetNextFrameCallback(
805 engine_,
806 [](void* user_data) {
807 // Embedder callback runs on raster thread. Switch back to platform
808 // thread.
809 FlutterWindowsEngine* self =
810 static_cast<FlutterWindowsEngine*>(user_data);
811
812 self->task_runner_->PostTask(std::move(self->next_frame_callback_));
813 },
814 this);
815 }

Referenced by FlutterDesktopEngineSetNextFrameCallback().

## ◆ SetRootIsolateCreateCallback()

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

Definition at line 270 of file flutter_windows_engine.h.

270 {
271 root_isolate_create_callback_ = callback;
272 }

References callback.

## ◆ SetSwitches()

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

Definition at line 252 of file flutter_windows_engine.cc.

253 {
254 project_->SetSwitches(switches);
255 }

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 162 of file flutter_windows_engine.h.

162 { 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 195 of file flutter_windows_engine.h.

195 { return text_input_plugin_.get(); }

## ◆ texture_registrar()

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

Definition at line 166 of file flutter_windows_engine.h.

166 {
167 return texture_registrar_.get();
168 }

Referenced by FlutterDesktopRegistrarGetTextureRegistrar().

## ◆ UnregisterExternalTexture()

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

Definition at line 930 of file flutter_windows_engine.cc.

930 {
931 return (embedder_api_.UnregisterExternalTexture(engine_, texture_id) ==
932 kSuccess);
933 }

## ◆ UpdateAccessibilityFeatures()

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

Definition at line 1008 of file flutter_windows_engine.cc.

1008 {
1009 UpdateHighContrastMode();
1010 }
flutter::FlutterWindowsEngine::UpdateHighContrastMode
void UpdateHighContrastMode()
Definition: flutter_windows_engine.cc:1012

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

## ◆ UpdateFlutterCursor()

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

Definition at line 1070 of file flutter_windows_engine.cc.

1071 {
1072 SetFlutterCursor(GetCursorByName(cursor_name));
1073 }
flutter::FlutterWindowsEngine::SetFlutterCursor
void SetFlutterCursor(HCURSOR cursor) const
Definition: flutter_windows_engine.cc:1075

## ◆ UpdateHighContrastMode()

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

Definition at line 1012 of file flutter_windows_engine.cc.

1012 {
1013 high_contrast_enabled_ = windows_proc_table_->GetHighContrastEnabled();
1014
1015 SendAccessibilityFeatures();
1016 settings_plugin_->UpdateHighContrastMode(high_contrast_enabled_);
1017 }

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

## ◆ UpdateSemanticsEnabled()

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

Definition at line 977 of file flutter_windows_engine.cc.

977 {
978 if (engine_ && semantics_enabled_ != enabled) {
979 std::shared_lock read_lock(views_mutex_);
980
981 semantics_enabled_ = enabled;
982 embedder_api_.UpdateSemanticsEnabled(engine_, enabled);
983 for (auto iterator = views_.begin(); iterator != views_.end(); iterator++) {
984 iterator->second->UpdateSemanticsEnabled(enabled);
985 }
986 }
987 }

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(), flutter::PlatformHandler::GetHasStrings(), flutter::PlatformHandler::GetPlainText(), InternalFlutterWindows_WindowManager_GetTopLevelWindowHandle(), Run(), and flutter::PlatformHandler::SetPlainText().

## ◆ window_manager()

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

Definition at line 319 of file flutter_windows_engine.h.

319 { 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 174 of file flutter_windows_engine.h.

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

Referenced by FlutterDesktopPluginRegistrarRegisterTopLevelWindowProcDelegate(), and FlutterDesktopPluginRegistrarUnregisterTopLevelWindowProcDelegate().

## ◆ windows_proc_table()

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

Definition at line 308 of file flutter_windows_engine.h.

308 {
309 return windows_proc_table_;
310 }

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

## Friends And Related Function Documentation

## ◆ EngineModifier

friend class EngineModifier
| friend

Definition at line 357 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