aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools/sk_app/mac/Window_mac.h
blob: aa5c8df69628e0ccb8407402e62e2ba7353871b6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/*
* Copyright 2016 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/

#ifndef Window_mac_DEFINED
#define Window_mac_DEFINED

#include "../Window.h"
#include "SkChecksum.h"
#include "SkTDynamicHash.h"

#include "SDL.h"

namespace sk_app {

class Window_mac : public Window {
public:
    Window_mac()
        : INHERITED()
        , fWindow(nullptr)
        , fWindowID(0)
        , fMSAASampleCount(0) {}
    ~Window_mac() override { this->closeWindow(); }

    bool initWindow();

    void setTitle(const char*) override;
    void show() override;

    bool attach(BackendType) override;

    void onInval() override;

    static bool HandleWindowEvent(const SDL_Event& event);

    static const Uint32& GetKey(const Window_mac& w) {
        return w.fWindowID;
    }

    static uint32_t Hash(const Uint32& winID) {
        return winID;
    }

private:
    bool handleEvent(const SDL_Event& event);

    void closeWindow();

    static SkTDynamicHash<Window_mac, Uint32> gWindowMap;

    SDL_Window*  fWindow;
    Uint32       fWindowID;

    int          fMSAASampleCount;

    typedef Window INHERITED;
};

}   // namespace sk_app

#endif