Flutter Windows Embedder
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< 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< LRESULT > ProcessExternalWindowMessage (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 
162  gl_ = egl::ProcTable::Create();
163 
164  embedder_api_.struct_size = sizeof(FlutterEngineProcTable);
165  FlutterEngineGetProcAddresses(&embedder_api_);
166 
167  task_runner_ =
168  std::make_unique<TaskRunner>(
169  embedder_api_.GetCurrentTime, [this](const auto* task) {
170  if (!engine_) {
171  FML_LOG(ERROR)
172  << "Cannot post an engine task when engine is not running.";
173  return;
174  }
175  if (embedder_api_.RunTask(engine_, task) != kSuccess) {
176  FML_LOG(ERROR) << "Failed to post an engine task.";
177  }
178  });
179 
180  // Set up the legacy structs backing the API handles.
181  messenger_ =
182  fml::RefPtr<FlutterDesktopMessenger>(new FlutterDesktopMessenger());
183  messenger_->SetEngine(this);
184  plugin_registrar_ = std::make_unique<FlutterDesktopPluginRegistrar>();
185  plugin_registrar_->engine = this;
186 
187  messenger_wrapper_ =
188  std::make_unique<BinaryMessengerImpl>(messenger_->ToRef());
189  message_dispatcher_ =
190  std::make_unique<IncomingMessageDispatcher>(messenger_->ToRef());
191 
192  texture_registrar_ =
193  std::make_unique<FlutterWindowsTextureRegistrar>(this, gl_);
194 
195  // Check for impeller support.
196  auto& switches = project_->GetSwitches();
197  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) {
222  BASE_DCHECK(user_data);
223  FlutterWindowsEngine* that =
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)
std::shared_ptr< WindowsProcTable > windows_proc_table()
FlutterWindowsEngine(const FlutterProjectBundle &project, std::shared_ptr< WindowsProcTable > windows_proc_table=nullptr)
static std::unique_ptr< Manager > Create(GpuPreference gpu_preference)
Definition: manager.cc:17
static std::shared_ptr< ProcTable > Create()
Definition: proc_table.cc:12

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

◆ ~FlutterWindowsEngine()

flutter::FlutterWindowsEngine::~FlutterWindowsEngine ( )
virtual

Definition at line 267 of file flutter_windows_engine.cc.

267  {
268  messenger_->SetEngine(nullptr);
269  Stop();
270 }

Member Function Documentation

◆ AddPluginRegistrarDestructionCallback()

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

Definition at line 761 of file flutter_windows_engine.cc.

763  {
764  plugin_registrar_destruction_callbacks_[callback] = registrar;
765 }
FlutterDesktopBinaryReply callback

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

971  {
972  auto keyboard_key_handler = std::make_unique<KeyboardKeyHandler>(messenger);
973  keyboard_key_handler->AddDelegate(
974  std::make_unique<KeyboardKeyEmbedderHandler>(
975  [this](const FlutterKeyEvent& event, FlutterKeyEventCallback callback,
976  void* user_data) {
977  return SendKeyEvent(event, callback, user_data);
978  },
979  get_key_state, map_vk_to_scan));
980  keyboard_key_handler->AddDelegate(
981  std::make_unique<KeyboardKeyChannelHandler>(messenger));
982  keyboard_key_handler->InitKeyboardChannel();
983  return keyboard_key_handler;
984 }
FlutterDesktopMessengerRef messenger()
KeyboardHandlerBase * keyboard_key_handler()
void SendKeyEvent(const FlutterKeyEvent &event, FlutterKeyEventCallback callback, void *user_data)

References callback, and user_data.

◆ CreateTextInputPlugin()

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

Definition at line 986 of file flutter_windows_engine.cc.

987  {
988  return std::make_unique<TextInputPlugin>(messenger, this);
989 }

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

576  {
577  auto view_id = next_view_id_;
578  auto view = std::make_unique<FlutterWindowsView>(
579  view_id, this, std::move(window), is_sized_to_content, box_constraints,
580  sizing_delegate, windows_proc_table_);
581 
583  view->UpdateSemanticsEnabled(semantics_enabled_);
584 
585  next_view_id_++;
586 
587  {
588  // Add the view to the embedder. This must happen before the engine
589  // is notified the view exists and starts presenting to it.
590  std::unique_lock write_lock(views_mutex_);
591  FML_DCHECK(views_.find(view_id) == views_.end());
592  views_[view_id] = view.get();
593  }
594 
595  if (!view->IsImplicitView()) {
596  FML_DCHECK(running());
597 
598  struct Captures {
599  fml::AutoResetWaitableEvent latch;
600  bool added;
601  };
602  Captures captures = {};
603 
604  FlutterWindowMetricsEvent metrics = view->CreateWindowMetricsEvent();
605 
606  FlutterAddViewInfo info = {};
607  info.struct_size = sizeof(FlutterAddViewInfo);
608  info.view_id = view_id;
609  info.view_metrics = &metrics;
610  info.user_data = &captures;
611  info.add_view_callback = [](const FlutterAddViewResult* result) {
612  Captures* captures = reinterpret_cast<Captures*>(result->user_data);
613  captures->added = result->added;
614  captures->latch.Signal();
615  };
616 
617  FlutterEngineResult result = embedder_api_.AddView(engine_, &info);
618  if (result != kSuccess) {
619  FML_LOG(ERROR)
620  << "Starting the add view operation failed. FlutterEngineAddView "
621  "returned an unexpected result: "
622  << result << ". This indicates a bug in the Windows embedder.";
623  FML_DCHECK(false);
624  return nullptr;
625  }
626 
627  // Block the platform thread until the engine has added the view.
628  // TODO(loicsharma): This blocks the platform thread eagerly and can
629  // cause unnecessary delay in input processing. Instead, this should block
630  // lazily only when the app does an operation which needs the view.
631  // https://github.com/flutter/flutter/issues/146248
632  captures.latch.Wait();
633 
634  if (!captures.added) {
635  // Adding the view failed. Update the embedder's state to match the
636  // engine's state. This is unexpected and indicates a bug in the Windows
637  // embedder.
638  FML_LOG(ERROR) << "FlutterEngineAddView failed to add view";
639  std::unique_lock write_lock(views_mutex_);
640  views_.erase(view_id);
641  return nullptr;
642  }
643  }
644 
645  return std::move(view);
646 }
FlutterWindowsView * view(FlutterViewId view_id) const
virtual void UpdateSemanticsEnabled(bool enabled)
FlutterWindowMetricsEvent CreateWindowMetricsEvent() const

Referenced by CreateViewController(), flutter::HostWindow::InitializeFlutterView(), 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 1027 of file flutter_windows_engine.cc.

1031  {
1032  FlutterSendSemanticsActionInfo info{
1033  .struct_size = sizeof(FlutterSendSemanticsActionInfo),
1034  .view_id = view_id,
1035  .node_id = target,
1036  .action = action,
1037  .data = data.GetMapping(),
1038  .data_length = data.GetSize(),
1039  };
1040  return (embedder_api_.SendSemanticsAction(engine_, &info));
1041 }

References action.

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

1060  {
1061  std::pair<bool, std::string> result = fml::paths::GetExecutablePath();
1062  if (result.first) {
1063  const std::string& executable_path = result.second;
1064  size_t last_separator = executable_path.find_last_of("/\\");
1065  if (last_separator == std::string::npos ||
1066  last_separator == executable_path.size() - 1) {
1067  return executable_path;
1068  }
1069  return executable_path.substr(last_separator + 1);
1070  }
1071  return "Flutter";
1072 }

◆ GetRegistrar()

FlutterDesktopPluginRegistrarRef flutter::FlutterWindowsEngine::GetRegistrar ( )

Definition at line 757 of file flutter_windows_engine.cc.

757  {
758  return plugin_registrar_.get();
759 }

Referenced by FlutterDesktopEngineGetPluginRegistrar().

◆ GetViewFromTopLevelWindow()

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

Definition at line 921 of file flutter_windows_engine.cc.

922  {
923  std::shared_lock read_lock(views_mutex_);
924  auto const iterator =
925  std::find_if(views_.begin(), views_.end(), [hwnd](auto const& pair) {
926  FlutterWindowsView* const view = pair.second;
927  return GetAncestor(view->GetWindowHandle(), GA_ROOT) == hwnd;
928  });
929  if (iterator != views_.end()) {
930  return iterator->second;
931  }
932  return nullptr;
933 }

