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

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

Issue 1534893002: Use C bindings to Mojo GL entry points exclusively. (Closed) Base URL: git@github.com:domokit/mojo.git@cl-2f
Patch Set: rebase Created 5 years 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/skia_bindings/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 4339 matching lines...) Expand 10 before | Expand all | Expand 10 after
4350 self.WriteClientGLReturnLog(func, file) 4350 self.WriteClientGLReturnLog(func, file)
4351 file.Write("}\n") 4351 file.Write("}\n")
4352 file.Write("\n") 4352 file.Write("\n")
4353 4353
4354 def WriteGLES2InterfaceHeader(self, func, file): 4354 def WriteGLES2InterfaceHeader(self, func, file):
4355 """Writes the GLES2 Interface.""" 4355 """Writes the GLES2 Interface."""
4356 file.Write("virtual %s %s(%s) = 0;\n" % 4356 file.Write("virtual %s %s(%s) = 0;\n" %
4357 (func.return_type, func.original_name, 4357 (func.return_type, func.original_name,
4358 func.MakeTypedOriginalArgString(""))) 4358 func.MakeTypedOriginalArgString("")))
4359 4359
4360 def WriteMojoGLES2ImplHeader(self, func, file):
4361 """Writes the Mojo GLES2 implementation header."""
4362 file.Write("%s %s(%s) override;\n" %
4363 (func.return_type, func.original_name,
4364 func.MakeTypedOriginalArgString("")))
4365
4366 def WriteMojoGLES2Impl(self, func, file):
4367 """Writes the Mojo GLES2 implementation."""
4368 file.Write("%s MojoGLES2Impl::%s(%s) {\n" %
4369 (func.return_type, func.original_name,
4370 func.MakeTypedOriginalArgString("")))
4371
4372 is_mojo_extension = func.GetInfo("extension") in _MOJO_EXPOSED_EXTENSIONS
4373 if func.IsCoreGLFunction() or is_mojo_extension:
4374 file.Write("MGLMakeCurrent(context_);");
4375 func_return = "gl" + func.original_name + "(" + \
4376 func.MakeOriginalArgString("") + ");"
4377 if func.original_name == "ResizeCHROMIUM":
4378 file.Write("MGLResizeSurface(width, height);");
4379 elif func.return_type == "void":
4380 file.Write(func_return);
4381 else:
4382 file.Write("return " + func_return);
4383 else:
4384 file.Write("NOTREACHED() << \"Unimplemented %s.\";\n" %
4385 func.original_name);
4386 if func.return_type != "void":
4387 file.Write("return 0;")
4388 file.Write("}")
4389
4390 def WriteGLES2InterfaceStub(self, func, file): 4360 def WriteGLES2InterfaceStub(self, func, file):
4391 """Writes the GLES2 Interface stub declaration.""" 4361 """Writes the GLES2 Interface stub declaration."""
4392 file.Write("%s %s(%s) override;\n" % 4362 file.Write("%s %s(%s) override;\n" %
4393 (func.return_type, func.original_name, 4363 (func.return_type, func.original_name,
4394 func.MakeTypedOriginalArgString(""))) 4364 func.MakeTypedOriginalArgString("")))
4395 4365
4396 def WriteGLES2InterfaceStubImpl(self, func, file): 4366 def WriteGLES2InterfaceStubImpl(self, func, file):
4397 """Writes the GLES2 Interface stub declaration.""" 4367 """Writes the GLES2 Interface stub declaration."""
4398 args = func.GetOriginalArgs() 4368 args = func.GetOriginalArgs()
4399 arg_string = ", ".join( 4369 arg_string = ", ".join(
(...skipping 4690 matching lines...) Expand 10 before | Expand all | Expand 10 after
9090 self.type_handler.WriteServiceUnitTest(self, file, *extras) 9060 self.type_handler.WriteServiceUnitTest(self, file, *extras)
9091 9061
9092 def WriteGLES2CLibImplementation(self, file): 9062 def WriteGLES2CLibImplementation(self, file):
9093 """Writes the GLES2 C Lib Implemention.""" 9063 """Writes the GLES2 C Lib Implemention."""
9094 self.type_handler.WriteGLES2CLibImplementation(self, file) 9064 self.type_handler.WriteGLES2CLibImplementation(self, file)
9095 9065
9096 def WriteGLES2InterfaceHeader(self, file): 9066 def WriteGLES2InterfaceHeader(self, file):
9097 """Writes the GLES2 Interface declaration.""" 9067 """Writes the GLES2 Interface declaration."""
9098 self.type_handler.WriteGLES2InterfaceHeader(self, file) 9068 self.type_handler.WriteGLES2InterfaceHeader(self, file)
9099 9069
9100 def WriteMojoGLES2ImplHeader(self, file):
9101 """Writes the Mojo GLES2 implementation header declaration."""
9102 self.type_handler.WriteMojoGLES2ImplHeader(self, file)
9103
9104 def WriteMojoGLES2Impl(self, file):
9105 """Writes the Mojo GLES2 implementation declaration."""
9106 self.type_handler.WriteMojoGLES2Impl(self, file)
9107
9108 def WriteGLES2InterfaceStub(self, file): 9070 def WriteGLES2InterfaceStub(self, file):
9109 """Writes the GLES2 Interface Stub declaration.""" 9071 """Writes the GLES2 Interface Stub declaration."""
9110 self.type_handler.WriteGLES2InterfaceStub(self, file) 9072 self.type_handler.WriteGLES2InterfaceStub(self, file)
9111 9073
9112 def WriteGLES2InterfaceStubImpl(self, file): 9074 def WriteGLES2InterfaceStubImpl(self, file):
9113 """Writes the GLES2 Interface Stub declaration.""" 9075 """Writes the GLES2 Interface Stub declaration."""
9114 self.type_handler.WriteGLES2InterfaceStubImpl(self, file) 9076 self.type_handler.WriteGLES2InterfaceStubImpl(self, file)
9115 9077
9116 def WriteGLES2ImplementationHeader(self, file): 9078 def WriteGLES2ImplementationHeader(self, file):
9117 """Writes the GLES2 Implemention declaration.""" 9079 """Writes the GLES2 Implemention declaration."""
(...skipping 1025 matching lines...) Expand 10 before | Expand all | Expand 10 after
10143 """Writes the GLES2 interface header.""" 10105 """Writes the GLES2 interface header."""
10144 file = CHeaderWriter( 10106 file = CHeaderWriter(
10145 filename, 10107 filename,
10146 "// This file is included by gles2_interface.h to declare the\n" 10108 "// This file is included by gles2_interface.h to declare the\n"
10147 "// GL api functions.\n") 10109 "// GL api functions.\n")
10148 for func in self.original_functions: 10110 for func in self.original_functions:
10149 func.WriteGLES2InterfaceHeader(file) 10111 func.WriteGLES2InterfaceHeader(file)
10150 file.Close() 10112 file.Close()
10151 self.generated_cpp_filenames.append(file.filename) 10113 self.generated_cpp_filenames.append(file.filename)
10152 10114
10153 def WriteMojoGLES2ImplHeader(self, filename):
10154 """Writes the Mojo GLES2 implementation header."""
10155 file = CHeaderWriter(
10156 filename,
10157 "// This file is included by gles2_interface.h to declare the\n"
10158 "// GL api functions.\n")
10159
10160 code = """
10161 #include <MGL/mgl.h>
10162
10163 #include "gpu/command_buffer/client/gles2_interface.h"
10164
10165 namespace mojo {
10166
10167 class MojoGLES2Impl : public gpu::gles2::GLES2Interface {
10168 public:
10169 explicit MojoGLES2Impl(MGLContext context) {
10170 context_ = context;
10171 }
10172 ~MojoGLES2Impl() override {}
10173 """
10174 file.Write(code);
10175 for func in self.original_functions:
10176 func.WriteMojoGLES2ImplHeader(file)
10177 code = """
10178 private:
10179 MGLContext context_;
10180 };
10181
10182 } // namespace mojo
10183 """
10184 file.Write(code);
10185 file.Close()
10186 self.generated_cpp_filenames.append(file.filename)
10187
10188 def WriteMojoGLES2Impl(self, filename):
10189 """Writes the Mojo GLES2 implementation."""
10190 file = CWriter(filename)
10191 file.Write(_LICENSE)
10192 file.Write(_DO_NOT_EDIT_WARNING)
10193
10194 code = """
10195 #include "mojo/gpu/mojo_gles2_impl_autogen.h"
10196
10197 #include <MGL/mgl.h>
10198 #include <MGL/mgl_onscreen.h>
10199
10200 #ifndef GL_GLEXT_PROTOTYPES
10201 #define GL_GLEXT_PROTOTYPES
10202 #endif
10203 #include <GLES2/gl2.h>
10204 #include <GLES2/gl2ext.h>
10205 #include <GLES2/gl2extmojo.h>
10206
10207 #include "base/logging.h"
10208
10209 namespace mojo {
10210
10211 """
10212 file.Write(code);
10213 for func in self.original_functions:
10214 func.WriteMojoGLES2Impl(file)
10215 code = """
10216
10217 } // namespace mojo
10218 """
10219 file.Write(code);
10220 file.Close()
10221 self.generated_cpp_filenames.append(file.filename)
10222
10223 def WriteGLES2InterfaceStub(self, filename): 10115 def WriteGLES2InterfaceStub(self, filename):
10224 """Writes the GLES2 interface stub header.""" 10116 """Writes the GLES2 interface stub header."""
10225 file = CHeaderWriter( 10117 file = CHeaderWriter(
10226 filename, 10118 filename,
10227 "// This file is included by gles2_interface_stub.h.\n") 10119 "// This file is included by gles2_interface_stub.h.\n")
10228 for func in self.original_functions: 10120 for func in self.original_functions:
10229 func.WriteGLES2InterfaceStub(file) 10121 func.WriteGLES2InterfaceStub(file)
10230 file.Close() 10122 file.Close()
10231 self.generated_cpp_filenames.append(file.filename) 10123 self.generated_cpp_filenames.append(file.filename)
10232 10124
(...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after
10729 gen.WriteMojoGLCallVisitorForExtension( 10621 gen.WriteMojoGLCallVisitorForExtension(
10730 mojo_gles2_call_visitor_prefix + "_" + extension.lower() + "_autogen.h", extension) 10622 mojo_gles2_call_visitor_prefix + "_" + extension.lower() + "_autogen.h", extension)
10731 10623
10732 mojo_gles2_thunks_prefix = ("mojo/public/platform/native/gles2_impl_") 10624 mojo_gles2_thunks_prefix = ("mojo/public/platform/native/gles2_impl_")
10733 for extension in _MOJO_EXPOSED_EXTENSIONS: 10625 for extension in _MOJO_EXPOSED_EXTENSIONS:
10734 gen.WriteMojoGLThunksHeader( 10626 gen.WriteMojoGLThunksHeader(
10735 mojo_gles2_thunks_prefix + extension.lower() + "_thunks.h", extension) 10627 mojo_gles2_thunks_prefix + extension.lower() + "_thunks.h", extension)
10736 gen.WriteMojoGLThunksImpl( 10628 gen.WriteMojoGLThunksImpl(
10737 mojo_gles2_thunks_prefix + extension.lower() + "_thunks.c", extension) 10629 mojo_gles2_thunks_prefix + extension.lower() + "_thunks.c", extension)
10738 10630
10739 gen.WriteMojoGLES2ImplHeader(
10740 "mojo/gpu/mojo_gles2_impl_autogen.h")
10741 gen.WriteMojoGLES2Impl(
10742 "mojo/gpu/mojo_gles2_impl_autogen.cc")
10743
10744 Format(gen.generated_cpp_filenames) 10631 Format(gen.generated_cpp_filenames)
10745 10632
10746 if gen.errors > 0: 10633 if gen.errors > 0:
10747 print "%d errors" % gen.errors 10634 print "%d errors" % gen.errors
10748 return 1 10635 return 1
10749 return 0 10636 return 0
10750 10637
10751 10638
10752 if __name__ == '__main__': 10639 if __name__ == '__main__':
10753 sys.exit(main(sys.argv[1:])) 10640 sys.exit(main(sys.argv[1:]))
OLDNEW
« no previous file with comments | « no previous file | gpu/skia_bindings/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698