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 8ababfe5cb0b131294a17091fbea87ae732c64d8..679cb812b3265865f7a1af32c727057535f88a1c 100755 |
| --- a/gpu/command_buffer/build_gles2_cmd_buffer.py |
| +++ b/gpu/command_buffer/build_gles2_cmd_buffer.py |
| @@ -2701,6 +2701,7 @@ _FUNCTION_INFO = { |
| 'GetInternalformativ': { |
| 'type': 'GETn', |
| 'result': ['SizedResult<GLint>'], |
| + 'unit_test': False, |
| 'unsafe': True, |
| }, |
| 'GetMaxValueInBufferCHROMIUM': { |
| @@ -6290,6 +6291,32 @@ class GETnHandler(TypeHandler): |
| """Overriden from TypeHandler.""" |
| return False |
| + def __GetCountLimitValidation(self, func): |
| + if func.name == 'GetInternalformativ': |
| + return """ |
| + if (%(count_param)s > 0) { |
| + // Sanity check for |bufSize| and set its upbound. |
| + GLint value = 0; |
| + LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("%(func_name)s"); |
| + glGetInternalformativ( |
| + target, format, GL_NUM_SAMPLE_COUNTS, 1, &value); |
| + GLenum error = LOCAL_PEEK_GL_ERROR("%(func_name)s"); |
| + if (error != GL_NO_ERROR) { |
| + return error::kNoError; |
| + } |
| + if (value < %(count_param)s) { |
| + %(count_param)s = value; |
| + } |
| + } |
| +""" |
|
piman
2015/06/01 21:29:36
I don't think this should belong to the generator.
|
| + return None |
| + |
| + def __GetCountParam(self, func): |
| + for arg in func.GetCmdArgs(): |
| + if arg.name == 'bufSize': |
| + return arg.name |
| + return None |
| + |
| def WriteServiceImplementation(self, func, file): |
| """Overrriden from TypeHandler.""" |
| self.WriteServiceHandlerFunctionHeader(func, file) |
| @@ -6300,8 +6327,20 @@ class GETnHandler(TypeHandler): |
| arg.WriteGetCode(file) |
| code = """ typedef cmds::%(func_name)s::Result Result; |
| - GLsizei num_values = 0; |
| - GetNumValuesReturnedForGLGet(pname, &num_values); |
| + GLsizei num_values = 0;""" |
| + count_param = self.__GetCountParam(func) |
| + if count_param: |
| + count_param_validation = self.__GetCountLimitValidation(func) |
| + if count_param_validation: |
| + code += count_param_validation |
| + code += """ |
| + if (%(count_param)s > 0) { |
| + num_values = static_cast<GLsizei>(%(count_param)s); |
| + }""" |
| + else: |
| + code += """ |
| + GetNumValuesReturnedForGLGet(pname, &num_values);""" |
| + code += """ |
| Result* result = GetSharedMemoryAs<Result*>( |
| c.%(last_arg_name)s_shm_id, c.%(last_arg_name)s_shm_offset, |
| Result::ComputeSize(num_values)); |
| @@ -6311,6 +6350,7 @@ class GETnHandler(TypeHandler): |
| 'last_arg_type': last_arg.type, |
| 'last_arg_name': last_arg.name, |
| 'func_name': func.name, |
| + 'count_param': count_param, |
| }) |
| func.WriteHandlerValidation(file) |
| code = """ // Check that the client initialized the result. |
| @@ -6329,11 +6369,9 @@ class GETnHandler(TypeHandler): |
| } |
| """ |
| else: |
| - code = """ GLenum error = glGetError(); |
| + code = """ GLenum error = LOCAL_PEEK_GL_ERROR("%(func_name)s"); |
| if (error == GL_NO_ERROR) { |
| result->SetNumResults(num_values); |
| - } else { |
| - LOCAL_SET_GL_ERROR(error, "%(func_name)s", ""); |
| } |
| return error::kNoError; |
| } |