Flutter Engine
The Flutter Engine
main_win.cpp
Go to the documentation of this file.
1/*
2* Copyright 2016 Google Inc.
3*
4* Use of this source code is governed by a BSD-style license that can be
5* found in the LICENSE file.
6*/
7
8#include <windows.h>
9#include <tchar.h>
10
15#include "tools/timer/Timer.h"
16
18
19static char* tchar_to_utf8(const TCHAR* str) {
20#ifdef _UNICODE
21 int size = WideCharToMultiByte(CP_UTF8, 0, str, wcslen(str), nullptr, 0, nullptr, nullptr);
22 char* str8 = (char*)sk_malloc_throw(size + 1);
23 WideCharToMultiByte(CP_UTF8, 0, str, wcslen(str), str8, size, nullptr, nullptr);
24 str8[size] = '\0';
25 return str8;
26#else
27 return _strdup(str);
28#endif
29}
30
31// This file can work with GUI or CONSOLE subsystem types since we define _tWinMain and main().
32
33static int main_common(HINSTANCE hInstance, int show, int argc, char**argv);
34
35int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine,
36 int nCmdShow) {
37
38 // convert from lpCmdLine to argc, argv.
39 char* argv[4096];
40 int argc = 0;
41 TCHAR exename[1024], *next;
42 int exenameLen = GetModuleFileName(nullptr, exename, std::size(exename));
43 // we're ignoring the possibility that the exe name exceeds the exename buffer
44 (void)exenameLen;
45 argv[argc++] = tchar_to_utf8(exename);
46 TCHAR* arg = _tcstok_s(lpCmdLine, _T(" "), &next);
47 while (arg != nullptr) {
48 argv[argc++] = tchar_to_utf8(arg);
49 arg = _tcstok_s(nullptr, _T(" "), &next);
50 }
51 int result = main_common(hInstance, nCmdShow, argc, argv);
52 for (int i = 0; i < argc; ++i) {
53 sk_free(argv[i]);
54 }
55 return result;
56}
57
58int main(int argc, char**argv) {
59 return main_common(GetModuleHandle(nullptr), SW_SHOW, argc, argv);
60}
61
62static int main_common(HINSTANCE hInstance, int show, int argc, char**argv) {
63
64 Application* app = Application::Create(argc, argv, (void*)hInstance);
65
66 MSG msg;
67 memset(&msg, 0, sizeof(msg));
68
69 bool idled = false;
70
71 // Main message loop
72 while (WM_QUIT != msg.message) {
73 if (PeekMessage(&msg, nullptr, 0, 0, PM_REMOVE)) {
74 TranslateMessage(&msg);
75
76 if (WM_PAINT == msg.message) {
77 // Ensure that call onIdle at least once per WM_PAINT, or mouse events can
78 // overwhelm the message processing loop, and prevent animation from running.
79 if (!idled) {
80 app->onIdle();
81 }
82 idled = false;
83 }
84 DispatchMessage(&msg);
85 } else {
86 app->onIdle();
87 idled = true;
88 }
89 }
90
91 delete app;
92
93 return (int)msg.wParam;
94}
static float next(float f)
static sk_sp< Effect > Create()
Definition: RefCntTest.cpp:117
SK_API void sk_free(void *)
static void * sk_malloc_throw(size_t size)
Definition: SkMalloc.h:67
GAsyncResult * result
static FlMethodResponse * show(FlTextInputPlugin *self)
char ** argv
Definition: library.h:9
static char * tchar_to_utf8(const TCHAR *str)
Definition: main_win.cpp:19
int main(int argc, char **argv)
Definition: main_win.cpp:58
static int main_common(HINSTANCE hInstance, int show, int argc, char **argv)
Definition: main_win.cpp:62
int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow)
Definition: main_win.cpp:35
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
Definition: switches.h:259
struct tagMSG MSG
#define DispatchMessage