blob: 6b5977ce3f17e76d25b180d7e9841d37f96732b9 [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,
bsalomon@google.comcf8fb1f2012-08-02 14:03:32 +000032#if SK_SUPPORT_GPU
robertphillips@google.comb442a6d2012-04-02 19:24:21 +000033 kNativeGL_BackEndType,
robertphillips@google.comd3b9fbb2012-03-28 16:19:11 +000034#if SK_ANGLE
robertphillips@google.comb442a6d2012-04-02 19:24:21 +000035 kANGLE_BackEndType,
bsalomon@google.comcf8fb1f2012-08-02 14:03:32 +000036#endif // SK_ANGLE
37#endif // SK_SUPPORT_GPU
robertphillips@google.comb442a6d2012-04-02 19:24:21 +000038 };
robertphillips@google.comd3b9fbb2012-03-28 16:19:11 +000039
bsalomon@google.com64cc8102013-03-05 20:06:05 +000040 struct AttachmentInfo {
41 int fSampleCount;
42 int fStencilBits;
43 };
44
45 bool attach(SkBackEndTypes attachType, int msaaSampleCount, AttachmentInfo*);
robertphillips@google.comb442a6d2012-04-02 19:24:21 +000046 void detach();
47 void present();
reed@android.comf2b98d62010-12-20 18:26:13 +000048
reed@android.come191b162009-12-18 21:33:39 +000049 bool wndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
50 static bool QuitOnDeactivate(HWND hWnd);
reed@android.com8a1c16f2008-12-17 15:59:43 +000051
52 enum {
53 SK_WM_SkEvent = WM_APP + 1000,
54 SK_WM_SkTimerID = 0xFFFF // just need a non-zero value
55 };
56
57protected:
58 virtual bool quitOnDeactivate() { return true; }
59
60 // overrides from SkWindow
61 virtual void onHandleInval(const SkIRect&);
62 // overrides from SkView
63 virtual void onAddMenu(const SkOSMenu*);
64
reed@android.comf2b98d62010-12-20 18:26:13 +000065 virtual void onSetTitle(const char title[]);
66
reed@android.com8a1c16f2008-12-17 15:59:43 +000067private:
reed@android.comf2b98d62010-12-20 18:26:13 +000068 void* fHWND;
rmistry@google.comfbfcd562012-08-23 18:09:54 +000069
reed@android.comf2b98d62010-12-20 18:26:13 +000070 void doPaint(void* ctx);
reed@android.com8a1c16f2008-12-17 15:59:43 +000071
bsalomon@google.comcf8fb1f2012-08-02 14:03:32 +000072#if SK_SUPPORT_GPU
reed@android.comf2b98d62010-12-20 18:26:13 +000073 void* fHGLRC;
robertphillips@google.comd3b9fbb2012-03-28 16:19:11 +000074#if SK_ANGLE
robertphillips@google.comd5c8fe62012-04-02 15:04:16 +000075 EGLDisplay fDisplay;
76 EGLContext fContext;
77 EGLSurface fSurface;
bsalomon@google.com64cc8102013-03-05 20:06:05 +000078 EGLConfig fConfig;
bsalomon@google.comcf8fb1f2012-08-02 14:03:32 +000079#endif // SK_ANGLE
80#endif // SK_SUPPORT_GPU
reed@android.com8a1c16f2008-12-17 15:59:43 +000081
reed@android.comf2b98d62010-12-20 18:26:13 +000082 HMENU fMBar;
83
robertphillips@google.comb442a6d2012-04-02 19:24:21 +000084 SkBackEndTypes fAttached;
85
bsalomon@google.comcf8fb1f2012-08-02 14:03:32 +000086#if SK_SUPPORT_GPU
bsalomon@google.com64cc8102013-03-05 20:06:05 +000087 bool attachGL(int msaaSampleCount, AttachmentInfo* info);
robertphillips@google.comb442a6d2012-04-02 19:24:21 +000088 void detachGL();
89 void presentGL();
90
91#if SK_ANGLE
bsalomon@google.com64cc8102013-03-05 20:06:05 +000092 bool attachANGLE(int msaaSampleCount, AttachmentInfo* info);
bsalomon@google.com3c4d0322012-04-03 18:04:51 +000093 void detachANGLE();
robertphillips@google.comb442a6d2012-04-02 19:24:21 +000094 void presentANGLE();
bsalomon@google.comcf8fb1f2012-08-02 14:03:32 +000095#endif // SK_ANGLE
96#endif // SK_SUPPORT_GPU
robertphillips@google.comb442a6d2012-04-02 19:24:21 +000097
rmistry@google.comfbfcd562012-08-23 18:09:54 +000098 typedef SkWindow INHERITED;
reed@android.com8a1c16f2008-12-17 15:59:43 +000099};
100
101#endif