Flutter Engine Uber Docs
Docs for the entire Flutter Engine repo.
 
Loading...
Searching...
No Matches
flutter::FlutterWindowsEngine Class Reference

#include <flutter_windows_engine.h>

Inheritance diagram for flutter::FlutterWindowsEngine:
flutter::testing::TestFlutterWindowsEngine

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< FlutterWindowsViewCreateView (std::unique_ptr< WindowBindingHandler > window, bool is_sized_to_content, const BoxConstraints &box_constraints, FlutterWindowsViewSizingDelegate *sizing_delegate=nullptr)
 
virtual void RemoveView (FlutterViewId view_id)
 
FlutterWindowsViewview (FlutterViewId view_id) const
 
FlutterDesktopPluginRegistrarRef GetRegistrar ()
 
void AddPluginRegistrarDestructionCallback (FlutterDesktopOnPluginRegistrarDestroyed callback, FlutterDesktopPluginRegistrarRef registrar)
 
void SetSwitches (const std::vector< std::string > &switches)
 
FlutterDesktopMessengerRef messenger ()
 
IncomingMessageDispatchermessage_dispatcher ()
 
std::shared_ptr< DisplayManagerWin32display_manager ()
 
void UpdateDisplay (const std::vector< FlutterEngineDisplay > &displays)
 
TaskRunnertask_runner ()
 
BinaryMessengermessenger_wrapper ()
 
FlutterWindowsTextureRegistrartexture_registrar ()
 
egl::Manageregl_manager () const
 
WindowProcDelegateManagerwindow_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)
 
KeyboardHandlerBasekeyboard_key_handler ()
 
TextInputPlugintext_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
 
bool iaccessibleex_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< LRESULTProcessExternalWindowMessage (HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam)
 
WindowsLifecycleManagerlifecycle_manager ()
 
std::shared_ptr< WindowsProcTablewindows_proc_table ()
 
void UpdateFlutterCursor (const std::string &cursor_name) const
 
void SetFlutterCursor (HCURSOR cursor) const
 
WindowManagerwindow_manager ()
 
FlutterWindowsViewGetViewFromTopLevelWindow (HWND hwnd) const
 

Static Public Member Functions

static FlutterWindowsEngineGetEngineForId (int64_t engine_id)
 

Protected Member Functions

virtual std::unique_ptr< KeyboardHandlerBaseCreateKeyboardKeyHandler (BinaryMessenger *messenger, KeyboardKeyEmbedderHandler::GetKeyStateHandler get_key_state, KeyboardKeyEmbedderHandler::MapVirtualKeyToScanCode map_vk_to_scan)
 
virtual std::unique_ptr< TextInputPluginCreateTextInputPlugin (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
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_ =
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 bool enable_impeller = true;
198 if (project_->impeller_switch() == FlutterImpellerSwitch::Enabled) {
199 enable_impeller = true;
200 } else if (project_->impeller_switch() == FlutterImpellerSwitch::Disabled) {
201 enable_impeller = false;
202 }
203 for (const auto& env_switch : switches) {
204 if (env_switch == "--enable-impeller" ||
205 env_switch == "--enable-impeller=true") {
206 enable_impeller = true;
207 } else if (env_switch == "--enable-impeller=false") {
208 enable_impeller = false;
209 }
210 }
211 enable_impeller_ = enable_impeller;
212
213 egl_manager_ = egl::Manager::Create(
214 static_cast<egl::GpuPreference>(project_->gpu_preference()));
215 window_proc_delegate_manager_ = std::make_unique<WindowProcDelegateManager>();
216
217 display_manager_ = std::make_shared<DisplayManagerWin32>(this);
218
219 window_proc_delegate_manager_->RegisterTopLevelWindowProcDelegate(
220 [](HWND hwnd, UINT msg, WPARAM wpar, LPARAM lpar, void* user_data,
221 LRESULT* result) {
224 static_cast<FlutterWindowsEngine*>(user_data);
225
226 BASE_DCHECK(that->display_manager_);
227 if (that->display_manager_->HandleWindowMessage(hwnd, msg, wpar, lpar,
228 result)) {
229 return true;
230 }
231
232 BASE_DCHECK(that->lifecycle_manager_);
233 bool handled =
234 that->lifecycle_manager_->WindowProc(hwnd, msg, wpar, lpar, result);
235 if (handled) {
236 return true;
237 }
238 auto message_result =
239 that->window_manager_->HandleMessage(hwnd, msg, wpar, lpar);
240 if (message_result) {
241 *result = *message_result;
242 return true;
243 }
244 return false;
245 },
246 static_cast<void*>(this));
247
248 // Set up internal channels.
249 // TODO: Replace this with an embedder.h API. See
250 // https://github.com/flutter/flutter/issues/71099
251 internal_plugin_registrar_ =
252 std::make_unique<PluginRegistrar>(plugin_registrar_.get());
253
254 accessibility_plugin_ = std::make_unique<AccessibilityPlugin>(this);
255 AccessibilityPlugin::SetUp(messenger_wrapper_.get(),
256 accessibility_plugin_.get());
257
258 cursor_handler_ =
259 std::make_unique<CursorHandler>(messenger_wrapper_.get(), this);
260 platform_handler_ =
261 std::make_unique<PlatformHandler>(messenger_wrapper_.get(), this);
262 window_manager_ = std::make_unique<WindowManager>(this);
263 settings_plugin_ = std::make_unique<SettingsPlugin>(messenger_wrapper_.get(),
264 task_runner_.get());
265}
static void SetUp(BinaryMessenger *binary_messenger, AccessibilityPlugin *plugin)
FlutterWindowsEngine(const FlutterProjectBundle &project, std::shared_ptr< WindowsProcTable > windows_proc_table=nullptr)
std::shared_ptr< WindowsProcTable > windows_proc_table()
static std::unique_ptr< Manager > Create(GpuPreference gpu_preference)
Definition manager.cc:17
static std::shared_ptr< ProcTable > Create()
Definition proc_table.cc:12
FlutterEngineResult FlutterEngineGetProcAddresses(FlutterEngineProcTable *table)
Gets the table of engine function pointers.
Definition embedder.cc:3741
if(engine==nullptr)
Function-pointer-based versions of the APIs above.
Definition embedder.h:3763
size_t struct_size
The size of this struct. Must be sizeof(FlutterEngineProcs).
Definition embedder.h:3765
FlutterEngineGetCurrentTimeFnPtr GetCurrentTime
Definition embedder.h:3796
FlutterEngineRunTaskFnPtr RunTask
Definition embedder.h:3797
#define BASE_DCHECK(condition)
Definition logging.h:63
LONG_PTR LRESULT
unsigned int UINT
LONG_PTR LPARAM
UINT_PTR WPARAM