◆ HandlePlatformMessage()

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

Definition at line 845 of file flutter_windows_engine.cc.

846  {
847  if (engine_message->struct_size != sizeof(FlutterPlatformMessage)) {
848  FML_LOG(ERROR) << "Invalid message size received. Expected: "
849  << sizeof(FlutterPlatformMessage) << " but received "
850  << engine_message->struct_size;
851  return;
852  }
853 
854  auto message = ConvertToDesktopMessage(*engine_message);
855 
856  message_dispatcher_->HandleMessage(message, [this] {}, [this] {});
857 }
Win32Message message

References message.

Referenced by Run().

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

1002  {
1003  return (embedder_api_.MarkExternalTextureFrameAvailable(
1004  engine_, texture_id) == kSuccess);
1005 }
uint32_t 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(); }

Referenced by FlutterDesktopEngineGetMessenger(), and FlutterDesktopPluginRegistrarGetMessenger().

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

1148  {
1149  if (name == "flutter/platform" && listening) {
1150  lifecycle_manager_->BeginProcessingExit();
1151  } else if (name == "flutter/lifecycle" && listening) {
1152  lifecycle_manager_->BeginProcessingLifecycle();
1153  }
1154 }

◆ OnDwmCompositionChanged()

void flutter::FlutterWindowsEngine::OnDwmCompositionChanged ( )

Definition at line 1111 of file flutter_windows_engine.cc.

1111  {
1112  if (display_manager_) {
1113  display_manager_->UpdateDisplays();
1114  }
1115 
1116  std::shared_lock read_lock(views_mutex_);
1117  for (auto iterator = views_.begin(); iterator != views_.end(); iterator++) {
1118  iterator->second->OnDwmCompositionChanged();
1119  }
1120 }

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

◆ OnPreEngineRestart()

void flutter::FlutterWindowsEngine::OnPreEngineRestart ( )
protected

Definition at line 1055 of file flutter_windows_engine.cc.

1055  {
1056  // Reset the keyboard's state on hot restart.
1057  InitializeKeyboard();
1058 }

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

1107  {
1108  lifecycle_manager_->Quit(hwnd, wparam, lparam, exit_code);
1109 }

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

◆ OnViewFocusChangeRequest()

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

Definition at line 1156 of file flutter_windows_engine.cc.

1157  {
1158  std::shared_lock read_lock(views_mutex_);
1159 
1160  auto iterator = views_.find(request->view_id);
1161  if (iterator == views_.end()) {
1162  return;
1163  }
1164 
1165  FlutterWindowsView* view = iterator->second;
1166  view->Focus();
1167 }

References flutter::FlutterWindowsView::Focus().

Referenced by Run().

◆ OnVsync()

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

Definition at line 717 of file flutter_windows_engine.cc.

717  {
718  std::chrono::nanoseconds current_time =
719  std::chrono::nanoseconds(embedder_api_.GetCurrentTime());
720  std::chrono::nanoseconds frame_interval = FrameInterval();
721  auto next = SnapToNextTick(current_time, start_time_, frame_interval);
722  embedder_api_.OnVsync(engine_, baton, next.count(),
723  (next + frame_interval).count());
724 }

Referenced by Run().

◆ OnWindowStateEvent()

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

Definition at line 1122 of file flutter_windows_engine.cc.

1123  {
1124  lifecycle_manager_->OnWindowStateEvent(hwnd, event);
1125 }

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

◆ PostRasterThreadTask()

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

Definition at line 1007 of file flutter_windows_engine.cc.

1007  {
1008  struct Captures {
1009  fml::closure callback;
1010  };
1011  auto captures = new Captures();
1012  captures->callback = std::move(callback);
1013  if (embedder_api_.PostRenderThreadTask(
1014  engine_,
1015  [](void* opaque) {
1016  auto captures = reinterpret_cast<Captures*>(opaque);
1017  captures->callback();
1018  delete captures;
1019  },
1020  captures) == kSuccess) {
1021  return true;
1022  }
1023  delete captures;
1024  return false;
1025 }

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

1131  {
1132  if (lifecycle_manager_) {
1133  return lifecycle_manager_->ExternalWindowMessage(hwnd, message, wparam,
1134  lparam);
1135  }
1136  return std::nullopt;
1137 }

