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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: gpu/command_buffer/build_gles2_cmd_buffer.py
diff --git a/gpu/command_buffer/build_gles2_cmd_buffer.py b/gpu/command_buffer/build_gles2_cmd_buffer.py
index bf5b19ef8b4e78ae5d1a6ccabeed338e9a57f19f..be626605903e9ea2a52d496539f0a19e128df9db 100755
--- a/gpu/command_buffer/build_gles2_cmd_buffer.py
+++ b/gpu/command_buffer/build_gles2_cmd_buffer.py
@@ -4039,6 +4039,46 @@ TEST_P(%(test_name)s, %(name)sInvalidArgs%(arg_index)d_%(value_index)d) {
(func.return_type, func.original_name,
func.MakeTypedOriginalArgString("")))
+ def WriteMojoGLES2ImplHeader(self, func, file):
+ """Writes the Mojo GLES2 implementation header."""
+ file.Write("%s %s(%s) override;\n" %
+ (func.return_type, func.original_name,
+ func.MakeTypedOriginalArgString("")))
+
+ def WriteMojoGLES2Impl(self, func, file):
+ """Writes the Mojo GLES2 implementation."""
+ file.Write("%s MojoGLES2Impl::%s(%s) {\n" %
+ (func.return_type, func.original_name,
+ func.MakeTypedOriginalArgString("")))
+ # TODO(alhaad): Add Mojo C thunk for each of the following methods and
+ # remove this.
+ func_list = ["GenQueriesEXT", "BeginQueryEXT", "MapTexSubImage2DCHROMIUM",
+ "UnmapTexSubImage2DCHROMIUM", "DeleteQueriesEXT",
+ "EndQueryEXT", "GetQueryObjectuivEXT", "ShallowFlushCHROMIUM",
+ "GenMailboxCHROMIUM", "ProduceTextureDirectCHROMIUM",
+ "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
+ if func.original_name in func_list:
+ file.Write("return static_cast<gpu::gles2::GLES2Interface*>"
+ "(MojoGLES2GetGLES2Interface(context_))->" +
+ func.original_name + "(" + func.MakeOriginalArgString("") +
+ ");")
+ file.Write("}")
+ return
+ if func.IsCoreGLFunction():
+ file.Write("MojoGLES2MakeCurrent(context_);");
+ func_return = "gl" + func.original_name + "(" + \
+ func.MakeOriginalArgString("") + ");"
+ if func.return_type == "void":
+ file.Write(func_return);
+ else:
+ file.Write("return " + func_return);
+ else:
+ file.Write("NOTREACHED() << \"Unimplemented %s.\";\n" %
+ func.original_name);
+ if func.return_type != "void":
+ file.Write("return 0;")
+ file.Write("}")
+
def WriteGLES2InterfaceStub(self, func, file):
"""Writes the GLES2 Interface stub declaration."""
file.Write("%s %s(%s) override;\n" %
@@ -8741,6 +8781,14 @@ class Function(object):
"""Writes the GLES2 Interface declaration."""
self.type_handler.WriteGLES2InterfaceHeader(self, file)
+ def WriteMojoGLES2ImplHeader(self, file):
+ """Writes the Mojo GLES2 implementation header declaration."""
+ self.type_handler.WriteMojoGLES2ImplHeader(self, file)
+
+ def WriteMojoGLES2Impl(self, file):
+ """Writes the Mojo GLES2 implementation declaration."""
+ self.type_handler.WriteMojoGLES2Impl(self, file)
+
def WriteGLES2InterfaceStub(self, file):
"""Writes the GLES2 Interface Stub declaration."""
self.type_handler.WriteGLES2InterfaceStub(self, file)
@@ -9764,6 +9812,65 @@ extern const NameToFunc g_gles2_function_table[] = {
file.Close()
self.generated_cpp_filenames.append(file.filename)
+ def WriteMojoGLES2ImplHeader(self, filename):
+ """Writes the Mojo GLES2 implementation header."""
+ file = CHeaderWriter(
+ filename,
+ "// This file is included by gles2_interface.h to declare the\n"
+ "// GL api functions.\n")
+
+ code = """
+ #include "gpu/command_buffer/client/gles2_interface.h"
+ #include "third_party/mojo/src/mojo/public/c/gles2/gles2.h"
+
+ namespace mojo {
+
+ class MojoGLES2Impl : public gpu::gles2::GLES2Interface {
+ public:
+ MojoGLES2Impl(MojoGLES2Context context) {
+ context_ = context;
+ }
+ """
+ file.Write(code);
+ for func in self.original_functions:
+ func.WriteMojoGLES2ImplHeader(file)
+ code = """
+ private:
+ MojoGLES2Context context_;
+ };
+
+ } // namespace mojo
+ """
+ file.Write(code);
+ file.Close()
+ self.generated_cpp_filenames.append(file.filename)
+
+ def WriteMojoGLES2Impl(self, filename):
+ """Writes the Mojo GLES2 implementation."""
+ file = CWriter(filename)
+ file.Write(_LICENSE)
+ file.Write(_DO_NOT_EDIT_WARNING)
+
+ code = """
+ #include "gpu/command_buffer/client/mojo_gles2_impl_autogen.h"
+
+ #include "base/logging.h"
+ #include "third_party/khronos/GLES2/gl2.h"
+
+ namespace mojo {
+
+ """
+ file.Write(code);
+ for func in self.original_functions:
+ func.WriteMojoGLES2Impl(file)
+ code = """
+
+ } // namespace mojo
+ """
+ file.Write(code);
+ file.Close()
+ self.generated_cpp_filenames.append(file.filename)
+
def WriteGLES2InterfaceStub(self, filename):
"""Writes the GLES2 interface stub header."""
file = CHeaderWriter(
@@ -10268,6 +10375,10 @@ def main(argv):
"gpu/command_buffer/common/gles2_cmd_format_test_autogen.h")
gen.WriteGLES2InterfaceHeader(
"gpu/command_buffer/client/gles2_interface_autogen.h")
+ gen.WriteMojoGLES2ImplHeader(
+ "gpu/command_buffer/client/mojo_gles2_impl_autogen.h")
+ gen.WriteMojoGLES2Impl(
+ "gpu/command_buffer/client/mojo_gles2_impl_autogen.cc")
gen.WriteGLES2InterfaceStub(
"gpu/command_buffer/client/gles2_interface_stub_autogen.h")
gen.WriteGLES2InterfaceStubImpl(
« no previous file with comments | « no previous file | gpu/command_buffer/client/BUILD.gn » ('j') | gpu/command_buffer/client/mojo_gles2_impl_autogen.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698