Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(94)

Side by Side Diff: gpu/command_buffer/build_gles2_cmd_buffer.py

Issue 7409003: Binding Graphics3D with Instance and OpenGLES2 interface. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | ppapi/cpp/instance.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/python 1 #!/usr/bin/python
2 # 2 #
3 # Copyright (c) 2011 The Chromium Authors. All rights reserved. 3 # Copyright (c) 2011 The Chromium Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be 4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file. 5 # found in the LICENSE file.
6 6
7 """code generator for GLES2 command buffers.""" 7 """code generator for GLES2 command buffers."""
8 8
9 import os 9 import os
10 import os.path 10 import os.path
(...skipping 5700 matching lines...) Expand 10 before | Expand all | Expand 10 after
5711 5711
5712 file.Close() 5712 file.Close()
5713 5713
5714 def WritePepperGLES2Implementation(self, filename): 5714 def WritePepperGLES2Implementation(self, filename):
5715 """Writes the Pepper OpenGLES interface implementation.""" 5715 """Writes the Pepper OpenGLES interface implementation."""
5716 5716
5717 file = CWriter(filename) 5717 file = CWriter(filename)
5718 file.Write(_LICENSE) 5718 file.Write(_LICENSE)
5719 file.Write(_DO_NOT_EDIT_WARNING) 5719 file.Write(_DO_NOT_EDIT_WARNING)
5720 5720
5721 file.Write("#include \"webkit/plugins/ppapi/ppb_opengles_impl.h\"\n\n") 5721 file.Write("#include \"ppapi/shared_impl/opengles2_impl.h\"\n\n")
5722 file.Write("#include \"base/logging.h\"\n")
5723 file.Write("#include \"gpu/command_buffer/client/gles2_implementation.h\"\n" )
5724 file.Write("#include \"ppapi/shared_impl/graphics_3d_impl.h\"\n")
5725 file.Write("#include \"ppapi/thunk/enter.h\"\n")
5726 file.Write("#include \"ppapi/thunk/ppb_context_3d_api.h\"\n\n")
5722 5727
5723 file.Write("#include \"gpu/command_buffer/client/gles2_implementation.h\"\n" )
5724 file.Write("#include \"ppapi/c/dev/ppb_opengles_dev.h\"\n")
5725 file.Write("#include \"ppapi/shared_impl/resource_object_base.h\"\n")
5726 file.Write("#include \"ppapi/shared_impl/tracker_base.h\"\n")
5727 file.Write("#include \"webkit/plugins/ppapi/ppb_context_3d_impl.h\"\n\n")
5728
5729 file.Write("using ppapi::ResourceObjectBase;\n")
5730 file.Write("using ppapi::TrackerBase;\n\n")
5731 file.Write("namespace webkit {\n")
5732 file.Write("namespace ppapi {\n\n") 5728 file.Write("namespace ppapi {\n\n")
5733 file.Write("namespace {\n\n") 5729 file.Write("namespace {\n\n")
5734 5730
5735 file.Write("gpu::gles2::GLES2Implementation* GetGLES(PP_Resource context) {\ n") 5731 file.Write("gpu::gles2::GLES2Implementation* GetGLES(PP_Resource context) {\ n")
5736 file.Write(" ResourceObjectBase* base = TrackerBase::Get()->GetResourceAPI( context);\n") 5732 file.Write(" thunk::EnterResource<thunk::PPB_Graphics3D_API> enter_g3d(cont ext, false);\n")
5737 file.Write(" DCHECK(base->AsPPB_Context3D_API());\n") 5733 file.Write(" if (enter_g3d.succeeded()) {\n")
5738 file.Write(" return static_cast<PPB_Context3D_Impl*>(base)->gles2_impl();\n ") 5734 file.Write(" return static_cast<Graphics3DImpl*>(enter_g3d.object())->gle s2_impl();\n")
5735 file.Write(" } else {\n")
5736 file.Write(" thunk::EnterResource<thunk::PPB_Context3D_API> enter_c3d(con text, true);\n")
5737 file.Write(" DCHECK(enter_c3d.succeeded());\n")
5738 file.Write(" return enter_c3d.object()->GetGLES2Impl();\n")
5739 file.Write(" }\n")
5739 file.Write("}\n\n") 5740 file.Write("}\n\n")
5740 5741
5741 for func in self.original_functions: 5742 for func in self.original_functions:
5742 if not func.IsCoreGLFunction(): 5743 if not func.IsCoreGLFunction():
5743 continue 5744 continue
5744 5745
5745 original_arg = func.MakeTypedOriginalArgString("") 5746 original_arg = func.MakeTypedOriginalArgString("")
5746 context_arg = "PP_Resource context_id" 5747 context_arg = "PP_Resource context_id"
5747 if len(original_arg): 5748 if len(original_arg):
5748 arg = context_arg + ", " + original_arg 5749 arg = context_arg + ", " + original_arg
(...skipping 10 matching lines...) Expand all
5759 file.Write("\nconst struct PPB_OpenGLES2_Dev ppb_opengles2 = {\n") 5760 file.Write("\nconst struct PPB_OpenGLES2_Dev ppb_opengles2 = {\n")
5760 file.Write(" &") 5761 file.Write(" &")
5761 file.Write(",\n &".join( 5762 file.Write(",\n &".join(
5762 f.name for f in self.original_functions if f.IsCoreGLFunction())) 5763 f.name for f in self.original_functions if f.IsCoreGLFunction()))
5763 file.Write("\n") 5764 file.Write("\n")
5764 file.Write("};\n\n") 5765 file.Write("};\n\n")
5765 5766
5766 file.Write("} // namespace\n") 5767 file.Write("} // namespace\n")
5767 5768
5768 file.Write(""" 5769 file.Write("""
5769 const PPB_OpenGLES2_Dev* PPB_OpenGLES_Impl::GetInterface() { 5770 const PPB_OpenGLES2_Dev* OpenGLES2Impl::GetInterface() {
5770 return &ppb_opengles2; 5771 return &ppb_opengles2;
5771 } 5772 }
5772 5773
5773 """) 5774 """)
5774 file.Write("} // namespace ppapi\n") 5775 file.Write("} // namespace ppapi\n")
5775 file.Write("} // namespace webkit\n\n")
5776
5777 file.Close()
5778
5779 def WritePepperGLES2ProxyImplementation(self, filename):
5780 """Writes the Pepper OpenGLES interface implementation."""
5781
5782 file = CWriter(filename)
5783 file.Write(_LICENSE)
5784 file.Write(_DO_NOT_EDIT_WARNING)
5785
5786 file.Write("#include \"ppapi/proxy/ppb_opengles2_proxy.h\"\n\n")
5787
5788 file.Write("#include \"gpu/command_buffer/client/gles2_implementation.h\"\n" )
5789 file.Write("#include \"ppapi/c/pp_errors.h\"\n")
5790 file.Write("#include \"ppapi/c/pp_resource.h\"\n")
5791 file.Write("#include \"ppapi/c/dev/ppb_opengles_dev.h\"\n")
5792 file.Write("#include \"ppapi/proxy/plugin_dispatcher.h\"\n")
5793 file.Write("#include \"ppapi/proxy/plugin_resource.h\"\n")
5794 file.Write("#include \"ppapi/proxy/ppb_context_3d_proxy.h\"\n")
5795 file.Write("#include \"ppapi/shared_impl/resource_object_base.h\"\n")
5796 file.Write("#include \"ppapi/shared_impl/tracker_base.h\"\n\n")
5797
5798 file.Write("namespace pp {\n")
5799 file.Write("namespace proxy {\n\n")
5800 file.Write("namespace {\n\n")
5801 file.Write("gpu::gles2::GLES2Implementation* GetGLES(PP_Resource context) {\ n")
5802 file.Write(" ppapi::ResourceObjectBase* base =\n")
5803 file.Write(" ppapi::TrackerBase::Get()->GetResourceAPI(context);\n")
5804 file.Write(" DCHECK(base->AsPPB_Context3D_API());\n")
5805 file.Write(" return static_cast<Context3D*>(base)->gles2_impl();\n")
5806 file.Write("}\n\n")
5807
5808 for func in self.original_functions:
5809 if not func.IsCoreGLFunction():
5810 continue
5811
5812 original_arg = func.MakeTypedOriginalArgString("")
5813 context_arg = "PP_Resource context_id"
5814 if len(original_arg):
5815 arg = context_arg + ", " + original_arg
5816 else:
5817 arg = context_arg
5818 file.Write("%s %s(%s) {\n" % (func.return_type, func.name, arg))
5819
5820 return_str = "" if func.return_type == "void" else "return "
5821 file.Write(" %sGetGLES(context_id)->%s(%s);\n" %
5822 (return_str, func.original_name,
5823 func.MakeOriginalArgString("")))
5824 file.Write("}\n\n")
5825
5826 file.Write("const struct PPB_OpenGLES2_Dev opengles2_interface = {\n")
5827 file.Write(" &")
5828 file.Write(",\n &".join(
5829 f.name for f in self.original_functions if f.IsCoreGLFunction()))
5830 file.Write("\n")
5831 file.Write("};\n\n")
5832
5833 file.Write("""
5834 InterfaceProxy* CreateOpenGLES2Proxy(Dispatcher* dispatcher,
5835 const void* target_interface) {
5836 return new PPB_OpenGLES2_Proxy(dispatcher, target_interface);
5837 }
5838
5839 } // namespace
5840
5841 PPB_OpenGLES2_Proxy::PPB_OpenGLES2_Proxy(Dispatcher* dispatcher,
5842 const void* target_interface)
5843 : InterfaceProxy(dispatcher, target_interface) {
5844 }
5845
5846 PPB_OpenGLES2_Proxy::~PPB_OpenGLES2_Proxy() {
5847 }
5848
5849 // static
5850 const InterfaceProxy::Info* PPB_OpenGLES2_Proxy::GetInfo() {
5851 static const Info info = {
5852 &opengles2_interface,
5853 PPB_OPENGLES2_DEV_INTERFACE,
5854 INTERFACE_ID_PPB_OPENGLES2,
5855 false,
5856 &CreateOpenGLES2Proxy,
5857 };
5858 return &info;
5859 }
5860
5861 bool PPB_OpenGLES2_Proxy::OnMessageReceived(const IPC::Message& msg) {
5862 return false;
5863 }
5864
5865 """)
5866 file.Write("} // namespace proxy\n")
5867 file.Write("} // namespace pp\n")
5868
5869 file.Close() 5776 file.Close()
5870 5777
5871 def WriteGLES2ToPPAPIBridge(self, filename): 5778 def WriteGLES2ToPPAPIBridge(self, filename):
5872 """Connects GLES2 helper library to PPB_OpenGLES2 interface""" 5779 """Connects GLES2 helper library to PPB_OpenGLES2 interface"""
5873 5780
5874 file = CWriter(filename) 5781 file = CWriter(filename)
5875 file.Write(_LICENSE) 5782 file.Write(_LICENSE)
5876 file.Write(_DO_NOT_EDIT_WARNING) 5783 file.Write(_DO_NOT_EDIT_WARNING)
5877 5784
5878 file.Write("#include <GLES2/gl2.h>\n") 5785 file.Write("#include <GLES2/gl2.h>\n")
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
5988 os.chdir(options.output_dir) 5895 os.chdir(options.output_dir)
5989 5896
5990 if options.alternate_mode == "ppapi": 5897 if options.alternate_mode == "ppapi":
5991 # To trigger this action, do "make ppapi_gles_bindings" 5898 # To trigger this action, do "make ppapi_gles_bindings"
5992 os.chdir("ppapi"); 5899 os.chdir("ppapi");
5993 gen.WritePepperGLES2Interface("c/dev/ppb_opengles_dev.h") 5900 gen.WritePepperGLES2Interface("c/dev/ppb_opengles_dev.h")
5994 gen.WriteGLES2ToPPAPIBridge("lib/gl/gles2/gles2.c") 5901 gen.WriteGLES2ToPPAPIBridge("lib/gl/gles2/gles2.c")
5995 5902
5996 elif options.alternate_mode == "chrome_ppapi": 5903 elif options.alternate_mode == "chrome_ppapi":
5997 # To trigger this action, do "make ppapi_gles_implementation" 5904 # To trigger this action, do "make ppapi_gles_implementation"
5998 gen.WritePepperGLES2Implementation( 5905 gen.WritePepperGLES2Implementation("ppapi/shared_impl/opengles2_impl.cc")
5999 "webkit/plugins/ppapi/ppb_opengles_impl.cc")
6000
6001 elif options.alternate_mode == "chrome_ppapi_proxy":
6002 gen.WritePepperGLES2ProxyImplementation(
6003 "ppapi/proxy/ppb_opengles2_proxy.cc")
6004 5906
6005 elif options.alternate_mode == "nacl_ppapi": 5907 elif options.alternate_mode == "nacl_ppapi":
6006 gen.WritePepperGLES2NaClProxy( 5908 gen.WritePepperGLES2NaClProxy(
6007 "native_client/src/shared/ppapi_proxy/plugin_opengles.cc") 5909 "native_client/src/shared/ppapi_proxy/plugin_opengles.cc")
6008 5910
6009 else: 5911 else:
6010 os.chdir("gpu/command_buffer") 5912 os.chdir("gpu/command_buffer")
6011 gen.WriteCommandIds("common/gles2_cmd_ids_autogen.h") 5913 gen.WriteCommandIds("common/gles2_cmd_ids_autogen.h")
6012 gen.WriteFormat("common/gles2_cmd_format_autogen.h") 5914 gen.WriteFormat("common/gles2_cmd_format_autogen.h")
6013 gen.WriteFormatTest("common/gles2_cmd_format_test_autogen.h") 5915 gen.WriteFormatTest("common/gles2_cmd_format_test_autogen.h")
(...skipping 13 matching lines...) Expand all
6027 5929
6028 if options.generate_docs: 5930 if options.generate_docs:
6029 gen.WriteDocs("docs/gles2_cmd_format_docs_autogen.h") 5931 gen.WriteDocs("docs/gles2_cmd_format_docs_autogen.h")
6030 5932
6031 if gen.errors > 0: 5933 if gen.errors > 0:
6032 print "%d errors" % gen.errors 5934 print "%d errors" % gen.errors
6033 sys.exit(1) 5935 sys.exit(1)
6034 5936
6035 if __name__ == '__main__': 5937 if __name__ == '__main__':
6036 main(sys.argv[1:]) 5938 main(sys.argv[1:])
OLDNEW
« no previous file with comments | « no previous file | ppapi/cpp/instance.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698