1 2 /* 3 * Copyright 2006 The Android Open Source Project 4 * 5 * Use of this source code is governed by a BSD-style license that can be 6 * found in the LICENSE file. 7 */ 8 9 10 #ifndef SkOSWindow_Win_DEFINED 11 #define SkOSWindow_Win_DEFINED 12 13 #include "SkWindow.h" 14 15 #if SK_ANGLE 16 #include "EGL/egl.h" 17 #endif 18 19 class SkOSWindow : public SkWindow { 20 public: 21 SkOSWindow(void* hwnd); 22 virtual ~SkOSWindow(); 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); 29 30 enum SkBackEndTypes { 31 kNone_BackEndType, 32 #if SK_SUPPORT_GPU 33 kNativeGL_BackEndType, 34 #if SK_ANGLE 35 kANGLE_BackEndType, 36 #endif // SK_ANGLE 37 #endif // SK_SUPPORT_GPU 38 }; 39 40 struct AttachmentInfo { 41 int fSampleCount; 42 int fStencilBits; 43 }; 44 45 bool attach(SkBackEndTypes attachType, int msaaSampleCount, AttachmentInfo*); 46 void detach(); 47 void present(); 48 49 bool wndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); 50 static bool QuitOnDeactivate(HWND hWnd); 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 65 virtual void onSetTitle(const char title[]); 66 67 private: 68 void* fHWND; 69 70 void doPaint(void* ctx); 71 72 #if SK_SUPPORT_GPU 73 void* fHGLRC; 74 #if SK_ANGLE 75 EGLDisplay fDisplay; 76 EGLContext fContext; 77 EGLSurface fSurface; 78 EGLConfig fConfig; 79 #endif // SK_ANGLE 80 #endif // SK_SUPPORT_GPU 81 82 HMENU fMBar; 83 84 SkBackEndTypes fAttached; 85 86 #if SK_SUPPORT_GPU 87 bool attachGL(int msaaSampleCount, AttachmentInfo* info); 88 void detachGL(); 89 void presentGL(); 90 91 #if SK_ANGLE 92 bool attachANGLE(int msaaSampleCount, AttachmentInfo* info); 93 void detachANGLE(); 94 void presentANGLE(); 95 #endif // SK_ANGLE 96 #endif // SK_SUPPORT_GPU 97 98 typedef SkWindow INHERITED; 99 }; 100 101 #endif 102