Bug 1470678 [wpt PR 11640] - Add a test for text-decoration in tables quirk, a=testonly
[gecko.git] / gfx / gl / GLXLibrary.h
blob0dbec50773894ec2c2c5c5f8c87fe6e04b37ca92
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"
10 #include "prlink.h"
11 typedef realGLboolean GLboolean;
13 // stuff from glx.h
14 #include "X11/Xlib.h"
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
23 #include "prenv.h"
25 struct PRLibrary;
26 class gfxASurface;
28 namespace mozilla {
29 namespace gl {
31 class GLXLibrary
33 public:
34 bool EnsureInitialized();
36 private:
37 void BeforeGLXCall() const;
38 void AfterGLXCall() const;
40 public:
42 #ifdef DEBUG
43 #define BEFORE_CALL BeforeGLXCall();
44 #define AFTER_CALL AfterGLXCall();
45 #else
46 #define BEFORE_CALL
47 #define AFTER_CALL
48 #endif
50 #define WRAP(X) \
51 { \
52 BEFORE_CALL \
53 const auto ret = mSymbols. X ; \
54 AFTER_CALL \
55 return ret; \
57 #define VOID_WRAP(X) \
58 { \
59 BEFORE_CALL \
60 mSymbols. X ; \
61 AFTER_CALL \
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) )
121 void fWaitGL() const
122 VOID_WRAP( fWaitGL() )
124 void fWaitX() const
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) )
139 #undef WRAP
140 #undef VOID_WRAP
141 #undef BEFORE_CALL
142 #undef AFTER_CALL
144 ////
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);
152 ////
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;
167 private:
168 struct {
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,
178 GLXContext, Bool);
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,
185 const int*);
186 GLXPixmap (GLAPIENTRY *fCreateGLXPixmapWithConfig) (Display*, GLXFBConfig,
187 Pixmap);
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,
193 const int*);
194 void (GLAPIENTRY *fReleaseTexImageEXT) (Display*, GLXDrawable, int);
195 GLXContext (GLAPIENTRY *fCreateContextAttribsARB) (Display*, GLXFBConfig,
196 GLXContext, Bool,
197 const int*);
198 int (GLAPIENTRY *fGetVideoSyncSGI) (unsigned int*);
199 int (GLAPIENTRY *fWaitVideoSyncSGI) (int, int, unsigned int*);
200 void (GLAPIENTRY *fSwapIntervalEXT) (Display*, GLXDrawable, int);
201 } mSymbols = {};
203 #ifdef DEBUG
204 void BeforeGLXCall();
205 void AfterGLXCall();
206 #endif
208 bool mInitialized = false;
209 bool mTriedInitializing = false;
210 bool mUseTextureFromPixmap = false;
211 bool mDebug = false;
212 bool mHasRobustness = false;
213 bool mHasCreateContextAttribs = false;
214 bool mHasVideoSync = false;
215 bool mIsATI = false;
216 bool mIsNVIDIA = false;
217 bool mClientIsMesa = false;
218 PRLibrary* mOGLLibrary = nullptr;
221 // a global GLXLibrary instance
222 extern GLXLibrary sGLXLibrary;
224 } /* namespace gl */
225 } /* namespace mozilla */
226 #endif /* GFX_GLXLIBRARY_H */