References message.

Referenced by FlutterDesktopEngineProcessExternalWindowMessage().

◆ RegisterExternalTexture()

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

Definition at line 991 of file flutter_windows_engine.cc.

991  {
992  return (embedder_api_.RegisterExternalTexture(engine_, texture_id) ==
993  kSuccess);
994 }

◆ ReloadSystemFonts()

void flutter::FlutterWindowsEngine::ReloadSystemFonts ( )

Definition at line 859 of file flutter_windows_engine.cc.

859  {
860  embedder_api_.ReloadSystemFonts(engine_);
861 }

Referenced by FlutterDesktopEngineReloadSystemFonts().

◆ RemoveView()

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

Definition at line 648 of file flutter_windows_engine.cc.

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

References flutter::kImplicitViewId.

◆ RequestApplicationQuit()

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

Definition at line 1097 of file flutter_windows_engine.cc.

1100  {
1101  platform_handler_->RequestAppExit(hwnd, wparam, lparam, exit_type, 0);
1102 }

◆ 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  if (project_->enable_flutter_gpu()) {
330  if (std::find(switches.begin(), switches.end(), "--enable-flutter-gpu") ==
331  switches.end() &&
332  std::find(switches.begin(), switches.end(),
333  "--enable-flutter-gpu=true") == switches.end()) {
334  // Flutter GPU was enabled programmatically, so forward the switch to
335  // the engine.
336  switches.push_back("--enable-flutter-gpu");
337  }
338  }
339  std::transform(
340  switches.begin(), switches.end(), std::back_inserter(argv),
341  [](const std::string& arg) -> const char* { return arg.c_str(); });
342 
343  const std::vector<std::string>& entrypoint_args =
344  project_->dart_entrypoint_arguments();
345  std::vector<const char*> entrypoint_argv;
346  std::transform(
347  entrypoint_args.begin(), entrypoint_args.end(),
348  std::back_inserter(entrypoint_argv),
349  [](const std::string& arg) -> const char* { return arg.c_str(); });
350 
351  // Configure task runners.
352  FlutterTaskRunnerDescription platform_task_runner = {};
353  platform_task_runner.struct_size = sizeof(FlutterTaskRunnerDescription);
354  platform_task_runner.user_data = task_runner_.get();
355  platform_task_runner.runs_task_on_current_thread_callback =
356  [](void* user_data) -> bool {
357  return static_cast<TaskRunner*>(user_data)->RunsTasksOnCurrentThread();
358  };
359  platform_task_runner.post_task_callback = [](FlutterTask task,
360  uint64_t target_time_nanos,
361  void* user_data) -> void {
362  static_cast<TaskRunner*>(user_data)->PostFlutterTask(task,
363  target_time_nanos);
364  };
365  FlutterCustomTaskRunners custom_task_runners = {};
366  custom_task_runners.struct_size = sizeof(FlutterCustomTaskRunners);
367  custom_task_runners.platform_task_runner = &platform_task_runner;
368  custom_task_runners.thread_priority_setter =
370 
371  if (project_->ui_thread_policy() !=
373  custom_task_runners.ui_task_runner = &platform_task_runner;
374  } else {
375  FML_LOG(WARNING) << "Running with unmerged platform and UI threads. This "
376  "will be removed in future.";
377  }
378 
379  FlutterProjectArgs args = {};
380  args.struct_size = sizeof(FlutterProjectArgs);
381  args.shutdown_dart_vm_when_done = true;
382  args.assets_path = assets_path_string.c_str();
383  args.icu_data_path = icu_path_string.c_str();
384  args.command_line_argc = static_cast<int>(argv.size());
385  args.command_line_argv = argv.empty() ? nullptr : argv.data();
386  args.engine_id = reinterpret_cast<int64_t>(this);
387 
388  // Fail if conflicting non-default entrypoints are specified in the method
389  // argument and the project.
390  //
391  // TODO(cbracken): https://github.com/flutter/flutter/issues/109285
392  // The entrypoint method parameter should eventually be removed from this
393  // method and only the entrypoint specified in project_ should be used.
394  if (!project_->dart_entrypoint().empty() && !entrypoint.empty() &&
395  project_->dart_entrypoint() != entrypoint) {
396  FML_LOG(ERROR) << "Conflicting entrypoints were specified in "
397  "FlutterDesktopEngineProperties.dart_entrypoint and "
398  "FlutterDesktopEngineRun(engine, entry_point). ";
399  return false;
400  }
401  if (!entrypoint.empty()) {
402  args.custom_dart_entrypoint = entrypoint.data();
403  } else if (!project_->dart_entrypoint().empty()) {
404  args.custom_dart_entrypoint = project_->dart_entrypoint().c_str();
405  }
406  args.dart_entrypoint_argc = static_cast<int>(entrypoint_argv.size());
407  args.dart_entrypoint_argv =
408  entrypoint_argv.empty() ? nullptr : entrypoint_argv.data();
409  args.platform_message_callback =
410  [](const FlutterPlatformMessage* engine_message,
411  void* user_data) -> void {
412  auto host = static_cast<FlutterWindowsEngine*>(user_data);
413  return host->HandlePlatformMessage(engine_message);
414  };
415  args.vsync_callback = [](void* user_data, intptr_t baton) -> void {
416  auto host = static_cast<FlutterWindowsEngine*>(user_data);
417  host->OnVsync(baton);
418  };
419  args.on_pre_engine_restart_callback = [](void* user_data) {
420  auto host = static_cast<FlutterWindowsEngine*>(user_data);
421  host->OnPreEngineRestart();
422  };
423  args.update_semantics_callback2 = [](const FlutterSemanticsUpdate2* update,
424  void* user_data) {
425  auto host = static_cast<FlutterWindowsEngine*>(user_data);
426 
427  auto view = host->view(update->view_id);
428  if (!view) {
429  return;
430  }
431 
432  auto accessibility_bridge = view->accessibility_bridge().lock();
433  if (!accessibility_bridge) {
434  return;
435  }
436 
437  for (size_t i = 0; i < update->node_count; i++) {
438  const FlutterSemanticsNode2* node = update->nodes[i];
439  accessibility_bridge->AddFlutterSemanticsNodeUpdate(*node);
440  }
441 
442  for (size_t i = 0; i < update->custom_action_count; i++) {
443  const FlutterSemanticsCustomAction2* action = update->custom_actions[i];
444  accessibility_bridge->AddFlutterSemanticsCustomActionUpdate(*action);
445  }
446 
447  accessibility_bridge->CommitUpdates();
448  };
449  args.root_isolate_create_callback = [](void* user_data) {
450  auto host = static_cast<FlutterWindowsEngine*>(user_data);
451  if (host->root_isolate_create_callback_) {
452  host->root_isolate_create_callback_();
453  }
454  };
455  args.channel_update_callback = [](const FlutterChannelUpdate* update,
456  void* user_data) {
457  auto host = static_cast<FlutterWindowsEngine*>(user_data);
458  if (SAFE_ACCESS(update, channel, nullptr) != nullptr) {
459  std::string channel_name(update->channel);
460  host->OnChannelUpdate(std::move(channel_name),
461  SAFE_ACCESS(update, listening, false));
462  }
463  };
464  args.view_focus_change_request_callback =
465  [](const FlutterViewFocusChangeRequest* request, void* user_data) {
466  auto host = static_cast<FlutterWindowsEngine*>(user_data);
467  host->OnViewFocusChangeRequest(request);
468  };
469 
470  args.custom_task_runners = &custom_task_runners;
471 
472  if (!platform_view_plugin_) {
473  platform_view_plugin_ = std::make_unique<PlatformViewPlugin>(
474  messenger_wrapper_.get(), task_runner_.get());
475  }
476  if (egl_manager_) {
477  auto resolver = [](const char* name) -> void* {
478  return reinterpret_cast<void*>(::eglGetProcAddress(name));
479  };
480 
481  // TODO(schectman) Pass the platform view manager to the compositor
482  // constructors: https://github.com/flutter/flutter/issues/143375
483  compositor_ =
484  std::make_unique<CompositorOpenGL>(this, resolver, enable_impeller_);
485  } else {
486  compositor_ = std::make_unique<CompositorSoftware>();
487  }
488 
489  FlutterCompositor compositor = {};
490  compositor.struct_size = sizeof(FlutterCompositor);
491  compositor.user_data = this;
492  compositor.create_backing_store_callback =
493  [](const FlutterBackingStoreConfig* config,
494  FlutterBackingStore* backing_store_out, void* user_data) -> bool {
495  auto host = static_cast<FlutterWindowsEngine*>(user_data);
496 
497  return host->compositor_->CreateBackingStore(*config, backing_store_out);
498  };
499 
500  compositor.collect_backing_store_callback =
501  [](const FlutterBackingStore* backing_store, void* user_data) -> bool {
502  auto host = static_cast<FlutterWindowsEngine*>(user_data);
503 
504  return host->compositor_->CollectBackingStore(backing_store);
505  };
506 
507  compositor.present_view_callback =
508  [](const FlutterPresentViewInfo* info) -> bool {
509  auto host = static_cast<FlutterWindowsEngine*>(info->user_data);
510 
511  return host->Present(info);
512  };
513  args.compositor = &compositor;
514 
515  if (aot_data_) {
516  args.aot_data = aot_data_.get();
517  }
518 
519  // The platform thread creates OpenGL contexts. These
520  // must be released to be used by the engine's threads.
521  FML_DCHECK(!egl_manager_ || !egl_manager_->HasContextCurrent());
522 
523  FlutterRendererConfig renderer_config;
524 
525  if (enable_impeller_) {
526  // Impeller does not support a Software backend. Avoid falling back and
527  // confusing the engine on which renderer is selected.
528  if (!egl_manager_) {
529  FML_LOG(ERROR) << "Could not create surface manager. Impeller backend "
530  "does not support software rendering.";
531  return false;
532  }
533  renderer_config = GetOpenGLRendererConfig();
534  } else {
535  renderer_config =
536  egl_manager_ ? GetOpenGLRendererConfig() : GetSoftwareRendererConfig();
537  }
538 
539  auto result = embedder_api_.Run(FLUTTER_ENGINE_VERSION, &renderer_config,
540  &args, this, &engine_);
541  if (result != kSuccess || engine_ == nullptr) {
542  FML_LOG(ERROR) << "Failed to start Flutter engine: error " << result;
543  return false;
544  }
545 
546  display_manager_->UpdateDisplays();
547 
548  SendSystemLocales();
549 
550  settings_plugin_->StartWatching();
551  settings_plugin_->SendSettings();
552 
553  InitializeKeyboard();
554 
555  return true;
556 }
std::weak_ptr< AccessibilityBridgeWindows > accessibility_bridge()
static void WindowsPlatformThreadPrioritySetter(FlutterThreadPriority priority)

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

125 { return engine_ != nullptr; }

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

◆ ScheduleFrame()

void flutter::FlutterWindowsEngine::ScheduleFrame ( )

Definition at line 863 of file flutter_windows_engine.cc.

863  {
864  embedder_api_.ScheduleFrame(engine_);
865 }

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

791  {
792  if (engine_) {
793  embedder_api_.SendKeyEvent(engine_, &event, callback, user_data);
794  }
795 }

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

809  {
810  FlutterPlatformMessageResponseHandle* response_handle = nullptr;
811  if (reply != nullptr && user_data != nullptr) {
812  FlutterEngineResult result =
813  embedder_api_.PlatformMessageCreateResponseHandle(
814  engine_, reply, user_data, &response_handle);
815  if (result != kSuccess) {
816  FML_LOG(ERROR) << "Failed to create response handle";
817  return false;
818  }
819  }
820 
821  FlutterPlatformMessage platform_message = {
822  sizeof(FlutterPlatformMessage),
823  channel,
824  message,
825  message_size,
826  response_handle,
827  };
828 
829  FlutterEngineResult message_result =
830  embedder_api_.SendPlatformMessage(engine_, &platform_message);
831  if (response_handle != nullptr) {
832  embedder_api_.PlatformMessageReleaseResponseHandle(engine_,
833  response_handle);
834  }
835  return message_result == kSuccess;
836 }

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

