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

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

Issue 993253003: Modify build_gles2_cmd_buffer.py to generate a class that implements gpu::GLES2Interace and for eac… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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
« no previous file with comments | « no previous file | gpu/command_buffer/client/gles2_c_lib_autogen.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/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 4184 matching lines...) Expand 10 before | Expand all | Expand 10 after
4195 self.WriteClientGLReturnLog(func, file) 4195 self.WriteClientGLReturnLog(func, file)
4196 file.Write("}\n") 4196 file.Write("}\n")
4197 file.Write("\n") 4197 file.Write("\n")
4198 4198
4199 def WriteGLES2InterfaceHeader(self, func, file): 4199 def WriteGLES2InterfaceHeader(self, func, file):
4200 """Writes the GLES2 Interface.""" 4200 """Writes the GLES2 Interface."""
4201 file.Write("virtual %s %s(%s) = 0;\n" % 4201 file.Write("virtual %s %s(%s) = 0;\n" %
4202 (func.return_type, func.original_name, 4202 (func.return_type, func.original_name,
4203 func.MakeTypedOriginalArgString(""))) 4203 func.MakeTypedOriginalArgString("")))
4204 4204
4205 def WriteMojoGLES2ImplHeader(self, func, file):
4206 """Writes the Mojo GLES2 implementation header."""
4207 file.Write("%s %s(%s) override;\n" %
4208 (func.return_type, func.original_name,
4209 func.MakeTypedOriginalArgString("")))
4210
4211 def WriteMojoGLES2Impl(self, func, file):
4212 """Writes the Mojo GLES2 implementation."""
4213 file.Write("%s MojoGLES2Impl::%s(%s) {\n" %
4214 (func.return_type, func.original_name,
4215 func.MakeTypedOriginalArgString("")))
4216 # TODO(alhaad): Add Mojo C thunk for each of the following methods and
4217 # remove this.
4218 func_list = ["GenQueriesEXT", "BeginQueryEXT", "MapTexSubImage2DCHROMIUM",
4219 "UnmapTexSubImage2DCHROMIUM", "DeleteQueriesEXT",
4220 "EndQueryEXT", "GetQueryObjectuivEXT", "ShallowFlushCHROMIUM"]
4221 if func.original_name in func_list:
4222 file.Write("return static_cast<gpu::gles2::GLES2Interface*>"
4223 "(MojoGLES2GetGLES2Interface(context_))->" +
4224 func.original_name + "(" + func.MakeOriginalArgString("") +
4225 ");")
4226 file.Write("}")
4227 return
4228
4229 extensions = ["CHROMIUM_sync_point", "CHROMIUM_texture_mailbox"]
4230 if func.IsCoreGLFunction() or func.GetInfo("extension") in extensions:
4231 file.Write("MojoGLES2MakeCurrent(context_);");
4232 func_return = "gl" + func.original_name + "(" + \
4233 func.MakeOriginalArgString("") + ");"
4234 if func.return_type == "void":
4235 file.Write(func_return);
4236 else:
4237 file.Write("return " + func_return);
4238 else:
4239 file.Write("NOTREACHED() << \"Unimplemented %s.\";\n" %
4240 func.original_name);
4241 if func.return_type != "void":
4242 file.Write("return 0;")
4243 file.Write("}")
4244
4205 def WriteGLES2InterfaceStub(self, func, file): 4245 def WriteGLES2InterfaceStub(self, func, file):
4206 """Writes the GLES2 Interface stub declaration.""" 4246 """Writes the GLES2 Interface stub declaration."""
4207 file.Write("%s %s(%s) override;\n" % 4247 file.Write("%s %s(%s) override;\n" %
4208 (func.return_type, func.original_name, 4248 (func.return_type, func.original_name,
4209 func.MakeTypedOriginalArgString(""))) 4249 func.MakeTypedOriginalArgString("")))
4210 4250
4211 def WriteGLES2InterfaceStubImpl(self, func, file): 4251 def WriteGLES2InterfaceStubImpl(self, func, file):
4212 """Writes the GLES2 Interface stub declaration.""" 4252 """Writes the GLES2 Interface stub declaration."""
4213 args = func.GetOriginalArgs() 4253 args = func.GetOriginalArgs()
4214 arg_string = ", ".join( 4254 arg_string = ", ".join(
(...skipping 4689 matching lines...) Expand 10 before | Expand all | Expand 10 after
8904 self.type_handler.WriteServiceUnitTest(self, file, *extras) 8944 self.type_handler.WriteServiceUnitTest(self, file, *extras)
8905 8945
8906 def WriteGLES2CLibImplementation(self, file): 8946 def WriteGLES2CLibImplementation(self, file):
8907 """Writes the GLES2 C Lib Implemention.""" 8947 """Writes the GLES2 C Lib Implemention."""
8908 self.type_handler.WriteGLES2CLibImplementation(self, file) 8948 self.type_handler.WriteGLES2CLibImplementation(self, file)
8909 8949
8910 def WriteGLES2InterfaceHeader(self, file): 8950 def WriteGLES2InterfaceHeader(self, file):
8911 """Writes the GLES2 Interface declaration.""" 8951 """Writes the GLES2 Interface declaration."""
8912 self.type_handler.WriteGLES2InterfaceHeader(self, file) 8952 self.type_handler.WriteGLES2InterfaceHeader(self, file)
8913 8953
8954 def WriteMojoGLES2ImplHeader(self, file):
8955 """Writes the Mojo GLES2 implementation header declaration."""
8956 self.type_handler.WriteMojoGLES2ImplHeader(self, file)
8957
8958 def WriteMojoGLES2Impl(self, file):
8959 """Writes the Mojo GLES2 implementation declaration."""
8960 self.type_handler.WriteMojoGLES2Impl(self, file)
8961
8914 def WriteGLES2InterfaceStub(self, file): 8962 def WriteGLES2InterfaceStub(self, file):
8915 """Writes the GLES2 Interface Stub declaration.""" 8963 """Writes the GLES2 Interface Stub declaration."""
8916 self.type_handler.WriteGLES2InterfaceStub(self, file) 8964 self.type_handler.WriteGLES2InterfaceStub(self, file)
8917 8965
8918 def WriteGLES2InterfaceStubImpl(self, file): 8966 def WriteGLES2InterfaceStubImpl(self, file):
8919 """Writes the GLES2 Interface Stub declaration.""" 8967 """Writes the GLES2 Interface Stub declaration."""
8920 self.type_handler.WriteGLES2InterfaceStubImpl(self, file) 8968 self.type_handler.WriteGLES2InterfaceStubImpl(self, file)
8921 8969
8922 def WriteGLES2ImplementationHeader(self, file): 8970 def WriteGLES2ImplementationHeader(self, file):
8923 """Writes the GLES2 Implemention declaration.""" 8971 """Writes the GLES2 Implemention declaration."""
(...skipping 1025 matching lines...) Expand 10 before | Expand all | Expand 10 after
9949 """Writes the GLES2 interface header.""" 9997 """Writes the GLES2 interface header."""
9950 file = CHeaderWriter( 9998 file = CHeaderWriter(
9951 filename, 9999 filename,
9952 "// This file is included by gles2_interface.h to declare the\n" 10000 "// This file is included by gles2_interface.h to declare the\n"
9953 "// GL api functions.\n") 10001 "// GL api functions.\n")
9954 for func in self.original_functions: 10002 for func in self.original_functions:
9955 func.WriteGLES2InterfaceHeader(file) 10003 func.WriteGLES2InterfaceHeader(file)
9956 file.Close() 10004 file.Close()
9957 self.generated_cpp_filenames.append(file.filename) 10005 self.generated_cpp_filenames.append(file.filename)
9958 10006
10007 def WriteMojoGLES2ImplHeader(self, filename):
10008 """Writes the Mojo GLES2 implementation header."""
10009 file = CHeaderWriter(
10010 filename,
10011 "// This file is included by gles2_interface.h to declare the\n"
10012 "// GL api functions.\n")
10013
10014 code = """
10015 #include "gpu/command_buffer/client/gles2_interface.h"
10016 #include "third_party/mojo/src/mojo/public/c/gles2/gles2.h"
10017
10018 namespace mojo {
10019
10020 class MojoGLES2Impl : public gpu::gles2::GLES2Interface {
10021 public:
10022 explicit MojoGLES2Impl(MojoGLES2Context context) {
10023 context_ = context;
10024 }
10025 ~MojoGLES2Impl() override {}
10026 """
10027 file.Write(code);
10028 for func in self.original_functions:
10029 func.WriteMojoGLES2ImplHeader(file)
10030 code = """
10031 private:
10032 MojoGLES2Context context_;
10033 };
10034
10035 } // namespace mojo
10036 """
10037 file.Write(code);
10038 file.Close()
10039 self.generated_cpp_filenames.append(file.filename)
10040
10041 def WriteMojoGLES2Impl(self, filename):
10042 """Writes the Mojo GLES2 implementation."""
10043 file = CWriter(filename)
10044 file.Write(_LICENSE)
10045 file.Write(_DO_NOT_EDIT_WARNING)
10046
10047 code = """
10048 #include "mojo/gpu/mojo_gles2_impl_autogen.h"
10049
10050 #include "base/logging.h"
10051 #include "third_party/mojo/src/mojo/public/c/gles2/chromium_sync_point.h"
10052 #include "third_party/mojo/src/mojo/public/c/gles2/chromium_texture_mailbox.h"
10053 #include "third_party/mojo/src/mojo/public/c/gles2/gles2.h"
10054
10055 namespace mojo {
10056
10057 """
10058 file.Write(code);
10059 for func in self.original_functions:
10060 func.WriteMojoGLES2Impl(file)
10061 code = """
10062
10063 } // namespace mojo
10064 """
10065 file.Write(code);
10066 file.Close()
10067 self.generated_cpp_filenames.append(file.filename)
10068
9959 def WriteGLES2InterfaceStub(self, filename): 10069 def WriteGLES2InterfaceStub(self, filename):
9960 """Writes the GLES2 interface stub header.""" 10070 """Writes the GLES2 interface stub header."""
9961 file = CHeaderWriter( 10071 file = CHeaderWriter(
9962 filename, 10072 filename,
9963 "// This file is included by gles2_interface_stub.h.\n") 10073 "// This file is included by gles2_interface_stub.h.\n")
9964 for func in self.original_functions: 10074 for func in self.original_functions:
9965 func.WriteGLES2InterfaceStub(file) 10075 func.WriteGLES2InterfaceStub(file)
9966 file.Close() 10076 file.Close()
9967 self.generated_cpp_filenames.append(file.filename) 10077 self.generated_cpp_filenames.append(file.filename)
9968 10078
(...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after
10467 gen.WriteGLES2ToPPAPIBridge("ppapi/lib/gl/gles2/gles2.c") 10577 gen.WriteGLES2ToPPAPIBridge("ppapi/lib/gl/gles2/gles2.c")
10468 gen.WritePepperGLES2Implementation( 10578 gen.WritePepperGLES2Implementation(
10469 "ppapi/shared_impl/ppb_opengles2_shared.cc") 10579 "ppapi/shared_impl/ppb_opengles2_shared.cc")
10470 os.chdir(base_dir) 10580 os.chdir(base_dir)
10471 gen.WriteCommandIds("gpu/command_buffer/common/gles2_cmd_ids_autogen.h") 10581 gen.WriteCommandIds("gpu/command_buffer/common/gles2_cmd_ids_autogen.h")
10472 gen.WriteFormat("gpu/command_buffer/common/gles2_cmd_format_autogen.h") 10582 gen.WriteFormat("gpu/command_buffer/common/gles2_cmd_format_autogen.h")
10473 gen.WriteFormatTest( 10583 gen.WriteFormatTest(
10474 "gpu/command_buffer/common/gles2_cmd_format_test_autogen.h") 10584 "gpu/command_buffer/common/gles2_cmd_format_test_autogen.h")
10475 gen.WriteGLES2InterfaceHeader( 10585 gen.WriteGLES2InterfaceHeader(
10476 "gpu/command_buffer/client/gles2_interface_autogen.h") 10586 "gpu/command_buffer/client/gles2_interface_autogen.h")
10587 gen.WriteMojoGLES2ImplHeader(
10588 "mojo/gpu/mojo_gles2_impl_autogen.h")
10589 gen.WriteMojoGLES2Impl(
10590 "mojo/gpu/mojo_gles2_impl_autogen.cc")
10477 gen.WriteGLES2InterfaceStub( 10591 gen.WriteGLES2InterfaceStub(
10478 "gpu/command_buffer/client/gles2_interface_stub_autogen.h") 10592 "gpu/command_buffer/client/gles2_interface_stub_autogen.h")
10479 gen.WriteGLES2InterfaceStubImpl( 10593 gen.WriteGLES2InterfaceStubImpl(
10480 "gpu/command_buffer/client/gles2_interface_stub_impl_autogen.h") 10594 "gpu/command_buffer/client/gles2_interface_stub_impl_autogen.h")
10481 gen.WriteGLES2ImplementationHeader( 10595 gen.WriteGLES2ImplementationHeader(
10482 "gpu/command_buffer/client/gles2_implementation_autogen.h") 10596 "gpu/command_buffer/client/gles2_implementation_autogen.h")
10483 gen.WriteGLES2Implementation( 10597 gen.WriteGLES2Implementation(
10484 "gpu/command_buffer/client/gles2_implementation_impl_autogen.h") 10598 "gpu/command_buffer/client/gles2_implementation_impl_autogen.h")
10485 gen.WriteGLES2ImplementationUnitTests( 10599 gen.WriteGLES2ImplementationUnitTests(
10486 "gpu/command_buffer/client/gles2_implementation_unittest_autogen.h") 10600 "gpu/command_buffer/client/gles2_implementation_unittest_autogen.h")
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
10530 Format(gen.generated_cpp_filenames) 10644 Format(gen.generated_cpp_filenames)
10531 10645
10532 if gen.errors > 0: 10646 if gen.errors > 0:
10533 print "%d errors" % gen.errors 10647 print "%d errors" % gen.errors
10534 return 1 10648 return 1
10535 return 0 10649 return 0
10536 10650
10537 10651
10538 if __name__ == '__main__': 10652 if __name__ == '__main__':
10539 sys.exit(main(sys.argv[1:])) 10653 sys.exit(main(sys.argv[1:]))
OLDNEW
« no previous file with comments | « no previous file | gpu/command_buffer/client/gles2_c_lib_autogen.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698