Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(572)

Side by Side Diff: app/gfx/gl/generate_bindings.py

Issue 2134006: Added EGL based GLContext.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « app/app_base.gypi ('k') | app/gfx/gl/gl_bindings.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 #!/usr/bin/python
2 #
3 # Copyright (c) 2010 The Chromium Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file.
6
7 """code generator for GL/GLES extension wrangler."""
8
9 import os
10 import re
11 import sys
12
13 GL_FUNCTIONS = [
14 ['void', ['glActiveTexture'], 'GLenum texture'],
15 ['void', ['glAttachShader'], 'GLuint program, GLuint shader'],
16 ['void', ['glBindAttribLocation'],
17 'GLuint program, GLuint index, const char* name'],
18 ['void', ['glBindBuffer'], 'GLenum target, GLuint buffer'],
19 ['void', ['glBindFramebufferEXT', 'glBindFramebuffer'],
20 'GLenum target, GLuint framebuffer'],
21 ['void', ['glBindRenderbufferEXT', 'glBindRenderbuffer'],
22 'GLenum target, GLuint renderbuffer'],
23 ['void', ['glBindTexture'], 'GLenum target, GLuint texture'],
24 ['void', ['glBlendColor'],
25 'GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha'],
26 ['void', ['glBlendEquation'], ' GLenum mode '],
27 ['void', ['glBlendEquationSeparate'], 'GLenum modeRGB, GLenum modeAlpha'],
28 ['void', ['glBlendFunc'], 'GLenum sfactor, GLenum dfactor'],
29 ['void', ['glBlendFuncSeparate'],
30 'GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha'],
31 ['void', ['glBufferData'],
32 'GLenum target, GLsizei size, const void* data, GLenum usage'],
33 ['void', ['glBufferSubData'],
34 'GLenum target, GLint offset, GLsizei size, const void* data'],
35 ['GLenum', ['glCheckFramebufferStatusEXT',
36 'glCheckFramebufferStatus'], 'GLenum target'],
37 ['void', ['glClear'], 'GLbitfield mask'],
38 ['void', ['glClearColor'],
39 'GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha'],
40 ['void', ['glClearDepth'], 'GLclampd depth'],
41 ['void', ['glClearDepthf'], 'GLclampf depth'],
42 ['void', ['glClearStencil'], 'GLint s'],
43 ['void', ['glColorMask'],
44 'GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha'],
45 ['void', ['glCompileShader'], 'GLuint shader'],
46 ['void', ['glCompressedTexImage2D'],
47 'GLenum target, GLint level, GLenum internalformat, GLsizei width, '
48 'GLsizei height, GLint border, GLsizei imageSize, const void* data'],
49 ['void', ['glCompressedTexSubImage2D'],
50 'GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, '
51 'GLsizei height, GLenum format, GLsizei imageSize, const void* data'],
52 ['void', ['glCopyTexImage2D'],
53 'GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, '
54 'GLsizei width, GLsizei height, GLint border'],
55 ['void', ['glCopyTexSubImage2D'], 'GLenum target, GLint level, GLint xoffset, '
56 'GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height'],
57 ['GLuint', ['glCreateProgram'], 'void'],
58 ['GLuint', ['glCreateShader'], 'GLenum type'],
59 ['void', ['glCullFace'], 'GLenum mode'],
60 ['void', ['glDeleteBuffersARB', 'glDeleteBuffers'],
61 'GLsizei n, const GLuint* buffers'],
62 ['void', ['glDeleteFramebuffersEXT', 'glDeleteFramebuffers'],
63 'GLsizei n, const GLuint* framebuffers'],
64 ['void', ['glDeleteProgram'], 'GLuint program'],
65 ['void', ['glDeleteRenderbuffersEXT', 'glDeleteRenderbuffers'],
66 'GLsizei n, const GLuint* renderbuffers'],
67 ['void', ['glDeleteShader'], 'GLuint shader'],
68 ['void', ['glDeleteTextures'], 'GLsizei n, const GLuint* textures'],
69 ['void', ['glDepthFunc'], 'GLenum func'],
70 ['void', ['glDepthMask'], 'GLboolean flag'],
71 ['void', ['glDepthRange'], 'GLclampd zNear, GLclampd zFar'],
72 ['void', ['glDepthRangef'], 'GLclampf zNear, GLclampf zFar'],
73 ['void', ['glDetachShader'], 'GLuint program, GLuint shader'],
74 ['void', ['glDisable'], 'GLenum cap'],
75 ['void', ['glDisableVertexAttribArray'], 'GLuint index'],
76 ['void', ['glDrawArrays'], 'GLenum mode, GLint first, GLsizei count'],
77 ['void', ['glDrawElements'],
78 'GLenum mode, GLsizei count, GLenum type, const void* indices'],
79 ['void', ['glEnable'], 'GLenum cap'],
80 ['void', ['glEnableVertexAttribArray'], 'GLuint index'],
81 ['void', ['glFinish'], 'void'],
82 ['void', ['glFlush'], 'void'],
83 ['void', ['glFramebufferRenderbufferEXT', 'glFramebufferRenderbuffer'],
84 'GLenum target, GLenum attachment, GLenum renderbuffertarget, '
85 'GLuint renderbuffer'],
86 ['void', ['glFramebufferTexture2DEXT', 'glFramebufferTexture2D'],
87 'GLenum target, GLenum attachment, GLenum textarget, GLuint texture, '
88 'GLint level'],
89 ['void', ['glFrontFace'], 'GLenum mode'],
90 ['void', ['glGenBuffersARB', 'glGenBuffers'], 'GLsizei n, GLuint* buffers'],
91 ['void', ['glGenerateMipmapEXT', 'glGenerateMipmap'], 'GLenum target'],
92 ['void', ['glGenFramebuffersEXT', 'glGenFramebuffers'],
93 'GLsizei n, GLuint* framebuffers'],
94 ['void', ['glGenRenderbuffersEXT', 'glGenRenderbuffers'],
95 'GLsizei n, GLuint* renderbuffers'],
96 ['void', ['glGenTextures'], 'GLsizei n, GLuint* textures'],
97 ['void', ['glGetActiveAttrib'],
98 'GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, '
99 'GLint* size, GLenum* type, char* name'],
100 ['void', ['glGetActiveUniform'],
101 'GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, '
102 'GLint* size, GLenum* type, char* name'],
103 ['void', ['glGetAttachedShaders'],
104 'GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders'],
105 ['GLint', ['glGetAttribLocation'], 'GLuint program, const char* name'],
106 ['void', ['glGetBooleanv'], 'GLenum pname, GLboolean* params'],
107 ['void', ['glGetBufferParameteriv'], 'GLenum target, GLenum pname, GLint* params '],
108 ['GLenum', ['glGetError'], 'void'],
109 ['void', ['glGetFloatv'], 'GLenum pname, GLfloat* params'],
110 ['void', ['glGetFramebufferAttachmentParameterivEXT',
111 'glGetFramebufferAttachmentParameteriv'], 'GLenum target, '
112 'GLenum attachment, GLenum pname, GLint* params'],
113 ['void', ['glGetIntegerv'], 'GLenum pname, GLint* params'],
114 ['void', ['glGetProgramiv'], 'GLuint program, GLenum pname, GLint* params'],
115 ['void', ['glGetProgramInfoLog'],
116 'GLuint program, GLsizei bufsize, GLsizei* length, char* infolog'],
117 ['void', ['glGetRenderbufferParameterivEXT', 'glGetRenderbufferParameteriv'],
118 'GLenum target, GLenum pname, GLint* params'],
119 ['void', ['glGetShaderiv'], 'GLuint shader, GLenum pname, GLint* params'],
120 ['void', ['glGetShaderInfoLog'],
121 'GLuint shader, GLsizei bufsize, GLsizei* length, char* infolog'],
122 ['void', ['glGetShaderPrecisionFormat'],
123 'GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision'],
124 ['void', ['glGetShaderSource'],
125 'GLuint shader, GLsizei bufsize, GLsizei* length, char* source'],
126 ['const GLubyte*', ['glGetString'], 'GLenum name'],
127 ['void', ['glGetTexParameterfv'],
128 'GLenum target, GLenum pname, GLfloat* params'],
129 ['void', ['glGetTexParameteriv'], 'GLenum target, GLenum pname, GLint* params'],
130 ['void', ['glGetUniformfv'], 'GLuint program, GLint location, GLfloat* params'],
131 ['void', ['glGetUniformiv'], 'GLuint program, GLint location, GLint* params'],
132 ['GLint', ['glGetUniformLocation'], 'GLuint program, const char* name'],
133 ['void', ['glGetVertexAttribfv'],
134 'GLuint index, GLenum pname, GLfloat* params'],
135 ['void', ['glGetVertexAttribiv'], 'GLuint index, GLenum pname, GLint* params'],
136 ['void', ['glGetVertexAttribPointerv'],
137 'GLuint index, GLenum pname, void** pointer'],
138 ['void', ['glHint'], 'GLenum target, GLenum mode'],
139 ['GLboolean', ['glIsBuffer'], 'GLuint buffer'],
140 ['GLboolean', ['glIsEnabled'], 'GLenum cap'],
141 ['GLboolean', ['glIsFramebuffer'], 'GLuint framebuffer'],
142 ['GLboolean', ['glIsProgram'], 'GLuint program'],
143 ['GLboolean', ['glIsRenderbuffer'], 'GLuint renderbuffer'],
144 ['GLboolean', ['glIsShader'], 'GLuint shader'],
145 ['GLboolean', ['glIsTexture'], 'GLuint texture'],
146 ['void', ['glLineWidth'], 'GLfloat width'],
147 ['void', ['glLinkProgram'], 'GLuint program'],
148 ['void', ['glPixelStorei'], 'GLenum pname, GLint param'],
149 ['void', ['glPolygonOffset'], 'GLfloat factor, GLfloat units'],
150 ['void', ['glReadPixels'],
151 'GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, '
152 'GLenum type, void* pixels'],
153 ['void', ['glReleaseShaderCompiler'], 'void'],
154 ['void', ['glRenderbufferStorageEXT', 'glRenderbufferStorage'],
155 'GLenum target, GLenum internalformat, GLsizei width, GLsizei height'],
156 ['void', ['glSampleCoverage'], 'GLclampf value, GLboolean invert'],
157 ['void', ['glScissor'], 'GLint x, GLint y, GLsizei width, GLsizei height'],
158 ['void', ['glShaderBinary'],
159 'GLsizei n, const GLuint* shaders, GLenum binaryformat, '
160 'const void* binary, GLsizei length'],
161 ['void', ['glShaderSource'],
162 'GLuint shader, GLsizei count, const char** str, const GLint* length'],
163 ['void', ['glStencilFunc'], 'GLenum func, GLint ref, GLuint mask'],
164 ['void', ['glStencilFuncSeparate'],
165 'GLenum face, GLenum func, GLint ref, GLuint mask'],
166 ['void', ['glStencilMask'], 'GLuint mask'],
167 ['void', ['glStencilMaskSeparate'], 'GLenum face, GLuint mask'],
168 ['void', ['glStencilOp'], 'GLenum fail, GLenum zfail, GLenum zpass'],
169 ['void', ['glStencilOpSeparate'],
170 'GLenum face, GLenum fail, GLenum zfail, GLenum zpass'],
171 ['void', ['glTexImage2D'],
172 'GLenum target, GLint level, GLint internalformat, GLsizei width, '
173 'GLsizei height, GLint border, GLenum format, GLenum type, '
174 'const void* pixels'],
175 ['void', ['glTexParameterf'], 'GLenum target, GLenum pname, GLfloat param'],
176 ['void', ['glTexParameterfv'],
177 'GLenum target, GLenum pname, const GLfloat* params'],
178 ['void', ['glTexParameteri'], 'GLenum target, GLenum pname, GLint param'],
179 ['void', ['glTexParameteriv'],
180 'GLenum target, GLenum pname, const GLint* params'],
181 ['void', ['glTexSubImage2D'],
182 'GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, '
183 'GLsizei height, GLenum format, GLenum type, const void* pixels'],
184 ['void', ['glUniform1f'], 'GLint location, GLfloat x'],
185 ['void', ['glUniform1fv'], 'GLint location, GLsizei count, const GLfloat* v'],
186 ['void', ['glUniform1i'], 'GLint location, GLint x'],
187 ['void', ['glUniform1iv'], 'GLint location, GLsizei count, const GLint* v'],
188 ['void', ['glUniform2f'], 'GLint location, GLfloat x, GLfloat y'],
189 ['void', ['glUniform2fv'], 'GLint location, GLsizei count, const GLfloat* v'],
190 ['void', ['glUniform2i'], 'GLint location, GLint x, GLint y'],
191 ['void', ['glUniform2iv'], 'GLint location, GLsizei count, const GLint* v'],
192 ['void', ['glUniform3f'], 'GLint location, GLfloat x, GLfloat y, GLfloat z'],
193 ['void', ['glUniform3fv'], 'GLint location, GLsizei count, const GLfloat* v'],
194 ['void', ['glUniform3i'], 'GLint location, GLint x, GLint y, GLint z'],
195 ['void', ['glUniform3iv'], 'GLint location, GLsizei count, const GLint* v'],
196 ['void', ['glUniform4f'],
197 'GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w'],
198 ['void', ['glUniform4fv'], 'GLint location, GLsizei count, const GLfloat* v'],
199 ['void', ['glUniform4i'], 'GLint location, GLint x, GLint y, GLint z, GLint w'],
200 ['void', ['glUniform4iv'], 'GLint location, GLsizei count, const GLint* v'],
201 ['void', ['glUniformMatrix2fv'],
202 'GLint location, GLsizei count, GLboolean transpose, const GLfloat* value'],
203 ['void', ['glUniformMatrix3fv'],
204 'GLint location, GLsizei count, GLboolean transpose, const GLfloat* value'],
205 ['void', ['glUniformMatrix4fv'],
206 'GLint location, GLsizei count, GLboolean transpose, const GLfloat* value'],
207 ['void', ['glUseProgram'], 'GLuint program'],
208 ['void', ['glValidateProgram'], 'GLuint program'],
209 ['void', ['glVertexAttrib1f'], 'GLuint indx, GLfloat x'],
210 ['void', ['glVertexAttrib1fv'], 'GLuint indx, const GLfloat* values'],
211 ['void', ['glVertexAttrib2f'], 'GLuint indx, GLfloat x, GLfloat y'],
212 ['void', ['glVertexAttrib2fv'], 'GLuint indx, const GLfloat* values'],
213 ['void', ['glVertexAttrib3f'], 'GLuint indx, GLfloat x, GLfloat y, GLfloat z'],
214 ['void', ['glVertexAttrib3fv'], 'GLuint indx, const GLfloat* values'],
215 ['void', ['glVertexAttrib4f'],
216 'GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w'],
217 ['void', ['glVertexAttrib4fv'], 'GLuint indx, const GLfloat* values'],
218 ['void', ['glVertexAttribPointer'],
219 'GLuint indx, GLint size, GLenum type, GLboolean normalized, '
220 'GLsizei stride, const void* ptr'],
221 ['void', ['glViewport'], 'GLint x, GLint y, GLsizei width, GLsizei height'],
222 ]
223
224 OSMESA_FUNCTIONS = [
225 ['OSMesaContext', ['OSMesaCreateContext'],
226 'GLenum format, OSMesaContext sharelist'],
227 ['OSMesaContext', ['OSMesaCreateContextExt'],
228 'GLenum format, GLint depthBits, GLint stencilBits, GLint accumBits, '
229 'OSMesaContext sharelist'],
230 ['void', ['OSMesaDestroyContext'], 'OSMesaContext ctx'],
231 ['GLboolean', ['OSMesaMakeCurrent'],
232 'OSMesaContext ctx, void* buffer, GLenum type, GLsizei width, '
233 'GLsizei height'],
234 ['OSMesaContext', ['OSMesaGetCurrentContext'], 'void'],
235 ['void', ['OSMesaPixelStore'], 'GLint pname, GLint value'],
236 ['void', ['OSMesaGetIntegerv'], 'GLint pname, GLint* value'],
237 ['GLboolean', ['OSMesaGetDepthBuffer'],
238 'OSMesaContext c, GLint* width, GLint* height, GLint* bytesPerValue, '
239 'void** buffer'],
240 ['GLboolean', ['OSMesaGetColorBuffer'],
241 'OSMesaContext c, GLint* width, GLint* height, GLint* format, '
242 'void** buffer'],
243 ['OSMESAproc', ['OSMesaGetProcAddress'], 'const char* funcName'],
244 ['void', ['OSMesaColorClamp'], 'GLboolean enable'],
245 ]
246
247 EGL_FUNCTIONS = [
248 ['EGLint', ['eglGetError'], 'void'],
249 ['EGLDisplay', ['eglGetDisplay'], 'void* display_id'],
250 ['EGLBoolean', ['eglInitialize'],
251 'EGLDisplay dpy, EGLint* major, EGLint* minor'],
252 ['EGLBoolean', ['eglTerminate'], 'EGLDisplay dpy'],
253 ['const char*', ['eglQueryString'], 'EGLDisplay dpy, EGLint name'],
254 ['EGLBoolean', ['eglGetConfigs'],
255 'EGLDisplay dpy, EGLConfig* configs, EGLint config_size, '
256 'EGLint* num_config'],
257 ['EGLBoolean', ['eglChooseConfig'],
258 'EGLDisplay dpy, const EGLint* attrib_list, EGLConfig* configs, '
259 'EGLint config_size, EGLint* num_config'],
260 ['EGLBoolean', ['eglGetConfigAttrib'],
261 'EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint* value'],
262 ['EGLSurface', ['eglCreateWindowSurface'],
263 'EGLDisplay dpy, EGLConfig config, void* win, const EGLint* attrib_list'],
264 ['EGLSurface', ['eglCreatePbufferSurface'],
265 'EGLDisplay dpy, EGLConfig config, const EGLint* attrib_list'],
266 ['EGLSurface', ['eglCreatePixmapSurface'],
267 'EGLDisplay dpy, EGLConfig config, void* pixmap, '
268 'const EGLint* attrib_list'],
269 ['EGLBoolean', ['eglDestroySurface'], 'EGLDisplay dpy, EGLSurface surface'],
270 ['EGLBoolean', ['eglQuerySurface'],
271 'EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint* value'],
272 ['EGLBoolean', ['eglBindAPI'], 'EGLenum api'],
273 ['EGLenum', ['eglQueryAPI'], 'void'],
274 ['EGLBoolean', ['eglWaitClient'], 'void'],
275 ['EGLBoolean', ['eglReleaseThread'], 'void'],
276 ['EGLSurface', ['eglCreatePbufferFromClientBuffer'],
277 'EGLDisplay dpy, EGLenum buftype, void* buffer, EGLConfig config, '
278 'const EGLint* attrib_list'],
279 ['EGLBoolean', ['eglSurfaceAttrib'],
280 'EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint value'],
281 ['EGLBoolean', ['eglBindTexImage'],
282 'EGLDisplay dpy, EGLSurface surface, EGLint buffer'],
283 ['EGLBoolean', ['eglReleaseTexImage'],
284 'EGLDisplay dpy, EGLSurface surface, EGLint buffer'],
285 ['EGLBoolean', ['eglSwapInterval'], 'EGLDisplay dpy, EGLint interval'],
286 ['EGLContext', ['eglCreateContext'],
287 'EGLDisplay dpy, EGLConfig config, EGLContext share_context, '
288 'const EGLint* attrib_list'],
289 ['EGLBoolean', ['eglDestroyContext'], 'EGLDisplay dpy, EGLContext ctx'],
290 ['EGLBoolean', ['eglMakeCurrent'],
291 'EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx'],
292 ['EGLContext', ['eglGetCurrentContext'], 'void'],
293 ['EGLSurface', ['eglGetCurrentSurface'], 'EGLint readdraw'],
294 ['EGLDisplay', ['eglGetCurrentDisplay'], 'void'],
295 ['EGLBoolean', ['eglQueryContext'],
296 'EGLDisplay dpy, EGLContext ctx, EGLint attribute, EGLint* value'],
297 ['EGLBoolean', ['eglWaitGL'], 'void'],
298 ['EGLBoolean', ['eglWaitNative'], 'EGLint engine'],
299 ['EGLBoolean', ['eglSwapBuffers'], 'EGLDisplay dpy, EGLSurface surface'],
300 ['EGLBoolean', ['eglCopyBuffers'],
301 'EGLDisplay dpy, EGLSurface surface, void* target'],
302 ['__eglMustCastToProperFunctionPointerType', ['eglGetProcAddress'],
303 'const char* procname'],
304 ]
305
306 WGL_FUNCTIONS = [
307 ['HGLRC', ['wglCreateContext'], 'HDC hdc'],
308 ['HGLRC', ['wglCreateLayerContext'], 'HDC hdc, int iLayerPlane'],
309 ['BOOL', ['wglCopyContext'], 'HGLRC hglrcSrc, HGLRC hglrcDst, UINT mask'],
310 ['BOOL', ['wglDeleteContext'], 'HGLRC hglrc'],
311 ['HGLRC', ['wglGetCurrentContext'], ''],
312 ['HDC', ['wglGetCurrentDC'], ''],
313 ['BOOL', ['wglMakeCurrent'], 'HDC hdc, HGLRC hglrc'],
314 ['BOOL', ['wglShareLists'], 'HGLRC hglrc1, HGLRC hglrc2'],
315 ['BOOL', ['wglSwapLayerBuffers'], 'HDC hdc, UINT fuPlanes'],
316 ['const char*', ['wglGetExtensionsStringARB', 'wglGetExtensionsStringEXT'],
317 'HDC hDC'],
318 ['BOOL', ['wglChoosePixelFormatARB'],
319 'HDC dc, const int* int_attrib_list, const float* float_attrib_list, '
320 'UINT max_formats, int* formats, UINT* num_formats'],
321 ['HPBUFFERARB', ['wglCreatePbufferARB'],
322 'HDC hDC, int iPixelFormat, int iWidth, int iHeight, '
323 'const int* piAttribList'],
324 ['HDC', ['wglGetPbufferDCARB'], 'HPBUFFERARB hPbuffer'],
325 ['int', ['wglReleasePbufferDCARB'], 'HPBUFFERARB hPbuffer, HDC hDC'],
326 ['BOOL', ['wglDestroyPbufferARB'], 'HPBUFFERARB hPbuffer'],
327 ['BOOL', ['wglQueryPbufferARB'],
328 'HPBUFFERARB hPbuffer, int iAttribute, int* piValue'],
329 ]
330
331 GLX_FUNCTIONS = [
332 ['XVisualInfo*', ['glXChooseVisual'],
333 'Display* dpy, int screen, int* attribList'],
334 ['GLXContext', ['glXCreateContext'],
335 'Display* dpy, XVisualInfo* vis, GLXContext shareList, int direct'],
336 ['void', ['glXDestroyContext'], 'Display* dpy, GLXContext ctx'],
337 ['int', ['glXMakeCurrent'],
338 'Display* dpy, GLXDrawable drawable, GLXContext ctx'],
339 ['void', ['glXCopyContext'],
340 'Display* dpy, GLXContext src, GLXContext dst, unsigned long mask'],
341 ['void', ['glXSwapBuffers'], 'Display* dpy, GLXDrawable drawable'],
342 ['GLXPixmap', ['glXCreateGLXPixmap'],
343 'Display* dpy, XVisualInfo* visual, Pixmap pixmap'],
344 ['void', ['glXDestroyGLXPixmap'], 'Display* dpy, GLXPixmap pixmap'],
345 ['int', ['glXQueryExtension'], 'Display* dpy, int* errorb, int* event'],
346 ['int', ['glXQueryVersion'], 'Display* dpy, int* maj, int* min'],
347 ['int', ['glXIsDirect'], 'Display* dpy, GLXContext ctx'],
348 ['int', ['glXGetConfig'],
349 'Display* dpy, XVisualInfo* visual, int attrib, int* value'],
350 ['GLXContext', ['glXGetCurrentContext'], 'void'],
351 ['GLXDrawable', ['glXGetCurrentDrawable'], 'void'],
352 ['void', ['glXWaitGL'], 'void'],
353 ['void', ['glXWaitX'], 'void'],
354 ['void', ['glXUseXFont'], 'Font font, int first, int count, int list'],
355 ['const char*', ['glXQueryExtensionsString'], 'Display* dpy, int screen'],
356 ['const char*', ['glXQueryServerString'], 'Display* dpy, int screen, int name'],
357 ['const char*', ['glXGetClientString'], 'Display* dpy, int name'],
358 ['Display*', ['glXGetCurrentDisplay'], 'void'],
359 ['GLXFBConfig*', ['glXChooseFBConfig'],
360 'Display* dpy, int screen, const int* attribList, int* nitems'],
361 ['int', ['glXGetFBConfigAttrib'],
362 'Display* dpy, GLXFBConfig config, int attribute, int* value'],
363 ['GLXFBConfig*', ['glXGetFBConfigs'],
364 'Display* dpy, int screen, int* nelements'],
365 ['XVisualInfo*', ['glXGetVisualFromFBConfig'],
366 'Display* dpy, GLXFBConfig config'],
367 ['GLXWindow', ['glXCreateWindow'],
368 'Display* dpy, GLXFBConfig config, Window win, const int* attribList'],
369 ['void', ['glXDestroyWindow'], 'Display* dpy, GLXWindow window'],
370 ['GLXPixmap', ['glXCreatePixmap'],
371 'Display* dpy, GLXFBConfig config, Pixmap pixmap, const int* attribList'],
372 ['void', ['glXDestroyPixmap'], 'Display* dpy, GLXPixmap pixmap'],
373 ['GLXPbuffer', ['glXCreatePbuffer'],
374 'Display* dpy, GLXFBConfig config, const int* attribList'],
375 ['void', ['glXDestroyPbuffer'], 'Display* dpy, GLXPbuffer pbuf'],
376 ['void', ['glXQueryDrawable'],
377 'Display* dpy, GLXDrawable draw, int attribute, unsigned int* value'],
378 ['GLXContext', ['glXCreateNewContext'],
379 'Display* dpy, GLXFBConfig config, int renderType, '
380 'GLXContext shareList, int direct'],
381 ['int', ['glXMakeContextCurrent'],
382 'Display* dpy, GLXDrawable draw, GLXDrawable read, GLXContext ctx'],
383 ['GLXDrawable', ['glXGetCurrentReadDrawable'], 'void'],
384 ['int', ['glXQueryContext'],
385 'Display* dpy, GLXContext ctx, int attribute, int* value'],
386 ['void', ['glXSelectEvent'],
387 'Display* dpy, GLXDrawable drawable, unsigned long mask'],
388 ['void', ['glXGetSelectedEvent'],
389 'Display* dpy, GLXDrawable drawable, unsigned long* mask'],
390 ]
391
392 FUNCTION_SETS = [
393 [GL_FUNCTIONS, 'gl'],
394 [OSMESA_FUNCTIONS, 'osmesa'],
395 [EGL_FUNCTIONS, 'egl'],
396 [WGL_FUNCTIONS, 'wgl'],
397 [GLX_FUNCTIONS, 'glx'],
398 ]
399
400 def GenerateHeader(file, functions, setName):
401 """Generates gl_binding_autogen_x.h"""
402
403 # Write file header.
404 file.write('// Copyright (c) 2010 The Chromium Authors. All rights reserved.\n ')
405 file.write('// Use of this source code is governed by a BSD-style license that can be\n')
406 file.write('// found in the LICENSE file.\n')
407 file.write('\n')
408 file.write('// This file is automatically generated.\n')
409 file.write('\n')
410 file.write('#ifndef APP_GFX_GL_GL_BINDINGS_AUTOGEN_%s_H_\n' % setName.upper())
411 file.write('#define APP_GFX_GL_GL_BINDINGS_AUTOGEN_%s_H_\n' % setName.upper())
412
413 # Write prototype for initialization function.
414 file.write('\n')
415 file.write('namespace gfx {\n')
416 file.write('\n')
417 file.write('void InitializeGLBindings%s();\n' % setName.upper())
418
419 # Write typedefs for function pointer types. Always use the GL name for the
420 # typedef.
421 file.write('\n')
422 for [returnType, names, arguments] in functions:
423 file.write('typedef %s (GL_BINDING_CALL *%sProc)(%s);\n' %
424 (returnType, names[0], arguments))
425
426 # Write declarations for function pointers. Always use the GL name for the
427 # declaration.
428 file.write('\n')
429 for [returnType, names, arguments] in functions:
430 file.write('extern %sProc g_%s;\n' % (names[0], names[0]))
431 file.write('\n')
432 file.write( '} // namespace gfx\n')
433
434 # Write macros to invoke function pointers. Always use the GL name for the
435 # macro.
436 file.write('\n')
437 for [returnType, names, arguments] in functions:
438 file.write('#define %s ::gfx::g_%s\n' %
439 (names[0], names[0]))
440
441 file.write('\n')
442 file.write('#endif // APP_GFX_GL_GL_BINDINGS_AUTOGEN_%s_H_\n' %
443 setName.upper())
444
445 def GenerateSource(file, functions, setName):
446 """Generates gl_binding_autogen_x.cc"""
447
448 # Write file header.
449 file.write('// Copyright (c) 2010 The Chromium Authors. All rights reserved.\n ')
450 file.write('// Use of this source code is governed by a BSD-style license that can be\n')
451 file.write('// found in the LICENSE file.\n')
452 file.write('\n')
453 file.write('// This file is automatically generated.\n')
454 file.write('\n')
455 file.write('#include "app/gfx/gl/gl_bindings.h"\n')
456 file.write('#include "app/gfx/gl/gl_implementation.h"\n')
457
458 # Write definitions of function pointers.
459 file.write('\n')
460 file.write('namespace gfx {\n')
461 file.write('\n')
462 for [returnType, names, arguments] in functions:
463 file.write('%sProc g_%s;\n' % (names[0], names[0]))
464
465 # Write function to initialize the function pointers.
466 file.write('\n')
467 file.write('void InitializeGLBindings%s() {\n' % setName.upper())
468 for [returnType, names, arguments] in functions:
469 for name in names:
470 file.write(' if (!g_%s)\n' % names[0])
471 file.write(
472 ' g_%s = reinterpret_cast<%sProc>(GetGLProcAddress("%s"));\n' %
473 (names[0], names[0], name))
474 file.write('}\n')
475 file.write('\n')
476 file.write( '} // namespace gfx\n')
477
478 def GenerateMockSource(file, functions):
479 """Generates functions that invoke a mock GLInterface"""
480
481 file.write('// Copyright (c) 2010 The Chromium Authors. All rights reserved.\n ')
482 file.write('// Use of this source code is governed by a BSD-style license that can be\n')
483 file.write('// found in the LICENSE file.\n')
484 file.write('\n')
485 file.write('// This file is automatically generated.\n')
486 file.write('\n')
487 file.write('#include <string.h>\n')
488 file.write('\n')
489 file.write('#include "app/gfx/gl/gl_interface.h"\n')
490
491 file.write('\n')
492 file.write('namespace gfx {\n')
493
494 # Write function that trampoline into the GLInterface.
495 for [returnType, names, arguments] in functions:
496 file.write('\n')
497 file.write('%s GL_BINDING_CALL Mock_%s(%s) {\n' %
498 (returnType, names[0], arguments))
499 argumentNames = re.sub(r'(const )?[a-zA-Z0-9]+\** ([a-zA-Z0-9]+)', r'\2',
500 arguments)
501 if argumentNames == 'void':
502 argumentNames = ''
503 functionName = names[0][2:]
504 if returnType == 'void':
505 file.write(' GLInterface::GetGLInterface()->%s(%s);\n' %
506 (functionName, argumentNames))
507 else:
508 file.write(' return GLInterface::GetGLInterface()->%s(%s);\n' %
509 (functionName, argumentNames))
510 file.write('}\n')
511
512 # Write a function to lookup a mock GL function based on its name.
513 file.write('\n')
514 file.write('void* GL_BINDING_CALL GetMockGLProcAddress(const char* name) {\n')
515 for [returnType, names, arguments] in functions:
516 file.write(' if (strcmp(name, "%s") == 0)\n' % names[0])
517 file.write(' return reinterpret_cast<void*>(Mock_%s);\n' % names[0])
518 file.write(' return NULL;\n')
519 file.write('}\n');
520
521 file.write('\n')
522 file.write('} // namespace gfx\n')
523
524 def main(argv):
525 """This is the main function."""
526
527 if len(argv) >= 1:
528 dir = argv[0]
529 else:
530 dir = '.'
531
532 for [functions, setName] in FUNCTION_SETS:
533 headerFile = open(
534 os.path.join(dir, 'gl_bindings_autogen_%s.h' % setName), 'wb')
535 GenerateHeader(headerFile, functions, setName)
536 headerFile.close()
537
538 sourceFile = open(
539 os.path.join(dir, 'gl_bindings_autogen_%s.cc' % setName), 'wb')
540 GenerateSource(sourceFile, functions, setName)
541 sourceFile.close()
542
543 sourceFile = open(os.path.join(dir, 'gl_bindings_autogen_mock.cc'), 'wb')
544 GenerateMockSource(sourceFile, GL_FUNCTIONS)
545 sourceFile.close()
546
547 if __name__ == '__main__':
548 main(sys.argv[1:])
OLDNEW
« no previous file with comments | « app/app_base.gypi ('k') | app/gfx/gl/gl_bindings.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698