VirtualBox

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

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

crOpenGL: linux, fixes for compiz to work

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