michael@0: michael@0: /* michael@0: * Copyright 2006 The Android Open Source Project michael@0: * michael@0: * Use of this source code is governed by a BSD-style license that can be michael@0: * found in the LICENSE file. michael@0: */ michael@0: michael@0: michael@0: #ifndef SkOSWindow_Win_DEFINED michael@0: #define SkOSWindow_Win_DEFINED michael@0: michael@0: #include "SkWindow.h" michael@0: michael@0: #if SK_ANGLE michael@0: #include "EGL/egl.h" michael@0: #endif michael@0: michael@0: class SkOSWindow : public SkWindow { michael@0: public: michael@0: SkOSWindow(void* hwnd); michael@0: virtual ~SkOSWindow(); michael@0: michael@0: void* getHWND() const { return fHWND; } michael@0: void setSize(int width, int height); michael@0: void updateSize(); michael@0: michael@0: static bool PostEvent(SkEvent* evt, SkEventSinkID, SkMSec delay); michael@0: michael@0: enum SkBackEndTypes { michael@0: kNone_BackEndType, michael@0: #if SK_SUPPORT_GPU michael@0: kNativeGL_BackEndType, michael@0: #if SK_ANGLE michael@0: kANGLE_BackEndType, michael@0: #endif // SK_ANGLE michael@0: #endif // SK_SUPPORT_GPU michael@0: }; michael@0: michael@0: struct AttachmentInfo { michael@0: int fSampleCount; michael@0: int fStencilBits; michael@0: }; michael@0: michael@0: bool attach(SkBackEndTypes attachType, int msaaSampleCount, AttachmentInfo*); michael@0: void detach(); michael@0: void present(); michael@0: michael@0: bool wndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); michael@0: static bool QuitOnDeactivate(HWND hWnd); michael@0: michael@0: enum { michael@0: SK_WM_SkEvent = WM_APP + 1000, michael@0: SK_WM_SkTimerID = 0xFFFF // just need a non-zero value michael@0: }; michael@0: michael@0: protected: michael@0: virtual bool quitOnDeactivate() { return true; } michael@0: michael@0: // overrides from SkWindow michael@0: virtual void onHandleInval(const SkIRect&); michael@0: // overrides from SkView michael@0: virtual void onAddMenu(const SkOSMenu*); michael@0: michael@0: virtual void onSetTitle(const char title[]); michael@0: michael@0: private: michael@0: void* fHWND; michael@0: michael@0: void doPaint(void* ctx); michael@0: michael@0: #if SK_SUPPORT_GPU michael@0: void* fHGLRC; michael@0: #if SK_ANGLE michael@0: EGLDisplay fDisplay; michael@0: EGLContext fContext; michael@0: EGLSurface fSurface; michael@0: EGLConfig fConfig; michael@0: #endif // SK_ANGLE michael@0: #endif // SK_SUPPORT_GPU michael@0: michael@0: HMENU fMBar; michael@0: michael@0: SkBackEndTypes fAttached; michael@0: michael@0: #if SK_SUPPORT_GPU michael@0: bool attachGL(int msaaSampleCount, AttachmentInfo* info); michael@0: void detachGL(); michael@0: void presentGL(); michael@0: michael@0: #if SK_ANGLE michael@0: bool attachANGLE(int msaaSampleCount, AttachmentInfo* info); michael@0: void detachANGLE(); michael@0: void presentANGLE(); michael@0: #endif // SK_ANGLE michael@0: #endif // SK_SUPPORT_GPU michael@0: michael@0: typedef SkWindow INHERITED; michael@0: }; michael@0: michael@0: #endif