References flutter::egl::ProcTable::Create(), FlutterEngineGetProcAddresses(), FlutterEngineProcTable::GetCurrentTime, if(), flutter::kSuccess, FlutterEngineProcTable::RunTask, and FlutterEngineProcTable::struct_size.

◆ ~FlutterWindowsEngine()

flutter::FlutterWindowsEngine::~FlutterWindowsEngine ( )
virtual

Definition at line 267 of file flutter_windows_engine.cc.

267 {
268 messenger_->SetEngine(nullptr);
269 Stop();
270}
void SetEngine(flutter::FlutterWindowsEngine *arg_engine)

Member Function Documentation

◆ AddPluginRegistrarDestructionCallback()

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

Definition at line 751 of file flutter_windows_engine.cc.

753 {
754 plugin_registrar_destruction_callbacks_[callback] = registrar;
755}
FlutterDesktopBinaryReply callback

References callback.

◆ CreateKeyboardKeyHandler()

std::unique_ptr< KeyboardHandlerBase > flutter::FlutterWindowsEngine::CreateKeyboardKeyHandler ( BinaryMessenger messenger,
KeyboardKeyEmbedderHandler::GetKeyStateHandler  get_key_state,
KeyboardKeyEmbedderHandler::MapVirtualKeyToScanCode  map_vk_to_scan 
)
protectedvirtual

Reimplemented in flutter::testing::TestFlutterWindowsEngine.

Definition at line 958 of file flutter_windows_engine.cc.

961 {
962 auto keyboard_key_handler = std::make_unique<KeyboardKeyHandler>(messenger);
963 keyboard_key_handler->AddDelegate(
964 std::make_unique<KeyboardKeyEmbedderHandler>(
966 void* user_data) {
967 return SendKeyEvent(event, callback, user_data);
968 },
969 get_key_state, map_vk_to_scan));
970 keyboard_key_handler->AddDelegate(
971 std::make_unique<KeyboardKeyChannelHandler>(messenger));
972 keyboard_key_handler->InitKeyboardChannel();
974}
FlutterDesktopMessengerRef messenger()
KeyboardHandlerBase * keyboard_key_handler()
void SendKeyEvent(const FlutterKeyEvent &event, FlutterKeyEventCallback callback, void *user_data)
void(* FlutterKeyEventCallback)(bool, void *)
Definition embedder.h:1482

References callback, and user_data.

Referenced by flutter::testing::TestFlutterWindowsEngine::CreateKeyboardKeyHandler().

◆ CreateTextInputPlugin()

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

Definition at line 976 of file flutter_windows_engine.cc.

977 {
978 return std::make_unique<TextInputPlugin>(messenger, this);
979}

◆ CreateView()

std::unique_ptr< FlutterWindowsView > flutter::FlutterWindowsEngine::CreateView ( std::unique_ptr< WindowBindingHandler window,
bool  is_sized_to_content,
const BoxConstraints box_constraints,
FlutterWindowsViewSizingDelegate sizing_delegate = nullptr 
)

Definition at line 562 of file flutter_windows_engine.cc.

566 {
567 auto view_id = next_view_id_;
568 auto view = std::make_unique<FlutterWindowsView>(
569 view_id, this, std::move(window), is_sized_to_content, box_constraints,
570 sizing_delegate, windows_proc_table_);
571
573 view->UpdateSemanticsEnabled(semantics_enabled_);
574
575 next_view_id_++;
576
577 {
578 // Add the view to the embedder. This must happen before the engine
579 // is notified the view exists and starts presenting to it.
580 std::unique_lock write_lock(views_mutex_);
581 FML_DCHECK(views_.find(view_id) == views_.end());
582 views_[view_id] = view.get();
583 }
584
585 if (!view->IsImplicitView()) {
587
588 struct Captures {
590 bool added;
591 };
592 Captures captures = {};
593
595
596 FlutterAddViewInfo info = {};
597 info.struct_size = sizeof(FlutterAddViewInfo);
598 info.view_id = view_id;
599 info.view_metrics = &metrics;
600 info.user_data = &captures;
601 info.add_view_callback = [](const FlutterAddViewResult* result) {
602 Captures* captures = reinterpret_cast<Captures*>(result->user_data);
603 captures->added = result->added;
604 captures->latch.Signal();
605 };
606
607 FlutterEngineResult result = embedder_api_.AddView(engine_, &info);
608 if (result != kSuccess) {
609 FML_LOG(ERROR)
610 << "Starting the add view operation failed. FlutterEngineAddView "
611 "returned an unexpected result: "
612 << result << ". This indicates a bug in the Windows embedder.";
613 FML_DCHECK(false);
614 return nullptr;
615 }
616
617 // Block the platform thread until the engine has added the view.
618 // TODO(loicsharma): This blocks the platform thread eagerly and can
619 // cause unnecessary delay in input processing. Instead, this should block
620 // lazily only when the app does an operation which needs the view.
621 // https://github.com/flutter/flutter/issues/146248
622 captures.latch.Wait();
623
624 if (!captures.added) {
625 // Adding the view failed. Update the embedder's state to match the
626 // engine's state. This is unexpected and indicates a bug in the Windows
627 // embedder.
628 FML_LOG(ERROR) << "FlutterEngineAddView failed to add view";
629 std::unique_lock write_lock(views_mutex_);
630 views_.erase(view_id);
631 return nullptr;
632 }
633 }
634
635 return std::move(view);
636}
FlutterWindowsView * view(FlutterViewId view_id) const
virtual void UpdateSemanticsEnabled(bool enabled)
FlutterWindowMetricsEvent CreateWindowMetricsEvent() const
FlutterEngineResult
Definition embedder.h:72
GLFWwindow * window
Definition main.cc:60
G_BEGIN_DECLS FlutterViewId view_id
#define FML_LOG(severity)
Definition logging.h:101
#define FML_DCHECK(condition)
Definition logging.h:122
FlutterAddViewCallback add_view_callback
Definition embedder.h:1147
FlutterViewId view_id
The identifier for the view to add. This must be unique.
Definition embedder.h:1127
const FlutterWindowMetricsEvent * view_metrics
Definition embedder.h:1132
FlutterEngineAddViewFnPtr AddView
Definition embedder.h:3807

