1 /* 2 * Copyright 2006 The Android Open Source Project 3 * 4 * Use of this source code is governed by a BSD-style license that can be 5 * found in the LICENSE file. 6 */ 7 8 #ifndef SkOSWindow_Unix_DEFINED 9 #define SkOSWindow_Unix_DEFINED 10 11 #include <GL/glx.h> 12 #include <X11/Xlib.h> 13 14 #include "SkWindow.h" 15 16 class SkEvent; 17 18 struct SkUnixWindow { 19 Display* fDisplay; 20 Window fWin; 21 size_t fOSWin; 22 GC fGc; 23 GLXContext fGLContext; 24 }; 25 26 class SkOSWindow : public SkWindow { 27 public: 28 SkOSWindow(void*); 29 ~SkOSWindow(); 30 getHWND()31 void* getHWND() const { return (void*)fUnixWindow.fWin; } getDisplay()32 void* getDisplay() const { return (void*)fUnixWindow.fDisplay; } getUnixWindow()33 void* getUnixWindow() const { return (void*)&fUnixWindow; } 34 void loop(); 35 36 enum SkBackEndTypes { 37 kNone_BackEndType, 38 kNativeGL_BackEndType, 39 }; 40 41 bool attach(SkBackEndTypes attachType, int msaaSampleCount, AttachmentInfo*); 42 void detach(); 43 void present(); 44 getMSAASampleCount()45 int getMSAASampleCount() const { return fMSAASampleCount; } 46 47 //static bool PostEvent(SkEvent* evt, SkEventSinkID, SkMSec delay); 48 49 protected: 50 // Overridden from from SkWindow: 51 void onSetTitle(const char title[]) override; 52 53 private: 54 enum NextXEventResult { 55 kContinue_NextXEventResult, 56 kQuitRequest_NextXEventResult, 57 kPaintRequest_NextXEventResult 58 }; 59 60 NextXEventResult nextXEvent(); 61 void doPaint(); 62 void mapWindowAndWait(); 63 64 void closeWindow(); 65 void initWindow(int newMSAASampleCount, AttachmentInfo* info); 66 67 SkUnixWindow fUnixWindow; 68 69 // Needed for GL 70 XVisualInfo* fVi; 71 // we recreate the underlying xwindow if this changes 72 int fMSAASampleCount; 73 74 typedef SkWindow INHERITED; 75 }; 76 77 #endif 78