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 488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
499 'expected': 'kViewportWidth', | 499 'expected': 'kViewportWidth', |
500 }, | 500 }, |
501 { | 501 { |
502 'name': 'viewport_height', | 502 'name': 'viewport_height', |
503 'type': 'GLsizei', | 503 'type': 'GLsizei', |
504 'default': '1', | 504 'default': '1', |
505 'expected': 'kViewportHeight', | 505 'expected': 'kViewportHeight', |
506 }, | 506 }, |
507 ], | 507 ], |
508 }, | 508 }, |
| 509 'MatrixValuesCHROMIUM': { |
| 510 'type': 'NamedParameter', |
| 511 'func': 'MatrixLoadfEXT', |
| 512 'states': [ |
| 513 { 'enum': 'GL_PATH_MODELVIEW_MATRIX_CHROMIUM', |
| 514 'enum_set': 'GL_PATH_MODELVIEW_CHROMIUM', |
| 515 'name': 'modelview_matrix', |
| 516 'type': 'GLfloat', |
| 517 'default': [ |
| 518 '1.0f', '0.0f','0.0f','0.0f', |
| 519 '0.0f', '1.0f','0.0f','0.0f', |
| 520 '0.0f', '0.0f','1.0f','0.0f', |
| 521 '0.0f', '0.0f','0.0f','1.0f', |
| 522 ], |
| 523 'extension_flag': 'chromium_path_rendering', |
| 524 }, |
| 525 { 'enum': 'GL_PATH_PROJECTION_MATRIX_CHROMIUM', |
| 526 'enum_set': 'GL_PATH_PROJECTION_CHROMIUM', |
| 527 'name': 'projection_matrix', |
| 528 'type': 'GLfloat', |
| 529 'default': [ |
| 530 '1.0f', '0.0f','0.0f','0.0f', |
| 531 '0.0f', '1.0f','0.0f','0.0f', |
| 532 '0.0f', '0.0f','1.0f','0.0f', |
| 533 '0.0f', '0.0f','0.0f','1.0f', |
| 534 ], |
| 535 'extension_flag': 'chromium_path_rendering', |
| 536 }, |
| 537 ], |
| 538 }, |
509 } | 539 } |
510 | 540 |
511 # Named type info object represents a named type that is used in OpenGL call | 541 # Named type info object represents a named type that is used in OpenGL call |
512 # arguments. Each named type defines a set of valid OpenGL call arguments. The | 542 # arguments. Each named type defines a set of valid OpenGL call arguments. The |
513 # named types are used in 'cmd_buffer_functions.txt'. | 543 # named types are used in 'cmd_buffer_functions.txt'. |
514 # type: The actual GL type of the named type. | 544 # type: The actual GL type of the named type. |
515 # valid: The list of values that are valid for both the client and the service. | 545 # valid: The list of values that are valid for both the client and the service. |
516 # invalid: Examples of invalid values for the type. At least these values | 546 # invalid: Examples of invalid values for the type. At least these values |
517 # should be tested to be invalid. | 547 # should be tested to be invalid. |
518 # is_complete: The list of valid values of type are final and will not be | 548 # is_complete: The list of valid values of type are final and will not be |
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
832 }, | 862 }, |
833 'FrameBufferParameter': { | 863 'FrameBufferParameter': { |
834 'type': 'GLenum', | 864 'type': 'GLenum', |
835 'valid': [ | 865 'valid': [ |
836 'GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE', | 866 'GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE', |
837 'GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME', | 867 'GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME', |
838 'GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL', | 868 'GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL', |
839 'GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE', | 869 'GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE', |
840 ], | 870 ], |
841 }, | 871 }, |
| 872 'MatrixMode': { |
| 873 'type': 'GLenum', |
| 874 'valid': [ |
| 875 'GL_PATH_PROJECTION_CHROMIUM', |
| 876 'GL_PATH_MODELVIEW_CHROMIUM', |
| 877 ], |
| 878 }, |
842 'ProgramParameter': { | 879 'ProgramParameter': { |
843 'type': 'GLenum', | 880 'type': 'GLenum', |
844 'valid': [ | 881 'valid': [ |
845 'GL_DELETE_STATUS', | 882 'GL_DELETE_STATUS', |
846 'GL_LINK_STATUS', | 883 'GL_LINK_STATUS', |
847 'GL_VALIDATE_STATUS', | 884 'GL_VALIDATE_STATUS', |
848 'GL_INFO_LOG_LENGTH', | 885 'GL_INFO_LOG_LENGTH', |
849 'GL_ATTACHED_SHADERS', | 886 'GL_ATTACHED_SHADERS', |
850 'GL_ACTIVE_ATTRIBUTES', | 887 'GL_ACTIVE_ATTRIBUTES', |
851 'GL_ACTIVE_ATTRIBUTE_MAX_LENGTH', | 888 'GL_ACTIVE_ATTRIBUTE_MAX_LENGTH', |
(...skipping 1725 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2577 'chromium': True, | 2614 'chromium': True, |
2578 }, | 2615 }, |
2579 'ScheduleOverlayPlaneCHROMIUM': { | 2616 'ScheduleOverlayPlaneCHROMIUM': { |
2580 'type': 'Custom', | 2617 'type': 'Custom', |
2581 'impl_func': True, | 2618 'impl_func': True, |
2582 'unit_test': False, | 2619 'unit_test': False, |
2583 'client_test': False, | 2620 'client_test': False, |
2584 'extension': True, | 2621 'extension': True, |
2585 'chromium': True, | 2622 'chromium': True, |
2586 }, | 2623 }, |
| 2624 'MatrixLoadfCHROMIUM': { |
| 2625 'type': 'PUT', |
| 2626 'count': 16, |
| 2627 'data_type': 'GLfloat', |
| 2628 'decoder_func': 'DoMatrixLoadfCHROMIUM', |
| 2629 'gl_test_func': 'glMatrixLoadfEXT', |
| 2630 'chromium': True, |
| 2631 'extension': True, |
| 2632 'extension_flag': 'chromium_path_rendering', |
| 2633 }, |
| 2634 'MatrixLoadIdentityCHROMIUM': { |
| 2635 'decoder_func': 'DoMatrixLoadIdentityCHROMIUM', |
| 2636 'gl_test_func': 'glMatrixLoadIdentityEXT', |
| 2637 'chromium': True, |
| 2638 'extension': True, |
| 2639 'extension_flag': 'chromium_path_rendering', |
| 2640 }, |
2587 } | 2641 } |
2588 | 2642 |
2589 | 2643 |
2590 def Grouper(n, iterable, fillvalue=None): | 2644 def Grouper(n, iterable, fillvalue=None): |
2591 """Collect data into fixed-length chunks or blocks""" | 2645 """Collect data into fixed-length chunks or blocks""" |
2592 args = [iter(iterable)] * n | 2646 args = [iter(iterable)] * n |
2593 return itertools.izip_longest(fillvalue=fillvalue, *args) | 2647 return itertools.izip_longest(fillvalue=fillvalue, *args) |
2594 | 2648 |
2595 | 2649 |
2596 def SplitWords(input_string): | 2650 def SplitWords(input_string): |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2646 uppercase_words = [ 'img', 'ext', 'arb', 'chromium', 'oes', 'amd', 'bgra8888', | 2700 uppercase_words = [ 'img', 'ext', 'arb', 'chromium', 'oes', 'amd', 'bgra8888', |
2647 'egl', 'atc', 'etc1', 'angle'] | 2701 'egl', 'atc', 'etc1', 'angle'] |
2648 parts = extension_flag.split('_') | 2702 parts = extension_flag.split('_') |
2649 return "_".join( | 2703 return "_".join( |
2650 [part.upper() if part in uppercase_words else part for part in parts]) | 2704 [part.upper() if part in uppercase_words else part for part in parts]) |
2651 | 2705 |
2652 def ToCamelCase(input_string): | 2706 def ToCamelCase(input_string): |
2653 """converts ABC_underscore_case to ABCUnderscoreCase.""" | 2707 """converts ABC_underscore_case to ABCUnderscoreCase.""" |
2654 return ''.join(w[0].upper() + w[1:] for w in input_string.split('_')) | 2708 return ''.join(w[0].upper() + w[1:] for w in input_string.split('_')) |
2655 | 2709 |
| 2710 def GetGLGetTypeConversion(result_type, value_type, value): |
| 2711 """Makes a gl compatible type conversion string for accessing state variables. |
| 2712 |
| 2713 Useful when accessing state variables through glGetXXX calls. |
| 2714 glGet documetation (for example, the manual pages): |
| 2715 [...] If glGetIntegerv is called, [...] most floating-point values are |
| 2716 rounded to the nearest integer value. [...] |
| 2717 |
| 2718 Args: |
| 2719 result_type: the gl type to be obtained |
| 2720 value_type: the GL type of the state variable |
| 2721 value: the name of the state variable |
| 2722 |
| 2723 Returns: |
| 2724 String that converts the state variable to desired GL type according to GL |
| 2725 rules. |
| 2726 """ |
| 2727 |
| 2728 if result_type == 'GLint': |
| 2729 if value_type == 'GLfloat': |
| 2730 return 'static_cast<GLint>(round(%s))' % value |
| 2731 return 'static_cast<%s>(%s)' % (result_type, value) |
| 2732 |
2656 class CWriter(object): | 2733 class CWriter(object): |
2657 """Writes to a file formatting it for Google's style guidelines.""" | 2734 """Writes to a file formatting it for Google's style guidelines.""" |
2658 | 2735 |
2659 def __init__(self, filename): | 2736 def __init__(self, filename): |
2660 self.filename = filename | 2737 self.filename = filename |
2661 self.content = [] | 2738 self.content = [] |
2662 | 2739 |
2663 def Write(self, string): | 2740 def Write(self, string): |
2664 """Writes a string to a file spliting if it's > 80 characters.""" | 2741 """Writes a string to a file spliting if it's > 80 characters.""" |
2665 lines = string.splitlines() | 2742 lines = string.splitlines() |
(...skipping 4795 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7461 file.Write("struct EnableFlags {\n") | 7538 file.Write("struct EnableFlags {\n") |
7462 file.Write(" EnableFlags();\n") | 7539 file.Write(" EnableFlags();\n") |
7463 for capability in _CAPABILITY_FLAGS: | 7540 for capability in _CAPABILITY_FLAGS: |
7464 file.Write(" bool %s;\n" % capability['name']) | 7541 file.Write(" bool %s;\n" % capability['name']) |
7465 file.Write(" bool cached_%s;\n" % capability['name']) | 7542 file.Write(" bool cached_%s;\n" % capability['name']) |
7466 file.Write("};\n\n") | 7543 file.Write("};\n\n") |
7467 | 7544 |
7468 for state_name in sorted(_STATES.keys()): | 7545 for state_name in sorted(_STATES.keys()): |
7469 state = _STATES[state_name] | 7546 state = _STATES[state_name] |
7470 for item in state['states']: | 7547 for item in state['states']: |
7471 file.Write("%s %s;\n" % (item['type'], item['name'])) | 7548 if isinstance(item['default'], list): |
| 7549 file.Write("%s %s[%d];\n" % (item['type'], item['name'], |
| 7550 len(item['default']))) |
| 7551 else: |
| 7552 file.Write("%s %s;\n" % (item['type'], item['name'])) |
| 7553 |
7472 if item.get('cached', False): | 7554 if item.get('cached', False): |
7473 file.Write("%s cached_%s;\n" % (item['type'], item['name'])) | 7555 if isinstance(item['default'], list): |
| 7556 file.Write("%s cached_%s[%d];\n" % (item['type'], item['name'], |
| 7557 len(item['default']))) |
| 7558 else: |
| 7559 file.Write("%s cached_%s;\n" % (item['type'], item['name'])) |
| 7560 |
7474 file.Write("\n") | 7561 file.Write("\n") |
7475 | 7562 |
7476 file.Write(""" | 7563 file.Write(""" |
7477 inline void SetDeviceCapabilityState(GLenum cap, bool enable) { | 7564 inline void SetDeviceCapabilityState(GLenum cap, bool enable) { |
7478 switch (cap) { | 7565 switch (cap) { |
7479 """) | 7566 """) |
7480 for capability in _CAPABILITY_FLAGS: | 7567 for capability in _CAPABILITY_FLAGS: |
7481 file.Write("""\ | 7568 file.Write("""\ |
7482 case GL_%s: | 7569 case GL_%s: |
7483 """ % capability['name'].upper()) | 7570 """ % capability['name'].upper()) |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7531 file.Write(" *num_written = %d;\n" % len(state['states'])) | 7618 file.Write(" *num_written = %d;\n" % len(state['states'])) |
7532 file.Write(" if (params) {\n") | 7619 file.Write(" if (params) {\n") |
7533 for ndx,item in enumerate(state['states']): | 7620 for ndx,item in enumerate(state['states']): |
7534 file.Write(" params[%d] = static_cast<%s>(%s);\n" % | 7621 file.Write(" params[%d] = static_cast<%s>(%s);\n" % |
7535 (ndx, gl_type, item['name'])) | 7622 (ndx, gl_type, item['name'])) |
7536 file.Write(" }\n") | 7623 file.Write(" }\n") |
7537 file.Write(" return true;\n") | 7624 file.Write(" return true;\n") |
7538 else: | 7625 else: |
7539 for item in state['states']: | 7626 for item in state['states']: |
7540 file.Write(" case %s:\n" % item['enum']) | 7627 file.Write(" case %s:\n" % item['enum']) |
7541 file.Write(" *num_written = 1;\n") | 7628 if isinstance(item['default'], list): |
7542 file.Write(" if (params) {\n") | 7629 item_len = len(item['default']) |
7543 file.Write(" params[0] = static_cast<%s>(%s);\n" % | 7630 file.Write(" *num_written = %d;\n" % item_len) |
7544 (gl_type, item['name'])) | 7631 file.Write(" if (params) {\n") |
| 7632 if item['type'] == gl_type: |
| 7633 file.Write(" memcpy(params, %s, sizeof(%s) * %d);\n" % |
| 7634 (item['name'], item['type'], item_len)) |
| 7635 else: |
| 7636 file.Write(" for (size_t i = 0; i < %s; ++i) {\n" % |
| 7637 item_len) |
| 7638 file.Write(" params[i] = %s;\n" % |
| 7639 (GetGLGetTypeConversion(gl_type, item['type'], |
| 7640 "%s[i]" % item['name']))) |
| 7641 file.Write(" }\n"); |
| 7642 else: |
| 7643 file.Write(" *num_written = 1;\n") |
| 7644 file.Write(" if (params) {\n") |
| 7645 file.Write(" params[0] = %s;\n" % |
| 7646 (GetGLGetTypeConversion(gl_type, item['type'], |
| 7647 item['name']))) |
7545 file.Write(" }\n") | 7648 file.Write(" }\n") |
7546 file.Write(" return true;\n") | 7649 file.Write(" return true;\n") |
7547 for capability in _CAPABILITY_FLAGS: | 7650 for capability in _CAPABILITY_FLAGS: |
7548 file.Write(" case GL_%s:\n" % capability['name'].upper()) | 7651 file.Write(" case GL_%s:\n" % capability['name'].upper()) |
7549 file.Write(" *num_written = 1;\n") | 7652 file.Write(" *num_written = 1;\n") |
7550 file.Write(" if (params) {\n") | 7653 file.Write(" if (params) {\n") |
7551 file.Write( | 7654 file.Write( |
7552 " params[0] = static_cast<%s>(enable_flags.%s);\n" % | 7655 " params[0] = static_cast<%s>(enable_flags.%s);\n" % |
7553 (gl_type, capability['name'])) | 7656 (gl_type, capability['name'])) |
7554 file.Write(" }\n") | 7657 file.Write(" }\n") |
(...skipping 18 matching lines...) Expand all Loading... |
7573 (capability['name'], | 7676 (capability['name'], |
7574 ('false', 'true')['default' in capability])) | 7677 ('false', 'true')['default' in capability])) |
7575 file.Write("ContextState::EnableFlags::EnableFlags()\n : %s {\n}\n" % | 7678 file.Write("ContextState::EnableFlags::EnableFlags()\n : %s {\n}\n" % |
7576 ",\n ".join(code)) | 7679 ",\n ".join(code)) |
7577 file.Write("\n") | 7680 file.Write("\n") |
7578 | 7681 |
7579 file.Write("void ContextState::Initialize() {\n") | 7682 file.Write("void ContextState::Initialize() {\n") |
7580 for state_name in sorted(_STATES.keys()): | 7683 for state_name in sorted(_STATES.keys()): |
7581 state = _STATES[state_name] | 7684 state = _STATES[state_name] |
7582 for item in state['states']: | 7685 for item in state['states']: |
7583 file.Write(" %s = %s;\n" % (item['name'], item['default'])) | 7686 if isinstance(item['default'], list): |
| 7687 for ndx, value in enumerate(item['default']): |
| 7688 file.Write(" %s[%d] = %s;\n" % (item['name'], ndx, value)) |
| 7689 else: |
| 7690 file.Write(" %s = %s;\n" % (item['name'], item['default'])) |
7584 if item.get('cached', False): | 7691 if item.get('cached', False): |
7585 file.Write(" cached_%s = %s;\n" % (item['name'], item['default'])) | 7692 if isinstance(item['default'], list): |
| 7693 for ndx, value in enumerate(item['default']): |
| 7694 file.Write(" cached_%s[%d] = %s;\n" % (item['name'], ndx, value)) |
| 7695 else: |
| 7696 file.Write(" cached_%s = %s;\n" % (item['name'], item['default'])) |
7586 file.Write("}\n") | 7697 file.Write("}\n") |
7587 | 7698 |
7588 file.Write(""" | 7699 file.Write(""" |
7589 void ContextState::InitCapabilities(const ContextState* prev_state) const { | 7700 void ContextState::InitCapabilities(const ContextState* prev_state) const { |
7590 """) | 7701 """) |
7591 def WriteCapabilities(test_prev): | 7702 def WriteCapabilities(test_prev): |
7592 for capability in _CAPABILITY_FLAGS: | 7703 for capability in _CAPABILITY_FLAGS: |
7593 capability_name = capability['name'] | 7704 capability_name = capability['name'] |
7594 if test_prev: | 7705 if test_prev: |
7595 file.Write(""" if (prev_state->enable_flags.cached_%s != | 7706 file.Write(""" if (prev_state->enable_flags.cached_%s != |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7629 if test_prev: | 7740 if test_prev: |
7630 file.Write(")\n") | 7741 file.Write(")\n") |
7631 file.Write( | 7742 file.Write( |
7632 " gl%s(%s, %s);\n" % | 7743 " gl%s(%s, %s);\n" % |
7633 (state['func'], ('GL_FRONT', 'GL_BACK')[ndx], ", ".join(args))) | 7744 (state['func'], ('GL_FRONT', 'GL_BACK')[ndx], ", ".join(args))) |
7634 elif state['type'] == 'NamedParameter': | 7745 elif state['type'] == 'NamedParameter': |
7635 for item in state['states']: | 7746 for item in state['states']: |
7636 item_name = CachedStateName(item) | 7747 item_name = CachedStateName(item) |
7637 | 7748 |
7638 if 'extension_flag' in item: | 7749 if 'extension_flag' in item: |
7639 file.Write(" if (feature_info_->feature_flags().%s)\n " % | 7750 file.Write(" if (feature_info_->feature_flags().%s) {\n " % |
7640 item['extension_flag']) | 7751 item['extension_flag']) |
7641 if test_prev: | 7752 if test_prev: |
7642 file.Write(" if (prev_state->%s != %s)\n" % | 7753 if isinstance(item['default'], list): |
7643 (item_name, item_name)) | 7754 file.Write(" if (memcmp(prev_state->%s, %s, " |
| 7755 "sizeof(%s) * %d)) {\n" % |
| 7756 (item_name, item_name, item['type'], |
| 7757 len(item['default']))) |
| 7758 else: |
| 7759 file.Write(" if (prev_state->%s != %s) {\n " % |
| 7760 (item_name, item_name)) |
7644 file.Write(" gl%s(%s, %s);\n" % | 7761 file.Write(" gl%s(%s, %s);\n" % |
7645 (state['func'], item['enum'], item_name)) | 7762 (state['func'], |
| 7763 (item['enum_set'] |
| 7764 if 'enum_set' in item else item['enum']), |
| 7765 item['name'])) |
| 7766 if test_prev: |
| 7767 if 'extension_flag' in item: |
| 7768 file.Write(" ") |
| 7769 file.Write(" }") |
| 7770 if 'extension_flag' in item: |
| 7771 file.Write(" }") |
7646 else: | 7772 else: |
7647 if 'extension_flag' in state: | 7773 if 'extension_flag' in state: |
7648 file.Write(" if (feature_info_->feature_flags().%s)\n " % | 7774 file.Write(" if (feature_info_->feature_flags().%s)\n " % |
7649 state['extension_flag']) | 7775 state['extension_flag']) |
7650 if test_prev: | 7776 if test_prev: |
7651 file.Write(" if (") | 7777 file.Write(" if (") |
7652 args = [] | 7778 args = [] |
7653 for place, item in enumerate(state['states']): | 7779 for place, item in enumerate(state['states']): |
7654 item_name = CachedStateName(item) | 7780 item_name = CachedStateName(item) |
7655 args.append('%s' % item_name) | 7781 args.append('%s' % item_name) |
7656 if test_prev: | 7782 if test_prev: |
7657 if place > 0: | 7783 if place > 0: |
7658 file.Write(' ||\n') | 7784 file.Write(' ||\n') |
7659 file.Write("(%s != prev_state->%s)" % | 7785 file.Write("(%s != prev_state->%s)" % |
7660 (item_name, item_name)) | 7786 (item_name, item_name)) |
7661 if test_prev: | 7787 if test_prev: |
7662 file.Write(" )\n") | 7788 file.Write(" )\n") |
7663 file.Write(" gl%s(%s);\n" % (state['func'], ", ".join(args))) | 7789 file.Write(" gl%s(%s);\n" % (state['func'], ", ".join(args))) |
7664 | 7790 |
7665 file.Write(" if (prev_state) {") | 7791 file.Write(" if (prev_state) {") |
7666 WriteStates(True) | 7792 WriteStates(True) |
7667 file.Write(" } else {") | 7793 file.Write(" } else {") |
7668 WriteStates(False) | 7794 WriteStates(False) |
7669 file.Write(" }") | 7795 file.Write(" }") |
7670 | |
7671 file.Write("}\n") | 7796 file.Write("}\n") |
7672 | 7797 |
7673 file.Write("""bool ContextState::GetEnabled(GLenum cap) const { | 7798 file.Write("""bool ContextState::GetEnabled(GLenum cap) const { |
7674 switch (cap) { | 7799 switch (cap) { |
7675 """) | 7800 """) |
7676 for capability in _CAPABILITY_FLAGS: | 7801 for capability in _CAPABILITY_FLAGS: |
7677 file.Write(" case GL_%s:\n" % capability['name'].upper()) | 7802 file.Write(" case GL_%s:\n" % capability['name'].upper()) |
7678 file.Write(" return enable_flags.%s;\n" % capability['name']) | 7803 file.Write(" return enable_flags.%s;\n" % capability['name']) |
7679 file.Write(""" default: | 7804 file.Write(""" default: |
7680 NOTREACHED(); | 7805 NOTREACHED(); |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7847 " EXPECT_CALL(*gl_, %s(%s, %s))\n" % | 7972 " EXPECT_CALL(*gl_, %s(%s, %s))\n" % |
7848 (state['func'], ('GL_FRONT', 'GL_BACK')[ndx], ", ".join(args))) | 7973 (state['func'], ('GL_FRONT', 'GL_BACK')[ndx], ", ".join(args))) |
7849 file.Write(" .Times(1)\n") | 7974 file.Write(" .Times(1)\n") |
7850 file.Write(" .RetiresOnSaturation();\n") | 7975 file.Write(" .RetiresOnSaturation();\n") |
7851 elif state['type'] == 'NamedParameter': | 7976 elif state['type'] == 'NamedParameter': |
7852 for item in state['states']: | 7977 for item in state['states']: |
7853 if 'extension_flag' in item: | 7978 if 'extension_flag' in item: |
7854 file.Write(" if (group_->feature_info()->feature_flags().%s) {\n" % | 7979 file.Write(" if (group_->feature_info()->feature_flags().%s) {\n" % |
7855 item['extension_flag']) | 7980 item['extension_flag']) |
7856 file.Write(" ") | 7981 file.Write(" ") |
| 7982 expect_value = item['default'] |
| 7983 if isinstance(expect_value, list): |
| 7984 # TODO: Currently we do not check array values. |
| 7985 expect_value = "_" |
7857 | 7986 |
7858 file.Write( | 7987 file.Write( |
7859 " EXPECT_CALL(*gl_, %s(%s, %s))\n" % | 7988 " EXPECT_CALL(*gl_, %s(%s, %s))\n" % |
7860 (state['func'], item['enum'], item['default'])) | 7989 (state['func'], |
| 7990 (item['enum_set'] |
| 7991 if 'enum_set' in item else item['enum']), |
| 7992 expect_value)) |
7861 file.Write(" .Times(1)\n") | 7993 file.Write(" .Times(1)\n") |
7862 file.Write(" .RetiresOnSaturation();\n") | 7994 file.Write(" .RetiresOnSaturation();\n") |
7863 if 'extension_flag' in item: | 7995 if 'extension_flag' in item: |
7864 file.Write(" }\n") | 7996 file.Write(" }\n") |
7865 else: | 7997 else: |
7866 if 'extension_flag' in state: | 7998 if 'extension_flag' in state: |
7867 file.Write(" if (group_->feature_info()->feature_flags().%s) {\n" % | 7999 file.Write(" if (group_->feature_info()->feature_flags().%s) {\n" % |
7868 state['extension_flag']) | 8000 state['extension_flag']) |
7869 file.Write(" ") | 8001 file.Write(" ") |
7870 args = [] | 8002 args = [] |
7871 for item in state['states']: | 8003 for item in state['states']: |
7872 if 'expected' in item: | 8004 if 'expected' in item: |
7873 args.append(item['expected']) | 8005 args.append(item['expected']) |
7874 else: | 8006 else: |
7875 args.append(item['default']) | 8007 args.append(item['default']) |
| 8008 # TODO: Currently we do not check array values. |
| 8009 args = ["_" if isinstance(arg, list) else arg for arg in args] |
7876 file.Write(" EXPECT_CALL(*gl_, %s(%s))\n" % | 8010 file.Write(" EXPECT_CALL(*gl_, %s(%s))\n" % |
7877 (state['func'], ", ".join(args))) | 8011 (state['func'], ", ".join(args))) |
7878 file.Write(" .Times(1)\n") | 8012 file.Write(" .Times(1)\n") |
7879 file.Write(" .RetiresOnSaturation();\n") | 8013 file.Write(" .RetiresOnSaturation();\n") |
7880 if 'extension_flag' in state: | 8014 if 'extension_flag' in state: |
7881 file.Write(" }\n") | 8015 file.Write(" }\n") |
7882 file.Write("""} | 8016 file.Write("""} |
7883 """) | 8017 """) |
7884 file.Close() | 8018 file.Close() |
7885 | 8019 |
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8345 parser.add_option( | 8479 parser.add_option( |
8346 "-v", "--verbose", action="store_true", | 8480 "-v", "--verbose", action="store_true", |
8347 help="prints more output.") | 8481 help="prints more output.") |
8348 | 8482 |
8349 (options, args) = parser.parse_args(args=argv) | 8483 (options, args) = parser.parse_args(args=argv) |
8350 | 8484 |
8351 # Add in states and capabilites to GLState | 8485 # Add in states and capabilites to GLState |
8352 gl_state_valid = _NAMED_TYPE_INFO['GLState']['valid'] | 8486 gl_state_valid = _NAMED_TYPE_INFO['GLState']['valid'] |
8353 for state_name in sorted(_STATES.keys()): | 8487 for state_name in sorted(_STATES.keys()): |
8354 state = _STATES[state_name] | 8488 state = _STATES[state_name] |
| 8489 if 'extension_flag' in state: |
| 8490 continue |
8355 if 'enum' in state: | 8491 if 'enum' in state: |
8356 if not state['enum'] in gl_state_valid: | 8492 if not state['enum'] in gl_state_valid: |
8357 gl_state_valid.append(state['enum']) | 8493 gl_state_valid.append(state['enum']) |
8358 else: | 8494 else: |
8359 for item in state['states']: | 8495 for item in state['states']: |
8360 if 'extension_flag' in item: | 8496 if 'extension_flag' in item: |
8361 continue | 8497 continue |
8362 if not item['enum'] in gl_state_valid: | 8498 if not item['enum'] in gl_state_valid: |
8363 gl_state_valid.append(item['enum']) | 8499 gl_state_valid.append(item['enum']) |
8364 for capability in _CAPABILITY_FLAGS: | 8500 for capability in _CAPABILITY_FLAGS: |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8463 "ppapi/shared_impl/ppb_opengles2_shared.cc"]) | 8599 "ppapi/shared_impl/ppb_opengles2_shared.cc"]) |
8464 | 8600 |
8465 if gen.errors > 0: | 8601 if gen.errors > 0: |
8466 print "%d errors" % gen.errors | 8602 print "%d errors" % gen.errors |
8467 return 1 | 8603 return 1 |
8468 return 0 | 8604 return 0 |
8469 | 8605 |
8470 | 8606 |
8471 if __name__ == '__main__': | 8607 if __name__ == '__main__': |
8472 sys.exit(main(sys.argv[1:])) | 8608 sys.exit(main(sys.argv[1:])) |
OLD | NEW |