-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcr_glwrapper.h
More file actions
executable file
·372 lines (283 loc) · 9.03 KB
/
cr_glwrapper.h
File metadata and controls
executable file
·372 lines (283 loc) · 9.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
/* Copyright (c) 2001, Stanford University
* All rights reserved.
*
* See the file LICENSE.txt for information on redistributing this software.
*/
/* Chromium sources include this file instead of including
* the GL/gl.h and GL/glext.h headers directly.
*/
#ifndef CR_GLWRAPPER_H
#define CR_GLWRAPPER_H
#ifdef WINDOWS
#define WIN32_LEAN_AND_MEAN
#define WGL_APIENTRY __stdcall
#include <windows.h>
#else
#include <GL/glx.h>
#endif
#include <GL/gl.h>
#include <GL/glext.h>
#ifdef __cplusplus
extern "C" {
#endif
#ifndef WINDOWS
typedef void (*CR_GLXFuncPtr)();
CR_GLXFuncPtr glXGetProcAddressARB( const GLubyte *name );
#endif
/*
* Define some OpenGL 1.2 tokens in case we're using an old gl.h header.
*/
#ifndef GL_SMOOTH_POINT_SIZE_RANGE
#define GL_SMOOTH_POINT_SIZE_RANGE 0x0B12
#endif
#ifndef GL_SMOOTH_POINT_SIZE_GRANULARITY
#define GL_SMOOTH_POINT_SIZE_GRANULARITY 0x0B13
#endif
#ifndef GL_SMOOTH_LINE_WIDTH_RANGE
#define GL_SMOOTH_LINE_WIDTH_RANGE 0x0B22
#endif
#ifndef GL_SMOOTH_LINE_WIDTH_GRANULARITY
#define GL_SMOOTH_LINE_WIDTH_GRANULARITY 0x0B23
#endif
#ifndef GL_ALIASED_POINT_SIZE_RANGE
#define GL_ALIASED_POINT_SIZE_RANGE 0x846D
#endif
#ifndef GL_ALIASED_LINE_WIDTH_RANGE
#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E
#endif
#ifndef GL_COLOR_MATRIX_STACK_DEPTH
#define GL_COLOR_MATRIX_STACK_DEPTH 0x80B2
#endif
#ifndef GL_COLOR_MATRIX
#define GL_COLOR_MATRIX 0x80B1
#endif
#ifndef GL_TEXTURE_3D
#define GL_TEXTURE_3D 0x806F
#endif
#ifndef GL_MAX_3D_TEXTURE_SIZE
#define GL_MAX_3D_TEXTURE_SIZE 0x8073
#endif
#ifndef GL_PACK_SKIP_IMAGES
#define GL_PACK_SKIP_IMAGES 0x806B
#endif
#ifndef GL_PACK_IMAGE_HEIGHT
#define GL_PACK_IMAGE_HEIGHT 0x806C
#endif
#ifndef GL_UNPACK_SKIP_IMAGES
#define GL_UNPACK_SKIP_IMAGES 0x806D
#endif
#ifndef GL_UNPACK_IMAGE_HEIGHT
#define GL_UNPACK_IMAGE_HEIGHT 0x806E
#endif
#ifndef GL_PROXY_TEXTURE_3D
#define GL_PROXY_TEXTURE_3D 0x8070
#endif
#ifndef GL_TEXTURE_DEPTH
#define GL_TEXTURE_DEPTH 0x8071
#endif
#ifndef GL_TEXTURE_WRAP_R
#define GL_TEXTURE_WRAP_R 0x8072
#endif
#ifndef GL_TEXTURE_BINDING_3D
#define GL_TEXTURE_BINDING_3D 0x806A
#endif
#ifndef GL_MAX_ELEMENTS_VERTICES
#define GL_MAX_ELEMENTS_VERTICES 0x80E8
#endif
#ifndef GL_MAX_ELEMENTS_INDICES
#define GL_MAX_ELEMENTS_INDICES 0x80E9
#endif
/*
* Tokens for OpenGL 1.2's ARB_imaging subset
*/
#ifndef GL_BLEND_EQUATION
#define GL_BLEND_EQUATION 0x8009
#endif
#ifndef GL_MIN
#define GL_MIN 0x8007
#endif
#ifndef GL_MAX
#define GL_MAX 0x8008
#endif
#ifndef GL_FUNC_ADD
#define GL_FUNC_ADD 0x8006
#endif
#ifndef GL_FUNC_SUBTRACT
#define GL_FUNC_SUBTRACT 0x800A
#endif
#ifndef GL_FUNC_REVERSE_SUBTRACT
#define GL_FUNC_REVERSE_SUBTRACT 0x800B
#endif
#ifndef GL_BLEND_COLOR
#define GL_BLEND_COLOR 0x8005
#endif
#ifndef GL_PER_STAGE_CONSTANTS_NV
#define GL_PER_STAGE_CONSTANTS_NV 0x8535
#endif
/*
* Chromium extensions
*/
#ifndef GL_CR_cursor_position
#define GL_CR_cursor_position 1
/* For virtual cursor feature (show_cursor) */
#define GL_CURSOR_POSITION_CR 0x9900 /* unofficial! */
#endif /* GL_CR_cursor_position */
#ifndef GL_CR_bounding_box
#define GL_CR_bounding_box 1
/* To set bounding box from client app */
#define GL_DEFAULT_BBOX_CR 0x9901 /* unofficial! */
#define GL_SCREEN_BBOX_CR 0x9902 /* unofficial! */
#define GL_OBJECT_BBOX_CR 0x9903 /* unofficial! */
#endif /* GL_CR_bounding_box */
#ifndef GL_CR_print_string
#define GL_CR_print_string 1
/* To print a string to stdout */
#define GL_PRINT_STRING_CR 0x9904 /* unofficial! */
#endif /* GL_CR_print_string */
#ifndef GL_CR_tilesort_info
#define GL_CR_tilesort_info 1
/* To query tilesort information */
#define GL_MURAL_SIZE_CR 0x9905 /* unofficial! */
#define GL_NUM_SERVERS_CR 0x9906 /* unofficial! */
#define GL_NUM_TILES_CR 0x9907 /* unofficial! */
#define GL_TILE_BOUNDS_CR 0x9908 /* unofficial! */
#define GL_VERTEX_COUNTS_CR 0x9909 /* unofficial! */
#define GL_RESET_VERTEX_COUNTERS_CR 0x990A /* unofficial! */
#define GL_SET_MAX_VIEWPORT_CR 0x990B /* unofficial! */
#endif /* GL_CR_tilesort_info */
#ifndef GL_CR_head_spu_name
#define GL_CR_head_spu_name 1
/* To fetch name of first SPU on a node */
#define GL_HEAD_SPU_NAME_CR 0x990C /* unofficial! */
#endif /* GL_CR_head_spu_name */
#ifndef GL_CR_performance_info
#define GL_CR_performance_info 1
/* For gathering performance metrics */
#define GL_PERF_GET_FRAME_DATA_CR 0x990D /* unofficial! */
#define GL_PERF_GET_TIMER_DATA_CR 0x990E /* unofficial! */
#define GL_PERF_DUMP_COUNTERS_CR 0x990F /* unofficial! */
#define GL_PERF_SET_TOKEN_CR 0x9910 /* unofficial! */
#define GL_PERF_SET_DUMP_ON_SWAP_CR 0x9911 /* unofficial! */
#define GL_PERF_SET_DUMP_ON_FINISH_CR 0x9912 /* unofficial! */
#define GL_PERF_SET_DUMP_ON_FLUSH_CR 0x9913 /* unofficial! */
#define GL_PERF_START_TIMER_CR 0x9914 /* unofficial! */
#define GL_PERF_STOP_TIMER_CR 0x9915 /* unofficial! */
#endif /* GL_CR_performance_info */
#ifndef GL_CR_window_size
#define GL_CR_window_size 1
/* To communicate window size changes */
#define GL_WINDOW_SIZE_CR 0x9920 /* unofficial! */
#endif /* GL_CR_window_size */
#ifndef GL_CR_tile_info
#define GL_CR_tile_info 1
/* To send new tile information to a server */
#define GL_TILE_INFO_CR 0x9921 /* unofficial! */
#endif /* GL_CR_tile_info */
/*
* These are the OpenGL / window system interface functions
*/
#ifdef WINDOWS
typedef HGLRC (WGL_APIENTRY *wglCreateContextFunc_t)(HDC);
typedef void (WGL_APIENTRY *wglDeleteContextFunc_t)(HGLRC);
typedef BOOL (WGL_APIENTRY *wglMakeCurrentFunc_t)(HDC,HGLRC);
typedef BOOL (WGL_APIENTRY *wglSwapBuffersFunc_t)(HDC);
typedef int (WGL_APIENTRY *wglChoosePixelFormatFunc_t)(HDC, CONST PIXELFORMATDESCRIPTOR *);
typedef int (WGL_APIENTRY *wglSetPixelFormatFunc_t)(HDC, int, CONST PIXELFORMATDESCRIPTOR *);
typedef HGLRC (WGL_APIENTRY *wglGetCurrentContextFunc_t)();
typedef PROC (WGL_APIENTRY *wglGetProcAddressFunc_t)();
typedef const GLubyte *(WGL_APIENTRY *glGetStringFunc_t)( GLenum );
#else
typedef int (*glXGetConfigFunc_t)( Display *, XVisualInfo *, int, int * );
typedef Bool (*glXQueryExtensionFunc_t) (Display *, int *, int * );
typedef XVisualInfo *(*glXChooseVisualFunc_t)( Display *, int, int * );
typedef GLXContext (*glXCreateContextFunc_t)( Display *, XVisualInfo *, GLXContext, Bool );
typedef void (*glXDestroyContextFunc_t)( Display *, GLXContext );
typedef Bool (*glXIsDirectFunc_t)( Display *, GLXContext );
typedef Bool (*glXMakeCurrentFunc_t)( Display *, GLXDrawable, GLXContext );
typedef void (*glXSwapBuffersFunc_t)( Display *, GLXDrawable );
typedef CR_GLXFuncPtr (*glXGetProcAddressARBFunc_t)( const GLubyte *name );
typedef Display *(*glXGetCurrentDisplayFunc_t)( void );
typedef const GLubyte *(*glGetStringFunc_t)( GLenum );
#endif
/*
* Package up the WGL/GLX function pointers into a struct. We use
* this in a few different places.
*/
typedef struct {
#ifdef WINDOWS
wglGetProcAddressFunc_t wglGetProcAddress;
wglCreateContextFunc_t wglCreateContext;
wglDeleteContextFunc_t wglDeleteContext;
wglMakeCurrentFunc_t wglMakeCurrent;
wglSwapBuffersFunc_t wglSwapBuffers;
wglGetCurrentContextFunc_t wglGetCurrentContext;
wglChoosePixelFormatFunc_t wglChoosePixelFormat;
wglSetPixelFormatFunc_t wglSetPixelFormat;
#else
glXGetConfigFunc_t glXGetConfig;
glXQueryExtensionFunc_t glXQueryExtension;
glXChooseVisualFunc_t glXChooseVisual;
glXCreateContextFunc_t glXCreateContext;
glXDestroyContextFunc_t glXDestroyContext;
glXIsDirectFunc_t glXIsDirect;
glXMakeCurrentFunc_t glXMakeCurrent;
glXSwapBuffersFunc_t glXSwapBuffers;
glXGetProcAddressARBFunc_t glXGetProcAddressARB;
glXGetCurrentDisplayFunc_t glXGetCurrentDisplay;
#endif
glGetStringFunc_t glGetString;
} crOpenGLInterface;
/* Used to communicate visual attributes throughout Chromium */
#define CR_RGB_BIT 0x1
#define CR_ALPHA_BIT 0x2
#define CR_DEPTH_BIT 0x4
#define CR_STENCIL_BIT 0x8
#define CR_ACCUM_BIT 0x10
#define CR_DOUBLE_BIT 0x20
#define CR_STEREO_BIT 0x40
#define CR_MULTISAMPLE_BIT 0x80
#define CR_MAX_CONTEXTS 512
#define CR_MAX_BITARRAY (CR_MAX_CONTEXTS / 32) /* 32 contexts per uint */
#define MAX_THREADS 32 /* max threads per spu */
/* Function inlining */
#if defined(__GNUC__)
# define INLINE __inline__
#elif defined(__MSC__)
# define INLINE __inline
#elif defined(_MSC_VER)
# define INLINE __inline
#elif defined(__ICL)
# define INLINE __inline
#else
# define INLINE
#endif
static INLINE void DIRTY( unsigned int *b, const unsigned int *d )
{
int j;
for (j=0;j<CR_MAX_BITARRAY;j++)
b[j] = d[j];
}
static INLINE void FILLDIRTY( unsigned int *b )
{
int j;
for (j=0;j<CR_MAX_BITARRAY;j++)
b[j] = 0xffffffff;
}
static INLINE void INVERTDIRTY( unsigned int *b, const unsigned int *d )
{
int j;
for (j=0;j<CR_MAX_BITARRAY;j++)
b[j] &= d[j];
}
static INLINE int CHECKDIRTY( const unsigned int *b, const unsigned int *d )
{
int j;
for (j=0;j<CR_MAX_BITARRAY;j++)
if (b[j] & d[j])
return 1;
return 0;
}
#ifdef __cplusplus
}
#endif
#endif /* CR_GLWRAPPER_H */