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 16class SkEvent; 17 18struct SkUnixWindow { 19 Display* fDisplay; 20 Window fWin; 21 size_t fOSWin; 22 GC fGc; 23 GLXContext fGLContext; 24}; 25 26class SkOSWindow : public SkWindow { 27public: 28 SkOSWindow(void*); 29 ~SkOSWindow(); 30 31 void* getHWND() const { return (void*)fUnixWindow.fWin; } 32 void* getDisplay() const { return (void*)fUnixWindow.fDisplay; } 33 void* getUnixWindow() const { return (void*)&fUnixWindow; } 34 void loop(); 35 36 enum SkBackEndTypes { 37 kNone_BackEndType, 38 kNativeGL_BackEndType, 39#if SK_ANGLE 40 kANGLE_BackEndType, 41#endif // SK_ANGLE 42#if SK_COMMAND_BUFFER 43 kCommandBufferES2_BackEndType, 44#endif // SK_COMMAND_BUFFER 45 }; 46 47 bool attach(SkBackEndTypes attachType, int msaaSampleCount, AttachmentInfo*); 48 void detach(); 49 void present(); 50 51 int getMSAASampleCount() const { return fMSAASampleCount; } 52 53 //static bool PostEvent(SkEvent* evt, SkEventSinkID, SkMSec delay); 54 55 bool makeFullscreen(); 56 void setVsync(bool); 57 void closeWindow(); 58 59protected: 60 // Overridden from from SkWindow: 61 void onSetTitle(const char title[]) override; 62 63private: 64 enum NextXEventResult { 65 kContinue_NextXEventResult, 66 kQuitRequest_NextXEventResult, 67 kPaintRequest_NextXEventResult 68 }; 69 70 NextXEventResult nextXEvent(); 71 void doPaint(); 72 void mapWindowAndWait(); 73 74 // Forcefully closes the window. If a graceful shutdown is desired then call the public 75 // closeWindow method 76 void internalCloseWindow(); 77 void initWindow(int newMSAASampleCount, AttachmentInfo* info); 78 79 SkUnixWindow fUnixWindow; 80 81 // Needed for GL 82 XVisualInfo* fVi; 83 // we recreate the underlying xwindow if this changes 84 int fMSAASampleCount; 85 86 typedef SkWindow INHERITED; 87}; 88 89#endif 90