gpu/command_buffer/build_cmd_buffer_lib.py
def WritePepperGLES2Implementation(self, filename):
    """Writes the Pepper OpenGLES interface implementation."""
    with CWriter(filename, self.year) as f:
      f.write("#include \"ppapi/shared_impl/ppb_opengles2_shared.h\"\n\n")
      f.write("#include \"base/logging.h\"\n")
      f.write("#include \"gpu/command_buffer/client/gles2_implementation.h\"\n")
      f.write("#include \"ppapi/shared_impl/ppb_graphics_3d_shared.h\"\n")
      f.write("#include \"ppapi/thunk/enter.h\"\n\n")

      f.write("namespace ppapi {\n\n")
      f.write("namespace {\n\n")

      f.write("typedef thunk::EnterResource<thunk::PPB_Graphics3D_API>"
                 " Enter3D;\n\n")

      f.write("gpu::gles2::GLES2Implementation* ToGles2Impl(Enter3D*"
                 " enter) {\n")
      f.write("  DCHECK(enter);\n")
      f.write("  DCHECK(enter->succeeded());\n")
      f.write("  return static_cast<PPB_Graphics3D_Shared*>(enter->object())->"
                 "gles2_impl();\n");
      f.write("}\n\n");

      for func in self.original_functions:
        if not func.InAnyPepperExtension():
          continue

        original_arg = func.MakeTypedPepperArgString("")
        context_arg = "PP_Resource context_id"
        if len(original_arg):
          arg = context_arg + ", " + original_arg
        else:
          arg = context_arg
        f.write("%s %s(%s) {\n" %
                   (func.return_type, func.GetPepperName(), arg))
        f.write("  Enter3D enter(context_id, true);\n")
        f.write("  if (enter.succeeded()) {\n")

        return_str = "" if func.return_type == "void" else "return "
        f.write("    %sToGles2Impl(&enter)->%s(%s);\n" %
                   (return_str, func.original_name,
                    func.MakeOriginalArgString("")))
        f.write("  }")
        if func.return_type == "void":
          f.write("\n")
        else:
          f.write(" else {\n")
          f.write("    return %s;\n" % func.GetErrorReturnString())
          f.write("  }\n")
        f.write("}\n\n")

      f.write("}  // namespace\n")

      for interface in self.pepper_interfaces:
        f.write("const %s* PPB_OpenGLES2_Shared::Get%sInterface() {\n" %
                   (interface.GetStructName(), interface.GetName()))
        f.write("  static const struct %s "
                   "ppb_opengles2 = {\n" % interface.GetStructName())
        f.write("    &")
        f.write(",\n    &".join(
          f.GetPepperName() for f in self.original_functions
            if f.InPepperInterface(interface)))
        f.write("\n")

        f.write("  };\n")
        f.write("  return &ppb_opengles2;\n")
        f.write("}\n")

      f.write("}  // namespace ppapi\n")
    self.generated_cpp_filenames.append(filename)
Writes the Pepper OpenGLES interface implementation.
Writes the Pepper OpenGLES interface implementation.
Writes the Pepper OpenGLES interface implementation .
def WritePepperGLES2Implementation(self, filename):
    with CWriter(filename, self.year) as f:
      f.write("#include \"ppapi/shared_impl/ppb_opengles2_shared.h\"\n\n")
      f.write("#include \"base/logging.h\"\n")
      f.write("#include \"gpu/command_buffer/client/gles2_implementation.h\"\n")
      f.write("#include \"ppapi/shared_impl/ppb_graphics_3d_shared.h\"\n")
      f.write("#include \"ppapi/thunk/enter.h\"\n\n")
      f.write("namespace ppapi {\n\n")
      f.write("namespace {\n\n")
      f.write("typedef thunk::EnterResource<thunk::PPB_Graphics3D_API>"
                 " Enter3D;\n\n")
      f.write("gpu::gles2::GLES2Implementation* ToGles2Impl(Enter3D*"
                 " enter) {\n")
      f.write("  DCHECK(enter);\n")
      f.write("  DCHECK(enter->succeeded());\n")
      f.write("  return static_cast<PPB_Graphics3D_Shared*>(enter->object())->"
                 "gles2_impl();\n");
      f.write("}\n\n");
      for func in self.original_functions:
        if not func.InAnyPepperExtension():
          continue
        original_arg = func.MakeTypedPepperArgString("")
        context_arg = "PP_Resource context_id"
        if len(original_arg):
          arg = context_arg + ", " + original_arg
        else:
          arg = context_arg
        f.write("%s %s(%s) {\n" %
                   (func.return_type, func.GetPepperName(), arg))
        f.write("  Enter3D enter(context_id, true);\n")
        f.write("  if (enter.succeeded()) {\n")
        return_str = "" if func.return_type == "void" else "return "
        f.write("    %sToGles2Impl(&enter)->%s(%s);\n" %
                   (return_str, func.original_name,
                    func.MakeOriginalArgString("")))
        f.write("  }")
        if func.return_type == "void":
          f.write("\n")
        else:
          f.write(" else {\n")
          f.write("    return %s;\n" % func.GetErrorReturnString())
          f.write("  }\n")
        f.write("}\n\n")
      f.write("}  // namespace\n")
      for interface in self.pepper_interfaces:
        f.write("const %s* PPB_OpenGLES2_Shared::Get%sInterface() {\n" %
                   (interface.GetStructName(), interface.GetName()))
        f.write("  static const struct %s "
                   "ppb_opengles2 = {\n" % interface.GetStructName())
        f.write("    &")
        f.write(",\n    &".join(
          f.GetPepperName() for f in self.original_functions
            if f.InPepperInterface(interface)))
        f.write("\n")
        f.write("  };\n")
        f.write("  return &ppb_opengles2;\n")
        f.write("}\n")
      f.write("}  // namespace ppapi\n")
    self.generated_cpp_filenames.append(filename)
