• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "SkTypes.h"
9 #include "SkTHash.h"
10 #include "SDL.h"
11 #include "Timer.h"
12 #include "Window_mac.h"
13 #include "../Application.h"
14 
15 using sk_app::Application;
16 
main(int argc,char * argv[])17 int main(int argc, char* argv[]) {
18     if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_EVENTS) != 0) {
19         SkDebugf("Could not initialize SDL!\n");
20         return 1;
21     }
22 
23     Application* app = Application::Create(argc, argv, nullptr);
24 
25     SDL_Event event;
26     bool done = false;
27     while (!done) {
28         while (SDL_PollEvent(&event)) {
29             switch (event.type) {
30                 // events handled by the windows
31                 case SDL_WINDOWEVENT:
32                 case SDL_MOUSEMOTION:
33                 case SDL_MOUSEBUTTONDOWN:
34                 case SDL_MOUSEBUTTONUP:
35                 case SDL_MOUSEWHEEL:
36                 case SDL_KEYDOWN:
37                 case SDL_KEYUP:
38                 case SDL_TEXTINPUT:
39                     done = sk_app::Window_mac::HandleWindowEvent(event);
40                     break;
41 
42                 case SDL_QUIT:
43                     done = true;
44                     break;
45 
46                 default:
47                     break;
48             }
49         }
50 
51         app->onIdle();
52     }
53     delete app;
54 
55     SDL_Quit();
56 
57     return 0;
58 }
59