VirtualBox

source: vbox/trunk/src/VBox/Additions/common/crOpenGL/stub.h@ 25943

Last change on this file since 25943 was 25383, checked in by vboxsync, 15 years ago

crOpenGL: fix compiz on older gpus (#4404)

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 7.5 KB
Line 
1/* Copyright (c) 2001, Stanford University
2 * All rights reserved
3 *
4 * See the file LICENSE.txt for information on redistributing this software.
5 */
6
7
8/*
9 * How this all works...
10 *
11 * This directory implements three different interfaces to Chromium:
12 *
13 * 1. the Chromium interface - this is defined by the functions that start
14 * with the "cr" prefix and are defined in chromium.h and implemented in
15 * stub.c. Typically, this is used by parallel apps (like psubmit).
16 *
17 * 2. GLX emulation interface - the glX*() functions are emulated here.
18 * When glXCreateContext() is called we may either create a real, native
19 * GLX context or a Chromium context (depending on match_window_title and
20 * mimimum_window_size).
21 *
22 * 3. WGL emulation interface - the wgl*() functions are emulated here.
23 * When wglCreateContext() is called we may either create a real, native
24 * WGL context or a Chromium context (depending on match_window_title and
25 * mimimum_window_size).
26 *
27 *
28 */
29
30
31#ifndef CR_STUB_H
32#define CR_STUB_H
33
34#include "chromium.h"
35#include "cr_version.h"
36#include "cr_hash.h"
37#include "cr_process.h"
38#include "cr_spu.h"
39#include "cr_threads.h"
40#include "spu_dispatch_table.h"
41
42#ifdef GLX
43#include <X11/extensions/XShm.h>
44#include <sys/shm.h>
45#include <X11/extensions/Xdamage.h>
46#endif
47
48
49/* When we first create a rendering context we can't be sure whether
50 * it'll be handled by Chromium or as a native GLX/WGL context. So in
51 * CreateContext() we'll mark the ContextInfo object as UNDECIDED then
52 * switch it to either NATIVE or CHROMIUM the first time MakeCurrent()
53 * is called. In MakeCurrent() we can use a criteria like window size
54 * or window title to decide between CHROMIUM and NATIVE.
55 */
56typedef enum
57{
58 UNDECIDED,
59 CHROMIUM,
60 NATIVE
61} ContextType;
62
63#define MAX_DPY_NAME 1000
64
65typedef struct context_info_t ContextInfo;
66typedef struct window_info_t WindowInfo;
67
68#ifdef GLX
69typedef struct glxpixmap_info_t GLX_Pixmap_t;
70
71struct glxpixmap_info_t
72{
73 int x, y;
74 unsigned int w, h, border, depth;
75 GLenum format;
76 Window root;
77 GLenum target;
78 GC gc;
79 Pixmap hShmPixmap; /* Shared memory pixmap object, if it's supported*/
80 Damage hDamage; /* damage xserver handle*/
81 Bool bPixmapImageDirty;
82 Region pDamageRegion;
83};
84#endif
85
86struct context_info_t
87{
88 char dpyName[MAX_DPY_NAME];
89 GLint spuContext; /* returned by head SPU's CreateContext() */
90 ContextType type; /* CHROMIUM, NATIVE or UNDECIDED */
91 unsigned long id; /* the client-visible handle */
92 GLint visBits;
93 WindowInfo *currentDrawable;
94 WindowInfo *pOwnWindow; /* window created by first call to MakeCurrent with this context */
95#ifdef WINDOWS
96 HGLRC hglrc;
97#elif defined(DARWIN)
98 ContextInfo *share;
99 CGLContextObj cglc;
100
101 /* CGLContextEnable (CGLEnable, CGLDisable, and CGLIsEnabled) */
102 unsigned int options;
103
104 /* CGLContextParameter (CGLSetParameter and CGLGetParameter) */
105 GLint parambits;
106 long swap_rect[4], swap_interval;
107 unsigned long client_storage;
108 long surf_order, surf_opacy;
109
110 long disp_mask;
111#elif defined(GLX)
112 Display *dpy;
113 ContextInfo *share;
114 XVisualInfo *visual;
115 Bool direct;
116 GLXContext glxContext;
117 CRHashTable *pGLXPixmapsHash;
118 Bool damageInitFailed;
119 Display *damageDpy; /* second display connection to read xdamage extension data */
120 int damageEventsBase;
121#endif
122};
123
124#ifdef DARWIN
125enum {
126 VISBIT_SWAP_RECT,
127 VISBIT_SWAP_INTERVAL,
128 VISBIT_CLIENT_STORAGE
129};
130#endif
131
132struct window_info_t
133{
134 char dpyName[MAX_DPY_NAME];
135 int x, y;
136 unsigned int width, height;
137 ContextType type;
138 GLint spuWindow; /* returned by head SPU's WindowCreate() */
139 GLboolean mapped;
140#ifdef WINDOWS
141 HDC drawable;
142 HRGN hVisibleRegion;
143 DWORD dmPelsWidth;
144 DWORD dmPelsHeight;
145 HWND hWnd;
146#elif defined(DARWIN)
147 CGSConnectionID connection;
148 CGSWindowID drawable;
149 CGSSurfaceID surface;
150#elif defined(GLX)
151 Display *dpy;
152 GLXDrawable drawable;
153 XRectangle *pVisibleRegions;
154 GLint cVisibleRegions;
155#endif
156};
157
158/* "Global" variables for the stub library */
159typedef struct {
160 /* the first SPU in the SPU chain on this app node */
161 SPU *spu;
162
163 /* OpenGL/SPU dispatch tables */
164 crOpenGLInterface wsInterface;
165 SPUDispatchTable spuDispatch;
166 SPUDispatchTable nativeDispatch;
167 GLboolean haveNativeOpenGL;
168
169 /* config options */
170 int appDrawCursor;
171 GLuint minChromiumWindowWidth;
172 GLuint minChromiumWindowHeight;
173 GLuint maxChromiumWindowWidth;
174 GLuint maxChromiumWindowHeight;
175 GLuint matchChromiumWindowCount;
176 GLuint matchChromiumWindowCounter;
177 GLuint *matchChromiumWindowID;
178 GLuint numIgnoreWindowID;
179 char *matchWindowTitle;
180 int ignoreFreeglutMenus;
181 int trackWindowSize;
182 int trackWindowPos;
183 int trackWindowVisibility;
184 int trackWindowVisibleRgn;
185 char *spu_dir;
186 int force_pbuffers;
187 int viewportHack;
188
189 /* thread safety stuff */
190 GLboolean threadSafe;
191#ifdef CHROMIUM_THREADSAFE
192 CRtsd dispatchTSD;
193 CRmutex mutex;
194#endif
195
196 CRpid mothershipPID;
197
198 /* contexts */
199 int freeContextNumber;
200 CRHashTable *contextTable;
201 ContextInfo *currentContext; /* may be NULL */
202
203 /* windows */
204 CRHashTable *windowTable;
205
206#ifdef GLX
207 /* Shared memory, used to transfer XServer pixmaps data into client memory */
208 XShmSegmentInfo xshmSI;
209 GLboolean bShmInitFailed;
210
211 CRHashTable *pGLXPixmapsHash;
212#endif
213
214#ifdef WINDOWS
215 HHOOK hMessageHook;
216#endif
217} Stub;
218
219
220extern Stub stub;
221extern DECLEXPORT(SPUDispatchTable) glim;
222extern SPUDispatchTable stubThreadsafeDispatch;
223extern DECLEXPORT(SPUDispatchTable) stubNULLDispatch;
224
225#if defined(GLX) || defined (WINDOWS)
226extern GLboolean stubUpdateWindowVisibileRegions(WindowInfo *pWindow);
227#endif
228
229#ifdef WINDOWS
230
231/* WGL versions */
232extern WindowInfo *stubGetWindowInfo( HDC drawable );
233
234extern void stubInstallWindowMessageHook();
235extern void stubUninstallWindowMessageHook();
236
237#elif defined(DARWIN)
238
239extern CGSConnectionID _CGSDefaultConnection(void);
240extern OSStatus CGSGetWindowLevel( CGSConnectionID cid, CGSWindowID wid, CGWindowLevel *level );
241extern OSStatus CGSSetWindowAlpha( const CGSConnectionID cid, CGSWindowID wid, float alpha );
242
243/* These don't seem to be included in the OSX glext.h ... */
244extern void glPointParameteri( GLenum pname, GLint param );
245extern void glPointParameteriv( GLenum pname, const GLint * param );
246
247extern WindowInfo *stubGetWindowInfo( CGSWindowID drawable );
248
249#elif defined(GLX)
250
251/* GLX versions */
252extern WindowInfo *stubGetWindowInfo( Display *dpy, GLXDrawable drawable );
253extern void stubUseXFont( Display *dpy, Font font, int first, int count, int listbase );
254
255#endif
256
257
258extern ContextInfo *stubNewContext( const char *dpyName, GLint visBits, ContextType type, unsigned long shareCtx );
259extern void stubDestroyContext( unsigned long contextId );
260extern GLboolean stubMakeCurrent( WindowInfo *window, ContextInfo *context );
261extern GLint stubNewWindow( const char *dpyName, GLint visBits );
262extern void stubSwapBuffers( const WindowInfo *window, GLint flags );
263extern void stubGetWindowGeometry( const WindowInfo *win, int *x, int *y, unsigned int *w, unsigned int *h );
264extern GLboolean stubUpdateWindowGeometry(WindowInfo *pWindow, GLboolean bForceUpdate);
265extern GLboolean stubIsWindowVisible( const WindowInfo *win );
266extern bool stubInit(void);
267
268extern void APIENTRY stub_GetChromiumParametervCR( GLenum target, GLuint index, GLenum type, GLsizei count, GLvoid *values );
269
270extern void APIENTRY glBoundsInfoCR(const CRrecti *, const GLbyte *, GLint, GLint);
271
272#endif /* CR_STUB_H */
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette