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

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

Issue 1747013: Changes the code to use separate ids namspaces... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 8 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/renderer/ggl/ggl.cc ('k') | gpu/command_buffer/client/gles2_implementation.h » ('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/python 1 #!/usr/bin/python
2 # 2 #
3 # Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. 3 # Copyright (c) 2006-2009 The Chromium Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be 4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file. 5 # found in the LICENSE file.
6 6
7 """code generator for GLES2 command buffers.""" 7 """code generator for GLES2 command buffers."""
8 8
9 import os 9 import os
10 import os.path 10 import os.path
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 GL_APICALL void GL_APIENTRY glGetTexParameteriv (GLenumTextureTarget tar get, GLenumTextureParameter pname, GLint* params); 109 GL_APICALL void GL_APIENTRY glGetTexParameteriv (GLenumTextureTarget tar get, GLenumTextureParameter pname, GLint* params);
110 GL_APICALL void GL_APIENTRY glGetUniformfv (GLidProgram program, GLint l ocation, GLfloat* params); 110 GL_APICALL void GL_APIENTRY glGetUniformfv (GLidProgram program, GLint l ocation, GLfloat* params);
111 GL_APICALL void GL_APIENTRY glGetUniformiv (GLidProgram program, GLint l ocation, GLint* params); 111 GL_APICALL void GL_APIENTRY glGetUniformiv (GLidProgram program, GLint l ocation, GLint* params);
112 GL_APICALL GLint GL_APIENTRY glGetUniformLocation (GLidProgram program, c onst char* name); 112 GL_APICALL GLint GL_APIENTRY glGetUniformLocation (GLidProgram program, c onst char* name);
113 GL_APICALL void GL_APIENTRY glGetVertexAttribfv (GLuint index, GLenumVer texAttribute pname, GLfloat* params); 113 GL_APICALL void GL_APIENTRY glGetVertexAttribfv (GLuint index, GLenumVer texAttribute pname, GLfloat* params);
114 GL_APICALL void GL_APIENTRY glGetVertexAttribiv (GLuint index, GLenumVer texAttribute pname, GLint* params); 114 GL_APICALL void GL_APIENTRY glGetVertexAttribiv (GLuint index, GLenumVer texAttribute pname, GLint* params);
115 GL_APICALL void GL_APIENTRY glGetVertexAttribPointerv (GLuint index, GLe numVertexPointer pname, void** pointer); 115 GL_APICALL void GL_APIENTRY glGetVertexAttribPointerv (GLuint index, GLe numVertexPointer pname, void** pointer);
116 GL_APICALL void GL_APIENTRY glHint (GLenumHintTarget target, GLenumHintM ode mode); 116 GL_APICALL void GL_APIENTRY glHint (GLenumHintTarget target, GLenumHintM ode mode);
117 GL_APICALL GLboolean GL_APIENTRY glIsBuffer (GLidBuffer buffer); 117 GL_APICALL GLboolean GL_APIENTRY glIsBuffer (GLidBuffer buffer);
118 GL_APICALL GLboolean GL_APIENTRY glIsEnabled (GLenumCapability cap); 118 GL_APICALL GLboolean GL_APIENTRY glIsEnabled (GLenumCapability cap);
119 GL_APICALL GLboolean GL_APIENTRY glIsFramebuffer (GLuint framebuffer); 119 GL_APICALL GLboolean GL_APIENTRY glIsFramebuffer (GLidFramebuffer framebuffer );
120 GL_APICALL GLboolean GL_APIENTRY glIsProgram (GLuint program); 120 GL_APICALL GLboolean GL_APIENTRY glIsProgram (GLidProgram program);
121 GL_APICALL GLboolean GL_APIENTRY glIsRenderbuffer (GLuint renderbuffer); 121 GL_APICALL GLboolean GL_APIENTRY glIsRenderbuffer (GLidRenderbuffer renderbuf fer);
122 GL_APICALL GLboolean GL_APIENTRY glIsShader (GLuint shader); 122 GL_APICALL GLboolean GL_APIENTRY glIsShader (GLidShader shader);
123 GL_APICALL GLboolean GL_APIENTRY glIsTexture (GLuint texture); 123 GL_APICALL GLboolean GL_APIENTRY glIsTexture (GLidTexture texture);
124 GL_APICALL void GL_APIENTRY glLineWidth (GLfloat width); 124 GL_APICALL void GL_APIENTRY glLineWidth (GLfloat width);
125 GL_APICALL void GL_APIENTRY glLinkProgram (GLidProgram program); 125 GL_APICALL void GL_APIENTRY glLinkProgram (GLidProgram program);
126 GL_APICALL void GL_APIENTRY glPixelStorei (GLenumPixelStore pname, GLint PixelStoreAlignment param); 126 GL_APICALL void GL_APIENTRY glPixelStorei (GLenumPixelStore pname, GLint PixelStoreAlignment param);
127 GL_APICALL void GL_APIENTRY glPolygonOffset (GLfloat factor, GLfloat uni ts); 127 GL_APICALL void GL_APIENTRY glPolygonOffset (GLfloat factor, GLfloat uni ts);
128 GL_APICALL void GL_APIENTRY glReadPixels (GLint x, GLint y, GLsizei widt h, GLsizei height, GLenumReadPixelFormat format, GLenumPixelType type, void* pix els); 128 GL_APICALL void GL_APIENTRY glReadPixels (GLint x, GLint y, GLsizei widt h, GLsizei height, GLenumReadPixelFormat format, GLenumPixelType type, void* pix els);
129 GL_APICALL void GL_APIENTRY glReleaseShaderCompiler (void); 129 GL_APICALL void GL_APIENTRY glReleaseShaderCompiler (void);
130 GL_APICALL void GL_APIENTRY glRenderbufferStorage (GLenumRenderBufferTar get target, GLenumRenderBufferFormat internalformat, GLsizei width, GLsizei heig ht); 130 GL_APICALL void GL_APIENTRY glRenderbufferStorage (GLenumRenderBufferTar get target, GLenumRenderBufferFormat internalformat, GLsizei width, GLsizei heig ht);
131 GL_APICALL void GL_APIENTRY glSampleCoverage (GLclampf value, GLboolean invert); 131 GL_APICALL void GL_APIENTRY glSampleCoverage (GLclampf value, GLboolean invert);
132 GL_APICALL void GL_APIENTRY glScissor (GLint x, GLint y, GLsizei width, GLsizei height); 132 GL_APICALL void GL_APIENTRY glScissor (GLint x, GLint y, GLsizei width, GLsizei height);
133 GL_APICALL void GL_APIENTRY glShaderBinary (GLsizei n, const GLuint* sha ders, GLenum binaryformat, const void* binary, GLsizei length); 133 GL_APICALL void GL_APIENTRY glShaderBinary (GLsizei n, const GLuint* sha ders, GLenum binaryformat, const void* binary, GLsizei length);
(...skipping 817 matching lines...) Expand 10 before | Expand all | Expand 10 after
951 # needs_size: If true a data_size field is added to the command. 951 # needs_size: If true a data_size field is added to the command.
952 # data_type: The type of data the command uses. For PUTn or PUT types. 952 # data_type: The type of data the command uses. For PUTn or PUT types.
953 # count: The number of units per element. For PUTn or PUT types. 953 # count: The number of units per element. For PUTn or PUT types.
954 # unit_test: If False no unit test will be generated. 954 # unit_test: If False no unit test will be generated.
955 # expectation: If False the unit test will have no expected calls. 955 # expectation: If False the unit test will have no expected calls.
956 # gen_func: Name of function that generates GL resource for corresponding 956 # gen_func: Name of function that generates GL resource for corresponding
957 # bind function. 957 # bind function.
958 958
959 _FUNCTION_INFO = { 959 _FUNCTION_INFO = {
960 'ActiveTexture': {'decoder_func': 'DoActiveTexture', 'unit_test': False}, 960 'ActiveTexture': {'decoder_func': 'DoActiveTexture', 'unit_test': False},
961 'AttachShader': {'decoder_func': 'DoAttachShader'},
961 'BindAttribLocation': {'type': 'GLchar', 'bucket': True, 'needs_size': True}, 962 'BindAttribLocation': {'type': 'GLchar', 'bucket': True, 'needs_size': True},
962 'BindBuffer': { 963 'BindBuffer': {
963 'type': 'Bind', 964 'type': 'Bind',
964 'impl_decl': False, 965 'impl_decl': False,
965 'decoder_func': 'DoBindBuffer', 966 'decoder_func': 'DoBindBuffer',
966 'gen_func': 'GenBuffersARB', 967 'gen_func': 'GenBuffersARB',
967 }, 968 },
968 'BindFramebuffer': { 969 'BindFramebuffer': {
969 'type': 'Bind', 970 'type': 'Bind',
970 'decoder_func': 'DoBindFramebuffer', 971 'decoder_func': 'DoBindFramebuffer',
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1006 'gl_test_func': 'glDeleteFramebuffersEXT', 1007 'gl_test_func': 'glDeleteFramebuffersEXT',
1007 }, 1008 },
1008 'DeleteProgram': {'type': 'Custom', 'decoder_func': 'DoDeleteProgram'}, 1009 'DeleteProgram': {'type': 'Custom', 'decoder_func': 'DoDeleteProgram'},
1009 'DeleteRenderbuffers': { 1010 'DeleteRenderbuffers': {
1010 'type': 'DELn', 1011 'type': 'DELn',
1011 'gl_test_func': 'glDeleteRenderbuffersEXT', 1012 'gl_test_func': 'glDeleteRenderbuffersEXT',
1012 }, 1013 },
1013 'DeleteShader': {'type': 'Custom', 'decoder_func': 'DoDeleteShader'}, 1014 'DeleteShader': {'type': 'Custom', 'decoder_func': 'DoDeleteShader'},
1014 'DeleteTextures': {'type': 'DELn'}, 1015 'DeleteTextures': {'type': 'DELn'},
1015 'DepthRangef': {'decoder_func': 'glDepthRange'}, 1016 'DepthRangef': {'decoder_func': 'glDepthRange'},
1017 'DetachShader': {'decoder_func': 'DoDetachShader'},
1016 'DisableVertexAttribArray': { 1018 'DisableVertexAttribArray': {
1017 'decoder_func': 'DoDisableVertexAttribArray', 1019 'decoder_func': 'DoDisableVertexAttribArray',
1018 'impl_decl': False, 1020 'impl_decl': False,
1019 }, 1021 },
1020 'DrawArrays': { 1022 'DrawArrays': {
1021 'decoder_func': 'DoDrawArrays', 1023 'decoder_func': 'DoDrawArrays',
1022 'unit_test': False, 1024 'unit_test': False,
1023 'impl_decl': False, 1025 'impl_decl': False,
1024 }, 1026 },
1025 'DrawElements': { 1027 'DrawElements': {
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
1123 }, 1125 },
1124 'GetProgramiv': { 1126 'GetProgramiv': {
1125 'type': 'GETn', 1127 'type': 'GETn',
1126 'decoder_func': 'DoGetProgramiv', 1128 'decoder_func': 'DoGetProgramiv',
1127 'result': ['SizedResult<GLint>'], 1129 'result': ['SizedResult<GLint>'],
1128 }, 1130 },
1129 'GetProgramInfoLog': { 1131 'GetProgramInfoLog': {
1130 'type': 'STRn', 1132 'type': 'STRn',
1131 'get_len_func': 'glGetProgramiv', 1133 'get_len_func': 'glGetProgramiv',
1132 'get_len_enum': 'GL_INFO_LOG_LENGTH', 1134 'get_len_enum': 'GL_INFO_LOG_LENGTH',
1133 }, 1135 },
1134 'GetRenderbufferParameteriv': { 1136 'GetRenderbufferParameteriv': {
1135 'type': 'GETn', 1137 'type': 'GETn',
1136 'decoder_func': 'DoGetRenderbufferParameteriv', 1138 'decoder_func': 'DoGetRenderbufferParameteriv',
1137 'gl_test_func': 'glGetRenderbufferParameterivEXT', 1139 'gl_test_func': 'glGetRenderbufferParameterivEXT',
1138 'result': ['SizedResult<GLint>'], 1140 'result': ['SizedResult<GLint>'],
1139 }, 1141 },
1140 'GetShaderiv': { 1142 'GetShaderiv': {
1141 'type': 'GETn', 1143 'type': 'GETn',
1142 'decoder_func': 'DoGetShaderiv', 1144 'decoder_func': 'DoGetShaderiv',
1143 'result': ['SizedResult<GLint>'], 1145 'result': ['SizedResult<GLint>'],
(...skipping 11 matching lines...) Expand all
1155 'void* result', 1157 'void* result',
1156 'result': [ 1158 'result': [
1157 'int32 success', 1159 'int32 success',
1158 'int32 min_range', 1160 'int32 min_range',
1159 'int32 max_range', 1161 'int32 max_range',
1160 'int32 precision', 1162 'int32 precision',
1161 ], 1163 ],
1162 }, 1164 },
1163 'GetShaderSource': { 1165 'GetShaderSource': {
1164 'type': 'STRn', 1166 'type': 'STRn',
1165 'decoder_func': 'DoGetShaderSource',
1166 'get_len_func': 'DoGetShaderiv', 1167 'get_len_func': 'DoGetShaderiv',
1167 'get_len_enum': 'GL_SHADER_SOURCE_LENGTH', 1168 'get_len_enum': 'GL_SHADER_SOURCE_LENGTH',
1168 'unit_test': False, 1169 'unit_test': False,
1169 }, 1170 },
1170 'GetString': { 1171 'GetString': {
1171 'type': 'Custom', 1172 'type': 'Custom',
1172 'cmd_args': 'GLenumStringType name, uint32 bucket_id', 1173 'cmd_args': 'GLenumStringType name, uint32 bucket_id',
1173 }, 1174 },
1174 'GetTexParameterfv': {'type': 'GETn', 'result': ['SizedResult<GLfloat>']}, 1175 'GetTexParameterfv': {'type': 'GETn', 'result': ['SizedResult<GLfloat>']},
1175 'GetTexParameteriv': {'type': 'GETn', 'result': ['SizedResult<GLint>']}, 1176 'GetTexParameteriv': {'type': 'GETn', 'result': ['SizedResult<GLint>']},
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
1304 'Uniform2fv': {'type': 'PUTn', 'data_type': 'GLfloat', 'count': 2}, 1305 'Uniform2fv': {'type': 'PUTn', 'data_type': 'GLfloat', 'count': 2},
1305 'Uniform2iv': {'type': 'PUTn', 'data_type': 'GLint', 'count': 2}, 1306 'Uniform2iv': {'type': 'PUTn', 'data_type': 'GLint', 'count': 2},
1306 'Uniform3fv': {'type': 'PUTn', 'data_type': 'GLfloat', 'count': 3}, 1307 'Uniform3fv': {'type': 'PUTn', 'data_type': 'GLfloat', 'count': 3},
1307 'Uniform3iv': {'type': 'PUTn', 'data_type': 'GLint', 'count': 3}, 1308 'Uniform3iv': {'type': 'PUTn', 'data_type': 'GLint', 'count': 3},
1308 'Uniform4fv': {'type': 'PUTn', 'data_type': 'GLfloat', 'count': 4}, 1309 'Uniform4fv': {'type': 'PUTn', 'data_type': 'GLfloat', 'count': 4},
1309 'Uniform4iv': {'type': 'PUTn', 'data_type': 'GLint', 'count': 4}, 1310 'Uniform4iv': {'type': 'PUTn', 'data_type': 'GLint', 'count': 4},
1310 'UniformMatrix2fv': {'type': 'PUTn', 'data_type': 'GLfloat', 'count': 4}, 1311 'UniformMatrix2fv': {'type': 'PUTn', 'data_type': 'GLfloat', 'count': 4},
1311 'UniformMatrix3fv': {'type': 'PUTn', 'data_type': 'GLfloat', 'count': 9}, 1312 'UniformMatrix3fv': {'type': 'PUTn', 'data_type': 'GLfloat', 'count': 9},
1312 'UniformMatrix4fv': {'type': 'PUTn', 'data_type': 'GLfloat', 'count': 16}, 1313 'UniformMatrix4fv': {'type': 'PUTn', 'data_type': 'GLfloat', 'count': 16},
1313 'UseProgram': {'decoder_func': 'DoUseProgram', 'unit_test': False}, 1314 'UseProgram': {'decoder_func': 'DoUseProgram', 'unit_test': False},
1315 'ValidateProgram': {'decoder_func': 'DoValidateProgram'},
1314 'VertexAttrib1fv': {'type': 'PUT', 'data_type': 'GLfloat', 'count': 1}, 1316 'VertexAttrib1fv': {'type': 'PUT', 'data_type': 'GLfloat', 'count': 1},
1315 'VertexAttrib2fv': {'type': 'PUT', 'data_type': 'GLfloat', 'count': 2}, 1317 'VertexAttrib2fv': {'type': 'PUT', 'data_type': 'GLfloat', 'count': 2},
1316 'VertexAttrib3fv': {'type': 'PUT', 'data_type': 'GLfloat', 'count': 3}, 1318 'VertexAttrib3fv': {'type': 'PUT', 'data_type': 'GLfloat', 'count': 3},
1317 'VertexAttrib4fv': {'type': 'PUT', 'data_type': 'GLfloat', 'count': 4}, 1319 'VertexAttrib4fv': {'type': 'PUT', 'data_type': 'GLfloat', 'count': 4},
1318 'VertexAttribPointer': { 1320 'VertexAttribPointer': {
1319 'type': 'Manual', 1321 'type': 'Manual',
1320 'cmd_args': 'GLuint indx, GLint size, GLenum type, GLboolean normalized, ' 1322 'cmd_args': 'GLuint indx, GLint size, GLenum type, GLboolean normalized, '
1321 'GLsizei stride, GLuint offset', 1323 'GLsizei stride, GLuint offset',
1322 }, 1324 },
1323 } 1325 }
(...skipping 830 matching lines...) Expand 10 before | Expand all | Expand 10 after
2154 2156
2155 TEST_F(%(test_name)s, %(name)sValidArgsNewId) { 2157 TEST_F(%(test_name)s, %(name)sValidArgsNewId) {
2156 EXPECT_CALL(*gl_, %(gl_func_name)s(%(first_gl_arg)s, kNewServiceId)); 2158 EXPECT_CALL(*gl_, %(gl_func_name)s(%(first_gl_arg)s, kNewServiceId));
2157 EXPECT_CALL(*gl_, %(gl_gen_func_name)s(1, _)) 2159 EXPECT_CALL(*gl_, %(gl_gen_func_name)s(1, _))
2158 .WillOnce(SetArgumentPointee<1>(kNewServiceId)); 2160 .WillOnce(SetArgumentPointee<1>(kNewServiceId));
2159 SpecializedSetup<%(name)s, 0>(); 2161 SpecializedSetup<%(name)s, 0>();
2160 %(name)s cmd; 2162 %(name)s cmd;
2161 cmd.Init(%(first_arg)s, kNewClientId); 2163 cmd.Init(%(first_arg)s, kNewClientId);
2162 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 2164 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
2163 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 2165 EXPECT_EQ(GL_NO_ERROR, GetGLError());
2164 EXPECT_EQ(GetServiceId(kNewClientId), kNewServiceId); 2166 EXPECT_TRUE(Get%(resource_type)sInfo(kNewClientId) != NULL);
2165 EXPECT_TRUE(Get%(resource_type)sInfo(kNewServiceId) != NULL);
2166 } 2167 }
2167 """ 2168 """
2168 gen_func_names = { 2169 gen_func_names = {
2169 } 2170 }
2170 self.WriteValidUnitTest(func, file, valid_test, { 2171 self.WriteValidUnitTest(func, file, valid_test, {
2171 'first_arg': func.GetOriginalArgs()[0].GetValidArg(0, 0), 2172 'first_arg': func.GetOriginalArgs()[0].GetValidArg(0, 0),
2172 'first_gl_arg': func.GetOriginalArgs()[0].GetValidGLArg(0, 0), 2173 'first_gl_arg': func.GetOriginalArgs()[0].GetValidGLArg(0, 0),
2173 'resource_type': func.GetOriginalArgs()[1].resource_type, 2174 'resource_type': func.GetOriginalArgs()[1].resource_type,
2174 'gl_gen_func_name': func.GetInfo("gen_func"), 2175 'gl_gen_func_name': func.GetInfo("gen_func"),
2175 }) 2176 })
(...skipping 14 matching lines...) Expand all
2190 impl_func = func.GetInfo('impl_func') 2191 impl_func = func.GetInfo('impl_func')
2191 impl_decl = func.GetInfo('impl_decl') 2192 impl_decl = func.GetInfo('impl_decl')
2192 if (func.can_auto_generate and 2193 if (func.can_auto_generate and
2193 (impl_func == None or impl_func == True) and 2194 (impl_func == None or impl_func == True) and
2194 (impl_decl == None or impl_decl == True)): 2195 (impl_decl == None or impl_decl == True)):
2195 file.Write("%s %s(%s) {\n" % 2196 file.Write("%s %s(%s) {\n" %
2196 (func.return_type, func.original_name, 2197 (func.return_type, func.original_name,
2197 func.MakeTypedOriginalArgString(""))) 2198 func.MakeTypedOriginalArgString("")))
2198 for arg in func.GetOriginalArgs(): 2199 for arg in func.GetOriginalArgs():
2199 arg.WriteClientSideValidationCode(file) 2200 arg.WriteClientSideValidationCode(file)
2200 code = """ if (IsReservedId(%(id)s)) { 2201 code = """ if (Is%(type)sReservedId(%(id)s)) {
2201 SetGLError(GL_INVALID_OPERATION); 2202 SetGLError(GL_INVALID_OPERATION);
2202 return; 2203 return;
2203 } 2204 }
2204 if (%(id)s != 0) { 2205 if (%(id)s != 0) {
2205 id_allocator_.MarkAsUsed(%(id)s); 2206 %(lc_type)s_id_allocator_.MarkAsUsed(%(id)s);
2206 } 2207 }
2207 helper_->%(name)s(%(arg_string)s); 2208 helper_->%(name)s(%(arg_string)s);
2208 } 2209 }
2209 2210
2210 """ 2211 """
2211 file.Write(code % { 2212 file.Write(code % {
2212 'name': func.name, 2213 'name': func.name,
2213 'arg_string': func.MakeOriginalArgString(""), 2214 'arg_string': func.MakeOriginalArgString(""),
2214 'id': func.GetOriginalArgs()[1].name, 2215 'id': func.GetOriginalArgs()[1].name,
2216 'type': func.GetOriginalArgs()[1].resource_type,
2217 'lc_type': func.GetOriginalArgs()[1].resource_type.lower(),
2215 }) 2218 })
2216 else: 2219 else:
2217 self.WriteGLES2ImplementationDeclaration(func, file) 2220 self.WriteGLES2ImplementationDeclaration(func, file)
2218 2221
2219 2222
2220 class GENnHandler(TypeHandler): 2223 class GENnHandler(TypeHandler):
2221 """Handler for glGen___ type functions.""" 2224 """Handler for glGen___ type functions."""
2222 2225
2223 def __init__(self): 2226 def __init__(self):
2224 TypeHandler.__init__(self) 2227 TypeHandler.__init__(self)
2225 2228
2226 def InitFunction(self, func): 2229 def InitFunction(self, func):
2227 """Overrriden from TypeHandler.""" 2230 """Overrriden from TypeHandler."""
2228 pass 2231 pass
2229 2232
2230 def WriteGetDataSizeCode(self, func, file): 2233 def WriteGetDataSizeCode(self, func, file):
2231 """Overrriden from TypeHandler.""" 2234 """Overrriden from TypeHandler."""
2232 code = """ uint32 data_size; 2235 code = """ uint32 data_size;
2233 if (!SafeMultiplyUint32(n, sizeof(GLuint), &data_size)) { 2236 if (!SafeMultiplyUint32(n, sizeof(GLuint), &data_size)) {
2234 return error::kOutOfBounds; 2237 return error::kOutOfBounds;
2235 } 2238 }
2236 """ 2239 """
2237 file.Write(code) 2240 file.Write(code)
2238 2241
2239 def WriteHandlerImplementation (self, func, file): 2242 def WriteHandlerImplementation (self, func, file):
2240 """Overrriden from TypeHandler.""" 2243 """Overrriden from TypeHandler."""
2241 file.Write(" if (!GenGLObjects<GL%sHelper>(n, %s)) {\n" 2244 file.Write(" if (!%sHelper(n, %s)) {\n"
2242 " return error::kInvalidArguments;\n" 2245 " return error::kInvalidArguments;\n"
2243 " }\n" % 2246 " }\n" %
2244 (func.name, func.GetLastOriginalArg().name)) 2247 (func.name, func.GetLastOriginalArg().name))
2245 2248
2246 def WriteImmediateHandlerImplementation(self, func, file): 2249 def WriteImmediateHandlerImplementation(self, func, file):
2247 """Overrriden from TypeHandler.""" 2250 """Overrriden from TypeHandler."""
2248 file.Write(" if (!GenGLObjects<GL%sHelper>(n, %s)) {\n" 2251 file.Write(" if (!%sHelper(n, %s)) {\n"
2249 " return error::kInvalidArguments;\n" 2252 " return error::kInvalidArguments;\n"
2250 " }\n" % 2253 " }\n" %
2251 (func.original_name, func.GetLastOriginalArg().name)) 2254 (func.original_name, func.GetLastOriginalArg().name))
2252 2255
2253 def WriteGLES2ImplementationHeader(self, func, file): 2256 def WriteGLES2ImplementationHeader(self, func, file):
2254 """Overrriden from TypeHandler.""" 2257 """Overrriden from TypeHandler."""
2255 file.Write("%s %s(%s) {\n" % 2258 code = """%(return_type)s %(name)s(%(typed_args)s) {
2256 (func.return_type, func.original_name, 2259 MakeIds(&%(resource_type)s_id_allocator_, %(args)s);
2257 func.MakeTypedOriginalArgString(""))) 2260 helper_->%(name)sImmediate(%(args)s);
2258 file.Write(" MakeIds(%s);\n" % func.MakeOriginalArgString("")) 2261 }
2259 file.Write(" helper_->%sImmediate(%s);\n" % 2262
2260 (func.name, func.MakeOriginalArgString(""))) 2263 """
2261 file.Write("}\n") 2264 file.Write(code % {
2262 file.Write("\n") 2265 'return_type': func.return_type,
2266 'name': func.original_name,
2267 'typed_args': func.MakeTypedOriginalArgString(""),
2268 'args': func.MakeOriginalArgString(""),
2269 'resource_type': func.name[3:-1].lower()
2270 })
2263 2271
2264 def WriteServiceUnitTest(self, func, file): 2272 def WriteServiceUnitTest(self, func, file):
2265 """Overrriden from TypeHandler.""" 2273 """Overrriden from TypeHandler."""
2266 valid_test = """ 2274 valid_test = """
2267 TEST_F(%(test_name)s, %(name)sValidArgs) { 2275 TEST_F(%(test_name)s, %(name)sValidArgs) {
2268 EXPECT_CALL(*gl_, %(gl_func_name)s(1, _)) 2276 EXPECT_CALL(*gl_, %(gl_func_name)s(1, _))
2269 .WillOnce(SetArgumentPointee<1>(kNewServiceId)); 2277 .WillOnce(SetArgumentPointee<1>(kNewServiceId));
2270 GetSharedMemoryAs<GLuint*>()[0] = kNewClientId; 2278 GetSharedMemoryAs<GLuint*>()[0] = kNewClientId;
2271 SpecializedSetup<%(name)s, 0>(); 2279 SpecializedSetup<%(name)s, 0>();
2272 %(name)s cmd; 2280 %(name)s cmd;
2273 cmd.Init(%(args)s); 2281 cmd.Init(%(args)s);
2274 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 2282 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
2275 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 2283 EXPECT_EQ(GL_NO_ERROR, GetGLError());
2276 EXPECT_EQ(GetServiceId(kNewClientId), kNewServiceId); 2284 EXPECT_TRUE(Get%(resource_name)sInfo(kNewClientId) != NULL);
2277 } 2285 }
2278 """ 2286 """
2279 self.WriteValidUnitTest(func, file, valid_test) 2287 self.WriteValidUnitTest(func, file, valid_test, {
2288 'resource_name': func.name[3:-1],
2289 })
2280 invalid_test = """ 2290 invalid_test = """
2281 TEST_F(%(test_name)s, %(name)sInvalidArgs) { 2291 TEST_F(%(test_name)s, %(name)sInvalidArgs) {
2282 EXPECT_CALL(*gl_, %(gl_func_name)s(_, _)).Times(0); 2292 EXPECT_CALL(*gl_, %(gl_func_name)s(_, _)).Times(0);
2283 GetSharedMemoryAs<GLuint*>()[0] = client_%(resource_name)s_id_; 2293 GetSharedMemoryAs<GLuint*>()[0] = client_%(resource_name)s_id_;
2284 SpecializedSetup<%(name)s, 0>(); 2294 SpecializedSetup<%(name)s, 0>();
2285 %(name)s cmd; 2295 %(name)s cmd;
2286 cmd.Init(%(args)s); 2296 cmd.Init(%(args)s);
2287 EXPECT_EQ(error::kInvalidArguments, ExecuteCmd(cmd)); 2297 EXPECT_EQ(error::kInvalidArguments, ExecuteCmd(cmd));
2288 } 2298 }
2289 """ 2299 """
2290 self.WriteValidUnitTest(func, file, invalid_test, { 2300 self.WriteValidUnitTest(func, file, invalid_test, {
2291 'resource_name': func.GetOriginalArgs()[1].name[0:-1] 2301 'resource_name': func.GetOriginalArgs()[1].name[0:-1]
2292 }) 2302 })
2293 2303
2294 def WriteImmediateServiceUnitTest(self, func, file): 2304 def WriteImmediateServiceUnitTest(self, func, file):
2295 """Overrriden from TypeHandler.""" 2305 """Overrriden from TypeHandler."""
2296 valid_test = """ 2306 valid_test = """
2297 TEST_F(%(test_name)s, %(name)sValidArgs) { 2307 TEST_F(%(test_name)s, %(name)sValidArgs) {
2298 EXPECT_CALL(*gl_, %(gl_func_name)s(1, _)) 2308 EXPECT_CALL(*gl_, %(gl_func_name)s(1, _))
2299 .WillOnce(SetArgumentPointee<1>(kNewServiceId)); 2309 .WillOnce(SetArgumentPointee<1>(kNewServiceId));
2300 %(name)s& cmd = *GetImmediateAs<%(name)s>(); 2310 %(name)s& cmd = *GetImmediateAs<%(name)s>();
2301 GLuint temp = kNewClientId; 2311 GLuint temp = kNewClientId;
2302 SpecializedSetup<%(name)s, 0>(); 2312 SpecializedSetup<%(name)s, 0>();
2303 cmd.Init(1, &temp); 2313 cmd.Init(1, &temp);
2304 EXPECT_EQ(error::kNoError, 2314 EXPECT_EQ(error::kNoError,
2305 ExecuteImmediateCmd(cmd, sizeof(temp))); 2315 ExecuteImmediateCmd(cmd, sizeof(temp)));
2306 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 2316 EXPECT_EQ(GL_NO_ERROR, GetGLError());
2307 EXPECT_EQ(GetServiceId(kNewClientId), kNewServiceId); 2317 EXPECT_TRUE(Get%(resource_name)sInfo(kNewClientId) != NULL);
2308 } 2318 }
2309 """ 2319 """
2310 self.WriteValidUnitTest(func, file, valid_test) 2320 self.WriteValidUnitTest(func, file, valid_test, {
2321 'resource_name': func.original_name[3:-1],
2322 })
2311 invalid_test = """ 2323 invalid_test = """
2312 TEST_F(%(test_name)s, %(name)sInvalidArgs) { 2324 TEST_F(%(test_name)s, %(name)sInvalidArgs) {
2313 EXPECT_CALL(*gl_, %(gl_func_name)s(_, _)).Times(0); 2325 EXPECT_CALL(*gl_, %(gl_func_name)s(_, _)).Times(0);
2314 %(name)s& cmd = *GetImmediateAs<%(name)s>(); 2326 %(name)s& cmd = *GetImmediateAs<%(name)s>();
2315 SpecializedSetup<%(name)s, 0>(); 2327 SpecializedSetup<%(name)s, 0>();
2316 cmd.Init(1, &client_%(resource_name)s_id_); 2328 cmd.Init(1, &client_%(resource_name)s_id_);
2317 EXPECT_EQ(error::kInvalidArguments, 2329 EXPECT_EQ(error::kInvalidArguments,
2318 ExecuteImmediateCmd(cmd, sizeof(&client_%(resource_name)s_id_))); 2330 ExecuteImmediateCmd(cmd, sizeof(&client_%(resource_name)s_id_)));
2319 } 2331 }
2320 """ 2332 """
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
2433 """Overrriden from TypeHandler.""" 2445 """Overrriden from TypeHandler."""
2434 valid_test = """ 2446 valid_test = """
2435 TEST_F(%(test_name)s, %(name)sValidArgs) { 2447 TEST_F(%(test_name)s, %(name)sValidArgs) {
2436 EXPECT_CALL(*gl_, %(gl_func_name)s(%(gl_args)s)) 2448 EXPECT_CALL(*gl_, %(gl_func_name)s(%(gl_args)s))
2437 .WillOnce(Return(kNewServiceId)); 2449 .WillOnce(Return(kNewServiceId));
2438 SpecializedSetup<%(name)s, 0>(); 2450 SpecializedSetup<%(name)s, 0>();
2439 %(name)s cmd; 2451 %(name)s cmd;
2440 cmd.Init(%(args)s%(comma)skNewClientId); 2452 cmd.Init(%(args)s%(comma)skNewClientId);
2441 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 2453 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
2442 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 2454 EXPECT_EQ(GL_NO_ERROR, GetGLError());
2443 EXPECT_EQ(GetServiceId(kNewClientId), kNewServiceId); 2455 EXPECT_TRUE(Get%(resource_type)sInfo(kNewClientId) != NULL);
2444 } 2456 }
2445 """ 2457 """
2446 comma = "" 2458 comma = ""
2447 if len(func.GetOriginalArgs()): 2459 if len(func.GetOriginalArgs()):
2448 comma =", " 2460 comma =", "
2449 self.WriteValidUnitTest(func, file, valid_test, { 2461 self.WriteValidUnitTest(func, file, valid_test, {
2450 'comma': comma, 2462 'comma': comma,
2463 'resource_type': func.name[6:],
2451 }) 2464 })
2452 invalid_test = """ 2465 invalid_test = """
2453 TEST_F(%(test_name)s, %(name)sInvalidArgs%(arg_index)d_%(value_index)d) { 2466 TEST_F(%(test_name)s, %(name)sInvalidArgs%(arg_index)d_%(value_index)d) {
2454 EXPECT_CALL(*gl_, %(gl_func_name)s(%(gl_args)s)).Times(0); 2467 EXPECT_CALL(*gl_, %(gl_func_name)s(%(gl_args)s)).Times(0);
2455 SpecializedSetup<%(name)s, 0>(); 2468 SpecializedSetup<%(name)s, 0>();
2456 %(name)s cmd; 2469 %(name)s cmd;
2457 cmd.Init(%(args)s%(comma)skNewClientId); 2470 cmd.Init(%(args)s%(comma)skNewClientId);
2458 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));%(gl_error_test)s 2471 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));%(gl_error_test)s
2459 } 2472 }
2460 """ 2473 """
2461 self.WriteInvalidUnitTest(func, file, invalid_test, { 2474 self.WriteInvalidUnitTest(func, file, invalid_test, {
2462 'comma': comma, 2475 'comma': comma,
2463 }) 2476 })
2464 2477
2465 def WriteHandlerImplementation (self, func, file): 2478 def WriteHandlerImplementation (self, func, file):
2466 """Overrriden from TypeHandler.""" 2479 """Overrriden from TypeHandler."""
2467 file.Write(" uint32 client_id = c.client_id;\n") 2480 file.Write(" uint32 client_id = c.client_id;\n")
2468 file.Write(" %sHelper(%s);\n" % 2481 file.Write(" if (!%sHelper(%s)) {\n" %
2469 (func.name, func.MakeCmdArgString(""))) 2482 (func.name, func.MakeCmdArgString("")))
2483 file.Write(" return error::kInvalidArguments;\n")
2484 file.Write(" }\n")
2470 2485
2471 def WriteGLES2ImplementationHeader(self, func, file): 2486 def WriteGLES2ImplementationHeader(self, func, file):
2472 """Overrriden from TypeHandler.""" 2487 """Overrriden from TypeHandler."""
2473 file.Write("%s %s(%s) {\n" % 2488 file.Write("%s %s(%s) {\n" %
2474 (func.return_type, func.original_name, 2489 (func.return_type, func.original_name,
2475 func.MakeTypedOriginalArgString(""))) 2490 func.MakeTypedOriginalArgString("")))
2476 file.Write(" GLuint client_id;\n") 2491 file.Write(" GLuint client_id;\n")
2477 file.Write(" MakeIds(1, &client_id);\n") 2492 file.Write(" MakeIds(&program_and_shader_id_allocator_, 1, &client_id);\n")
2478 file.Write(" helper_->%s(%s);\n" % 2493 file.Write(" helper_->%s(%s);\n" %
2479 (func.name, func.MakeCmdArgString(""))) 2494 (func.name, func.MakeCmdArgString("")))
2480 file.Write(" return client_id;\n") 2495 file.Write(" return client_id;\n")
2481 file.Write("}\n") 2496 file.Write("}\n")
2482 file.Write("\n") 2497 file.Write("\n")
2483 2498
2484 2499
2485 class DELnHandler(TypeHandler): 2500 class DELnHandler(TypeHandler):
2486 """Handler for glDelete___ type functions.""" 2501 """Handler for glDelete___ type functions."""
2487 2502
(...skipping 16 matching lines...) Expand all
2504 EXPECT_CALL( 2519 EXPECT_CALL(
2505 *gl_, 2520 *gl_,
2506 %(gl_func_name)s(1, Pointee(kService%(upper_resource_name)sId))) 2521 %(gl_func_name)s(1, Pointee(kService%(upper_resource_name)sId)))
2507 .Times(1); 2522 .Times(1);
2508 GetSharedMemoryAs<GLuint*>()[0] = client_%(resource_name)s_id_; 2523 GetSharedMemoryAs<GLuint*>()[0] = client_%(resource_name)s_id_;
2509 SpecializedSetup<%(name)s, 0>(); 2524 SpecializedSetup<%(name)s, 0>();
2510 %(name)s cmd; 2525 %(name)s cmd;
2511 cmd.Init(%(args)s); 2526 cmd.Init(%(args)s);
2512 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 2527 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
2513 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 2528 EXPECT_EQ(GL_NO_ERROR, GetGLError());
2514 EXPECT_EQ(GetServiceId(kNewClientId), 0u); 2529 EXPECT_TRUE(
2530 Get%(upper_resource_name)sInfo(client_%(resource_name)s_id_) == NULL);
2515 } 2531 }
2516 """ 2532 """
2517 self.WriteValidUnitTest(func, file, valid_test, { 2533 self.WriteValidUnitTest(func, file, valid_test, {
2518 'resource_name': func.GetOriginalArgs()[1].name[0:-1], 2534 'resource_name': func.GetOriginalArgs()[1].name[0:-1],
2519 'upper_resource_name': 2535 'upper_resource_name':
2520 func.GetOriginalArgs()[1].name[0:-1].capitalize(), 2536 func.GetOriginalArgs()[1].name[0:-1].capitalize(),
2521 }) 2537 })
2522 invalid_test = """ 2538 invalid_test = """
2523 TEST_F(%(test_name)s, %(name)sInvalidArgs) { 2539 TEST_F(%(test_name)s, %(name)sInvalidArgs) {
2524 EXPECT_CALL(*gl_, %(gl_func_name)s(1, Pointee(0)))
2525 .Times(1);
2526 GetSharedMemoryAs<GLuint*>()[0] = kInvalidClientId; 2540 GetSharedMemoryAs<GLuint*>()[0] = kInvalidClientId;
2527 SpecializedSetup<%(name)s, 0>(); 2541 SpecializedSetup<%(name)s, 0>();
2528 %(name)s cmd; 2542 %(name)s cmd;
2529 cmd.Init(%(args)s); 2543 cmd.Init(%(args)s);
2530 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 2544 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
2531 } 2545 }
2532 """ 2546 """
2533 self.WriteValidUnitTest(func, file, invalid_test) 2547 self.WriteValidUnitTest(func, file, invalid_test)
2534 2548
2535 def WriteImmediateServiceUnitTest(self, func, file): 2549 def WriteImmediateServiceUnitTest(self, func, file):
2536 """Overrriden from TypeHandler.""" 2550 """Overrriden from TypeHandler."""
2537 valid_test = """ 2551 valid_test = """
2538 TEST_F(%(test_name)s, %(name)sValidArgs) { 2552 TEST_F(%(test_name)s, %(name)sValidArgs) {
2539 EXPECT_CALL( 2553 EXPECT_CALL(
2540 *gl_, 2554 *gl_,
2541 %(gl_func_name)s(1, Pointee(kService%(upper_resource_name)sId))) 2555 %(gl_func_name)s(1, Pointee(kService%(upper_resource_name)sId)))
2542 .Times(1); 2556 .Times(1);
2543 %(name)s& cmd = *GetImmediateAs<%(name)s>(); 2557 %(name)s& cmd = *GetImmediateAs<%(name)s>();
2544 SpecializedSetup<%(name)s, 0>(); 2558 SpecializedSetup<%(name)s, 0>();
2545 cmd.Init(1, &client_%(resource_name)s_id_); 2559 cmd.Init(1, &client_%(resource_name)s_id_);
2546 EXPECT_EQ(error::kNoError, 2560 EXPECT_EQ(error::kNoError,
2547 ExecuteImmediateCmd(cmd, sizeof(client_%(resource_name)s_id_))); 2561 ExecuteImmediateCmd(cmd, sizeof(client_%(resource_name)s_id_)));
2548 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 2562 EXPECT_EQ(GL_NO_ERROR, GetGLError());
2549 EXPECT_EQ(GetServiceId(kNewClientId), 0u); 2563 EXPECT_TRUE(
2564 Get%(upper_resource_name)sInfo(client_%(resource_name)s_id_) == NULL);
2550 } 2565 }
2551 """ 2566 """
2552 self.WriteValidUnitTest(func, file, valid_test, { 2567 self.WriteValidUnitTest(func, file, valid_test, {
2553 'resource_name': func.GetOriginalArgs()[1].name[0:-1], 2568 'resource_name': func.GetOriginalArgs()[1].name[0:-1],
2554 'upper_resource_name': 2569 'upper_resource_name':
2555 func.GetOriginalArgs()[1].name[0:-1].capitalize(), 2570 func.GetOriginalArgs()[1].name[0:-1].capitalize(),
2556 }) 2571 })
2557 invalid_test = """ 2572 invalid_test = """
2558 TEST_F(%(test_name)s, %(name)sInvalidArgs) { 2573 TEST_F(%(test_name)s, %(name)sInvalidArgs) {
2559 EXPECT_CALL(*gl_, %(gl_func_name)s(1, Pointee(0)))
2560 .Times(1);
2561 %(name)s& cmd = *GetImmediateAs<%(name)s>(); 2574 %(name)s& cmd = *GetImmediateAs<%(name)s>();
2562 SpecializedSetup<%(name)s, 0>(); 2575 SpecializedSetup<%(name)s, 0>();
2563 GLuint temp = kInvalidClientId; 2576 GLuint temp = kInvalidClientId;
2564 cmd.Init(1, &temp); 2577 cmd.Init(1, &temp);
2565 EXPECT_EQ(error::kNoError, 2578 EXPECT_EQ(error::kNoError,
2566 ExecuteImmediateCmd(cmd, sizeof(temp))); 2579 ExecuteImmediateCmd(cmd, sizeof(temp)));
2567 } 2580 }
2568 """ 2581 """
2569 self.WriteValidUnitTest(func, file, invalid_test) 2582 self.WriteValidUnitTest(func, file, invalid_test)
2570 2583
2571 def WriteHandlerImplementation (self, func, file): 2584 def WriteHandlerImplementation (self, func, file):
2572 """Overrriden from TypeHandler.""" 2585 """Overrriden from TypeHandler."""
2573 file.Write(" DeleteGLObjects<GL%sHelper>(n, %s);\n" % 2586 file.Write(" %sHelper(n, %s);\n" %
2574 (func.name, func.GetLastOriginalArg().name)) 2587 (func.name, func.GetLastOriginalArg().name))
2575 2588
2576 def WriteImmediateHandlerImplementation (self, func, file): 2589 def WriteImmediateHandlerImplementation (self, func, file):
2577 """Overrriden from TypeHandler.""" 2590 """Overrriden from TypeHandler."""
2578 file.Write(" DeleteGLObjects<GL%sHelper>(n, %s);\n" % 2591 file.Write(" %sHelper(n, %s);\n" %
2579 (func.original_name, func.GetLastOriginalArg().name)) 2592 (func.original_name, func.GetLastOriginalArg().name))
2580 2593
2581 def WriteGLES2ImplementationHeader(self, func, file): 2594 def WriteGLES2ImplementationHeader(self, func, file):
2582 """Overrriden from TypeHandler.""" 2595 """Overrriden from TypeHandler."""
2583 impl_decl = func.GetInfo('impl_decl') 2596 impl_decl = func.GetInfo('impl_decl')
2584 if impl_decl == None or impl_decl == True: 2597 if impl_decl == None or impl_decl == True:
2585 file.Write("%s %s(%s) {\n" % 2598 file.Write("%s %s(%s) {\n" %
2586 (func.return_type, func.original_name, 2599 (func.return_type, func.original_name,
2587 func.MakeTypedOriginalArgString(""))) 2600 func.MakeTypedOriginalArgString("")))
2588 file.Write(" FreeIds(%s);\n" % func.MakeOriginalArgString("")) 2601 file.Write(" FreeIds(&%s_id_allocator_, %s);\n" %
2602 (func.name[6:-1].lower(), func.MakeOriginalArgString("")))
2589 file.Write(" helper_->%sImmediate(%s);\n" % 2603 file.Write(" helper_->%sImmediate(%s);\n" %
2590 (func.name, func.MakeOriginalArgString(""))) 2604 (func.name, func.MakeOriginalArgString("")))
2591 file.Write("}\n") 2605 file.Write("}\n")
2592 file.Write("\n") 2606 file.Write("\n")
2593 2607
2594 def WriteImmediateCmdComputeSize(self, func, file): 2608 def WriteImmediateCmdComputeSize(self, func, file):
2595 """Overrriden from TypeHandler.""" 2609 """Overrriden from TypeHandler."""
2596 file.Write(" static uint32 ComputeDataSize(GLsizei n) {\n") 2610 file.Write(" static uint32 ComputeDataSize(GLsizei n) {\n")
2597 file.Write( 2611 file.Write(
2598 " return static_cast<uint32>(sizeof(GLuint) * n); // NOLINT\n") 2612 " return static_cast<uint32>(sizeof(GLuint) * n); // NOLINT\n")
(...skipping 898 matching lines...) Expand 10 before | Expand all | Expand 10 after
3497 %(name)s cmd; 3511 %(name)s cmd;
3498 cmd.Init(kInvalidClientId, kBucketId); 3512 cmd.Init(kInvalidClientId, kBucketId);
3499 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 3513 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
3500 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); 3514 EXPECT_EQ(GL_INVALID_VALUE, GetGLError());
3501 } 3515 }
3502 """ 3516 """
3503 self.WriteValidUnitTest(func, file, invalid_test) 3517 self.WriteValidUnitTest(func, file, invalid_test)
3504 3518
3505 def WriteServiceImplementation(self, func, file): 3519 def WriteServiceImplementation(self, func, file):
3506 """Overrriden from TypeHandler.""" 3520 """Overrriden from TypeHandler."""
3507 file.Write( 3521 pass
3508 "error::Error GLES2DecoderImpl::Handle%s(\n" % func.name)
3509 file.Write(
3510 " uint32 immediate_data_size, const gles2::%s& c) {\n" % func.name)
3511 args = func.GetCmdArgs()
3512 id_arg = args[0]
3513 bucket_arg = args[1]
3514 id_arg.WriteGetCode(file)
3515 bucket_arg.WriteGetCode(file)
3516 id_arg.WriteValidationCode(file)
3517 file.Write(" GLint len = 0;\n")
3518 file.Write(" %s(%s, %s, &len);\n" % (
3519 func.GetInfo('get_len_func'), id_arg.name,
3520 func.GetInfo('get_len_enum')))
3521 file.Write(" Bucket* bucket = CreateBucket(%s);\n" % bucket_arg.name)
3522 file.Write(" bucket->SetSize(len + 1);\n");
3523 file.Write(
3524 " %s(%s, len + 1, &len, bucket->GetDataAs<GLchar*>(0, len + 1));\n" %
3525 (func.GetGLFunctionName(), id_arg.name))
3526 file.Write(" return error::kNoError;\n")
3527 file.Write("}\n")
3528 file.Write("\n")
3529 3522
3530 3523
3531 class FunctionInfo(object): 3524 class FunctionInfo(object):
3532 """Holds info about a function.""" 3525 """Holds info about a function."""
3533 3526
3534 def __init__(self, info, type_handler): 3527 def __init__(self, info, type_handler):
3535 for key in info: 3528 for key in info:
3536 setattr(self, key, info[key]) 3529 setattr(self, key, info[key])
3537 self.type_handler = type_handler 3530 self.type_handler = type_handler
3538 if not 'type' in info: 3531 if not 'type' in info:
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
3878 """A class that represents a resource id argument to a function.""" 3871 """A class that represents a resource id argument to a function."""
3879 3872
3880 def __init__(self, name, type): 3873 def __init__(self, name, type):
3881 match = re.match("(GLid\w+)", type) 3874 match = re.match("(GLid\w+)", type)
3882 self.resource_type = match.group(1)[4:] 3875 self.resource_type = match.group(1)[4:]
3883 type = type.replace(match.group(1), "GLuint") 3876 type = type.replace(match.group(1), "GLuint")
3884 Argument.__init__(self, name, type) 3877 Argument.__init__(self, name, type)
3885 3878
3886 def WriteGetCode(self, file): 3879 def WriteGetCode(self, file):
3887 """Overridden from Argument.""" 3880 """Overridden from Argument."""
3888 file.Write(" %s %s;\n" % (self.type, self.name)) 3881 file.Write(" %s %s = c.%s;\n" % (self.type, self.name, self.name))
3889 file.Write(" if (!id_manager()->GetServiceId(c.%s, &%s)) {\n" %
3890 (self.name, self.name))
3891 file.Write(" SetGLError(GL_INVALID_VALUE);\n")
3892 file.Write(" return error::kNoError;\n")
3893 file.Write(" }\n")
3894 3882
3895 def GetValidArg(self, offset, index): 3883 def GetValidArg(self, offset, index):
3896 return "client_%s_id_" % self.resource_type.lower() 3884 return "client_%s_id_" % self.resource_type.lower()
3897 3885
3898 def GetValidGLArg(self, offset, index): 3886 def GetValidGLArg(self, offset, index):
3899 return "kService%sId" % self.resource_type 3887 return "kService%sId" % self.resource_type
3900 3888
3901 3889
3902 class ResourceIdBindArgument(Argument): 3890 class ResourceIdBindArgument(Argument):
3903 """Represents a resource id argument to a bind function.""" 3891 """Represents a resource id argument to a bind function."""
3904 3892
3905 def __init__(self, name, type): 3893 def __init__(self, name, type):
3906 match = re.match("(GLidBind\w+)", type) 3894 match = re.match("(GLidBind\w+)", type)
3907 self.resource_type = match.group(1)[8:] 3895 self.resource_type = match.group(1)[8:]
3908 type = type.replace(match.group(1), "GLuint") 3896 type = type.replace(match.group(1), "GLuint")
3909 Argument.__init__(self, name, type) 3897 Argument.__init__(self, name, type)
3910 3898
3911 def WriteGetCode(self, file): 3899 def WriteGetCode(self, file):
3912 """Overridden from Argument.""" 3900 """Overridden from Argument."""
3913 code = """ %(type)s %(name)s = c.%(name)s; 3901 code = """ %(type)s %(name)s = c.%(name)s;
3914 """ 3902 """
3915 file.Write(code % {'type': self.type, 'name': self.name}) 3903 file.Write(code % {'type': self.type, 'name': self.name})
3916 3904
3917 def GetValidArg(self, offset, index): 3905 def GetValidArg(self, offset, index):
3918 return "client_%s_id_" % self.resource_type.lower() 3906 return "client_%s_id_" % self.resource_type.lower()
3919 3907
3920 def GetValidGLArg(self, offset, index): 3908 def GetValidGLArg(self, offset, index):
3921 return "kService%sId" % self.resource_type 3909 return "kService%sId" % self.resource_type
3922 3910
3923 def GetNumInvalidValues(self, func):
3924 """returns the number of invalid values to be tested."""
3925 return 1
3926
3927 def GetInvalidArg(self, offset, index):
3928 """returns an invalid value by index."""
3929 if self.resource_type == "Texture":
3930 return ("client_buffer_id_", "kNoError", "GL_INVALID_OPERATION")
3931 return ("client_texture_id_", "kNoError", "GL_INVALID_OPERATION")
3932
3933 3911
3934 class ResourceIdZeroArgument(Argument): 3912 class ResourceIdZeroArgument(Argument):
3935 """Represents a resource id argument to a function that can be zero.""" 3913 """Represents a resource id argument to a function that can be zero."""
3936 3914
3937 def __init__(self, name, type): 3915 def __init__(self, name, type):
3938 match = re.match("(GLidZero\w+)", type) 3916 match = re.match("(GLidZero\w+)", type)
3939 self.resource_type = match.group(1)[8:] 3917 self.resource_type = match.group(1)[8:]
3940 type = type.replace(match.group(1), "GLuint") 3918 type = type.replace(match.group(1), "GLuint")
3941 Argument.__init__(self, name, type) 3919 Argument.__init__(self, name, type)
3942 3920
3943 def WriteGetCode(self, file): 3921 def WriteGetCode(self, file):
3944 """Overridden from Argument.""" 3922 """Overridden from Argument."""
3945 file.Write(" %s %s = c.%s;\n" % (self.type, self.name, self.name)) 3923 file.Write(" %s %s = c.%s;\n" % (self.type, self.name, self.name))
3946 file.Write(" if (%s != 0 && !id_manager()->GetServiceId(%s, &%s)) {\n" %
3947 (self.name, self.name, self.name))
3948 file.Write(" SetGLError(GL_INVALID_VALUE);\n")
3949 file.Write(" return error::kNoError;\n")
3950 file.Write(" }\n")
3951 3924
3952 def GetValidArg(self, offset, index): 3925 def GetValidArg(self, offset, index):
3953 return "client_%s_id_" % self.resource_type.lower() 3926 return "client_%s_id_" % self.resource_type.lower()
3954 3927
3955 def GetValidGLArg(self, offset, index): 3928 def GetValidGLArg(self, offset, index):
3956 return "kService%sId" % self.resource_type 3929 return "kService%sId" % self.resource_type
3957 3930
3958 def GetNumInvalidValues(self, func): 3931 def GetNumInvalidValues(self, func):
3959 """returns the number of invalid values to be tested.""" 3932 """returns the number of invalid values to be tested."""
3960 return 1 3933 return 1
3961 3934
3962 def GetInvalidArg(self, offset, index): 3935 def GetInvalidArg(self, offset, index):
3963 """returns an invalid value by index.""" 3936 """returns an invalid value by index."""
3964 if self.resource_type == "Texture": 3937 return ("kInvalidClientId", "kNoError", "GL_INVALID_VALUE")
3965 return ("client_buffer_id_", "kNoError", "GL_INVALID_OPERATION")
3966 return ("client_texture_id_", "kNoError", "GL_INVALID_OPERATION")
3967 3938
3968 3939
3969 class Function(object): 3940 class Function(object):
3970 """A class that represents a function.""" 3941 """A class that represents a function."""
3971 3942
3972 def __init__(self, original_name, name, info, return_type, original_args, 3943 def __init__(self, original_name, name, info, return_type, original_args,
3973 args_for_cmds, cmd_args, init_args, num_pointer_args): 3944 args_for_cmds, cmd_args, init_args, num_pointer_args):
3974 self.name = name 3945 self.name = name
3975 self.original_name = original_name 3946 self.original_name = original_name
3976 self.info = info 3947 self.info = info
(...skipping 732 matching lines...) Expand 10 before | Expand all | Expand 10 after
4709 4680
4710 if options.generate_docs: 4681 if options.generate_docs:
4711 gen.WriteDocs("docs/gles2_cmd_format_docs_autogen.h") 4682 gen.WriteDocs("docs/gles2_cmd_format_docs_autogen.h")
4712 4683
4713 if gen.errors > 0: 4684 if gen.errors > 0:
4714 print "%d errors" % gen.errors 4685 print "%d errors" % gen.errors
4715 sys.exit(1) 4686 sys.exit(1)
4716 4687
4717 if __name__ == '__main__': 4688 if __name__ == '__main__':
4718 main(sys.argv[1:]) 4689 main(sys.argv[1:])
OLDNEW
« no previous file with comments | « chrome/renderer/ggl/ggl.cc ('k') | gpu/command_buffer/client/gles2_implementation.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698