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 optparse | 8 import optparse |
9 import os | 9 import os |
10 import collections | 10 import collections |
(...skipping 1329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1340 | 1340 |
1341 # Write file header. | 1341 # Write file header. |
1342 file.write( | 1342 file.write( |
1343 """// Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1343 """// Copyright (c) 2011 The Chromium Authors. All rights reserved. |
1344 // Use of this source code is governed by a BSD-style license that can be | 1344 // Use of this source code is governed by a BSD-style license that can be |
1345 // found in the LICENSE file. | 1345 // found in the LICENSE file. |
1346 | 1346 |
1347 // This file is automatically generated. | 1347 // This file is automatically generated. |
1348 | 1348 |
1349 #include <string> | 1349 #include <string> |
| 1350 #include "base/debug/trace_event.h" |
1350 #include "gpu/command_buffer/common/gles2_cmd_utils.h" | 1351 #include "gpu/command_buffer/common/gles2_cmd_utils.h" |
1351 #include "ui/gl/gl_bindings.h" | 1352 #include "ui/gl/gl_bindings.h" |
1352 #include "ui/gl/gl_context.h" | 1353 #include "ui/gl/gl_context.h" |
1353 #include "ui/gl/gl_implementation.h" | 1354 #include "ui/gl/gl_implementation.h" |
1354 #include "ui/gl/gl_%s_api_implementation.h" | 1355 #include "ui/gl/gl_%s_api_implementation.h" |
1355 | 1356 |
1356 using gpu::gles2::GLES2Util; | 1357 using gpu::gles2::GLES2Util; |
1357 | 1358 |
1358 namespace gfx { | 1359 namespace gfx { |
1359 """ % set_name.lower()) | 1360 """ % set_name.lower()) |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1503 file.write(' }\n') | 1504 file.write(' }\n') |
1504 file.write('}\n') | 1505 file.write('}\n') |
1505 | 1506 |
1506 # Write function to clear all function pointers. | 1507 # Write function to clear all function pointers. |
1507 file.write('\n') | 1508 file.write('\n') |
1508 file.write("""void Driver%s::ClearBindings() { | 1509 file.write("""void Driver%s::ClearBindings() { |
1509 memset(this, 0, sizeof(*this)); | 1510 memset(this, 0, sizeof(*this)); |
1510 } | 1511 } |
1511 """ % set_name.upper()) | 1512 """ % set_name.upper()) |
1512 | 1513 |
1513 # Write RealGLApi functions | 1514 # Write GLApiBase functions |
1514 for func in functions: | 1515 for func in functions: |
1515 names = func['names'] | 1516 names = func['names'] |
1516 return_type = func['return_type'] | 1517 return_type = func['return_type'] |
1517 arguments = func['arguments'] | 1518 arguments = func['arguments'] |
1518 file.write('\n') | 1519 file.write('\n') |
1519 file.write('%s %sApiBase::%sFn(%s) {\n' % | 1520 file.write('%s %sApiBase::%sFn(%s) {\n' % |
1520 (return_type, set_name.upper(), names[0], arguments)) | 1521 (return_type, set_name.upper(), names[0], arguments)) |
1521 argument_names = re.sub( | 1522 argument_names = re.sub( |
1522 r'(const )?[a-zA-Z0-9_]+\** ([a-zA-Z0-9_]+)', r'\2', arguments) | 1523 r'(const )?[a-zA-Z0-9_]+\** ([a-zA-Z0-9_]+)', r'\2', arguments) |
1523 argument_names = re.sub( | 1524 argument_names = re.sub( |
1524 r'(const )?[a-zA-Z0-9_]+\** ([a-zA-Z0-9_]+)', r'\2', argument_names) | 1525 r'(const )?[a-zA-Z0-9_]+\** ([a-zA-Z0-9_]+)', r'\2', argument_names) |
1525 if argument_names == 'void' or argument_names == '': | 1526 if argument_names == 'void' or argument_names == '': |
1526 argument_names = '' | 1527 argument_names = '' |
1527 function_name = names[0] | 1528 function_name = names[0] |
1528 if return_type == 'void': | 1529 if return_type == 'void': |
1529 file.write(' driver_->fn.%sFn(%s);\n' % | 1530 file.write(' driver_->fn.%sFn(%s);\n' % |
1530 (function_name, argument_names)) | 1531 (function_name, argument_names)) |
1531 else: | 1532 else: |
1532 file.write(' return driver_->fn.%sFn(%s);\n' % | 1533 file.write(' return driver_->fn.%sFn(%s);\n' % |
1533 (function_name, argument_names)) | 1534 (function_name, argument_names)) |
1534 file.write('}\n') | 1535 file.write('}\n') |
1535 | 1536 |
| 1537 # Write TraceGLApi functions |
| 1538 for func in functions: |
| 1539 names = func['names'] |
| 1540 return_type = func['return_type'] |
| 1541 arguments = func['arguments'] |
| 1542 file.write('\n') |
| 1543 file.write('%s Trace%sApi::%sFn(%s) {\n' % |
| 1544 (return_type, set_name.upper(), names[0], arguments)) |
| 1545 argument_names = re.sub( |
| 1546 r'(const )?[a-zA-Z0-9_]+\** ([a-zA-Z0-9_]+)', r'\2', arguments) |
| 1547 argument_names = re.sub( |
| 1548 r'(const )?[a-zA-Z0-9_]+\** ([a-zA-Z0-9_]+)', r'\2', argument_names) |
| 1549 if argument_names == 'void' or argument_names == '': |
| 1550 argument_names = '' |
| 1551 function_name = names[0] |
| 1552 file.write(' TRACE_EVENT0("gpu", "TraceGLAPI::%s")\n' % function_name) |
| 1553 if return_type == 'void': |
| 1554 file.write(' %s_api_->%sFn(%s);\n' % |
| 1555 (set_name.lower(), function_name, argument_names)) |
| 1556 else: |
| 1557 file.write(' return %s_api_->%sFn(%s);\n' % |
| 1558 (set_name.lower(), function_name, argument_names)) |
| 1559 file.write('}\n') |
| 1560 |
1536 file.write('\n') | 1561 file.write('\n') |
1537 file.write('} // namespace gfx\n') | 1562 file.write('} // namespace gfx\n') |
1538 | 1563 |
1539 | 1564 |
1540 def GenerateMockSource(file, functions): | 1565 def GenerateMockSource(file, functions): |
1541 """Generates functions that invoke a mock GLInterface""" | 1566 """Generates functions that invoke a mock GLInterface""" |
1542 | 1567 |
1543 file.write( | 1568 file.write( |
1544 """// Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1569 """// Copyright (c) 2011 The Chromium Authors. All rights reserved. |
1545 // Use of this source code is governed by a BSD-style license that can be | 1570 // Use of this source code is governed by a BSD-style license that can be |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1793 header_file.close() | 1818 header_file.close() |
1794 | 1819 |
1795 source_file = open(os.path.join(dir, 'gl_bindings_autogen_mock.cc'), 'wb') | 1820 source_file = open(os.path.join(dir, 'gl_bindings_autogen_mock.cc'), 'wb') |
1796 GenerateMockSource(source_file, GL_FUNCTIONS) | 1821 GenerateMockSource(source_file, GL_FUNCTIONS) |
1797 source_file.close() | 1822 source_file.close() |
1798 return 0 | 1823 return 0 |
1799 | 1824 |
1800 | 1825 |
1801 if __name__ == '__main__': | 1826 if __name__ == '__main__': |
1802 sys.exit(main(sys.argv[1:])) | 1827 sys.exit(main(sys.argv[1:])) |
OLD | NEW |