1 /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 * This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef GFX_GLXLIBRARY_H
7 #define GFX_GLXLIBRARY_H
9 #include "GLContextTypes.h"
11 typedef realGLboolean GLboolean
;
15 #include "X11/Xutil.h" // for XVisualInfo
16 #include "X11UndefineNone.h"
17 typedef struct __GLXcontextRec
* GLXContext
;
18 typedef XID GLXPixmap
;
19 typedef XID GLXDrawable
;
20 /* GLX 1.3 and later */
21 typedef struct __GLXFBConfigRec
* GLXFBConfig
;
22 // end of stuff from glx.h
34 bool EnsureInitialized();
37 void BeforeGLXCall() const;
38 void AfterGLXCall() const;
43 #define BEFORE_CALL BeforeGLXCall();
44 #define AFTER_CALL AfterGLXCall();
53 const auto ret = mSymbols. X ; \
57 #define VOID_WRAP(X) \
64 void fDestroyContext(Display
* display
, GLXContext context
) const
65 VOID_WRAP( fDestroyContext(display
, context
) )
67 Bool
fMakeCurrent(Display
* display
, GLXDrawable drawable
, GLXContext context
) const
68 WRAP( fMakeCurrent(display
, drawable
, context
) )
70 XVisualInfo
* fGetConfig(Display
* display
, XVisualInfo
* info
, int attrib
, int* value
) const
71 WRAP( fGetConfig(display
, info
, attrib
, value
) )
73 GLXContext
fGetCurrentContext() const
74 WRAP( fGetCurrentContext() )
76 GLXFBConfig
* fChooseFBConfig(Display
* display
, int screen
, const int* attrib_list
, int* nelements
) const
77 WRAP( fChooseFBConfig(display
, screen
, attrib_list
, nelements
) )
79 XVisualInfo
* fChooseVisual(Display
* display
, int screen
, int* attrib_list
) const
80 WRAP( fChooseVisual(display
, screen
, attrib_list
) )
82 GLXFBConfig
* fGetFBConfigs(Display
* display
, int screen
, int* nelements
) const
83 WRAP( fGetFBConfigs(display
, screen
, nelements
) )
85 GLXContext
fCreateNewContext(Display
* display
, GLXFBConfig config
, int render_type
, GLXContext share_list
, Bool direct
) const
86 WRAP( fCreateNewContext(display
, config
, render_type
, share_list
, direct
) )
88 int fGetFBConfigAttrib(Display
* display
, GLXFBConfig config
, int attribute
, int* value
) const
89 WRAP( fGetFBConfigAttrib(display
, config
, attribute
, value
) )
91 void fSwapBuffers(Display
* display
, GLXDrawable drawable
) const
92 VOID_WRAP( fSwapBuffers(display
, drawable
) )
94 const char* fQueryExtensionsString(Display
* display
, int screen
) const
95 WRAP( fQueryExtensionsString(display
, screen
) )
97 const char* fGetClientString(Display
* display
, int screen
) const
98 WRAP( fGetClientString(display
, screen
) )
100 const char* fQueryServerString(Display
* display
, int screen
, int name
) const
101 WRAP( fQueryServerString(display
, screen
, name
) )
103 GLXPixmap
fCreatePixmap(Display
* display
, GLXFBConfig config
, Pixmap pixmap
, const int* attrib_list
) const
104 WRAP( fCreatePixmap(display
, config
, pixmap
, attrib_list
) )
106 GLXPixmap
fCreateGLXPixmapWithConfig(Display
* display
, GLXFBConfig config
, Pixmap pixmap
) const
107 WRAP( fCreateGLXPixmapWithConfig(display
, config
, pixmap
) )
109 void fDestroyPixmap(Display
* display
, GLXPixmap pixmap
) const
110 VOID_WRAP( fDestroyPixmap(display
, pixmap
) )
112 Bool
fQueryVersion(Display
* display
, int* major
, int* minor
) const
113 WRAP( fQueryVersion(display
, major
, minor
) )
115 void fBindTexImage(Display
* display
, GLXDrawable drawable
, int buffer
, const int* attrib_list
) const
116 VOID_WRAP( fBindTexImageEXT(display
, drawable
, buffer
, attrib_list
) )
118 void fReleaseTexImage(Display
* display
, GLXDrawable drawable
, int buffer
) const
119 VOID_WRAP( fReleaseTexImageEXT(display
, drawable
, buffer
) )
122 VOID_WRAP( fWaitGL() )
125 VOID_WRAP( fWaitX() )
127 GLXContext
fCreateContextAttribs(Display
* display
, GLXFBConfig config
, GLXContext share_list
, Bool direct
, const int* attrib_list
) const
128 WRAP( fCreateContextAttribsARB(display
, config
, share_list
, direct
, attrib_list
) )
130 int fGetVideoSync(unsigned int* count
) const
131 WRAP( fGetVideoSyncSGI(count
) )
133 int fWaitVideoSync(int divisor
, int remainder
, unsigned int* count
) const
134 WRAP( fWaitVideoSyncSGI(divisor
, remainder
, count
) )
136 void fSwapInterval(Display
* dpy
, GLXDrawable drawable
, int interval
) const
137 VOID_WRAP( fSwapIntervalEXT(dpy
, drawable
, interval
) )
146 GLXPixmap
CreatePixmap(gfxASurface
* aSurface
);
147 void DestroyPixmap(Display
* aDisplay
, GLXPixmap aPixmap
);
148 void BindTexImage(Display
* aDisplay
, GLXPixmap aPixmap
);
149 void ReleaseTexImage(Display
* aDisplay
, GLXPixmap aPixmap
);
150 void UpdateTexImage(Display
* aDisplay
, GLXPixmap aPixmap
);
154 bool UseTextureFromPixmap() { return mUseTextureFromPixmap
; }
155 bool HasRobustness() { return mHasRobustness
; }
156 bool HasCreateContextAttribs() { return mHasCreateContextAttribs
; }
157 bool SupportsTextureFromPixmap(gfxASurface
* aSurface
);
158 bool SupportsVideoSync();
159 bool SupportsSwapControl() const { return bool(mSymbols
.fSwapIntervalEXT
); }
160 bool IsATI() { return mIsATI
; }
161 bool IsMesa() { return mClientIsMesa
; }
163 PRFuncPtr
GetGetProcAddress() const {
164 return (PRFuncPtr
)mSymbols
.fGetProcAddress
;
169 void (GLAPIENTRY
*fDestroyContext
) (Display
*, GLXContext
);
170 Bool (GLAPIENTRY
*fMakeCurrent
) (Display
*, GLXDrawable
, GLXContext
);
171 XVisualInfo
* (GLAPIENTRY
*fGetConfig
) (Display
*, XVisualInfo
*, int, int*);
172 GLXContext (GLAPIENTRY
*fGetCurrentContext
) ();
173 void* (GLAPIENTRY
*fGetProcAddress
) (const char*);
174 GLXFBConfig
* (GLAPIENTRY
*fChooseFBConfig
) (Display
*, int, const int*, int*);
175 XVisualInfo
* (GLAPIENTRY
*fChooseVisual
) (Display
*, int, const int*);
176 GLXFBConfig
* (GLAPIENTRY
*fGetFBConfigs
) (Display
*, int, int*);
177 GLXContext (GLAPIENTRY
*fCreateNewContext
) (Display
*, GLXFBConfig
, int,
179 int (GLAPIENTRY
*fGetFBConfigAttrib
) (Display
*, GLXFBConfig
, int, int*);
180 void (GLAPIENTRY
*fSwapBuffers
) (Display
*, GLXDrawable
);
181 const char* (GLAPIENTRY
*fQueryExtensionsString
) (Display
*, int);
182 const char* (GLAPIENTRY
*fGetClientString
) (Display
*, int);
183 const char* (GLAPIENTRY
*fQueryServerString
) (Display
*, int, int);
184 GLXPixmap (GLAPIENTRY
*fCreatePixmap
) (Display
*, GLXFBConfig
, Pixmap
,
186 GLXPixmap (GLAPIENTRY
*fCreateGLXPixmapWithConfig
) (Display
*, GLXFBConfig
,
188 void (GLAPIENTRY
*fDestroyPixmap
) (Display
*, GLXPixmap
);
189 Bool (GLAPIENTRY
*fQueryVersion
) (Display
*, int*, int*);
190 void (GLAPIENTRY
*fWaitGL
) ();
191 void (GLAPIENTRY
*fWaitX
) ();
192 void (GLAPIENTRY
*fBindTexImageEXT
) (Display
*, GLXDrawable
, int,
194 void (GLAPIENTRY
*fReleaseTexImageEXT
) (Display
*, GLXDrawable
, int);
195 GLXContext (GLAPIENTRY
*fCreateContextAttribsARB
) (Display
*, GLXFBConfig
,
198 int (GLAPIENTRY
*fGetVideoSyncSGI
) (unsigned int*);
199 int (GLAPIENTRY
*fWaitVideoSyncSGI
) (int, int, unsigned int*);
200 void (GLAPIENTRY
*fSwapIntervalEXT
) (Display
*, GLXDrawable
, int);
204 void BeforeGLXCall();
208 bool mInitialized
= false;
209 bool mTriedInitializing
= false;
210 bool mUseTextureFromPixmap
= false;
212 bool mHasRobustness
= false;
213 bool mHasCreateContextAttribs
= false;
214 bool mHasVideoSync
= false;
216 bool mIsNVIDIA
= false;
217 bool mClientIsMesa
= false;
218 PRLibrary
* mOGLLibrary
= nullptr;
221 // a global GLXLibrary instance
222 extern GLXLibrary sGLXLibrary
;
225 } /* namespace mozilla */
226 #endif /* GFX_GLXLIBRARY_H */