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

Side by Side Diff: tools/viewer/sk_app/unix/main_unix.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
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 "SkTypes.h" 8 #include "SkTypes.h"
9 #include "SkTHash.h" 9 #include "SkTHash.h"
10 #include "Timer.h" 10 #include "Timer.h"
11 #include "Window_unix.h" 11 #include "Window_unix.h"
12 #include "../Application.h" 12 #include "../Application.h"
13 13
14 using sk_app::Application; 14 using sk_app::Application;
15 15
16 static double now_ms() { return SkTime::GetNSecs() * 1e-6; }
17
18 void finishWindow(sk_app::Window_unix* win) { 16 void finishWindow(sk_app::Window_unix* win) {
19 win->finishResize(); 17 win->finishResize();
20 win->finishPaint(); 18 win->finishPaint();
21 } 19 }
22 20
23 int main(int argc, char**argv) { 21 int main(int argc, char**argv) {
24 22
25 Display* display = XOpenDisplay(nullptr); 23 Display* display = XOpenDisplay(nullptr);
26 24
27 Application* app = Application::Create(argc, argv, (void*)display); 25 Application* app = Application::Create(argc, argv, (void*)display);
28 26
29 double currentTime = 0.0;
30 double previousTime = 0.0;
31
32 // Get the file descriptor for the X display 27 // Get the file descriptor for the X display
33 int x11_fd = ConnectionNumber(display); 28 int x11_fd = ConnectionNumber(display);
34 fd_set in_fds; 29 fd_set in_fds;
35 30
36 SkTHashSet<sk_app::Window_unix*> pendingWindows; 31 SkTHashSet<sk_app::Window_unix*> pendingWindows;
37 bool done = false; 32 bool done = false;
38 while (!done) { 33 while (!done) {
39 // Create a file description set containing x11_fd 34 // Create a file description set containing x11_fd
40 FD_ZERO(&in_fds); 35 FD_ZERO(&in_fds);
41 FD_SET(x11_fd, &in_fds); 36 FD_SET(x11_fd, &in_fds);
(...skipping 26 matching lines...) Expand all
68 default: 63 default:
69 if (win->handleEvent(event)) { 64 if (win->handleEvent(event)) {
70 done = true; 65 done = true;
71 } 66 }
72 break; 67 break;
73 } 68 }
74 } 69 }
75 70
76 pendingWindows.foreach(finishWindow); 71 pendingWindows.foreach(finishWindow);
77 if (pendingWindows.count() > 0) { 72 if (pendingWindows.count() > 0) {
78 previousTime = currentTime; 73 app->onIdle();
79 currentTime = now_ms();
80 app->onIdle(currentTime - previousTime);
81 } 74 }
82 pendingWindows.reset(); 75 pendingWindows.reset();
83 } 76 }
84 77
85 delete app; 78 delete app;
86 79
87 XCloseDisplay(display); 80 XCloseDisplay(display);
88 81
89 return 0; 82 return 0;
90 } 83 }
OLDNEW
« no previous file with comments | « tools/viewer/sk_app/android/surface_glue_android.cpp ('k') | tools/viewer/sk_app/win/main_win.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698