| Flutter Windows Embedder |

Functions
flutter_windows.cc File Reference
`#include "flutter/shell/platform/windows/public/flutter_windows.h"`
`#include <io.h>`
`#include <algorithm>`
`#include <chrono>`
`#include <cstdlib>`
`#include <filesystem>`
`#include <memory>`
`#include <vector>`
`#include "flutter/shell/platform/common/client_wrapper/include/flutter/plugin_registrar.h"`
`#include "flutter/shell/platform/common/incoming_message_dispatcher.h"`
`#include "flutter/shell/platform/common/path_utils.h"`
`#include "flutter/shell/platform/embedder/embedder.h"`
`#include "flutter/shell/platform/windows/dpi_utils.h"`
`#include "flutter/shell/platform/windows/flutter_project_bundle.h"`
`#include "flutter/shell/platform/windows/flutter_window.h"`
`#include "flutter/shell/platform/windows/flutter_windows_engine.h"`
`#include "flutter/shell/platform/windows/flutter_windows_view.h"`
`#include "flutter/shell/platform/windows/flutter_windows_view_controller.h"`
`#include "flutter/shell/platform/windows/window_binding_handler.h"`
`#include "flutter/shell/platform/windows/window_state.h"`

Go to the source code of this file.

## Functions
static flutter::FlutterWindowsEngine * | EngineFromHandle (FlutterDesktopEngineRef ref)
static FlutterDesktopEngineRef | HandleForEngine (flutter::FlutterWindowsEngine *engine)
static flutter::FlutterWindowsViewController * | ViewControllerFromHandle (FlutterDesktopViewControllerRef ref)
static FlutterDesktopViewControllerRef | HandleForViewController (flutter::FlutterWindowsViewController *view_controller)
static flutter::FlutterWindowsView * | ViewFromHandle (FlutterDesktopViewRef ref)
static FlutterDesktopViewRef | HandleForView (flutter::FlutterWindowsView *view)
static flutter::FlutterWindowsTextureRegistrar * | TextureRegistrarFromHandle (FlutterDesktopTextureRegistrarRef ref)
static FlutterDesktopTextureRegistrarRef | HandleForTextureRegistrar (flutter::FlutterWindowsTextureRegistrar *registrar)
FlutterDesktopViewControllerRef | FlutterDesktopViewControllerCreate (int width, int height, FlutterDesktopEngineRef engine_ref)
void | FlutterDesktopViewControllerDestroy (FlutterDesktopViewControllerRef ref)
FlutterDesktopEngineRef | FlutterDesktopViewControllerGetEngine (FlutterDesktopViewControllerRef ref)
FlutterDesktopViewRef | FlutterDesktopViewControllerGetView (FlutterDesktopViewControllerRef ref)
void | FlutterDesktopViewControllerForceRedraw (FlutterDesktopViewControllerRef ref)
bool | FlutterDesktopViewControllerHandleTopLevelWindowProc (FlutterDesktopViewControllerRef ref, HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam, LRESULT *result)
FlutterDesktopEngineRef | FlutterDesktopEngineCreate (const FlutterDesktopEngineProperties *engine_properties)
bool | FlutterDesktopEngineDestroy (FlutterDesktopEngineRef engine_ref)
bool | FlutterDesktopEngineRun (FlutterDesktopEngineRef engine, const char *entry_point)
uint64_t | FlutterDesktopEngineProcessMessages (FlutterDesktopEngineRef engine)
void | FlutterDesktopEngineReloadSystemFonts (FlutterDesktopEngineRef engine)
FlutterDesktopPluginRegistrarRef | FlutterDesktopEngineGetPluginRegistrar (FlutterDesktopEngineRef engine, const char *plugin_name)
FlutterDesktopMessengerRef | FlutterDesktopEngineGetMessenger (FlutterDesktopEngineRef engine)
FlutterDesktopTextureRegistrarRef | FlutterDesktopEngineGetTextureRegistrar (FlutterDesktopEngineRef engine)
void | FlutterDesktopEngineSetNextFrameCallback (FlutterDesktopEngineRef engine, VoidCallback callback, void *user_data)
HWND | FlutterDesktopViewGetHWND (FlutterDesktopViewRef view)
IDXGIAdapter * | FlutterDesktopViewGetGraphicsAdapter (FlutterDesktopViewRef view)
bool | FlutterDesktopEngineProcessExternalWindowMessage (FlutterDesktopEngineRef engine, HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam, LRESULT *result)
FlutterDesktopViewRef | FlutterDesktopPluginRegistrarGetView (FlutterDesktopPluginRegistrarRef registrar)
void | FlutterDesktopPluginRegistrarRegisterTopLevelWindowProcDelegate (FlutterDesktopPluginRegistrarRef registrar, FlutterDesktopWindowProcCallback delegate, void *user_data)
void | FlutterDesktopPluginRegistrarUnregisterTopLevelWindowProcDelegate (FlutterDesktopPluginRegistrarRef registrar, FlutterDesktopWindowProcCallback delegate)
UINT | FlutterDesktopGetDpiForHWND (HWND hwnd)
UINT | FlutterDesktopGetDpiForMonitor (HMONITOR monitor)
void | FlutterDesktopResyncOutputStreams ()
FlutterDesktopMessengerRef | FlutterDesktopPluginRegistrarGetMessenger (FlutterDesktopPluginRegistrarRef registrar)
void | FlutterDesktopPluginRegistrarSetDestructionHandler (FlutterDesktopPluginRegistrarRef registrar, FlutterDesktopOnPluginRegistrarDestroyed callback)
bool | FlutterDesktopMessengerSendWithReply (FlutterDesktopMessengerRef messenger, const char *channel, const uint8_t *message, const size_t message_size, const FlutterDesktopBinaryReply reply, void *user_data)
bool | FlutterDesktopMessengerSend (FlutterDesktopMessengerRef messenger, const char *channel, const uint8_t *message, const size_t message_size)
void | FlutterDesktopMessengerSendResponse (FlutterDesktopMessengerRef messenger, const FlutterDesktopMessageResponseHandle *handle, const uint8_t *data, size_t data_length)
void | FlutterDesktopMessengerSetCallback (FlutterDesktopMessengerRef messenger, const char *channel, FlutterDesktopMessageCallback callback, void *user_data)
FlutterDesktopMessengerRef | FlutterDesktopMessengerAddRef (FlutterDesktopMessengerRef messenger)
void | FlutterDesktopMessengerRelease (FlutterDesktopMessengerRef messenger)
bool | FlutterDesktopMessengerIsAvailable (FlutterDesktopMessengerRef messenger)
FlutterDesktopMessengerRef | FlutterDesktopMessengerLock (FlutterDesktopMessengerRef messenger)
void | FlutterDesktopMessengerUnlock (FlutterDesktopMessengerRef messenger)
FlutterDesktopTextureRegistrarRef | FlutterDesktopRegistrarGetTextureRegistrar (FlutterDesktopPluginRegistrarRef registrar)
int64_t | FlutterDesktopTextureRegistrarRegisterExternalTexture (FlutterDesktopTextureRegistrarRef texture_registrar, const FlutterDesktopTextureInfo *texture_info)
void | FlutterDesktopTextureRegistrarUnregisterExternalTexture (FlutterDesktopTextureRegistrarRef texture_registrar, int64_t texture_id, void(*callback)(void *user_data), void *user_data)
bool | FlutterDesktopTextureRegistrarMarkExternalTextureFrameAvailable (FlutterDesktopTextureRegistrarRef texture_registrar, int64_t texture_id)

## Function Documentation

## ◆ EngineFromHandle()

static flutter::FlutterWindowsEngine* EngineFromHandle | ( | FlutterDesktopEngineRef | ref | ) |
| static

Definition at line 32 of file flutter_windows.cc.

33 {
34 return reinterpret_cast<flutter::FlutterWindowsEngine*>(ref);
35 }

Referenced by FlutterDesktopEngineDestroy(), FlutterDesktopEngineGetMessenger(), FlutterDesktopEngineGetPluginRegistrar(), FlutterDesktopEngineGetTextureRegistrar(), FlutterDesktopEngineProcessExternalWindowMessage(), FlutterDesktopEngineReloadSystemFonts(), FlutterDesktopEngineRun(), FlutterDesktopEngineSetNextFrameCallback(), and FlutterDesktopViewControllerCreate().

## ◆ FlutterDesktopEngineCreate()

FlutterDesktopEngineRef FlutterDesktopEngineCreate | ( | const FlutterDesktopEngineProperties * | engine_properties | ) |

Definition at line 150 of file flutter_windows.cc.

151 {
152 flutter::FlutterProjectBundle project(*engine_properties);
153 auto engine = std::make_unique<flutter::FlutterWindowsEngine>(project);
154 return HandleForEngine(engine.release());
155 }

References HandleForEngine().

Referenced by flutter::FlutterEngine::FlutterEngine(), and flutter::testing::TEST().

## ◆ FlutterDesktopEngineDestroy()

bool FlutterDesktopEngineDestroy | ( | FlutterDesktopEngineRef | engine_ref | ) |

Definition at line 157 of file flutter_windows.cc.

157 {
158 flutter::FlutterWindowsEngine* engine = EngineFromHandle(engine_ref);
159 bool result = true;
160 if (engine->running()) {
161 result = engine->Stop();
162 }
163 delete engine;
164 return result;
165 }

References EngineFromHandle(), flutter::FlutterWindowsEngine::running(), and flutter::FlutterWindowsEngine::Stop().

Referenced by flutter::FlutterEngine::ShutDown(), and flutter::testing::TEST().

## ◆ FlutterDesktopEngineGetMessenger()

FlutterDesktopMessengerRef FlutterDesktopEngineGetMessenger | ( | FlutterDesktopEngineRef | engine | ) |

Definition at line 195 of file flutter_windows.cc.

196 {
197 return EngineFromHandle(engine)->messenger();
198 }

References EngineFromHandle(), and flutter::FlutterWindowsEngine::messenger().

Referenced by flutter::FlutterEngine::FlutterEngine().

## ◆ FlutterDesktopEngineGetPluginRegistrar()

FlutterDesktopPluginRegistrarRef FlutterDesktopEngineGetPluginRegistrar | ( | FlutterDesktopEngineRef | engine,
|  | const char * | plugin_name
| ) |  |

Definition at line 185 of file flutter_windows.cc.

187 {
188 // Currently, one registrar acts as the registrar for all plugins, so the
189 // name is ignored. It is part of the API to reduce churn in the future when
190 // aligning more closely with the Flutter registrar system.
191
192 return EngineFromHandle(engine)->GetRegistrar();
193 }

References EngineFromHandle(), and flutter::FlutterWindowsEngine::GetRegistrar().

Referenced by flutter::FlutterEngine::GetRegistrarForPlugin().

## ◆ FlutterDesktopEngineGetTextureRegistrar()

FlutterDesktopTextureRegistrarRef FlutterDesktopEngineGetTextureRegistrar | ( | FlutterDesktopEngineRef | engine | ) |

Definition at line 200 of file flutter_windows.cc.

201 {
202 return HandleForTextureRegistrar(
203 EngineFromHandle(engine)->texture_registrar());
204 }

References EngineFromHandle(), and HandleForTextureRegistrar().

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

## ◆ FlutterDesktopEngineProcessExternalWindowMessage()

bool FlutterDesktopEngineProcessExternalWindowMessage | ( | FlutterDesktopEngineRef | engine,
|  | HWND | hwnd,
|  | UINT | message,
|  | WPARAM | wparam,
|  | LPARAM | lparam,
|  | LRESULT * | result
| ) |  |

Definition at line 233 of file flutter_windows.cc.

239 {
240 std::optional<LRESULT> lresult =
241 EngineFromHandle(engine)->ProcessExternalWindowMessage(hwnd, message,
242 wparam, lparam);
243 if (result && lresult.has_value()) {
244 *result = lresult.value();
245 }
246 return lresult.has_value();
247 }

References EngineFromHandle(), message, and flutter::FlutterWindowsEngine::ProcessExternalWindowMessage().

Referenced by flutter::FlutterEngine::ProcessExternalWindowMessage().

## ◆ FlutterDesktopEngineProcessMessages()

uint64_t FlutterDesktopEngineProcessMessages | ( | FlutterDesktopEngineRef | engine | ) |

Definition at line 177 of file flutter_windows.cc.

177 {
178 return std::chrono::nanoseconds::max().count();
179 }

Referenced by flutter::FlutterEngine::ProcessMessages().

## ◆ FlutterDesktopEngineReloadSystemFonts()

void FlutterDesktopEngineReloadSystemFonts | ( | FlutterDesktopEngineRef | engine | ) |

Definition at line 181 of file flutter_windows.cc.

181 {
182 EngineFromHandle(engine)->ReloadSystemFonts();
183 }

References EngineFromHandle(), and flutter::FlutterWindowsEngine::ReloadSystemFonts().

Referenced by flutter::FlutterEngine::ReloadSystemFonts().

## ◆ FlutterDesktopEngineRun()

bool FlutterDesktopEngineRun | ( | FlutterDesktopEngineRef | engine,
|  | const char * | entry_point
| ) |  |

Definition at line 167 of file flutter_windows.cc.

168 {
169 std::string_view entry_point_view{""};
170 if (entry_point != nullptr) {
171 entry_point_view = entry_point;
172 }
173
174 return EngineFromHandle(engine)->Run(entry_point_view);
175 }

References EngineFromHandle(), and flutter::FlutterWindowsEngine::Run().

Referenced by flutter::FlutterEngine::Run(), and flutter::testing::TEST_F().

## ◆ FlutterDesktopEngineSetNextFrameCallback()

void FlutterDesktopEngineSetNextFrameCallback | ( | FlutterDesktopEngineRef | engine,
|  | VoidCallback | callback,
|  | void * | user_data
| ) |  |

Definition at line 206 of file flutter_windows.cc.

208 {
209 EngineFromHandle(engine)->SetNextFrameCallback(
210 [callback, user_data]() { callback(user_data); });
211 }

References callback, EngineFromHandle(), flutter::FlutterWindowsEngine::SetNextFrameCallback(), and user_data.

Referenced by flutter::FlutterEngine::SetNextFrameCallback(), and flutter::testing::TEST_F().

## ◆ FlutterDesktopGetDpiForHWND()

UINT FlutterDesktopGetDpiForHWND | ( | HWND | hwnd | ) |

Definition at line 269 of file flutter_windows.cc.

269 {
270 return flutter::GetDpiForHWND(hwnd);
271 }

References flutter::GetDpiForHWND().

## ◆ FlutterDesktopGetDpiForMonitor()

UINT FlutterDesktopGetDpiForMonitor | ( | HMONITOR | monitor | ) |

Definition at line 273 of file flutter_windows.cc.

273 {
274 return flutter::GetDpiForMonitor(monitor);
275 }

References flutter::GetDpiForMonitor().

## ◆ FlutterDesktopMessengerAddRef()

FlutterDesktopMessengerRef FlutterDesktopMessengerAddRef | ( | FlutterDesktopMessengerRef | messenger | ) |

Definition at line 349 of file flutter_windows.cc.

350 {
351 return flutter::FlutterDesktopMessenger::FromRef(messenger)
352 ->AddRef()
353 ->ToRef();
354 }

References flutter::FlutterDesktopMessenger::AddRef(), flutter::FlutterDesktopMessenger::FromRef(), and flutter::FlutterDesktopMessenger::ToRef().

## ◆ FlutterDesktopMessengerIsAvailable()

bool FlutterDesktopMessengerIsAvailable | ( | FlutterDesktopMessengerRef | messenger | ) |

Definition at line 360 of file flutter_windows.cc.

360 {
361 return flutter::FlutterDesktopMessenger::FromRef(messenger)->GetEngine() !=
362 nullptr;
363 }

References flutter::FlutterDesktopMessenger::FromRef(), and flutter::FlutterDesktopMessenger::GetEngine().

Referenced by FlutterDesktopMessengerSendResponse(), FlutterDesktopMessengerSendWithReply(), and FlutterDesktopMessengerSetCallback().

## ◆ FlutterDesktopMessengerLock()

FlutterDesktopMessengerRef FlutterDesktopMessengerLock | ( | FlutterDesktopMessengerRef | messenger | ) |

Definition at line 365 of file flutter_windows.cc.

366 {
367 flutter::FlutterDesktopMessenger::FromRef(messenger)->GetMutex().lock();
368 return messenger;
369 }

References flutter::FlutterDesktopMessenger::FromRef(), and flutter::FlutterDesktopMessenger::GetMutex().

## ◆ FlutterDesktopMessengerRelease()

void FlutterDesktopMessengerRelease | ( | FlutterDesktopMessengerRef | messenger | ) |

Definition at line 356 of file flutter_windows.cc.

356 {
357 flutter::FlutterDesktopMessenger::FromRef(messenger)->Release();
358 }

References flutter::FlutterDesktopMessenger::FromRef(), and flutter::FlutterDesktopMessenger::Release().

## ◆ FlutterDesktopMessengerSend()

bool FlutterDesktopMessengerSend | ( | FlutterDesktopMessengerRef | messenger,
|  | const char * | channel,
|  | const uint8_t * | message,
|  | const size_t | message_size
| ) |  |

Definition at line 315 of file flutter_windows.cc.

318 {
319 return FlutterDesktopMessengerSendWithReply(messenger, channel, message,
320 message_size, nullptr, nullptr);
321 }

References FlutterDesktopMessengerSendWithReply(), and message.

Referenced by flutter::BinaryMessengerImpl::Send().

## ◆ FlutterDesktopMessengerSendResponse()

void FlutterDesktopMessengerSendResponse | ( | FlutterDesktopMessengerRef | messenger,
|  | const FlutterDesktopMessageResponseHandle * | handle,
|  | const uint8_t * | data,
|  | size_t | data_length
| ) |  |

Definition at line 323 of file flutter_windows.cc.

327 {
328 FML_DCHECK(FlutterDesktopMessengerIsAvailable(messenger))
329 << "Messenger must reference a running engine to send a response";
330
331 flutter::FlutterDesktopMessenger::FromRef(messenger)
332 ->GetEngine()
333 ->SendPlatformMessageResponse(handle, data, data_length);
334 }

References FlutterDesktopMessengerIsAvailable(), flutter::FlutterDesktopMessenger::FromRef(), flutter::FlutterDesktopMessenger::GetEngine(), and flutter::FlutterWindowsEngine::SendPlatformMessageResponse().

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

## ◆ FlutterDesktopMessengerSendWithReply()

bool FlutterDesktopMessengerSendWithReply | ( | FlutterDesktopMessengerRef | messenger,
|  | const char * | channel,
|  | const uint8_t * | message,
|  | const size_t | message_size,
|  | const FlutterDesktopBinaryReply | reply,
|  | void * | user_data
| ) |  |

Definition at line 301 of file flutter_windows.cc.

306 {
307 FML_DCHECK(FlutterDesktopMessengerIsAvailable(messenger))
308 << "Messenger must reference a running engine to send a message";
309
310 return flutter::FlutterDesktopMessenger::FromRef(messenger)
311 ->GetEngine()
312 ->SendPlatformMessage(channel, message, message_size, reply, user_data);
313 }

References FlutterDesktopMessengerIsAvailable(), flutter::FlutterDesktopMessenger::FromRef(), flutter::FlutterDesktopMessenger::GetEngine(), message, flutter::FlutterWindowsEngine::SendPlatformMessage(), and user_data.

Referenced by FlutterDesktopMessengerSend(), and flutter::BinaryMessengerImpl::Send().

## ◆ FlutterDesktopMessengerSetCallback()

void FlutterDesktopMessengerSetCallback | ( | FlutterDesktopMessengerRef | messenger,
|  | const char * | channel,
|  | FlutterDesktopMessageCallback | callback,
|  | void * | user_data
| ) |  |

Definition at line 336 of file flutter_windows.cc.

339 {
340 FML_DCHECK(FlutterDesktopMessengerIsAvailable(messenger))
341 << "Messenger must reference a running engine to set a callback";
342
343 flutter::FlutterDesktopMessenger::FromRef(messenger)
344 ->GetEngine()
345 ->message_dispatcher()
346 ->SetMessageCallback(channel, callback, user_data);
347 }

References callback, FlutterDesktopMessengerIsAvailable(), flutter::FlutterDesktopMessenger::FromRef(), flutter::FlutterDesktopMessenger::GetEngine(), flutter::FlutterWindowsEngine::message_dispatcher(), flutter::IncomingMessageDispatcher::SetMessageCallback(), and user_data.

Referenced by flutter::BinaryMessengerImpl::SetMessageHandler().

## ◆ FlutterDesktopMessengerUnlock()

void FlutterDesktopMessengerUnlock | ( | FlutterDesktopMessengerRef | messenger | ) |

Definition at line 371 of file flutter_windows.cc.

371 {
372 flutter::FlutterDesktopMessenger::FromRef(messenger)->GetMutex().unlock();
373 }

References flutter::FlutterDesktopMessenger::FromRef(), and flutter::FlutterDesktopMessenger::GetMutex().

## ◆ FlutterDesktopPluginRegistrarGetMessenger()

FlutterDesktopMessengerRef FlutterDesktopPluginRegistrarGetMessenger | ( | FlutterDesktopPluginRegistrarRef | registrar | ) |

Definition at line 290 of file flutter_windows.cc.

291 {
292 return registrar->engine->messenger();
293 }

References FlutterDesktopPluginRegistrar::engine, and flutter::FlutterWindowsEngine::messenger().

## ◆ FlutterDesktopPluginRegistrarGetView()

FlutterDesktopViewRef FlutterDesktopPluginRegistrarGetView | ( | FlutterDesktopPluginRegistrarRef | registrar | ) |

Definition at line 249 of file flutter_windows.cc.

250 {
251 return HandleForView(registrar->engine->view());
252 }

References FlutterDesktopPluginRegistrar::engine, HandleForView(), and flutter::FlutterWindowsEngine::view().

Referenced by flutter::PluginRegistrarWindows::PluginRegistrarWindows().

## ◆ FlutterDesktopPluginRegistrarRegisterTopLevelWindowProcDelegate()

void FlutterDesktopPluginRegistrarRegisterTopLevelWindowProcDelegate | ( | FlutterDesktopPluginRegistrarRef | registrar,
|  | FlutterDesktopWindowProcCallback | delegate,
|  | void * | user_data
| ) |  |

Definition at line 254 of file flutter_windows.cc.

257 {
258 registrar->engine->window_proc_delegate_manager()
259 ->RegisterTopLevelWindowProcDelegate(delegate, user_data);
260 }

References FlutterDesktopPluginRegistrar::engine, flutter::WindowProcDelegateManager::RegisterTopLevelWindowProcDelegate(), user_data, and flutter::FlutterWindowsEngine::window_proc_delegate_manager().

Referenced by flutter::PluginRegistrarWindows::RegisterTopLevelWindowProcDelegate().

## ◆ FlutterDesktopPluginRegistrarSetDestructionHandler()

void FlutterDesktopPluginRegistrarSetDestructionHandler | ( | FlutterDesktopPluginRegistrarRef | registrar,
|  | FlutterDesktopOnPluginRegistrarDestroyed | callback
| ) |  |

Definition at line 295 of file flutter_windows.cc.

297 {
298 registrar->engine->AddPluginRegistrarDestructionCallback(callback, registrar);
299 }

References flutter::FlutterWindowsEngine::AddPluginRegistrarDestructionCallback(), callback, and FlutterDesktopPluginRegistrar::engine.

Referenced by flutter::PluginRegistrarManager::GetRegistrar().

## ◆ FlutterDesktopPluginRegistrarUnregisterTopLevelWindowProcDelegate()

void FlutterDesktopPluginRegistrarUnregisterTopLevelWindowProcDelegate | ( | FlutterDesktopPluginRegistrarRef | registrar,
|  | FlutterDesktopWindowProcCallback | delegate
| ) |  |

Definition at line 262 of file flutter_windows.cc.

264 {
265 registrar->engine->window_proc_delegate_manager()
266 ->UnregisterTopLevelWindowProcDelegate(delegate);
267 }

References FlutterDesktopPluginRegistrar::engine, flutter::WindowProcDelegateManager::UnregisterTopLevelWindowProcDelegate(), and flutter::FlutterWindowsEngine::window_proc_delegate_manager().

Referenced by flutter::PluginRegistrarWindows::UnregisterTopLevelWindowProcDelegate().

## ◆ FlutterDesktopRegistrarGetTextureRegistrar()

FlutterDesktopTextureRegistrarRef FlutterDesktopRegistrarGetTextureRegistrar | ( | FlutterDesktopPluginRegistrarRef | registrar | ) |

Definition at line 375 of file flutter_windows.cc.

376 {
377 return HandleForTextureRegistrar(registrar->engine->texture_registrar());
378 }

References FlutterDesktopPluginRegistrar::engine, HandleForTextureRegistrar(), and flutter::FlutterWindowsEngine::texture_registrar().

## ◆ FlutterDesktopResyncOutputStreams()

void FlutterDesktopResyncOutputStreams | ( |  | ) |

Definition at line 277 of file flutter_windows.cc.

277 {
278 FILE* unused;
279 if (freopen_s(&unused, "CONOUT$", "w", stdout)) {
280 _dup2(_fileno(stdout), 1);
281 }
282 if (freopen_s(&unused, "CONOUT$", "w", stderr)) {
283 _dup2(_fileno(stdout), 2);
284 }
285 std::ios::sync_with_stdio();
286 }

## ◆ FlutterDesktopTextureRegistrarMarkExternalTextureFrameAvailable()

bool FlutterDesktopTextureRegistrarMarkExternalTextureFrameAvailable | ( | FlutterDesktopTextureRegistrarRef | texture_registrar,
|  | int64_t | texture_id
| ) |  |

Definition at line 401 of file flutter_windows.cc.

403 {
404 return TextureRegistrarFromHandle(texture_registrar)
405 ->MarkTextureFrameAvailable(texture_id);
406 }

References flutter::FlutterWindowsTextureRegistrar::MarkTextureFrameAvailable(), texture_id, and TextureRegistrarFromHandle().

Referenced by flutter::TextureRegistrarImpl::MarkTextureFrameAvailable().

## ◆ FlutterDesktopTextureRegistrarRegisterExternalTexture()

int64_t FlutterDesktopTextureRegistrarRegisterExternalTexture | ( | FlutterDesktopTextureRegistrarRef | texture_registrar,
|  | const FlutterDesktopTextureInfo * | texture_info
| ) |  |

Definition at line 380 of file flutter_windows.cc.

382 {
383 return TextureRegistrarFromHandle(texture_registrar)
384 ->RegisterTexture(texture_info);
385 }

References flutter::FlutterWindowsTextureRegistrar::RegisterTexture(), and TextureRegistrarFromHandle().

Referenced by flutter::TextureRegistrarImpl::RegisterTexture().

## ◆ FlutterDesktopTextureRegistrarUnregisterExternalTexture()

void FlutterDesktopTextureRegistrarUnregisterExternalTexture | ( | FlutterDesktopTextureRegistrarRef | texture_registrar,
|  | int64_t | texture_id,
|  | void(*)(void *user_data) | callback,
|  | void * | user_data
| ) |  |

Definition at line 387 of file flutter_windows.cc.

391 {
392 auto registrar = TextureRegistrarFromHandle(texture_registrar);
393 if (callback) {
394 registrar->UnregisterTexture(
395 texture_id, [callback, user_data]() { callback(user_data); });
396 return;
397 }
398 registrar->UnregisterTexture(texture_id);
399 }

References callback, texture_id, TextureRegistrarFromHandle(), and user_data.

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

## ◆ FlutterDesktopViewControllerCreate()

FlutterDesktopViewControllerRef FlutterDesktopViewControllerCreate | ( | int | width,
|  | int | height,
|  | FlutterDesktopEngineRef | engine_ref
| ) |  |

Definition at line 75 of file flutter_windows.cc.

78 {
79 flutter::FlutterWindowsEngine* engine_ptr = EngineFromHandle(engine_ref);
80 std::unique_ptr<flutter::WindowBindingHandler> window_wrapper =
81 std::make_unique<flutter::FlutterWindow>(
82 width, height, engine_ptr->windows_proc_table());
83
84 auto engine = std::unique_ptr<flutter::FlutterWindowsEngine>(engine_ptr);
85 auto view = std::make_unique<flutter::FlutterWindowsView>(
86 std::move(window_wrapper), engine_ptr->windows_proc_table());
87 auto controller = std::make_unique<flutter::FlutterWindowsViewController>(
88 std::move(engine), std::move(view));
89
90 controller->view()->SetEngine(controller->engine());
91 controller->view()->CreateRenderSurface();
92 if (!controller->engine()->running()) {
93 if (!controller->engine()->Run()) {
94 return nullptr;
95 }
96 }
97
98 // Must happen after engine is running.
99 controller->view()->SendInitialBounds();
100
101 // The Windows embedder listens to accessibility updates using the
102 // view's HWND. The embedder's accessibility features may be stale if
103 // the app was in headless mode.
104 controller->engine()->UpdateAccessibilityFeatures();
105
106 return HandleForViewController(controller.release());
107 }

References EngineFromHandle(), HandleForViewController(), and flutter::FlutterWindowsEngine::windows_proc_table().

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

## ◆ FlutterDesktopViewControllerDestroy()

void FlutterDesktopViewControllerDestroy | ( | FlutterDesktopViewControllerRef | ref | ) |

Definition at line 109 of file flutter_windows.cc.

109 {
110 auto controller = ViewControllerFromHandle(ref);
111 delete controller;
112 }

References ViewControllerFromHandle().

Referenced by flutter::FlutterViewController::~FlutterViewController().

## ◆ FlutterDesktopViewControllerForceRedraw()

void FlutterDesktopViewControllerForceRedraw | ( | FlutterDesktopViewControllerRef | ref | ) |

Definition at line 126 of file flutter_windows.cc.

127 {
128 auto controller = ViewControllerFromHandle(ref);
129 controller->view()->ForceRedraw();
130 }

References ViewControllerFromHandle().

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

## ◆ FlutterDesktopViewControllerGetEngine()

FlutterDesktopEngineRef FlutterDesktopViewControllerGetEngine | ( | FlutterDesktopViewControllerRef | ref | ) |

Definition at line 114 of file flutter_windows.cc.

115 {
116 auto controller = ViewControllerFromHandle(ref);
117 return HandleForEngine(controller->engine());
118 }

References HandleForEngine(), and ViewControllerFromHandle().

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

## ◆ FlutterDesktopViewControllerGetView()

FlutterDesktopViewRef FlutterDesktopViewControllerGetView | ( | FlutterDesktopViewControllerRef | ref | ) |

Definition at line 120 of file flutter_windows.cc.

121 {
122 auto controller = ViewControllerFromHandle(ref);
123 return HandleForView(controller->view());
124 }

References HandleForView(), and ViewControllerFromHandle().

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

## ◆ FlutterDesktopViewControllerHandleTopLevelWindowProc()

bool FlutterDesktopViewControllerHandleTopLevelWindowProc | ( | FlutterDesktopViewControllerRef | ref,
|  | HWND | hwnd,
|  | UINT | message,
|  | WPARAM | wparam,
|  | LPARAM | lparam,
|  | LRESULT * | result
| ) |  |

Definition at line 132 of file flutter_windows.cc.

138 {
139 auto controller = ViewControllerFromHandle(ref);
140 std::optional<LRESULT> delegate_result =
141 controller->engine()
142 ->window_proc_delegate_manager()
143 ->OnTopLevelWindowProc(hwnd, message, wparam, lparam);
144 if (delegate_result) {
145 *result = *delegate_result;
146 }
147 return delegate_result.has_value();
148 }

References message, and ViewControllerFromHandle().

Referenced by flutter::FlutterViewController::HandleTopLevelWindowProc().

## ◆ FlutterDesktopViewGetGraphicsAdapter()

IDXGIAdapter* FlutterDesktopViewGetGraphicsAdapter | ( | FlutterDesktopViewRef | view | ) |

Definition at line 217 of file flutter_windows.cc.

217 {
218 auto surface_manager = ViewFromHandle(view)->GetEngine()->surface_manager();
219 if (surface_manager) {
220 Microsoft::WRL::ComPtr<ID3D11Device> d3d_device;
221 Microsoft::WRL::ComPtr<IDXGIDevice> dxgi_device;
222 if (surface_manager->GetDevice(d3d_device.GetAddressOf()) &&
223 SUCCEEDED(d3d_device.As(&dxgi_device))) {
224 IDXGIAdapter* adapter;
225 if (SUCCEEDED(dxgi_device->GetAdapter(&adapter))) {
226 return adapter;
227 }
228 }
229 }
230 return nullptr;
231 }

References flutter::FlutterWindowsView::GetEngine(), flutter::FlutterWindowsEngine::surface_manager(), and ViewFromHandle().

Referenced by flutter::FlutterView::GetGraphicsAdapter(), and flutter::testing::TEST_F().

## ◆ FlutterDesktopViewGetHWND()

HWND FlutterDesktopViewGetHWND | ( | FlutterDesktopViewRef | view | ) |

Definition at line 213 of file flutter_windows.cc.

213 {
214 return ViewFromHandle(view)->GetWindowHandle();
215 }

References flutter::FlutterWindowsView::GetWindowHandle(), and ViewFromHandle().

Referenced by flutter::FlutterView::GetNativeWindow().

## ◆ HandleForEngine()

static FlutterDesktopEngineRef HandleForEngine | ( | flutter::FlutterWindowsEngine * | engine | ) |
| static

Definition at line 38 of file flutter_windows.cc.

39 {
40 return reinterpret_cast<FlutterDesktopEngineRef>(engine);
41 }

Referenced by FlutterDesktopEngineCreate(), and FlutterDesktopViewControllerGetEngine().

## ◆ HandleForTextureRegistrar()

static FlutterDesktopTextureRegistrarRef HandleForTextureRegistrar | ( | flutter::FlutterWindowsTextureRegistrar * | registrar | ) |
| static

Definition at line 70 of file flutter_windows.cc.

71 {
72 return reinterpret_cast<FlutterDesktopTextureRegistrarRef>(registrar);
73 }

Referenced by FlutterDesktopEngineGetTextureRegistrar(), and FlutterDesktopRegistrarGetTextureRegistrar().

## ◆ HandleForView()

static FlutterDesktopViewRef HandleForView | ( | flutter::FlutterWindowsView * | view | ) |
| static

Definition at line 59 of file flutter_windows.cc.

59 {
60 return reinterpret_cast<FlutterDesktopViewRef>(view);
61 }

Referenced by FlutterDesktopPluginRegistrarGetView(), and FlutterDesktopViewControllerGetView().

## ◆ HandleForViewController()

static FlutterDesktopViewControllerRef HandleForViewController | ( | flutter::FlutterWindowsViewController * | view_controller | ) |
| static

Definition at line 48 of file flutter_windows.cc.

49 {
50 return reinterpret_cast<FlutterDesktopViewControllerRef>(view_controller);
51 }

Referenced by FlutterDesktopViewControllerCreate().

## ◆ TextureRegistrarFromHandle()

static flutter::FlutterWindowsTextureRegistrar* TextureRegistrarFromHandle | ( | FlutterDesktopTextureRegistrarRef | ref | ) |
| static

Definition at line 64 of file flutter_windows.cc.

65 {
66 return reinterpret_cast<flutter::FlutterWindowsTextureRegistrar*>(ref);
67 }

Referenced by FlutterDesktopTextureRegistrarMarkExternalTextureFrameAvailable(), FlutterDesktopTextureRegistrarRegisterExternalTexture(), and FlutterDesktopTextureRegistrarUnregisterExternalTexture().

## ◆ ViewControllerFromHandle()

static flutter::FlutterWindowsViewController* ViewControllerFromHandle | ( | FlutterDesktopViewControllerRef | ref | ) |
| static

Definition at line 43 of file flutter_windows.cc.

44 {
45 return reinterpret_cast<flutter::FlutterWindowsViewController*>(ref);
46 }

Referenced by FlutterDesktopViewControllerDestroy(), FlutterDesktopViewControllerForceRedraw(), FlutterDesktopViewControllerGetEngine(), FlutterDesktopViewControllerGetView(), and FlutterDesktopViewControllerHandleTopLevelWindowProc().

## ◆ ViewFromHandle()

static flutter::FlutterWindowsView* ViewFromHandle | ( | FlutterDesktopViewRef | ref | ) |
| static

Definition at line 54 of file flutter_windows.cc.

54 {
55 return reinterpret_cast<flutter::FlutterWindowsView*>(ref);
56 }

Referenced by FlutterDesktopViewGetGraphicsAdapter(), and FlutterDesktopViewGetHWND().

flutter::FlutterWindowsEngine::GetRegistrar
FlutterDesktopPluginRegistrarRef GetRegistrar()
Definition: flutter_windows_engine.cc:497
TextureRegistrarFromHandle
static flutter::FlutterWindowsTextureRegistrar * TextureRegistrarFromHandle(FlutterDesktopTextureRegistrarRef ref)
Definition: flutter_windows.cc:64
flutter::FlutterProjectBundle
Definition: flutter_project_bundle.h:21
flutter::FlutterWindowsView
Definition: flutter_windows_view.h:35
HandleForView
static FlutterDesktopViewRef HandleForView(flutter::FlutterWindowsView *view)
Definition: flutter_windows.cc:59
HandleForTextureRegistrar
static FlutterDesktopTextureRegistrarRef HandleForTextureRegistrar(flutter::FlutterWindowsTextureRegistrar *registrar)
Definition: flutter_windows.cc:70
flutter::FlutterWindowsEngine::SetNextFrameCallback
void SetNextFrameCallback(fml::closure callback)
Definition: flutter_windows_engine.cc:591
flutter::GetDpiForMonitor
UINT GetDpiForMonitor(HMONITOR monitor)
Definition: dpi_utils.cc:134
user_data
void * user_data
Definition: flutter_windows_view_unittests.cc:49
flutter::FlutterWindowsTextureRegistrar::MarkTextureFrameAvailable
bool MarkTextureFrameAvailable(int64_t texture_id)
Definition: flutter_windows_texture_registrar.cc:103
flutter::FlutterWindowsEngine
Definition: flutter_windows_engine.h:78
flutter::FlutterWindowsEngine::window_proc_delegate_manager
WindowProcDelegateManager * window_proc_delegate_manager()
Definition: flutter_windows_engine.h:148
flutter::FlutterWindowsEngine::running
virtual bool running() const
Definition: flutter_windows_engine.h:105
flutter::WindowProcDelegateManager::RegisterTopLevelWindowProcDelegate
void RegisterTopLevelWindowProcDelegate(FlutterDesktopWindowProcCallback delegate, void *user_data)
Definition: window_proc_delegate_manager.cc:14
flutter::GetDpiForHWND
UINT GetDpiForHWND(HWND hwnd)
Definition: dpi_utils.cc:130
flutter::FlutterWindowsEngine::windows_proc_table
std::shared_ptr< WindowsProcTable > windows_proc_table()
Definition: flutter_windows_engine.h:278
EngineFromHandle
static flutter::FlutterWindowsEngine * EngineFromHandle(FlutterDesktopEngineRef ref)
Definition: flutter_windows.cc:32
flutter::FlutterDesktopMessenger::ToRef
FlutterDesktopMessengerRef ToRef()
Convert to FlutterDesktopMessengerRef.
Definition: flutter_desktop_messenger.h:28
flutter::FlutterWindowsView::GetWindowHandle
virtual HWND GetWindowHandle() const
Definition: flutter_windows_view.cc:645
flutter::FlutterWindowsEngine::SendPlatformMessage
bool SendPlatformMessage(const char *channel, const uint8_t *message, const size_t message_size, const FlutterDesktopBinaryReply reply, void *user_data)
Definition: flutter_windows_engine.cc:528
flutter::FlutterWindowsEngine::Stop
virtual bool Stop()
Definition: flutter_windows_engine.cc:450
flutter::FlutterWindowsEngine::messenger
FlutterDesktopMessengerRef messenger()
Definition: flutter_windows_engine.h:130
HandleForViewController
static FlutterDesktopViewControllerRef HandleForViewController(flutter::FlutterWindowsViewController *view_controller)
Definition: flutter_windows.cc:48
flutter::FlutterWindowsEngine::ProcessExternalWindowMessage
std::optional< LRESULT > ProcessExternalWindowMessage(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam)
Definition: flutter_windows_engine.cc:814
flutter::FlutterDesktopMessenger::GetMutex
std::mutex & GetMutex()
Definition: flutter_desktop_messenger.h:70
flutter::FlutterDesktopMessenger::Release
void Release()
Definition: flutter_desktop_messenger.h:59
FlutterDesktopViewRef
struct FlutterDesktopView * FlutterDesktopViewRef
Definition: flutter_windows.h:29
FlutterDesktopEngineRef
struct FlutterDesktopEngine * FlutterDesktopEngineRef
Definition: flutter_windows.h:33
flutter::WindowProcDelegateManager::UnregisterTopLevelWindowProcDelegate
void UnregisterTopLevelWindowProcDelegate(FlutterDesktopWindowProcCallback delegate)
Definition: window_proc_delegate_manager.cc:20
flutter::FlutterWindowsTextureRegistrar
Definition: flutter_windows_texture_registrar.h:24
flutter::FlutterWindowsEngine::texture_registrar
FlutterWindowsTextureRegistrar * texture_registrar()
Definition: flutter_windows_engine.h:138
flutter::FlutterWindowsViewController
Controls a view that displays Flutter content.
Definition: flutter_windows_view_controller.h:16
flutter::FlutterWindowsEngine::AddPluginRegistrarDestructionCallback
void AddPluginRegistrarDestructionCallback(FlutterDesktopOnPluginRegistrarDestroyed callback, FlutterDesktopPluginRegistrarRef registrar)
Definition: flutter_windows_engine.cc:501
FlutterDesktopTextureRegistrarRef
struct FlutterDesktopTextureRegistrar * FlutterDesktopTextureRegistrarRef
Definition: flutter_texture_registrar.h:19
FlutterDesktopViewControllerRef
struct FlutterDesktopViewController * FlutterDesktopViewControllerRef
Definition: flutter_windows.h:25
FlutterDesktopPluginRegistrar::engine
flutter::FlutterWindowsEngine * engine
Definition: window_state.h:25
flutter::FlutterWindowsEngine::SendPlatformMessageResponse
void SendPlatformMessageResponse(const FlutterDesktopMessageResponseHandle *handle, const uint8_t *data, size_t data_length)
Definition: flutter_windows_engine.cc:562
flutter::FlutterDesktopMessenger::GetEngine
flutter::FlutterWindowsEngine * GetEngine() const
Getter for the engine field.
Definition: flutter_desktop_messenger.h:38
flutter::IncomingMessageDispatcher::SetMessageCallback
void SetMessageCallback(const std::string &channel, FlutterDesktopMessageCallback callback, void *user_data)
Definition: incoming_message_dispatcher.cc:43
flutter::FlutterWindowsEngine::surface_manager
AngleSurfaceManager * surface_manager() const
Definition: flutter_windows_engine.h:144
flutter::FlutterWindowsEngine::message_dispatcher
IncomingMessageDispatcher * message_dispatcher()
Definition: flutter_windows_engine.h:132
flutter::FlutterDesktopMessenger::AddRef
FlutterDesktopMessenger * AddRef()
Definition: flutter_desktop_messenger.h:50
FlutterDesktopMessengerIsAvailable
bool FlutterDesktopMessengerIsAvailable(FlutterDesktopMessengerRef messenger)
Definition: flutter_windows.cc:360
HandleForEngine
static FlutterDesktopEngineRef HandleForEngine(flutter::FlutterWindowsEngine *engine)
Definition: flutter_windows.cc:38
ViewFromHandle
static flutter::FlutterWindowsView * ViewFromHandle(FlutterDesktopViewRef ref)
Definition: flutter_windows.cc:54
flutter::FlutterWindowsEngine::view
FlutterWindowsView * view()
Definition: flutter_windows_engine.h:117
ViewControllerFromHandle
static flutter::FlutterWindowsViewController * ViewControllerFromHandle(FlutterDesktopViewControllerRef ref)
Definition: flutter_windows.cc:43
message
Win32Message message
Definition: keyboard_unittests.cc:137
flutter::FlutterDesktopMessenger::FromRef
static FlutterDesktopMessenger * FromRef(FlutterDesktopMessengerRef ref)
Convert from FlutterDesktopMessengerRef.
Definition: flutter_desktop_messenger.h:33
texture_id
int64_t texture_id
Definition: texture_registrar_unittests.cc:24
flutter::FlutterWindowsEngine::Run
bool Run()
Definition: flutter_windows_engine.cc:254
flutter::FlutterWindowsView::GetEngine
FlutterWindowsEngine * GetEngine()
Definition: flutter_windows_view.cc:649
flutter::FlutterWindowsTextureRegistrar::RegisterTexture
int64_t RegisterTexture(const FlutterDesktopTextureInfo *texture_info)
Definition: flutter_windows_texture_registrar.cc:26
FlutterDesktopMessengerSendWithReply
bool FlutterDesktopMessengerSendWithReply(FlutterDesktopMessengerRef messenger, const char *channel, const uint8_t *message, const size_t message_size, const FlutterDesktopBinaryReply reply, void *user_data)
Definition: flutter_windows.cc:301
flutter::FlutterWindowsEngine::ReloadSystemFonts
void ReloadSystemFonts()
Definition: flutter_windows_engine.cc:583
callback
FlutterDesktopBinaryReply callback
Definition: flutter_windows_view_unittests.cc:48