References FlutterAddViewInfo::add_view_callback, FML_DCHECK, FML_LOG, kSuccess, FlutterAddViewInfo::struct_size, FlutterAddViewInfo::user_data, view, FlutterAddViewInfo::view_id, view_id, FlutterAddViewInfo::view_metrics, and window.

Referenced by CreateViewController(), and flutter::HostWindow::InitializeFlutterView().

◆ DispatchSemanticsAction()

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

Definition at line 1017 of file flutter_windows_engine.cc.

1021 {
1024 .view_id = view_id,
1025 .node_id = target,
1026 .action = action,
1027 .data = data.GetMapping(),
1028 .data_length = data.GetSize(),
1029 };
1030 return (embedder_api_.SendSemanticsAction(engine_, &info));
1031}
uint32_t * target
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot data
Definition switch_defs.h:36
FlutterEngineSendSemanticsActionFnPtr SendSemanticsAction
Definition embedder.h:3810

References action, flutter::data, FlutterSendSemanticsActionInfo::struct_size, target, and view_id.

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

◆ display_manager()

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

Definition at line 166 of file flutter_windows_engine.h.

166 {
167 return display_manager_;
168 }

Referenced by CreateViewController(), and flutter::HostWindow::InitializeFlutterView().

◆ egl_manager()

◆ GetEngineForId()

◆ GetExecutableName()

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

Definition at line 1050 of file flutter_windows_engine.cc.

1050 {
1051 std::pair<bool, std::string> result = fml::paths::GetExecutablePath();
1052 if (result.first) {
1053 const std::string& executable_path = result.second;
1054 size_t last_separator = executable_path.find_last_of("/\\");
1055 if (last_separator == std::string::npos ||
1056 last_separator == executable_path.size() - 1) {
1057 return executable_path;
1058 }
1059 return executable_path.substr(last_separator + 1);
1060 }
1061 return "Flutter";
1062}
std::pair< bool, std::string > GetExecutablePath()

References fml::paths::GetExecutablePath().

◆ GetRegistrar()

FlutterDesktopPluginRegistrarRef flutter::FlutterWindowsEngine::GetRegistrar ( )

Definition at line 747 of file flutter_windows_engine.cc.

747 {
748 return plugin_registrar_.get();
749}

Referenced by FlutterDesktopEngineGetPluginRegistrar().

◆ GetViewFromTopLevelWindow()

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

Definition at line 911 of file flutter_windows_engine.cc.

912 {
913 std::shared_lock read_lock(views_mutex_);
914 auto const iterator =
915 std::find_if(views_.begin(), views_.end(), [hwnd](auto const& pair) {
916 FlutterWindowsView* const view = pair.second;
917 return GetAncestor(view->GetWindowHandle(), GA_ROOT) == hwnd;
918 });
919 if (iterator != views_.end()) {
920 return iterator->second;
921 }
922 return nullptr;
923}

◆ HandlePlatformMessage()

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

Definition at line 835 of file flutter_windows_engine.cc.

836 {
837 if (engine_message->struct_size != sizeof(FlutterPlatformMessage)) {
838 FML_LOG(ERROR) << "Invalid message size received. Expected: "
839 << sizeof(FlutterPlatformMessage) << " but received "
840 << engine_message->struct_size;
841 return;
842 }
843
844 auto message = ConvertToDesktopMessage(*engine_message);
845
846 message_dispatcher_->HandleMessage(message, [this] {}, [this] {});
847}
const char * message
static FlutterDesktopMessage ConvertToDesktopMessage(const FlutterPlatformMessage &engine_message)
size_t struct_size
The size of this struct. Must be sizeof(FlutterPlatformMessage).
Definition embedder.h:1491

References ConvertToDesktopMessage(), FML_LOG, message, and FlutterPlatformMessage::struct_size.

◆ high_contrast_enabled()

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

Definition at line 275 of file flutter_windows_engine.h.

275{ return high_contrast_enabled_; }

◆ iaccessibleex_enabled()

bool flutter::FlutterWindowsEngine::iaccessibleex_enabled ( ) const
inline

Definition at line 263 of file flutter_windows_engine.h.

263 {
264 return project_->accessibility_mode() ==
266 }

References flutter::IAccessibleEx.

Referenced by flutter::FlutterPlatformNodeDelegateWindows::IsIAccessibleExEnabled().

◆ keyboard_key_handler()

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

Definition at line 203 of file flutter_windows_engine.h.

203 {
204 return keyboard_key_handler_.get();
205 }

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

◆ lifecycle_manager()

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

Definition at line 320 of file flutter_windows_engine.h.

320 {
321 return lifecycle_manager_.get();
322 }

◆ MarkExternalTextureFrameAvailable()

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

Definition at line 991 of file flutter_windows_engine.cc.

992 {
993 return (embedder_api_.MarkExternalTextureFrameAvailable(
994 engine_, texture_id) == kSuccess);
995}
FlutterEngineMarkExternalTextureFrameAvailableFnPtr MarkExternalTextureFrameAvailable
Definition embedder.h:3786
int64_t texture_id

References kSuccess, and texture_id.

◆ message_dispatcher()

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

Definition at line 162 of file flutter_windows_engine.h.

162 {
163 return message_dispatcher_.get();
164 }

Referenced by FlutterDesktopMessengerSetCallback().

◆ messenger()

FlutterDesktopMessengerRef flutter::FlutterWindowsEngine::messenger ( )
inline

Definition at line 160 of file flutter_windows_engine.h.

160{ return messenger_->ToRef(); }
FlutterDesktopMessengerRef ToRef()
Convert to FlutterDesktopMessengerRef.

References flutter::FlutterDesktopMessenger::ToRef().

Referenced by flutter::testing::TestFlutterWindowsEngine::CreateKeyboardKeyHandler(), and FlutterDesktopEngineGetMessenger().

◆ messenger_wrapper()

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

Definition at line 175 of file flutter_windows_engine.h.

175{ return messenger_wrapper_.get(); }

◆ OnChannelUpdate()

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

Definition at line 1138 of file flutter_windows_engine.cc.

1138 {
1139 if (name == "flutter/platform" && listening) {
1140 lifecycle_manager_->BeginProcessingExit();
1141 } else if (name == "flutter/lifecycle" && listening) {
1142 lifecycle_manager_->BeginProcessingLifecycle();
1143 }
1144}
DEF_SWITCHES_START aot vmservice shared library name
Definition switch_defs.h:27

References name.

