|
Flutter Windows Embedder
|
|
Go to the documentation of this file.
19 #include "flutter/shell/platform/embedder/embedder.h"
29 static_assert(FLUTTER_ENGINE_VERSION == 1,
"");
85 std::unique_ptr<flutter::WindowBindingHandler> window_wrapper =
86 std::make_unique<flutter::FlutterWindow>(
89 std::unique_ptr<flutter::FlutterWindowsEngine> engine;
91 engine = std::unique_ptr<flutter::FlutterWindowsEngine>(engine_ptr);
94 std::unique_ptr<flutter::FlutterWindowsView> view =
95 engine_ptr->
CreateView(std::move(window_wrapper));
100 auto controller = std::make_unique<flutter::FlutterWindowsViewController>(
101 std::move(engine), std::move(view));
104 if (!controller->engine()->running()) {
105 if (!controller->engine()->Run()) {
111 controller->view()->SendInitialBounds();
116 controller->engine()->UpdateAccessibilityFeatures();
137 controller->Destroy();
162 controller->view()->ForceRedraw();
173 std::optional<LRESULT> delegate_result =
175 ->window_proc_delegate_manager()
176 ->OnTopLevelWindowProc(hwnd,
message, wparam, lparam);
177 if (delegate_result) {
178 *result = *delegate_result;
180 return delegate_result.has_value();
186 auto engine = std::make_unique<flutter::FlutterWindowsEngine>(project);
194 result = engine->
Stop();
201 const char* entry_point) {
202 std::string_view entry_point_view{
""};
203 if (entry_point !=
nullptr) {
204 entry_point_view = entry_point;
211 return std::chrono::nanoseconds::max().count();
220 const char* plugin_name) {
253 Microsoft::WRL::ComPtr<ID3D11Device> d3d_device;
254 Microsoft::WRL::ComPtr<IDXGIDevice> dxgi_device;
255 if (egl_manager->GetDevice(d3d_device.GetAddressOf()) &&
256 SUCCEEDED(d3d_device.As(&dxgi_device))) {
257 IDXGIAdapter* adapter;
258 if (SUCCEEDED(dxgi_device->GetAdapter(&adapter))) {
273 std::optional<LRESULT> lresult =
276 if (result && lresult.has_value()) {
277 *result = lresult.value();
279 return lresult.has_value();
284 const char* view_type_name,
326 if (freopen_s(&unused,
"CONOUT$",
"w", stdout)) {
327 _dup2(_fileno(stdout), 1);
329 if (freopen_s(&unused,
"CONOUT$",
"w", stderr)) {
330 _dup2(_fileno(stdout), 2);
332 std::ios::sync_with_stdio();
351 const size_t message_size,
355 <<
"Messenger must reference a running engine to send a message";
365 const size_t message_size) {
367 message_size,
nullptr,
nullptr);
374 size_t data_length) {
376 <<
"Messenger must reference a running engine to send a response";
388 <<
"Messenger must reference a running engine to set a callback";
441 registrar->UnregisterTexture(
constexpr FlutterViewId kImplicitViewId
bool FlutterDesktopViewControllerHandleTopLevelWindowProc(FlutterDesktopViewControllerRef ref, HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam, LRESULT *result)
FlutterDesktopPluginRegistrarRef GetRegistrar()
static flutter::FlutterWindowsTextureRegistrar * TextureRegistrarFromHandle(FlutterDesktopTextureRegistrarRef ref)
HWND FlutterDesktopViewGetHWND(FlutterDesktopViewRef view)
FlutterDesktopViewRef FlutterDesktopViewControllerGetView(FlutterDesktopViewControllerRef ref)
FlutterDesktopTextureRegistrarRef FlutterDesktopEngineGetTextureRegistrar(FlutterDesktopEngineRef engine)
FlutterDesktopViewRef FlutterDesktopPluginRegistrarGetView(FlutterDesktopPluginRegistrarRef registrar)
FlutterWindowsView * view(FlutterViewId view_id) const
FlutterDesktopMessengerRef FlutterDesktopEngineGetMessenger(FlutterDesktopEngineRef engine)
void FlutterDesktopPluginRegistrarRegisterTopLevelWindowProcDelegate(FlutterDesktopPluginRegistrarRef registrar, FlutterDesktopWindowProcCallback delegate, void *user_data)
static FlutterDesktopViewRef HandleForView(flutter::FlutterWindowsView *view)
void FlutterDesktopMessengerUnlock(FlutterDesktopMessengerRef messenger)
static FlutterDesktopViewControllerRef CreateViewController(FlutterDesktopEngineRef engine_ref, int width, int height, bool owns_engine)
bool FlutterDesktopMessengerSend(FlutterDesktopMessengerRef messenger, const char *channel, const uint8_t *message, const size_t message_size)
void(* FlutterDesktopBinaryReply)(const uint8_t *data, size_t data_size, void *user_data)
int64_t FlutterDesktopViewId
static FlutterDesktopTextureRegistrarRef HandleForTextureRegistrar(flutter::FlutterWindowsTextureRegistrar *registrar)
void SetNextFrameCallback(fml::closure callback)
UINT GetDpiForMonitor(HMONITOR monitor)
bool MarkTextureFrameAvailable(int64_t texture_id)
WindowProcDelegateManager * window_proc_delegate_manager()
virtual bool running() const
void FlutterDesktopEngineRegisterPlatformViewType(FlutterDesktopEngineRef engine, const char *view_type_name, FlutterPlatformViewTypeEntry view_type)
struct _FlutterPlatformMessageResponseHandle FlutterDesktopMessageResponseHandle
bool FlutterDesktopEngineProcessExternalWindowMessage(FlutterDesktopEngineRef engine, HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam, LRESULT *result)
void FlutterDesktopPluginRegistrarSetDestructionHandler(FlutterDesktopPluginRegistrarRef registrar, FlutterDesktopOnPluginRegistrarDestroyed callback)
FlutterDesktopPluginRegistrarRef FlutterDesktopEngineGetPluginRegistrar(FlutterDesktopEngineRef engine, const char *plugin_name)
UINT GetDpiForHWND(HWND hwnd)
std::shared_ptr< WindowsProcTable > windows_proc_table()
static flutter::FlutterWindowsEngine * EngineFromHandle(FlutterDesktopEngineRef ref)
FlutterDesktopMessengerRef FlutterDesktopPluginRegistrarGetMessenger(FlutterDesktopPluginRegistrarRef registrar)
FlutterDesktopMessengerRef ToRef()
Convert to FlutterDesktopMessengerRef.
virtual HWND GetWindowHandle() const
bool SendPlatformMessage(const char *channel, const uint8_t *message, const size_t message_size, const FlutterDesktopBinaryReply reply, void *user_data)
void FlutterDesktopResyncOutputStreams()
FlutterDesktopViewId FlutterDesktopViewControllerGetViewId(FlutterDesktopViewControllerRef ref)
FlutterDesktopMessengerRef messenger()
static FlutterDesktopViewControllerRef HandleForViewController(flutter::FlutterWindowsViewController *view_controller)
std::optional< LRESULT > ProcessExternalWindowMessage(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam)
FlutterDesktopMessengerRef FlutterDesktopMessengerLock(FlutterDesktopMessengerRef messenger)
struct FlutterDesktopView * FlutterDesktopViewRef
struct FlutterDesktopEngine * FlutterDesktopEngineRef
std::unique_ptr< FlutterWindowsView > CreateView(std::unique_ptr< WindowBindingHandler > window)
FlutterWindowsTextureRegistrar * texture_registrar()
Controls a view that displays Flutter content.
FlutterDesktopTextureRegistrarRef FlutterDesktopRegistrarGetTextureRegistrar(FlutterDesktopPluginRegistrarRef registrar)
void AddPluginRegistrarDestructionCallback(FlutterDesktopOnPluginRegistrarDestroyed callback, FlutterDesktopPluginRegistrarRef registrar)
struct FlutterDesktopTextureRegistrar * FlutterDesktopTextureRegistrarRef
UINT FlutterDesktopGetDpiForMonitor(HMONITOR monitor)
uint64_t FlutterDesktopEngineProcessMessages(FlutterDesktopEngineRef engine)
struct FlutterDesktopViewController * FlutterDesktopViewControllerRef
flutter::FlutterWindowsEngine * engine
void FlutterDesktopTextureRegistrarUnregisterExternalTexture(FlutterDesktopTextureRegistrarRef texture_registrar, int64_t texture_id, void(*callback)(void *user_data), void *user_data)
void SendPlatformMessageResponse(const FlutterDesktopMessageResponseHandle *handle, const uint8_t *data, size_t data_length)
flutter::FlutterWindowsEngine * GetEngine() const
Getter for the engine field.
FlutterDesktopViewControllerRef FlutterDesktopViewControllerCreate(int width, int height, FlutterDesktopEngineRef engine)
void SetMessageCallback(const std::string &channel, FlutterDesktopMessageCallback callback, void *user_data)
void FlutterDesktopPluginRegistrarUnregisterTopLevelWindowProcDelegate(FlutterDesktopPluginRegistrarRef registrar, FlutterDesktopWindowProcCallback delegate)
void(* FlutterDesktopOnPluginRegistrarDestroyed)(FlutterDesktopPluginRegistrarRef)
void FlutterDesktopViewControllerForceRedraw(FlutterDesktopViewControllerRef ref)
void UnregisterTopLevelWindowProcDelegate(FlutterDesktopWindowProcCallback callback)
IncomingMessageDispatcher * message_dispatcher()
FlutterDesktopMessenger * AddRef()
FlutterWindowsEngine * GetEngine() const
bool FlutterDesktopTextureRegistrarMarkExternalTextureFrameAvailable(FlutterDesktopTextureRegistrarRef texture_registrar, int64_t texture_id)
bool FlutterDesktopEngineDestroy(FlutterDesktopEngineRef engine_ref)
FlutterDesktopEngineRef FlutterDesktopEngineCreate(const FlutterDesktopEngineProperties *engine_properties)
struct FlutterDesktopMessenger * FlutterDesktopMessengerRef
void FlutterDesktopMessengerSendResponse(FlutterDesktopMessengerRef messenger, const FlutterDesktopMessageResponseHandle *handle, const uint8_t *data, size_t data_length)
bool FlutterDesktopMessengerIsAvailable(FlutterDesktopMessengerRef messenger)
FlutterDesktopEngineRef FlutterDesktopViewControllerGetEngine(FlutterDesktopViewControllerRef ref)
static FlutterDesktopEngineRef HandleForEngine(flutter::FlutterWindowsEngine *engine)
static flutter::FlutterWindowsView * ViewFromHandle(FlutterDesktopViewRef ref)
static flutter::FlutterWindowsViewController * ViewControllerFromHandle(FlutterDesktopViewControllerRef ref)
void(* VoidCallback)(void *)
void FlutterDesktopViewControllerDestroy(FlutterDesktopViewControllerRef ref)
static FlutterDesktopMessenger * FromRef(FlutterDesktopMessengerRef ref)
Convert from FlutterDesktopMessengerRef.
void FlutterDesktopEngineSetNextFrameCallback(FlutterDesktopEngineRef engine, VoidCallback callback, void *user_data)
FlutterDesktopViewControllerRef FlutterDesktopEngineCreateViewController(FlutterDesktopEngineRef engine, const FlutterDesktopViewControllerProperties *properties)
void FlutterDesktopMessengerRelease(FlutterDesktopMessengerRef messenger)
int64_t FlutterDesktopTextureRegistrarRegisterExternalTexture(FlutterDesktopTextureRegistrarRef texture_registrar, const FlutterDesktopTextureInfo *texture_info)
void FlutterDesktopMessengerSetCallback(FlutterDesktopMessengerRef messenger, const char *channel, FlutterDesktopMessageCallback callback, void *user_data)
IDXGIAdapter * FlutterDesktopViewGetGraphicsAdapter(FlutterDesktopViewRef view)
egl::Manager * egl_manager() const
void(* FlutterDesktopMessageCallback)(FlutterDesktopMessengerRef, const FlutterDesktopMessage *, void *)
UINT FlutterDesktopGetDpiForHWND(HWND hwnd)
bool FlutterDesktopEngineRun(FlutterDesktopEngineRef engine, const char *entry_point)
FlutterDesktopViewRef FlutterDesktopPluginRegistrarGetViewById(FlutterDesktopPluginRegistrarRef registrar, FlutterDesktopViewId view_id)
bool(* FlutterDesktopWindowProcCallback)(HWND, UINT, WPARAM, LPARAM, void *, LRESULT *result)
void RegisterTopLevelWindowProcDelegate(FlutterDesktopWindowProcCallback callback, void *user_data)
int64_t RegisterTexture(const FlutterDesktopTextureInfo *texture_info)
bool FlutterDesktopMessengerSendWithReply(FlutterDesktopMessengerRef messenger, const char *channel, const uint8_t *message, const size_t message_size, const FlutterDesktopBinaryReply reply, void *user_data)
void FlutterDesktopEngineReloadSystemFonts(FlutterDesktopEngineRef engine)
FlutterDesktopBinaryReply callback
FlutterDesktopMessengerRef FlutterDesktopMessengerAddRef(FlutterDesktopMessengerRef messenger)