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
|
|
|
|
|
|
|
|
#include "SkWindow.h"
|
2015-07-01 20:35:59 +00:00
|
|
|
#include "../../src/core/SkFunction.h"
|
|
|
|
#include "../../src/core/SkTHash.h"
|
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
|
|
|
|
2013-03-05 20:06:05 +00:00
|
|
|
bool attach(SkBackEndTypes attachType, int msaaSampleCount, AttachmentInfo*);
|
2012-04-02 19:24:21 +00:00
|
|
|
void detach();
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Iterates SkFunction over all the SkOSWindows and their corresponding HWNDs.
|
|
|
|
// The void* argument to the SkFunction is a HWND.
|
|
|
|
static void ForAllWindows(const SkFunction<void(void*, SkOSWindow**)>& f) {
|
|
|
|
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
|
2012-04-02 15:04:16 +00:00
|
|
|
EGLDisplay fDisplay;
|
|
|
|
EGLContext fContext;
|
|
|
|
EGLSurface fSurface;
|
2013-03-05 20:06:05 +00:00
|
|
|
EGLConfig fConfig;
|
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
|
2013-03-05 20:06:05 +00:00
|
|
|
bool attachGL(int msaaSampleCount, 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
|
|
|
|
#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
|