◆ OnDwmCompositionChanged()

void flutter::FlutterWindowsEngine::OnDwmCompositionChanged ( )

Definition at line 1101 of file flutter_windows_engine.cc.

1101 {
1102 if (display_manager_) {
1103 display_manager_->UpdateDisplays();
1104 }
1105
1106 std::shared_lock read_lock(views_mutex_);
1107 for (auto iterator = views_.begin(); iterator != views_.end(); iterator++) {
1108 iterator->second->OnDwmCompositionChanged();
1109 }
1110}

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

◆ OnPreEngineRestart()

void flutter::FlutterWindowsEngine::OnPreEngineRestart ( )
protected

Definition at line 1045 of file flutter_windows_engine.cc.

1045 {
1046 // Reset the keyboard's state on hot restart.
1047 InitializeKeyboard();
1048}

Referenced by flutter::EngineModifier::Restart().

◆ OnQuit()

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

Definition at line 1094 of file flutter_windows_engine.cc.

1097 {
1098 lifecycle_manager_->Quit(hwnd, wparam, lparam, exit_code);
1099}

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

◆ OnViewFocusChangeRequest()

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

Definition at line 1146 of file flutter_windows_engine.cc.

1147 {
1148 std::shared_lock read_lock(views_mutex_);
1149
1150 auto iterator = views_.find(request->view_id);
1151 if (iterator == views_.end()) {
1152 return;
1153 }
1154
1155 FlutterWindowsView* view = iterator->second;
1156 view->Focus();
1157}
FlView * view
FlutterViewId view_id
The identifier of the view that received the focus event.
Definition embedder.h:1257

References view, and FlutterViewFocusChangeRequest::view_id.

Referenced by flutter::EngineModifier::OnViewFocusChangeRequest().

◆ OnVsync()

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

Definition at line 707 of file flutter_windows_engine.cc.

707 {
708 std::chrono::nanoseconds current_time =
709 std::chrono::nanoseconds(embedder_api_.GetCurrentTime());
710 std::chrono::nanoseconds frame_interval = FrameInterval();
711 auto next = SnapToNextTick(current_time, start_time_, frame_interval);
712 embedder_api_.OnVsync(engine_, baton, next.count(),
713 (next + frame_interval).count());
714}
FlutterEngineOnVsyncFnPtr OnVsync
Definition embedder.h:3790

◆ OnWindowStateEvent()

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

Definition at line 1112 of file flutter_windows_engine.cc.

1113 {
1114 lifecycle_manager_->OnWindowStateEvent(hwnd, event);
1115}

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

◆ PostRasterThreadTask()

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

Definition at line 997 of file flutter_windows_engine.cc.

997 {
998 struct Captures {
1000 };
1001 auto captures = new Captures();
1002 captures->callback = std::move(callback);
1003 if (embedder_api_.PostRenderThreadTask(
1004 engine_,
1005 [](void* opaque) {
1006 auto captures = reinterpret_cast<Captures*>(opaque);
1007 captures->callback();
1008 delete captures;
1009 },
1010 captures) == kSuccess) {
1011 return true;
1012 }
1013 delete captures;
1014 return false;
1015}
std::function< void()> closure
Definition closure.h:14
FlutterEnginePostRenderThreadTaskFnPtr PostRenderThreadTask
Definition embedder.h:3795

References callback, and kSuccess.

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

◆ ProcessExternalWindowMessage()

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

Definition at line 1117 of file flutter_windows_engine.cc.

1121 {
1122 if (lifecycle_manager_) {
1123 return lifecycle_manager_->ExternalWindowMessage(hwnd, message, wparam,
1124 lparam);
1125 }
1126 return std::nullopt;
1127}

References message.

Referenced by FlutterDesktopEngineProcessExternalWindowMessage().

◆ RegisterExternalTexture()

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

Definition at line 981 of file flutter_windows_engine.cc.

981 {
982 return (embedder_api_.RegisterExternalTexture(engine_, texture_id) ==
983 kSuccess);
984}
FlutterEngineRegisterExternalTextureFnPtr RegisterExternalTexture
Definition embedder.h:3783

References kSuccess, and texture_id.

◆ ReloadSystemFonts()

void flutter::FlutterWindowsEngine::ReloadSystemFonts ( )

Definition at line 849 of file flutter_windows_engine.cc.

849 {
850 embedder_api_.ReloadSystemFonts(engine_);
851}
FlutterEngineReloadSystemFontsFnPtr ReloadSystemFonts
Definition embedder.h:3791

Referenced by FlutterDesktopEngineReloadSystemFonts().

◆ RemoveView()

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

Definition at line 638 of file flutter_windows_engine.cc.

638 {
640
641 // Notify the engine to stop rendering to the view if it isn't the implicit
642 // view. The engine and framework assume the implicit view always exists and
643 // can continue presenting.
644 if (view_id != kImplicitViewId) {
645 struct Captures {
647 bool removed;
648 };
649 Captures captures = {};
650
651 FlutterRemoveViewInfo info = {};
652 info.struct_size = sizeof(FlutterRemoveViewInfo);
653 info.view_id = view_id;
654 info.user_data = &captures;
655 info.remove_view_callback = [](const FlutterRemoveViewResult* result) {
656 // This is invoked on an engine thread. If
657 // |FlutterRemoveViewResult.removed| is `true`, the engine guarantees the
658 // view won't be presented.
659 Captures* captures = reinterpret_cast<Captures*>(result->user_data);
660 captures->removed = result->removed;
661 captures->latch.Signal();
662 };
663
664 FlutterEngineResult result = embedder_api_.RemoveView(engine_, &info);
665 if (result != kSuccess) {
666 FML_LOG(ERROR) << "Starting the remove view operation failed. "
667 "FlutterEngineRemoveView "
668 "returned an unexpected result: "
669 << result
670 << ". This indicates a bug in the Windows embedder.";
671 FML_DCHECK(false);
672 return;
673 }
674
675 // Block the platform thread until the engine has removed the view.
676 // TODO(loicsharma): This blocks the platform thread eagerly and can
677 // cause unnecessary delay in input processing. Instead, this should block
678 // lazily only when an operation needs the view.
679 // https://github.com/flutter/flutter/issues/146248
680 captures.latch.Wait();
681
682 if (!captures.removed) {
683 // Removing the view failed. This is unexpected and indicates a bug in the
684 // Windows embedder.
685 FML_LOG(ERROR) << "FlutterEngineRemoveView failed to remove view";
686 return;
687 }
688 }
689
690 {
691 // The engine no longer presents to the view. Remove the view from the
692 // embedder.
693 std::unique_lock write_lock(views_mutex_);
694
695 FML_DCHECK(views_.find(view_id) != views_.end());
696
697 // Reset text input state if the removed view is the active text input
698 // view, to prevent stale view references.
699 if (text_input_plugin_) {
700 text_input_plugin_->OnViewRemoved(view_id);
701 }
702
703 views_.erase(view_id);
704 }
705}
constexpr FlutterViewId kImplicitViewId
FlutterEngineRemoveViewFnPtr RemoveView
Definition embedder.h:3808
FlutterRemoveViewCallback remove_view_callback
Definition embedder.h:1195
FlutterViewId view_id
Definition embedder.h:1178

