| 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/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::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)
void | FlutterDesktopViewControllerDestroy (FlutterDesktopViewControllerRef controller)
FlutterDesktopEngineRef | FlutterDesktopViewControllerGetEngine (FlutterDesktopViewControllerRef controller)
FlutterDesktopViewRef | FlutterDesktopViewControllerGetView (FlutterDesktopViewControllerRef controller)
void | FlutterDesktopViewControllerForceRedraw (FlutterDesktopViewControllerRef controller)
bool | FlutterDesktopViewControllerHandleTopLevelWindowProc (FlutterDesktopViewControllerRef controller, 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 31 of file flutter_windows.cc.

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

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

## ◆ FlutterDesktopEngineCreate()

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

Definition at line 127 of file flutter_windows.cc.

128 {
129 flutter::FlutterProjectBundle project(*engine_properties);
130 auto engine = std::make_unique<flutter::FlutterWindowsEngine>(project);
131 return HandleForEngine(engine.release());
132 }

References HandleForEngine().

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

## ◆ FlutterDesktopEngineDestroy()

bool FlutterDesktopEngineDestroy | ( | FlutterDesktopEngineRef | engine_ref | ) |

Definition at line 134 of file flutter_windows.cc.

134 {
135 flutter::FlutterWindowsEngine* engine = EngineFromHandle(engine_ref);
136 bool result = true;
137 if (engine->running()) {
138 result = engine->Stop();
139 }
140 delete engine;
141 return result;
142 }

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 172 of file flutter_windows.cc.

173 {
174 return EngineFromHandle(engine)->messenger();
175 }

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

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

## ◆ FlutterDesktopEngineGetPluginRegistrar()

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

Definition at line 162 of file flutter_windows.cc.

164 {
165 // Currently, one registrar acts as the registrar for all plugins, so the
166 // name is ignored. It is part of the API to reduce churn in the future when
167 // aligning more closely with the Flutter registrar system.
168
169 return EngineFromHandle(engine)->GetRegistrar();
170 }

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

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

## ◆ FlutterDesktopEngineGetTextureRegistrar()

FlutterDesktopTextureRegistrarRef FlutterDesktopEngineGetTextureRegistrar | ( | FlutterDesktopEngineRef | engine | ) |

Definition at line 177 of file flutter_windows.cc.

178 {
179 return HandleForTextureRegistrar(
180 EngineFromHandle(engine)->texture_registrar());
181 }

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 210 of file flutter_windows.cc.

216 {
217 std::optional<LRESULT> lresult =
218 EngineFromHandle(engine)->ProcessExternalWindowMessage(hwnd, message,
219 wparam, lparam);
220 if (result && lresult.has_value()) {
221 *result = lresult.value();
222 }
223 return lresult.has_value();
224 }

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

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

## ◆ FlutterDesktopEngineProcessMessages()

uint64_t FlutterDesktopEngineProcessMessages | ( | FlutterDesktopEngineRef | engine | ) |

Definition at line 154 of file flutter_windows.cc.

154 {
155 return std::chrono::nanoseconds::max().count();
156 }

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

## ◆ FlutterDesktopEngineReloadSystemFonts()

void FlutterDesktopEngineReloadSystemFonts | ( | FlutterDesktopEngineRef | engine | ) |

Definition at line 158 of file flutter_windows.cc.

158 {
159 EngineFromHandle(engine)->ReloadSystemFonts();
160 }

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

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

## ◆ FlutterDesktopEngineRun()

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

Definition at line 144 of file flutter_windows.cc.

145 {
146 std::string_view entry_point_view{""};
147 if (entry_point != nullptr) {
148 entry_point_view = entry_point;
149 }
150
151 return EngineFromHandle(engine)->Run(entry_point_view);
152 }

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 183 of file flutter_windows.cc.

185 {
186 EngineFromHandle(engine)->SetNextFrameCallback(
187 [callback, user_data]() { callback(user_data); });
188 }

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 246 of file flutter_windows.cc.

246 {
247 return flutter::GetDpiForHWND(hwnd);
248 }

References flutter::GetDpiForHWND().

## ◆ FlutterDesktopGetDpiForMonitor()

UINT FlutterDesktopGetDpiForMonitor | ( | HMONITOR | monitor | ) |

Definition at line 250 of file flutter_windows.cc.

250 {
251 return flutter::GetDpiForMonitor(monitor);
252 }

References flutter::GetDpiForMonitor().

## ◆ FlutterDesktopMessengerAddRef()

FlutterDesktopMessengerRef FlutterDesktopMessengerAddRef | ( | FlutterDesktopMessengerRef | messenger | ) |

Definition at line 326 of file flutter_windows.cc.

327 {
328 return flutter::FlutterDesktopMessenger::FromRef(messenger)
329 ->AddRef()
330 ->ToRef();
331 }

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

## ◆ FlutterDesktopMessengerIsAvailable()

bool FlutterDesktopMessengerIsAvailable | ( | FlutterDesktopMessengerRef | messenger | ) |

Definition at line 337 of file flutter_windows.cc.

337 {
338 return flutter::FlutterDesktopMessenger::FromRef(messenger)->GetEngine() !=
339 nullptr;
340 }

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

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

## ◆ FlutterDesktopMessengerLock()

FlutterDesktopMessengerRef FlutterDesktopMessengerLock | ( | FlutterDesktopMessengerRef | messenger | ) |

Definition at line 342 of file flutter_windows.cc.

343 {
344 flutter::FlutterDesktopMessenger::FromRef(messenger)->GetMutex().lock();
345 return messenger;
346 }

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

## ◆ FlutterDesktopMessengerRelease()

void FlutterDesktopMessengerRelease | ( | FlutterDesktopMessengerRef | messenger | ) |

Definition at line 333 of file flutter_windows.cc.

333 {
334 flutter::FlutterDesktopMessenger::FromRef(messenger)->Release();
335 }

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 292 of file flutter_windows.cc.

295 {
296 return FlutterDesktopMessengerSendWithReply(messenger, channel, message,
297 message_size, nullptr, nullptr);
298 }

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 300 of file flutter_windows.cc.

304 {
305 FML_DCHECK(FlutterDesktopMessengerIsAvailable(messenger))
306 << "Messenger must reference a running engine to send a response";
307
308 flutter::FlutterDesktopMessenger::FromRef(messenger)
309 ->GetEngine()
310 ->SendPlatformMessageResponse(handle, data, data_length);
311 }

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 278 of file flutter_windows.cc.

283 {
284 FML_DCHECK(FlutterDesktopMessengerIsAvailable(messenger))
285 << "Messenger must reference a running engine to send a message";
286
287 return flutter::FlutterDesktopMessenger::FromRef(messenger)
288 ->GetEngine()
289 ->SendPlatformMessage(channel, message, message_size, reply, user_data);
290 }

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 313 of file flutter_windows.cc.

316 {
317 FML_DCHECK(FlutterDesktopMessengerIsAvailable(messenger))
318 << "Messenger must reference a running engine to set a callback";
319
320 flutter::FlutterDesktopMessenger::FromRef(messenger)
321 ->GetEngine()
322 ->message_dispatcher()
323 ->SetMessageCallback(channel, callback, user_data);
324 }

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 348 of file flutter_windows.cc.

348 {
349 flutter::FlutterDesktopMessenger::FromRef(messenger)->GetMutex().unlock();
350 }

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

## ◆ FlutterDesktopPluginRegistrarGetMessenger()

FlutterDesktopMessengerRef FlutterDesktopPluginRegistrarGetMessenger | ( | FlutterDesktopPluginRegistrarRef | registrar | ) |

Definition at line 267 of file flutter_windows.cc.

268 {
269 return registrar->engine->messenger();
270 }

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

## ◆ FlutterDesktopPluginRegistrarGetView()

FlutterDesktopViewRef FlutterDesktopPluginRegistrarGetView | ( | FlutterDesktopPluginRegistrarRef | registrar | ) |

Definition at line 226 of file flutter_windows.cc.

227 {
228 return HandleForView(registrar->engine->view());
229 }

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 231 of file flutter_windows.cc.

234 {
235 registrar->engine->window_proc_delegate_manager()
236 ->RegisterTopLevelWindowProcDelegate(delegate, user_data);
237 }

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 272 of file flutter_windows.cc.

274 {
275 registrar->engine->AddPluginRegistrarDestructionCallback(callback, registrar);
276 }

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

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

## ◆ FlutterDesktopPluginRegistrarUnregisterTopLevelWindowProcDelegate()

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

Definition at line 239 of file flutter_windows.cc.

241 {
242 registrar->engine->window_proc_delegate_manager()
243 ->UnregisterTopLevelWindowProcDelegate(delegate);
244 }

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 352 of file flutter_windows.cc.

353 {
354 return HandleForTextureRegistrar(registrar->engine->texture_registrar());
355 }

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

## ◆ FlutterDesktopResyncOutputStreams()

void FlutterDesktopResyncOutputStreams | ( |  | ) |

Definition at line 254 of file flutter_windows.cc.

254 {
255 FILE* unused;
256 if (freopen_s(&unused, "CONOUT$", "w", stdout)) {
257 _dup2(_fileno(stdout), 1);
258 }
259 if (freopen_s(&unused, "CONOUT$", "w", stderr)) {
260 _dup2(_fileno(stdout), 2);
261 }
262 std::ios::sync_with_stdio();
263 }

## ◆ FlutterDesktopTextureRegistrarMarkExternalTextureFrameAvailable()

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

Definition at line 378 of file flutter_windows.cc.

380 {
381 return TextureRegistrarFromHandle(texture_registrar)
382 ->MarkTextureFrameAvailable(texture_id);
383 }

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 357 of file flutter_windows.cc.

359 {
360 return TextureRegistrarFromHandle(texture_registrar)
361 ->RegisterTexture(texture_info);
362 }

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 364 of file flutter_windows.cc.

368 {
369 auto registrar = TextureRegistrarFromHandle(texture_registrar);
370 if (callback) {
371 registrar->UnregisterTexture(
372 texture_id, [callback, user_data]() { callback(user_data); });
373 return;
374 }
375 registrar->UnregisterTexture(texture_id);
376 }

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

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

## ◆ FlutterDesktopViewControllerCreate()

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

Definition at line 64 of file flutter_windows.cc.

67 {
68 std::unique_ptr<flutter::WindowBindingHandler> window_wrapper =
69 std::make_unique<flutter::FlutterWindow>(width, height);
70
71 auto state = std::make_unique<FlutterDesktopViewControllerState>();
72 state->view =
73 std::make_unique<flutter::FlutterWindowsView>(std::move(window_wrapper));
74 // Take ownership of the engine, starting it if necessary.
75 state->view->SetEngine(
76 std::unique_ptr<flutter::FlutterWindowsEngine>(EngineFromHandle(engine)));
77 state->view->CreateRenderSurface();
78 if (!state->view->GetEngine()->running()) {
79 if (!state->view->GetEngine()->Run()) {
80 return nullptr;
81 }
82 }
83
84 // Must happen after engine is running.
85 state->view->SendInitialBounds();
86 state->view->SendInitialAccessibilityFeatures();
87 return state.release();
88 }

References EngineFromHandle().

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

## ◆ FlutterDesktopViewControllerDestroy()

void FlutterDesktopViewControllerDestroy | ( | FlutterDesktopViewControllerRef | controller | ) |

Definition at line 90 of file flutter_windows.cc.

91 {
92 delete controller;
93 }

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

## ◆ FlutterDesktopViewControllerForceRedraw()

void FlutterDesktopViewControllerForceRedraw | ( | FlutterDesktopViewControllerRef | controller | ) |

Definition at line 105 of file flutter_windows.cc.

106 {
107 controller->view->ForceRedraw();
108 }

References FlutterDesktopViewControllerState::view.

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

## ◆ FlutterDesktopViewControllerGetEngine()

FlutterDesktopEngineRef FlutterDesktopViewControllerGetEngine | ( | FlutterDesktopViewControllerRef | controller | ) |

Definition at line 95 of file flutter_windows.cc.

96 {
97 return HandleForEngine(controller->view->GetEngine());
98 }

References HandleForEngine(), and FlutterDesktopViewControllerState::view.

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

## ◆ FlutterDesktopViewControllerGetView()

FlutterDesktopViewRef FlutterDesktopViewControllerGetView | ( | FlutterDesktopViewControllerRef | controller | ) |

Definition at line 100 of file flutter_windows.cc.

101 {
102 return HandleForView(controller->view.get());
103 }

References HandleForView(), and FlutterDesktopViewControllerState::view.

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

## ◆ FlutterDesktopViewControllerHandleTopLevelWindowProc()

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

Definition at line 110 of file flutter_windows.cc.

116 {
117 std::optional<LRESULT> delegate_result =
118 controller->view->GetEngine()
119 ->window_proc_delegate_manager()
120 ->OnTopLevelWindowProc(hwnd, message, wparam, lparam);
121 if (delegate_result) {
122 *result = *delegate_result;
123 }
124 return delegate_result.has_value();
125 }

References message, and FlutterDesktopViewControllerState::view.

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

## ◆ FlutterDesktopViewGetGraphicsAdapter()

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

Definition at line 194 of file flutter_windows.cc.

194 {
195 auto surface_manager = ViewFromHandle(view)->GetEngine()->surface_manager();
196 if (surface_manager) {
197 Microsoft::WRL::ComPtr<ID3D11Device> d3d_device;
198 Microsoft::WRL::ComPtr<IDXGIDevice> dxgi_device;
199 if (surface_manager->GetDevice(d3d_device.GetAddressOf()) &&
200 SUCCEEDED(d3d_device.As(&dxgi_device))) {
201 IDXGIAdapter* adapter;
202 if (SUCCEEDED(dxgi_device->GetAdapter(&adapter))) {
203 return adapter;
204 }
205 }
206 }
207 return nullptr;
208 }

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 190 of file flutter_windows.cc.

190 {
191 return ViewFromHandle(view)->GetPlatformWindow();
192 }

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

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

## ◆ HandleForEngine()

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

Definition at line 37 of file flutter_windows.cc.

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

Referenced by FlutterDesktopEngineCreate(), and FlutterDesktopViewControllerGetEngine().

## ◆ HandleForTextureRegistrar()

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

Definition at line 59 of file flutter_windows.cc.

60 {
61 return reinterpret_cast<FlutterDesktopTextureRegistrarRef>(registrar);
62 }

Referenced by FlutterDesktopEngineGetTextureRegistrar(), and FlutterDesktopRegistrarGetTextureRegistrar().

## ◆ HandleForView()

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

Definition at line 48 of file flutter_windows.cc.

48 {
49 return reinterpret_cast<FlutterDesktopViewRef>(view);
50 }

Referenced by FlutterDesktopPluginRegistrarGetView(), and FlutterDesktopViewControllerGetView().

## ◆ TextureRegistrarFromHandle()

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

Definition at line 53 of file flutter_windows.cc.

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

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

## ◆ ViewFromHandle()

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

Definition at line 43 of file flutter_windows.cc.

43 {
44 return reinterpret_cast<flutter::FlutterWindowsView*>(ref);
45 }

Referenced by FlutterDesktopViewGetGraphicsAdapter(), and FlutterDesktopViewGetHWND().

flutter::FlutterWindowsEngine::GetRegistrar
FlutterDesktopPluginRegistrarRef GetRegistrar()
Definition: flutter_windows_engine.cc:489
TextureRegistrarFromHandle
static flutter::FlutterWindowsTextureRegistrar * TextureRegistrarFromHandle(FlutterDesktopTextureRegistrarRef ref)
Definition: flutter_windows.cc:53
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:48
HandleForTextureRegistrar
static FlutterDesktopTextureRegistrarRef HandleForTextureRegistrar(flutter::FlutterWindowsTextureRegistrar *registrar)
Definition: flutter_windows.cc:59
flutter::FlutterWindowsEngine::SetNextFrameCallback
void SetNextFrameCallback(fml::closure callback)
Definition: flutter_windows_engine.cc:584
flutter::GetDpiForMonitor
UINT GetDpiForMonitor(HMONITOR monitor)
Definition: dpi_utils.cc:134
user_data
void * user_data
Definition: flutter_windows_view_unittests.cc:47
flutter::FlutterWindowsTextureRegistrar::MarkTextureFrameAvailable
bool MarkTextureFrameAvailable(int64_t texture_id)
Definition: flutter_windows_texture_registrar.cc:104
flutter::FlutterWindowsEngine
Definition: flutter_windows_engine.h:78
flutter::FlutterWindowsEngine::window_proc_delegate_manager
WindowProcDelegateManager * window_proc_delegate_manager()
Definition: flutter_windows_engine.h:144
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
EngineFromHandle
static flutter::FlutterWindowsEngine * EngineFromHandle(FlutterDesktopEngineRef ref)
Definition: flutter_windows.cc:31
flutter::FlutterDesktopMessenger::ToRef
FlutterDesktopMessengerRef ToRef()
Convert to FlutterDesktopMessengerRef.
Definition: flutter_desktop_messenger.h:28
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:520
flutter::FlutterWindowsEngine::Stop
virtual bool Stop()
Definition: flutter_windows_engine.cc:442
flutter::FlutterWindowsEngine::messenger
FlutterDesktopMessengerRef messenger()
Definition: flutter_windows_engine.h:128
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:23
flutter::FlutterWindowsEngine::texture_registrar
FlutterWindowsTextureRegistrar * texture_registrar()
Definition: flutter_windows_engine.h:136
flutter::FlutterWindowsEngine::AddPluginRegistrarDestructionCallback
void AddPluginRegistrarDestructionCallback(FlutterDesktopOnPluginRegistrarDestroyed callback, FlutterDesktopPluginRegistrarRef registrar)
Definition: flutter_windows_engine.cc:493
FlutterDesktopTextureRegistrarRef
struct FlutterDesktopTextureRegistrar * FlutterDesktopTextureRegistrarRef
Definition: flutter_texture_registrar.h:19
FlutterDesktopPluginRegistrar::engine
flutter::FlutterWindowsEngine * engine
Definition: window_state.h:33
flutter::FlutterWindowsEngine::SendPlatformMessageResponse
void SendPlatformMessageResponse(const FlutterDesktopMessageResponseHandle *handle, const uint8_t *data, size_t data_length)
Definition: flutter_windows_engine.cc:554
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::message_dispatcher
IncomingMessageDispatcher * message_dispatcher()
Definition: flutter_windows_engine.h:130
flutter::FlutterDesktopMessenger::AddRef
FlutterDesktopMessenger * AddRef()
Definition: flutter_desktop_messenger.h:50
flutter::FlutterWindowsEngine::surface_manager
AngleSurfaceManager * surface_manager()
Definition: flutter_windows_engine.h:142
FlutterDesktopMessengerIsAvailable
bool FlutterDesktopMessengerIsAvailable(FlutterDesktopMessengerRef messenger)
Definition: flutter_windows.cc:337
HandleForEngine
static FlutterDesktopEngineRef HandleForEngine(flutter::FlutterWindowsEngine *engine)
Definition: flutter_windows.cc:37
ViewFromHandle
static flutter::FlutterWindowsView * ViewFromHandle(FlutterDesktopViewRef ref)
Definition: flutter_windows.cc:43
flutter::FlutterWindowsEngine::view
FlutterWindowsView * view()
Definition: flutter_windows_engine.h:115
flutter::FlutterWindowsEngine::running
bool running()
Definition: flutter_windows_engine.h:103
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
FlutterDesktopViewControllerState::view
std::unique_ptr< flutter::FlutterWindowsView > view
Definition: window_state.h:26
flutter::FlutterWindowsView::GetPlatformWindow
virtual PlatformWindow GetPlatformWindow() const
Definition: flutter_windows_view.cc:626
texture_id
int64_t texture_id
Definition: texture_registrar_unittests.cc:24
flutter::FlutterWindowsEngine::Run
bool Run()
Definition: flutter_windows_engine.cc:246
flutter::FlutterWindowsView::GetEngine
FlutterWindowsEngine * GetEngine()
Definition: flutter_windows_view.cc:630
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:278
flutter::FlutterWindowsEngine::ReloadSystemFonts
void ReloadSystemFonts()
Definition: flutter_windows_engine.cc:576
callback
FlutterDesktopBinaryReply callback
Definition: flutter_windows_view_unittests.cc:46