VirtualBox

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

Last change on this file since 29041 was 26909, checked in by vboxsync, 15 years ago

crOpenGL: fix flickering when opengl context is used with multiply windows

  • 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
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 ContextInfo *pOwner; /* ctx which created this window */
140 GLboolean mapped;
141#ifdef WINDOWS
142 HDC drawable;
143 HRGN hVisibleRegion;
144 DWORD dmPelsWidth;
145 DWORD dmPelsHeight;
146 HWND hWnd;
147#elif defined(DARWIN)
148 CGSConnectionID connection;
149 CGSWindowID drawable;
150 CGSSurfaceID surface;
151#elif defined(GLX)
152 Display *dpy;
153 GLXDrawable drawable;
154 XRectangle *pVisibleRegions;
155 GLint cVisibleRegions;
156#endif
157};
158
159/* "Global" variables for the stub library */
160typedef struct {
161 /* the first SPU in the SPU chain on this app node */
162 SPU *spu;
163
164 /* OpenGL/SPU dispatch tables */
165 crOpenGLInterface wsInterface;
166 SPUDispatchTable spuDispatch;
167 SPUDispatchTable nativeDispatch;
168 GLboolean haveNativeOpenGL;
169
170 /* config options */
171 int appDrawCursor;
172 GLuint minChromiumWindowWidth;
173 GLuint minChromiumWindowHeight;
174 GLuint maxChromiumWindowWidth;
175 GLuint maxChromiumWindowHeight;
176 GLuint matchChromiumWindowCount;
177 GLuint matchChromiumWindowCounter;
178 GLuint *matchChromiumWindowID;
179 GLuint numIgnoreWindowID;
180 char *matchWindowTitle;
181 int ignoreFreeglutMenus;
182 int trackWindowSize;
183 int trackWindowPos;
184 int trackWindowVisibility;
185 int trackWindowVisibleRgn;
186 char *spu_dir;
187 int force_pbuffers;
188 int viewportHack;
189
190 /* thread safety stuff */
191 GLboolean threadSafe;
192#ifdef CHROMIUM_THREADSAFE
193 CRtsd dispatchTSD;
194 CRmutex mutex;
195#endif
196
197 CRpid mothershipPID;
198
199 /* contexts */
200 int freeContextNumber;
201 CRHashTable *contextTable;
202 ContextInfo *currentContext; /* may be NULL */
203
204 /* windows */
205 CRHashTable *windowTable;
206
207#ifdef GLX
208 /* Shared memory, used to transfer XServer pixmaps data into client memory */
209 XShmSegmentInfo xshmSI;
210 GLboolean bShmInitFailed;
211
212 CRHashTable *pGLXPixmapsHash;
213#endif
214
215#ifdef WINDOWS
216 HHOOK hMessageHook;
217#endif
218} Stub;
219
220
221extern Stub stub;
222extern DECLEXPORT(SPUDispatchTable) glim;
223extern SPUDispatchTable stubThreadsafeDispatch;
224extern DECLEXPORT(SPUDispatchTable) stubNULLDispatch;
225
226#if defined(GLX) || defined (WINDOWS)
227extern GLboolean stubUpdateWindowVisibileRegions(WindowInfo *pWindow);
228#endif
229
230#ifdef WINDOWS
231
232/* WGL versions */
233extern WindowInfo *stubGetWindowInfo( HDC drawable );
234
235extern void stubInstallWindowMessageHook();
236extern void stubUninstallWindowMessageHook();
237
238#elif defined(DARWIN)
239
240extern CGSConnectionID _CGSDefaultConnection(void);
241extern OSStatus CGSGetWindowLevel( CGSConnectionID cid, CGSWindowID wid, CGWindowLevel *level );
242extern OSStatus CGSSetWindowAlpha( const CGSConnectionID cid, CGSWindowID wid, float alpha );
243
244/* These don't seem to be included in the OSX glext.h ... */
245extern void glPointParameteri( GLenum pname, GLint param );
246extern void glPointParameteriv( GLenum pname, const GLint * param );
247
248extern WindowInfo *stubGetWindowInfo( CGSWindowID drawable );
249
250#elif defined(GLX)
251
252/* GLX versions */
253extern WindowInfo *stubGetWindowInfo( Display *dpy, GLXDrawable drawable );
254extern void stubUseXFont( Display *dpy, Font font, int first, int count, int listbase );
255
256#endif
257
258
259extern ContextInfo *stubNewContext( const char *dpyName, GLint visBits, ContextType type, unsigned long shareCtx );
260extern void stubDestroyContext( unsigned long contextId );
261extern GLboolean stubMakeCurrent( WindowInfo *window, ContextInfo *context );
262extern GLint stubNewWindow( const char *dpyName, GLint visBits );
263extern void stubSwapBuffers( const WindowInfo *window, GLint flags );
264extern void stubGetWindowGeometry( const WindowInfo *win, int *x, int *y, unsigned int *w, unsigned int *h );
265extern GLboolean stubUpdateWindowGeometry(WindowInfo *pWindow, GLboolean bForceUpdate);
266extern GLboolean stubIsWindowVisible( const WindowInfo *win );
267extern bool stubInit(void);
268
269extern void APIENTRY stub_GetChromiumParametervCR( GLenum target, GLuint index, GLenum type, GLsizei count, GLvoid *values );
270
271extern void APIENTRY glBoundsInfoCR(const CRrecti *, const GLbyte *, GLint, GLint);
272
273#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