841  {
842  embedder_api_.SendPlatformMessageResponse(engine_, handle, data, data_length);
843 }

Referenced by FlutterDesktopMessengerSendResponse().

◆ SendPointerEvent()

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

Definition at line 783 of file flutter_windows_engine.cc.

783  {
784  if (engine_) {
785  embedder_api_.SendPointerEvent(engine_, &event, 1);
786  }
787 }

◆ SendViewFocusEvent()

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

Definition at line 797 of file flutter_windows_engine.cc.

798  {
799  if (engine_) {
800  embedder_api_.SendViewFocusEvent(engine_, &event);
801  }
802 }

◆ SendWindowMetricsEvent()

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

Definition at line 776 of file flutter_windows_engine.cc.

777  {
778  if (engine_) {
779  embedder_api_.SendWindowMetricsEvent(engine_, &event);
780  }
781 }

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

◆ SetFlutterCursor()

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

Definition at line 1144 of file flutter_windows_engine.cc.

1144  {
1145  windows_proc_table_->SetCursor(cursor);
1146 }

◆ SetNextFrameCallback()

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

Definition at line 867 of file flutter_windows_engine.cc.

867  {
868  next_frame_callback_ = std::move(callback);
869 
870  embedder_api_.SetNextFrameCallback(
871  engine_,
872  [](void* user_data) {
873  // Embedder callback runs on raster thread. Switch back to platform
874  // thread.
875  FlutterWindowsEngine* self =
876  static_cast<FlutterWindowsEngine*>(user_data);
877 
878  self->task_runner_->PostTask(std::move(self->next_frame_callback_));
879  },
880  this);
881 }

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.

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

