VirtualBox

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

最後變更 在這個檔案從21077是 20616,由 vboxsync 提交於 15 年 前

crOpenGL: enable viewport hack for googleearth in d3d9 mode

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

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