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< FlutterWindowsView > CreateView (std::unique_ptr< WindowBindingHandler > window, bool is_sized_to_content, const BoxConstraints &box_constraints, bool allow_implicit_view, FlutterWindowsViewSizingDelegate *sizing_delegate=nullptr)
 
virtual void RemoveView (FlutterViewId view_id)
 
FlutterWindowsView * view (FlutterViewId view_id) const
 
FlutterDesktopPluginRegistrarRef GetRegistrar ()
 
void AddPluginRegistrarDestructionCallback (FlutterDesktopOnPluginRegistrarDestroyed callback, FlutterDesktopPluginRegistrarRef registrar)
 
void SetSwitches (const std::vector< std::string > &switches)
 
FlutterDesktopMessengerRef messenger ()
 
IncomingMessageDispatcher * message_dispatcher ()
 
std::shared_ptr< DisplayManagerWin32 > display_manager ()
 
void UpdateDisplay (const std::vector< FlutterEngineDisplay > &displays)
 
TaskRunner * task_runner ()
 
BinaryMessenger * messenger_wrapper ()
 
FlutterWindowsTextureRegistrar * texture_registrar ()
 
egl::Manager * egl_manager () const
 
WindowProcDelegateManager * window_proc_delegate_manager ()
 
void SendWindowMetricsEvent (const FlutterWindowMetricsEvent &event)
 
void SendPointerEvent (const FlutterPointerEvent &event)
 
void SendKeyEvent (const FlutterKeyEvent &event, FlutterKeyEventCallback callback, void *user_data)
 
void SendViewFocusEvent (const FlutterViewFocusEvent &event)
 
KeyboardHandlerBase * keyboard_key_handler ()
 
TextInputPlugin * text_input_plugin ()
 
bool SendPlatformMessage (const char *channel, const uint8_t *message, const size_t message_size, const FlutterDesktopBinaryReply reply, void *user_data)
 
void SendPlatformMessageResponse (const FlutterDesktopMessageResponseHandle *handle, const uint8_t *data, size_t data_length)
 
void HandlePlatformMessage (const FlutterPlatformMessage *)
 
void ReloadSystemFonts ()
 
void ScheduleFrame ()
 
void SetNextFrameCallback (fml::closure callback)
 
bool RegisterExternalTexture (int64_t texture_id)
 
bool UnregisterExternalTexture (int64_t texture_id)
 
bool MarkExternalTextureFrameAvailable (int64_t texture_id)
 
virtual bool PostRasterThreadTask (fml::closure callback) const
 
void OnVsync (intptr_t baton)
 
bool DispatchSemanticsAction (FlutterViewId view_id, uint64_t node_id, FlutterSemanticsAction action, fml::MallocMapping data)
 
void UpdateSemanticsEnabled (bool enabled)
 
bool semantics_enabled () const
 
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)
 
WindowsLifecycleManager * lifecycle_manager ()
 
std::shared_ptr< WindowsProcTable > windows_proc_table ()
 
void UpdateFlutterCursor (const std::string &cursor_name) const
 
void SetFlutterCursor (HCURSOR cursor) const
 
WindowManager * window_manager ()
 
FlutterWindowsView * GetViewFromTopLevelWindow (HWND hwnd) const
 

Static Public Member Functions

static FlutterWindowsEngine * GetEngineForId (int64_t engine_id)
 

Protected Member Functions

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

Friends

class EngineModifier
 

Detailed Description

Definition at line 92 of file flutter_windows_engine.h.

Constructor & Destructor Documentation

◆ FlutterWindowsEngine()

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

Definition at line 151 of file flutter_windows_engine.cc.

154  : project_(std::make_unique<FlutterProjectBundle>(project)),
155  windows_proc_table_(std::move(windows_proc_table)),
156  aot_data_(nullptr, nullptr),
157  lifecycle_manager_(std::make_unique<WindowsLifecycleManager>(this)) {
158  if (windows_proc_table_ == nullptr) {
159  windows_proc_table_ = std::make_shared<WindowsProcTable>();
160  }
161 
162  gl_ = egl::ProcTable::Create();
163 
164  embedder_api_.struct_size = sizeof(FlutterEngineProcTable);
165  FlutterEngineGetProcAddresses(&embedder_api_);
166 
167  task_runner_ =
168  std::make_unique<TaskRunner>(
169  embedder_api_.GetCurrentTime, [this](const auto* task) {
170  if (!engine_) {
171  FML_LOG(ERROR)
172  << "Cannot post an engine task when engine is not running.";
173  return;
174  }
175  if (embedder_api_.RunTask(engine_, task) != kSuccess) {
176  FML_LOG(ERROR) << "Failed to post an engine task.";
177  }
178  });
179 
180  // Set up the legacy structs backing the API handles.
181  messenger_ =
182  fml::RefPtr<FlutterDesktopMessenger>(new FlutterDesktopMessenger());
183  messenger_->SetEngine(this);
184  plugin_registrar_ = std::make_unique<FlutterDesktopPluginRegistrar>();
185  plugin_registrar_->engine = this;
186 
187  messenger_wrapper_ =
188  std::make_unique<BinaryMessengerImpl>(messenger_->ToRef());
189  message_dispatcher_ =
190  std::make_unique<IncomingMessageDispatcher>(messenger_->ToRef());
191 
192  texture_registrar_ =
193  std::make_unique<FlutterWindowsTextureRegistrar>(this, gl_);
194 
195  // Check for impeller support.
196  auto& switches = project_->GetSwitches();
197  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  // Only Impeller knows how to render into a top-left origin default
214  // framebuffer. The Skia path still expects OpenGL's bottom-left origin.
215  egl_manager_ = egl::Manager::Create(
216  static_cast<egl::GpuPreference>(project_->gpu_preference()),
217  /*allow_inverted_surface=*/enable_impeller_);
218  window_proc_delegate_manager_ = std::make_unique<WindowProcDelegateManager>();
219 
220  display_manager_ = std::make_shared<DisplayManagerWin32>(this);
221 
222  window_proc_delegate_manager_->RegisterTopLevelWindowProcDelegate(
223  [](HWND hwnd, UINT msg, WPARAM wpar, LPARAM lpar, void* user_data,
224  LRESULT* result) {
225  BASE_DCHECK(user_data);
226  FlutterWindowsEngine* that =
227  static_cast<FlutterWindowsEngine*>(user_data);
228 
229  BASE_DCHECK(that->display_manager_);
230  if (that->display_manager_->HandleWindowMessage(hwnd, msg, wpar, lpar,
231  result)) {
232  return true;
233  }
234 
235  BASE_DCHECK(that->lifecycle_manager_);
236  bool handled =
237  that->lifecycle_manager_->WindowProc(hwnd, msg, wpar, lpar, result);
238  if (handled) {
239  return true;
240  }
241  auto message_result =
242  that->window_manager_->HandleMessage(hwnd, msg, wpar, lpar);
243  if (message_result) {
244  *result = *message_result;
245  return true;
246  }
247  return false;
248  },
249  static_cast<void*>(this));
250 
251  // Set up internal channels.
252  // TODO: Replace this with an embedder.h API. See
253  // https://github.com/flutter/flutter/issues/71099
254  internal_plugin_registrar_ =
255  std::make_unique<PluginRegistrar>(plugin_registrar_.get());
256 
257  accessibility_plugin_ = std::make_unique<AccessibilityPlugin>(this);
258  AccessibilityPlugin::SetUp(messenger_wrapper_.get(),
259  accessibility_plugin_.get());
260 
261  cursor_handler_ =
262  std::make_unique<CursorHandler>(messenger_wrapper_.get(), this);
263  platform_handler_ =
264  std::make_unique<PlatformHandler>(messenger_wrapper_.get(), this);
265  window_manager_ = std::make_unique<WindowManager>(this);
266  settings_plugin_ = std::make_unique<SettingsPlugin>(messenger_wrapper_.get(),
267  task_runner_.get());
268 }
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, bool allow_inverted_surface, std::optional< D3DFeatureLevel > max_feature_level=std::nullopt)
Definition: manager.cc:61
static std::shared_ptr< ProcTable > Create()
Definition: proc_table.cc:12

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

◆ ~FlutterWindowsEngine()

flutter::FlutterWindowsEngine::~FlutterWindowsEngine ( )
virtual

Definition at line 270 of file flutter_windows_engine.cc.

270  {
271  messenger_->SetEngine(nullptr);
272  Stop();
273 }

Member Function Documentation

