OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 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 1170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1181 (first_name, first_name, name)) | 1181 (first_name, first_name, name)) |
1182 file.write('}\n') | 1182 file.write('}\n') |
1183 file.write('\n') | 1183 file.write('\n') |
1184 | 1184 |
1185 # Write function to initialize the extension function pointers. This function | 1185 # Write function to initialize the extension function pointers. This function |
1186 # uses a current context to query which extensions are actually supported. | 1186 # uses a current context to query which extensions are actually supported. |
1187 file.write('void InitializeGLExtensionBindings%s(GLContext* context) {\n' % | 1187 file.write('void InitializeGLExtensionBindings%s(GLContext* context) {\n' % |
1188 set_name.upper()) | 1188 set_name.upper()) |
1189 file.write(' DCHECK(context && context->IsCurrent(NULL));\n') | 1189 file.write(' DCHECK(context && context->IsCurrent(NULL));\n') |
1190 for extension, ext_functions in used_extension_functions: | 1190 for extension, ext_functions in used_extension_functions: |
1191 file.write(' if ((g_%s = context->HasExtension("%s"))) {\n' % | 1191 file.write(' g_%s = context->HasExtension("%s");\n' % |
1192 (extension, extension)) | 1192 (extension, extension)) |
| 1193 file.write(' if (g_%s) {\n' % |
| 1194 (extension)) |
1193 queried_entry_points = set() | 1195 queried_entry_points = set() |
1194 for entry_point_name, function_name in ext_functions: | 1196 for entry_point_name, function_name in ext_functions: |
1195 # Replace the pointer unconditionally unless this extension has several | 1197 # Replace the pointer unconditionally unless this extension has several |
1196 # alternatives for the same entry point (e.g., | 1198 # alternatives for the same entry point (e.g., |
1197 # GL_ARB_blend_func_extended). | 1199 # GL_ARB_blend_func_extended). |
1198 if entry_point_name in queried_entry_points: | 1200 if entry_point_name in queried_entry_points: |
1199 file.write(' if (!g_%s)\n ' % entry_point_name) | 1201 file.write(' if (!g_%s)\n ' % entry_point_name) |
1200 file.write( | 1202 file.write( |
1201 ' g_%s = reinterpret_cast<%sProc>(GetGLProcAddress("%s"));\n' % | 1203 ' g_%s = reinterpret_cast<%sProc>(GetGLProcAddress("%s"));\n' % |
1202 (entry_point_name, entry_point_name, function_name)) | 1204 (entry_point_name, entry_point_name, function_name)) |
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1515 source_file.close() | 1517 source_file.close() |
1516 | 1518 |
1517 source_file = open(os.path.join(dir, 'gl_bindings_autogen_mock.cc'), 'wb') | 1519 source_file = open(os.path.join(dir, 'gl_bindings_autogen_mock.cc'), 'wb') |
1518 GenerateMockSource(source_file, GL_FUNCTIONS) | 1520 GenerateMockSource(source_file, GL_FUNCTIONS) |
1519 source_file.close() | 1521 source_file.close() |
1520 return 0 | 1522 return 0 |
1521 | 1523 |
1522 | 1524 |
1523 if __name__ == '__main__': | 1525 if __name__ == '__main__': |
1524 sys.exit(main(sys.argv[1:])) | 1526 sys.exit(main(sys.argv[1:])) |
OLD | NEW |