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 getHWND()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 bool attach(SkBackEndTypes attachType, int msaaSampleCount, AttachmentInfo*); 41 void detach(); 42 void present(); 43 44 bool wndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); 45 static bool QuitOnDeactivate(HWND hWnd); 46 47 enum { 48 SK_WM_SkEvent = WM_APP + 1000, 49 SK_WM_SkTimerID = 0xFFFF // just need a non-zero value 50 }; 51 52 protected: quitOnDeactivate()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 60 virtual void onSetTitle(const char title[]); 61 62 private: 63 void* fHWND; 64 65 void doPaint(void* ctx); 66 67 #if SK_SUPPORT_GPU 68 void* fHGLRC; 69 #if SK_ANGLE 70 EGLDisplay fDisplay; 71 EGLContext fContext; 72 EGLSurface fSurface; 73 EGLConfig fConfig; 74 #endif // SK_ANGLE 75 #endif // SK_SUPPORT_GPU 76 77 HMENU fMBar; 78 79 SkBackEndTypes fAttached; 80 81 #if SK_SUPPORT_GPU 82 bool attachGL(int msaaSampleCount, AttachmentInfo* info); 83 void detachGL(); 84 void presentGL(); 85 86 #if SK_ANGLE 87 bool attachANGLE(int msaaSampleCount, AttachmentInfo* info); 88 void detachANGLE(); 89 void presentANGLE(); 90 #endif // SK_ANGLE 91 #endif // SK_SUPPORT_GPU 92 93 typedef SkWindow INHERITED; 94 }; 95 96 #endif 97