Chromium Code Reviews| 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 GLES2 command buffers.""" | 6 """code generator for GLES2 command buffers.""" |
| 7 | 7 |
| 8 import itertools | 8 import itertools |
| 9 import os | 9 import os |
| 10 import os.path | 10 import os.path |
| (...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 494 'default': '0', | 494 'default': '0', |
| 495 'es3': True, | 495 'es3': True, |
| 496 'manual': True, | 496 'manual': True, |
| 497 } | 497 } |
| 498 ], | 498 ], |
| 499 }, | 499 }, |
| 500 # TODO: Consider implemenenting these states | 500 # TODO: Consider implemenenting these states |
| 501 # GL_ACTIVE_TEXTURE | 501 # GL_ACTIVE_TEXTURE |
| 502 'LineWidth': { | 502 'LineWidth': { |
| 503 'type': 'Normal', | 503 'type': 'Normal', |
| 504 'func': 'LineWidth', | 504 'custom_function_prefix' : 'Do', |
| 505 'func': 'DoLineWidth', | |
| 505 'enum': 'GL_LINE_WIDTH', | 506 'enum': 'GL_LINE_WIDTH', |
| 506 'states': [ | 507 'states': [ |
| 507 { | 508 { |
| 508 'name': 'line_width', | 509 'name': 'line_width', |
| 509 'type': 'GLfloat', | 510 'type': 'GLfloat', |
| 510 'default': '1.0f', | 511 'default': '1.0f', |
| 511 'range_checks': [{'check': "<= 0.0f", 'test_value': "0.0f"}], | 512 'range_checks': [{'check': "<= 0.0f", 'test_value': "0.0f"}], |
| 512 'nan_check': True, | 513 'nan_check': True, |
| 513 }], | 514 }], |
| 514 }, | 515 }, |
| (...skipping 9751 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 10266 for place, item in enumerate(state['states']): | 10267 for place, item in enumerate(state['states']): |
| 10267 item_name = CachedStateName(item) | 10268 item_name = CachedStateName(item) |
| 10268 args.append('%s' % item_name) | 10269 args.append('%s' % item_name) |
| 10269 if test_prev: | 10270 if test_prev: |
| 10270 if place > 0: | 10271 if place > 0: |
| 10271 f.write(' ||\n') | 10272 f.write(' ||\n') |
| 10272 f.write("(%s != prev_state->%s)" % | 10273 f.write("(%s != prev_state->%s)" % |
| 10273 (item_name, item_name)) | 10274 (item_name, item_name)) |
| 10274 if test_prev: | 10275 if test_prev: |
| 10275 f.write(" )\n") | 10276 f.write(" )\n") |
| 10276 f.write(" gl%s(%s);\n" % (state['func'], ", ".join(args))) | 10277 if 'custom_function_prefix' in state: |
| 10278 f.write(" %s(%s);\n" % (state['func'], ", ".join(args))) | |
| 10279 else: | |
| 10280 f.write(" gl%s(%s);\n" % (state['func'], ", ".join(args))) | |
| 10277 | 10281 |
| 10278 f.write(" if (prev_state) {") | 10282 f.write(" if (prev_state) {") |
| 10279 WriteStates(True) | 10283 WriteStates(True) |
| 10280 f.write(" } else {") | 10284 f.write(" } else {") |
| 10281 WriteStates(False) | 10285 WriteStates(False) |
| 10282 f.write(" }") | 10286 f.write(" }") |
| 10283 f.write(" InitStateManual(prev_state);") | 10287 f.write(" InitStateManual(prev_state);") |
| 10284 f.write("}\n") | 10288 f.write("}\n") |
| 10285 | 10289 |
| 10286 f.write("""bool ContextState::GetEnabled(GLenum cap) const { | 10290 f.write("""bool ContextState::GetEnabled(GLenum cap) const { |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 10522 state['extension_flag']) | 10526 state['extension_flag']) |
| 10523 f.write(" ") | 10527 f.write(" ") |
| 10524 args = [] | 10528 args = [] |
| 10525 for item in state['states']: | 10529 for item in state['states']: |
| 10526 if 'expected' in item: | 10530 if 'expected' in item: |
| 10527 args.append(item['expected']) | 10531 args.append(item['expected']) |
| 10528 else: | 10532 else: |
| 10529 args.append(item['default']) | 10533 args.append(item['default']) |
| 10530 # TODO: Currently we do not check array values. | 10534 # TODO: Currently we do not check array values. |
| 10531 args = ["_" if isinstance(arg, list) else arg for arg in args] | 10535 args = ["_" if isinstance(arg, list) else arg for arg in args] |
| 10536 func_name = state['func'] | |
| 10537 if 'custom_function_prefix' in state: | |
| 10538 func_prefix = state['custom_function_prefix']; | |
| 10539 if func_name.startswith(func_prefix): | |
| 10540 func_name = func_name[len(func_prefix):] | |
|
piman
2016/11/09 16:32:13
Mmh, the reason I suggested manual code for the te
Lof
2016/11/09 22:14:19
Done.
| |
| 10532 f.write(" EXPECT_CALL(*gl_, %s(%s))\n" % | 10541 f.write(" EXPECT_CALL(*gl_, %s(%s))\n" % |
| 10533 (state['func'], ", ".join(args))) | 10542 (func_name, ", ".join(args))) |
| 10534 f.write(" .Times(1)\n") | 10543 f.write(" .Times(1)\n") |
| 10535 f.write(" .RetiresOnSaturation();\n") | 10544 f.write(" .RetiresOnSaturation();\n") |
| 10536 if 'extension_flag' in state: | 10545 if 'extension_flag' in state: |
| 10537 f.write(" }\n") | 10546 f.write(" }\n") |
| 10538 f.write(" SetupInitStateManualExpectations(es3_capable);\n") | 10547 f.write(" SetupInitStateManualExpectations(es3_capable);\n") |
| 10539 f.write("}\n") | 10548 f.write("}\n") |
| 10540 self.generated_cpp_filenames.append(filename) | 10549 self.generated_cpp_filenames.append(filename) |
| 10541 | 10550 |
| 10542 def WriteServiceUnitTestsForExtensions(self, filename): | 10551 def WriteServiceUnitTestsForExtensions(self, filename): |
| 10543 """Writes the service decorder unit tests for functions with extension_flag. | 10552 """Writes the service decorder unit tests for functions with extension_flag. |
| (...skipping 631 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 11175 Format(gen.generated_cpp_filenames) | 11184 Format(gen.generated_cpp_filenames) |
| 11176 | 11185 |
| 11177 if gen.errors > 0: | 11186 if gen.errors > 0: |
| 11178 print "%d errors" % gen.errors | 11187 print "%d errors" % gen.errors |
| 11179 return 1 | 11188 return 1 |
| 11180 return 0 | 11189 return 0 |
| 11181 | 11190 |
| 11182 | 11191 |
| 11183 if __name__ == '__main__': | 11192 if __name__ == '__main__': |
| 11184 sys.exit(main(sys.argv[1:])) | 11193 sys.exit(main(sys.argv[1:])) |
| OLD | NEW |