References FML_DCHECK, FML_LOG, kImplicitViewId, kSuccess, FlutterRemoveViewInfo::remove_view_callback, FlutterRemoveViewInfo::struct_size, FlutterRemoveViewInfo::user_data, FlutterRemoveViewInfo::view_id, and view_id.

◆ RequestApplicationQuit()

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

Definition at line 1087 of file flutter_windows_engine.cc.

1090 {
1091 platform_handler_->RequestAppExit(hwnd, wparam, lparam, exit_type, 0);
1092}

◆ Run() [1/2]

bool flutter::FlutterWindowsEngine::Run ( )

Definition at line 281 of file flutter_windows_engine.cc.

281 {
282 return Run("");
283}

Referenced by FlutterDesktopEngineRun().

◆ Run() [2/2]

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

Definition at line 285 of file flutter_windows_engine.cc.

285 {
286 if (!project_->HasValidPaths()) {
287 FML_LOG(ERROR) << "Missing or unresolvable paths to assets.";
288 return false;
289 }
290 std::string assets_path_string = fml::PathToUtf8(project_->assets_path());
291 std::string icu_path_string = fml::PathToUtf8(project_->icu_path());
292 if (embedder_api_.RunsAOTCompiledDartCode()) {
293 aot_data_ = project_->LoadAotData(embedder_api_);
294 if (!aot_data_) {
295 FML_LOG(ERROR) << "Unable to start engine without AOT data.";
296 return false;
297 }
298 }
299
300 // FlutterProjectArgs is expecting a full argv, so when processing it for
301 // flags the first item is treated as the executable and ignored. Add a dummy
302 // value so that all provided arguments are used.
303 std::string executable_name = GetExecutableName();
304 std::vector<const char*> argv = {executable_name.c_str()};
305 std::vector<std::string> switches = project_->GetSwitches();
306 if (enable_impeller_) {
307 if (std::find(switches.begin(), switches.end(),
308 "--impeller-use-sdfs=true") == switches.end() &&
309 std::find(switches.begin(), switches.end(),
310 "--impeller-use-sdfs=false") == switches.end()) {
311 switches.push_back("--impeller-use-sdfs=true");
312 }
313 if (std::find(switches.begin(), switches.end(), "--enable-impeller") ==
314 switches.end() &&
315 std::find(switches.begin(), switches.end(), "--enable-impeller=true") ==
316 switches.end()) {
317 // Impeller was enabled programmatically, so forward the switch to the
318 // engine.
319 switches.push_back("--enable-impeller");
320 }
321 } else if (project_->impeller_switch() == FlutterImpellerSwitch::Disabled) {
322 if (std::find(switches.begin(), switches.end(),
323 "--enable-impeller=false") == switches.end()) {
324 // Impeller was disabled programmatically, so forward the switch to the
325 // engine.
326 switches.push_back("--enable-impeller=false");
327 }
328 }
329 std::transform(
330 switches.begin(), switches.end(), std::back_inserter(argv),
331 [](const std::string& arg) -> const char* { return arg.c_str(); });
332
333 const std::vector<std::string>& entrypoint_args =
334 project_->dart_entrypoint_arguments();
335 std::vector<const char*> entrypoint_argv;
336 std::transform(
337 entrypoint_args.begin(), entrypoint_args.end(),
338 std::back_inserter(entrypoint_argv),
339 [](const std::string& arg) -> const char* { return arg.c_str(); });
340
341 // Configure task runners.
342 FlutterTaskRunnerDescription platform_task_runner = {};
343 platform_task_runner.struct_size = sizeof(FlutterTaskRunnerDescription);
344 platform_task_runner.user_data = task_runner_.get();
345 platform_task_runner.runs_task_on_current_thread_callback =
346 [](void* user_data) -> bool {
347 return static_cast<TaskRunner*>(user_data)->RunsTasksOnCurrentThread();
348 };
349 platform_task_runner.post_task_callback = [](FlutterTask task,
350 uint64_t target_time_nanos,
351 void* user_data) -> void {
352 static_cast<TaskRunner*>(user_data)->PostFlutterTask(task,
353 target_time_nanos);
354 };
355 FlutterCustomTaskRunners custom_task_runners = {};
356 custom_task_runners.struct_size = sizeof(FlutterCustomTaskRunners);
357 custom_task_runners.platform_task_runner = &platform_task_runner;
358 custom_task_runners.thread_priority_setter =
360
361 if (project_->ui_thread_policy() !=
363 custom_task_runners.ui_task_runner = &platform_task_runner;
364 } else {
365 FML_LOG(WARNING) << "Running with unmerged platform and UI threads. This "
366 "will be removed in future.";
367 }
368
371 args.shutdown_dart_vm_when_done = true;
372 args.assets_path = assets_path_string.c_str();
373 args.icu_data_path = icu_path_string.c_str();
374 args.command_line_argc = static_cast<int>(argv.size());
375 args.command_line_argv = argv.empty() ? nullptr : argv.data();
376 args.engine_id = reinterpret_cast<int64_t>(this);
377
378 // Fail if conflicting non-default entrypoints are specified in the method
379 // argument and the project.
380 //
381 // TODO(cbracken): https://github.com/flutter/flutter/issues/109285
382 // The entrypoint method parameter should eventually be removed from this
383 // method and only the entrypoint specified in project_ should be used.
384 if (!project_->dart_entrypoint().empty() && !entrypoint.empty() &&
385 project_->dart_entrypoint() != entrypoint) {
386 FML_LOG(ERROR) << "Conflicting entrypoints were specified in "
387 "FlutterDesktopEngineProperties.dart_entrypoint and "
388 "FlutterDesktopEngineRun(engine, entry_point). ";
389 return false;
390 }
391 if (!entrypoint.empty()) {
392 args.custom_dart_entrypoint = entrypoint.data();
393 } else if (!project_->dart_entrypoint().empty()) {
394 args.custom_dart_entrypoint = project_->dart_entrypoint().c_str();
395 }
396 args.dart_entrypoint_argc = static_cast<int>(entrypoint_argv.size());
397 args.dart_entrypoint_argv =
398 entrypoint_argv.empty() ? nullptr : entrypoint_argv.data();
399 args.platform_message_callback =
400 [](const FlutterPlatformMessage* engine_message,
401 void* user_data) -> void {
402 auto host = static_cast<FlutterWindowsEngine*>(user_data);
403 return host->HandlePlatformMessage(engine_message);
404 };
405 args.vsync_callback = [](void* user_data, intptr_t baton) -> void {
406 auto host = static_cast<FlutterWindowsEngine*>(user_data);
407 host->OnVsync(baton);
408 };
409 args.on_pre_engine_restart_callback = [](void* user_data) {
410 auto host = static_cast<FlutterWindowsEngine*>(user_data);
411 host->OnPreEngineRestart();
412 };
413 args.update_semantics_callback2 = [](const FlutterSemanticsUpdate2* update,
414 void* user_data) {
415 auto host = static_cast<FlutterWindowsEngine*>(user_data);
416
417 auto view = host->view(update->view_id);
418 if (!view) {
419 return;
420 }
421
422 auto accessibility_bridge = view->accessibility_bridge().lock();
423 if (!accessibility_bridge) {
424 return;
425 }
426
427 for (size_t i = 0; i < update->node_count; i++) {
428 const FlutterSemanticsNode2* node = update->nodes[i];
429 accessibility_bridge->AddFlutterSemanticsNodeUpdate(*node);
430 }
431
432 for (size_t i = 0; i < update->custom_action_count; i++) {
434 accessibility_bridge->AddFlutterSemanticsCustomActionUpdate(*action);
435 }
436
437 accessibility_bridge->CommitUpdates();
438 };
439 args.root_isolate_create_callback = [](void* user_data) {
440 auto host = static_cast<FlutterWindowsEngine*>(user_data);
441 if (host->root_isolate_create_callback_) {
442 host->root_isolate_create_callback_();
443 }
444 };
445 args.channel_update_callback = [](const FlutterChannelUpdate* update,
446 void* user_data) {
447 auto host = static_cast<FlutterWindowsEngine*>(user_data);
448 if (SAFE_ACCESS(update, channel, nullptr) != nullptr) {
449 std::string channel_name(update->channel);
450 host->OnChannelUpdate(std::move(channel_name),
451 SAFE_ACCESS(update, listening, false));
452 }
453 };
454 args.view_focus_change_request_callback =
455 [](const FlutterViewFocusChangeRequest* request, void* user_data) {
456 auto host = static_cast<FlutterWindowsEngine*>(user_data);
457 host->OnViewFocusChangeRequest(request);
458 };
459
460 args.custom_task_runners = &custom_task_runners;
461
462 if (!platform_view_plugin_) {
463 platform_view_plugin_ = std::make_unique<PlatformViewPlugin>(
464 messenger_wrapper_.get(), task_runner_.get());
465 }
466 if (egl_manager_) {
467 auto resolver = [](const char* name) -> void* {
468 return reinterpret_cast<void*>(::eglGetProcAddress(name));
469 };
470
471 // TODO(schectman) Pass the platform view manager to the compositor
472 // constructors: https://github.com/flutter/flutter/issues/143375
473 compositor_ =
474 std::make_unique<CompositorOpenGL>(this, resolver, enable_impeller_);
475 } else {
476 compositor_ = std::make_unique<CompositorSoftware>();
477 }
478
479 FlutterCompositor compositor = {};
480 compositor.struct_size = sizeof(FlutterCompositor);
481 compositor.user_data = this;
483 [](const FlutterBackingStoreConfig* config,
484 FlutterBackingStore* backing_store_out, void* user_data) -> bool {
485 auto host = static_cast<FlutterWindowsEngine*>(user_data);
486
487 return host->compositor_->CreateBackingStore(*config, backing_store_out);
488 };
489
491 [](const FlutterBackingStore* backing_store, void* user_data) -> bool {
492 auto host = static_cast<FlutterWindowsEngine*>(user_data);
493
494 return host->compositor_->CollectBackingStore(backing_store);
495 };
496
497 compositor.present_view_callback =
498 [](const FlutterPresentViewInfo* info) -> bool {
499 auto host = static_cast<FlutterWindowsEngine*>(info->user_data);
500
501 return host->Present(info);
502 };
503 args.compositor = &compositor;
504
505 if (aot_data_) {
506 args.aot_data = aot_data_.get();
507 }
508
509 // The platform thread creates OpenGL contexts. These
510 // must be released to be used by the engine's threads.
511 FML_DCHECK(!egl_manager_ || !egl_manager_->HasContextCurrent());
512
513 FlutterRendererConfig renderer_config;
514
515 if (enable_impeller_) {
516 // Impeller does not support a Software backend. Avoid falling back and
517 // confusing the engine on which renderer is selected.
518 if (!egl_manager_) {
519 FML_LOG(ERROR) << "Could not create surface manager. Impeller backend "
520 "does not support software rendering.";
521 return false;
522 }
523 renderer_config = GetOpenGLRendererConfig();
524 } else {
525 renderer_config =
526 egl_manager_ ? GetOpenGLRendererConfig() : GetSoftwareRendererConfig();
527 }
528
529 auto result = embedder_api_.Run(FLUTTER_ENGINE_VERSION, &renderer_config,
530 &args, this, &engine_);
531 if (result != kSuccess || engine_ == nullptr) {
532 FML_LOG(ERROR) << "Failed to start Flutter engine: error " << result;
533 return false;
534 }
535
536 display_manager_->UpdateDisplays();
537
538 SendSystemLocales();
539
540 settings_plugin_->StartWatching();
541 settings_plugin_->SendSettings();
542
543 InitializeKeyboard();
544
545 return true;
546}
std::weak_ptr< AccessibilityBridgeWindows > accessibility_bridge()
#define FLUTTER_ENGINE_VERSION
Definition embedder.h:70
#define SAFE_ACCESS(pointer, member, default_value)
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
const gchar * channel
char ** argv
Definition library.h:9
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service host
Definition switch_defs.h:69
static void WindowsPlatformThreadPrioritySetter(FlutterThreadPriority priority)
std::string PathToUtf8(const std::filesystem::path &path)
An update to whether a message channel has a listener set or not.
Definition embedder.h:1884
const char * channel
The name of the channel.
Definition embedder.h:1888
FlutterBackingStoreCreateCallback create_backing_store_callback
Definition embedder.h:2268
size_t struct_size
This size of this struct. Must be sizeof(FlutterCompositor).
Definition embedder.h:2252
FlutterPresentViewCallback present_view_callback
Definition embedder.h:2305
FlutterBackingStoreCollectCallback collect_backing_store_callback
Definition embedder.h:2273
void(* thread_priority_setter)(FlutterThreadPriority)
Definition embedder.h:1959
const FlutterTaskRunnerDescription * ui_task_runner
Definition embedder.h:1963
const FlutterTaskRunnerDescription * platform_task_runner
Definition embedder.h:1951
size_t struct_size
The size of this struct. Must be sizeof(FlutterCustomTaskRunners).
Definition embedder.h:1946
FlutterEngineRunsAOTCompiledDartCodeFnPtr RunsAOTCompiledDartCode
Definition embedder.h:3799
FlutterEngineRunFnPtr Run
Definition embedder.h:3769
size_t struct_size
The size of this struct. Must be sizeof(FlutterProjectArgs).
Definition embedder.h:2513
A batch of updates to semantics nodes and custom actions.
Definition embedder.h:1851
size_t node_count
The number of semantics node updates.
Definition embedder.h:1855
size_t custom_action_count
The number of semantics custom action updates.
Definition embedder.h:1859
FlutterSemanticsNode2 ** nodes
Definition embedder.h:1857
FlutterSemanticsCustomAction2 ** custom_actions
Definition embedder.h:1862
FlutterViewId view_id
Definition embedder.h:1864
size_t struct_size
The size of this struct. Must be sizeof(FlutterTaskRunnerDescription).
Definition embedder.h:1919
BoolCallback runs_task_on_current_thread_callback
Definition embedder.h:1925
FlutterTaskRunnerPostTaskCallback post_task_callback
Definition embedder.h:1936

