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