Window_ios.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. #ifndef Window_ios_DEFINED
  8. #define Window_ios_DEFINED
  9. #include "include/private/SkChecksum.h"
  10. #include "src/core/SkTDynamicHash.h"
  11. #include "tools/sk_app/Window.h"
  12. #include "SDL.h"
  13. namespace sk_app {
  14. class Window_ios : public Window {
  15. public:
  16. Window_ios()
  17. : INHERITED()
  18. , fWindow(nullptr)
  19. , fWindowID(0)
  20. , fGLContext(nullptr)
  21. , fMSAASampleCount(1) {}
  22. ~Window_ios() override { this->closeWindow(); }
  23. bool initWindow();
  24. void setTitle(const char*) override;
  25. void show() override;
  26. bool attach(BackendType) override;
  27. void onInval() override;
  28. static bool HandleWindowEvent(const SDL_Event& event);
  29. static const Uint32& GetKey(const Window_ios& w) {
  30. return w.fWindowID;
  31. }
  32. static uint32_t Hash(const Uint32& winID) {
  33. return winID;
  34. }
  35. private:
  36. bool handleEvent(const SDL_Event& event);
  37. void closeWindow();
  38. static SkTDynamicHash<Window_ios, Uint32> gWindowMap;
  39. SDL_Window* fWindow;
  40. Uint32 fWindowID;
  41. SDL_GLContext fGLContext;
  42. int fMSAASampleCount;
  43. typedef Window INHERITED;
  44. };
  45. } // namespace sk_app
  46. #endif