References action, args, argv, channel, FlutterSemanticsUpdate2::custom_action_count, FlutterSemanticsUpdate2::custom_actions, FLUTTER_ENGINE_VERSION, FML_DCHECK, FML_LOG, flutter::host, i, kSuccess, name, FlutterSemanticsUpdate2::node_count, FlutterSemanticsUpdate2::nodes, fml::PathToUtf8(), FlutterCustomTaskRunners::platform_task_runner, FlutterTaskRunnerDescription::post_task_callback, FlutterTaskRunnerDescription::runs_task_on_current_thread_callback, SAFE_ACCESS, FlutterTaskRunnerDescription::struct_size, FlutterCustomTaskRunners::struct_size, FlutterProjectArgs::struct_size, FlutterCustomTaskRunners::thread_priority_setter, FlutterCustomTaskRunners::ui_task_runner, user_data, FlutterTaskRunnerDescription::user_data, view, and FlutterSemanticsUpdate2::view_id.

◆ running()

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

Definition at line 125 of file flutter_windows_engine.h.

125{ return engine_ != nullptr; }

Referenced by flutter::HostWindow::InitializeFlutterView().

◆ ScheduleFrame()

void flutter::FlutterWindowsEngine::ScheduleFrame ( )

Definition at line 853 of file flutter_windows_engine.cc.

