2011-07-28 14:26:00 +00:00
|
|
|
|
2008-12-17 15:59:43 +00:00
|
|
|
/*
|
2011-07-28 14:26:00 +00:00
|
|
|
* Copyright 2006 The Android Open Source Project
|
2008-12-17 15:59:43 +00:00
|
|
|
*
|
2011-07-28 14:26:00 +00:00
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
2008-12-17 15:59:43 +00:00
|
|
|
*/
|
|
|
|
|
2011-07-28 14:26:00 +00:00
|
|
|
|
2008-12-17 15:59:43 +00:00
|
|
|
#ifndef SkOSWindow_Win_DEFINED
|
|
|
|
#define SkOSWindow_Win_DEFINED
|
|
|
|
|
2015-07-28 16:54:52 +00:00
|
|
|
#include "../private/SkTHash.h"
|
|
|
|
#include "SkWindow.h"
|
2015-11-12 18:41:05 +00:00
|
|
|
#include <functional>
|
2008-12-17 15:59:43 +00:00
|
|
|
|
2012-03-28 16:19:11 +00:00
|
|
|
#if SK_ANGLE
|
|
|
|
#include "EGL/egl.h"
|
|
|
|
#endif
|
|
|
|
|
2008-12-17 15:59:43 +00:00
|
|
|
class SkOSWindow : public SkWindow {
|
|
|
|
public:
|
2015-06-16 14:04:43 +00:00
|
|
|
struct WindowInit {
|
2015-06-16 19:21:00 +00:00
|
|
|
const TCHAR* fClass;
|
|
|
|
HINSTANCE fInstance;
|
2015-06-16 14:04:43 +00:00
|
|
|
};
|
2008-12-17 15:59:43 +00:00
|
|
|
|
2015-06-16 14:04:43 +00:00
|
|
|
SkOSWindow(const void* winInit);
|
|
|
|
virtual ~SkOSWindow();
|
2008-12-17 15:59:43 +00:00
|
|
|
|
|
|
|
static bool PostEvent(SkEvent* evt, SkEventSinkID, SkMSec delay);
|
2010-12-20 18:26:13 +00:00
|
|
|
|
2012-04-02 19:24:21 +00:00
|
|
|
enum SkBackEndTypes {
|
|
|
|
kNone_BackEndType,
|
2012-08-02 14:03:32 +00:00
|
|
|
#if SK_SUPPORT_GPU
|
2012-04-02 19:24:21 +00:00
|
|
|
kNativeGL_BackEndType,
|
2012-03-28 16:19:11 +00:00
|
|
|
#if SK_ANGLE
|
2012-04-02 19:24:21 +00:00
|
|
|
kANGLE_BackEndType,
|
2012-08-02 14:03:32 +00:00
|
|
|
#endif // SK_ANGLE
|
|
|
|
#endif // SK_SUPPORT_GPU
|
2012-04-02 19:24:21 +00:00
|
|
|
};
|
2012-03-28 16:19:11 +00:00
|
|
|
|
2016-05-05 19:24:31 +00:00
|
|
|
bool attach(SkBackEndTypes attachType, int msaaSampleCount, bool deepColor, AttachmentInfo*);
|
2016-03-16 20:53:35 +00:00
|
|
|
void release();
|
2012-04-02 19:24:21 +00:00
|
|
|
void present();
|
2010-12-20 18:26:13 +00:00
|
|
|
|
2009-12-18 21:33:39 +00:00
|
|
|
bool wndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
|
|
|
|
static bool QuitOnDeactivate(HWND hWnd);
|
2008-12-17 15:59:43 +00:00
|
|
|
|
|
|
|
enum {
|
|
|
|
SK_WM_SkEvent = WM_APP + 1000,
|
|
|
|
SK_WM_SkTimerID = 0xFFFF // just need a non-zero value
|
|
|
|
};
|
|
|
|
|
2015-06-16 19:47:25 +00:00
|
|
|
bool makeFullscreen();
|
|
|
|
void setVsync(bool);
|
|
|
|
void closeWindow();
|
2015-06-16 14:04:43 +00:00
|
|
|
|
|
|
|
static SkOSWindow* GetOSWindowForHWND(void* hwnd) {
|
|
|
|
SkOSWindow** win = gHwndToOSWindowMap.find(hwnd);
|
|
|
|
if (!win) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
return *win;
|
|
|
|
}
|
|
|
|
|
2015-11-12 18:41:05 +00:00
|
|
|
// Iterates f over all the SkOSWindows and their corresponding HWNDs.
|
|
|
|
// The void* argument to f is a HWND.
|
|
|
|
static void ForAllWindows(const std::function<void(void*, SkOSWindow**)>& f) {
|
2015-06-16 14:04:43 +00:00
|
|
|
gHwndToOSWindowMap.foreach(f);
|
|
|
|
}
|
|
|
|
|
2008-12-17 15:59:43 +00:00
|
|
|
protected:
|
|
|
|
virtual bool quitOnDeactivate() { return true; }
|
|
|
|
|
|
|
|
// overrides from SkWindow
|
|
|
|
virtual void onHandleInval(const SkIRect&);
|
|
|
|
// overrides from SkView
|
|
|
|
virtual void onAddMenu(const SkOSMenu*);
|
|
|
|
|
2010-12-20 18:26:13 +00:00
|
|
|
virtual void onSetTitle(const char title[]);
|
|
|
|
|
2008-12-17 15:59:43 +00:00
|
|
|
private:
|
2015-06-16 14:04:43 +00:00
|
|
|
static SkTHashMap<void*, SkOSWindow*> gHwndToOSWindowMap;
|
|
|
|
|
|
|
|
WindowInit fWinInit;
|
2010-12-20 18:26:13 +00:00
|
|
|
void* fHWND;
|
2012-08-23 18:09:54 +00:00
|
|
|
|
2010-12-20 18:26:13 +00:00
|
|
|
void doPaint(void* ctx);
|
|
|
|
|
2012-08-02 14:03:32 +00:00
|
|
|
#if SK_SUPPORT_GPU
|
2010-12-20 18:26:13 +00:00
|
|
|
void* fHGLRC;
|
2012-03-28 16:19:11 +00:00
|
|
|
#if SK_ANGLE
|
2016-10-27 16:30:08 +00:00
|
|
|
EGLDisplay fDisplay;
|
|
|
|
EGLContext fContext;
|
|
|
|
EGLSurface fSurface;
|
|
|
|
EGLConfig fConfig;
|
|
|
|
sk_sp<const GrGLInterface> fANGLEInterface;
|
2012-08-02 14:03:32 +00:00
|
|
|
#endif // SK_ANGLE
|
|
|
|
#endif // SK_SUPPORT_GPU
|
2010-12-20 18:26:13 +00:00
|
|
|
|
2015-06-16 14:04:43 +00:00
|
|
|
bool fFullscreen;
|
|
|
|
struct SavedWindowState {
|
|
|
|
bool fZoomed;
|
|
|
|
LONG fStyle;
|
|
|
|
LONG fExStyle;
|
|
|
|
RECT fRect;
|
|
|
|
LONG fScreenWidth;
|
|
|
|
LONG fScreenHeight;
|
|
|
|
LONG fScreenBits;
|
|
|
|
void* fHWND;
|
|
|
|
} fSavedWindowState;
|
|
|
|
|
2010-12-20 18:26:13 +00:00
|
|
|
HMENU fMBar;
|
2008-12-17 15:59:43 +00:00
|
|
|
|
2012-04-02 19:24:21 +00:00
|
|
|
SkBackEndTypes fAttached;
|
|
|
|
|
2015-06-16 14:04:43 +00:00
|
|
|
void updateSize();
|
2012-08-02 14:03:32 +00:00
|
|
|
#if SK_SUPPORT_GPU
|
2016-05-05 19:24:31 +00:00
|
|
|
bool attachGL(int msaaSampleCount, bool deepColor, AttachmentInfo* info);
|
2012-04-02 19:24:21 +00:00
|
|
|
void detachGL();
|
|
|
|
void presentGL();
|
|
|
|
|
|
|
|
#if SK_ANGLE
|
2013-03-05 20:06:05 +00:00
|
|
|
bool attachANGLE(int msaaSampleCount, AttachmentInfo* info);
|
2012-04-03 18:04:51 +00:00
|
|
|
void detachANGLE();
|
2012-04-02 19:24:21 +00:00
|
|
|
void presentANGLE();
|
2012-08-02 14:03:32 +00:00
|
|
|
#endif // SK_ANGLE
|
2015-08-27 17:38:39 +00:00
|
|
|
|
2012-08-02 14:03:32 +00:00
|
|
|
#endif // SK_SUPPORT_GPU
|
2012-04-02 19:24:21 +00:00
|
|
|
|
2012-08-23 18:09:54 +00:00
|
|
|
typedef SkWindow INHERITED;
|
2008-12-17 15:59:43 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|