Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 #include "X11/Xlib.h" | 8 #include "X11/Xlib.h" |
| 9 #include "X11/keysym.h" | 9 #include "X11/keysym.h" |
| 10 | 10 |
| 11 #include "SkApplication.h" | 11 #include "SkApplication.h" |
| 12 #include "SkEvent.h" | 12 #include "SkEvent.h" |
| 13 #include "SkWindow.h" | 13 #include "SkWindow.h" |
| 14 #include "SkTypes.h" | 14 #include "SkTypes.h" |
| 15 | 15 |
| 16 #include <signal.h> | 16 #include <signal.h> |
| 17 #include <sys/time.h> | 17 #include <sys/time.h> |
| 18 | 18 |
| 19 SkOSWindow* gWindow; | 19 SkOSWindow* gWindow; |
| 20 | 20 |
| 21 static void catch_alarm(int sig) | 21 static void catch_alarm(int sig) |
| 22 { | 22 { |
| 23 SkEvent::ServiceQueueTimer(); | 23 SkEvent::ServiceQueueTimer(); |
| 24 } | 24 } |
| 25 | 25 |
| 26 int main(int argc, char** argv){ | 26 int main(int argc, char** argv){ |
| 27 signal(SIGALRM, catch_alarm); | 27 signal(SIGALRM, catch_alarm); |
| 28 | 28 |
| 29 // Start normal Skia sequence | |
|
caryclark
2013/06/17 15:08:39
A comment as to why the init() needs to be called
| |
| 30 application_init(); | |
| 31 | |
| 29 gWindow = create_sk_window(NULL, argc, argv); | 32 gWindow = create_sk_window(NULL, argc, argv); |
| 30 | 33 |
| 31 // drain any events that occurred before gWindow was assigned. | 34 // drain any events that occurred before gWindow was assigned. |
| 32 while (SkEvent::ProcessEvent()); | 35 while (SkEvent::ProcessEvent()); |
| 33 | 36 |
| 34 // Start normal Skia sequence | |
| 35 application_init(); | |
| 36 | |
| 37 gWindow->loop(); | 37 gWindow->loop(); |
| 38 | 38 |
| 39 delete gWindow; | 39 delete gWindow; |
| 40 application_term(); | 40 application_term(); |
| 41 return 0; | 41 return 0; |
| 42 } | 42 } |
| 43 | 43 |
| 44 // SkEvent handlers | 44 // SkEvent handlers |
| 45 | 45 |
| 46 void SkEvent::SignalNonEmptyQueue() | 46 void SkEvent::SignalNonEmptyQueue() |
| 47 { | 47 { |
| 48 if (gWindow) { | 48 if (gWindow) { |
| 49 gWindow->post_linuxevent(); | 49 gWindow->post_linuxevent(); |
| 50 } | 50 } |
| 51 } | 51 } |
| 52 | 52 |
| 53 void SkEvent::SignalQueueTimer(SkMSec delay) | 53 void SkEvent::SignalQueueTimer(SkMSec delay) |
| 54 { | 54 { |
| 55 itimerval newTimer; | 55 itimerval newTimer; |
| 56 newTimer.it_interval.tv_sec = 0; | 56 newTimer.it_interval.tv_sec = 0; |
| 57 newTimer.it_interval.tv_usec = 0; | 57 newTimer.it_interval.tv_usec = 0; |
| 58 newTimer.it_value.tv_sec = 0; | 58 newTimer.it_value.tv_sec = 0; |
| 59 newTimer.it_value.tv_usec = delay * 1000; | 59 newTimer.it_value.tv_usec = delay * 1000; |
| 60 | 60 |
| 61 setitimer(ITIMER_REAL, &newTimer, NULL); | 61 setitimer(ITIMER_REAL, &newTimer, NULL); |
| 62 } | 62 } |
| OLD | NEW |