853 {
854 embedder_api_.ScheduleFrame(engine_);
855}
FlutterEngineScheduleFrameFnPtr ScheduleFrame
Definition embedder.h:3805

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

◆ semantics_enabled()

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

Definition at line 261 of file flutter_windows_engine.h.

261{ return semantics_enabled_; }

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

◆ SendKeyEvent()

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

Definition at line 779 of file flutter_windows_engine.cc.

781 {
782 if (engine_) {
783 embedder_api_.SendKeyEvent(engine_, &event, callback, user_data);
784 }
785}
FlutterEngineSendKeyEventFnPtr SendKeyEvent
Definition embedder.h:3776

References callback, and user_data.

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

799 {
800 FlutterPlatformMessageResponseHandle* response_handle = nullptr;
801 if (reply != nullptr && user_data != nullptr) {
802 FlutterEngineResult result =
804 engine_, reply, user_data, &response_handle);
805 if (result != kSuccess) {
806 FML_LOG(ERROR) << "Failed to create response handle";
807 return false;
808 }
809 }
810
811 FlutterPlatformMessage platform_message = {
813 channel,
814 message,
815 message_size,
816 response_handle,
817 };
818
819 FlutterEngineResult message_result =
820 embedder_api_.SendPlatformMessage(engine_, &platform_message);
821 if (response_handle != nullptr) {
822 embedder_api_.PlatformMessageReleaseResponseHandle(engine_,
823 response_handle);
824 }
825 return message_result == kSuccess;
826}
FlutterEnginePlatformMessageReleaseResponseHandleFnPtr PlatformMessageReleaseResponseHandle
Definition embedder.h:3781
FlutterEngineSendPlatformMessageFnPtr SendPlatformMessage
Definition embedder.h:3777
FlutterEnginePlatformMessageCreateResponseHandleFnPtr PlatformMessageCreateResponseHandle
Definition embedder.h:3779

References channel, FML_LOG, kSuccess, message, and user_data.

Referenced by FlutterDesktopMessengerSendWithReply().

◆ SendPlatformMessageResponse()

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

Definition at line 828 of file flutter_windows_engine.cc.

831 {
832 embedder_api_.SendPlatformMessageResponse(engine_, handle, data, data_length);
833}
FlutterEngineSendPlatformMessageResponseFnPtr SendPlatformMessageResponse
Definition embedder.h:3782

References flutter::data.

Referenced by FlutterDesktopMessengerSendResponse().

◆ SendPointerEvent()

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

Definition at line 773 of file flutter_windows_engine.cc.

773 {
774 if (engine_) {
775 embedder_api_.SendPointerEvent(engine_, &event, 1);
776 }
777}
FlutterEngineSendPointerEventFnPtr SendPointerEvent
Definition embedder.h:3775

◆ SendViewFocusEvent()

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

Definition at line 787 of file flutter_windows_engine.cc.

788 {
789 if (engine_) {
790 embedder_api_.SendViewFocusEvent(engine_, &event);
791 }
792}
FlutterEngineSendViewFocusEventFnPtr SendViewFocusEvent
Definition embedder.h:3809

◆ SendWindowMetricsEvent()

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

Definition at line 766 of file flutter_windows_engine.cc.

767 {
768 if (engine_) {
769 embedder_api_.SendWindowMetricsEvent(engine_, &event);
770 }
771}
FlutterEngineSendWindowMetricsEventFnPtr SendWindowMetricsEvent
Definition embedder.h:3774

Referenced by flutter::FlutterWindowsView::SendInitialBounds(), and flutter::FlutterWindowsView::SetSizedToContent().

◆ SetFlutterCursor()

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

Definition at line 1134 of file flutter_windows_engine.cc.

1134 {
1135 windows_proc_table_->SetCursor(cursor);
1136}

◆ SetNextFrameCallback()

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

Definition at line 857 of file flutter_windows_engine.cc.

857 {
858 next_frame_callback_ = std::move(callback);
859
860 embedder_api_.SetNextFrameCallback(
861 engine_,
862 [](void* user_data) {
863 // Embedder callback runs on raster thread. Switch back to platform
864 // thread.
866 static_cast<FlutterWindowsEngine*>(user_data);
867
868 self->task_runner_->PostTask(std::move(self->next_frame_callback_));
869 },
870 this);
871}
FlutterEngineSetNextFrameCallbackFnPtr SetNextFrameCallback
Definition embedder.h:3806

References callback, self, and user_data.

Referenced by FlutterDesktopEngineSetNextFrameCallback().

◆ SetRootIsolateCreateCallback()

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

Definition at line 286 of file flutter_windows_engine.h.

286 {
287 root_isolate_create_callback_ = callback;
288 }

References callback.

Referenced by flutter::testing::WindowsConfigBuilder::Run(), and flutter::testing::WindowsConfigBuilder::RunHeadless().

◆ SetSwitches()

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

Definition at line 276 of file flutter_windows_engine.cc.

277 {
278 project_->SetSwitches(switches);
279}

References SetSwitches().

Referenced by SetSwitches().

◆ Stop()

bool flutter::FlutterWindowsEngine::Stop ( )
virtual

Definition at line 548 of file flutter_windows_engine.cc.

548 {
549 if (engine_) {
550 window_manager_->OnEngineShutdown();
551 for (const auto& [callback, registrar] :
552 plugin_registrar_destruction_callbacks_) {
553 callback(registrar);
554 }
555 FlutterEngineResult result = embedder_api_.Shutdown(engine_);
556 engine_ = nullptr;
557 return (result == kSuccess);
558 }
559 return false;
560}
FlutterEngineShutdownFnPtr Shutdown
Definition embedder.h:3770

References callback, and kSuccess.

◆ task_runner()

◆ text_input_plugin()

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

Definition at line 206 of file flutter_windows_engine.h.

206{ return text_input_plugin_.get(); }

◆ texture_registrar()

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

Definition at line 177 of file flutter_windows_engine.h.

177 {
178 return texture_registrar_.get();
179 }

◆ UnregisterExternalTexture()

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

Definition at line 986 of file flutter_windows_engine.cc.

986 {
987 return (embedder_api_.UnregisterExternalTexture(engine_, texture_id) ==
988 kSuccess);
989}
FlutterEngineUnregisterExternalTextureFnPtr UnregisterExternalTexture
Definition embedder.h:3784

References kSuccess, and texture_id.

◆ UpdateAccessibilityFeatures()

void flutter::FlutterWindowsEngine::UpdateAccessibilityFeatures ( )

◆ UpdateDisplay()

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

Definition at line 757 of file flutter_windows_engine.cc.

758 {
759 if (engine_) {
760 embedder_api_.NotifyDisplayUpdate(engine_,
762 displays.data(), displays.size());
763 }
764}
@ kFlutterEngineDisplaysUpdateTypeStartup
Definition embedder.h:2379
std::vector< FlutterEngineDisplay > * displays
FlutterEngineNotifyDisplayUpdateFnPtr NotifyDisplayUpdate
Definition embedder.h:3804

References displays, and kFlutterEngineDisplaysUpdateTypeStartup.

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

◆ UpdateFlutterCursor()

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

Definition at line 1129 of file flutter_windows_engine.cc.

1130 {
1131 SetFlutterCursor(GetCursorByName(cursor_name));
1132}
void SetFlutterCursor(HCURSOR cursor) const

◆ UpdateHighContrastMode()

void flutter::FlutterWindowsEngine::UpdateHighContrastMode ( )

Definition at line 1068 of file flutter_windows_engine.cc.

1068 {
1069 high_contrast_enabled_ = windows_proc_table_->GetHighContrastEnabled();
1070
1071 SendAccessibilityFeatures();
1072 settings_plugin_->UpdateHighContrastMode(high_contrast_enabled_);
1073}

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

◆ UpdateSemanticsEnabled()

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

Definition at line 1033 of file flutter_windows_engine.cc.

1033 {
1034 if (engine_ && semantics_enabled_ != enabled) {
1035 std::shared_lock read_lock(views_mutex_);
1036
1037 semantics_enabled_ = enabled;
1038 embedder_api_.UpdateSemanticsEnabled(engine_, enabled);
1039 for (auto iterator = views_.begin(); iterator != views_.end(); iterator++) {
1040 iterator->second->UpdateSemanticsEnabled(enabled);
1041 }
1042 }
1043}
FlutterEngineUpdateSemanticsEnabledFnPtr UpdateSemanticsEnabled
Definition embedder.h:3787

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

◆ view()

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

Definition at line 735 of file flutter_windows_engine.cc.

735 {
736 std::shared_lock read_lock(views_mutex_);
737
738 auto iterator = views_.find(view_id);
739 if (iterator == views_.end()) {
740 return nullptr;
741 }
742
743 return iterator->second;
744}

References view_id.

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

◆ window_manager()

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

Definition at line 335 of file flutter_windows_engine.h.

335{ return window_manager_.get(); }

◆ window_proc_delegate_manager()

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

Definition at line 185 of file flutter_windows_engine.h.

185 {
186 return window_proc_delegate_manager_.get();
187 }

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

◆ windows_proc_table()

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

Definition at line 324 of file flutter_windows_engine.h.

324 {
325 return windows_proc_table_;
326 }

Referenced by flutter::HostWindowSized::ApplyContentSize(), CreateViewController(), and flutter::HostWindow::InitializeFlutterView().

Friends And Related Symbol Documentation

◆ EngineModifier

friend class EngineModifier
friend

Definition at line 373 of file flutter_windows_engine.h.


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