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: #ifndef SkOSWindow_Unix_DEFINED michael@0: #define SkOSWindow_Unix_DEFINED michael@0: michael@0: #include michael@0: #include michael@0: michael@0: #include "SkWindow.h" michael@0: michael@0: class SkEvent; michael@0: michael@0: struct SkUnixWindow { michael@0: Display* fDisplay; michael@0: Window fWin; michael@0: size_t fOSWin; michael@0: GC fGc; michael@0: GLXContext fGLContext; michael@0: }; michael@0: michael@0: class SkOSWindow : public SkWindow { michael@0: public: michael@0: SkOSWindow(void*); michael@0: ~SkOSWindow(); michael@0: michael@0: void* getHWND() const { return (void*)fUnixWindow.fWin; } michael@0: void* getDisplay() const { return (void*)fUnixWindow.fDisplay; } michael@0: void* getUnixWindow() const { return (void*)&fUnixWindow; } michael@0: void loop(); michael@0: michael@0: enum SkBackEndTypes { michael@0: kNone_BackEndType, michael@0: kNativeGL_BackEndType, 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: int getMSAASampleCount() const { return fMSAASampleCount; } michael@0: michael@0: //static bool PostEvent(SkEvent* evt, SkEventSinkID, SkMSec delay); michael@0: michael@0: protected: michael@0: // Overridden from from SkWindow: michael@0: virtual void onSetTitle(const char title[]) SK_OVERRIDE; michael@0: michael@0: private: michael@0: enum NextXEventResult { michael@0: kContinue_NextXEventResult, michael@0: kQuitRequest_NextXEventResult, michael@0: kPaintRequest_NextXEventResult michael@0: }; michael@0: michael@0: NextXEventResult nextXEvent(); michael@0: void doPaint(); michael@0: void mapWindowAndWait(); michael@0: michael@0: void closeWindow(); michael@0: void initWindow(int newMSAASampleCount, AttachmentInfo* info); michael@0: michael@0: SkUnixWindow fUnixWindow; michael@0: michael@0: // Needed for GL michael@0: XVisualInfo* fVi; michael@0: // we recreate the underlying xwindow if this changes michael@0: int fMSAASampleCount; michael@0: michael@0: typedef SkWindow INHERITED; michael@0: }; michael@0: michael@0: #endif