michael@0: /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- michael@0: * This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef GFX_GLXLIBRARY_H michael@0: #define GFX_GLXLIBRARY_H michael@0: michael@0: #include "GLContextTypes.h" michael@0: typedef realGLboolean GLboolean; michael@0: michael@0: // stuff from glx.h michael@0: #include "X11/Xlib.h" michael@0: typedef struct __GLXcontextRec *GLXContext; michael@0: typedef XID GLXPixmap; michael@0: typedef XID GLXDrawable; michael@0: /* GLX 1.3 and later */ michael@0: typedef struct __GLXFBConfigRec *GLXFBConfig; michael@0: typedef XID GLXFBConfigID; michael@0: typedef XID GLXContextID; michael@0: typedef XID GLXWindow; michael@0: typedef XID GLXPbuffer; michael@0: // end of stuff from glx.h michael@0: michael@0: struct PRLibrary; michael@0: class gfxASurface; michael@0: michael@0: namespace mozilla { michael@0: namespace gl { michael@0: michael@0: class GLXLibrary michael@0: { michael@0: public: michael@0: GLXLibrary() : mInitialized(false), mTriedInitializing(false), michael@0: mUseTextureFromPixmap(false), mDebug(false), michael@0: mHasRobustness(false), mIsATI(false), mIsNVIDIA(false), michael@0: mClientIsMesa(false), mGLXMajorVersion(0), michael@0: mGLXMinorVersion(0), michael@0: mOGLLibrary(nullptr) {} michael@0: michael@0: void xDestroyContext(Display* display, GLXContext context); michael@0: Bool xMakeCurrent(Display* display, michael@0: GLXDrawable drawable, michael@0: GLXContext context); michael@0: michael@0: GLXContext xGetCurrentContext(); michael@0: static void* xGetProcAddress(const char *procName); michael@0: GLXFBConfig* xChooseFBConfig(Display* display, michael@0: int screen, michael@0: const int *attrib_list, michael@0: int *nelements); michael@0: GLXFBConfig* xGetFBConfigs(Display* display, michael@0: int screen, michael@0: int *nelements); michael@0: GLXContext xCreateNewContext(Display* display, michael@0: GLXFBConfig config, michael@0: int render_type, michael@0: GLXContext share_list, michael@0: Bool direct); michael@0: int xGetFBConfigAttrib(Display *display, michael@0: GLXFBConfig config, michael@0: int attribute, michael@0: int *value); michael@0: void xSwapBuffers(Display *display, GLXDrawable drawable); michael@0: const char * xQueryExtensionsString(Display *display, michael@0: int screen); michael@0: const char * xGetClientString(Display *display, michael@0: int screen); michael@0: const char * xQueryServerString(Display *display, michael@0: int screen, int name); michael@0: GLXPixmap xCreatePixmap(Display *display, michael@0: GLXFBConfig config, michael@0: Pixmap pixmap, michael@0: const int *attrib_list); michael@0: GLXPixmap xCreateGLXPixmapWithConfig(Display *display, michael@0: GLXFBConfig config, michael@0: Pixmap pixmap); michael@0: void xDestroyPixmap(Display *display, GLXPixmap pixmap); michael@0: Bool xQueryVersion(Display *display, michael@0: int *major, michael@0: int *minor); michael@0: void xBindTexImage(Display *display, michael@0: GLXDrawable drawable, michael@0: int buffer, michael@0: const int *attrib_list); michael@0: void xReleaseTexImage(Display *display, michael@0: GLXDrawable drawable, michael@0: int buffer); michael@0: void xWaitGL(); michael@0: void xWaitX(); michael@0: michael@0: GLXContext xCreateContextAttribs(Display* display, michael@0: GLXFBConfig config, michael@0: GLXContext share_list, michael@0: Bool direct, michael@0: const int* attrib_list); michael@0: michael@0: bool EnsureInitialized(); michael@0: michael@0: GLXPixmap CreatePixmap(gfxASurface* aSurface); michael@0: void DestroyPixmap(Display* aDisplay, GLXPixmap aPixmap); michael@0: void BindTexImage(Display* aDisplay, GLXPixmap aPixmap); michael@0: void ReleaseTexImage(Display* aDisplay, GLXPixmap aPixmap); michael@0: void UpdateTexImage(Display* aDisplay, GLXPixmap aPixmap); michael@0: michael@0: bool UseTextureFromPixmap() { return mUseTextureFromPixmap; } michael@0: bool HasRobustness() { return mHasRobustness; } michael@0: bool SupportsTextureFromPixmap(gfxASurface* aSurface); michael@0: bool IsATI() { return mIsATI; } michael@0: bool GLXVersionCheck(int aMajor, int aMinor); michael@0: michael@0: private: michael@0: michael@0: typedef void (GLAPIENTRY * PFNGLXDESTROYCONTEXTPROC) (Display*, michael@0: GLXContext); michael@0: PFNGLXDESTROYCONTEXTPROC xDestroyContextInternal; michael@0: typedef Bool (GLAPIENTRY * PFNGLXMAKECURRENTPROC) (Display*, michael@0: GLXDrawable, michael@0: GLXContext); michael@0: PFNGLXMAKECURRENTPROC xMakeCurrentInternal; michael@0: typedef GLXContext (GLAPIENTRY * PFNGLXGETCURRENTCONTEXT) (); michael@0: PFNGLXGETCURRENTCONTEXT xGetCurrentContextInternal; michael@0: typedef void* (GLAPIENTRY * PFNGLXGETPROCADDRESSPROC) (const char *); michael@0: PFNGLXGETPROCADDRESSPROC xGetProcAddressInternal; michael@0: typedef GLXFBConfig* (GLAPIENTRY * PFNGLXCHOOSEFBCONFIG) (Display *, michael@0: int, michael@0: const int *, michael@0: int *); michael@0: PFNGLXCHOOSEFBCONFIG xChooseFBConfigInternal; michael@0: typedef GLXFBConfig* (GLAPIENTRY * PFNGLXGETFBCONFIGS) (Display *, michael@0: int, michael@0: int *); michael@0: PFNGLXGETFBCONFIGS xGetFBConfigsInternal; michael@0: typedef GLXContext (GLAPIENTRY * PFNGLXCREATENEWCONTEXT) (Display *, michael@0: GLXFBConfig, michael@0: int, michael@0: GLXContext, michael@0: Bool); michael@0: PFNGLXCREATENEWCONTEXT xCreateNewContextInternal; michael@0: typedef int (GLAPIENTRY * PFNGLXGETFBCONFIGATTRIB) (Display *, michael@0: GLXFBConfig, michael@0: int, michael@0: int *); michael@0: PFNGLXGETFBCONFIGATTRIB xGetFBConfigAttribInternal; michael@0: michael@0: typedef void (GLAPIENTRY * PFNGLXSWAPBUFFERS) (Display *, michael@0: GLXDrawable); michael@0: PFNGLXSWAPBUFFERS xSwapBuffersInternal; michael@0: typedef const char * (GLAPIENTRY * PFNGLXQUERYEXTENSIONSSTRING) (Display *, michael@0: int); michael@0: PFNGLXQUERYEXTENSIONSSTRING xQueryExtensionsStringInternal; michael@0: typedef const char * (GLAPIENTRY * PFNGLXGETCLIENTSTRING) (Display *, michael@0: int); michael@0: PFNGLXGETCLIENTSTRING xGetClientStringInternal; michael@0: typedef const char * (GLAPIENTRY * PFNGLXQUERYSERVERSTRING) (Display *, michael@0: int, michael@0: int); michael@0: PFNGLXQUERYSERVERSTRING xQueryServerStringInternal; michael@0: michael@0: typedef GLXPixmap (GLAPIENTRY * PFNGLXCREATEPIXMAP) (Display *, michael@0: GLXFBConfig, michael@0: Pixmap, michael@0: const int *); michael@0: PFNGLXCREATEPIXMAP xCreatePixmapInternal; michael@0: typedef GLXPixmap (GLAPIENTRY * PFNGLXCREATEGLXPIXMAPWITHCONFIG) michael@0: (Display *, michael@0: GLXFBConfig, michael@0: Pixmap); michael@0: PFNGLXCREATEGLXPIXMAPWITHCONFIG xCreateGLXPixmapWithConfigInternal; michael@0: typedef void (GLAPIENTRY * PFNGLXDESTROYPIXMAP) (Display *, michael@0: GLXPixmap); michael@0: PFNGLXDESTROYPIXMAP xDestroyPixmapInternal; michael@0: typedef Bool (GLAPIENTRY * PFNGLXQUERYVERSION) (Display *, michael@0: int *, michael@0: int *); michael@0: PFNGLXQUERYVERSION xQueryVersionInternal; michael@0: michael@0: typedef void (GLAPIENTRY * PFNGLXBINDTEXIMAGE) (Display *, michael@0: GLXDrawable, michael@0: int, michael@0: const int *); michael@0: PFNGLXBINDTEXIMAGE xBindTexImageInternal; michael@0: michael@0: typedef void (GLAPIENTRY * PFNGLXRELEASETEXIMAGE) (Display *, michael@0: GLXDrawable, michael@0: int); michael@0: PFNGLXRELEASETEXIMAGE xReleaseTexImageInternal; michael@0: michael@0: typedef void (GLAPIENTRY * PFNGLXWAITGL) (); michael@0: PFNGLXWAITGL xWaitGLInternal; michael@0: michael@0: typedef void (GLAPIENTRY * PFNGLXWAITX) (); michael@0: PFNGLXWAITGL xWaitXInternal; michael@0: michael@0: typedef GLXContext (GLAPIENTRY * PFNGLXCREATECONTEXTATTRIBS) (Display *, michael@0: GLXFBConfig, michael@0: GLXContext, michael@0: Bool, michael@0: const int *); michael@0: PFNGLXCREATECONTEXTATTRIBS xCreateContextAttribsInternal; michael@0: michael@0: #ifdef DEBUG michael@0: void BeforeGLXCall(); michael@0: void AfterGLXCall(); michael@0: #endif michael@0: michael@0: bool mInitialized; michael@0: bool mTriedInitializing; michael@0: bool mUseTextureFromPixmap; michael@0: bool mDebug; michael@0: bool mHasRobustness; michael@0: bool mIsATI; michael@0: bool mIsNVIDIA; michael@0: bool mClientIsMesa; michael@0: int mGLXMajorVersion; michael@0: int mGLXMinorVersion; michael@0: PRLibrary *mOGLLibrary; michael@0: }; michael@0: michael@0: // a global GLXLibrary instance michael@0: extern GLXLibrary sGLXLibrary; michael@0: michael@0: } /* namespace gl */ michael@0: } /* namespace mozilla */ michael@0: #endif /* GFX_GLXLIBRARY_H */ michael@0: