blob: fe65459f4deb4fb46c260eb562a497b79ca6a30d [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 bool attach(SkBackEndTypes attachType, int msaaSampleCount, AttachmentInfo*);
robertphillips@google.comb442a6d2012-04-02 19:24:21 +000041 void detach();
42 void present();
reed@android.comf2b98d62010-12-20 18:26:13 +000043
reed@android.come191b162009-12-18 21:33:39 +000044 bool wndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
45 static bool QuitOnDeactivate(HWND hWnd);
reed@android.com8a1c16f2008-12-17 15:59:43 +000046
47 enum {
48 SK_WM_SkEvent = WM_APP + 1000,
49 SK_WM_SkTimerID = 0xFFFF // just need a non-zero value
50 };
51
52protected:
53 virtual bool quitOnDeactivate() { return true; }
54
55 // overrides from SkWindow
56 virtual void onHandleInval(const SkIRect&);
57 // overrides from SkView
58 virtual void onAddMenu(const SkOSMenu*);
59
reed@android.comf2b98d62010-12-20 18:26:13 +000060 virtual void onSetTitle(const char title[]);
61
reed@android.com8a1c16f2008-12-17 15:59:43 +000062private:
reed@android.comf2b98d62010-12-20 18:26:13 +000063 void* fHWND;
rmistry@google.comfbfcd562012-08-23 18:09:54 +000064
reed@android.comf2b98d62010-12-20 18:26:13 +000065 void doPaint(void* ctx);
reed@android.com8a1c16f2008-12-17 15:59:43 +000066
bsalomon@google.comcf8fb1f2012-08-02 14:03:32 +000067#if SK_SUPPORT_GPU
reed@android.comf2b98d62010-12-20 18:26:13 +000068 void* fHGLRC;
robertphillips@google.comd3b9fbb2012-03-28 16:19:11 +000069#if SK_ANGLE
robertphillips@google.comd5c8fe62012-04-02 15:04:16 +000070 EGLDisplay fDisplay;
71 EGLContext fContext;
72 EGLSurface fSurface;
bsalomon@google.com64cc8102013-03-05 20:06:05 +000073 EGLConfig fConfig;
bsalomon@google.comcf8fb1f2012-08-02 14:03:32 +000074#endif // SK_ANGLE
75#endif // SK_SUPPORT_GPU
reed@android.com8a1c16f2008-12-17 15:59:43 +000076
reed@android.comf2b98d62010-12-20 18:26:13 +000077 HMENU fMBar;
78
robertphillips@google.comb442a6d2012-04-02 19:24:21 +000079 SkBackEndTypes fAttached;
80
bsalomon@google.comcf8fb1f2012-08-02 14:03:32 +000081#if SK_SUPPORT_GPU
bsalomon@google.com64cc8102013-03-05 20:06:05 +000082 bool attachGL(int msaaSampleCount, AttachmentInfo* info);
robertphillips@google.comb442a6d2012-04-02 19:24:21 +000083 void detachGL();
84 void presentGL();
85
86#if SK_ANGLE
bsalomon@google.com64cc8102013-03-05 20:06:05 +000087 bool attachANGLE(int msaaSampleCount, AttachmentInfo* info);
bsalomon@google.com3c4d0322012-04-03 18:04:51 +000088 void detachANGLE();
robertphillips@google.comb442a6d2012-04-02 19:24:21 +000089 void presentANGLE();
bsalomon@google.comcf8fb1f2012-08-02 14:03:32 +000090#endif // SK_ANGLE
91#endif // SK_SUPPORT_GPU
robertphillips@google.comb442a6d2012-04-02 19:24:21 +000092
rmistry@google.comfbfcd562012-08-23 18:09:54 +000093 typedef SkWindow INHERITED;
reed@android.com8a1c16f2008-12-17 15:59:43 +000094};
95
96#endif