VirtualBox

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

Last change on this file since 25250 was 24816, checked in by vboxsync, 15 years ago

crOpenGL: integrate fix for non ARGB textures and compiz

  • 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 GC gc;
78 Pixmap hShmPixmap; /* Shared memory pixmap object, if it's supported*/
79 Damage hDamage; /* damage xserver handle*/
80 Bool bPixmapImageDirty;
81 Region pDamageRegion;
82};
83#endif
84
85struct context_info_t
86{
87 char dpyName[MAX_DPY_NAME];
88 GLint spuContext; /* returned by head SPU's CreateContext() */
89 ContextType type; /* CHROMIUM, NATIVE or UNDECIDED */
90 unsigned long id; /* the client-visible handle */
91 GLint visBits;
92 WindowInfo *currentDrawable;
93 WindowInfo *pOwnWindow; /* window created by first call to MakeCurrent with this context */
94#ifdef WINDOWS
95 HGLRC hglrc;
96#elif defined(DARWIN)
97 ContextInfo *share;
98 CGLContextObj cglc;
99
100 /* CGLContextEnable (CGLEnable, CGLDisable, and CGLIsEnabled) */
101 unsigned int options;
102
103 /* CGLContextParameter (CGLSetParameter and CGLGetParameter) */
104 GLint parambits;
105 long swap_rect[4], swap_interval;
106 unsigned long client_storage;
107 long surf_order, surf_opacy;
108
109 long disp_mask;
110#elif defined(GLX)
111 Display *dpy;
112 ContextInfo *share;
113 XVisualInfo *visual;
114 Bool direct;
115 GLXContext glxContext;
116 CRHashTable *pGLXPixmapsHash;
117 Bool damageInitFailed;
118 Display *damageDpy; /* second display connection to read xdamage extension data */
119 int damageEventsBase;
120#endif
121};
122
123#ifdef DARWIN
124enum {
125 VISBIT_SWAP_RECT,
126 VISBIT_SWAP_INTERVAL,
127 VISBIT_CLIENT_STORAGE
128};
129#endif
130
131struct window_info_t
132{
133 char dpyName[MAX_DPY_NAME];
134 int x, y;
135 unsigned int width, height;
136 ContextType type;
137 GLint spuWindow; /* returned by head SPU's WindowCreate() */
138 GLboolean mapped;
139#ifdef WINDOWS
140 HDC drawable;
141 HRGN hVisibleRegion;
142 DWORD dmPelsWidth;
143 DWORD dmPelsHeight;
144 HWND hWnd;
145#elif defined(DARWIN)
146 CGSConnectionID connection;
147 CGSWindowID drawable;
148 CGSSurfaceID surface;
149#elif defined(GLX)
150 Display *dpy;
151 GLXDrawable drawable;
152 XRectangle *pVisibleRegions;
153 GLint cVisibleRegions;
154#endif
155};
156
157/* "Global" variables for the stub library */
158typedef struct {
159 /* the first SPU in the SPU chain on this app node */
160 SPU *spu;
161
162 /* OpenGL/SPU dispatch tables */
163 crOpenGLInterface wsInterface;
164 SPUDispatchTable spuDispatch;
165 SPUDispatchTable nativeDispatch;
166 GLboolean haveNativeOpenGL;
167
168 /* config options */
169 int appDrawCursor;
170 GLuint minChromiumWindowWidth;
171 GLuint minChromiumWindowHeight;
172 GLuint maxChromiumWindowWidth;
173 GLuint maxChromiumWindowHeight;
174 GLuint matchChromiumWindowCount;
175 GLuint matchChromiumWindowCounter;
176 GLuint *matchChromiumWindowID;
177 GLuint numIgnoreWindowID;
178 char *matchWindowTitle;
179 int ignoreFreeglutMenus;
180 int trackWindowSize;
181 int trackWindowPos;
182 int trackWindowVisibility;
183 int trackWindowVisibleRgn;
184 char *spu_dir;
185 int force_pbuffers;
186 int viewportHack;
187
188 /* thread safety stuff */
189 GLboolean threadSafe;
190#ifdef CHROMIUM_THREADSAFE
191 CRtsd dispatchTSD;
192 CRmutex mutex;
193#endif
194
195 CRpid mothershipPID;
196
197 /* contexts */
198 int freeContextNumber;
199 CRHashTable *contextTable;
200 ContextInfo *currentContext; /* may be NULL */
201
202 /* windows */
203 CRHashTable *windowTable;
204
205#ifdef GLX
206 /* Shared memory, used to transfer XServer pixmaps data into client memory */
207 XShmSegmentInfo xshmSI;
208 GLboolean bShmInitFailed;
209#endif
210
211#ifdef WINDOWS
212 HHOOK hMessageHook;
213#endif
214} Stub;
215
216
217extern Stub stub;
218extern DECLEXPORT(SPUDispatchTable) glim;
219extern SPUDispatchTable stubThreadsafeDispatch;
220extern DECLEXPORT(SPUDispatchTable) stubNULLDispatch;
221
222#if defined(GLX) || defined (WINDOWS)
223extern GLboolean stubUpdateWindowVisibileRegions(WindowInfo *pWindow);
224#endif
225
226#ifdef WINDOWS
227
228/* WGL versions */
229extern WindowInfo *stubGetWindowInfo( HDC drawable );
230
231extern void stubInstallWindowMessageHook();
232extern void stubUninstallWindowMessageHook();
233
234#elif defined(DARWIN)
235
236extern CGSConnectionID _CGSDefaultConnection(void);
237extern OSStatus CGSGetWindowLevel( CGSConnectionID cid, CGSWindowID wid, CGWindowLevel *level );
238extern OSStatus CGSSetWindowAlpha( const CGSConnectionID cid, CGSWindowID wid, float alpha );
239
240/* These don't seem to be included in the OSX glext.h ... */
241extern void glPointParameteri( GLenum pname, GLint param );
242extern void glPointParameteriv( GLenum pname, const GLint * param );
243
244extern WindowInfo *stubGetWindowInfo( CGSWindowID drawable );
245
246#elif defined(GLX)
247
248/* GLX versions */
249extern WindowInfo *stubGetWindowInfo( Display *dpy, GLXDrawable drawable );
250extern void stubUseXFont( Display *dpy, Font font, int first, int count, int listbase );
251
252#endif
253
254
255extern ContextInfo *stubNewContext( const char *dpyName, GLint visBits, ContextType type, unsigned long shareCtx );
256extern void stubDestroyContext( unsigned long contextId );
257extern GLboolean stubMakeCurrent( WindowInfo *window, ContextInfo *context );
258extern GLint stubNewWindow( const char *dpyName, GLint visBits );
259extern void stubSwapBuffers( const WindowInfo *window, GLint flags );
260extern void stubGetWindowGeometry( const WindowInfo *win, int *x, int *y, unsigned int *w, unsigned int *h );
261extern GLboolean stubUpdateWindowGeometry(WindowInfo *pWindow, GLboolean bForceUpdate);
262extern GLboolean stubIsWindowVisible( const WindowInfo *win );
263extern bool stubInit(void);
264
265extern void APIENTRY stub_GetChromiumParametervCR( GLenum target, GLuint index, GLenum type, GLsizei count, GLvoid *values );
266
267extern void APIENTRY glBoundsInfoCR(const CRrecti *, const GLbyte *, GLint, GLint);
268
269#endif /* CR_STUB_H */
Note: See TracBrowser for help on using the repository browser.

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