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