main_ios.cpp 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*
  2. * Copyright 2017 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. #include "include/core/SkTypes.h"
  8. #include "include/private/SkTHash.h"
  9. #include "tools/sk_app/Application.h"
  10. #include "tools/sk_app/ios/Window_ios.h"
  11. #include "tools/timer/Timer.h"
  12. #include "SDL.h"
  13. using sk_app::Application;
  14. int main(int argc, char* argv[]) {
  15. if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_EVENTS) != 0) {
  16. SkDebugf("Could not initialize SDL!\n");
  17. return 1;
  18. }
  19. Application* app = Application::Create(argc, argv, nullptr);
  20. SDL_Event event;
  21. bool done = false;
  22. while (!done) {
  23. while (SDL_PollEvent(&event)) {
  24. switch (event.type) {
  25. // events handled by the windows
  26. case SDL_WINDOWEVENT:
  27. case SDL_FINGERDOWN:
  28. case SDL_FINGERMOTION:
  29. case SDL_FINGERUP:
  30. case SDL_KEYDOWN:
  31. case SDL_KEYUP:
  32. case SDL_TEXTINPUT:
  33. done = sk_app::Window_ios::HandleWindowEvent(event);
  34. break;
  35. case SDL_QUIT:
  36. done = true;
  37. break;
  38. default:
  39. break;
  40. }
  41. }
  42. app->onIdle();
  43. }
  44. delete app;
  45. SDL_Quit();
  46. return 0;
  47. }