VirtualBox

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

最後變更 在這個檔案從34418是 34295,由 vboxsync 提交於 14 年 前

crOpenGL/wddm: more strict window info tracking

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

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