Chromium Code Reviews| 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 f4c7e5b7367b70c10599bbc3d76cfb5096e19b6a..e7eca0d4cacf52f3b9210c927f8591c7b825e7fe 100755 |
| --- a/gpu/command_buffer/build_gles2_cmd_buffer.py |
| +++ b/gpu/command_buffer/build_gles2_cmd_buffer.py |
| @@ -1212,6 +1212,16 @@ _PEPPER_INTERFACES = [ |
| # valid_args: A dictionary of argument indices to args to use in unit tests |
| # when they can not be automatically determined. |
| # pepper_interface: The pepper interface that is used for this extension |
| +# pepper_args: A string representing the argument list (what would appear in |
| +# C/C++ between the parentheses for the function declaration) |
| +# that the Pepper API expects for this function. Use this only if |
| +# the stable Pepper API differs from the GLES2 argument list. |
| +# pepper_args_to_pass: A string representing the parameters to pass from the |
| +# Pepper API to the CommandBuffer (i.e., what would appear in |
| +# C/C++ between the parentheses for the function call). This is |
| +# for cases where pepper_args is set, and there is some conversion |
| +# (such as a type cast) required to call the CommandBuffer |
| +# function. |
| # invalid_test: False if no invalid test needed. |
| # shadowed: True = the value is shadowed so no glGetXXX call will be made. |
| # first_element_only: For PUT types, True if only the first element of an |
| @@ -1941,6 +1951,10 @@ _FUNCTION_INFO = { |
| 'client_test': False, |
| 'cmd_args': |
| 'GLuint shader, const char* data', |
| + 'pepper_args': |
| + 'GLuint shader, GLsizei count, const char** str, const GLint* length', |
| + 'pepper_args_to_pass': |
| + 'shader, count, const_cast<const char* const*>(str), length' |
| }, |
| 'StencilMask': { |
| 'type': 'StateSetFrontBack', |
| @@ -2305,6 +2319,7 @@ _FUNCTION_INFO = { |
| }, |
| 'BindUniformLocationCHROMIUM': { |
| 'type': 'GLchar', |
| + 'extension': True, |
| 'bucket': True, |
| 'needs_size': True, |
| 'gl_test_func': 'DoBindUniformLocationCHROMIUM', |
| @@ -2313,20 +2328,24 @@ _FUNCTION_INFO = { |
| 'type': 'GLcharN', |
| 'decoder_func': 'DoInsertEventMarkerEXT', |
| 'expectation': False, |
| + 'extension': True, |
| }, |
| 'PushGroupMarkerEXT': { |
| 'type': 'GLcharN', |
| 'decoder_func': 'DoPushGroupMarkerEXT', |
| 'expectation': False, |
| + 'extension': True, |
| }, |
| 'PopGroupMarkerEXT': { |
| 'decoder_func': 'DoPopGroupMarkerEXT', |
| 'expectation': False, |
| + 'extension': True, |
| 'impl_func': False, |
| }, |
| 'GenVertexArraysOES': { |
| 'type': 'GENn', |
| + 'extension': True, |
| 'gl_test_func': 'glGenVertexArraysOES', |
| 'resource_type': 'VertexArray', |
| 'resource_types': 'VertexArrays', |
| @@ -2334,6 +2353,7 @@ _FUNCTION_INFO = { |
| }, |
| 'BindVertexArrayOES': { |
| 'type': 'Bind', |
| + 'extension': True, |
| 'gl_test_func': 'glBindVertexArrayOES', |
| 'decoder_func': 'DoBindVertexArrayOES', |
| 'gen_func': 'GenVertexArraysOES', |
| @@ -2342,6 +2362,7 @@ _FUNCTION_INFO = { |
| }, |
| 'DeleteVertexArraysOES': { |
| 'type': 'DELn', |
| + 'extension': True, |
| 'gl_test_func': 'glDeleteVertexArraysOES', |
| 'resource_type': 'VertexArray', |
| 'resource_types': 'VertexArrays', |
| @@ -2349,6 +2370,7 @@ _FUNCTION_INFO = { |
| }, |
| 'IsVertexArrayOES': { |
| 'type': 'Is', |
| + 'extension': True, |
| 'gl_test_func': 'glIsVertexArrayOES', |
| 'decoder_func': 'DoIsVertexArrayOES', |
| 'expectation': False, |
| @@ -6394,7 +6416,7 @@ class Function(object): |
| """Gets the last original argument to this function.""" |
| return self.original_args[len(self.original_args) - 1] |
| - def __GetArgList(self, arg_string, add_comma): |
| + def __MaybePrependComma(self, arg_string, add_comma): |
| """Adds a comma if arg_string is not empty and add_comma is true.""" |
| comma = "" |
| if add_comma and len(arg_string): |
| @@ -6402,46 +6424,60 @@ class Function(object): |
| return "%s%s" % (comma, arg_string) |
| def MakeTypedOriginalArgString(self, prefix, add_comma = False): |
| - """Gets a list of arguments as they arg in GL.""" |
| + """Gets a list of arguments as they are in GL.""" |
| args = self.GetOriginalArgs() |
| arg_string = ", ".join( |
| ["%s %s%s" % (arg.type, prefix, arg.name) for arg in args]) |
| - return self.__GetArgList(arg_string, add_comma) |
| + return self.__MaybePrependComma(arg_string, add_comma) |
| def MakeOriginalArgString(self, prefix, add_comma = False, separator = ", "): |
| """Gets the list of arguments as they are in GL.""" |
| args = self.GetOriginalArgs() |
| arg_string = separator.join( |
| ["%s%s" % (prefix, arg.name) for arg in args]) |
| - return self.__GetArgList(arg_string, add_comma) |
| + return self.__MaybePrependComma(arg_string, add_comma) |
| + |
| + def MakeTypedPepperArgString(self, prefix): |
| + """Gets a list of arguments as they need to be for Pepper.""" |
| + if self.GetInfo("pepper_args"): |
| + return self.GetInfo("pepper_args") |
| + else: |
| + return self.MakeTypedOriginalArgString(prefix, False) |
| + |
| + def MakePepperArgString(self, prefix): |
| + """Gets the list of arguments to pass from a Pepper call.""" |
| + if self.GetInfo("pepper_args_to_pass"): |
| + return self.GetInfo("pepper_args_to_pass") |
| + else: |
| + return self.MakeOriginalArgString(prefix, False) |
| def MakeTypedCmdArgString(self, prefix, add_comma = False): |
| """Gets a typed list of arguments as they need to be for command buffers.""" |
| args = self.GetCmdArgs() |
| arg_string = ", ".join( |
| ["%s %s%s" % (arg.type, prefix, arg.name) for arg in args]) |
| - return self.__GetArgList(arg_string, add_comma) |
| + return self.__MaybePrependComma(arg_string, add_comma) |
| def MakeCmdArgString(self, prefix, add_comma = False): |
| """Gets the list of arguments as they need to be for command buffers.""" |
| args = self.GetCmdArgs() |
| arg_string = ", ".join( |
| ["%s%s" % (prefix, arg.name) for arg in args]) |
| - return self.__GetArgList(arg_string, add_comma) |
| + return self.__MaybePrependComma(arg_string, add_comma) |
| def MakeTypedInitString(self, prefix, add_comma = False): |
| """Gets a typed list of arguments as they need to be for cmd Init/Set.""" |
| args = self.GetInitArgs() |
| arg_string = ", ".join( |
| ["%s %s%s" % (arg.type, prefix, arg.name) for arg in args]) |
| - return self.__GetArgList(arg_string, add_comma) |
| + return self.__MaybePrependComma(arg_string, add_comma) |
| def MakeInitString(self, prefix, add_comma = False): |
| """Gets the list of arguments as they need to be for cmd Init/Set.""" |
| args = self.GetInitArgs() |
| arg_string = ", ".join( |
| ["%s%s" % (prefix, arg.name) for arg in args]) |
| - return self.__GetArgList(arg_string, add_comma) |
| + return self.__MaybePrependComma(arg_string, add_comma) |
| def MakeLogArgString(self): |
| """Makes a string of the arguments for the LOG macros""" |
| @@ -7593,7 +7629,7 @@ const size_t GLES2Util::enum_to_string_table_len_ = |
| if not func.InPepperInterface(interface): |
| continue |
| - original_arg = func.MakeTypedOriginalArgString("") |
| + original_arg = func.MakeTypedPepperArgString("") |
| context_arg = "PP_Resource context" |
| if len(original_arg): |
| arg = context_arg + ", " + original_arg |
| @@ -7621,31 +7657,52 @@ const size_t GLES2Util::enum_to_string_table_len_ = |
| file.Write("namespace ppapi {\n\n") |
| file.Write("namespace {\n\n") |
| - file.Write("gpu::gles2::GLES2Implementation*" |
| - " GetGLES(PP_Resource context) {\n") |
| - file.Write(" thunk::EnterResource<thunk::PPB_Graphics3D_API>" |
| - " enter_g3d(context, false);\n") |
| - file.Write(" DCHECK(enter_g3d.succeeded());\n") |
| - file.Write(" return static_cast<PPB_Graphics3D_Shared*>" |
| - "(enter_g3d.object())->gles2_impl();\n") |
| - file.Write("}\n\n") |
| + file.Write("typedef thunk::EnterResource<thunk::PPB_Graphics3D_API>" |
| + " Enter3D;\n\n") |
| + |
| + file.Write("gpu::gles2::GLES2Implementation* ToGles2Impl(Enter3D*" |
| + " enter) {\n") |
| + file.Write(" CHECK(enter);\n") |
| + file.Write(" CHECK(enter->succeeded());\n") |
| + file.Write(" return static_cast<PPB_Graphics3D_Shared*>(enter->object())->" |
| + "gles2_impl();\n"); |
| + file.Write("}\n\n"); |
| for func in self.original_functions: |
| if not func.InAnyPepperExtension(): |
| continue |
| - original_arg = func.MakeTypedOriginalArgString("") |
| + original_arg = func.MakeTypedPepperArgString("") |
| context_arg = "PP_Resource context_id" |
| if len(original_arg): |
| arg = context_arg + ", " + original_arg |
| else: |
| arg = context_arg |
| file.Write("%s %s(%s) {\n" % (func.return_type, func.name, arg)) |
| + file.Write(" Enter3D enter(context_id, true);\n") |
| + file.Write(" if (enter.succeeded()) {\n") |
| return_str = "" if func.return_type == "void" else "return " |
| - file.Write(" %sGetGLES(context_id)->%s(%s);\n" % |
| + file.Write(" %sToGles2Impl(&enter)->%s(%s);\n" % |
| (return_str, func.original_name, |
| - func.MakeOriginalArgString(""))) |
| + func.MakePepperArgString(""))) |
| + file.Write(" }") |
| + if func.return_type == "void": |
| + file.Write("\n") |
| + else: |
| + file.Write(" else {\n") |
| + error_return = "0" |
| + if func.return_type == "GLboolean": |
| + error_return = "GL_FALSE" |
| + elif func.return_type == "GLenum": |
| + if func.name == "CheckFramebufferStatus": |
| + error_return = "GL_INVALID_ENUM" |
|
dmichael (off chromium)
2013/09/25 20:05:13
I looked at the documentation of glCheckFramebuffe
|
| + else: |
| + error_return = "GL_INVALID_OPERATION" |
| + elif "*" in func.return_type: |
| + error_return = "NULL" |
| + file.Write(" return %s;\n" % error_return) |
| + file.Write(" }\n") |
| file.Write("}\n\n") |
| file.Write("} // namespace\n") |