Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
task_runner_window.h
Go to the documentation of this file.
1// Copyright 2013 The Flutter Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef FLUTTER_SHELL_PLATFORM_WINDOWS_TASK_RUNNER_WINDOW_H_
6#define FLUTTER_SHELL_PLATFORM_WINDOWS_TASK_RUNNER_WINDOW_H_
7
8#include <windows.h>
9
10#include <chrono>
11#include <memory>
12#include <string>
13#include <vector>
14
15#include "flutter/fml/macros.h"
16
17namespace flutter {
18
19// Hidden HWND responsible for processing flutter tasks on main thread
21 public:
22 class Delegate {
23 public:
24 // Executes expired task, and returns the duration until the next task
25 // deadline if exists, otherwise returns `std::chrono::nanoseconds::max()`.
26 //
27 // Each platform implementation must call this to schedule the tasks.
28 virtual std::chrono::nanoseconds ProcessTasks() = 0;
29 };
30
31 static std::shared_ptr<TaskRunnerWindow> GetSharedInstance();
32
33 // Triggers processing delegate tasks on main thread
34 void WakeUp();
35
36 void AddDelegate(Delegate* delegate);
37 void RemoveDelegate(Delegate* delegate);
38
40
41 private:
43
44 void ProcessTasks();
45
46 void SetTimer(std::chrono::nanoseconds when);
47
48 WNDCLASS RegisterWindowClass();
49
51 HandleMessage(UINT const message,
52 WPARAM const wparam,
53 LPARAM const lparam) noexcept;
54
55 static LRESULT CALLBACK WndProc(HWND const window,
56 UINT const message,
57 WPARAM const wparam,
58 LPARAM const lparam) noexcept;
59
60 HWND window_handle_;
61 std::wstring window_class_name_;
62 std::vector<Delegate*> delegates_;
63
65};
66} // namespace flutter
67
68#endif // FLUTTER_SHELL_PLATFORM_WINDOWS_TASK_RUNNER_WINDOW_H_
virtual std::chrono::nanoseconds ProcessTasks()=0
static std::shared_ptr< TaskRunnerWindow > GetSharedInstance()
void AddDelegate(Delegate *delegate)
void RemoveDelegate(Delegate *delegate)
GLFWwindow * window
Definition main.cc:45
#define FML_DISALLOW_COPY_AND_ASSIGN(TypeName)
Definition macros.h:27
Win32Message message
LONG_PTR LRESULT
unsigned int UINT
LONG_PTR LPARAM
UINT_PTR WPARAM
#define CALLBACK