SkOSWindow_Win.h revision bd8d7adb0ac9533a04e7b7a481371d4c66bbbc9b
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 19class SkOSWindow : public SkWindow { 20public: 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 bool attachGL(); 31 void detachGL(); 32 void presentGL(); 33 34#if SK_ANGLE 35 bool attachANGLE(); 36 void detachANGLE(); 37 void presentANGLE(); 38#endif 39 40 bool attachD3D9(); 41 void detachD3D9(); 42 void presentD3D9(); 43 44 void* d3d9Device() { return fD3D9Device; } 45 46 bool wndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); 47 static bool QuitOnDeactivate(HWND hWnd); 48 49 enum { 50 SK_WM_SkEvent = WM_APP + 1000, 51 SK_WM_SkTimerID = 0xFFFF // just need a non-zero value 52 }; 53 54protected: 55 virtual bool quitOnDeactivate() { return true; } 56 57 // overrides from SkWindow 58 virtual void onHandleInval(const SkIRect&); 59 // overrides from SkView 60 virtual void onAddMenu(const SkOSMenu*); 61 62 virtual void onSetTitle(const char title[]); 63 64private: 65 void* fHWND; 66 67 void doPaint(void* ctx); 68 69 void* fHGLRC; 70#if SK_ANGLE 71 angle::EGLDisplay fDisplay; 72 angle::EGLContext fContext; 73 angle::EGLSurface fSurface; 74#endif 75 76 bool fGLAttached; 77 78 void* fD3D9Device; 79 bool fD3D9Attached; 80 81 HMENU fMBar; 82 83 typedef SkWindow INHERITED; 84}; 85 86#endif 87