Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(135)

Side by Side Diff: tools/vulkan/win/main_win.cpp

Issue 1945103003: Rename VulkanViewer to Viewer, take 2. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix android path Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « tools/vulkan/win/Window_win.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
11 #include "SkTypes.h"
12 #include "Timer.h"
13 #include "Window_win.h"
14 #include "../Application.h"
15
16 static char* tchar_to_utf8(const TCHAR* str) {
17 #ifdef _UNICODE
18 int size = WideCharToMultiByte(CP_UTF8, 0, str, wcslen(str), NULL, 0, NULL, NULL);
19 char* str8 = (char*)sk_malloc_throw(size + 1);
20 WideCharToMultiByte(CP_UTF8, 0, str, wcslen(str), str8, size, NULL, NULL);
21 str8[size] = '\0';
22 return str8;
23 #else
24 return _strdup(str);
25 #endif
26 }
27
28 static double now_ms() { return SkTime::GetNSecs() * 1e-6; }
29
30 // This file can work with GUI or CONSOLE subsystem types since we define _tWinM ain and main().
31
32 static int main_common(HINSTANCE hInstance, int show, int argc, char**argv);
33
34 int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCm dLine,
35 int nCmdShow) {
36
37 // convert from lpCmdLine to argc, argv.
38 char* argv[4096];
39 int argc = 0;
40 TCHAR exename[1024], *next;
41 int exenameLen = GetModuleFileName(NULL, exename, SK_ARRAY_COUNT(exename));
42 // we're ignoring the possibility that the exe name exceeds the exename buff er
43 (void)exenameLen;
44 argv[argc++] = tchar_to_utf8(exename);
45 TCHAR* arg = _tcstok_s(lpCmdLine, _T(" "), &next);
46 while (arg != NULL) {
47 argv[argc++] = tchar_to_utf8(arg);
48 arg = _tcstok_s(NULL, _T(" "), &next);
49 }
50 int result = main_common(hInstance, nCmdShow, argc, argv);
51 for (int i = 0; i < argc; ++i) {
52 sk_free(argv[i]);
53 }
54 return result;
55 }
56
57 int main(int argc, char**argv) {
58 return main_common(GetModuleHandle(NULL), SW_SHOW, argc, argv);
59 }
60
61 static int main_common(HINSTANCE hInstance, int show, int argc, char**argv) {
62
63 Application* app = Application::Create(argc, argv, (void*)hInstance);
64
65 MSG msg = { 0 };
66
67 double currentTime = 0.0;
68 double previousTime = 0.0;
69
70 // Main message loop
71 while (WM_QUIT != msg.message) {
72 if (PeekMessage(&msg, nullptr, 0, 0, PM_REMOVE)) {
73 TranslateMessage(&msg);
74 DispatchMessage(&msg);
75 } else {
76 previousTime = currentTime;
77 currentTime = now_ms();
78 app->onIdle(currentTime - previousTime);
79 }
80 }
81
82 delete app;
83
84 return (int)msg.wParam;
85 }
OLDNEW
« no previous file with comments | « tools/vulkan/win/Window_win.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698