• 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 "src/core/SkTDynamicHash.h"
12 #include "tools/sk_app/Window.h"
13 
14 #import <Cocoa/Cocoa.h>
15 
16 namespace sk_app {
17 
18 class Window_mac : public Window {
19 public:
Window_mac()20     Window_mac()
21             : INHERITED()
22             , fWindow(nil) {}
~Window_mac()23     ~Window_mac() override {
24         this->closeWindow();
25     }
26 
27     bool initWindow();
28 
29     void setTitle(const char*) override;
30     void show() override;
31 
32     bool attach(BackendType) override;
33 
onInval()34     void onInval() override {}
35 
36     float scaleFactor() const override;
37 
38     static void PaintWindows();
39 
GetKey(const Window_mac & w)40     static const NSInteger& GetKey(const Window_mac& w) {
41         return w.fWindowNumber;
42     }
43 
Hash(const NSInteger & windowNumber)44     static uint32_t Hash(const NSInteger& windowNumber) {
45         return windowNumber;
46     }
47 
window()48     NSWindow* window() { return fWindow; }
49     void closeWindow();
50 
51 private:
52     NSWindow*    fWindow;
53     NSInteger    fWindowNumber;
54 
55     static SkTDynamicHash<Window_mac, NSInteger> gWindowMap;
56 
57     using INHERITED = Window;
58 };
59 
60 }   // namespace sk_app
61 
62 #endif
63