VirtualBox

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

Last change on this file since 31520 was 30598, checked in by vboxsync, 15 years ago

crOpenGL: enable new tracking code for solaris

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 8.2 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#if defined(WINDOWS) || defined(Linux) || defined(SunOS)
49# define CR_NEWWINTRACK
50#endif
51
52#if !defined(CHROMIUM_THREADSAFE) && defined(CR_NEWWINTRACK)
53# error CHROMIUM_THREADSAFE have to be defined
54#endif
55
56#if 0 && defined(CR_NEWWINTRACK) && !defined(WINDOWS)
57#define XLOCK(dpy) XLockDisplay(dpy)
58#define XUNLOCK(dpy) XUnlockDisplay(dpy)
59#else
60#define XLOCK(dpy)
61#define XUNLOCK(dpy)
62#endif
63
64/* When we first create a rendering context we can't be sure whether
65 * it'll be handled by Chromium or as a native GLX/WGL context. So in
66 * CreateContext() we'll mark the ContextInfo object as UNDECIDED then
67 * switch it to either NATIVE or CHROMIUM the first time MakeCurrent()
68 * is called. In MakeCurrent() we can use a criteria like window size
69 * or window title to decide between CHROMIUM and NATIVE.
70 */
71typedef enum
72{
73 UNDECIDED,
74 CHROMIUM,
75 NATIVE
76} ContextType;
77
78#define MAX_DPY_NAME 1000
79
80typedef struct context_info_t ContextInfo;
81typedef struct window_info_t WindowInfo;
82
83#ifdef GLX
84typedef struct glxpixmap_info_t GLX_Pixmap_t;
85
86struct glxpixmap_info_t
87{
88 int x, y;
89 unsigned int w, h, border, depth;
90 GLenum format;
91 Window root;
92 GLenum target;
93 GC gc;
94 Pixmap hShmPixmap; /* Shared memory pixmap object, if it's supported*/
95 Damage hDamage; /* damage xserver handle*/
96 Bool bPixmapImageDirty;
97 Region pDamageRegion;
98};
99#endif
100
101struct context_info_t
102{
103 char dpyName[MAX_DPY_NAME];
104 GLint spuContext; /* returned by head SPU's CreateContext() */
105 ContextType type; /* CHROMIUM, NATIVE or UNDECIDED */
106 unsigned long id; /* the client-visible handle */
107 GLint visBits;
108 WindowInfo *currentDrawable;
109
110#ifdef WINDOWS
111 HGLRC hglrc;
112#elif defined(DARWIN)
113 ContextInfo *share;
114 CGLContextObj cglc;
115
116 /* CGLContextEnable (CGLEnable, CGLDisable, and CGLIsEnabled) */
117 unsigned int options;
118
119 /* CGLContextParameter (CGLSetParameter and CGLGetParameter) */
120 GLint parambits;
121 long swap_rect[4], swap_interval;
122 unsigned long client_storage;
123 long surf_order, surf_opacy;
124
125 long disp_mask;
126#elif defined(GLX)
127 Display *dpy;
128 ContextInfo *share;
129 XVisualInfo *visual;
130 Bool direct;
131 GLXContext glxContext;
132 CRHashTable *pGLXPixmapsHash;
133 Bool damageInitFailed;
134 Display *damageDpy; /* second display connection to read xdamage extension data */
135 int damageEventsBase;
136#endif
137};
138
139#ifdef DARWIN
140enum {
141 VISBIT_SWAP_RECT,
142 VISBIT_SWAP_INTERVAL,
143 VISBIT_CLIENT_STORAGE
144};
145#endif
146
147struct window_info_t
148{
149 char dpyName[MAX_DPY_NAME];
150 int x, y;
151 unsigned int width, height;
152 ContextType type;
153 GLint spuWindow; /* returned by head SPU's WindowCreate() */
154 ContextInfo *pOwner; /* ctx which created this window */
155 GLboolean mapped;
156#ifdef WINDOWS
157 HDC drawable;
158 HRGN hVisibleRegion;
159 DWORD dmPelsWidth;
160 DWORD dmPelsHeight;
161 HWND hWnd;
162#elif defined(DARWIN)
163 CGSConnectionID connection;
164 CGSWindowID drawable;
165 CGSSurfaceID surface;
166#elif defined(GLX)
167 Display *dpy;
168# ifdef CR_NEWWINTRACK
169 Display *syncDpy;
170# endif
171 GLXDrawable drawable;
172 XRectangle *pVisibleRegions;
173 GLint cVisibleRegions;
174#endif
175#ifdef CR_NEWWINTRACK
176 uint32_t u32ClientID;
177#endif
178};
179
180/* "Global" variables for the stub library */
181typedef struct {
182 /* the first SPU in the SPU chain on this app node */
183 SPU *spu;
184
185 /* OpenGL/SPU dispatch tables */
186 crOpenGLInterface wsInterface;
187 SPUDispatchTable spuDispatch;
188 SPUDispatchTable nativeDispatch;
189 GLboolean haveNativeOpenGL;
190
191 /* config options */
192 int appDrawCursor;
193 GLuint minChromiumWindowWidth;
194 GLuint minChromiumWindowHeight;
195 GLuint maxChromiumWindowWidth;
196 GLuint maxChromiumWindowHeight;
197 GLuint matchChromiumWindowCount;
198 GLuint matchChromiumWindowCounter;
199 GLuint *matchChromiumWindowID;
200 GLuint numIgnoreWindowID;
201 char *matchWindowTitle;
202 int ignoreFreeglutMenus;
203 int trackWindowSize;
204 int trackWindowPos;
205 int trackWindowVisibility;
206 int trackWindowVisibleRgn;
207 char *spu_dir;
208 int force_pbuffers;
209 int viewportHack;
210
211 /* thread safety stuff */
212 GLboolean threadSafe;
213#ifdef CHROMIUM_THREADSAFE
214 CRtsd dispatchTSD;
215 CRmutex mutex;
216#endif
217
218 CRpid mothershipPID;
219
220 /* contexts */
221 int freeContextNumber;
222 CRHashTable *contextTable;
223 ContextInfo *currentContext; /* may be NULL */
224
225 /* windows */
226 CRHashTable *windowTable;
227
228#ifdef GLX
229 /* Shared memory, used to transfer XServer pixmaps data into client memory */
230 XShmSegmentInfo xshmSI;
231 GLboolean bShmInitFailed;
232
233 CRHashTable *pGLXPixmapsHash;
234#endif
235
236#ifdef WINDOWS
237# ifndef CR_NEWWINTRACK
238 HHOOK hMessageHook;
239# endif
240#endif
241
242#ifdef CR_NEWWINTRACK
243 RTTHREAD hSyncThread;
244 bool volatile bShutdownSyncThread;
245#endif
246
247} Stub;
248
249
250extern Stub stub;
251extern DECLEXPORT(SPUDispatchTable) glim;
252extern SPUDispatchTable stubThreadsafeDispatch;
253extern DECLEXPORT(SPUDispatchTable) stubNULLDispatch;
254
255#if defined(GLX) || defined (WINDOWS)
256extern GLboolean stubUpdateWindowVisibileRegions(WindowInfo *pWindow);
257#endif
258
259#ifdef WINDOWS
260
261/* WGL versions */
262extern WindowInfo *stubGetWindowInfo( HDC drawable );
263
264extern void stubInstallWindowMessageHook();
265extern void stubUninstallWindowMessageHook();
266
267#elif defined(DARWIN)
268
269extern CGSConnectionID _CGSDefaultConnection(void);
270extern OSStatus CGSGetWindowLevel( CGSConnectionID cid, CGSWindowID wid, CGWindowLevel *level );
271extern OSStatus CGSSetWindowAlpha( const CGSConnectionID cid, CGSWindowID wid, float alpha );
272
273/* These don't seem to be included in the OSX glext.h ... */
274extern void glPointParameteri( GLenum pname, GLint param );
275extern void glPointParameteriv( GLenum pname, const GLint * param );
276
277extern WindowInfo *stubGetWindowInfo( CGSWindowID drawable );
278
279#elif defined(GLX)
280
281/* GLX versions */
282extern WindowInfo *stubGetWindowInfo( Display *dpy, GLXDrawable drawable );
283extern void stubUseXFont( Display *dpy, Font font, int first, int count, int listbase );
284extern Display* stubGetWindowDisplay(WindowInfo *pWindow);
285
286#endif
287
288
289extern ContextInfo *stubNewContext( const char *dpyName, GLint visBits, ContextType type, unsigned long shareCtx );
290extern void stubDestroyContext( unsigned long contextId );
291extern GLboolean stubMakeCurrent( WindowInfo *window, ContextInfo *context );
292extern GLint stubNewWindow( const char *dpyName, GLint visBits );
293extern void stubSwapBuffers(WindowInfo *window, GLint flags);
294extern void stubGetWindowGeometry(WindowInfo *win, int *x, int *y, unsigned int *w, unsigned int *h);
295extern GLboolean stubUpdateWindowGeometry(WindowInfo *pWindow, GLboolean bForceUpdate);
296extern GLboolean stubIsWindowVisible(WindowInfo *win);
297extern bool stubInit(void);
298
299extern void APIENTRY stub_GetChromiumParametervCR( GLenum target, GLuint index, GLenum type, GLsizei count, GLvoid *values );
300
301extern void APIENTRY glBoundsInfoCR(const CRrecti *, const GLbyte *, GLint, GLint);
302
303#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