2016-07-19 21:17:20 +00:00
|
|
|
/*
|
|
|
|
* 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"
|
|
|
|
|
2016-08-04 19:30:31 +00:00
|
|
|
#include "SDL.h"
|
|
|
|
|
2016-07-19 21:17:20 +00:00
|
|
|
namespace sk_app {
|
|
|
|
|
|
|
|
class Window_mac : public Window {
|
|
|
|
public:
|
2016-08-04 19:30:31 +00:00
|
|
|
Window_mac()
|
|
|
|
: INHERITED()
|
|
|
|
, fWindow(nullptr)
|
|
|
|
, fWindowID(0)
|
|
|
|
, fMSAASampleCount(0) {}
|
2016-07-19 21:17:20 +00:00
|
|
|
~Window_mac() override { this->closeWindow(); }
|
|
|
|
|
2017-02-24 23:04:47 +00:00
|
|
|
bool initWindow();
|
2016-07-19 21:17:20 +00:00
|
|
|
|
|
|
|
void setTitle(const char*) override;
|
|
|
|
void show() override;
|
|
|
|
|
2017-02-24 23:04:47 +00:00
|
|
|
bool attach(BackendType) override;
|
2016-07-19 21:17:20 +00:00
|
|
|
|
|
|
|
void onInval() override;
|
|
|
|
|
2016-08-04 19:30:31 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2016-07-19 21:17:20 +00:00
|
|
|
private:
|
2016-08-04 19:30:31 +00:00
|
|
|
bool handleEvent(const SDL_Event& event);
|
|
|
|
|
2016-07-19 21:17:20 +00:00
|
|
|
void closeWindow();
|
|
|
|
|
2016-08-04 19:30:31 +00:00
|
|
|
static SkTDynamicHash<Window_mac, Uint32> gWindowMap;
|
|
|
|
|
|
|
|
SDL_Window* fWindow;
|
|
|
|
Uint32 fWindowID;
|
2017-10-09 19:45:33 +00:00
|
|
|
|
2016-07-19 21:17:20 +00:00
|
|
|
int fMSAASampleCount;
|
2017-10-09 19:45:33 +00:00
|
|
|
|
2016-08-04 19:30:31 +00:00
|
|
|
typedef Window INHERITED;
|
2016-07-19 21:17:20 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace sk_app
|
|
|
|
|
|
|
|
#endif
|