blob: 9c76d5c7e5f85423acf5769a4dc703a8eba8574d [file] [log] [blame]
epoger@google.comec3ed6a2011-07-28 14:26:00 +00001
reed@android.com8a1c16f2008-12-17 15:59:43 +00002/*
epoger@google.comec3ed6a2011-07-28 14:26:00 +00003 * Copyright 2006 The Android Open Source Project
reed@android.com8a1c16f2008-12-17 15:59:43 +00004 *
epoger@google.comec3ed6a2011-07-28 14:26:00 +00005 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
reed@android.com8a1c16f2008-12-17 15:59:43 +00007 */
8
epoger@google.comec3ed6a2011-07-28 14:26:00 +00009
reed@android.com8a1c16f2008-12-17 15:59:43 +000010#ifndef SkOSWindow_Win_DEFINED
11#define SkOSWindow_Win_DEFINED
12
13#include "SkWindow.h"
14
robertphillips@google.comd3b9fbb2012-03-28 16:19:11 +000015#if SK_ANGLE
16#include "EGL/egl.h"
17#endif
18
reed@android.com8a1c16f2008-12-17 15:59:43 +000019class SkOSWindow : public SkWindow {
20public:
21 SkOSWindow(void* hwnd);
reed@android.comf2b98d62010-12-20 18:26:13 +000022 virtual ~SkOSWindow();
reed@android.com8a1c16f2008-12-17 15:59:43 +000023
24 void* getHWND() const { return fHWND; }
25 void setSize(int width, int height);
26 void updateSize();
27
28 static bool PostEvent(SkEvent* evt, SkEventSinkID, SkMSec delay);
reed@android.comf2b98d62010-12-20 18:26:13 +000029
robertphillips@google.comb442a6d2012-04-02 19:24:21 +000030 enum SkBackEndTypes {
31 kNone_BackEndType,
32 kNativeGL_BackEndType,
robertphillips@google.comd3b9fbb2012-03-28 16:19:11 +000033#if SK_ANGLE
robertphillips@google.comb442a6d2012-04-02 19:24:21 +000034 kANGLE_BackEndType,
robertphillips@google.comd3b9fbb2012-03-28 16:19:11 +000035#endif
robertphillips@google.comb442a6d2012-04-02 19:24:21 +000036 };
robertphillips@google.comd3b9fbb2012-03-28 16:19:11 +000037
bsalomon@google.com3c4d0322012-04-03 18:04:51 +000038 bool attach(SkBackEndTypes attachType);
robertphillips@google.comb442a6d2012-04-02 19:24:21 +000039 void detach();
40 void present();
reed@android.comf2b98d62010-12-20 18:26:13 +000041
reed@android.come191b162009-12-18 21:33:39 +000042 bool wndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
43 static bool QuitOnDeactivate(HWND hWnd);
reed@android.com8a1c16f2008-12-17 15:59:43 +000044
45 enum {
46 SK_WM_SkEvent = WM_APP + 1000,
47 SK_WM_SkTimerID = 0xFFFF // just need a non-zero value
48 };
49
50protected:
51 virtual bool quitOnDeactivate() { return true; }
52
53 // overrides from SkWindow
54 virtual void onHandleInval(const SkIRect&);
55 // overrides from SkView
56 virtual void onAddMenu(const SkOSMenu*);
57
reed@android.comf2b98d62010-12-20 18:26:13 +000058 virtual void onSetTitle(const char title[]);
59
reed@android.com8a1c16f2008-12-17 15:59:43 +000060private:
reed@android.comf2b98d62010-12-20 18:26:13 +000061 void* fHWND;
62
63 void doPaint(void* ctx);
reed@android.com8a1c16f2008-12-17 15:59:43 +000064
reed@android.comf2b98d62010-12-20 18:26:13 +000065 void* fHGLRC;
robertphillips@google.comd3b9fbb2012-03-28 16:19:11 +000066#if SK_ANGLE
robertphillips@google.comd5c8fe62012-04-02 15:04:16 +000067 EGLDisplay fDisplay;
68 EGLContext fContext;
69 EGLSurface fSurface;
robertphillips@google.comd3b9fbb2012-03-28 16:19:11 +000070#endif
reed@android.com8a1c16f2008-12-17 15:59:43 +000071
reed@android.comf2b98d62010-12-20 18:26:13 +000072 HMENU fMBar;
73
robertphillips@google.comb442a6d2012-04-02 19:24:21 +000074 SkBackEndTypes fAttached;
75
bsalomon@google.com3c4d0322012-04-03 18:04:51 +000076 bool attachGL();
robertphillips@google.comb442a6d2012-04-02 19:24:21 +000077 void detachGL();
78 void presentGL();
79
80#if SK_ANGLE
81 bool attachANGLE();
bsalomon@google.com3c4d0322012-04-03 18:04:51 +000082 void detachANGLE();
robertphillips@google.comb442a6d2012-04-02 19:24:21 +000083 void presentANGLE();
84#endif
85
reed@android.comf2b98d62010-12-20 18:26:13 +000086 typedef SkWindow INHERITED;
reed@android.com8a1c16f2008-12-17 15:59:43 +000087};
88
89#endif