epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 1 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 2 | /* |
epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 3 | * Copyright 2006 The Android Open Source Project |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 4 | * |
epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 5 | * Use of this source code is governed by a BSD-style license that can be |
| 6 | * found in the LICENSE file. |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 7 | */ |
| 8 | |
epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 9 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 10 | #ifndef SkOSWindow_Win_DEFINED |
| 11 | #define SkOSWindow_Win_DEFINED |
| 12 | |
| 13 | #include "SkWindow.h" |
| 14 | |
robertphillips@google.com | d3b9fbb | 2012-03-28 16:19:11 +0000 | [diff] [blame] | 15 | #if SK_ANGLE |
| 16 | #include "EGL/egl.h" |
| 17 | #endif |
| 18 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 19 | class SkOSWindow : public SkWindow { |
| 20 | public: |
| 21 | SkOSWindow(void* hwnd); |
reed@android.com | f2b98d6 | 2010-12-20 18:26:13 +0000 | [diff] [blame] | 22 | virtual ~SkOSWindow(); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 23 | |
| 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.com | f2b98d6 | 2010-12-20 18:26:13 +0000 | [diff] [blame] | 29 | |
robertphillips@google.com | b442a6d | 2012-04-02 19:24:21 +0000 | [diff] [blame] | 30 | enum SkBackEndTypes { |
| 31 | kNone_BackEndType, |
bsalomon@google.com | cf8fb1f | 2012-08-02 14:03:32 +0000 | [diff] [blame] | 32 | #if SK_SUPPORT_GPU |
robertphillips@google.com | b442a6d | 2012-04-02 19:24:21 +0000 | [diff] [blame] | 33 | kNativeGL_BackEndType, |
robertphillips@google.com | d3b9fbb | 2012-03-28 16:19:11 +0000 | [diff] [blame] | 34 | #if SK_ANGLE |
robertphillips@google.com | b442a6d | 2012-04-02 19:24:21 +0000 | [diff] [blame] | 35 | kANGLE_BackEndType, |
bsalomon@google.com | cf8fb1f | 2012-08-02 14:03:32 +0000 | [diff] [blame] | 36 | #endif // SK_ANGLE |
| 37 | #endif // SK_SUPPORT_GPU |
robertphillips@google.com | b442a6d | 2012-04-02 19:24:21 +0000 | [diff] [blame] | 38 | }; |
robertphillips@google.com | d3b9fbb | 2012-03-28 16:19:11 +0000 | [diff] [blame] | 39 | |
bsalomon@google.com | 64cc810 | 2013-03-05 20:06:05 +0000 | [diff] [blame] | 40 | struct AttachmentInfo { |
| 41 | int fSampleCount; |
| 42 | int fStencilBits; |
| 43 | }; |
| 44 | |
| 45 | bool attach(SkBackEndTypes attachType, int msaaSampleCount, AttachmentInfo*); |
robertphillips@google.com | b442a6d | 2012-04-02 19:24:21 +0000 | [diff] [blame] | 46 | void detach(); |
| 47 | void present(); |
reed@android.com | f2b98d6 | 2010-12-20 18:26:13 +0000 | [diff] [blame] | 48 | |
reed@android.com | e191b16 | 2009-12-18 21:33:39 +0000 | [diff] [blame] | 49 | bool wndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); |
| 50 | static bool QuitOnDeactivate(HWND hWnd); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 51 | |
| 52 | enum { |
| 53 | SK_WM_SkEvent = WM_APP + 1000, |
| 54 | SK_WM_SkTimerID = 0xFFFF // just need a non-zero value |
| 55 | }; |
| 56 | |
| 57 | protected: |
| 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.com | f2b98d6 | 2010-12-20 18:26:13 +0000 | [diff] [blame] | 65 | virtual void onSetTitle(const char title[]); |
| 66 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 67 | private: |
reed@android.com | f2b98d6 | 2010-12-20 18:26:13 +0000 | [diff] [blame] | 68 | void* fHWND; |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 69 | |
reed@android.com | f2b98d6 | 2010-12-20 18:26:13 +0000 | [diff] [blame] | 70 | void doPaint(void* ctx); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 71 | |
bsalomon@google.com | cf8fb1f | 2012-08-02 14:03:32 +0000 | [diff] [blame] | 72 | #if SK_SUPPORT_GPU |
reed@android.com | f2b98d6 | 2010-12-20 18:26:13 +0000 | [diff] [blame] | 73 | void* fHGLRC; |
robertphillips@google.com | d3b9fbb | 2012-03-28 16:19:11 +0000 | [diff] [blame] | 74 | #if SK_ANGLE |
robertphillips@google.com | d5c8fe6 | 2012-04-02 15:04:16 +0000 | [diff] [blame] | 75 | EGLDisplay fDisplay; |
| 76 | EGLContext fContext; |
| 77 | EGLSurface fSurface; |
bsalomon@google.com | 64cc810 | 2013-03-05 20:06:05 +0000 | [diff] [blame] | 78 | EGLConfig fConfig; |
bsalomon@google.com | cf8fb1f | 2012-08-02 14:03:32 +0000 | [diff] [blame] | 79 | #endif // SK_ANGLE |
| 80 | #endif // SK_SUPPORT_GPU |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 81 | |
reed@android.com | f2b98d6 | 2010-12-20 18:26:13 +0000 | [diff] [blame] | 82 | HMENU fMBar; |
| 83 | |
robertphillips@google.com | b442a6d | 2012-04-02 19:24:21 +0000 | [diff] [blame] | 84 | SkBackEndTypes fAttached; |
| 85 | |
bsalomon@google.com | cf8fb1f | 2012-08-02 14:03:32 +0000 | [diff] [blame] | 86 | #if SK_SUPPORT_GPU |
bsalomon@google.com | 64cc810 | 2013-03-05 20:06:05 +0000 | [diff] [blame] | 87 | bool attachGL(int msaaSampleCount, AttachmentInfo* info); |
robertphillips@google.com | b442a6d | 2012-04-02 19:24:21 +0000 | [diff] [blame] | 88 | void detachGL(); |
| 89 | void presentGL(); |
| 90 | |
| 91 | #if SK_ANGLE |
bsalomon@google.com | 64cc810 | 2013-03-05 20:06:05 +0000 | [diff] [blame] | 92 | bool attachANGLE(int msaaSampleCount, AttachmentInfo* info); |
bsalomon@google.com | 3c4d032 | 2012-04-03 18:04:51 +0000 | [diff] [blame] | 93 | void detachANGLE(); |
robertphillips@google.com | b442a6d | 2012-04-02 19:24:21 +0000 | [diff] [blame] | 94 | void presentANGLE(); |
bsalomon@google.com | cf8fb1f | 2012-08-02 14:03:32 +0000 | [diff] [blame] | 95 | #endif // SK_ANGLE |
| 96 | #endif // SK_SUPPORT_GPU |
robertphillips@google.com | b442a6d | 2012-04-02 19:24:21 +0000 | [diff] [blame] | 97 | |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 98 | typedef SkWindow INHERITED; |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 99 | }; |
| 100 | |
| 101 | #endif |