gpu/command_buffer/build_cmd_buffer_lib.py
def WriteServiceContextStateHeader(self, filename):
    """Writes the service context state header."""
    comment = "// It is included by context_state.h\n"
    with CHeaderWriter(filename, self.year, comment) as f:
      f.write("struct EnableFlags {\n")
      f.write("  EnableFlags();\n")
      for capability in self.capability_flags:
        f.write("  bool %s;\n" % capability['name'])
        f.write("  bool cached_%s;\n" % capability['name'])
      f.write("};\n\n")

      for state_name in sorted(_STATE_INFO.keys()):
        state = _STATE_INFO[state_name]
        for item in state['states']:
          if isinstance(item['default'], list):
            f.write("%s %s[%d];\n" % (item['type'], item['name'],
                                         len(item['default'])))
          else:
            f.write("%s %s;\n" % (item['type'], item['name']))

          if item.get('cached', False):
            if isinstance(item['default'], list):
              f.write("%s cached_%s[%d];\n" % (item['type'], item['name'],
                                                  len(item['default'])))
            else:
              f.write("%s cached_%s;\n" % (item['type'], item['name']))

      f.write("\n")
      f.write("""
          inline void SetDeviceCapabilityState(GLenum cap, bool enable) {
            switch (cap) {
          """)
      for capability in self.capability_flags:
        f.write("""\
              case GL_%s:
            """ % capability['name'].upper())
        f.write("""\
                if (enable_flags.cached_%(name)s == enable &&
                    !ignore_cached_state)
                  return;
                enable_flags.cached_%(name)s = enable;
                break;
            """ % capability)

      f.write("""\
              default:
                NOTREACHED();
                return;
            }
            if (enable)
              api()->glEnableFn(cap);
            else
              api()->glDisableFn(cap);
          }
          """)
    self.generated_cpp_filenames.append(filename)
Writes the service context state header.
Writes the service context state header.
Writes the service context state header .
def WriteServiceContextStateHeader(self, filename):
    comment = "// It is included by context_state.h\n"
    with CHeaderWriter(filename, self.year, comment) as f:
      f.write("struct EnableFlags {\n")
      f.write("  EnableFlags();\n")
      for capability in self.capability_flags:
        f.write("  bool %s;\n" % capability['name'])
        f.write("  bool cached_%s;\n" % capability['name'])
      f.write("};\n\n")
      for state_name in sorted(_STATE_INFO.keys()):
        state = _STATE_INFO[state_name]
        for item in state['states']:
          if isinstance(item['default'], list):
            f.write("%s %s[%d];\n" % (item['type'], item['name'],
                                         len(item['default'])))
          else:
            f.write("%s %s;\n" % (item['type'], item['name']))
          if item.get('cached', False):
            if isinstance(item['default'], list):
              f.write("%s cached_%s[%d];\n" % (item['type'], item['name'],
                                                  len(item['default'])))
            else:
              f.write("%s cached_%s;\n" % (item['type'], item['name']))
      f.write("\n")
      f.write("""
          inline void SetDeviceCapabilityState(GLenum cap, bool enable) {
            switch (cap) {
          """)
      for capability in self.capability_flags:
        f.write("""\
              case GL_%s:
            """ % capability['name'].upper())
        f.write("""\
                if (enable_flags.cached_%(name)s == enable &&
                    !ignore_cached_state)
                  return;
                enable_flags.cached_%(name)s = enable;
                break;
            """ % capability)
      f.write("""\
              default:
                NOTREACHED();
                return;
            }
            if (enable)
              api()->glEnableFn(cap);
            else
              api()->glDisableFn(cap);
          }
          """)
    self.generated_cpp_filenames.append(filename)
def WriteServiceContextStateHeader ( self , filename ) : comment = "// It is included by context_state.h\n" with CHeaderWriter ( filename , self . year , comment ) as f : f . write ( "struct EnableFlags {\n" ) f . write ( "  EnableFlags();\n" ) for capability in self . capability_flags : f . write ( "  bool %s;\n" % capability [ 'name' ] ) f . write ( "  bool cached_%s;\n" % capability [ 'name' ] ) f . write ( "};\n\n" ) for state_name in sorted ( _STATE_INFO . keys ( ) ) : state = _STATE_INFO [ state_name ] for item in state [ 'states' ] : if isinstance ( item [ 'default' ] , list ) : f . write ( "%s %s[%d];\n" % ( item [ 'type' ] , item [ 'name' ] , len ( item [ 'default' ] ) ) ) else : f . write ( "%s %s;\n" % ( item [ 'type' ] , item [ 'name' ] ) ) if item . get ( 'cached' , False ) : if isinstance ( item [ 'default' ] , list ) : f . write ( "%s cached_%s[%d];\n" % ( item [ 'type' ] , item [ 'name' ] , len ( item [ 'default' ] ) ) ) else : f . write ( "%s cached_%s;\n" % ( item [ 'type' ] , item [ 'name' ] ) ) f . write ( "\n" ) f . write ( """
          inline void SetDeviceCapabilityState(GLenum cap, bool enable) {
            switch (cap) {
          """ ) for capability in self . capability_flags : f . write ( """\
              case GL_%s:
            """ % capability [ 'name' ] . upper ( ) ) f . write ( """\
                if (enable_flags.cached_%(name)s == enable &&
                    !ignore_cached_state)
                  return;
                enable_flags.cached_%(name)s = enable;
                break;
            """ % capability ) f . write ( """\
              default:
                NOTREACHED();
                return;
            }
            if (enable)
              api()->glEnableFn(cap);
            else
              api()->glDisableFn(cap);
          }
          """ ) self . generated_cpp_filenames . append ( filename )
Writes the service context state header.
Writes the service context state header .
"""Writes the service context state header."""
self
filename