◆ AddPluginRegistrarDestructionCallback()

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

Definition at line 776 of file flutter_windows_engine.cc.

778  {
779  plugin_registrar_destruction_callbacks_[callback] = registrar;
780 }
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 983 of file flutter_windows_engine.cc.

986  {
987  auto keyboard_key_handler = std::make_unique<KeyboardKeyHandler>(messenger);
988  keyboard_key_handler->AddDelegate(
989  std::make_unique<KeyboardKeyEmbedderHandler>(
990  [this](const FlutterKeyEvent& event, FlutterKeyEventCallback callback,
991  void* user_data) {
992  return SendKeyEvent(event, callback, user_data);
993  },
994  get_key_state, map_vk_to_scan));
995  keyboard_key_handler->AddDelegate(
996  std::make_unique<KeyboardKeyChannelHandler>(messenger));
997  keyboard_key_handler->InitKeyboardChannel();
998  return keyboard_key_handler;
999 }
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 1001 of file flutter_windows_engine.cc.

1002  {
1003  return std::make_unique<TextInputPlugin>(messenger, this);
1004 }

◆ CreateView()

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

Definition at line 582 of file flutter_windows_engine.cc.

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

References flutter::kImplicitViewId.

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

1046  {
1047  FlutterSendSemanticsActionInfo info{
1048  .struct_size = sizeof(FlutterSendSemanticsActionInfo),
1049  .view_id = view_id,
1050  .node_id = target,
1051  .action = action,
1052  .data = data.GetMapping(),
1053  .data_length = data.GetSize(),
1054  };
1055  return (embedder_api_.SendSemanticsAction(engine_, &info));
1056 }

References action.

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

◆ display_manager()

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

Definition at line 167 of file flutter_windows_engine.h.

167  {
168  return display_manager_;
169  }

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

◆ egl_manager()

◆ GetEngineForId()

◆ GetExecutableName()

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

Definition at line 1076 of file flutter_windows_engine.cc.

1076  {
1077  std::pair<bool, std::string> result = fml::paths::GetExecutablePath();
1078  if (result.first) {
1079  const std::string& executable_path = result.second;
1080  size_t last_separator = executable_path.find_last_of("/\\");
1081  if (last_separator == std::string::npos ||
1082  last_separator == executable_path.size() - 1) {
1083  return executable_path;
1084  }
1085  return executable_path.substr(last_separator + 1);
1086  }
1087  return "Flutter";
1088 }

◆ GetRegistrar()

FlutterDesktopPluginRegistrarRef flutter::FlutterWindowsEngine::GetRegistrar ( )

Definition at line 772 of file flutter_windows_engine.cc.

772  {
773  return plugin_registrar_.get();
774 }

Referenced by FlutterDesktopEngineGetPluginRegistrar().

◆ GetViewFromTopLevelWindow()

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

Definition at line 936 of file flutter_windows_engine.cc.

937  {
938  std::shared_lock read_lock(views_mutex_);
939  auto const iterator =
940  std::find_if(views_.begin(), views_.end(), [hwnd](auto const& pair) {
941  FlutterWindowsView* const view = pair.second;
942  return GetAncestor(view->GetWindowHandle(), GA_ROOT) == hwnd;
943  });
944  if (iterator != views_.end()) {
945  return iterator->second;
946  }
947  return nullptr;
948 }

◆ HandlePlatformMessage()

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

Definition at line 860 of file flutter_windows_engine.cc.

861  {
862  if (engine_message->struct_size != sizeof(FlutterPlatformMessage)) {
863  FML_LOG(ERROR) << "Invalid message size received. Expected: "
864  << sizeof(FlutterPlatformMessage) << " but received "
865  << engine_message->struct_size;
866  return;
867  }
868 
869  auto message = ConvertToDesktopMessage(*engine_message);
870 
871  message_dispatcher_->HandleMessage(message, [this] {}, [this] {});
872 }
Win32Message message

References message.

◆ high_contrast_enabled()

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

Definition at line 276 of file flutter_windows_engine.h.

276 { return high_contrast_enabled_; }

◆ iaccessibleex_enabled()

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

Definition at line 264 of file flutter_windows_engine.h.

264  {
265  return project_->accessibility_mode() ==
267  }

References flutter::IAccessibleEx.

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

◆ keyboard_key_handler()

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

Definition at line 204 of file flutter_windows_engine.h.

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

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

◆ lifecycle_manager()

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

Definition at line 321 of file flutter_windows_engine.h.

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

Referenced by flutter::testing::TEST_F().

◆ MarkExternalTextureFrameAvailable()

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

Definition at line 1016 of file flutter_windows_engine.cc.

1017  {
1018  return (embedder_api_.MarkExternalTextureFrameAvailable(
1019  engine_, texture_id) == kSuccess);
1020 }
uint32_t texture_id

◆ message_dispatcher()

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

Definition at line 163 of file flutter_windows_engine.h.

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

Referenced by FlutterDesktopMessengerSetCallback().

◆ messenger()

FlutterDesktopMessengerRef flutter::FlutterWindowsEngine::messenger ( )
inline

Definition at line 161 of file flutter_windows_engine.h.

161 { return messenger_->ToRef(); }

Referenced by FlutterDesktopEngineGetMessenger(), FlutterDesktopPluginRegistrarGetMessenger(), and flutter::testing::TEST_F().

◆ messenger_wrapper()

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

Definition at line 176 of file flutter_windows_engine.h.

176 { return messenger_wrapper_.get(); }

◆ OnChannelUpdate()

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

Definition at line 1164 of file flutter_windows_engine.cc.

1164  {
1165  if (name == "flutter/platform" && listening) {
1166  lifecycle_manager_->BeginProcessingExit();
1167  } else if (name == "flutter/lifecycle" && listening) {
1168  lifecycle_manager_->BeginProcessingLifecycle();
1169  }
1170 }
const char * name

References name.

◆ OnDwmCompositionChanged()

void flutter::FlutterWindowsEngine::OnDwmCompositionChanged ( )

Definition at line 1127 of file flutter_windows_engine.cc.

1127  {
1128  if (display_manager_) {
1129  display_manager_->UpdateDisplays();
1130  }
1131 
1132  std::shared_lock read_lock(views_mutex_);
1133  for (auto iterator = views_.begin(); iterator != views_.end(); iterator++) {
1134  iterator->second->OnDwmCompositionChanged();
1135  }
1136 }

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

◆ OnPreEngineRestart()

void flutter::FlutterWindowsEngine::OnPreEngineRestart ( )
protected

Definition at line 1070 of file flutter_windows_engine.cc.

1070  {
1071  // Reset the keyboard's state on hot restart.
1072  InitializeKeyboard();
1073  window_manager_->OnPreEngineRestart();
1074 }

◆ OnQuit()

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

Definition at line 1120 of file flutter_windows_engine.cc.

1123  {
1124  lifecycle_manager_->Quit(hwnd, wparam, lparam, exit_code);
1125 }

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

◆ OnViewFocusChangeRequest()

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

Definition at line 1172 of file flutter_windows_engine.cc.

1173  {
1174  std::shared_lock read_lock(views_mutex_);
1175 
1176  auto iterator = views_.find(request->view_id);
1177  if (iterator == views_.end()) {
1178  return;
1179  }
1180 
1181  FlutterWindowsView* view = iterator->second;
1182  view->Focus();
1183 }

References flutter::FlutterWindowsView::Focus().

◆ OnVsync()

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

Definition at line 732 of file flutter_windows_engine.cc.

732  {
733  std::chrono::nanoseconds current_time =
734  std::chrono::nanoseconds(embedder_api_.GetCurrentTime());
735  std::chrono::nanoseconds frame_interval = FrameInterval();
736  auto next = SnapToNextTick(current_time, start_time_, frame_interval);
737  embedder_api_.OnVsync(engine_, baton, next.count(),
738  (next + frame_interval).count());
739 }

◆ OnWindowStateEvent()

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

Definition at line 1138 of file flutter_windows_engine.cc.

1139  {
1140  lifecycle_manager_->OnWindowStateEvent(hwnd, event);
1141 }

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

◆ PostRasterThreadTask()

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

Definition at line 1022 of file flutter_windows_engine.cc.

1022  {
1023  struct Captures {
1024  fml::closure callback;
1025  };
1026  auto captures = new Captures();
1027  captures->callback = std::move(callback);
1028  if (embedder_api_.PostRenderThreadTask(
1029  engine_,
1030  [](void* opaque) {
1031  auto captures = reinterpret_cast<Captures*>(opaque);
1032  captures->callback();
1033  delete captures;
1034  },
1035  captures) == kSuccess) {
1036  return true;
1037  }
1038  delete captures;
1039  return false;
1040 }

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

1147  {
1148  if (lifecycle_manager_) {
1149  return lifecycle_manager_->ExternalWindowMessage(hwnd, message, wparam,
1150  lparam);
1151  }
1152  return std::nullopt;
1153 }

References message.

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

◆ RegisterExternalTexture()

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

Definition at line 1006 of file flutter_windows_engine.cc.

1006  {
1007  return (embedder_api_.RegisterExternalTexture(engine_, texture_id) ==
1008  kSuccess);
1009 }

◆ ReloadSystemFonts()

void flutter::FlutterWindowsEngine::ReloadSystemFonts ( )

Definition at line 874 of file flutter_windows_engine.cc.

874  {
875  embedder_api_.ReloadSystemFonts(engine_);
876 }

Referenced by FlutterDesktopEngineReloadSystemFonts().

◆ RemoveView()

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

Definition at line 663 of file flutter_windows_engine.cc.

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

References flutter::kImplicitViewId.

Referenced by flutter::testing::TEST_F().

◆ RequestApplicationQuit()

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

Definition at line 1113 of file flutter_windows_engine.cc.

1116  {
1117  platform_handler_->RequestAppExit(hwnd, wparam, lparam, exit_type, 0);
1118 }

◆ Run() [1/2]

bool flutter::FlutterWindowsEngine::Run ( )

Definition at line 284 of file flutter_windows_engine.cc.

284  {
285  return Run("");
286 }

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

◆ Run() [2/2]

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

Definition at line 288 of file flutter_windows_engine.cc.

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

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

878  {
879  embedder_api_.ScheduleFrame(engine_);
880 }

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

◆ semantics_enabled()

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

Definition at line 262 of file flutter_windows_engine.h.

262 { return semantics_enabled_; }

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

◆ SendKeyEvent()

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

Definition at line 804 of file flutter_windows_engine.cc.

806  {
807  if (engine_) {
808  embedder_api_.SendKeyEvent(engine_, &event, callback, user_data);
809  }
810 }

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

824  {
825  FlutterPlatformMessageResponseHandle* response_handle = nullptr;
826  if (reply != nullptr && user_data != nullptr) {
827  FlutterEngineResult result =
828  embedder_api_.PlatformMessageCreateResponseHandle(
829  engine_, reply, user_data, &response_handle);
830  if (result != kSuccess) {
831  FML_LOG(ERROR) << "Failed to create response handle";
832  return false;
833  }
834  }
835 
836  FlutterPlatformMessage platform_message = {
837  sizeof(FlutterPlatformMessage),
838  channel,
839  message,
840  message_size,
841  response_handle,
842  };
843 
844  FlutterEngineResult message_result =
845  embedder_api_.SendPlatformMessage(engine_, &platform_message);
846  if (response_handle != nullptr) {
847  embedder_api_.PlatformMessageReleaseResponseHandle(engine_,
848  response_handle);
849  }
850  return message_result == kSuccess;
851 }

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

856  {
857  embedder_api_.SendPlatformMessageResponse(engine_, handle, data, data_length);
858 }

Referenced by FlutterDesktopMessengerSendResponse().

◆ SendPointerEvent()

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

Definition at line 798 of file flutter_windows_engine.cc.

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

◆ SendViewFocusEvent()

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

Definition at line 812 of file flutter_windows_engine.cc.

813  {
814  if (engine_) {
815  embedder_api_.SendViewFocusEvent(engine_, &event);
816  }
817 }

◆ SendWindowMetricsEvent()

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

Definition at line 791 of file flutter_windows_engine.cc.

792  {
793  if (engine_) {
794  embedder_api_.SendWindowMetricsEvent(engine_, &event);
795  }
796 }

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

◆ SetFlutterCursor()

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

Definition at line 1160 of file flutter_windows_engine.cc.

1160  {
1161  windows_proc_table_->SetCursor(cursor);
1162 }

◆ SetNextFrameCallback()

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

Definition at line 882 of file flutter_windows_engine.cc.

882  {
883  next_frame_callback_ = std::move(callback);
884 
885  embedder_api_.SetNextFrameCallback(
886  engine_,
887  [](void* user_data) {
888  // Embedder callback runs on raster thread. Switch back to platform
889  // thread.
890  FlutterWindowsEngine* self =
891  static_cast<FlutterWindowsEngine*>(user_data);
892 
893  self->task_runner_->PostTask(std::move(self->next_frame_callback_));
894  },
895  this);
896 }

Referenced by FlutterDesktopEngineSetNextFrameCallback().

◆ SetRootIsolateCreateCallback()

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

Definition at line 287 of file flutter_windows_engine.h.

287  {
288  root_isolate_create_callback_ = callback;
289  }

References callback.

◆ SetSwitches()

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

Definition at line 279 of file flutter_windows_engine.cc.

280  {
281  project_->SetSwitches(switches);
282 }

References SetSwitches().

Referenced by SetSwitches().

◆ Stop()

bool flutter::FlutterWindowsEngine::Stop ( )
virtual

Definition at line 568 of file flutter_windows_engine.cc.

568  {
569  if (engine_) {
570  window_manager_->OnEngineShutdown();
571  for (const auto& [callback, registrar] :
572  plugin_registrar_destruction_callbacks_) {
573  callback(registrar);
574  }
575  FlutterEngineResult result = embedder_api_.Shutdown(engine_);
576  engine_ = nullptr;
577  return (result == kSuccess);
578  }
579  return false;
580 }

Referenced by FlutterDesktopEngineDestroy().

◆ task_runner()

◆ text_input_plugin()

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

Definition at line 207 of file flutter_windows_engine.h.

207 { return text_input_plugin_.get(); }

◆ texture_registrar()

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

Definition at line 178 of file flutter_windows_engine.h.

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

Referenced by FlutterDesktopRegistrarGetTextureRegistrar().

◆ UnregisterExternalTexture()

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

Definition at line 1011 of file flutter_windows_engine.cc.

1011  {
1012  return (embedder_api_.UnregisterExternalTexture(engine_, texture_id) ==
1013  kSuccess);
1014 }

◆ UpdateAccessibilityFeatures()

void flutter::FlutterWindowsEngine::UpdateAccessibilityFeatures ( )

◆ UpdateDisplay()

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

Definition at line 782 of file flutter_windows_engine.cc.

783  {
784  if (engine_) {
785  embedder_api_.NotifyDisplayUpdate(engine_,
786  kFlutterEngineDisplaysUpdateTypeStartup,
787  displays.data(), displays.size());
788  }
789 }
std::vector< FlutterEngineDisplay > * displays

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

◆ UpdateFlutterCursor()

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

Definition at line 1155 of file flutter_windows_engine.cc.

1156  {
1157  SetFlutterCursor(GetCursorByName(cursor_name));
1158 }
void SetFlutterCursor(HCURSOR cursor) const

◆ UpdateHighContrastMode()

void flutter::FlutterWindowsEngine::UpdateHighContrastMode ( )

Definition at line 1094 of file flutter_windows_engine.cc.

1094  {
1095  high_contrast_enabled_ = windows_proc_table_->GetHighContrastEnabled();
1096 
1097  SendAccessibilityFeatures();
1098  settings_plugin_->UpdateHighContrastMode(high_contrast_enabled_);
1099 }

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

◆ UpdateSemanticsEnabled()

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

Definition at line 1058 of file flutter_windows_engine.cc.

1058  {
1059  if (engine_ && semantics_enabled_ != enabled) {
1060  std::shared_lock read_lock(views_mutex_);
1061 
1062  semantics_enabled_ = enabled;
1063  embedder_api_.UpdateSemanticsEnabled(engine_, enabled);
1064  for (auto iterator = views_.begin(); iterator != views_.end(); iterator++) {
1065  iterator->second->UpdateSemanticsEnabled(enabled);
1066  }
1067  }
1068 }

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

◆ view()

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

Definition at line 760 of file flutter_windows_engine.cc.

760  {
761  std::shared_lock read_lock(views_mutex_);
762 
763  auto iterator = views_.find(view_id);
764  if (iterator == views_.end()) {
765  return nullptr;
766  }
767 
768  return iterator->second;
769 }

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

◆ 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

Friends And Related Function Documentation

◆ EngineModifier

friend class EngineModifier
friend

Definition at line 374 of file flutter_windows_engine.h.


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