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 4021 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4032 self.WriteClientGLReturnLog(func, file) | 4032 self.WriteClientGLReturnLog(func, file) |
4033 file.Write("}\n") | 4033 file.Write("}\n") |
4034 file.Write("\n") | 4034 file.Write("\n") |
4035 | 4035 |
4036 def WriteGLES2InterfaceHeader(self, func, file): | 4036 def WriteGLES2InterfaceHeader(self, func, file): |
4037 """Writes the GLES2 Interface.""" | 4037 """Writes the GLES2 Interface.""" |
4038 file.Write("virtual %s %s(%s) = 0;\n" % | 4038 file.Write("virtual %s %s(%s) = 0;\n" % |
4039 (func.return_type, func.original_name, | 4039 (func.return_type, func.original_name, |
4040 func.MakeTypedOriginalArgString(""))) | 4040 func.MakeTypedOriginalArgString(""))) |
4041 | 4041 |
4042 def WriteMojoGLES2ImplHeader(self, func, file): | |
4043 """Writes the Mojo GLES2 implementation header.""" | |
4044 file.Write("%s %s(%s) override;\n" % | |
4045 (func.return_type, func.original_name, | |
4046 func.MakeTypedOriginalArgString(""))) | |
4047 | |
4048 def WriteMojoGLES2Impl(self, func, file): | |
4049 """Writes the Mojo GLES2 implementation.""" | |
4050 file.Write("%s MojoGLES2Impl::%s(%s) {\n" % | |
4051 (func.return_type, func.original_name, | |
4052 func.MakeTypedOriginalArgString(""))) | |
4053 # TODO(alhaad): Add Mojo C thunk for each of the following methods and | |
4054 # remove this. | |
4055 func_list = ["GenQueriesEXT", "BeginQueryEXT", "MapTexSubImage2DCHROMIUM", | |
4056 "UnmapTexSubImage2DCHROMIUM", "DeleteQueriesEXT", | |
4057 "EndQueryEXT", "GetQueryObjectuivEXT", "ShallowFlushCHROMIUM", | |
4058 "GenMailboxCHROMIUM", "ProduceTextureDirectCHROMIUM", | |
4059 "InsertSyncPointCHROMIUM"] | |
jamesr
2015/03/19 18:22:50
we have mojo C thunks for InsertSyncPointCHROMIUM:
alhaad
2015/03/19 23:14:59
Is it ok if I add it when I have added all the oth
| |
4060 if func.original_name in func_list: | |
4061 file.Write("return static_cast<gpu::gles2::GLES2Interface*>" | |
4062 "(MojoGLES2GetGLES2Interface(context_))->" + | |
4063 func.original_name + "(" + func.MakeOriginalArgString("") + | |
4064 ");") | |
4065 file.Write("}") | |
4066 return | |
4067 if func.IsCoreGLFunction(): | |
4068 file.Write("MojoGLES2MakeCurrent(context_);"); | |
4069 func_return = "gl" + func.original_name + "(" + \ | |
4070 func.MakeOriginalArgString("") + ");" | |
4071 if func.return_type == "void": | |
4072 file.Write(func_return); | |
4073 else: | |
4074 file.Write("return " + func_return); | |
4075 else: | |
4076 file.Write("NOTREACHED() << \"Unimplemented %s.\";\n" % | |
4077 func.original_name); | |
4078 if func.return_type != "void": | |
4079 file.Write("return 0;") | |
4080 file.Write("}") | |
4081 | |
4042 def WriteGLES2InterfaceStub(self, func, file): | 4082 def WriteGLES2InterfaceStub(self, func, file): |
4043 """Writes the GLES2 Interface stub declaration.""" | 4083 """Writes the GLES2 Interface stub declaration.""" |
4044 file.Write("%s %s(%s) override;\n" % | 4084 file.Write("%s %s(%s) override;\n" % |
4045 (func.return_type, func.original_name, | 4085 (func.return_type, func.original_name, |
4046 func.MakeTypedOriginalArgString(""))) | 4086 func.MakeTypedOriginalArgString(""))) |
4047 | 4087 |
4048 def WriteGLES2InterfaceStubImpl(self, func, file): | 4088 def WriteGLES2InterfaceStubImpl(self, func, file): |
4049 """Writes the GLES2 Interface stub declaration.""" | 4089 """Writes the GLES2 Interface stub declaration.""" |
4050 args = func.GetOriginalArgs() | 4090 args = func.GetOriginalArgs() |
4051 arg_string = ", ".join( | 4091 arg_string = ", ".join( |
(...skipping 4682 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
8734 self.type_handler.WriteServiceUnitTest(self, file, *extras) | 8774 self.type_handler.WriteServiceUnitTest(self, file, *extras) |
8735 | 8775 |
8736 def WriteGLES2CLibImplementation(self, file): | 8776 def WriteGLES2CLibImplementation(self, file): |
8737 """Writes the GLES2 C Lib Implemention.""" | 8777 """Writes the GLES2 C Lib Implemention.""" |
8738 self.type_handler.WriteGLES2CLibImplementation(self, file) | 8778 self.type_handler.WriteGLES2CLibImplementation(self, file) |
8739 | 8779 |
8740 def WriteGLES2InterfaceHeader(self, file): | 8780 def WriteGLES2InterfaceHeader(self, file): |
8741 """Writes the GLES2 Interface declaration.""" | 8781 """Writes the GLES2 Interface declaration.""" |
8742 self.type_handler.WriteGLES2InterfaceHeader(self, file) | 8782 self.type_handler.WriteGLES2InterfaceHeader(self, file) |
8743 | 8783 |
8784 def WriteMojoGLES2ImplHeader(self, file): | |
8785 """Writes the Mojo GLES2 implementation header declaration.""" | |
8786 self.type_handler.WriteMojoGLES2ImplHeader(self, file) | |
8787 | |
8788 def WriteMojoGLES2Impl(self, file): | |
8789 """Writes the Mojo GLES2 implementation declaration.""" | |
8790 self.type_handler.WriteMojoGLES2Impl(self, file) | |
8791 | |
8744 def WriteGLES2InterfaceStub(self, file): | 8792 def WriteGLES2InterfaceStub(self, file): |
8745 """Writes the GLES2 Interface Stub declaration.""" | 8793 """Writes the GLES2 Interface Stub declaration.""" |
8746 self.type_handler.WriteGLES2InterfaceStub(self, file) | 8794 self.type_handler.WriteGLES2InterfaceStub(self, file) |
8747 | 8795 |
8748 def WriteGLES2InterfaceStubImpl(self, file): | 8796 def WriteGLES2InterfaceStubImpl(self, file): |
8749 """Writes the GLES2 Interface Stub declaration.""" | 8797 """Writes the GLES2 Interface Stub declaration.""" |
8750 self.type_handler.WriteGLES2InterfaceStubImpl(self, file) | 8798 self.type_handler.WriteGLES2InterfaceStubImpl(self, file) |
8751 | 8799 |
8752 def WriteGLES2ImplementationHeader(self, file): | 8800 def WriteGLES2ImplementationHeader(self, file): |
8753 """Writes the GLES2 Implemention declaration.""" | 8801 """Writes the GLES2 Implemention declaration.""" |
(...skipping 1003 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
9757 """Writes the GLES2 interface header.""" | 9805 """Writes the GLES2 interface header.""" |
9758 file = CHeaderWriter( | 9806 file = CHeaderWriter( |
9759 filename, | 9807 filename, |
9760 "// This file is included by gles2_interface.h to declare the\n" | 9808 "// This file is included by gles2_interface.h to declare the\n" |
9761 "// GL api functions.\n") | 9809 "// GL api functions.\n") |
9762 for func in self.original_functions: | 9810 for func in self.original_functions: |
9763 func.WriteGLES2InterfaceHeader(file) | 9811 func.WriteGLES2InterfaceHeader(file) |
9764 file.Close() | 9812 file.Close() |
9765 self.generated_cpp_filenames.append(file.filename) | 9813 self.generated_cpp_filenames.append(file.filename) |
9766 | 9814 |
9815 def WriteMojoGLES2ImplHeader(self, filename): | |
9816 """Writes the Mojo GLES2 implementation header.""" | |
9817 file = CHeaderWriter( | |
9818 filename, | |
9819 "// This file is included by gles2_interface.h to declare the\n" | |
9820 "// GL api functions.\n") | |
9821 | |
9822 code = """ | |
9823 #include "gpu/command_buffer/client/gles2_interface.h" | |
9824 #include "third_party/mojo/src/mojo/public/c/gles2/gles2.h" | |
9825 | |
9826 namespace mojo { | |
9827 | |
9828 class MojoGLES2Impl : public gpu::gles2::GLES2Interface { | |
9829 public: | |
9830 MojoGLES2Impl(MojoGLES2Context context) { | |
9831 context_ = context; | |
9832 } | |
9833 """ | |
9834 file.Write(code); | |
9835 for func in self.original_functions: | |
9836 func.WriteMojoGLES2ImplHeader(file) | |
9837 code = """ | |
9838 private: | |
9839 MojoGLES2Context context_; | |
9840 }; | |
9841 | |
9842 } // namespace mojo | |
9843 """ | |
9844 file.Write(code); | |
9845 file.Close() | |
9846 self.generated_cpp_filenames.append(file.filename) | |
9847 | |
9848 def WriteMojoGLES2Impl(self, filename): | |
9849 """Writes the Mojo GLES2 implementation.""" | |
9850 file = CWriter(filename) | |
9851 file.Write(_LICENSE) | |
9852 file.Write(_DO_NOT_EDIT_WARNING) | |
9853 | |
9854 code = """ | |
9855 #include "gpu/command_buffer/client/mojo_gles2_impl_autogen.h" | |
9856 | |
9857 #include "base/logging.h" | |
9858 #include "third_party/khronos/GLES2/gl2.h" | |
9859 | |
9860 namespace mojo { | |
9861 | |
9862 """ | |
9863 file.Write(code); | |
9864 for func in self.original_functions: | |
9865 func.WriteMojoGLES2Impl(file) | |
9866 code = """ | |
9867 | |
9868 } // namespace mojo | |
9869 """ | |
9870 file.Write(code); | |
9871 file.Close() | |
9872 self.generated_cpp_filenames.append(file.filename) | |
9873 | |
9767 def WriteGLES2InterfaceStub(self, filename): | 9874 def WriteGLES2InterfaceStub(self, filename): |
9768 """Writes the GLES2 interface stub header.""" | 9875 """Writes the GLES2 interface stub header.""" |
9769 file = CHeaderWriter( | 9876 file = CHeaderWriter( |
9770 filename, | 9877 filename, |
9771 "// This file is included by gles2_interface_stub.h.\n") | 9878 "// This file is included by gles2_interface_stub.h.\n") |
9772 for func in self.original_functions: | 9879 for func in self.original_functions: |
9773 func.WriteGLES2InterfaceStub(file) | 9880 func.WriteGLES2InterfaceStub(file) |
9774 file.Close() | 9881 file.Close() |
9775 self.generated_cpp_filenames.append(file.filename) | 9882 self.generated_cpp_filenames.append(file.filename) |
9776 | 9883 |
(...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
10261 gen.WriteGLES2ToPPAPIBridge("ppapi/lib/gl/gles2/gles2.c") | 10368 gen.WriteGLES2ToPPAPIBridge("ppapi/lib/gl/gles2/gles2.c") |
10262 gen.WritePepperGLES2Implementation( | 10369 gen.WritePepperGLES2Implementation( |
10263 "ppapi/shared_impl/ppb_opengles2_shared.cc") | 10370 "ppapi/shared_impl/ppb_opengles2_shared.cc") |
10264 os.chdir(base_dir) | 10371 os.chdir(base_dir) |
10265 gen.WriteCommandIds("gpu/command_buffer/common/gles2_cmd_ids_autogen.h") | 10372 gen.WriteCommandIds("gpu/command_buffer/common/gles2_cmd_ids_autogen.h") |
10266 gen.WriteFormat("gpu/command_buffer/common/gles2_cmd_format_autogen.h") | 10373 gen.WriteFormat("gpu/command_buffer/common/gles2_cmd_format_autogen.h") |
10267 gen.WriteFormatTest( | 10374 gen.WriteFormatTest( |
10268 "gpu/command_buffer/common/gles2_cmd_format_test_autogen.h") | 10375 "gpu/command_buffer/common/gles2_cmd_format_test_autogen.h") |
10269 gen.WriteGLES2InterfaceHeader( | 10376 gen.WriteGLES2InterfaceHeader( |
10270 "gpu/command_buffer/client/gles2_interface_autogen.h") | 10377 "gpu/command_buffer/client/gles2_interface_autogen.h") |
10378 gen.WriteMojoGLES2ImplHeader( | |
10379 "gpu/command_buffer/client/mojo_gles2_impl_autogen.h") | |
10380 gen.WriteMojoGLES2Impl( | |
10381 "gpu/command_buffer/client/mojo_gles2_impl_autogen.cc") | |
10271 gen.WriteGLES2InterfaceStub( | 10382 gen.WriteGLES2InterfaceStub( |
10272 "gpu/command_buffer/client/gles2_interface_stub_autogen.h") | 10383 "gpu/command_buffer/client/gles2_interface_stub_autogen.h") |
10273 gen.WriteGLES2InterfaceStubImpl( | 10384 gen.WriteGLES2InterfaceStubImpl( |
10274 "gpu/command_buffer/client/gles2_interface_stub_impl_autogen.h") | 10385 "gpu/command_buffer/client/gles2_interface_stub_impl_autogen.h") |
10275 gen.WriteGLES2ImplementationHeader( | 10386 gen.WriteGLES2ImplementationHeader( |
10276 "gpu/command_buffer/client/gles2_implementation_autogen.h") | 10387 "gpu/command_buffer/client/gles2_implementation_autogen.h") |
10277 gen.WriteGLES2Implementation( | 10388 gen.WriteGLES2Implementation( |
10278 "gpu/command_buffer/client/gles2_implementation_impl_autogen.h") | 10389 "gpu/command_buffer/client/gles2_implementation_impl_autogen.h") |
10279 gen.WriteGLES2ImplementationUnitTests( | 10390 gen.WriteGLES2ImplementationUnitTests( |
10280 "gpu/command_buffer/client/gles2_implementation_unittest_autogen.h") | 10391 "gpu/command_buffer/client/gles2_implementation_unittest_autogen.h") |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
10324 Format(gen.generated_cpp_filenames) | 10435 Format(gen.generated_cpp_filenames) |
10325 | 10436 |
10326 if gen.errors > 0: | 10437 if gen.errors > 0: |
10327 print "%d errors" % gen.errors | 10438 print "%d errors" % gen.errors |
10328 return 1 | 10439 return 1 |
10329 return 0 | 10440 return 0 |
10330 | 10441 |
10331 | 10442 |
10332 if __name__ == '__main__': | 10443 if __name__ == '__main__': |
10333 sys.exit(main(sys.argv[1:])) | 10444 sys.exit(main(sys.argv[1:])) |
OLD | NEW |