def WritePepperGLES2Implementation ( self , filename ) : with CWriter ( filename , self . year ) as f : f . write ( "#include \"ppapi/shared_impl/ppb_opengles2_shared.h\"\n\n" ) f . write ( "#include \"base/logging.h\"\n" ) f . write ( "#include \"gpu/command_buffer/client/gles2_implementation.h\"\n" ) f . write ( "#include \"ppapi/shared_impl/ppb_graphics_3d_shared.h\"\n" ) f . write ( "#include \"ppapi/thunk/enter.h\"\n\n" ) f . write ( "namespace ppapi {\n\n" ) f . write ( "namespace {\n\n" ) f . write ( "typedef thunk::EnterResource<thunk::PPB_Graphics3D_API>" " Enter3D;\n\n" ) f . write ( "gpu::gles2::GLES2Implementation* ToGles2Impl(Enter3D*" " enter) {\n" ) f . write ( "  DCHECK(enter);\n" ) f . write ( "  DCHECK(enter->succeeded());\n" ) f . write ( "  return static_cast<PPB_Graphics3D_Shared*>(enter->object())->" "gles2_impl();\n" ) ; f . write ( "}\n\n" ) ; for func in self . original_functions : if not func . InAnyPepperExtension ( ) : continue original_arg = func . MakeTypedPepperArgString ( "" ) context_arg = "PP_Resource context_id" if len ( original_arg ) : arg = context_arg + ", " + original_arg else : arg = context_arg f . write ( "%s %s(%s) {\n" % ( func . return_type , func . GetPepperName ( ) , arg ) ) f . write ( "  Enter3D enter(context_id, true);\n" ) f . write ( "  if (enter.succeeded()) {\n" ) return_str = "" if func . return_type == "void" else "return " f . write ( "    %sToGles2Impl(&enter)->%s(%s);\n" % ( return_str , func . original_name , func . MakeOriginalArgString ( "" ) ) ) f . write ( "  }" ) if func . return_type == "void" : f . write ( "\n" ) else : f . write ( " else {\n" ) f . write ( "    return %s;\n" % func . GetErrorReturnString ( ) ) f . write ( "  }\n" ) f . write ( "}\n\n" ) f . write ( "}  // namespace\n" ) for interface in self . pepper_interfaces : f . write ( "const %s* PPB_OpenGLES2_Shared::Get%sInterface() {\n" % ( interface . GetStructName ( ) , interface . GetName ( ) ) ) f . write ( "  static const struct %s " "ppb_opengles2 = {\n" % interface . GetStructName ( ) ) f . write ( "    &" ) f . write ( ",\n    &" . join ( f . GetPepperName ( ) for f in self . original_functions if f . InPepperInterface ( interface ) ) ) f . write ( "\n" ) f . write ( "  };\n" ) f . write ( "  return &ppb_opengles2;\n" ) f . write ( "}\n" ) f . write ( "}  // namespace ppapi\n" ) self . generated_cpp_filenames . append ( filename )
Writes the Pepper OpenGLES interface implementation.
Writes the Pepper OpenGLES interface implementation .
"""Writes the Pepper OpenGLES interface implementation."""
self
filename