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

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') | ppapi/thunk/ppb_context_3d_api.h » ('J')
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 1721 matching lines...) Expand 10 before | Expand all | Expand 10 after
1732 'RequestExtensionCHROMIUM': { 1732 'RequestExtensionCHROMIUM': {
1733 'type': 'Custom', 1733 'type': 'Custom',
1734 'impl_func': False, 1734 'impl_func': False,
1735 'immediate': False, 1735 'immediate': False,
1736 'cmd_args': 'uint32 bucket_id', 1736 'cmd_args': 'uint32 bucket_id',
1737 'extension': True, 1737 'extension': True,
1738 'chromium': True, 1738 'chromium': True,
1739 }, 1739 },
1740 'SetLatchCHROMIUM': { 1740 'SetLatchCHROMIUM': {
1741 'type': 'Custom', 1741 'type': 'Custom',
1742 'extension': True,
1743 'chromium': True,
1742 }, 1744 },
1743 'WaitLatchCHROMIUM': { 1745 'WaitLatchCHROMIUM': {
1744 'type': 'Custom', 1746 'type': 'Custom',
1747 'extension': True,
1748 'chromium': True,
1745 }, 1749 },
1746 'RateLimitOffscreenContextCHROMIUM': { 1750 'RateLimitOffscreenContextCHROMIUM': {
1747 'gen_cmd': False, 1751 'gen_cmd': False,
1748 'extension': True, 1752 'extension': True,
1749 'chromium': True, 1753 'chromium': True,
1750 }, 1754 },
1751 } 1755 }
1752 1756
1753 1757
1754 def SplitWords(input_string): 1758 def SplitWords(input_string):
(...skipping 3966 matching lines...) Expand 10 before | Expand all | Expand 10 after
5721 5725
5722 file.Close() 5726 file.Close()
5723 5727
5724 def WritePepperGLES2Implementation(self, filename): 5728 def WritePepperGLES2Implementation(self, filename):
5725 """Writes the Pepper OpenGLES interface implementation.""" 5729 """Writes the Pepper OpenGLES interface implementation."""
5726 5730
5727 file = CWriter(filename) 5731 file = CWriter(filename)
5728 file.Write(_LICENSE) 5732 file.Write(_LICENSE)
5729 file.Write(_DO_NOT_EDIT_WARNING) 5733 file.Write(_DO_NOT_EDIT_WARNING)
5730 5734
5731 file.Write("#include \"webkit/plugins/ppapi/ppb_opengles_impl.h\"\n\n") 5735 file.Write("#include \"ppapi/shared_impl/opengles2_impl.h\"\n\n")
5736 file.Write("#include \"gpu/command_buffer/client/gles2_implementation.h\"\n" )
5737 file.Write("#include \"ppapi/shared_impl/graphics_3d_impl.h\"\n")
5738 file.Write("#include \"ppapi/thunk/enter.h\"\n")
5739 file.Write("#include \"ppapi/thunk/ppb_context_3d_api.h\"\n\n")
5732 5740
5733 file.Write("#include \"gpu/command_buffer/client/gles2_implementation.h\"\n" )
5734 file.Write("#include \"ppapi/c/dev/ppb_opengles_dev.h\"\n")
5735 file.Write("#include \"ppapi/shared_impl/resource_object_base.h\"\n")
5736 file.Write("#include \"ppapi/shared_impl/tracker_base.h\"\n")
5737 file.Write("#include \"webkit/plugins/ppapi/ppb_context_3d_impl.h\"\n\n")
5738
5739 file.Write("using ppapi::ResourceObjectBase;\n")
5740 file.Write("using ppapi::TrackerBase;\n\n")
5741 file.Write("namespace webkit {\n")
5742 file.Write("namespace ppapi {\n\n") 5741 file.Write("namespace ppapi {\n\n")
5743 file.Write("namespace {\n\n") 5742 file.Write("namespace {\n\n")
5744 5743
5745 file.Write("gpu::gles2::GLES2Implementation* GetGLES(PP_Resource context) {\ n") 5744 file.Write("gpu::gles2::GLES2Implementation* GetGLES(PP_Resource context) {\ n")
5746 file.Write(" ResourceObjectBase* base = TrackerBase::Get()->GetResourceAPI( context);\n") 5745 file.Write(" thunk::EnterResource<thunk::PPB_Graphics3D_API> enter_g3d(cont ext, false);\n")
5747 file.Write(" DCHECK(base->AsPPB_Context3D_API());\n") 5746 file.Write(" if (enter_g3d.succeeded()) {\n")
5748 file.Write(" return static_cast<PPB_Context3D_Impl*>(base)->gles2_impl();\n ") 5747 file.Write(" return static_cast<Graphics3DImpl*>(enter_g3d.object())->gle s2_impl();\n")
5748 file.Write(" }\n")
5749 file.Write(" else {\n")
piman 2011/07/18 23:04:19 Merge 2 lines: '} else {' is the right style.
alokp 2011/07/19 16:32:59 Done.
5750 file.Write(" thunk::EnterResource<thunk::PPB_Context3D_API> enter_c3d(con text, true);\n")
5751 file.Write(" DCHECK(enter_c3d.succeeded());\n")
5752 file.Write(" return enter_c3d.object()->GetGLES2Impl();\n")
5753 file.Write(" }\n")
5749 file.Write("}\n\n") 5754 file.Write("}\n\n")
5750 5755
5751 for func in self.original_functions: 5756 for func in self.original_functions:
5752 if not func.IsCoreGLFunction(): 5757 if not func.IsCoreGLFunction():
5753 continue 5758 continue
5754 5759
5755 original_arg = func.MakeTypedOriginalArgString("") 5760 original_arg = func.MakeTypedOriginalArgString("")
5756 context_arg = "PP_Resource context_id" 5761 context_arg = "PP_Resource context_id"
5757 if len(original_arg): 5762 if len(original_arg):
5758 arg = context_arg + ", " + original_arg 5763 arg = context_arg + ", " + original_arg
(...skipping 10 matching lines...) Expand all
5769 file.Write("\nconst struct PPB_OpenGLES2_Dev ppb_opengles2 = {\n") 5774 file.Write("\nconst struct PPB_OpenGLES2_Dev ppb_opengles2 = {\n")
5770 file.Write(" &") 5775 file.Write(" &")
5771 file.Write(",\n &".join( 5776 file.Write(",\n &".join(
5772 f.name for f in self.original_functions if f.IsCoreGLFunction())) 5777 f.name for f in self.original_functions if f.IsCoreGLFunction()))
5773 file.Write("\n") 5778 file.Write("\n")
5774 file.Write("};\n\n") 5779 file.Write("};\n\n")
5775 5780
5776 file.Write("} // namespace\n") 5781 file.Write("} // namespace\n")
5777 5782
5778 file.Write(""" 5783 file.Write("""
5779 const PPB_OpenGLES2_Dev* PPB_OpenGLES_Impl::GetInterface() { 5784 const PPB_OpenGLES2_Dev* OpenGLES2Impl::GetInterface() {
5780 return &ppb_opengles2; 5785 return &ppb_opengles2;
5781 } 5786 }
5782 5787
5783 """) 5788 """)
5784 file.Write("} // namespace ppapi\n") 5789 file.Write("} // namespace ppapi\n")
5785 file.Write("} // namespace webkit\n\n")
5786
5787 file.Close()
5788
5789 def WritePepperGLES2ProxyImplementation(self, filename):
5790 """Writes the Pepper OpenGLES interface implementation."""
5791
5792 file = CWriter(filename)
5793 file.Write(_LICENSE)
5794 file.Write(_DO_NOT_EDIT_WARNING)
5795
5796 file.Write("#include \"ppapi/proxy/ppb_opengles2_proxy.h\"\n\n")
5797
5798 file.Write("#include \"gpu/command_buffer/client/gles2_implementation.h\"\n" )
5799 file.Write("#include \"ppapi/c/pp_errors.h\"\n")
5800 file.Write("#include \"ppapi/c/pp_resource.h\"\n")
5801 file.Write("#include \"ppapi/c/dev/ppb_opengles_dev.h\"\n")
5802 file.Write("#include \"ppapi/proxy/plugin_dispatcher.h\"\n")
5803 file.Write("#include \"ppapi/proxy/plugin_resource.h\"\n")
5804 file.Write("#include \"ppapi/proxy/ppb_context_3d_proxy.h\"\n")
5805 file.Write("#include \"ppapi/shared_impl/resource_object_base.h\"\n")
5806 file.Write("#include \"ppapi/shared_impl/tracker_base.h\"\n\n")
5807
5808 file.Write("namespace pp {\n")
5809 file.Write("namespace proxy {\n\n")
5810 file.Write("namespace {\n\n")
5811 file.Write("gpu::gles2::GLES2Implementation* GetGLES(PP_Resource context) {\ n")
5812 file.Write(" ppapi::ResourceObjectBase* base =\n")
5813 file.Write(" ppapi::TrackerBase::Get()->GetResourceAPI(context);\n")
5814 file.Write(" DCHECK(base->AsPPB_Context3D_API());\n")
5815 file.Write(" return static_cast<Context3D*>(base)->gles2_impl();\n")
5816 file.Write("}\n\n")
5817
5818 for func in self.original_functions:
5819 if not func.IsCoreGLFunction():
5820 continue
5821
5822 original_arg = func.MakeTypedOriginalArgString("")
5823 context_arg = "PP_Resource context_id"
5824 if len(original_arg):
5825 arg = context_arg + ", " + original_arg
5826 else:
5827 arg = context_arg
5828 file.Write("%s %s(%s) {\n" % (func.return_type, func.name, arg))
5829
5830 return_str = "" if func.return_type == "void" else "return "
5831 file.Write(" %sGetGLES(context_id)->%s(%s);\n" %
5832 (return_str, func.original_name,
5833 func.MakeOriginalArgString("")))
5834 file.Write("}\n\n")
5835
5836 file.Write("const struct PPB_OpenGLES2_Dev opengles2_interface = {\n")
5837 file.Write(" &")
5838 file.Write(",\n &".join(
5839 f.name for f in self.original_functions if f.IsCoreGLFunction()))
5840 file.Write("\n")
5841 file.Write("};\n\n")
5842
5843 file.Write("""
5844 InterfaceProxy* CreateOpenGLES2Proxy(Dispatcher* dispatcher,
5845 const void* target_interface) {
5846 return new PPB_OpenGLES2_Proxy(dispatcher, target_interface);
5847 }
5848
5849 } // namespace
5850
5851 PPB_OpenGLES2_Proxy::PPB_OpenGLES2_Proxy(Dispatcher* dispatcher,
5852 const void* target_interface)
5853 : InterfaceProxy(dispatcher, target_interface) {
5854 }
5855
5856 PPB_OpenGLES2_Proxy::~PPB_OpenGLES2_Proxy() {
5857 }
5858
5859 // static
5860 const InterfaceProxy::Info* PPB_OpenGLES2_Proxy::GetInfo() {
5861 static const Info info = {
5862 &opengles2_interface,
5863 PPB_OPENGLES2_DEV_INTERFACE,
5864 INTERFACE_ID_PPB_OPENGLES2,
5865 false,
5866 &CreateOpenGLES2Proxy,
5867 };
5868 return &info;
5869 }
5870
5871 bool PPB_OpenGLES2_Proxy::OnMessageReceived(const IPC::Message& msg) {
5872 return false;
5873 }
5874
5875 """)
5876 file.Write("} // namespace proxy\n")
5877 file.Write("} // namespace pp\n")
5878
5879 file.Close() 5790 file.Close()
5880 5791
5881 def WriteGLES2ToPPAPIBridge(self, filename): 5792 def WriteGLES2ToPPAPIBridge(self, filename):
5882 """Connects GLES2 helper library to PPB_OpenGLES2 interface""" 5793 """Connects GLES2 helper library to PPB_OpenGLES2 interface"""
5883 5794
5884 file = CWriter(filename) 5795 file = CWriter(filename)
5885 file.Write(_LICENSE) 5796 file.Write(_LICENSE)
5886 file.Write(_DO_NOT_EDIT_WARNING) 5797 file.Write(_DO_NOT_EDIT_WARNING)
5887 5798
5888 file.Write("#include <GLES2/gl2.h>\n") 5799 file.Write("#include <GLES2/gl2.h>\n")
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
5998 os.chdir(options.output_dir) 5909 os.chdir(options.output_dir)
5999 5910
6000 if options.alternate_mode == "ppapi": 5911 if options.alternate_mode == "ppapi":
6001 # To trigger this action, do "make ppapi_gles_bindings" 5912 # To trigger this action, do "make ppapi_gles_bindings"
6002 os.chdir("ppapi"); 5913 os.chdir("ppapi");
6003 gen.WritePepperGLES2Interface("c/dev/ppb_opengles_dev.h") 5914 gen.WritePepperGLES2Interface("c/dev/ppb_opengles_dev.h")
6004 gen.WriteGLES2ToPPAPIBridge("lib/gl/gles2/gles2.c") 5915 gen.WriteGLES2ToPPAPIBridge("lib/gl/gles2/gles2.c")
6005 5916
6006 elif options.alternate_mode == "chrome_ppapi": 5917 elif options.alternate_mode == "chrome_ppapi":
6007 # To trigger this action, do "make ppapi_gles_implementation" 5918 # To trigger this action, do "make ppapi_gles_implementation"
6008 gen.WritePepperGLES2Implementation( 5919 gen.WritePepperGLES2Implementation("ppapi/shared_impl/opengles2_impl.cc")
6009 "webkit/plugins/ppapi/ppb_opengles_impl.cc")
6010
6011 elif options.alternate_mode == "chrome_ppapi_proxy":
6012 gen.WritePepperGLES2ProxyImplementation(
6013 "ppapi/proxy/ppb_opengles2_proxy.cc")
6014 5920
6015 elif options.alternate_mode == "nacl_ppapi": 5921 elif options.alternate_mode == "nacl_ppapi":
6016 gen.WritePepperGLES2NaClProxy( 5922 gen.WritePepperGLES2NaClProxy(
6017 "native_client/src/shared/ppapi_proxy/plugin_opengles.cc") 5923 "native_client/src/shared/ppapi_proxy/plugin_opengles.cc")
6018 5924
6019 else: 5925 else:
6020 os.chdir("gpu/command_buffer") 5926 os.chdir("gpu/command_buffer")
6021 gen.WriteCommandIds("common/gles2_cmd_ids_autogen.h") 5927 gen.WriteCommandIds("common/gles2_cmd_ids_autogen.h")
6022 gen.WriteFormat("common/gles2_cmd_format_autogen.h") 5928 gen.WriteFormat("common/gles2_cmd_format_autogen.h")
6023 gen.WriteFormatTest("common/gles2_cmd_format_test_autogen.h") 5929 gen.WriteFormatTest("common/gles2_cmd_format_test_autogen.h")
(...skipping 13 matching lines...) Expand all
6037 5943
6038 if options.generate_docs: 5944 if options.generate_docs:
6039 gen.WriteDocs("docs/gles2_cmd_format_docs_autogen.h") 5945 gen.WriteDocs("docs/gles2_cmd_format_docs_autogen.h")
6040 5946
6041 if gen.errors > 0: 5947 if gen.errors > 0:
6042 print "%d errors" % gen.errors 5948 print "%d errors" % gen.errors
6043 sys.exit(1) 5949 sys.exit(1)
6044 5950
6045 if __name__ == '__main__': 5951 if __name__ == '__main__':
6046 main(sys.argv[1:]) 5952 main(sys.argv[1:])
OLDNEW
« no previous file with comments | « no previous file | ppapi/cpp/instance.h » ('j') | ppapi/thunk/ppb_context_3d_api.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698