5#include "flutter/shell/platform/windows/task_runner_window.h"
9#include "flutter/fml/logging.h"
13TaskRunnerWindow::TaskRunnerWindow() {
14 WNDCLASS window_class = RegisterWindowClass();
16 CreateWindowEx(0, window_class.lpszClassName,
L"", 0, 0, 0, 0, 0,
17 HWND_MESSAGE,
nullptr, window_class.hInstance,
nullptr);
20 SetWindowLongPtr(window_handle_, GWLP_USERDATA,
25 size_t size = FormatMessageW(
26 FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM |
27 FORMAT_MESSAGE_IGNORE_INSERTS,
28 NULL,
error, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
29 reinterpret_cast<LPWSTR
>(&
message), 0, NULL);
37 DestroyWindow(window_handle_);
38 window_handle_ =
nullptr;
40 UnregisterClass(window_class_name_.c_str(),
nullptr);
44 static std::weak_ptr<TaskRunnerWindow>
instance;
56 FML_LOG(
ERROR) <<
"Failed to post message to main thread.";
61 delegates_.push_back(delegate);
62 SetTimer(std::chrono::nanoseconds::zero());
66 auto i =
std::find(delegates_.begin(), delegates_.end(), delegate);
67 if (
i != delegates_.end()) {
72void TaskRunnerWindow::ProcessTasks() {
74 auto delegates_copy(delegates_);
75 for (
auto delegate : delegates_copy) {
77 if (
std::find(delegates_.begin(), delegates_.end(), delegate) !=
85void TaskRunnerWindow::SetTimer(std::chrono::nanoseconds when) {
87 KillTimer(window_handle_, 0);
89 auto millis = std::chrono::duration_cast<std::chrono::milliseconds>(when);
90 ::SetTimer(window_handle_, 0, millis.count() + 1,
nullptr);
94WNDCLASS TaskRunnerWindow::RegisterWindowClass() {
95 window_class_name_ =
L"FlutterTaskRunnerWindow";
97 WNDCLASS window_class{};
98 window_class.hCursor =
nullptr;
99 window_class.lpszClassName = window_class_name_.c_str();
100 window_class.style = 0;
101 window_class.cbClsExtra = 0;
102 window_class.cbWndExtra = 0;
103 window_class.hInstance = GetModuleHandle(
nullptr);
104 window_class.hIcon =
nullptr;
105 window_class.hbrBackground = 0;
106 window_class.lpszMenuName =
nullptr;
107 window_class.lpfnWndProc = WndProc;
108 RegisterClass(&window_class);
115 LPARAM const lparam)
noexcept {
122 return DefWindowProcW(window_handle_,
message, wparam, lparam);
128 LPARAM const lparam)
noexcept {
129 if (
auto* that =
reinterpret_cast<TaskRunnerWindow*
>(
130 GetWindowLongPtr(
window, GWLP_USERDATA))) {
131 return that->HandleMessage(
message, wparam, lparam);
static float next(float f)
int find(T *array, int N, T item)
static std::shared_ptr< TaskRunnerWindow > GetSharedInstance()
void AddDelegate(Delegate *delegate)
void RemoveDelegate(Delegate *delegate)
const uint8_t uint32_t uint32_t GError ** error
#define FML_LOG(severity)
static float max(float r, float g, float b)
static float min(float r, float g, float b)
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
WINBASEAPI _Check_return_ _Post_equals_last_error_ DWORD WINAPI GetLastError(VOID)