VirtualBox

source: vbox/trunk/src/VBox/Additions/WINNT/Graphics/crOpenGL/stub.h@ 16480

Last change on this file since 16480 was 16480, checked in by vboxsync, 16 years ago

crOpenGL: track visible regions on linux guests + some more exports

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 6.6 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_hash.h"
36#include "cr_process.h"
37#include "cr_spu.h"
38#include "cr_threads.h"
39#include "spu_dispatch_table.h"
40
41
42/* When we first create a rendering context we can't be sure whether
43 * it'll be handled by Chromium or as a native GLX/WGL context. So in
44 * CreateContext() we'll mark the ContextInfo object as UNDECIDED then
45 * switch it to either NATIVE or CHROMIUM the first time MakeCurrent()
46 * is called. In MakeCurrent() we can use a criteria like window size
47 * or window title to decide between CHROMIUM and NATIVE.
48 */
49typedef enum
50{
51 UNDECIDED,
52 CHROMIUM,
53 NATIVE
54} ContextType;
55
56#define MAX_DPY_NAME 1000
57
58typedef struct context_info_t ContextInfo;
59typedef struct window_info_t WindowInfo;
60
61struct context_info_t
62{
63 char dpyName[MAX_DPY_NAME];
64 GLint spuContext; /* returned by head SPU's CreateContext() */
65 ContextType type; /* CHROMIUM, NATIVE or UNDECIDED */
66 unsigned long id; /* the client-visible handle */
67 GLint visBits;
68 WindowInfo *currentDrawable;
69 WindowInfo *pOwnWindow; /* window created by first call to MakeCurrent with this context */
70#ifdef WINDOWS
71 HGLRC hglrc;
72#elif defined(DARWIN)
73 ContextInfo *share;
74 CGLContextObj cglc;
75
76 /* CGLContextEnable (CGLEnable, CGLDisable, and CGLIsEnabled) */
77 unsigned int options;
78
79 /* CGLContextParameter (CGLSetParameter and CGLGetParameter) */
80 GLint parambits;
81 long swap_rect[4], swap_interval;
82 unsigned long client_storage;
83 long surf_order, surf_opacy;
84
85 long disp_mask;
86#elif defined(GLX)
87 Display *dpy;
88 ContextInfo *share;
89 XVisualInfo *visual;
90 Bool direct;
91 GLXContext glxContext;
92#endif
93};
94
95#ifdef DARWIN
96enum {
97 VISBIT_SWAP_RECT,
98 VISBIT_SWAP_INTERVAL,
99 VISBIT_CLIENT_STORAGE
100};
101#endif
102
103struct window_info_t
104{
105 char dpyName[MAX_DPY_NAME];
106 int x, y;
107 unsigned int width, height;
108 ContextType type;
109 GLint spuWindow; /* returned by head SPU's WindowCreate() */
110 GLboolean mapped;
111#ifdef WINDOWS
112 HDC drawable;
113 HRGN hVisibleRegion;
114 DWORD dmPelsWidth;
115 DWORD dmPelsHeight;
116 HWND hWnd;
117#elif defined(DARWIN)
118 CGSConnectionID connection;
119 CGSWindowID drawable;
120 CGSSurfaceID surface;
121#elif defined(GLX)
122 Display *dpy;
123 GLXDrawable drawable;
124 XRectangle *pVisibleRegions;
125 GLint cVisibleRegions;
126#endif
127};
128
129/* "Global" variables for the stub library */
130typedef struct {
131 /* the first SPU in the SPU chain on this app node */
132 SPU *spu;
133
134 /* OpenGL/SPU dispatch tables */
135 crOpenGLInterface wsInterface;
136 SPUDispatchTable spuDispatch;
137 SPUDispatchTable nativeDispatch;
138 GLboolean haveNativeOpenGL;
139
140 /* config options */
141 int appDrawCursor;
142 GLuint minChromiumWindowWidth;
143 GLuint minChromiumWindowHeight;
144 GLuint maxChromiumWindowWidth;
145 GLuint maxChromiumWindowHeight;
146 GLuint matchChromiumWindowCount;
147 GLuint matchChromiumWindowCounter;
148 GLuint *matchChromiumWindowID;
149 GLuint numIgnoreWindowID;
150 char *matchWindowTitle;
151 int ignoreFreeglutMenus;
152 int trackWindowSize;
153 int trackWindowPos;
154 int trackWindowVisibility;
155 int trackWindowVisibleRgn;
156 char *spu_dir;
157 int force_pbuffers;
158
159 /* thread safety stuff */
160 GLboolean threadSafe;
161#ifdef CHROMIUM_THREADSAFE
162 CRtsd dispatchTSD;
163 CRmutex mutex;
164#endif
165
166 CRpid mothershipPID;
167
168 /* contexts */
169 int freeContextNumber;
170 CRHashTable *contextTable;
171 ContextInfo *currentContext; /* may be NULL */
172
173 /* windows */
174 CRHashTable *windowTable;
175
176#ifdef WINDOWS
177 HHOOK hMessageHook;
178#endif
179} Stub;
180
181
182extern Stub stub;
183extern DECLEXPORT(SPUDispatchTable) glim;
184extern SPUDispatchTable stubThreadsafeDispatch;
185extern DECLEXPORT(SPUDispatchTable) stubNULLDispatch;
186
187#if defined(GLX) || defined (WINDOWS)
188extern GLboolean stubUpdateWindowVisibileRegions(WindowInfo *pWindow);
189#endif
190
191#ifdef WINDOWS
192
193/* WGL versions */
194extern WindowInfo *stubGetWindowInfo( HDC drawable );
195
196extern void stubInstallWindowMessageHook();
197extern void stubUninstallWindowMessageHook();
198
199#elif defined(DARWIN)
200
201extern CGSConnectionID _CGSDefaultConnection(void);
202extern OSStatus CGSGetWindowLevel( CGSConnectionID cid, CGSWindowID wid, CGWindowLevel *level );
203extern OSStatus CGSSetWindowAlpha( const CGSConnectionID cid, CGSWindowID wid, float alpha );
204
205/* These don't seem to be included in the OSX glext.h ... */
206extern void glPointParameteri( GLenum pname, GLint param );
207extern void glPointParameteriv( GLenum pname, const GLint * param );
208
209extern WindowInfo *stubGetWindowInfo( CGSWindowID drawable );
210
211#elif defined(GLX)
212
213/* GLX versions */
214extern WindowInfo *stubGetWindowInfo( Display *dpy, GLXDrawable drawable );
215extern void stubUseXFont( Display *dpy, Font font, int first, int count, int listbase );
216
217#endif
218
219
220extern ContextInfo *stubNewContext( const char *dpyName, GLint visBits, ContextType type, unsigned long shareCtx );
221extern void stubDestroyContext( unsigned long contextId );
222extern GLboolean stubMakeCurrent( WindowInfo *window, ContextInfo *context );
223extern GLint stubNewWindow( const char *dpyName, GLint visBits );
224extern void stubSwapBuffers( const WindowInfo *window, GLint flags );
225extern void stubGetWindowGeometry( const WindowInfo *win, int *x, int *y, unsigned int *w, unsigned int *h );
226extern GLboolean stubUpdateWindowGeometry(WindowInfo *pWindow, GLboolean bForceUpdate);
227extern GLboolean stubIsWindowVisible( const WindowInfo *win );
228extern bool stubInit(void);
229
230extern void APIENTRY stub_GetChromiumParametervCR( GLenum target, GLuint index, GLenum type, GLsizei count, GLvoid *values );
231
232extern void APIENTRY glBoundsInfoCR(const CRrecti *, const GLbyte *, GLint, GLint);
233
234#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