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

Side by Side Diff: tools/viewer/sk_app/win/main_win.cpp

Issue 2129613002: More accurate render time and continuous fresh (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Remove ms argument of onIdle function Created 4 years, 5 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/viewer/sk_app/unix/main_unix.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
1 /* 1 /*
2 * Copyright 2016 Google Inc. 2 * Copyright 2016 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include <windows.h> 8 #include <windows.h>
9 #include <tchar.h> 9 #include <tchar.h>
10 10
11 #include "SkTypes.h" 11 #include "SkTypes.h"
12 #include "Timer.h" 12 #include "Timer.h"
13 #include "Window_win.h" 13 #include "Window_win.h"
14 #include "../Application.h" 14 #include "../Application.h"
15 15
16 using sk_app::Application; 16 using sk_app::Application;
17 17
18 static char* tchar_to_utf8(const TCHAR* str) { 18 static char* tchar_to_utf8(const TCHAR* str) {
19 #ifdef _UNICODE 19 #ifdef _UNICODE
20 int size = WideCharToMultiByte(CP_UTF8, 0, str, wcslen(str), NULL, 0, NULL, NULL); 20 int size = WideCharToMultiByte(CP_UTF8, 0, str, wcslen(str), NULL, 0, NULL, NULL);
21 char* str8 = (char*)sk_malloc_throw(size + 1); 21 char* str8 = (char*)sk_malloc_throw(size + 1);
22 WideCharToMultiByte(CP_UTF8, 0, str, wcslen(str), str8, size, NULL, NULL); 22 WideCharToMultiByte(CP_UTF8, 0, str, wcslen(str), str8, size, NULL, NULL);
23 str8[size] = '\0'; 23 str8[size] = '\0';
24 return str8; 24 return str8;
25 #else 25 #else
26 return _strdup(str); 26 return _strdup(str);
27 #endif 27 #endif
28 } 28 }
29 29
30 static double now_ms() { return SkTime::GetNSecs() * 1e-6; }
31
32 // This file can work with GUI or CONSOLE subsystem types since we define _tWinM ain and main(). 30 // This file can work with GUI or CONSOLE subsystem types since we define _tWinM ain and main().
33 31
34 static int main_common(HINSTANCE hInstance, int show, int argc, char**argv); 32 static int main_common(HINSTANCE hInstance, int show, int argc, char**argv);
35 33
36 int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCm dLine, 34 int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCm dLine,
37 int nCmdShow) { 35 int nCmdShow) {
38 36
39 // convert from lpCmdLine to argc, argv. 37 // convert from lpCmdLine to argc, argv.
40 char* argv[4096]; 38 char* argv[4096];
41 int argc = 0; 39 int argc = 0;
(...skipping 17 matching lines...) Expand all
59 int main(int argc, char**argv) { 57 int main(int argc, char**argv) {
60 return main_common(GetModuleHandle(NULL), SW_SHOW, argc, argv); 58 return main_common(GetModuleHandle(NULL), SW_SHOW, argc, argv);
61 } 59 }
62 60
63 static int main_common(HINSTANCE hInstance, int show, int argc, char**argv) { 61 static int main_common(HINSTANCE hInstance, int show, int argc, char**argv) {
64 62
65 Application* app = Application::Create(argc, argv, (void*)hInstance); 63 Application* app = Application::Create(argc, argv, (void*)hInstance);
66 64
67 MSG msg = { 0 }; 65 MSG msg = { 0 };
68 66
69 double currentTime = 0.0;
70 double previousTime = 0.0;
71
72 // Main message loop 67 // Main message loop
73 while (WM_QUIT != msg.message) { 68 while (WM_QUIT != msg.message) {
74 if (PeekMessage(&msg, nullptr, 0, 0, PM_REMOVE)) { 69 if (PeekMessage(&msg, nullptr, 0, 0, PM_REMOVE)) {
75 TranslateMessage(&msg); 70 TranslateMessage(&msg);
76 DispatchMessage(&msg); 71 DispatchMessage(&msg);
77 } else { 72 } else {
78 previousTime = currentTime; 73 app->onIdle();
79 currentTime = now_ms();
80 app->onIdle(currentTime - previousTime);
81 } 74 }
82 } 75 }
83 76
84 delete app; 77 delete app;
85 78
86 return (int)msg.wParam; 79 return (int)msg.wParam;
87 } 80 }
OLDNEW
« no previous file with comments | « tools/viewer/sk_app/unix/main_unix.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698