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

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

Issue 8936011: Log GLenums as strings in service (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add back execute permission for py file Created 9 years 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 | « gpu/gpu.gyp ('k') | ui/gfx/gl/gl.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2011 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """code generator for GL/GLES extension wrangler.""" 6 """code generator for GL/GLES extension wrangler."""
7 7
8 import os 8 import os
9 import collections 9 import collections
10 import re 10 import re
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 'GLbitfield mask, GLenum filter', }, 70 'GLbitfield mask, GLenum filter', },
71 { 'return_type': 'void', 71 { 'return_type': 'void',
72 'names': ['glBufferData'], 72 'names': ['glBufferData'],
73 'arguments': 'GLenum target, GLsizei size, const void* data, GLenum usage', }, 73 'arguments': 'GLenum target, GLsizei size, const void* data, GLenum usage', },
74 { 'return_type': 'void', 74 { 'return_type': 'void',
75 'names': ['glBufferSubData'], 75 'names': ['glBufferSubData'],
76 'arguments': 'GLenum target, GLint offset, GLsizei size, const void* data', }, 76 'arguments': 'GLenum target, GLint offset, GLsizei size, const void* data', },
77 { 'return_type': 'GLenum', 77 { 'return_type': 'GLenum',
78 'names': ['glCheckFramebufferStatusEXT', 78 'names': ['glCheckFramebufferStatusEXT',
79 'glCheckFramebufferStatus'], 79 'glCheckFramebufferStatus'],
80 'arguments': 'GLenum target', }, 80 'arguments': 'GLenum target',
81 'logging_code': """
82 GL_SERVICE_LOG("GL_RESULT: " << GLES2Util::GetStringEnum(result));
83 """, },
81 { 'return_type': 'void', 84 { 'return_type': 'void',
82 'names': ['glClear'], 85 'names': ['glClear'],
83 'arguments': 'GLbitfield mask', }, 86 'arguments': 'GLbitfield mask', },
84 { 'return_type': 'void', 87 { 'return_type': 'void',
85 'names': ['glClearColor'], 88 'names': ['glClearColor'],
86 'arguments': 'GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha', }, 89 'arguments': 'GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha', },
87 { 'return_type': 'void', 90 { 'return_type': 'void',
88 'names': ['glClearDepth'], 91 'names': ['glClearDepth'],
89 'arguments': 'GLclampd depth', }, 92 'arguments': 'GLclampd depth', },
90 { 'return_type': 'void', 93 { 'return_type': 'void',
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 'names': ['glGetAttribLocation'], 255 'names': ['glGetAttribLocation'],
253 'arguments': 'GLuint program, const char* name', }, 256 'arguments': 'GLuint program, const char* name', },
254 { 'return_type': 'void', 257 { 'return_type': 'void',
255 'names': ['glGetBooleanv'], 258 'names': ['glGetBooleanv'],
256 'arguments': 'GLenum pname, GLboolean* params', }, 259 'arguments': 'GLenum pname, GLboolean* params', },
257 { 'return_type': 'void', 260 { 'return_type': 'void',
258 'names': ['glGetBufferParameteriv'], 261 'names': ['glGetBufferParameteriv'],
259 'arguments': 'GLenum target, GLenum pname, GLint* params', }, 262 'arguments': 'GLenum target, GLenum pname, GLint* params', },
260 { 'return_type': 'GLenum', 263 { 'return_type': 'GLenum',
261 'names': ['glGetError'], 264 'names': ['glGetError'],
262 'arguments': 'void', }, 265 'arguments': 'void',
266 'logging_code': """
267 GL_SERVICE_LOG("GL_RESULT: " << GLES2Util::GetStringError(result));
268 """, },
263 { 'return_type': 'void', 269 { 'return_type': 'void',
264 'names': ['glGetFloatv'], 270 'names': ['glGetFloatv'],
265 'arguments': 'GLenum pname, GLfloat* params', }, 271 'arguments': 'GLenum pname, GLfloat* params', },
266 { 'return_type': 'void', 272 { 'return_type': 'void',
267 'names': ['glGetFramebufferAttachmentParameterivEXT', 273 'names': ['glGetFramebufferAttachmentParameterivEXT',
268 'glGetFramebufferAttachmentParameteriv'], 274 'glGetFramebufferAttachmentParameteriv'],
269 'arguments': 'GLenum target, ' 275 'arguments': 'GLenum target, '
270 'GLenum attachment, GLenum pname, GLint* params', }, 276 'GLenum attachment, GLenum pname, GLint* params', },
271 { 'return_type': 'GLenum', 277 { 'return_type': 'GLenum',
272 'names': ['glGetGraphicsResetStatusARB'], 278 'names': ['glGetGraphicsResetStatusARB'],
(...skipping 801 matching lines...) Expand 10 before | Expand all | Expand 10 after
1074 """Generates gl_binding_autogen_x.cc""" 1080 """Generates gl_binding_autogen_x.cc"""
1075 1081
1076 # Write file header. 1082 # Write file header.
1077 file.write('// Copyright (c) 2011 The Chromium Authors. All rights reserved.\n ') 1083 file.write('// Copyright (c) 2011 The Chromium Authors. All rights reserved.\n ')
1078 file.write('// Use of this source code is governed by a BSD-style license that can be\n') 1084 file.write('// Use of this source code is governed by a BSD-style license that can be\n')
1079 file.write('// found in the LICENSE file.\n') 1085 file.write('// found in the LICENSE file.\n')
1080 file.write('\n') 1086 file.write('\n')
1081 file.write('// This file is automatically generated.\n') 1087 file.write('// This file is automatically generated.\n')
1082 file.write('\n') 1088 file.write('\n')
1083 file.write('#include <string>\n') 1089 file.write('#include <string>\n')
1090 file.write('#include "gpu/command_buffer/common/gles2_cmd_utils.h"\n')
1084 file.write('#include "ui/gfx/gl/gl_bindings.h"\n') 1091 file.write('#include "ui/gfx/gl/gl_bindings.h"\n')
1085 file.write('#include "ui/gfx/gl/gl_context.h"\n') 1092 file.write('#include "ui/gfx/gl/gl_context.h"\n')
1086 file.write('#include "ui/gfx/gl/gl_implementation.h"\n') 1093 file.write('#include "ui/gfx/gl/gl_implementation.h"\n')
1087 1094
1088 # Write definitions for booleans indicating which extensions are available. 1095 # Write definitions for booleans indicating which extensions are available.
1089 file.write('\n') 1096 file.write('\n')
1097 file.write('using gpu::gles2::GLES2Util;\n')
1098 file.write('\n')
1090 file.write('namespace gfx {\n') 1099 file.write('namespace gfx {\n')
1091 file.write('\n') 1100 file.write('\n')
1092 for extension, ext_functions in used_extension_functions: 1101 for extension, ext_functions in used_extension_functions:
1093 file.write('bool g_%s;\n' % extension) 1102 file.write('bool g_%s;\n' % extension)
1094 1103
1095 # Write definitions of function pointers. 1104 # Write definitions of function pointers.
1096 file.write('\n') 1105 file.write('\n')
1097 file.write('static bool g_debugBindingsInitialized;\n') 1106 file.write('static bool g_debugBindingsInitialized;\n')
1098 file.write('static void UpdateDebugGLExtensionBindings();\n') 1107 file.write('static void UpdateDebugGLExtensionBindings();\n')
1099 file.write('\n') 1108 file.write('\n')
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
1158 argument_names = re.sub( 1167 argument_names = re.sub(
1159 r'(const )?[a-zA-Z0-9_]+\** ([a-zA-Z0-9_]+)', r'\2', arguments) 1168 r'(const )?[a-zA-Z0-9_]+\** ([a-zA-Z0-9_]+)', r'\2', arguments)
1160 argument_names = re.sub( 1169 argument_names = re.sub(
1161 r'(const )?[a-zA-Z0-9_]+\** ([a-zA-Z0-9_]+)', r'\2', argument_names) 1170 r'(const )?[a-zA-Z0-9_]+\** ([a-zA-Z0-9_]+)', r'\2', argument_names)
1162 log_argument_names = re.sub( 1171 log_argument_names = re.sub(
1163 r'const char\* ([a-zA-Z0-9_]+)', r'CONSTCHAR_\1', arguments) 1172 r'const char\* ([a-zA-Z0-9_]+)', r'CONSTCHAR_\1', arguments)
1164 log_argument_names = re.sub( 1173 log_argument_names = re.sub(
1165 r'(const )?[a-zA-Z0-9_]+\* ([a-zA-Z0-9_]+)', 1174 r'(const )?[a-zA-Z0-9_]+\* ([a-zA-Z0-9_]+)',
1166 r'CONSTVOID_\2', log_argument_names) 1175 r'CONSTVOID_\2', log_argument_names)
1167 log_argument_names = re.sub( 1176 log_argument_names = re.sub(
1177 r'(?<!E)GLenum ([a-zA-Z0-9_]+)', r'GLenum_\1', log_argument_names)
1178 log_argument_names = re.sub(
1168 r'(const )?[a-zA-Z0-9_]+\** ([a-zA-Z0-9_]+)', r'\2', 1179 r'(const )?[a-zA-Z0-9_]+\** ([a-zA-Z0-9_]+)', r'\2',
1169 log_argument_names) 1180 log_argument_names)
1170 log_argument_names = re.sub( 1181 log_argument_names = re.sub(
1171 r'(const )?[a-zA-Z0-9_]+\** ([a-zA-Z0-9_]+)', r'\2', 1182 r'(const )?[a-zA-Z0-9_]+\** ([a-zA-Z0-9_]+)', r'\2',
1172 log_argument_names) 1183 log_argument_names)
1173 log_argument_names = re.sub( 1184 log_argument_names = re.sub(
1174 r'CONSTVOID_([a-zA-Z0-9_]+)', 1185 r'CONSTVOID_([a-zA-Z0-9_]+)',
1175 r'static_cast<const void*>(\1)', log_argument_names); 1186 r'static_cast<const void*>(\1)', log_argument_names);
1176 log_argument_names = re.sub( 1187 log_argument_names = re.sub(
1177 r'CONSTCHAR_([a-zA-Z0-9_]+)', r'\1', log_argument_names); 1188 r'CONSTCHAR_([a-zA-Z0-9_]+)', r'\1', log_argument_names);
1178 log_argument_names = log_argument_names.replace(',', ' << ", " <<'); 1189 log_argument_names = re.sub(
1190 r'GLenum_([a-zA-Z0-9_]+)', r'GLES2Util::GetStringEnum(\1)',
1191 log_argument_names)
1192 log_argument_names = log_argument_names.replace(',', ' << ", " <<')
1179 if argument_names == 'void' or argument_names == '': 1193 if argument_names == 'void' or argument_names == '':
1180 argument_names = '' 1194 argument_names = ''
1181 log_argument_names = '' 1195 log_argument_names = ''
1182 else: 1196 else:
1183 log_argument_names = " << " + log_argument_names 1197 log_argument_names = " << " + log_argument_names
1184 function_name = names[0] 1198 function_name = names[0]
1185 if return_type == 'void': 1199 if return_type == 'void':
1186 file.write(' GL_SERVICE_LOG("%s" << "(" %s << ")");\n' % 1200 file.write(' GL_SERVICE_LOG("%s" << "(" %s << ")");\n' %
1187 (function_name, log_argument_names)) 1201 (function_name, log_argument_names))
1188 file.write(' g_debug_%s(%s);\n' % 1202 file.write(' g_debug_%s(%s);\n' %
1189 (function_name, argument_names)) 1203 (function_name, argument_names))
1204 if 'logging_code' in func:
1205 file.write("%s\n" % func['logging_code'])
1190 else: 1206 else:
1191 file.write(' GL_SERVICE_LOG("%s" << "(" %s << ")");\n' % 1207 file.write(' GL_SERVICE_LOG("%s" << "(" %s << ")");\n' %
1192 (function_name, log_argument_names)) 1208 (function_name, log_argument_names))
1193 file.write(' %s result = g_debug_%s(%s);\n' % 1209 file.write(' %s result = g_debug_%s(%s);\n' %
1194 (return_type, function_name, argument_names)) 1210 (return_type, function_name, argument_names))
1195 file.write(' GL_SERVICE_LOG("GL_RESULT: " << result);\n'); 1211 if 'logging_code' in func:
1212 file.write("%s\n" % func['logging_code'])
1213 else:
1214 file.write(' GL_SERVICE_LOG("GL_RESULT: " << result);\n');
1196 file.write(' return result;\n') 1215 file.write(' return result;\n')
1197 if 'logging_code' in func:
1198 file.write("%s\n" % func['logging_code'])
1199 file.write('}\n') 1216 file.write('}\n')
1200 file.write('} // extern "C"\n') 1217 file.write('} // extern "C"\n')
1201 1218
1202 # Write function to initialize the debug function pointers. 1219 # Write function to initialize the debug function pointers.
1203 file.write('\n') 1220 file.write('\n')
1204 file.write('void InitializeDebugGLBindings%s() {\n' % set_name.upper()) 1221 file.write('void InitializeDebugGLBindings%s() {\n' % set_name.upper())
1205 for func in functions: 1222 for func in functions:
1206 first_name = func['names'][0] 1223 first_name = func['names'][0]
1207 file.write(' if (!g_debug_%s) {\n' % first_name) 1224 file.write(' if (!g_debug_%s) {\n' % first_name)
1208 file.write(' g_debug_%s = g_%s;\n' % (first_name, first_name)) 1225 file.write(' g_debug_%s = g_%s;\n' % (first_name, first_name))
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
1439 source_file.close() 1456 source_file.close()
1440 1457
1441 source_file = open(os.path.join(dir, 'gl_bindings_autogen_mock.cc'), 'wb') 1458 source_file = open(os.path.join(dir, 'gl_bindings_autogen_mock.cc'), 'wb')
1442 GenerateMockSource(source_file, GL_FUNCTIONS) 1459 GenerateMockSource(source_file, GL_FUNCTIONS)
1443 source_file.close() 1460 source_file.close()
1444 return 0 1461 return 0
1445 1462
1446 1463
1447 if __name__ == '__main__': 1464 if __name__ == '__main__':
1448 sys.exit(main(sys.argv[1:])) 1465 sys.exit(main(sys.argv[1:]))
OLDNEW
« no previous file with comments | « gpu/gpu.gyp ('k') | ui/gfx/gl/gl.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698