Skip to content

Commit

Permalink
Make GLES2Implementation based on GLES2Interface
Browse files Browse the repository at this point in the history
GLES2Interface is a pure virutal interface. It's likely
that more functions of GLES2Implementation will need have
be declared in GLES2Interface but this is a first step

BUG=155914


Review URL: https://chromiumcodereview.appspot.com/11138021

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@162216 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
gman@chromium.org committed Oct 16, 2012
1 parent c553118 commit a9fb79d
Show file tree
Hide file tree
Showing 16 changed files with 3,412 additions and 1,623 deletions.
153 changes: 120 additions & 33 deletions gpu/command_buffer/build_gles2_cmd_buffer.py
Original file line number Diff line number Diff line change
Expand Up @@ -2249,7 +2249,7 @@ def WriteGLES2ImplementationDeclaration(self, func, file):
"""Writes the GLES2 Implemention declaration."""
impl_decl = func.GetInfo('impl_decl')
if impl_decl == None or impl_decl == True:
file.Write("%s %s(%s);\n" %
file.Write("virtual %s %s(%s) OVERRIDE;\n" %
(func.return_type, func.original_name,
func.MakeTypedOriginalArgString("")))
file.Write("\n")
Expand Down Expand Up @@ -2281,6 +2281,10 @@ def WriteClientGLReturnLog(self, func, file):
file.Write(' GPU_CLIENT_LOG("return:" << result)\n')

def WriteGLES2ImplementationHeader(self, func, file):
"""Writes the GLES2 Implemention."""
self.WriteGLES2ImplementationDeclaration(func, file)

def WriteGLES2Implementation(self, func, file):
"""Writes the GLES2 Implemention."""
impl_func = func.GetInfo('impl_func')
impl_decl = func.GetInfo('impl_decl')
Expand All @@ -2289,7 +2293,7 @@ def WriteGLES2ImplementationHeader(self, func, file):
(impl_func == None or impl_func == True) and
(impl_decl == None or impl_decl == True) and
(gen_cmd == None or gen_cmd == True)):
file.Write("%s %s(%s) {\n" %
file.Write("%s GLES2Implementation::%s(%s) {\n" %
(func.return_type, func.original_name,
func.MakeTypedOriginalArgString("")))
file.Write(" GPU_CLIENT_SINGLE_THREAD_CHECK();\n")
Expand All @@ -2302,8 +2306,29 @@ def WriteGLES2ImplementationHeader(self, func, file):
self.WriteClientGLReturnLog(func, file)
file.Write("}\n")
file.Write("\n")
else:
self.WriteGLES2ImplementationDeclaration(func, file)

def WriteGLES2InterfaceHeader(self, func, file):
"""Writes the GLES2 Interface."""
file.Write("virtual %s %s(%s) = 0;\n" %
(func.return_type, func.original_name,
func.MakeTypedOriginalArgString("")))

def WriteGLES2InterfaceStub(self, func, file):
"""Writes the GLES2 Interface stub declaration."""
file.Write("virtual %s %s(%s) OVERRIDE;\n" %
(func.return_type, func.original_name,
func.MakeTypedOriginalArgString("")))

def WriteGLES2InterfaceStubImpl(self, func, file):
"""Writes the GLES2 Interface stub declaration."""
args = func.GetOriginalArgs()
arg_string = ", ".join(
["%s /* %s */" % (arg.type, arg.name) for arg in args])
file.Write("%s GLES2InterfaceStub::%s(%s) {\n" %
(func.return_type, func.original_name, arg_string))
if func.return_type != "void":
file.Write(" return 0;\n")
file.Write("}\n")

def WriteGLES2ImplementationUnitTest(self, func, file):
"""Writes the GLES2 Implemention unit test."""
Expand Down Expand Up @@ -2474,9 +2499,9 @@ def WriteGLES2ImplementationUnitTest(self, func, file):
"""Overrriden from TypeHandler."""
pass

def WriteGLES2ImplementationHeader(self, func, file):
def WriteGLES2Implementation(self, func, file):
"""Overrriden from TypeHandler."""
file.Write("%s %s(%s) {\n" %
file.Write("%s GLES2Implementation::%s(%s) {\n" %
(func.return_type, func.original_name,
func.MakeTypedOriginalArgString("")))
file.Write(" // TODO: for now this is a no-op\n")
Expand Down Expand Up @@ -2607,9 +2632,13 @@ def WriteImmediateFormatTest(self, func, file):
"""Overrriden from TypeHandler."""
file.Write("// TODO(gman): Implement test for %s\n" % func.name)

def WriteGLES2Implementation(self, func, file):
"""Overrriden from TypeHandler."""
pass

def WriteGLES2ImplementationHeader(self, func, file):
"""Overrriden from TypeHandler."""
file.Write("%s %s(%s);\n" %
file.Write("virtual %s %s(%s) OVERRIDE;\n" %
(func.return_type, func.original_name,
func.MakeTypedOriginalArgString("")))
file.Write("\n")
Expand Down Expand Up @@ -2822,7 +2851,7 @@ def WriteServiceUnitTest(self, func, file):
"""
self.WriteInvalidUnitTest(func, file, invalid_test)

def WriteGLES2ImplementationHeader(self, func, file):
def WriteGLES2Implementation(self, func, file):
"""Writes the GLES2 Implemention."""

impl_func = func.GetInfo('impl_func')
Expand All @@ -2832,7 +2861,7 @@ def WriteGLES2ImplementationHeader(self, func, file):
(impl_func == None or impl_func == True) and
(impl_decl == None or impl_decl == True)):

file.Write("%s %s(%s) {\n" %
file.Write("%s GLES2Implementation::%s(%s) {\n" %
(func.return_type, func.original_name,
func.MakeTypedOriginalArgString("")))
file.Write(" GPU_CLIENT_SINGLE_THREAD_CHECK();\n")
Expand Down Expand Up @@ -2866,9 +2895,6 @@ def WriteGLES2ImplementationHeader(self, func, file):
'lc_type': name_arg.resource_type.lower(),
})

else:
self.WriteGLES2ImplementationDeclaration(func, file)


class GENnHandler(TypeHandler):
"""Handler for glGen___ type functions."""
Expand Down Expand Up @@ -2903,7 +2929,7 @@ def WriteImmediateHandlerImplementation(self, func, file):
" }\n" %
(func.original_name, func.GetLastOriginalArg().name))

def WriteGLES2ImplementationHeader(self, func, file):
def WriteGLES2Implementation(self, func, file):
"""Overrriden from TypeHandler."""
log_code = (""" GPU_CLIENT_LOG_CODE_BLOCK({
for (GLsizei i = 0; i < n; ++i) {
Expand All @@ -2919,7 +2945,9 @@ def WriteGLES2ImplementationHeader(self, func, file):
'resource_types': func.GetInfo('resource_types'),
'count_name': func.GetOriginalArgs()[0].name,
}
file.Write("%(return_type)s %(name)s(%(typed_args)s) {\n" % args)
file.Write(
"%(return_type)s GLES2Implementation::%(name)s(%(typed_args)s) {\n" %
args)
func.WriteDestinationInitalizationValidation(file)
self.WriteClientGLCallLog(func, file)
for arg in func.GetOriginalArgs():
Expand Down Expand Up @@ -3164,9 +3192,9 @@ def WriteHandlerImplementation (self, func, file):
file.Write(" return error::kInvalidArguments;\n")
file.Write(" }\n")

def WriteGLES2ImplementationHeader(self, func, file):
def WriteGLES2Implementation(self, func, file):
"""Overrriden from TypeHandler."""
file.Write("%s %s(%s) {\n" %
file.Write("%s GLES2Implementation::%s(%s) {\n" %
(func.return_type, func.original_name,
func.MakeTypedOriginalArgString("")))
file.Write(" GPU_CLIENT_SINGLE_THREAD_CHECK();\n")
Expand Down Expand Up @@ -3196,9 +3224,9 @@ def WriteServiceImplementation(self, func, file):
"""Overrriden from TypeHandler."""
pass

def WriteGLES2ImplementationHeader(self, func, file):
def WriteGLES2Implementation(self, func, file):
"""Overrriden from TypeHandler."""
file.Write("%s %s(%s) {\n" %
file.Write("%s GLES2Implementation::%s(%s) {\n" %
(func.return_type, func.original_name,
func.MakeTypedOriginalArgString("")))
file.Write(" GPU_CLIENT_SINGLE_THREAD_CHECK();\n")
Expand Down Expand Up @@ -3328,7 +3356,7 @@ def WriteImmediateHandlerImplementation (self, func, file):
file.Write(" %sHelper(n, %s);\n" %
(func.original_name, func.GetLastOriginalArg().name))

def WriteGLES2ImplementationHeader(self, func, file):
def WriteGLES2Implementation(self, func, file):
"""Overrriden from TypeHandler."""
impl_decl = func.GetInfo('impl_decl')
if impl_decl == None or impl_decl == True:
Expand All @@ -3340,7 +3368,9 @@ def WriteGLES2ImplementationHeader(self, func, file):
'resource_type': func.GetInfo('resource_type').lower(),
'count_name': func.GetOriginalArgs()[0].name,
}
file.Write("%(return_type)s %(name)s(%(typed_args)s) {\n" % args)
file.Write(
"%(return_type)s GLES2Implementation::%(name)s(%(typed_args)s) {\n" %
args)
file.Write(" GPU_CLIENT_SINGLE_THREAD_CHECK();\n")
func.WriteDestinationInitalizationValidation(file)
self.WriteClientGLCallLog(func, file)
Expand Down Expand Up @@ -3507,11 +3537,11 @@ def WriteServiceImplementation(self, func, file):
"""
file.Write(code)

def WriteGLES2ImplementationHeader(self, func, file):
def WriteGLES2Implementation(self, func, file):
"""Overrriden from TypeHandler."""
impl_decl = func.GetInfo('impl_decl')
if impl_decl == None or impl_decl == True:
file.Write("%s %s(%s) {\n" %
file.Write("%s GLES2Implementation::%s(%s) {\n" %
(func.return_type, func.original_name,
func.MakeTypedOriginalArgString("")))
file.Write(" GPU_CLIENT_SINGLE_THREAD_CHECK();\n")
Expand Down Expand Up @@ -3741,9 +3771,9 @@ def WriteGetDataSizeCode(self, func, file):
file.Write(" return error::kOutOfBounds;\n")
file.Write(" }\n")

def WriteGLES2ImplementationHeader(self, func, file):
def WriteGLES2Implementation(self, func, file):
"""Overrriden from TypeHandler."""
file.Write("%s %s(%s) {\n" %
file.Write("%s GLES2Implementation::%s(%s) {\n" %
(func.return_type, func.original_name,
func.MakeTypedOriginalArgString("")))
file.Write(" GPU_CLIENT_SINGLE_THREAD_CHECK();\n")
Expand Down Expand Up @@ -4010,9 +4040,9 @@ def WriteGetDataSizeCode(self, func, file):
file.Write(" return error::kOutOfBounds;\n")
file.Write(" }\n")

def WriteGLES2ImplementationHeader(self, func, file):
def WriteGLES2Implementation(self, func, file):
"""Overrriden from TypeHandler."""
file.Write("%s %s(%s) {\n" %
file.Write("%s GLES2Implementation::%s(%s) {\n" %
(func.return_type, func.original_name,
func.MakeTypedOriginalArgString("")))
file.Write(" GPU_CLIENT_SINGLE_THREAD_CHECK();\n")
Expand Down Expand Up @@ -4493,12 +4523,12 @@ def WriteServiceImplementation(self, func, file):
file.Write("}\n")
file.Write("\n")

def WriteGLES2ImplementationHeader(self, func, file):
def WriteGLES2Implementation(self, func, file):
"""Overrriden from TypeHandler."""
impl_func = func.GetInfo('impl_func')
if impl_func == None or impl_func == True:
error_value = func.GetInfo("error_value") or "GL_FALSE"
file.Write("%s %s(%s) {\n" %
file.Write("%s GLES2Implementation::%s(%s) {\n" %
(func.return_type, func.original_name,
func.MakeTypedOriginalArgString("")))
file.Write(" GPU_CLIENT_SINGLE_THREAD_CHECK();\n")
Expand All @@ -4522,8 +4552,6 @@ def WriteGLES2ImplementationHeader(self, func, file):
file.Write(" return *result;\n")
file.Write("}\n")
file.Write("\n")
else:
self.WriteGLES2ImplementationDeclaration(func, file)

def WriteGLES2ImplementationUnitTest(self, func, file):
"""Overrriden from TypeHandler."""
Expand Down Expand Up @@ -4571,9 +4599,9 @@ def InitFunction(self, func):
# add on a bucket id.
func.AddCmdArg(Argument('bucket_id', 'uint32'))

def WriteGLES2ImplementationHeader(self, func, file):
def WriteGLES2Implementation(self, func, file):
"""Overrriden from TypeHandler."""
code_1 = """%(return_type)s %(func_name)s(%(args)s) {
code_1 = """%(return_type)s GLES2Implementation::%(func_name)s(%(args)s) {
GPU_CLIENT_SINGLE_THREAD_CHECK();
"""
code_2 = """ GPU_CLIENT_LOG("[" << GetLogPrefix()
Expand Down Expand Up @@ -5505,10 +5533,26 @@ def WriteGLES2CLibImplementation(self, file):
"""Writes the GLES2 C Lib Implemention."""
self.type_handler.WriteGLES2CLibImplementation(self, file)

def WriteGLES2InterfaceHeader(self, file):
"""Writes the GLES2 Interface declaration."""
self.type_handler.WriteGLES2InterfaceHeader(self, file)

def WriteGLES2InterfaceStub(self, file):
"""Writes the GLES2 Interface Stub declaration."""
self.type_handler.WriteGLES2InterfaceStub(self, file)

def WriteGLES2InterfaceStubImpl(self, file):
"""Writes the GLES2 Interface Stub declaration."""
self.type_handler.WriteGLES2InterfaceStubImpl(self, file)

def WriteGLES2ImplementationHeader(self, file):
"""Writes the GLES2 Implemention declaration."""
self.type_handler.WriteGLES2ImplementationHeader(self, file)

def WriteGLES2Implementation(self, file):
"""Writes the GLES2 Implemention definition."""
self.type_handler.WriteGLES2Implementation(self, file)

def WriteGLES2ImplementationUnitTest(self, file):
"""Writes the GLES2 Implemention unit test."""
self.type_handler.WriteGLES2ImplementationUnitTest(self, file)
Expand Down Expand Up @@ -6023,8 +6067,36 @@ def WriteGLES2CLibImplementation(self, filename):

file.Close()

def WriteGLES2InterfaceHeader(self, filename):
"""Writes the GLES2 interface header."""
file = CHeaderWriter(
filename,
"// This file is included by gles2_interface.h to declare the\n"
"// GL api functions.\n")
for func in self.original_functions:
func.WriteGLES2InterfaceHeader(file)
file.Close()

def WriteGLES2InterfaceStub(self, filename):
"""Writes the GLES2 interface stub header."""
file = CHeaderWriter(
filename,
"// This file is included by gles2_interface_stub.h.\n")
for func in self.original_functions:
func.WriteGLES2InterfaceStub(file)
file.Close()

def WriteGLES2InterfaceStubImpl(self, filename):
"""Writes the GLES2 interface header."""
file = CHeaderWriter(
filename,
"// This file is included by gles2_interface_stub.cc.\n")
for func in self.original_functions:
func.WriteGLES2InterfaceStubImpl(file)
file.Close()

def WriteGLES2ImplementationHeader(self, filename):
"""Writes the GLES2 helper header."""
"""Writes the GLES2 Implementation header."""
file = CHeaderWriter(
filename,
"// This file is included by gles2_implementation.h to declare the\n"
Expand All @@ -6033,6 +6105,16 @@ def WriteGLES2ImplementationHeader(self, filename):
func.WriteGLES2ImplementationHeader(file)
file.Close()

def WriteGLES2Implementation(self, filename):
"""Writes the GLES2 Implementation."""
file = CHeaderWriter(
filename,
"// This file is included by gles2_implementation.cc to define the\n"
"// GL api functions.\n")
for func in self.original_functions:
func.WriteGLES2Implementation(file)
file.Close()

def WriteGLES2ImplementationUnitTests(self, filename):
"""Writes the GLES2 helper header."""
file = CHeaderWriter(
Expand Down Expand Up @@ -6407,7 +6489,12 @@ def main(argv):
gen.WriteCommandIds("common/gles2_cmd_ids_autogen.h")
gen.WriteFormat("common/gles2_cmd_format_autogen.h")
gen.WriteFormatTest("common/gles2_cmd_format_test_autogen.h")
gen.WriteGLES2InterfaceHeader("client/gles2_interface_autogen.h")
gen.WriteGLES2InterfaceStub("client/gles2_interface_stub_autogen.h")
gen.WriteGLES2InterfaceStubImpl(
"client/gles2_interface_stub_impl_autogen.h")
gen.WriteGLES2ImplementationHeader("client/gles2_implementation_autogen.h")
gen.WriteGLES2Implementation("client/gles2_implementation_impl_autogen.h")
gen.WriteGLES2ImplementationUnitTests(
"client/gles2_implementation_unittest_autogen.h")
gen.WriteGLES2CLibImplementation("client/gles2_c_lib_autogen.h")
Expand Down
5 changes: 5 additions & 0 deletions gpu/command_buffer/client/gles2_implementation.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3470,5 +3470,10 @@ void GLES2Implementation::PopGroupMarkerEXT() {
debug_marker_manager_.PopGroup();
}

// Include the auto-generated part of this file. We split this because it means
// we can easily edit the non-auto generated parts right here in this file
// instead of having to edit some template or the code generator.
#include "../client/gles2_implementation_impl_autogen.h"

} // namespace gles2
} // namespace gpu
Loading

0 comments on commit a9fb79d

Please sign in to comment.