558  {
559  if (engine_) {
560  window_manager_->OnEngineShutdown();
561  for (const auto& [callback, registrar] :
562  plugin_registrar_destruction_callbacks_) {
563  callback(registrar);
564  }
565  FlutterEngineResult result = embedder_api_.Shutdown(engine_);
566  engine_ = nullptr;
567  return (result == kSuccess);
568  }
569  return false;
570 }

Referenced by FlutterDesktopEngineDestroy().

◆ 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  }

Referenced by FlutterDesktopRegistrarGetTextureRegistrar().

◆ UnregisterExternalTexture()

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

Definition at line 996 of file flutter_windows_engine.cc.

996  {
997  return (embedder_api_.UnregisterExternalTexture(engine_, texture_id) ==
998  kSuccess);
999 }

◆ UpdateAccessibilityFeatures()

void flutter::FlutterWindowsEngine::UpdateAccessibilityFeatures ( )

◆ UpdateDisplay()

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

Definition at line 767 of file flutter_windows_engine.cc.

768  {
769  if (engine_) {
770  embedder_api_.NotifyDisplayUpdate(engine_,
771  kFlutterEngineDisplaysUpdateTypeStartup,
772  displays.data(), displays.size());
773  }
774 }
std::vector< FlutterEngineDisplay > * displays

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

◆ UpdateFlutterCursor()

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

Definition at line 1139 of file flutter_windows_engine.cc.

1140  {
1141  SetFlutterCursor(GetCursorByName(cursor_name));
1142 }
void SetFlutterCursor(HCURSOR cursor) const

◆ UpdateHighContrastMode()

void flutter::FlutterWindowsEngine::UpdateHighContrastMode ( )

Definition at line 1078 of file flutter_windows_engine.cc.

1078  {
1079  high_contrast_enabled_ = windows_proc_table_->GetHighContrastEnabled();
1080 
1081  SendAccessibilityFeatures();
1082  settings_plugin_->UpdateHighContrastMode(high_contrast_enabled_);
1083 }

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

◆ UpdateSemanticsEnabled()

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

Definition at line 1043 of file flutter_windows_engine.cc.

1043  {
1044  if (engine_ && semantics_enabled_ != enabled) {
1045  std::shared_lock read_lock(views_mutex_);
1046 
1047  semantics_enabled_ = enabled;
1048  embedder_api_.UpdateSemanticsEnabled(engine_, enabled);
1049  for (auto iterator = views_.begin(); iterator != views_.end(); iterator++) {
1050  iterator->second->UpdateSemanticsEnabled(enabled);
1051  }
1052  }
1053 }

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

◆ view()

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

Definition at line 745 of file flutter_windows_engine.cc.

745  {
746  std::shared_lock read_lock(views_mutex_);
747 
748  auto iterator = views_.find(view_id);
749  if (iterator == views_.end()) {
750  return nullptr;
751  }
752 
753  return iterator->second;
754 }

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

◆ window_manager()

◆ window_proc_delegate_manager()

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

◆ 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 Function 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: