5#ifndef FLUTTER_SHELL_PLATFORM_WINDOWS_FLUTTER_WINDOWS_ENGINE_H_
6#define FLUTTER_SHELL_PLATFORM_WINDOWS_FLUTTER_WINDOWS_ENGINE_H_
14#include <unordered_map>
17#include "flutter/fml/closure.h"
18#include "flutter/fml/macros.h"
19#include "flutter/fml/synchronization/shared_mutex.h"
20#include "flutter/shell/platform/common/accessibility_bridge.h"
21#include "flutter/shell/platform/common/app_lifecycle_state.h"
22#include "flutter/shell/platform/common/client_wrapper/binary_messenger_impl.h"
23#include "flutter/shell/platform/common/client_wrapper/include/flutter/basic_message_channel.h"
24#include "flutter/shell/platform/common/incoming_message_dispatcher.h"
25#include "flutter/shell/platform/embedder/embedder.h"
26#include "flutter/shell/platform/windows/accessibility_bridge_windows.h"
27#include "flutter/shell/platform/windows/accessibility_plugin.h"
28#include "flutter/shell/platform/windows/compositor.h"
29#include "flutter/shell/platform/windows/cursor_handler.h"
30#include "flutter/shell/platform/windows/egl/manager.h"
31#include "flutter/shell/platform/windows/egl/proc_table.h"
32#include "flutter/shell/platform/windows/flutter_desktop_messenger.h"
33#include "flutter/shell/platform/windows/flutter_project_bundle.h"
34#include "flutter/shell/platform/windows/flutter_windows_texture_registrar.h"
35#include "flutter/shell/platform/windows/keyboard_handler_base.h"
36#include "flutter/shell/platform/windows/keyboard_key_embedder_handler.h"
37#include "flutter/shell/platform/windows/platform_handler.h"
38#include "flutter/shell/platform/windows/platform_view_plugin.h"
39#include "flutter/shell/platform/windows/public/flutter_windows.h"
40#include "flutter/shell/platform/windows/settings_plugin.h"
41#include "flutter/shell/platform/windows/task_runner.h"
42#include "flutter/shell/platform/windows/text_input_plugin.h"
43#include "flutter/shell/platform/windows/window_proc_delegate_manager.h"
44#include "flutter/shell/platform/windows/window_state.h"
45#include "flutter/shell/platform/windows/windows_lifecycle_manager.h"
46#include "flutter/shell/platform/windows/windows_proc_table.h"
47#include "third_party/rapidjson/include/rapidjson/document.h"
66 SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_BELOW_NORMAL);
70 SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_ABOVE_NORMAL);
74 SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_ABOVE_NORMAL);
114 bool Run(std::string_view entrypoint);
117 virtual bool running()
const {
return engine_ !=
nullptr; }
127 std::unique_ptr<FlutterWindowsView>
CreateView(
128 std::unique_ptr<WindowBindingHandler>
window);
147 void SetSwitches(
const std::vector<std::string>& switches);
152 return message_dispatcher_.get();
160 return texture_registrar_.get();
168 return window_proc_delegate_manager_.get();
183 return keyboard_key_handler_.get();
191 const size_t message_size,
260 root_isolate_create_callback_ =
callback;
267 void OnQuit(std::optional<HWND> hwnd,
268 std::optional<WPARAM> wparam,
269 std::optional<LPARAM> lparam,
294 return lifecycle_manager_.get();
298 return windows_proc_table_;
336 void SendSystemLocales();
345 void InitializeKeyboard();
348 void SendAccessibilityFeatures();
360 std::unique_ptr<FlutterProjectBundle> project_;
378 std::unordered_map<FlutterViewId, FlutterWindowsView*> views_;
387 std::unique_ptr<fml::SharedMutex> views_mutex_;
390 std::unique_ptr<TaskRunner> task_runner_;
396 std::unique_ptr<BinaryMessengerImpl> messenger_wrapper_;
399 std::unique_ptr<IncomingMessageDispatcher> message_dispatcher_;
402 std::unique_ptr<FlutterDesktopPluginRegistrar> plugin_registrar_;
405 std::unique_ptr<FlutterWindowsTextureRegistrar> texture_registrar_;
410 std::unique_ptr<egl::Manager> egl_manager_;
414 std::unique_ptr<Compositor> compositor_;
417 std::unique_ptr<PluginRegistrar> internal_plugin_registrar_;
420 std::unique_ptr<AccessibilityPlugin> accessibility_plugin_;
423 std::unique_ptr<CursorHandler> cursor_handler_;
426 std::unique_ptr<PlatformHandler> platform_handler_;
429 std::unique_ptr<KeyboardHandlerBase> keyboard_key_handler_;
432 std::unique_ptr<TextInputPlugin> text_input_plugin_;
435 std::unique_ptr<SettingsPlugin> settings_plugin_;
441 plugin_registrar_destruction_callbacks_;
444 std::chrono::nanoseconds FrameInterval();
447 std::chrono::nanoseconds start_time_ = std::chrono::nanoseconds::zero();
450 std::optional<std::chrono::nanoseconds> frame_interval_override_ =
453 bool semantics_enabled_ =
false;
455 bool high_contrast_enabled_ =
false;
457 bool enable_impeller_ =
false;
460 std::unique_ptr<WindowProcDelegateManager> window_proc_delegate_manager_;
469 std::unique_ptr<WindowsLifecycleManager> lifecycle_manager_;
471 std::shared_ptr<WindowsProcTable> windows_proc_table_;
473 std::shared_ptr<egl::ProcTable> gl_;
475 std::unique_ptr<PlatformViewPlugin> platform_view_plugin_;
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
FlutterDesktopMessengerRef ToRef()
Convert to FlutterDesktopMessengerRef.
void UpdateHighContrastMode()
FlutterWindowsEngine(const FlutterProjectBundle &project, std::shared_ptr< WindowsProcTable > windows_proc_table=nullptr)
void UpdateAccessibilityFeatures()
FlutterDesktopMessengerRef messenger()
bool DispatchSemanticsAction(uint64_t id, FlutterSemanticsAction action, fml::MallocMapping data)
void OnWindowStateEvent(HWND hwnd, WindowStateEvent event)
void OnDwmCompositionChanged()
void RequestApplicationQuit(HWND hwnd, WPARAM wparam, LPARAM lparam, AppExitType exit_type)
FlutterWindowsView * view(FlutterViewId view_id) const
void OnPreEngineRestart()
bool SendPlatformMessage(const char *channel, const uint8_t *message, const size_t message_size, const FlutterDesktopBinaryReply reply, void *user_data)
std::optional< LRESULT > ProcessExternalWindowMessage(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam)
void AddPluginRegistrarDestructionCallback(FlutterDesktopOnPluginRegistrarDestroyed callback, FlutterDesktopPluginRegistrarRef registrar)
std::shared_ptr< WindowsProcTable > windows_proc_table()
bool RegisterExternalTexture(int64_t texture_id)
IncomingMessageDispatcher * message_dispatcher()
void SendPlatformMessageResponse(const FlutterDesktopMessageResponseHandle *handle, const uint8_t *data, size_t data_length)
void SetRootIsolateCreateCallback(const fml::closure &callback)
void UpdateSemanticsEnabled(bool enabled)
TaskRunner * task_runner()
std::string GetExecutableName() const
virtual void OnChannelUpdate(std::string name, bool listening)
virtual std::unique_ptr< KeyboardHandlerBase > CreateKeyboardKeyHandler(BinaryMessenger *messenger, KeyboardKeyEmbedderHandler::GetKeyStateHandler get_key_state, KeyboardKeyEmbedderHandler::MapVirtualKeyToScanCode map_vk_to_scan)
egl::Manager * egl_manager() const
bool MarkExternalTextureFrameAvailable(int64_t texture_id)
bool high_contrast_enabled() const
virtual bool running() const
WindowProcDelegateManager * window_proc_delegate_manager()
std::unique_ptr< FlutterWindowsView > CreateView(std::unique_ptr< WindowBindingHandler > window)
bool semantics_enabled() const
virtual bool PostRasterThreadTask(fml::closure callback) const
FlutterWindowsTextureRegistrar * texture_registrar()
bool UnregisterExternalTexture(int64_t texture_id)
void SetNextFrameCallback(fml::closure callback)
void HandlePlatformMessage(const FlutterPlatformMessage *)
virtual void RemoveView(FlutterViewId view_id)
FlutterDesktopPluginRegistrarRef GetRegistrar()
virtual std::unique_ptr< TextInputPlugin > CreateTextInputPlugin(BinaryMessenger *messenger)
void OnVsync(intptr_t baton)
TextInputPlugin * text_input_plugin()
WindowsLifecycleManager * lifecycle_manager()
void SendPointerEvent(const FlutterPointerEvent &event)
BinaryMessenger * messenger_wrapper()
void SendWindowMetricsEvent(const FlutterWindowMetricsEvent &event)
KeyboardHandlerBase * keyboard_key_handler()
void SetSwitches(const std::vector< std::string > &switches)
void SendKeyEvent(const FlutterKeyEvent &event, FlutterKeyEventCallback callback, void *user_data)
void OnQuit(std::optional< HWND > hwnd, std::optional< WPARAM > wparam, std::optional< LPARAM > lparam, UINT exit_code)
virtual ~FlutterWindowsEngine()
std::function< SHORT(UINT, bool)> MapVirtualKeyToScanCode
std::function< SHORT(int)> GetKeyStateHandler
A Mapping like NonOwnedMapping, but uses Free as its release proc.
struct _FlutterEngine * FLUTTER_API_SYMBOL(FlutterEngine)
FlutterThreadPriority
Valid values for priority of Thread.
@ kBackground
Suitable for threads that shouldn't disrupt high priority work.
@ kDisplay
Suitable for threads which generate data for the display.
@ kNormal
Default priority level.
@ kRaster
Suitable for thread which raster data.
void(* FlutterKeyEventCallback)(bool, void *)
FlKeyEvent uint64_t FlKeyResponderAsyncCallback callback
void(* FlutterDesktopBinaryReply)(const uint8_t *data, size_t data_size, void *user_data)
void(* FlutterDesktopOnPluginRegistrarDestroyed)(FlutterDesktopPluginRegistrarRef)
#define FML_DISALLOW_COPY_AND_ASSIGN(TypeName)
WindowStateEvent
An event representing a change in window state that may update the.
DEF_SWITCHES_START aot vmservice shared library name
constexpr FlutterViewId kImplicitViewId
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot data
static void WindowsPlatformThreadPrioritySetter(FlutterThreadPriority priority)
std::unique_ptr< _FlutterEngineAOTData, FlutterEngineCollectAOTDataFnPtr > UniqueAotDataPtr
std::function< void()> closure
SI auto map(std::index_sequence< I... >, Fn &&fn, const Args &... args) -> skvx::Vec< sizeof...(I), decltype(fn(args[0]...))>
Function-pointer-based versions of the APIs above.