gfx/gl/GLXLibrary.h

branch
TOR_BUG_9701
changeset 8
97036ab72558
equal deleted inserted replaced
-1:000000000000 0:58fc91079b97
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/. */
5
6 #ifndef GFX_GLXLIBRARY_H
7 #define GFX_GLXLIBRARY_H
8
9 #include "GLContextTypes.h"
10 typedef realGLboolean GLboolean;
11
12 // stuff from glx.h
13 #include "X11/Xlib.h"
14 typedef struct __GLXcontextRec *GLXContext;
15 typedef XID GLXPixmap;
16 typedef XID GLXDrawable;
17 /* GLX 1.3 and later */
18 typedef struct __GLXFBConfigRec *GLXFBConfig;
19 typedef XID GLXFBConfigID;
20 typedef XID GLXContextID;
21 typedef XID GLXWindow;
22 typedef XID GLXPbuffer;
23 // end of stuff from glx.h
24
25 struct PRLibrary;
26 class gfxASurface;
27
28 namespace mozilla {
29 namespace gl {
30
31 class GLXLibrary
32 {
33 public:
34 GLXLibrary() : mInitialized(false), mTriedInitializing(false),
35 mUseTextureFromPixmap(false), mDebug(false),
36 mHasRobustness(false), mIsATI(false), mIsNVIDIA(false),
37 mClientIsMesa(false), mGLXMajorVersion(0),
38 mGLXMinorVersion(0),
39 mOGLLibrary(nullptr) {}
40
41 void xDestroyContext(Display* display, GLXContext context);
42 Bool xMakeCurrent(Display* display,
43 GLXDrawable drawable,
44 GLXContext context);
45
46 GLXContext xGetCurrentContext();
47 static void* xGetProcAddress(const char *procName);
48 GLXFBConfig* xChooseFBConfig(Display* display,
49 int screen,
50 const int *attrib_list,
51 int *nelements);
52 GLXFBConfig* xGetFBConfigs(Display* display,
53 int screen,
54 int *nelements);
55 GLXContext xCreateNewContext(Display* display,
56 GLXFBConfig config,
57 int render_type,
58 GLXContext share_list,
59 Bool direct);
60 int xGetFBConfigAttrib(Display *display,
61 GLXFBConfig config,
62 int attribute,
63 int *value);
64 void xSwapBuffers(Display *display, GLXDrawable drawable);
65 const char * xQueryExtensionsString(Display *display,
66 int screen);
67 const char * xGetClientString(Display *display,
68 int screen);
69 const char * xQueryServerString(Display *display,
70 int screen, int name);
71 GLXPixmap xCreatePixmap(Display *display,
72 GLXFBConfig config,
73 Pixmap pixmap,
74 const int *attrib_list);
75 GLXPixmap xCreateGLXPixmapWithConfig(Display *display,
76 GLXFBConfig config,
77 Pixmap pixmap);
78 void xDestroyPixmap(Display *display, GLXPixmap pixmap);
79 Bool xQueryVersion(Display *display,
80 int *major,
81 int *minor);
82 void xBindTexImage(Display *display,
83 GLXDrawable drawable,
84 int buffer,
85 const int *attrib_list);
86 void xReleaseTexImage(Display *display,
87 GLXDrawable drawable,
88 int buffer);
89 void xWaitGL();
90 void xWaitX();
91
92 GLXContext xCreateContextAttribs(Display* display,
93 GLXFBConfig config,
94 GLXContext share_list,
95 Bool direct,
96 const int* attrib_list);
97
98 bool EnsureInitialized();
99
100 GLXPixmap CreatePixmap(gfxASurface* aSurface);
101 void DestroyPixmap(Display* aDisplay, GLXPixmap aPixmap);
102 void BindTexImage(Display* aDisplay, GLXPixmap aPixmap);
103 void ReleaseTexImage(Display* aDisplay, GLXPixmap aPixmap);
104 void UpdateTexImage(Display* aDisplay, GLXPixmap aPixmap);
105
106 bool UseTextureFromPixmap() { return mUseTextureFromPixmap; }
107 bool HasRobustness() { return mHasRobustness; }
108 bool SupportsTextureFromPixmap(gfxASurface* aSurface);
109 bool IsATI() { return mIsATI; }
110 bool GLXVersionCheck(int aMajor, int aMinor);
111
112 private:
113
114 typedef void (GLAPIENTRY * PFNGLXDESTROYCONTEXTPROC) (Display*,
115 GLXContext);
116 PFNGLXDESTROYCONTEXTPROC xDestroyContextInternal;
117 typedef Bool (GLAPIENTRY * PFNGLXMAKECURRENTPROC) (Display*,
118 GLXDrawable,
119 GLXContext);
120 PFNGLXMAKECURRENTPROC xMakeCurrentInternal;
121 typedef GLXContext (GLAPIENTRY * PFNGLXGETCURRENTCONTEXT) ();
122 PFNGLXGETCURRENTCONTEXT xGetCurrentContextInternal;
123 typedef void* (GLAPIENTRY * PFNGLXGETPROCADDRESSPROC) (const char *);
124 PFNGLXGETPROCADDRESSPROC xGetProcAddressInternal;
125 typedef GLXFBConfig* (GLAPIENTRY * PFNGLXCHOOSEFBCONFIG) (Display *,
126 int,
127 const int *,
128 int *);
129 PFNGLXCHOOSEFBCONFIG xChooseFBConfigInternal;
130 typedef GLXFBConfig* (GLAPIENTRY * PFNGLXGETFBCONFIGS) (Display *,
131 int,
132 int *);
133 PFNGLXGETFBCONFIGS xGetFBConfigsInternal;
134 typedef GLXContext (GLAPIENTRY * PFNGLXCREATENEWCONTEXT) (Display *,
135 GLXFBConfig,
136 int,
137 GLXContext,
138 Bool);
139 PFNGLXCREATENEWCONTEXT xCreateNewContextInternal;
140 typedef int (GLAPIENTRY * PFNGLXGETFBCONFIGATTRIB) (Display *,
141 GLXFBConfig,
142 int,
143 int *);
144 PFNGLXGETFBCONFIGATTRIB xGetFBConfigAttribInternal;
145
146 typedef void (GLAPIENTRY * PFNGLXSWAPBUFFERS) (Display *,
147 GLXDrawable);
148 PFNGLXSWAPBUFFERS xSwapBuffersInternal;
149 typedef const char * (GLAPIENTRY * PFNGLXQUERYEXTENSIONSSTRING) (Display *,
150 int);
151 PFNGLXQUERYEXTENSIONSSTRING xQueryExtensionsStringInternal;
152 typedef const char * (GLAPIENTRY * PFNGLXGETCLIENTSTRING) (Display *,
153 int);
154 PFNGLXGETCLIENTSTRING xGetClientStringInternal;
155 typedef const char * (GLAPIENTRY * PFNGLXQUERYSERVERSTRING) (Display *,
156 int,
157 int);
158 PFNGLXQUERYSERVERSTRING xQueryServerStringInternal;
159
160 typedef GLXPixmap (GLAPIENTRY * PFNGLXCREATEPIXMAP) (Display *,
161 GLXFBConfig,
162 Pixmap,
163 const int *);
164 PFNGLXCREATEPIXMAP xCreatePixmapInternal;
165 typedef GLXPixmap (GLAPIENTRY * PFNGLXCREATEGLXPIXMAPWITHCONFIG)
166 (Display *,
167 GLXFBConfig,
168 Pixmap);
169 PFNGLXCREATEGLXPIXMAPWITHCONFIG xCreateGLXPixmapWithConfigInternal;
170 typedef void (GLAPIENTRY * PFNGLXDESTROYPIXMAP) (Display *,
171 GLXPixmap);
172 PFNGLXDESTROYPIXMAP xDestroyPixmapInternal;
173 typedef Bool (GLAPIENTRY * PFNGLXQUERYVERSION) (Display *,
174 int *,
175 int *);
176 PFNGLXQUERYVERSION xQueryVersionInternal;
177
178 typedef void (GLAPIENTRY * PFNGLXBINDTEXIMAGE) (Display *,
179 GLXDrawable,
180 int,
181 const int *);
182 PFNGLXBINDTEXIMAGE xBindTexImageInternal;
183
184 typedef void (GLAPIENTRY * PFNGLXRELEASETEXIMAGE) (Display *,
185 GLXDrawable,
186 int);
187 PFNGLXRELEASETEXIMAGE xReleaseTexImageInternal;
188
189 typedef void (GLAPIENTRY * PFNGLXWAITGL) ();
190 PFNGLXWAITGL xWaitGLInternal;
191
192 typedef void (GLAPIENTRY * PFNGLXWAITX) ();
193 PFNGLXWAITGL xWaitXInternal;
194
195 typedef GLXContext (GLAPIENTRY * PFNGLXCREATECONTEXTATTRIBS) (Display *,
196 GLXFBConfig,
197 GLXContext,
198 Bool,
199 const int *);
200 PFNGLXCREATECONTEXTATTRIBS xCreateContextAttribsInternal;
201
202 #ifdef DEBUG
203 void BeforeGLXCall();
204 void AfterGLXCall();
205 #endif
206
207 bool mInitialized;
208 bool mTriedInitializing;
209 bool mUseTextureFromPixmap;
210 bool mDebug;
211 bool mHasRobustness;
212 bool mIsATI;
213 bool mIsNVIDIA;
214 bool mClientIsMesa;
215 int mGLXMajorVersion;
216 int mGLXMinorVersion;
217 PRLibrary *mOGLLibrary;
218 };
219
220 // a global GLXLibrary instance
221 extern GLXLibrary sGLXLibrary;
222
223 } /* namespace gl */
224 } /* namespace mozilla */
225 #endif /* GFX_GLXLIBRARY_H */
226

mercurial