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

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

Issue 2007813003: Remove Mojo GLES2 API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update Created 4 years, 7 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 | « components/mus/ws/BUILD.gn ('k') | mash/wm/BUILD.gn » ('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 5209 matching lines...) Expand 10 before | Expand all | Expand 10 after
5220 self.WriteClientGLReturnLog(func, f) 5220 self.WriteClientGLReturnLog(func, f)
5221 f.write("}\n") 5221 f.write("}\n")
5222 f.write("\n") 5222 f.write("\n")
5223 5223
5224 def WriteGLES2InterfaceHeader(self, func, f): 5224 def WriteGLES2InterfaceHeader(self, func, f):
5225 """Writes the GLES2 Interface.""" 5225 """Writes the GLES2 Interface."""
5226 f.write("virtual %s %s(%s) = 0;\n" % 5226 f.write("virtual %s %s(%s) = 0;\n" %
5227 (func.return_type, func.original_name, 5227 (func.return_type, func.original_name,
5228 func.MakeTypedOriginalArgString(""))) 5228 func.MakeTypedOriginalArgString("")))
5229 5229
5230 def WriteMojoGLES2ImplHeader(self, func, f):
5231 """Writes the Mojo GLES2 implementation header."""
5232 f.write("%s %s(%s) override;\n" %
5233 (func.return_type, func.original_name,
5234 func.MakeTypedOriginalArgString("")))
5235
5236 def WriteMojoGLES2Impl(self, func, f):
5237 """Writes the Mojo GLES2 implementation."""
5238 f.write("%s MojoGLES2Impl::%s(%s) {\n" %
5239 (func.return_type, func.original_name,
5240 func.MakeTypedOriginalArgString("")))
5241 is_core_gl_func = func.IsCoreGLFunction()
5242 is_ext = bool(func.GetInfo("extension"))
5243 is_safe = not func.IsUnsafe()
5244 if is_core_gl_func or (is_safe and is_ext):
5245 f.write("MojoGLES2MakeCurrent(context_);");
5246 func_return = "gl" + func.original_name + "(" + \
5247 func.MakeOriginalArgString("") + ");"
5248 if func.return_type == "void":
5249 f.write(func_return);
5250 else:
5251 f.write("return " + func_return);
5252 else:
5253 f.write("NOTREACHED() << \"Unimplemented %s.\";\n" %
5254 func.original_name);
5255 if func.return_type != "void":
5256 f.write("return 0;")
5257 f.write("}")
5258
5259 def WriteGLES2InterfaceStub(self, func, f): 5230 def WriteGLES2InterfaceStub(self, func, f):
5260 """Writes the GLES2 Interface stub declaration.""" 5231 """Writes the GLES2 Interface stub declaration."""
5261 f.write("%s %s(%s) override;\n" % 5232 f.write("%s %s(%s) override;\n" %
5262 (func.return_type, func.original_name, 5233 (func.return_type, func.original_name,
5263 func.MakeTypedOriginalArgString(""))) 5234 func.MakeTypedOriginalArgString("")))
5264 5235
5265 def WriteGLES2InterfaceStubImpl(self, func, f): 5236 def WriteGLES2InterfaceStubImpl(self, func, f):
5266 """Writes the GLES2 Interface stub declaration.""" 5237 """Writes the GLES2 Interface stub declaration."""
5267 args = func.GetOriginalArgs() 5238 args = func.GetOriginalArgs()
5268 arg_string = ", ".join( 5239 arg_string = ", ".join(
(...skipping 4482 matching lines...) Expand 10 before | Expand all | Expand 10 after
9751 self.type_handler.WriteServiceUnitTest(self, f, *extras) 9722 self.type_handler.WriteServiceUnitTest(self, f, *extras)
9752 9723
9753 def WriteGLES2CLibImplementation(self, f): 9724 def WriteGLES2CLibImplementation(self, f):
9754 """Writes the GLES2 C Lib Implemention.""" 9725 """Writes the GLES2 C Lib Implemention."""
9755 self.type_handler.WriteGLES2CLibImplementation(self, f) 9726 self.type_handler.WriteGLES2CLibImplementation(self, f)
9756 9727
9757 def WriteGLES2InterfaceHeader(self, f): 9728 def WriteGLES2InterfaceHeader(self, f):
9758 """Writes the GLES2 Interface declaration.""" 9729 """Writes the GLES2 Interface declaration."""
9759 self.type_handler.WriteGLES2InterfaceHeader(self, f) 9730 self.type_handler.WriteGLES2InterfaceHeader(self, f)
9760 9731
9761 def WriteMojoGLES2ImplHeader(self, f):
9762 """Writes the Mojo GLES2 implementation header declaration."""
9763 self.type_handler.WriteMojoGLES2ImplHeader(self, f)
9764
9765 def WriteMojoGLES2Impl(self, f):
9766 """Writes the Mojo GLES2 implementation declaration."""
9767 self.type_handler.WriteMojoGLES2Impl(self, f)
9768
9769 def WriteGLES2InterfaceStub(self, f): 9732 def WriteGLES2InterfaceStub(self, f):
9770 """Writes the GLES2 Interface Stub declaration.""" 9733 """Writes the GLES2 Interface Stub declaration."""
9771 self.type_handler.WriteGLES2InterfaceStub(self, f) 9734 self.type_handler.WriteGLES2InterfaceStub(self, f)
9772 9735
9773 def WriteGLES2InterfaceStubImpl(self, f): 9736 def WriteGLES2InterfaceStubImpl(self, f):
9774 """Writes the GLES2 Interface Stub declaration.""" 9737 """Writes the GLES2 Interface Stub declaration."""
9775 self.type_handler.WriteGLES2InterfaceStubImpl(self, f) 9738 self.type_handler.WriteGLES2InterfaceStubImpl(self, f)
9776 9739
9777 def WriteGLES2ImplementationHeader(self, f): 9740 def WriteGLES2ImplementationHeader(self, f):
9778 """Writes the GLES2 Implemention declaration.""" 9741 """Writes the GLES2 Implemention declaration."""
(...skipping 998 matching lines...) Expand 10 before | Expand all | Expand 10 after
10777 10740
10778 def WriteGLES2InterfaceHeader(self, filename): 10741 def WriteGLES2InterfaceHeader(self, filename):
10779 """Writes the GLES2 interface header.""" 10742 """Writes the GLES2 interface header."""
10780 comment = ("// This file is included by gles2_interface.h to declare the\n" 10743 comment = ("// This file is included by gles2_interface.h to declare the\n"
10781 "// GL api functions.\n") 10744 "// GL api functions.\n")
10782 with CHeaderWriter(filename, comment) as f: 10745 with CHeaderWriter(filename, comment) as f:
10783 for func in self.original_functions: 10746 for func in self.original_functions:
10784 func.WriteGLES2InterfaceHeader(f) 10747 func.WriteGLES2InterfaceHeader(f)
10785 self.generated_cpp_filenames.append(filename) 10748 self.generated_cpp_filenames.append(filename)
10786 10749
10787 def WriteMojoGLES2ImplHeader(self, filename):
10788 """Writes the Mojo GLES2 implementation header."""
10789 comment = ("// This file is included by gles2_interface.h to declare the\n"
10790 "// GL api functions.\n")
10791 code = """
10792 #include <memory>
10793
10794 #include "gpu/command_buffer/client/gles2_interface.h"
10795 #include "mojo/public/c/gles2/gles2.h"
10796
10797 namespace mojo {
10798
10799 class MojoGLES2Impl : public gpu::gles2::GLES2Interface {
10800 public:
10801 explicit MojoGLES2Impl(MojoGLES2Context context) {
10802 context_ = context;
10803 }
10804 ~MojoGLES2Impl() override {}
10805 """
10806 with CHeaderWriter(filename, comment) as f:
10807 f.write(code);
10808 for func in self.original_functions:
10809 func.WriteMojoGLES2ImplHeader(f)
10810 code = """
10811 private:
10812 MojoGLES2Context context_;
10813 };
10814
10815 } // namespace mojo
10816 """
10817 f.write(code);
10818 self.generated_cpp_filenames.append(filename)
10819
10820 def WriteMojoGLES2Impl(self, filename):
10821 """Writes the Mojo GLES2 implementation."""
10822 code = """
10823 #include "mojo/gpu/mojo_gles2_impl_autogen.h"
10824
10825 #include "base/logging.h"
10826 #include "mojo/public/c/gles2/chromium_extension.h"
10827 #include "mojo/public/c/gles2/gles2.h"
10828
10829 namespace mojo {
10830
10831 """
10832 with CWriter(filename) as f:
10833 f.write(code);
10834 for func in self.original_functions:
10835 func.WriteMojoGLES2Impl(f)
10836 code = """
10837
10838 } // namespace mojo
10839 """
10840 f.write(code);
10841 self.generated_cpp_filenames.append(filename)
10842
10843 def WriteGLES2InterfaceStub(self, filename): 10750 def WriteGLES2InterfaceStub(self, filename):
10844 """Writes the GLES2 interface stub header.""" 10751 """Writes the GLES2 interface stub header."""
10845 comment = "// This file is included by gles2_interface_stub.h.\n" 10752 comment = "// This file is included by gles2_interface_stub.h.\n"
10846 with CHeaderWriter(filename, comment) as f: 10753 with CHeaderWriter(filename, comment) as f:
10847 for func in self.original_functions: 10754 for func in self.original_functions:
10848 func.WriteGLES2InterfaceStub(f) 10755 func.WriteGLES2InterfaceStub(f)
10849 self.generated_cpp_filenames.append(filename) 10756 self.generated_cpp_filenames.append(filename)
10850 10757
10851 def WriteGLES2InterfaceStubImpl(self, filename): 10758 def WriteGLES2InterfaceStubImpl(self, filename):
10852 """Writes the GLES2 interface header.""" 10759 """Writes the GLES2 interface header."""
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after
11274 f.write(" %sext->%s(%s);\n" % 11181 f.write(" %sext->%s(%s);\n" %
11275 (return_str, func.GetPepperName(), arg)) 11182 (return_str, func.GetPepperName(), arg))
11276 if return_str: 11183 if return_str:
11277 f.write(" %s0;\n" % return_str) 11184 f.write(" %s0;\n" % return_str)
11278 else: 11185 else:
11279 f.write(" %s%s->%s(%s);\n" % 11186 f.write(" %s%s->%s(%s);\n" %
11280 (return_str, interface_str, func.GetPepperName(), arg)) 11187 (return_str, interface_str, func.GetPepperName(), arg))
11281 f.write("}\n\n") 11188 f.write("}\n\n")
11282 self.generated_cpp_filenames.append(filename) 11189 self.generated_cpp_filenames.append(filename)
11283 11190
11284 def WriteMojoGLCallVisitor(self, filename):
11285 """Provides the GL implementation for mojo"""
11286 with CWriter(filename) as f:
11287 for func in self.original_functions:
11288 if not func.IsCoreGLFunction():
11289 continue
11290 f.write("VISIT_GL_CALL(%s, %s, (%s), (%s))\n" %
11291 (func.name, func.return_type,
11292 func.MakeTypedOriginalArgString(""),
11293 func.MakeOriginalArgString("")))
11294 self.generated_cpp_filenames.append(filename)
11295
11296 def WriteMojoGLCallVisitorForExtension(self, filename):
11297 """Provides the GL implementation for mojo for all extensions"""
11298 with CWriter(filename) as f:
11299 for func in self.original_functions:
11300 if not func.GetInfo("extension"):
11301 continue
11302 if func.IsUnsafe():
11303 continue
11304 f.write("VISIT_GL_CALL(%s, %s, (%s), (%s))\n" %
11305 (func.name, func.return_type,
11306 func.MakeTypedOriginalArgString(""),
11307 func.MakeOriginalArgString("")))
11308 self.generated_cpp_filenames.append(filename)
11309 11191
11310 def Format(generated_files): 11192 def Format(generated_files):
11311 formatter = "clang-format" 11193 formatter = "clang-format"
11312 if platform.system() == "Windows": 11194 if platform.system() == "Windows":
11313 formatter += ".bat" 11195 formatter += ".bat"
11314 for filename in generated_files: 11196 for filename in generated_files:
11315 call([formatter, "-i", "-style=chromium", filename]) 11197 call([formatter, "-i", "-style=chromium", filename])
11316 11198
11317 def main(argv): 11199 def main(argv):
11318 """This is the main function.""" 11200 """This is the main function."""
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
11370 gen.WriteGLES2ToPPAPIBridge("ppapi/lib/gl/gles2/gles2.c") 11252 gen.WriteGLES2ToPPAPIBridge("ppapi/lib/gl/gles2/gles2.c")
11371 gen.WritePepperGLES2Implementation( 11253 gen.WritePepperGLES2Implementation(
11372 "ppapi/shared_impl/ppb_opengles2_shared.cc") 11254 "ppapi/shared_impl/ppb_opengles2_shared.cc")
11373 os.chdir(base_dir) 11255 os.chdir(base_dir)
11374 gen.WriteCommandIds("gpu/command_buffer/common/gles2_cmd_ids_autogen.h") 11256 gen.WriteCommandIds("gpu/command_buffer/common/gles2_cmd_ids_autogen.h")
11375 gen.WriteFormat("gpu/command_buffer/common/gles2_cmd_format_autogen.h") 11257 gen.WriteFormat("gpu/command_buffer/common/gles2_cmd_format_autogen.h")
11376 gen.WriteFormatTest( 11258 gen.WriteFormatTest(
11377 "gpu/command_buffer/common/gles2_cmd_format_test_autogen.h") 11259 "gpu/command_buffer/common/gles2_cmd_format_test_autogen.h")
11378 gen.WriteGLES2InterfaceHeader( 11260 gen.WriteGLES2InterfaceHeader(
11379 "gpu/command_buffer/client/gles2_interface_autogen.h") 11261 "gpu/command_buffer/client/gles2_interface_autogen.h")
11380 gen.WriteMojoGLES2ImplHeader(
11381 "mojo/gpu/mojo_gles2_impl_autogen.h")
11382 gen.WriteMojoGLES2Impl(
11383 "mojo/gpu/mojo_gles2_impl_autogen.cc")
11384 gen.WriteGLES2InterfaceStub( 11262 gen.WriteGLES2InterfaceStub(
11385 "gpu/command_buffer/client/gles2_interface_stub_autogen.h") 11263 "gpu/command_buffer/client/gles2_interface_stub_autogen.h")
11386 gen.WriteGLES2InterfaceStubImpl( 11264 gen.WriteGLES2InterfaceStubImpl(
11387 "gpu/command_buffer/client/gles2_interface_stub_impl_autogen.h") 11265 "gpu/command_buffer/client/gles2_interface_stub_impl_autogen.h")
11388 gen.WriteGLES2ImplementationHeader( 11266 gen.WriteGLES2ImplementationHeader(
11389 "gpu/command_buffer/client/gles2_implementation_autogen.h") 11267 "gpu/command_buffer/client/gles2_implementation_autogen.h")
11390 gen.WriteGLES2Implementation( 11268 gen.WriteGLES2Implementation(
11391 "gpu/command_buffer/client/gles2_implementation_impl_autogen.h") 11269 "gpu/command_buffer/client/gles2_implementation_impl_autogen.h")
11392 gen.WriteGLES2ImplementationUnitTests( 11270 gen.WriteGLES2ImplementationUnitTests(
11393 "gpu/command_buffer/client/gles2_implementation_unittest_autogen.h") 11271 "gpu/command_buffer/client/gles2_implementation_unittest_autogen.h")
(...skipping 24 matching lines...) Expand all
11418 "gpu/command_buffer/service/gles2_cmd_validation_autogen.h") 11296 "gpu/command_buffer/service/gles2_cmd_validation_autogen.h")
11419 gen.WriteServiceUtilsImplementation( 11297 gen.WriteServiceUtilsImplementation(
11420 "gpu/command_buffer/service/" 11298 "gpu/command_buffer/service/"
11421 "gles2_cmd_validation_implementation_autogen.h") 11299 "gles2_cmd_validation_implementation_autogen.h")
11422 gen.WriteCommonUtilsHeader( 11300 gen.WriteCommonUtilsHeader(
11423 "gpu/command_buffer/common/gles2_cmd_utils_autogen.h") 11301 "gpu/command_buffer/common/gles2_cmd_utils_autogen.h")
11424 gen.WriteCommonUtilsImpl( 11302 gen.WriteCommonUtilsImpl(
11425 "gpu/command_buffer/common/gles2_cmd_utils_implementation_autogen.h") 11303 "gpu/command_buffer/common/gles2_cmd_utils_implementation_autogen.h")
11426 gen.WriteGLES2Header("gpu/GLES2/gl2chromium_autogen.h") 11304 gen.WriteGLES2Header("gpu/GLES2/gl2chromium_autogen.h")
11427 mojo_gles2_prefix = ("mojo/public/c/gles2/gles2_call_visitor") 11305 mojo_gles2_prefix = ("mojo/public/c/gles2/gles2_call_visitor")
11428 gen.WriteMojoGLCallVisitor(mojo_gles2_prefix + "_autogen.h")
11429 gen.WriteMojoGLCallVisitorForExtension(
11430 mojo_gles2_prefix + "_chromium_extension_autogen.h")
11431 11306
11432 Format(gen.generated_cpp_filenames) 11307 Format(gen.generated_cpp_filenames)
11433 11308
11434 if gen.errors > 0: 11309 if gen.errors > 0:
11435 print "%d errors" % gen.errors 11310 print "%d errors" % gen.errors
11436 return 1 11311 return 1
11437 return 0 11312 return 0
11438 11313
11439 11314
11440 if __name__ == '__main__': 11315 if __name__ == '__main__':
11441 sys.exit(main(sys.argv[1:])) 11316 sys.exit(main(sys.argv[1:]))
OLDNEW
« no previous file with comments | « components/mus/ws/BUILD.gn ('k') | mash/wm/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698