1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/gfx/gl/GLXLibrary.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,226 @@ 1.4 +/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- 1.5 + * This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +#ifndef GFX_GLXLIBRARY_H 1.10 +#define GFX_GLXLIBRARY_H 1.11 + 1.12 +#include "GLContextTypes.h" 1.13 +typedef realGLboolean GLboolean; 1.14 + 1.15 +// stuff from glx.h 1.16 +#include "X11/Xlib.h" 1.17 +typedef struct __GLXcontextRec *GLXContext; 1.18 +typedef XID GLXPixmap; 1.19 +typedef XID GLXDrawable; 1.20 +/* GLX 1.3 and later */ 1.21 +typedef struct __GLXFBConfigRec *GLXFBConfig; 1.22 +typedef XID GLXFBConfigID; 1.23 +typedef XID GLXContextID; 1.24 +typedef XID GLXWindow; 1.25 +typedef XID GLXPbuffer; 1.26 +// end of stuff from glx.h 1.27 + 1.28 +struct PRLibrary; 1.29 +class gfxASurface; 1.30 + 1.31 +namespace mozilla { 1.32 +namespace gl { 1.33 + 1.34 +class GLXLibrary 1.35 +{ 1.36 +public: 1.37 + GLXLibrary() : mInitialized(false), mTriedInitializing(false), 1.38 + mUseTextureFromPixmap(false), mDebug(false), 1.39 + mHasRobustness(false), mIsATI(false), mIsNVIDIA(false), 1.40 + mClientIsMesa(false), mGLXMajorVersion(0), 1.41 + mGLXMinorVersion(0), 1.42 + mOGLLibrary(nullptr) {} 1.43 + 1.44 + void xDestroyContext(Display* display, GLXContext context); 1.45 + Bool xMakeCurrent(Display* display, 1.46 + GLXDrawable drawable, 1.47 + GLXContext context); 1.48 + 1.49 + GLXContext xGetCurrentContext(); 1.50 + static void* xGetProcAddress(const char *procName); 1.51 + GLXFBConfig* xChooseFBConfig(Display* display, 1.52 + int screen, 1.53 + const int *attrib_list, 1.54 + int *nelements); 1.55 + GLXFBConfig* xGetFBConfigs(Display* display, 1.56 + int screen, 1.57 + int *nelements); 1.58 + GLXContext xCreateNewContext(Display* display, 1.59 + GLXFBConfig config, 1.60 + int render_type, 1.61 + GLXContext share_list, 1.62 + Bool direct); 1.63 + int xGetFBConfigAttrib(Display *display, 1.64 + GLXFBConfig config, 1.65 + int attribute, 1.66 + int *value); 1.67 + void xSwapBuffers(Display *display, GLXDrawable drawable); 1.68 + const char * xQueryExtensionsString(Display *display, 1.69 + int screen); 1.70 + const char * xGetClientString(Display *display, 1.71 + int screen); 1.72 + const char * xQueryServerString(Display *display, 1.73 + int screen, int name); 1.74 + GLXPixmap xCreatePixmap(Display *display, 1.75 + GLXFBConfig config, 1.76 + Pixmap pixmap, 1.77 + const int *attrib_list); 1.78 + GLXPixmap xCreateGLXPixmapWithConfig(Display *display, 1.79 + GLXFBConfig config, 1.80 + Pixmap pixmap); 1.81 + void xDestroyPixmap(Display *display, GLXPixmap pixmap); 1.82 + Bool xQueryVersion(Display *display, 1.83 + int *major, 1.84 + int *minor); 1.85 + void xBindTexImage(Display *display, 1.86 + GLXDrawable drawable, 1.87 + int buffer, 1.88 + const int *attrib_list); 1.89 + void xReleaseTexImage(Display *display, 1.90 + GLXDrawable drawable, 1.91 + int buffer); 1.92 + void xWaitGL(); 1.93 + void xWaitX(); 1.94 + 1.95 + GLXContext xCreateContextAttribs(Display* display, 1.96 + GLXFBConfig config, 1.97 + GLXContext share_list, 1.98 + Bool direct, 1.99 + const int* attrib_list); 1.100 + 1.101 + bool EnsureInitialized(); 1.102 + 1.103 + GLXPixmap CreatePixmap(gfxASurface* aSurface); 1.104 + void DestroyPixmap(Display* aDisplay, GLXPixmap aPixmap); 1.105 + void BindTexImage(Display* aDisplay, GLXPixmap aPixmap); 1.106 + void ReleaseTexImage(Display* aDisplay, GLXPixmap aPixmap); 1.107 + void UpdateTexImage(Display* aDisplay, GLXPixmap aPixmap); 1.108 + 1.109 + bool UseTextureFromPixmap() { return mUseTextureFromPixmap; } 1.110 + bool HasRobustness() { return mHasRobustness; } 1.111 + bool SupportsTextureFromPixmap(gfxASurface* aSurface); 1.112 + bool IsATI() { return mIsATI; } 1.113 + bool GLXVersionCheck(int aMajor, int aMinor); 1.114 + 1.115 +private: 1.116 + 1.117 + typedef void (GLAPIENTRY * PFNGLXDESTROYCONTEXTPROC) (Display*, 1.118 + GLXContext); 1.119 + PFNGLXDESTROYCONTEXTPROC xDestroyContextInternal; 1.120 + typedef Bool (GLAPIENTRY * PFNGLXMAKECURRENTPROC) (Display*, 1.121 + GLXDrawable, 1.122 + GLXContext); 1.123 + PFNGLXMAKECURRENTPROC xMakeCurrentInternal; 1.124 + typedef GLXContext (GLAPIENTRY * PFNGLXGETCURRENTCONTEXT) (); 1.125 + PFNGLXGETCURRENTCONTEXT xGetCurrentContextInternal; 1.126 + typedef void* (GLAPIENTRY * PFNGLXGETPROCADDRESSPROC) (const char *); 1.127 + PFNGLXGETPROCADDRESSPROC xGetProcAddressInternal; 1.128 + typedef GLXFBConfig* (GLAPIENTRY * PFNGLXCHOOSEFBCONFIG) (Display *, 1.129 + int, 1.130 + const int *, 1.131 + int *); 1.132 + PFNGLXCHOOSEFBCONFIG xChooseFBConfigInternal; 1.133 + typedef GLXFBConfig* (GLAPIENTRY * PFNGLXGETFBCONFIGS) (Display *, 1.134 + int, 1.135 + int *); 1.136 + PFNGLXGETFBCONFIGS xGetFBConfigsInternal; 1.137 + typedef GLXContext (GLAPIENTRY * PFNGLXCREATENEWCONTEXT) (Display *, 1.138 + GLXFBConfig, 1.139 + int, 1.140 + GLXContext, 1.141 + Bool); 1.142 + PFNGLXCREATENEWCONTEXT xCreateNewContextInternal; 1.143 + typedef int (GLAPIENTRY * PFNGLXGETFBCONFIGATTRIB) (Display *, 1.144 + GLXFBConfig, 1.145 + int, 1.146 + int *); 1.147 + PFNGLXGETFBCONFIGATTRIB xGetFBConfigAttribInternal; 1.148 + 1.149 + typedef void (GLAPIENTRY * PFNGLXSWAPBUFFERS) (Display *, 1.150 + GLXDrawable); 1.151 + PFNGLXSWAPBUFFERS xSwapBuffersInternal; 1.152 + typedef const char * (GLAPIENTRY * PFNGLXQUERYEXTENSIONSSTRING) (Display *, 1.153 + int); 1.154 + PFNGLXQUERYEXTENSIONSSTRING xQueryExtensionsStringInternal; 1.155 + typedef const char * (GLAPIENTRY * PFNGLXGETCLIENTSTRING) (Display *, 1.156 + int); 1.157 + PFNGLXGETCLIENTSTRING xGetClientStringInternal; 1.158 + typedef const char * (GLAPIENTRY * PFNGLXQUERYSERVERSTRING) (Display *, 1.159 + int, 1.160 + int); 1.161 + PFNGLXQUERYSERVERSTRING xQueryServerStringInternal; 1.162 + 1.163 + typedef GLXPixmap (GLAPIENTRY * PFNGLXCREATEPIXMAP) (Display *, 1.164 + GLXFBConfig, 1.165 + Pixmap, 1.166 + const int *); 1.167 + PFNGLXCREATEPIXMAP xCreatePixmapInternal; 1.168 + typedef GLXPixmap (GLAPIENTRY * PFNGLXCREATEGLXPIXMAPWITHCONFIG) 1.169 + (Display *, 1.170 + GLXFBConfig, 1.171 + Pixmap); 1.172 + PFNGLXCREATEGLXPIXMAPWITHCONFIG xCreateGLXPixmapWithConfigInternal; 1.173 + typedef void (GLAPIENTRY * PFNGLXDESTROYPIXMAP) (Display *, 1.174 + GLXPixmap); 1.175 + PFNGLXDESTROYPIXMAP xDestroyPixmapInternal; 1.176 + typedef Bool (GLAPIENTRY * PFNGLXQUERYVERSION) (Display *, 1.177 + int *, 1.178 + int *); 1.179 + PFNGLXQUERYVERSION xQueryVersionInternal; 1.180 + 1.181 + typedef void (GLAPIENTRY * PFNGLXBINDTEXIMAGE) (Display *, 1.182 + GLXDrawable, 1.183 + int, 1.184 + const int *); 1.185 + PFNGLXBINDTEXIMAGE xBindTexImageInternal; 1.186 + 1.187 + typedef void (GLAPIENTRY * PFNGLXRELEASETEXIMAGE) (Display *, 1.188 + GLXDrawable, 1.189 + int); 1.190 + PFNGLXRELEASETEXIMAGE xReleaseTexImageInternal; 1.191 + 1.192 + typedef void (GLAPIENTRY * PFNGLXWAITGL) (); 1.193 + PFNGLXWAITGL xWaitGLInternal; 1.194 + 1.195 + typedef void (GLAPIENTRY * PFNGLXWAITX) (); 1.196 + PFNGLXWAITGL xWaitXInternal; 1.197 + 1.198 + typedef GLXContext (GLAPIENTRY * PFNGLXCREATECONTEXTATTRIBS) (Display *, 1.199 + GLXFBConfig, 1.200 + GLXContext, 1.201 + Bool, 1.202 + const int *); 1.203 + PFNGLXCREATECONTEXTATTRIBS xCreateContextAttribsInternal; 1.204 + 1.205 +#ifdef DEBUG 1.206 + void BeforeGLXCall(); 1.207 + void AfterGLXCall(); 1.208 +#endif 1.209 + 1.210 + bool mInitialized; 1.211 + bool mTriedInitializing; 1.212 + bool mUseTextureFromPixmap; 1.213 + bool mDebug; 1.214 + bool mHasRobustness; 1.215 + bool mIsATI; 1.216 + bool mIsNVIDIA; 1.217 + bool mClientIsMesa; 1.218 + int mGLXMajorVersion; 1.219 + int mGLXMinorVersion; 1.220 + PRLibrary *mOGLLibrary; 1.221 +}; 1.222 + 1.223 +// a global GLXLibrary instance 1.224 +extern GLXLibrary sGLXLibrary; 1.225 + 1.226 +} /* namespace gl */ 1.227 +} /* namespace mozilla */ 1.228 +#endif /* GFX_GLXLIBRARY_H */ 1.229 +