diff options
author | gman@chromium.org <gman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-01-05 00:21:24 +0000 |
---|---|---|
committer | gman@chromium.org <gman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-01-05 00:21:24 +0000 |
commit | 8a837bb40249dfd9f0a2736abdab4f64592c99db (patch) | |
tree | cf8b56d3cd87bdcfe99de1b08a8479543b9e6f68 /gpu | |
parent | 4d9ce39dd68140342a275d685b9136ac92a3e475 (diff) | |
download | chromium_src-8a837bb40249dfd9f0a2736abdab4f64592c99db.zip chromium_src-8a837bb40249dfd9f0a2736abdab4f64592c99db.tar.gz chromium_src-8a837bb40249dfd9f0a2736abdab4f64592c99db.tar.bz2 |
A bunch of unit tests for GLES2
TEST=none
BUG=none
Review URL: http://codereview.chromium.org/521018
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@35495 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gpu')
18 files changed, 4527 insertions, 889 deletions
diff --git a/gpu/command_buffer/build_gles2_cmd_buffer.py b/gpu/command_buffer/build_gles2_cmd_buffer.py index b9bc4ec..0c7ff36 100755 --- a/gpu/command_buffer/build_gles2_cmd_buffer.py +++ b/gpu/command_buffer/build_gles2_cmd_buffer.py @@ -16,8 +16,7 @@ _SIZE_OF_UINT32 = 4 _SIZE_OF_COMMAND_HEADER = 4 _FIRST_SPECIFIC_COMMAND_ID = 256 -_LICENSE = """ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +_LICENSE = """// Copyright (c) 2009 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -27,19 +26,19 @@ _LICENSE = """ # # Edits: # -# *) Any argument that is a resourceID has been changed to GLresourceID. +# *) Any argument that is a resourceID has been changed to GLid<Type>. # (not pointer arguments) # # *) All GLenums have been changed to GLenumTypeOfEnum # _GL_FUNCTIONS = """ GL_APICALL void GL_APIENTRY glActiveTexture (GLenum texture); -GL_APICALL void GL_APIENTRY glAttachShader (GLResourceId program, GLResourceId shader); -GL_APICALL void GL_APIENTRY glBindAttribLocation (GLResourceId program, GLuint index, const char* name); -GL_APICALL void GL_APIENTRY glBindBuffer (GLenumBufferTarget target, GLResourceId buffer); -GL_APICALL void GL_APIENTRY glBindFramebuffer (GLenumFrameBufferTarget target, GLResourceId framebuffer); -GL_APICALL void GL_APIENTRY glBindRenderbuffer (GLenumRenderBufferTarget target, GLResourceId renderbuffer); -GL_APICALL void GL_APIENTRY glBindTexture (GLenumTextureBindTarget target, GLResourceId texture); +GL_APICALL void GL_APIENTRY glAttachShader (GLidProgram program, GLidShader shader); +GL_APICALL void GL_APIENTRY glBindAttribLocation (GLidProgram program, GLuint index, const char* name); +GL_APICALL void GL_APIENTRY glBindBuffer (GLenumBufferTarget target, GLidBuffer buffer); +GL_APICALL void GL_APIENTRY glBindFramebuffer (GLenumFrameBufferTarget target, GLidFramebuffer framebuffer); +GL_APICALL void GL_APIENTRY glBindRenderbuffer (GLenumRenderBufferTarget target, GLidRenderbuffer renderbuffer); +GL_APICALL void GL_APIENTRY glBindTexture (GLenumTextureBindTarget target, GLidTexture texture); GL_APICALL void GL_APIENTRY glBlendColor (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); GL_APICALL void GL_APIENTRY glBlendEquation ( GLenumEquation mode ); GL_APICALL void GL_APIENTRY glBlendEquationSeparate (GLenumEquation modeRGB, GLenumEquation modeAlpha); @@ -53,7 +52,7 @@ GL_APICALL void GL_APIENTRY glClearColor (GLclampf red, GLclampf green, GL_APICALL void GL_APIENTRY glClearDepthf (GLclampf depth); GL_APICALL void GL_APIENTRY glClearStencil (GLint s); GL_APICALL void GL_APIENTRY glColorMask (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); -GL_APICALL void GL_APIENTRY glCompileShader (GLResourceId shader); +GL_APICALL void GL_APIENTRY glCompileShader (GLidShader shader); GL_APICALL void GL_APIENTRY glCompressedTexImage2D (GLenumTextureTarget target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void* data); GL_APICALL void GL_APIENTRY glCompressedTexSubImage2D (GLenumTextureTarget target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void* data); GL_APICALL void GL_APIENTRY glCopyTexImage2D (GLenumTextureTarget target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); @@ -63,14 +62,14 @@ GL_APICALL GLuint GL_APIENTRY glCreateShader (GLenumShaderType type); GL_APICALL void GL_APIENTRY glCullFace (GLenumFaceType mode); GL_APICALL void GL_APIENTRY glDeleteBuffers (GLsizei n, const GLuint* buffers); GL_APICALL void GL_APIENTRY glDeleteFramebuffers (GLsizei n, const GLuint* framebuffers); -GL_APICALL void GL_APIENTRY glDeleteProgram (GLResourceId program); +GL_APICALL void GL_APIENTRY glDeleteProgram (GLidProgram program); GL_APICALL void GL_APIENTRY glDeleteRenderbuffers (GLsizei n, const GLuint* renderbuffers); -GL_APICALL void GL_APIENTRY glDeleteShader (GLResourceId shader); +GL_APICALL void GL_APIENTRY glDeleteShader (GLidShader shader); GL_APICALL void GL_APIENTRY glDeleteTextures (GLsizei n, const GLuint* textures); GL_APICALL void GL_APIENTRY glDepthFunc (GLenumCmpFunction func); GL_APICALL void GL_APIENTRY glDepthMask (GLboolean flag); GL_APICALL void GL_APIENTRY glDepthRangef (GLclampf zNear, GLclampf zFar); -GL_APICALL void GL_APIENTRY glDetachShader (GLResourceId program, GLResourceId shader); +GL_APICALL void GL_APIENTRY glDetachShader (GLidProgram program, GLidShader shader); GL_APICALL void GL_APIENTRY glDisable (GLenumCapability cap); GL_APICALL void GL_APIENTRY glDisableVertexAttribArray (GLuint index); GL_APICALL void GL_APIENTRY glDrawArrays (GLenumDrawMode mode, GLint first, GLsizei count); @@ -79,50 +78,50 @@ GL_APICALL void GL_APIENTRY glEnable (GLenumCapability cap); GL_APICALL void GL_APIENTRY glEnableVertexAttribArray (GLuint index); GL_APICALL void GL_APIENTRY glFinish (void); GL_APICALL void GL_APIENTRY glFlush (void); -GL_APICALL void GL_APIENTRY glFramebufferRenderbuffer (GLenumFrameBufferTarget target, GLenumAttachment attachment, GLenumRenderBufferTarget renderbuffertarget, GLResourceId renderbuffer); -GL_APICALL void GL_APIENTRY glFramebufferTexture2D (GLenumFrameBufferTarget target, GLenumAttachment attachment, GLenumTextureTarget textarget, GLResourceId texture, GLint level); +GL_APICALL void GL_APIENTRY glFramebufferRenderbuffer (GLenumFrameBufferTarget target, GLenumAttachment attachment, GLenumRenderBufferTarget renderbuffertarget, GLidRenderbuffer renderbuffer); +GL_APICALL void GL_APIENTRY glFramebufferTexture2D (GLenumFrameBufferTarget target, GLenumAttachment attachment, GLenumTextureTarget textarget, GLidTexture texture, GLint level); GL_APICALL void GL_APIENTRY glFrontFace (GLenumFaceMode mode); GL_APICALL void GL_APIENTRY glGenBuffers (GLsizei n, GLuint* buffers); GL_APICALL void GL_APIENTRY glGenerateMipmap (GLenumTextureBindTarget target); GL_APICALL void GL_APIENTRY glGenFramebuffers (GLsizei n, GLuint* framebuffers); GL_APICALL void GL_APIENTRY glGenRenderbuffers (GLsizei n, GLuint* renderbuffers); GL_APICALL void GL_APIENTRY glGenTextures (GLsizei n, GLuint* textures); -GL_APICALL void GL_APIENTRY glGetActiveAttrib (GLResourceId program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name); -GL_APICALL void GL_APIENTRY glGetActiveUniform (GLResourceId program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name); -GL_APICALL void GL_APIENTRY glGetAttachedShaders (GLResourceId program, GLsizei maxcount, GLsizei* count, GLuint* shaders); -GL_APICALL GLint GL_APIENTRY glGetAttribLocation (GLResourceId program, const char* name); +GL_APICALL void GL_APIENTRY glGetActiveAttrib (GLidProgram program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name); +GL_APICALL void GL_APIENTRY glGetActiveUniform (GLidProgram program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name); +GL_APICALL void GL_APIENTRY glGetAttachedShaders (GLidProgram program, GLsizei maxcount, GLsizei* count, GLuint* shaders); +GL_APICALL GLint GL_APIENTRY glGetAttribLocation (GLidProgram program, const char* name); GL_APICALL void GL_APIENTRY glGetBooleanv (GLenum pname, GLboolean* params); GL_APICALL void GL_APIENTRY glGetBufferParameteriv (GLenumBufferTarget target, GLenumBufferParameter pname, GLint* params); GL_APICALL GLenum GL_APIENTRY glGetError (void); GL_APICALL void GL_APIENTRY glGetFloatv (GLenum pname, GLfloat* params); GL_APICALL void GL_APIENTRY glGetFramebufferAttachmentParameteriv (GLenumFrameBufferTarget target, GLenumAttachment attachment, GLenumFrameBufferParameter pname, GLint* params); GL_APICALL void GL_APIENTRY glGetIntegerv (GLenum pname, GLint* params); -GL_APICALL void GL_APIENTRY glGetProgramiv (GLResourceId program, GLenumProgramParameter pname, GLint* params); -GL_APICALL void GL_APIENTRY glGetProgramInfoLog (GLResourceId program, GLsizei bufsize, GLsizei* length, char* infolog); +GL_APICALL void GL_APIENTRY glGetProgramiv (GLidProgram program, GLenumProgramParameter pname, GLint* params); +GL_APICALL void GL_APIENTRY glGetProgramInfoLog (GLidProgram program, GLsizei bufsize, GLsizei* length, char* infolog); GL_APICALL void GL_APIENTRY glGetRenderbufferParameteriv (GLenumRenderBufferTarget target, GLenumRenderBufferParameter pname, GLint* params); -GL_APICALL void GL_APIENTRY glGetShaderiv (GLResourceId shader, GLenumShaderParameter pname, GLint* params); -GL_APICALL void GL_APIENTRY glGetShaderInfoLog (GLResourceId shader, GLsizei bufsize, GLsizei* length, char* infolog); +GL_APICALL void GL_APIENTRY glGetShaderiv (GLidShader shader, GLenumShaderParameter pname, GLint* params); +GL_APICALL void GL_APIENTRY glGetShaderInfoLog (GLidShader shader, GLsizei bufsize, GLsizei* length, char* infolog); GL_APICALL void GL_APIENTRY glGetShaderPrecisionFormat (GLenumShaderType shadertype, GLenumShaderPercision precisiontype, GLint* range, GLint* precision); -GL_APICALL void GL_APIENTRY glGetShaderSource (GLResourceId shader, GLsizei bufsize, GLsizei* length, char* source); +GL_APICALL void GL_APIENTRY glGetShaderSource (GLidShader shader, GLsizei bufsize, GLsizei* length, char* source); GL_APICALL const GLubyte* GL_APIENTRY glGetString (GLenumStringType name); GL_APICALL void GL_APIENTRY glGetTexParameterfv (GLenumTextureTarget target, GLenumTextureParameter pname, GLfloat* params); GL_APICALL void GL_APIENTRY glGetTexParameteriv (GLenumTextureTarget target, GLenumTextureParameter pname, GLint* params); -GL_APICALL void GL_APIENTRY glGetUniformfv (GLResourceId program, GLint location, GLfloat* params); -GL_APICALL void GL_APIENTRY glGetUniformiv (GLResourceId program, GLint location, GLint* params); -GL_APICALL GLint GL_APIENTRY glGetUniformLocation (GLResourceId program, const char* name); +GL_APICALL void GL_APIENTRY glGetUniformfv (GLidProgram program, GLint location, GLfloat* params); +GL_APICALL void GL_APIENTRY glGetUniformiv (GLidProgram program, GLint location, GLint* params); +GL_APICALL GLint GL_APIENTRY glGetUniformLocation (GLidProgram program, const char* name); GL_APICALL void GL_APIENTRY glGetVertexAttribfv (GLuint index, GLenumVertexAttribute pname, GLfloat* params); GL_APICALL void GL_APIENTRY glGetVertexAttribiv (GLuint index, GLenumVertexAttribute pname, GLint* params); GL_APICALL void GL_APIENTRY glGetVertexAttribPointerv (GLuint index, GLenumVertexPointer pname, void** pointer); GL_APICALL void GL_APIENTRY glHint (GLenumHintTarget target, GLenumHintMode mode); -GL_APICALL GLboolean GL_APIENTRY glIsBuffer (GLResourceId buffer); +GL_APICALL GLboolean GL_APIENTRY glIsBuffer (GLidBuffer buffer); GL_APICALL GLboolean GL_APIENTRY glIsEnabled (GLenumCapability cap); -GL_APICALL GLboolean GL_APIENTRY glIsFramebuffer (GLResourceId framebuffer); -GL_APICALL GLboolean GL_APIENTRY glIsProgram (GLResourceId program); -GL_APICALL GLboolean GL_APIENTRY glIsRenderbuffer (GLResourceId renderbuffer); -GL_APICALL GLboolean GL_APIENTRY glIsShader (GLResourceId shader); -GL_APICALL GLboolean GL_APIENTRY glIsTexture (GLResourceId texture); +GL_APICALL GLboolean GL_APIENTRY glIsFramebuffer (GLidFramebuffer framebuffer); +GL_APICALL GLboolean GL_APIENTRY glIsProgram (GLidProgram program); +GL_APICALL GLboolean GL_APIENTRY glIsRenderbuffer (GLidRenderbuffer renderbuffer); +GL_APICALL GLboolean GL_APIENTRY glIsShader (GLidShader shader); +GL_APICALL GLboolean GL_APIENTRY glIsTexture (GLidTexture texture); GL_APICALL void GL_APIENTRY glLineWidth (GLfloat width); -GL_APICALL void GL_APIENTRY glLinkProgram (GLResourceId program); +GL_APICALL void GL_APIENTRY glLinkProgram (GLidProgram program); GL_APICALL void GL_APIENTRY glPixelStorei (GLenumPixelStore pname, GLintPixelStoreAlignment param); GL_APICALL void GL_APIENTRY glPolygonOffset (GLfloat factor, GLfloat units); GL_APICALL void GL_APIENTRY glReadPixels (GLint x, GLint y, GLsizei width, GLsizei height, GLenumReadPixelFormat format, GLenumPixelType type, void* pixels); @@ -130,8 +129,8 @@ GL_APICALL void GL_APIENTRY glReleaseShaderCompiler (void); GL_APICALL void GL_APIENTRY glRenderbufferStorage (GLenumRenderBufferTarget target, GLenumRenderBufferFormat internalformat, GLsizei width, GLsizei height); GL_APICALL void GL_APIENTRY glSampleCoverage (GLclampf value, GLboolean invert); GL_APICALL void GL_APIENTRY glScissor (GLint x, GLint y, GLsizei width, GLsizei height); -GL_APICALL void GL_APIENTRY glShaderBinary (GLsizei n, const GLResourceId* shaders, GLenum binaryformat, const void* binary, GLsizei length); -GL_APICALL void GL_APIENTRY glShaderSource (GLResourceId shader, GLsizei count, const char** string, const GLint* length); +GL_APICALL void GL_APIENTRY glShaderBinary (GLsizei n, const GLidShader* shaders, GLenum binaryformat, const void* binary, GLsizei length); +GL_APICALL void GL_APIENTRY glShaderSource (GLidShader shader, GLsizei count, const char** str, const GLint* length); GL_APICALL void GL_APIENTRY glStencilFunc (GLenumCmpFunction func, GLint ref, GLuint mask); GL_APICALL void GL_APIENTRY glStencilFuncSeparate (GLenumFaceType face, GLenumCmpFunction func, GLint ref, GLuint mask); GL_APICALL void GL_APIENTRY glStencilMask (GLuint mask); @@ -160,11 +159,11 @@ GL_APICALL void GL_APIENTRY glUniform4f (GLint location, GLfloat x, GLfl GL_APICALL void GL_APIENTRY glUniform4fv (GLint location, GLsizei count, const GLfloat* v); GL_APICALL void GL_APIENTRY glUniform4i (GLint location, GLint x, GLint y, GLint z, GLint w); GL_APICALL void GL_APIENTRY glUniform4iv (GLint location, GLsizei count, const GLint* v); -GL_APICALL void GL_APIENTRY glUniformMatrix2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); -GL_APICALL void GL_APIENTRY glUniformMatrix3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); -GL_APICALL void GL_APIENTRY glUniformMatrix4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); -GL_APICALL void GL_APIENTRY glUseProgram (GLResourceId program); -GL_APICALL void GL_APIENTRY glValidateProgram (GLResourceId program); +GL_APICALL void GL_APIENTRY glUniformMatrix2fv (GLint location, GLsizei count, GLbooleanFalse transpose, const GLfloat* value); +GL_APICALL void GL_APIENTRY glUniformMatrix3fv (GLint location, GLsizei count, GLbooleanFalse transpose, const GLfloat* value); +GL_APICALL void GL_APIENTRY glUniformMatrix4fv (GLint location, GLsizei count, GLbooleanFalse transpose, const GLfloat* value); +GL_APICALL void GL_APIENTRY glUseProgram (GLidProgram program); +GL_APICALL void GL_APIENTRY glValidateProgram (GLidProgram program); GL_APICALL void GL_APIENTRY glVertexAttrib1f (GLuint indx, GLfloat x); GL_APICALL void GL_APIENTRY glVertexAttrib1fv (GLuint indx, const GLfloat* values); GL_APICALL void GL_APIENTRY glVertexAttrib2f (GLuint indx, GLfloat x, GLfloat y); @@ -366,263 +365,447 @@ _CMD_ID_TABLE = { # This is a list of enum names and their valid values. It is used to map # GLenum arguments to a specific set of valid values. _ENUM_LISTS = { - 'FrameBufferTarget': [ - 'GL_FRAMEBUFFER', - ], - 'RenderBufferTarget': [ - 'GL_RENDERBUFFER', - ], - 'BufferTarget': [ - 'GL_ARRAY_BUFFER', - 'GL_ELEMENT_ARRAY_BUFFER', - ], - 'BufferUsage': [ - 'GL_STREAM_DRAW', - 'GL_STATIC_DRAW', - 'GL_DYNAMIC_DRAW', - ], - 'TextureTarget': [ - 'GL_TEXTURE_2D', - 'GL_TEXTURE_CUBE_MAP_POSITIVE_X', - 'GL_TEXTURE_CUBE_MAP_NEGATIVE_X', - 'GL_TEXTURE_CUBE_MAP_POSITIVE_Y', - 'GL_TEXTURE_CUBE_MAP_NEGATIVE_Y', - 'GL_TEXTURE_CUBE_MAP_POSITIVE_Z', - 'GL_TEXTURE_CUBE_MAP_NEGATIVE_Z', - ], - 'TextureBindTarget': [ - 'GL_TEXTURE_2D', - 'GL_TEXTURE_CUBE_MAP', - ], - 'ShaderType': [ - 'GL_VERTEX_SHADER', - 'GL_FRAGMENT_SHADER', - ], - 'FaceType': [ - 'GL_FRONT', - 'GL_BACK', - 'GL_FRONT_AND_BACK', - ], - 'FaceMode': [ - 'GL_CW', - 'GL_CCW', - ], - 'CmpFunction': [ - 'GL_NEVER', - 'GL_LESS', - 'GL_EQUAL', - 'GL_LEQUAL', - 'GL_GREATER', - 'GL_NOTEQUAL', - 'GL_GEQUAL', - 'GL_ALWAYS', - ], - 'Equation': [ - 'GL_FUNC_ADD', - 'GL_FUNC_SUBTRACT', - 'GL_FUNC_REVERSE_SUBTRACT', - ], - 'SrcBlendFactor': [ - 'GL_ZERO', - 'GL_ONE', - 'GL_SRC_COLOR', - 'GL_ONE_MINUS_SRC_COLOR', - 'GL_DST_COLOR', - 'GL_ONE_MINUS_DST_COLOR', - 'GL_SRC_ALPHA', - 'GL_ONE_MINUS_SRC_ALPHA', - 'GL_DST_ALPHA', - 'GL_ONE_MINUS_DST_ALPHA', - 'GL_CONSTANT_COLOR', - 'GL_ONE_MINUS_CONSTANT_COLOR', - 'GL_CONSTANT_ALPHA', - 'GL_ONE_MINUS_CONSTANT_ALPHA', - 'GL_SRC_ALPHA_SATURATE', - ], - 'DstBlendFactor': [ - 'GL_ZERO', - 'GL_ONE', - 'GL_SRC_COLOR', - 'GL_ONE_MINUS_SRC_COLOR', - 'GL_DST_COLOR', - 'GL_ONE_MINUS_DST_COLOR', - 'GL_SRC_ALPHA', - 'GL_ONE_MINUS_SRC_ALPHA', - 'GL_DST_ALPHA', - 'GL_ONE_MINUS_DST_ALPHA', - 'GL_CONSTANT_COLOR', - 'GL_ONE_MINUS_CONSTANT_COLOR', - 'GL_CONSTANT_ALPHA', - 'GL_ONE_MINUS_CONSTANT_ALPHA', - ], - 'Capability': [ - 'GL_BLEND', - 'GL_CULL_FACE', - 'GL_DEPTH_TEST', - 'GL_DITHER', - 'GL_POLYGON_OFFSET_FILL', - 'GL_SAMPLE_ALPHA_TO_COVERAGE', - 'GL_SAMPLE_COVERAGE', - 'GL_SCISSOR_TEST', - 'GL_STENCIL_TEST', - ], - 'DrawMode': [ - 'GL_POINTS', - 'GL_LINE_STRIP', - 'GL_LINE_LOOP', - 'GL_LINES', - 'GL_TRIANGLE_STRIP', - 'GL_TRIANGLE_FAN', - 'GL_TRIANGLES', - ], - 'IndexType': [ - 'GL_UNSIGNED_BYTE', - 'GL_UNSIGNED_SHORT', - ], - 'Attachment': [ - 'GL_COLOR_ATTACHMENT0', - 'GL_DEPTH_ATTACHMENT', - 'GL_STENCIL_ATTACHMENT', - ], - 'BufferParameter': [ - 'GL_BUFFER_SIZE', - 'GL_BUFFER_USAGE', - ], - 'FrameBufferParameter': [ - 'GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE', - 'GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME', - 'GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL', - 'GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE', - ], - 'ProgramParameter': [ - 'GL_DELETE_STATUS', - 'GL_LINK_STATUS', - 'GL_VALIDATE_STATUS', - 'GL_INFO_LOG_LENGTH', - 'GL_ATTACHED_SHADERS', - 'GL_ACTIVE_ATTRIBUTES', - 'GL_ACTIVE_ATTRIBUTE_MAX_LENGTH', - 'GL_ACTIVE_UNIFORMS', - 'GL_ACTIVE_UNIFORM_MAX_LENGTH', - ], - 'RenderBufferParameter': [ - 'GL_RENDERBUFFER_WIDTH', - 'GL_RENDERBUFFER_HEIGHT', - 'GL_RENDERBUFFER_INTERNAL_FORMAT', - 'GL_RENDERBUFFER_RED_SIZE', - 'GL_RENDERBUFFER_GREEN_SIZE', - 'GL_RENDERBUFFER_BLUE_SIZE', - 'GL_RENDERBUFFER_ALPHA_SIZE', - 'GL_RENDERBUFFER_DEPTH_SIZE', - 'GL_RENDERBUFFER_STENCIL_SIZE', - ], - 'ShaderParameter': [ - 'GL_SHADER_TYPE', - 'GL_DELETE_STATUS', - 'GL_COMPILE_STATUS', - 'GL_INFO_LOG_LENGTH', - 'GL_SHADER_SOURCE_LENGTH', - ], - 'ShaderPercision': [ - 'GL_LOW_FLOAT', - 'GL_MEDIUM_FLOAT', - 'GL_HIGH_FLOAT', - 'GL_LOW_INT', - 'GL_MEDIUM_INT', - 'GL_HIGH_INT', - ], - 'StringType': [ - 'GL_VENDOR', - 'GL_RENDERER', - 'GL_VERSION', - 'GL_SHADING_LANGUAGE_VERSION', - 'GL_EXTENSIONS', - ], - 'TextureParameter': [ - 'GL_TEXTURE_MAG_FILTER', - 'GL_TEXTURE_MIN_FILTER', - 'GL_TEXTURE_WRAP_S', - 'GL_TEXTURE_WRAP_T', - ], - 'VertexAttribute': [ - 'GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING', - 'GL_VERTEX_ATTRIB_ARRAY_ENABLED', - 'GL_VERTEX_ATTRIB_ARRAY_SIZE', - 'GL_VERTEX_ATTRIB_ARRAY_STRIDE', - 'GL_VERTEX_ATTRIB_ARRAY_TYPE', - 'GL_VERTEX_ATTRIB_ARRAY_NORMALIZED', - 'GL_CURRENT_VERTEX_ATTRIB', - ], - 'VertexPointer': [ - 'GL_VERTEX_ATTRIB_ARRAY_POINTER', - ], - 'HintTarget': [ - 'GL_GENERATE_MIPMAP_HINT', - ], - 'HintMode': [ - 'GL_FASTEST', - 'GL_NICEST', - 'GL_DONT_CARE', - ], - 'PixelStore': [ - 'GL_PACK_ALIGNMENT', - 'GL_UNPACK_ALIGNMENT', - ], - 'PixelStoreAlignment': [ - '1', - '2', - '4', - '8', - ], - 'ReadPixelFormat': [ - 'GL_ALPHA', - 'GL_RGB', - 'GL_RGBA', - ], - 'PixelType': [ - 'GL_UNSIGNED_BYTE', - 'GL_UNSIGNED_SHORT_5_6_5', - 'GL_UNSIGNED_SHORT_4_4_4_4', - 'GL_UNSIGNED_SHORT_5_5_5_1', - ], - 'RenderBufferFormat': [ - 'GL_RGBA4', - 'GL_RGB565', - 'GL_RGB5_A1', - 'GL_DEPTH_COMPONENT16', - 'GL_STENCIL_INDEX8', - ], - 'StencilOp': [ - 'GL_KEEP', - 'GL_ZERO', - 'GL_REPLACE', - 'GL_INCR', - 'GL_INCR_WRAP', - 'GL_DECR', - 'GL_DECR_WRAP', - 'GL_INVERT', - ], - 'TextureFormat': [ - 'GL_ALPHA', - 'GL_LUMINANCE', - 'GL_LUMINANCE_ALPHA', - 'GL_RGB', - 'GL_RGBA', - ], - 'VertexAttribType': [ - 'GL_BYTE', - 'GL_UNSIGNED_BYTE', - 'GL_SHORT', - 'GL_UNSIGNED_SHORT', - #'GL_FIXED', // This is not available on Desktop GL. - 'GL_FLOAT', - ], - 'VertexAttribSize': [ - '1', - '2', - '3', - '4', - ], + 'FrameBufferTarget': { + 'type': 'GLenum', + 'valid': [ + 'GL_FRAMEBUFFER', + ], + }, + 'RenderBufferTarget': { + 'type': 'GLenum', + 'valid': [ + 'GL_RENDERBUFFER', + ], + }, + 'BufferTarget': { + 'type': 'GLenum', + 'valid': [ + 'GL_ARRAY_BUFFER', + 'GL_ELEMENT_ARRAY_BUFFER', + ], + 'invalid': [ + 'GL_RENDERBUFFER', + ], + }, + 'BufferUsage': { + 'type': 'GLenum', + 'valid': [ + 'GL_STREAM_DRAW', + 'GL_STATIC_DRAW', + 'GL_DYNAMIC_DRAW', + ], + 'invalid': [ + 'GL_STATIC_READ', + ], + }, + 'TextureTarget': { + 'type': 'GLenum', + 'valid': [ + 'GL_TEXTURE_2D', + 'GL_TEXTURE_CUBE_MAP_POSITIVE_X', + 'GL_TEXTURE_CUBE_MAP_NEGATIVE_X', + 'GL_TEXTURE_CUBE_MAP_POSITIVE_Y', + 'GL_TEXTURE_CUBE_MAP_NEGATIVE_Y', + 'GL_TEXTURE_CUBE_MAP_POSITIVE_Z', + 'GL_TEXTURE_CUBE_MAP_NEGATIVE_Z', + ], + 'invalid': [ + 'GL_PROXY_TEXTURE_CUBE_MAP', + ] + }, + 'TextureBindTarget': { + 'type': 'GLenum', + 'valid': [ + 'GL_TEXTURE_2D', + 'GL_TEXTURE_CUBE_MAP', + ], + 'invalid': [ + 'GL_TEXTURE_1D', + 'GL_TEXTURE_3D', + ], + }, + 'ShaderType': { + 'type': 'GLenum', + 'valid': [ + 'GL_VERTEX_SHADER', + 'GL_FRAGMENT_SHADER', + ], + }, + 'FaceType': { + 'type': 'GLenum', + 'valid': [ + 'GL_FRONT', + 'GL_BACK', + 'GL_FRONT_AND_BACK', + ], + }, + 'FaceMode': { + 'type': 'GLenum', + 'valid': [ + 'GL_CW', + 'GL_CCW', + ], + }, + 'CmpFunction': { + 'type': 'GLenum', + 'valid': [ + 'GL_NEVER', + 'GL_LESS', + 'GL_EQUAL', + 'GL_LEQUAL', + 'GL_GREATER', + 'GL_NOTEQUAL', + 'GL_GEQUAL', + 'GL_ALWAYS', + ], + }, + 'Equation': { + 'type': 'GLenum', + 'valid': [ + 'GL_FUNC_ADD', + 'GL_FUNC_SUBTRACT', + 'GL_FUNC_REVERSE_SUBTRACT', + ], + 'invalid': [ + 'GL_MIN', + 'GL_MAX', + ], + }, + 'SrcBlendFactor': { + 'type': 'GLenum', + 'valid': [ + 'GL_ZERO', + 'GL_ONE', + 'GL_SRC_COLOR', + 'GL_ONE_MINUS_SRC_COLOR', + 'GL_DST_COLOR', + 'GL_ONE_MINUS_DST_COLOR', + 'GL_SRC_ALPHA', + 'GL_ONE_MINUS_SRC_ALPHA', + 'GL_DST_ALPHA', + 'GL_ONE_MINUS_DST_ALPHA', + 'GL_CONSTANT_COLOR', + 'GL_ONE_MINUS_CONSTANT_COLOR', + 'GL_CONSTANT_ALPHA', + 'GL_ONE_MINUS_CONSTANT_ALPHA', + 'GL_SRC_ALPHA_SATURATE', + ], + }, + 'DstBlendFactor': { + 'type': 'GLenum', + 'valid': [ + 'GL_ZERO', + 'GL_ONE', + 'GL_SRC_COLOR', + 'GL_ONE_MINUS_SRC_COLOR', + 'GL_DST_COLOR', + 'GL_ONE_MINUS_DST_COLOR', + 'GL_SRC_ALPHA', + 'GL_ONE_MINUS_SRC_ALPHA', + 'GL_DST_ALPHA', + 'GL_ONE_MINUS_DST_ALPHA', + 'GL_CONSTANT_COLOR', + 'GL_ONE_MINUS_CONSTANT_COLOR', + 'GL_CONSTANT_ALPHA', + 'GL_ONE_MINUS_CONSTANT_ALPHA', + ], + }, + 'Capability': { + 'type': 'GLenum', + 'valid': [ + 'GL_BLEND', + 'GL_CULL_FACE', + 'GL_DEPTH_TEST', + 'GL_DITHER', + 'GL_POLYGON_OFFSET_FILL', + 'GL_SAMPLE_ALPHA_TO_COVERAGE', + 'GL_SAMPLE_COVERAGE', + 'GL_SCISSOR_TEST', + 'GL_STENCIL_TEST', + ], + 'invalid': [ + 'GL_CLIP_PLANE0', + 'GL_POINT_SPRITE', + ], + }, + 'DrawMode': { + 'type': 'GLenum', + 'valid': [ + 'GL_POINTS', + 'GL_LINE_STRIP', + 'GL_LINE_LOOP', + 'GL_LINES', + 'GL_TRIANGLE_STRIP', + 'GL_TRIANGLE_FAN', + 'GL_TRIANGLES', + ], + 'invalid': [ + 'GL_QUADS', + 'GL_POLYGON', + ], + }, + 'IndexType': { + 'type': 'GLenum', + 'valid': [ + 'GL_UNSIGNED_BYTE', + 'GL_UNSIGNED_SHORT', + ], + 'invalid': [ + 'GL_UNSIGNED_INT', + 'GL_INT', + ], + }, + 'Attachment': { + 'type': 'GLenum', + 'valid': [ + 'GL_COLOR_ATTACHMENT0', + 'GL_DEPTH_ATTACHMENT', + 'GL_STENCIL_ATTACHMENT', + ], + }, + 'BufferParameter': { + 'type': 'GLenum', + 'valid': [ + 'GL_BUFFER_SIZE', + 'GL_BUFFER_USAGE', + ], + 'invalid': [ + 'GL_PIXEL_PACK_BUFFER', + ], + }, + 'FrameBufferParameter': { + 'type': 'GLenum', + 'valid': [ + 'GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE', + 'GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME', + 'GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL', + 'GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE', + ], + }, + 'ProgramParameter': { + 'type': 'GLenum', + 'valid': [ + 'GL_DELETE_STATUS', + 'GL_LINK_STATUS', + 'GL_VALIDATE_STATUS', + 'GL_INFO_LOG_LENGTH', + 'GL_ATTACHED_SHADERS', + 'GL_ACTIVE_ATTRIBUTES', + 'GL_ACTIVE_ATTRIBUTE_MAX_LENGTH', + 'GL_ACTIVE_UNIFORMS', + 'GL_ACTIVE_UNIFORM_MAX_LENGTH', + ], + }, + 'RenderBufferParameter': { + 'type': 'GLenum', + 'valid': [ + 'GL_RENDERBUFFER_WIDTH', + 'GL_RENDERBUFFER_HEIGHT', + 'GL_RENDERBUFFER_INTERNAL_FORMAT', + 'GL_RENDERBUFFER_RED_SIZE', + 'GL_RENDERBUFFER_GREEN_SIZE', + 'GL_RENDERBUFFER_BLUE_SIZE', + 'GL_RENDERBUFFER_ALPHA_SIZE', + 'GL_RENDERBUFFER_DEPTH_SIZE', + 'GL_RENDERBUFFER_STENCIL_SIZE', + ], + }, + 'ShaderParameter': { + 'type': 'GLenum', + 'valid': [ + 'GL_SHADER_TYPE', + 'GL_DELETE_STATUS', + 'GL_COMPILE_STATUS', + 'GL_INFO_LOG_LENGTH', + 'GL_SHADER_SOURCE_LENGTH', + ], + }, + 'ShaderPercision': { + 'type': 'GLenum', + 'valid': [ + 'GL_LOW_FLOAT', + 'GL_MEDIUM_FLOAT', + 'GL_HIGH_FLOAT', + 'GL_LOW_INT', + 'GL_MEDIUM_INT', + 'GL_HIGH_INT', + ], + }, + 'StringType': { + 'type': 'GLenum', + 'valid': [ + 'GL_VENDOR', + 'GL_RENDERER', + 'GL_VERSION', + 'GL_SHADING_LANGUAGE_VERSION', + 'GL_EXTENSIONS', + ], + }, + 'TextureParameter': { + 'type': 'GLenum', + 'valid': [ + 'GL_TEXTURE_MAG_FILTER', + 'GL_TEXTURE_MIN_FILTER', + 'GL_TEXTURE_WRAP_S', + 'GL_TEXTURE_WRAP_T', + ], + 'invalid': [ + 'GL_GENERATE_MIPMAP', + ], + }, + 'VertexAttribute': { + 'type': 'GLenum', + 'valid': [ + 'GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING', + 'GL_VERTEX_ATTRIB_ARRAY_ENABLED', + 'GL_VERTEX_ATTRIB_ARRAY_SIZE', + 'GL_VERTEX_ATTRIB_ARRAY_STRIDE', + 'GL_VERTEX_ATTRIB_ARRAY_TYPE', + 'GL_VERTEX_ATTRIB_ARRAY_NORMALIZED', + 'GL_CURRENT_VERTEX_ATTRIB', + ], + }, + 'VertexPointer': { + 'type': 'GLenum', + 'valid': [ + 'GL_VERTEX_ATTRIB_ARRAY_POINTER', + ], + }, + 'HintTarget': { + 'type': 'GLenum', + 'valid': [ + 'GL_GENERATE_MIPMAP_HINT', + ], + 'invalid': [ + 'GL_PERSPECTIVE_CORRECTION_HINT', + ], + }, + 'HintMode': { + 'type': 'GLenum', + 'valid': [ + 'GL_FASTEST', + 'GL_NICEST', + 'GL_DONT_CARE', + ], + }, + 'PixelStore': { + 'type': 'GLenum', + 'valid': [ + 'GL_PACK_ALIGNMENT', + 'GL_UNPACK_ALIGNMENT', + ], + 'invalid': [ + 'GL_PACK_SWAP_BYTES', + 'GL_UNPACK_SWAP_BYTES', + ], + }, + 'PixelStoreAlignment': { + 'type': 'GLint', + 'valid': [ + '1', + '2', + '4', + '8', + ], + 'invalid': [ + '3', + '9', + ], + }, + 'ReadPixelFormat': { + 'type': 'GLenum', + 'valid': [ + 'GL_ALPHA', + 'GL_RGB', + 'GL_RGBA', + ], + }, + 'PixelType': { + 'type': 'GLenum', + 'valid': [ + 'GL_UNSIGNED_BYTE', + 'GL_UNSIGNED_SHORT_5_6_5', + 'GL_UNSIGNED_SHORT_4_4_4_4', + 'GL_UNSIGNED_SHORT_5_5_5_1', + ], + 'invalid': [ + 'GL_SHORT', + 'GL_INT', + ], + }, + 'RenderBufferFormat': { + 'type': 'GLenum', + 'valid': [ + 'GL_RGBA4', + 'GL_RGB565', + 'GL_RGB5_A1', + 'GL_DEPTH_COMPONENT16', + 'GL_STENCIL_INDEX8', + ], + }, + 'StencilOp': { + 'type': 'GLenum', + 'valid': [ + 'GL_KEEP', + 'GL_ZERO', + 'GL_REPLACE', + 'GL_INCR', + 'GL_INCR_WRAP', + 'GL_DECR', + 'GL_DECR_WRAP', + 'GL_INVERT', + ], + }, + 'TextureFormat': { + 'type': 'GLenum', + 'valid': [ + 'GL_ALPHA', + 'GL_LUMINANCE', + 'GL_LUMINANCE_ALPHA', + 'GL_RGB', + 'GL_RGBA', + ], + 'invalid': [ + 'GL_BGRA', + 'GL_BGR', + ], + }, + 'VertexAttribType': { + 'type': 'GLenum', + 'valid': [ + 'GL_BYTE', + 'GL_UNSIGNED_BYTE', + 'GL_SHORT', + 'GL_UNSIGNED_SHORT', + # 'GL_FIXED', // This is not available on Desktop GL. + 'GL_FLOAT', + ], + 'invalid': [ + 'GL_DOUBLE', + ], + }, + 'VertexAttribSize': { + 'type': 'GLint', + 'valid': [ + '1', + '2', + '3', + '4', + ], + 'invalid': [ + '0', + '5', + ], + }, + 'False': { + 'type': 'GLboolean', + 'valid': [ + 'false', + ], + 'invalid': [ + 'true', + ], + }, } # This table specifies types and other special data for the commands that @@ -656,15 +839,21 @@ _FUNCTION_INFO = { 'CompressedTexSubImage2D': {'type': 'Data'}, 'CreateProgram': {'type': 'Create'}, 'CreateShader': {'type': 'Create'}, - 'DeleteBuffers': {'type': 'DELn'}, - 'DeleteFramebuffers': {'type': 'DELn'}, + 'DeleteBuffers': {'type': 'DELn', 'gl_test_func': 'glDeleteBuffersARB'}, + 'DeleteFramebuffers': { + 'type': 'DELn', + 'gl_test_func': 'glDeleteFramebuffersEXT', + }, 'DeleteProgram': {'type': 'Custom', 'DecoderFunc': 'DoDeleteProgram'}, - 'DeleteRenderbuffers': {'type': 'DELn'}, + 'DeleteRenderbuffers': { + 'type': 'DELn', + 'gl_test_func': 'glDeleteRenderbuffersEXT', + }, 'DeleteShader': {'type': 'Custom', 'DecoderFunc': 'DoDeleteShader'}, 'DeleteTextures': {'type': 'DELn'}, 'DepthRangef': {'DecoderFunc': 'glDepthRange'}, 'DisableVertexAttribArray': {'DecoderFunc': 'DoDisableVertexAttribArray'}, - 'DrawArrays': { 'DecoderFunc': 'DoDrawArrays'}, + 'DrawArrays': { 'DecoderFunc': 'DoDrawArrays', 'unit_test': False}, 'DrawElements': { 'type': 'Manual', 'cmd_args': 'GLenum mode, GLsizei count, GLenum type, GLuint index_offset', @@ -673,10 +862,10 @@ _FUNCTION_INFO = { 'FramebufferRenderbuffer': {'DecoderFunc': 'glFramebufferRenderbufferEXT'}, 'FramebufferTexture2D': {'DecoderFunc': 'glFramebufferTexture2DEXT'}, 'GenerateMipmap': {'DecoderFunc': 'glGenerateMipmapEXT'}, - 'GenBuffers': {'type': 'GENn'}, - 'GenFramebuffers': {'type': 'GENn'}, - 'GenRenderbuffers': {'type': 'GENn'}, - 'GenTextures': {'type': 'GENn'}, + 'GenBuffers': {'type': 'GENn', 'gl_test_func': 'glGenBuffersARB'}, + 'GenFramebuffers': {'type': 'GENn', 'gl_test_func': 'glGenFramebuffersEXT'}, + 'GenRenderbuffers': {'type': 'GENn', 'gl_test_func': 'glGenRenderbuffersEXT'}, + 'GenTextures': {'type': 'GENn', 'gl_test_func': 'glGenTextures'}, 'GetActiveAttrib': {'type': 'Custom'}, 'GetActiveUniform': {'type': 'Custom'}, 'GetAttachedShaders': {'type': 'Custom'}, @@ -685,7 +874,7 @@ _FUNCTION_INFO = { 'immediate': True, 'needs_size': True, 'cmd_args': - 'GLResourceId program, const char* name, NonImmediate GLint* location', + 'GLidProgram program, const char* name, NonImmediate GLint* location', }, 'GetBooleanv': {'type': 'GETn'}, 'GetBufferParameteriv': {'type': 'GETn'}, @@ -715,7 +904,7 @@ _FUNCTION_INFO = { 'immediate': True, 'needs_size': True, 'cmd_args': - 'GLResourceId program, const char* name, NonImmediate GLint* location', + 'GLidProgram program, const char* name, NonImmediate GLint* location', }, 'GetVertexAttribfv': {'type': 'GETn'}, 'GetVertexAttribiv': {'type': 'GETn'}, @@ -755,7 +944,7 @@ _FUNCTION_INFO = { 'UniformMatrix2fv': {'type': 'PUTn', 'data_type': 'GLfloat', 'count': 4}, 'UniformMatrix3fv': {'type': 'PUTn', 'data_type': 'GLfloat', 'count': 9}, 'UniformMatrix4fv': {'type': 'PUTn', 'data_type': 'GLfloat', 'count': 16}, - 'UseProgram': {'DecoderFunc': 'DoUseProgram'}, + 'UseProgram': {'DecoderFunc': 'DoUseProgram', 'unit_test': False}, 'VertexAttrib1fv': {'type': 'PUT', 'data_type': 'GLfloat', 'count': 1}, 'VertexAttrib2fv': {'type': 'PUT', 'data_type': 'GLfloat', 'count': 2}, 'VertexAttrib3fv': {'type': 'PUT', 'data_type': 'GLfloat', 'count': 3}, @@ -765,7 +954,7 @@ _FUNCTION_INFO = { 'cmd_args': 'GLuint indx, GLint size, GLenum type, GLboolean normalized, ' 'GLsizei stride, GLuint offset', }, - 'SwapBuffers': {'DecoderFunc': 'DoSwapBuffers'}, + 'SwapBuffers': {'DecoderFunc': 'DoSwapBuffers', 'unit_test': False}, } @@ -786,13 +975,15 @@ class CWriter(object): def __FindSplit(self, string): """Finds a place to split a string.""" splitter = string.find('=') - if splitter >= 0 and not string[splitter + 1] == '=': + if splitter >= 0 and not string[splitter + 1] == '=' and splitter < 80: return splitter parts = string.split('(') if len(parts) > 1: splitter = len(parts[0]) for ii in range(1, len(parts)): - if not parts[ii - 1][-3:] == "if ": + if (not parts[ii - 1][-3:] == "if " and + (len(parts[ii]) > 0 and not parts[ii][0] == ")") + and splitter < 80): return splitter splitter += len(parts[ii]) + 1 done = False @@ -832,6 +1023,32 @@ class CWriter(object): self.file.close() +class CHeaderWriter(CWriter): + """Writes a C Header file.""" + + _non_alnum_re = re.compile(r'[^a-zA-Z0-9]') + + def __init__(self, filename, file_comment = None): + CWriter.__init__(self, filename) + + base = os.path.dirname( + os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) + hpath = os.path.abspath(filename)[len(base) + 1:] + self.guard = self._non_alnum_re.sub('_', hpath).upper() + '_' + + self.Write(_LICENSE) + self.Write( + "// This file is auto-generated. DO NOT EDIT!\n" + "\n") + if not file_comment == None: + self.Write(file_comment) + self.Write("#ifndef %s\n" % self.guard) + self.Write("#define %s\n\n" % self.guard) + + def Close(self): + self.Write("#endif // %s\n\n" % self.guard) + CWriter.Close(self) + class TypeHandler(object): """This class emits code for a particular type of function.""" @@ -892,12 +1109,12 @@ class TypeHandler(object): def WriteCmdSizeTest(self, func, file): """Writes the size test for a command.""" - file.Write(" EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT\n") + file.Write(" EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);\n") def WriteFormatTest(self, func, file): """Writes a format test for a command.""" file.Write("TEST(GLES2FormatTest, %s) {\n" % func.name) - file.Write(" %s cmd = {{0}};\n" % func.name) + file.Write(" %s cmd = { { 0 } };\n" % func.name) file.Write(" void* next_cmd = cmd.Set(\n") file.Write(" &cmd") args = func.GetCmdArgs() @@ -997,6 +1214,101 @@ class TypeHandler(object): file.Write("}\n") file.Write("\n") + def WriteValidUnitTest(self, func, file, test, extra = {}): + """Writes a valid unit test.""" + name = func.name + arg_strings = [] + count = 0 + for arg in func.GetOriginalArgs(): + arg_strings.append(arg.GetValidArg(count, 0)) + count += 1 + gl_arg_strings = [] + count = 0 + for arg in func.GetOriginalArgs(): + gl_arg_strings.append(arg.GetValidGLArg(count, 0)) + count += 1 + gl_func_name = func.GetGLTestFunctionName() + vars = { + 'name':name, + 'gl_func_name': gl_func_name, + 'args': ", ".join(arg_strings), + 'gl_args': ", ".join(gl_arg_strings), + } + vars.update(extra) + file.Write(test % vars) + + def WriteInvalidUnitTest(self, func, file, test, extra = {}): + """Writes a invalid unit test.""" + arg_index = 0 + for arg in func.GetOriginalArgs(): + num_invalid_values = arg.GetNumInvalidValues() + for value_index in range(0, num_invalid_values): + arg_strings = [] + parse_result = "kParseNoError" + count = 0 + for arg in func.GetOriginalArgs(): + if count == arg_index: + (arg_string, parse_result) = arg.GetInvalidArg(count, value_index) + else: + arg_string = arg.GetValidArg(count, 0) + arg_strings.append(arg_string) + count += 1 + gl_arg_strings = [] + count = 0 + for arg in func.GetOriginalArgs(): + gl_arg_strings.append("_") + count += 1 + gl_func_name = func.GetGLFunctionName() + if gl_func_name.startswith("gl"): + gl_func_name = gl_func_name[2:] + else: + gl_func_name = func.name + + vars = { + 'name': func.name, + 'arg_index': arg_index, + 'value_index': value_index, + 'gl_func_name': gl_func_name, + 'args': ", ".join(arg_strings), + 'all_but_last_args': ", ".join(arg_strings[:-1]), + 'gl_args': ", ".join(gl_arg_strings), + 'parse_result': parse_result, + } + vars.update(extra) + file.Write(test % vars) + arg_index += 1 + + def WriteServiceUnitTest(self, func, file): + """Writes the service unit test for a command.""" + if func.GetInfo('unit_test') == False: + file.Write("// TODO(gman): %s\n" % func.name) + return + valid_test = """ +TEST_F(GLES2DecoderTest, %(name)sValidArgs) { + EXPECT_CALL(*gl_, %(gl_func_name)s(%(gl_args)s)); + SpecializedSetup<%(name)s, 0>(); + %(name)s cmd; + cmd.Init(%(args)s); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} +""" + self.WriteValidUnitTest(func, file, valid_test) + + invalid_test = """ +TEST_F(GLES2DecoderTest, %(name)sInvalidArgs%(arg_index)d_%(value_index)d) { + EXPECT_CALL(*gl_, %(gl_func_name)s(%(gl_args)s)).Times(0); + SpecializedSetup<%(name)s, 0>(); + %(name)s cmd; + cmd.Init(%(args)s); + EXPECT_EQ(parse_error::%(parse_result)s, ExecuteCmd(cmd)); +} +""" + self.WriteInvalidUnitTest(func, file, invalid_test) + + def WriteImmediateServiceUnitTest(self, func, file): + """Writes the service unit test for an immediate command.""" + file.Write("// TODO(gman): %s\n" % func.name) + def WriteImmediateValidationCode(self, func, file): """Writes the validation code for an immediate version of a command.""" pass @@ -1046,26 +1358,11 @@ class TypeHandler(object): def WriteImmediateCmdInit(self, func, file): """Writes the Init function for the immediate version of a command.""" - file.Write(" void Init(%s) {\n" % func.MakeTypedCmdArgString("_")) - file.Write(" SetHeader(0); // TODO(gman): pass in correct size\n") - args = func.GetCmdArgs() - for arg in args: - file.Write(" %s = _%s;\n" % (arg.name, arg.name)) - file.Write(" }\n") - file.Write("\n") + raise Error def WriteImmediateCmdSet(self, func, file): """Writes the Set function for the immediate version of a command.""" - copy_args = func.MakeCmdArgString("_", False) - file.Write(" void* Set(void* cmd%s) {\n" % - func.MakeTypedCmdArgString("_", True)) - file.Write(" // TODO(gman): compute correct size.\n") - file.Write(" const uint32 size = ComputeSize(0);\n") - file.Write(" static_cast<ValueType*>(cmd)->Init(%s);\n" % copy_args) - file.Write(" return NextImmediateCmdAddressTotalSize<ValueType>(" - "cmd, size);\n") - file.Write(" }\n") - file.Write("\n") + raise Error def WriteCmdHelper(self, func, file): """Writes the cmd helper definition for a cmd.""" @@ -1100,6 +1397,14 @@ class CustomHandler(TypeHandler): """Overrriden from TypeHandler.""" pass + def WriteServiceUnitTest(self, func, file): + """Overrriden from TypeHandler.""" + file.Write("// TODO(gman): %s\n\n" % func.name) + + def WriteImmediateServiceUnitTest(self, func, file): + """Overrriden from TypeHandler.""" + file.Write("// TODO(gman): %s\n\n" % func.name) + def WriteImmediateCmdGetTotalSize(self, func, file): """Overrriden from TypeHandler.""" file.Write(" uint32 total_size = 0; // TODO(gman): get correct size.\n") @@ -1148,6 +1453,14 @@ class HandWrittenHandler(CustomHandler): """Overrriden from TypeHandler.""" pass + def WriteServiceUnitTest(self, func, file): + """Overrriden from TypeHandler.""" + file.Write("// TODO(gman): %s\n\n" % func.name) + + def WriteImmediateServiceUnitTest(self, func, file): + """Overrriden from TypeHandler.""" + file.Write("// TODO(gman): %s\n\n" % func.name) + def WriteServiceImplementation(self, func, file): """Overrriden from TypeHandler.""" pass @@ -1187,6 +1500,14 @@ class ManualHandler(CustomHandler): """Overrriden from TypeHandler.""" pass + def WriteServiceUnitTest(self, func, file): + """Overrriden from TypeHandler.""" + file.Write("// TODO(gman): %s\n\n" % func.name) + + def WriteImmediateServiceUnitTest(self, func, file): + """Overrriden from TypeHandler.""" + file.Write("// TODO(gman): %s\n\n" % func.name) + def WriteImmediateServiceImplementation(self, func, file): """Overrriden from TypeHandler.""" pass @@ -1314,6 +1635,14 @@ class DataHandler(TypeHandler): """Overrriden from TypeHandler.""" pass + def WriteServiceUnitTest(self, func, file): + """Overrriden from TypeHandler.""" + file.Write("// TODO(gman): %s\n\n" % func.name) + + def WriteImmediateServiceUnitTest(self, func, file): + """Overrriden from TypeHandler.""" + file.Write("// TODO(gman): %s\n\n" % func.name) + class GENnHandler(TypeHandler): """Handler for glGen___ type functions.""" @@ -1331,12 +1660,16 @@ class GENnHandler(TypeHandler): def WriteHandlerImplementation (self, func, file): """Overrriden from TypeHandler.""" - file.Write(" GenGLObjects<GL%sHelper>(n, %s);\n" % + file.Write(" if (!GenGLObjects<GL%sHelper>(n, %s)) {\n" + " return parse_error::kParseInvalidArguments;\n" + " }\n" % (func.name, func.GetLastOriginalArg().name)) def WriteImmediateHandlerImplementation(self, func, file): """Overrriden from TypeHandler.""" - file.Write(" GenGLObjects<GL%sHelper>(n, %s);\n" % + file.Write(" if (!GenGLObjects<GL%sHelper>(n, %s)) {\n" + " return parse_error::kParseInvalidArguments;\n" + " }\n" % (func.original_name, func.GetLastOriginalArg().name)) def WriteGLES2ImplementationHeader(self, func, file): @@ -1354,6 +1687,65 @@ class GENnHandler(TypeHandler): """Overrriden from TypeHandler.""" pass + def WriteServiceUnitTest(self, func, file): + """Overrriden from TypeHandler.""" + valid_test = """ +TEST_F(GLES2DecoderTest, %(name)sValidArgs) { + EXPECT_CALL(*gl_, %(gl_func_name)s(1, _)) + .WillOnce(SetArgumentPointee<1>(kNewServiceId)); + GetSharedMemoryAs<GLuint*>()[0] = kNewClientId; + SpecializedSetup<%(name)s, 0>(); + %(name)s cmd; + cmd.Init(%(args)s); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); + EXPECT_EQ(GetServiceId(kNewClientId), kNewServiceId); +} +""" + self.WriteValidUnitTest(func, file, valid_test) + invalid_test = """ +TEST_F(GLES2DecoderTest, %(name)sInvalidArgs) { + EXPECT_CALL(*gl_, %(gl_func_name)s(_, _)).Times(0); + GetSharedMemoryAs<GLuint*>()[0] = client_%(resource_name)s_id_; + SpecializedSetup<%(name)s, 0>(); + %(name)s cmd; + cmd.Init(%(args)s); + EXPECT_EQ(parse_error::kParseInvalidArguments, ExecuteCmd(cmd)); +} +""" + self.WriteValidUnitTest(func, file, invalid_test, { + 'resource_name': func.GetOriginalArgs()[1].name[0:-1] + }) + + def WriteImmediateServiceUnitTest(self, func, file): + """Overrriden from TypeHandler.""" + valid_test = """ +TEST_F(GLES2DecoderTest, %(name)sValidArgs) { + EXPECT_CALL(*gl_, %(gl_func_name)s(1, _)) + .WillOnce(SetArgumentPointee<1>(kNewServiceId)); + %(name)s& cmd = *GetImmediateAs<%(name)s>(); + GLuint temp = kNewClientId; + SpecializedSetup<%(name)s, 0>(); + cmd.Init(1, &temp); + EXPECT_EQ(parse_error::kParseNoError, + ExecuteImmediateCmd(cmd, sizeof(temp))); + EXPECT_EQ(GetServiceId(kNewClientId), kNewServiceId); +} +""" + self.WriteValidUnitTest(func, file, valid_test) + invalid_test = """ +TEST_F(GLES2DecoderTest, %(name)sInvalidArgs) { + EXPECT_CALL(*gl_, %(gl_func_name)s(_, _)).Times(0); + %(name)s& cmd = *GetImmediateAs<%(name)s>(); + SpecializedSetup<%(name)s, 0>(); + cmd.Init(1, &client_%(resource_name)s_id_); + EXPECT_EQ(parse_error::kParseInvalidArguments, + ExecuteImmediateCmd(cmd, sizeof(&client_%(resource_name)s_id_))); +} +""" + self.WriteValidUnitTest(func, file, invalid_test, { + 'resource_name': func.GetOriginalArgs()[1].name[0:-1] + }) + def WriteImmediateCmdComputeSize(self, func, file): """Overrriden from TypeHandler.""" file.Write(" static uint32 ComputeDataSize(GLsizei n) {\n") @@ -1438,7 +1830,7 @@ class GENnHandler(TypeHandler): file.Write(" cmd.header.command);\n") file.Write(" EXPECT_EQ(sizeof(cmd) +\n") file.Write(" RoundSizeToMultipleOfEntries(cmd.n * 4u),\n") - file.Write(" cmd.header.size * 4u); // NOLINT\n") + file.Write(" cmd.header.size * 4u);\n") file.Write(" EXPECT_EQ(static_cast<char*>(next_cmd),\n") file.Write(" reinterpret_cast<char*>(&cmd) + sizeof(cmd) +\n"); file.Write(" RoundSizeToMultipleOfEntries(cmd.n * 4u));\n"); @@ -1461,6 +1853,38 @@ class CreateHandler(TypeHandler): """Overrriden from TypeHandler.""" func.AddCmdArg(Argument("client_id", 'uint32')) + def WriteServiceUnitTest(self, func, file): + """Overrriden from TypeHandler.""" + valid_test = """ +TEST_F(GLES2DecoderTest, %(name)sValidArgs) { + EXPECT_CALL(*gl_, %(gl_func_name)s(%(gl_args)s)) + .WillOnce(Return(kNewServiceId)); + SpecializedSetup<%(name)s, 0>(); + %(name)s cmd; + cmd.Init(%(args)s%(comma)skNewClientId); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); + EXPECT_EQ(GetServiceId(kNewClientId), kNewServiceId); +} +""" + comma = "" + if len(func.GetOriginalArgs()): + comma =", " + self.WriteValidUnitTest(func, file, valid_test, { + 'comma': comma, + }) + invalid_test = """ +TEST_F(GLES2DecoderTest, %(name)sInvalidArgs%(arg_index)d_%(value_index)d) { + EXPECT_CALL(*gl_, %(gl_func_name)s(%(gl_args)s)).Times(0); + SpecializedSetup<%(name)s, 0>(); + %(name)s cmd; + cmd.Init(%(args)s%(comma)skNewClientId); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} +""" + self.WriteInvalidUnitTest(func, file, invalid_test, { + 'comma': comma, + }) + def WriteHandlerImplementation (self, func, file): """Overrriden from TypeHandler.""" file.Write(" uint32 client_id = c.client_id;\n") @@ -1495,6 +1919,75 @@ class DELnHandler(TypeHandler): """Overrriden from TypeHandler.""" file.Write(" uint32 data_size = n * sizeof(GLuint);\n") + def WriteServiceUnitTest(self, func, file): + """Overrriden from TypeHandler.""" + valid_test = """ +TEST_F(GLES2DecoderTest, %(name)sValidArgs) { + EXPECT_CALL( + *gl_, + %(gl_func_name)s(1, Pointee(kService%(upper_resource_name)sId))) + .Times(1); + GetSharedMemoryAs<GLuint*>()[0] = client_%(resource_name)s_id_; + SpecializedSetup<%(name)s, 0>(); + %(name)s cmd; + cmd.Init(%(args)s); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); + EXPECT_EQ(GetServiceId(kNewClientId), 0u); +} +""" + self.WriteValidUnitTest(func, file, valid_test, { + 'resource_name': func.GetOriginalArgs()[1].name[0:-1], + 'upper_resource_name': + func.GetOriginalArgs()[1].name[0:-1].capitalize(), + }) + invalid_test = """ +TEST_F(GLES2DecoderTest, %(name)sInvalidArgs) { + EXPECT_CALL(*gl_, %(gl_func_name)s(1, Pointee(0))) + .Times(1); + GetSharedMemoryAs<GLuint*>()[0] = kInvalidClientId; + SpecializedSetup<%(name)s, 0>(); + %(name)s cmd; + cmd.Init(%(args)s); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} +""" + self.WriteValidUnitTest(func, file, invalid_test) + + def WriteImmediateServiceUnitTest(self, func, file): + """Overrriden from TypeHandler.""" + valid_test = """ +TEST_F(GLES2DecoderTest, %(name)sValidArgs) { + EXPECT_CALL( + *gl_, + %(gl_func_name)s(1, Pointee(kService%(upper_resource_name)sId))) + .Times(1); + %(name)s& cmd = *GetImmediateAs<%(name)s>(); + SpecializedSetup<%(name)s, 0>(); + cmd.Init(1, &client_%(resource_name)s_id_); + EXPECT_EQ(parse_error::kParseNoError, + ExecuteImmediateCmd(cmd, sizeof(client_%(resource_name)s_id_))); + EXPECT_EQ(GetServiceId(kNewClientId), 0u); +} +""" + self.WriteValidUnitTest(func, file, valid_test, { + 'resource_name': func.GetOriginalArgs()[1].name[0:-1], + 'upper_resource_name': + func.GetOriginalArgs()[1].name[0:-1].capitalize(), + }) + invalid_test = """ +TEST_F(GLES2DecoderTest, %(name)sInvalidArgs) { + EXPECT_CALL(*gl_, %(gl_func_name)s(1, Pointee(0))) + .Times(1); + %(name)s& cmd = *GetImmediateAs<%(name)s>(); + SpecializedSetup<%(name)s, 0>(); + GLuint temp = kInvalidClientId; + cmd.Init(1, &temp); + EXPECT_EQ(parse_error::kParseNoError, + ExecuteImmediateCmd(cmd, sizeof(temp))); +} +""" + self.WriteValidUnitTest(func, file, invalid_test) + def WriteHandlerImplementation (self, func, file): """Overrriden from TypeHandler.""" file.Write(" DeleteGLObjects<GL%sHelper>(n, %s);\n" % @@ -1604,7 +2097,7 @@ class DELnHandler(TypeHandler): file.Write(" cmd.header.command);\n") file.Write(" EXPECT_EQ(sizeof(cmd) +\n") file.Write(" RoundSizeToMultipleOfEntries(cmd.n * 4u),\n") - file.Write(" cmd.header.size * 4u); // NOLINT\n") + file.Write(" cmd.header.size * 4u);\n") file.Write(" EXPECT_EQ(static_cast<char*>(next_cmd),\n") file.Write(" reinterpret_cast<char*>(&cmd) + sizeof(cmd) +\n"); file.Write(" RoundSizeToMultipleOfEntries(cmd.n * 4u));\n"); @@ -1680,6 +2173,50 @@ class PUTHandler(TypeHandler): def __init__(self): TypeHandler.__init__(self) + def WriteImmediateServiceUnitTest(self, func, file): + """Writes the service unit test for a command.""" + valid_test = """ +TEST_F(GLES2DecoderTest, %(name)sValidArgs) { + %(name)s& cmd = *GetImmediateAs<%(name)s>(); + EXPECT_CALL( + *gl_, + %(gl_func_name)s(%(gl_args)s, + reinterpret_cast<%(data_type)s*>(ImmediateDataAddress(&cmd)))); + SpecializedSetup<%(name)s, 0>(); + %(data_type)s temp[%(data_count)s] = { 0, }; + cmd.Init(%(gl_args)s, &temp[0]); + EXPECT_EQ(parse_error::kParseNoError, + ExecuteImmediateCmd(cmd, sizeof(temp))); +} +""" + gl_arg_strings = [] + gl_any_strings = [] + count = 0 + for arg in func.GetOriginalArgs()[0:-1]: + gl_arg_strings.append(arg.GetValidGLArg(count, 0)) + gl_any_strings.append("_") + count += 1 + extra = { + 'data_type': func.GetInfo('data_type'), + 'data_count': func.GetInfo('count'), + 'gl_args': ", ".join(gl_arg_strings), + 'gl_any_args': ", ".join(gl_any_strings), + } + self.WriteValidUnitTest(func, file, valid_test, extra) + + invalid_test = """ +TEST_F(GLES2DecoderTest, %(name)sInvalidArgs%(arg_index)d_%(value_index)d) { + %(name)s& cmd = *GetImmediateAs<%(name)s>(); + EXPECT_CALL(*gl_, %(gl_func_name)s(%(gl_any_args)s, _)).Times(0); + SpecializedSetup<%(name)s, 0>(); + %(data_type)s temp[%(data_count)s] = { 0, }; + cmd.Init(%(all_but_last_args)s, &temp[0]); + EXPECT_EQ(parse_error::%(parse_result)s, + ExecuteImmediateCmd(cmd, sizeof(temp))); +} +""" + self.WriteInvalidUnitTest(func, file, invalid_test, extra) + def WriteGetDataSizeCode(self, func, file): """Overrriden from TypeHandler.""" file.Write(" uint32 data_size = ComputeImmediateDataSize(" @@ -1792,7 +2329,7 @@ class PUTHandler(TypeHandler): file.Write(" cmd.header.command);\n") file.Write(" EXPECT_EQ(sizeof(cmd) +\n") file.Write(" RoundSizeToMultipleOfEntries(sizeof(data)),\n") - file.Write(" cmd.header.size * 4u); // NOLINT\n") + file.Write(" cmd.header.size * 4u);\n") file.Write(" EXPECT_EQ(static_cast<char*>(next_cmd),\n") file.Write(" reinterpret_cast<char*>(&cmd) + sizeof(cmd) +\n") file.Write(" RoundSizeToMultipleOfEntries(sizeof(data)));\n") @@ -1811,6 +2348,50 @@ class PUTnHandler(TypeHandler): def __init__(self): TypeHandler.__init__(self) + def WriteImmediateServiceUnitTest(self, func, file): + """Writes the service unit test for a command.""" + valid_test = """ +TEST_F(GLES2DecoderTest, %(name)sValidArgs) { + %(name)s& cmd = *GetImmediateAs<%(name)s>(); + EXPECT_CALL( + *gl_, + %(gl_func_name)s(%(gl_args)s, + reinterpret_cast<%(data_type)s*>(ImmediateDataAddress(&cmd)))); + SpecializedSetup<%(name)s, 0>(); + %(data_type)s temp[%(data_count)s * 2] = { 0, }; + cmd.Init(%(gl_args)s, &temp[0]); + EXPECT_EQ(parse_error::kParseNoError, + ExecuteImmediateCmd(cmd, sizeof(temp))); +} +""" + gl_arg_strings = [] + gl_any_strings = [] + count = 0 + for arg in func.GetOriginalArgs()[0:-1]: + gl_arg_strings.append(arg.GetValidGLArg(count, 0)) + gl_any_strings.append("_") + count += 1 + extra = { + 'data_type': func.GetInfo('data_type'), + 'data_count': func.GetInfo('count'), + 'gl_args': ", ".join(gl_arg_strings), + 'gl_any_args': ", ".join(gl_any_strings), + } + self.WriteValidUnitTest(func, file, valid_test, extra) + + invalid_test = """ +TEST_F(GLES2DecoderTest, %(name)sInvalidArgs%(arg_index)d_%(value_index)d) { + %(name)s& cmd = *GetImmediateAs<%(name)s>(); + EXPECT_CALL(*gl_, %(gl_func_name)s(%(gl_any_args)s, _)).Times(0); + SpecializedSetup<%(name)s, 0>(); + %(data_type)s temp[%(data_count)s * 2] = { 0, }; + cmd.Init(%(all_but_last_args)s, &temp[0]); + EXPECT_EQ(parse_error::%(parse_result)s, + ExecuteImmediateCmd(cmd, sizeof(temp))); +} +""" + self.WriteInvalidUnitTest(func, file, invalid_test, extra) + def WriteGetDataSizeCode(self, func, file): """Overrriden from TypeHandler.""" file.Write(" uint32 data_size = ComputeImmediateDataSize(" @@ -1923,7 +2504,7 @@ class PUTnHandler(TypeHandler): file.Write(" cmd.header.command);\n") file.Write(" EXPECT_EQ(sizeof(cmd) +\n") file.Write(" RoundSizeToMultipleOfEntries(sizeof(data)),\n") - file.Write(" cmd.header.size * 4u); // NOLINT\n") + file.Write(" cmd.header.size * 4u);\n") file.Write(" EXPECT_EQ(static_cast<char*>(next_cmd),\n") file.Write(" reinterpret_cast<char*>(&cmd) + sizeof(cmd) +\n") file.Write(" RoundSizeToMultipleOfEntries(sizeof(data)));\n") @@ -1946,6 +2527,14 @@ class GLcharHandler(TypeHandler): """Overrriden from TypeHandler.""" func.AddCmdArg(Argument('data_size', 'uint32')) + def WriteServiceUnitTest(self, func, file): + """Overrriden from TypeHandler.""" + file.Write("// TODO(gman): %s\n\n" % func.name) + + def WriteImmediateServiceUnitTest(self, func, file): + """Overrriden from TypeHandler.""" + file.Write("// TODO(gman): %s\n\n" % func.name) + def WriteServiceImplementation(self, func, file): """Overrriden from TypeHandler.""" file.Write( @@ -2014,47 +2603,50 @@ class GLcharHandler(TypeHandler): def WriteImmediateCmdComputeSize(self, func, file): """Overrriden from TypeHandler.""" - file.Write(" static uint32 ComputeDataSize(const char* s) {\n") - file.Write(" return strlen(s);\n") - file.Write(" }\n") - file.Write("\n") - file.Write(" static uint32 ComputeSize(const char* s) {\n") + file.Write(" static uint32 ComputeSize(uint32 data_size) {\n") file.Write(" return static_cast<uint32>(\n") - file.Write(" sizeof(ValueType) + ComputeDataSize(s)); // NOLINT\n") + file.Write(" sizeof(ValueType) + data_size); // NOLINT\n") file.Write(" }\n") - file.Write("\n") def WriteImmediateCmdSetHeader(self, func, file): """Overrriden from TypeHandler.""" - file.Write(" void SetHeader(const char* s) {\n") - file.Write(" header.SetCmdByTotalSize<ValueType>(ComputeSize(s));\n") - file.Write(" }\n") - file.Write("\n") + code = """ + void SetHeader(uint32 data_size) { + header.SetCmdBySize<ValueType>(data_size); + } +""" + file.Write(code) def WriteImmediateCmdInit(self, func, file): """Overrriden from TypeHandler.""" last_arg = func.GetLastOriginalArg() - file.Write(" void Init(%s) {\n" % func.MakeTypedOriginalArgString("_")) - file.Write(" SetHeader(_%s);\n" % last_arg.name) - args = func.GetCmdArgs()[:-1] + args = func.GetCmdArgs() + set_code = [] for arg in args: - file.Write(" %s = _%s;\n" % (arg.name, arg.name)) - file.Write(" data_size = strlen(_%s);\n" % last_arg.name) - file.Write(" memcpy(ImmediateDataAddress(this), _%s, data_size);\n" % - last_arg.name) - file.Write(" }\n") - file.Write("\n") + set_code.append(" %s = _%s;" % (arg.name, arg.name)) + code = """ + void Init(%(typed_args)s, uint32 _data_size) { + SetHeader(_data_size); +%(set_code)s + memcpy(ImmediateDataAddress(this), _%(last_arg)s, _data_size); + } + +""" + file.Write(code % { + "typed_args": func.MakeTypedOriginalArgString("_"), + "set_code": "\n".join(set_code), + "last_arg": last_arg.name + }) def WriteImmediateCmdSet(self, func, file): """Overrriden from TypeHandler.""" last_arg = func.GetLastOriginalArg() - file.Write(" void* Set(void* cmd%s) {\n" % + file.Write(" void* Set(void* cmd%s, uint32 _data_size) {\n" % func.MakeTypedOriginalArgString("_", True)) - file.Write(" static_cast<ValueType*>(cmd)->Init(%s);\n" % + file.Write(" static_cast<ValueType*>(cmd)->Init(%s, _data_size);\n" % func.MakeOriginalArgString("_")) - file.Write(" const uint32 size = ComputeSize(_%s);\n" % last_arg.name) - file.Write(" return NextImmediateCmdAddressTotalSize<ValueType>(" - "cmd, size);\n") + file.Write(" return NextImmediateCmdAddress<ValueType>(" + "cmd, _data_size);\n") file.Write(" }\n") file.Write("\n") @@ -2064,45 +2656,55 @@ class GLcharHandler(TypeHandler): last_arg = func.GetLastOriginalArg() file.Write(" void %s(%s) {\n" % (func.name, func.MakeTypedOriginalArgString(""))) - file.Write(" const uint32 size = gles2::%s::ComputeSize(%s);\n" % - (func.name, last_arg.name)) - file.Write(" gles2::%s& c = GetImmediateCmdSpaceTotalSize<gles2::%s>(" - "size);\n" % + file.Write(" const uint32 data_size = strlen(name);\n") + file.Write(" gles2::%s& c = GetImmediateCmdSpace<gles2::%s>(" + "data_size);\n" % (func.name, func.name)) - file.Write(" c.Init(%s);\n" % args) + file.Write(" c.Init(%s, data_size);\n" % args) file.Write(" }\n\n") def WriteImmediateFormatTest(self, func, file): """Overrriden from TypeHandler.""" - file.Write("TEST(GLES2FormatTest, %s) {\n" % func.name) - file.Write(" int8 buf[256] = { 0, };\n") - file.Write(" %s& cmd = *static_cast<%s*>(static_cast<void*>(&buf));\n" % - (func.name, func.name)) - file.Write(" static const char* const test_str = \"test string\";\n") - file.Write(" void* next_cmd = cmd.Set(\n") - file.Write(" &cmd") + init_code = [] + check_code = [] all_but_last_arg = func.GetCmdArgs()[:-1] value = 11 for arg in all_but_last_arg: - file.Write(",\n static_cast<%s>(%d)" % (arg.type, value)) + init_code.append(" static_cast<%s>(%d)," % (arg.type, value)) value += 1 - file.Write(",\n test_str);\n") value = 11 - file.Write(" EXPECT_EQ(static_cast<uint32>(%s::kCmdId),\n" % func.name) - file.Write(" cmd.header.command);\n") - file.Write(" EXPECT_EQ(sizeof(cmd) + // NOLINT\n") - file.Write(" RoundSizeToMultipleOfEntries(strlen(test_str)),\n") - file.Write(" cmd.header.size * 4u);\n") - file.Write(" EXPECT_EQ(static_cast<char*>(next_cmd),\n") - file.Write(" reinterpret_cast<char*>(&cmd) + sizeof(cmd) +\n") - file.Write(" strlen(test_str) + 1);\n") for arg in all_but_last_arg: - file.Write(" EXPECT_EQ(static_cast<%s>(%d), cmd.%s);\n" % - (arg.type, value, arg.name)) + check_code.append(" EXPECT_EQ(static_cast<%s>(%d), cmd.%s);" % + (arg.type, value, arg.name)) value += 1 - file.Write(" // TODO(gman): check that string got copied.\n") - file.Write("}\n") - file.Write("\n") + code = """ +TEST(GLES2FormatTest, %(func_name)s) { + int8 buf[256] = { 0, }; + %(func_name)s& cmd = *static_cast<%(func_name)s*>(static_cast<void*>(&buf)); + static const char* const test_str = \"test string\"; + void* next_cmd = cmd.Set( + &cmd, +%(init_code)s + test_str, + strlen(test_str)); + EXPECT_EQ(static_cast<uint32>(%(func_name)s::kCmdId), + cmd.header.command); + EXPECT_EQ(sizeof(cmd) + + RoundSizeToMultipleOfEntries(strlen(test_str)), + cmd.header.size * 4u); + EXPECT_EQ(static_cast<char*>(next_cmd), + reinterpret_cast<char*>(&cmd) + sizeof(cmd) + + RoundSizeToMultipleOfEntries(strlen(test_str))); +%(check_code)s + EXPECT_EQ(static_cast<uint32>(strlen(test_str)), cmd.data_size); + EXPECT_EQ(0, memcmp(test_str, ImmediateDataAddress(&cmd), strlen(test_str))); +} +""" + file.Write(code % { + 'func_name': func.name, + 'init_code': "\n".join(init_code), + 'check_code': "\n".join(check_code), + }) class GetGLcharHandler(GLcharHandler): """Handler for glGetAttibLoc, glGetUniformLoc.""" @@ -2110,6 +2712,14 @@ class GetGLcharHandler(GLcharHandler): def __init__(self): GLcharHandler.__init__(self) + def WriteServiceUnitTest(self, func, file): + """Overrriden from TypeHandler.""" + file.Write("// TODO(gman): %s\n\n" % func.name) + + def WriteImmediateServiceUnitTest(self, func, file): + """Overrriden from TypeHandler.""" + file.Write("// TODO(gman): %s\n\n" % func.name) + def WriteServiceImplementation(self, func, file): """Overrriden from TypeHandler.""" file.Write( @@ -2261,7 +2871,7 @@ class GetGLcharHandler(GLcharHandler): file.Write(",\n test_str);\n") value = 11 file.Write(" EXPECT_EQ(%s::kCmdId ^ cmd.header.command);\n" % func.name) - file.Write(" EXPECT_EQ(sizeof(cmd) + // NOLINT\n") + file.Write(" EXPECT_EQ(sizeof(cmd)\n") file.Write(" RoundSizeToMultipleOfEntries(strlen(test_str)),\n") file.Write(" cmd.header.size * 4u);\n") file.Write(" EXPECT_EQ(static_cast<char*>(next_cmd),\n") @@ -2286,6 +2896,37 @@ class IsHandler(TypeHandler): func.AddCmdArg(Argument("result_shm_id", 'uint32')) func.AddCmdArg(Argument("result_shm_offset", 'uint32')) + def WriteServiceUnitTest(self, func, file): + """Overrriden from TypeHandler.""" + valid_test = """ +TEST_F(GLES2DecoderTest, %(name)sValidArgs) { + EXPECT_CALL(*gl_, %(gl_func_name)s(%(gl_args)s)); + SpecializedSetup<%(name)s, 0>(); + %(name)s cmd; + cmd.Init(%(args)s%(comma)sshared_memory_id_, shared_memory_offset_); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} +""" + comma = "" + if len(func.GetOriginalArgs()): + comma =", " + self.WriteValidUnitTest(func, file, valid_test, { + 'comma': comma, + }) + + invalid_test = """ +TEST_F(GLES2DecoderTest, %(name)sInvalidArgs%(arg_index)d_%(value_index)d) { + EXPECT_CALL(*gl_, %(gl_func_name)s(%(gl_args)s)).Times(0); + SpecializedSetup<%(name)s, 0>(); + %(name)s cmd; + cmd.Init(%(args)s%(comma)sshared_memory_id_, shared_memory_offset_); + EXPECT_EQ(parse_error::%(parse_result)s, ExecuteCmd(cmd)); +} +""" + self.WriteInvalidUnitTest(func, file, invalid_test, { + 'comma': comma, + }) + def WriteServiceImplementation(self, func, file): """Overrriden from TypeHandler.""" file.Write( @@ -2340,6 +2981,14 @@ class STRnHandler(TypeHandler): file.Write("// TODO(gman): Implement this\n") TypeHandler.WriteGLES2ImplementationHeader(self, func, file) + def WriteServiceUnitTest(self, func, file): + """Overrriden from TypeHandler.""" + file.Write("// TODO(gman): %s\n\n" % func.name) + + def WriteImmediateServiceUnitTest(self, func, file): + """Overrriden from TypeHandler.""" + file.Write("// TODO(gman): %s\n\n" % func.name) + def WriteServiceImplementation(self, func, file): """Overrriden from TypeHandler.""" file.Write( @@ -2421,6 +3070,20 @@ class Argument(object): """Adds init arguments for this argument to the given list.""" return args.append(self) + def GetValidArg(self, offset, index): + return str(offset + 1) + + def GetValidGLArg(self, offset, index): + return str(offset + 1) + + def GetNumInvalidValues(self): + """returns the number of invalid values to be tested.""" + return 0 + + def GetInvalidArg(self, offset, index): + """returns an invalid value and expected parse result by index.""" + return ("---ERROR0---", "---ERROR2---") + def WriteGetCode(self, file): """Writes the code to get an argument from a command structure.""" file.Write(" %s %s = static_cast<%s>(c.%s);\n" % @@ -2438,23 +3101,61 @@ class Argument(object): """Gets the immediate version of this argument.""" return self +class EnumBaseArgument(Argument): + """Base calss for EnumArgument, IntArgument and BoolArgument""" -class EnumArgument(Argument): - """A class that represents a GLenum argument""" + def __init__(self, name, gl_type, type, gl_error): + Argument.__init__(self, name, gl_type) - def __init__(self, name, type): - Argument.__init__(self, name, "GLenum") - - self.enum_type = type + self.local_type = type + self.gl_error = gl_error + name = type[len(gl_type):] + self.enum_info = _ENUM_LISTS[name] def WriteValidationCode(self, file): - file.Write(" if (!Validate%s(%s)) {\n" % (self.enum_type, self.name)) - file.Write(" SetGLError(GL_INVALID_ENUM);\n") + file.Write(" if (!Validate%s(%s)) {\n" % (self.local_type, self.name)) + file.Write(" SetGLError(%s);\n" % self.gl_error) file.Write(" return parse_error::kParseNoError;\n") file.Write(" }\n") + def GetValidArg(self, offset, index): + if 'valid' in self.enum_info: + valid = self.enum_info['valid'] + num_valid = len(valid) + if index >= num_valid: + index = num_valid - 1 + return valid[index] + return str(offset + 1) + + def GetValidGLArg(self, offset, index): + return self.GetValidArg(offset, index) + + def GetNumInvalidValues(self): + """returns the number of invalid values to be tested.""" + if 'invalid' in self.enum_info: + invalid = self.enum_info['invalid'] + return len(invalid) + return 0 + + def GetInvalidArg(self, offset, index): + """returns an invalid value by index.""" + if 'invalid' in self.enum_info: + invalid = self.enum_info['invalid'] + num_invalid = len(invalid) + if index >= num_invalid: + index = num_invalid - 1 + return (invalid[index], "kParseNoError") + return ("---ERROR1---", "kParseNoError") + + +class EnumArgument(EnumBaseArgument): + """A class that represents a GLenum argument""" + + def __init__(self, name, type): + EnumBaseArgument.__init__(self, name, "GLenum", type, "GL_INVALID_ENUM") + -class IntArgument(Argument): +class IntArgument(EnumBaseArgument): """A class for a GLint argument that can only except specific values. For example glTexImage2D takes a GLint for its internalformat @@ -2462,15 +3163,18 @@ class IntArgument(Argument): """ def __init__(self, name, type): - Argument.__init__(self, name, "GLint") + EnumBaseArgument.__init__(self, name, "GLint", type, "GL_INVALID_VALUE") - self.int_type = type - def WriteValidationCode(self, file): - file.Write(" if (!Validate%s(%s)) {\n" % (self.int_type, self.name)) - file.Write(" SetGLError(GL_INVALID_VALUE);\n") - file.Write(" return parse_error::kParseNoError;\n") - file.Write(" }\n") +class BoolArgument(EnumBaseArgument): + """A class for a GLboolean argument that can only except specific values. + + For example glUniformMatrix takes a GLboolean for it's transpose but it + must be false. + """ + + def __init__(self, name, type): + EnumBaseArgument.__init__(self, name, "GLboolean", type, "GL_INVALID_VALUE") class ImmediatePointerArgument(Argument): @@ -2514,6 +3218,26 @@ class PointerArgument(Argument): """Returns true if argument is a pointer.""" return True + def GetValidArg(self, offset, index): + """Overridden from Argument.""" + return "shared_memory_id_, shared_memory_offset_" + + def GetValidGLArg(self, offset, index): + """Overridden from Argument.""" + return "reinterpret_cast<%s>(shared_memory_address_)" % self.type + + def GetNumInvalidValues(self): + """Overridden from Argument.""" + return 2 + + def GetInvalidArg(self, offset, index): + """Overridden from Argument.""" + if index == 0: + return ("kInvalidSharedMemoryId, 0", "kParseOutOfBounds") + else: + return ("shared_memory_id_, kInvalidSharedMemoryOffset", + "kParseOutOfBounds") + def AddCmdArgs(self, args): """Overridden from Argument.""" args.append(Argument("%s_shm_id" % self.name, 'uint32')) @@ -2567,7 +3291,9 @@ class ResourceIdArgument(Argument): """A class that represents a resource id argument to a function.""" def __init__(self, name, type): - type = type.replace("GLResourceId", "GLuint") + match = re.match("(GLid\w+)", type) + self.resource_type = match.group(1)[4:] + type = type.replace(match.group(1), "GLuint") Argument.__init__(self, name, type) def WriteGetCode(self, file): @@ -2579,6 +3305,11 @@ class ResourceIdArgument(Argument): file.Write(" return parse_error::kParseNoError;\n") file.Write(" }\n") + def GetValidArg(self, offset, index): + return "client_%s_id_" % self.resource_type.lower() + + def GetValidGLArg(self, offset, index): + return "kService%sId" % self.resource_type class Function(object): """A class that represents a function.""" @@ -2614,6 +3345,16 @@ class Function(object): return self.GetInfo('DecoderFunc') return "gl%s" % self.original_name + def GetGLTestFunctionName(self): + gl_func_name = self.GetInfo('gl_test_func') + if gl_func_name == None: + gl_func_name = self.GetGLFunctionName() + if gl_func_name.startswith("gl"): + gl_func_name = gl_func_name[2:] + else: + gl_func_name = self.name + return gl_func_name + def AddCmdArg(self, arg): """Adds a cmd argument to this function.""" self.cmd_args.append(arg) @@ -2747,6 +3488,10 @@ class Function(object): """Writes the service implementation for a command.""" self.type_handler.WriteServiceImplementation(self, file) + def WriteServiceUnitTest(self, file): + """Writes the service implementation for a command.""" + self.type_handler.WriteServiceUnitTest(self, file) + def WriteGLES2ImplementationHeader(self, file): """Writes the GLES2 Implemention declaration.""" self.type_handler.WriteGLES2ImplementationHeader(self, file) @@ -2802,6 +3547,10 @@ class ImmediateFunction(Function): """Overridden from Function""" self.type_handler.WriteImmediateHandlerImplementation(self, file) + def WriteServiceUnitTest(self, file): + """Writes the service implementation for a command.""" + self.type_handler.WriteImmediateServiceUnitTest(self, file) + def WriteValidationCode(self, file): """Overridden from Function""" self.type_handler.WriteImmediateValidationCode(self, file) @@ -2851,12 +3600,12 @@ def CreateArg(arg_string): arg_parts[-1], " ".join(arg_parts[0:-1])) # Is this a resource argument? Must come after pointer check. - elif arg_parts[0] == 'GLResourceId': - return ResourceIdArgument( - arg_parts[-1], - " ".join(arg_parts[0:-1])) + elif arg_parts[0].startswith('GLid'): + return ResourceIdArgument(arg_parts[-1], " ".join(arg_parts[0:-1])) elif arg_parts[0].startswith('GLenum') and len(arg_parts[0]) > 6: return EnumArgument(arg_parts[-1], " ".join(arg_parts[0:-1])) + elif arg_parts[0].startswith('GLboolean') and len(arg_parts[0]) > 9: + return BoolArgument(arg_parts[-1], " ".join(arg_parts[0:-1])) elif (arg_parts[0].startswith('GLint') and len(arg_parts[0]) > 5 and arg_parts[0] != "GLintptr"): return IntArgument(arg_parts[-1], " ".join(arg_parts[0:-1])) @@ -2868,7 +3617,6 @@ class GLGenerator(object): """A class to generate GL command buffers.""" _function_re = re.compile(r'GL_APICALL(.*?)GL_APIENTRY (.*?) \((.*?)\);') - _non_alnum_re = re.compile(r'[^a-zA-Z0-9]') def __init__(self, verbose): self.original_functions = [] @@ -2931,12 +3679,6 @@ class GLGenerator(object): print "Error: %s" % msg self.errors += 1 - def WriteHeader(self, file): - """Writes header to file""" - file.Write( - "// This file is auto-generated. DO NOT EDIT!\n" - "\n") - def WriteLicense(self, file): """Writes the license.""" file.Write(_LICENSE) @@ -2953,13 +3695,6 @@ class GLGenerator(object): file.Write("} // namespace gpu\n") file.Write("\n") - def MakeGuard(self, filename): - """Creates a header guard id.""" - base = os.path.dirname(os.path.dirname(os.path.dirname( - os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))) - hpath = os.path.abspath(filename)[len(base) + 1:] - return self._non_alnum_re.sub('_', hpath).upper() - def ParseArgs(self, arg_string): """Parses a function arg string.""" args = [] @@ -3022,8 +3757,7 @@ class GLGenerator(object): def WriteCommandIds(self, filename): """Writes the command buffer format""" - file = CWriter(filename) - self.WriteHeader(file) + file = CHeaderWriter(filename) file.Write("#define GLES2_COMMAND_LIST(OP) \\\n") for func in self.functions: if not func.name in _CMD_ID_TABLE: @@ -3045,22 +3779,19 @@ class GLGenerator(object): def WriteFormat(self, filename): """Writes the command buffer format""" - file = CWriter(filename) - self.WriteHeader(file) - + file = CHeaderWriter(filename) for func in self.functions: func.WriteStruct(file) - file.Write("\n") file.Close() def WriteFormatTest(self, filename): """Writes the command buffer format test.""" - file = CWriter(filename) - self.WriteHeader(file) - file.Write("// This file contains unit tests for gles2 commmands\n") - file.Write("// It is included by gles2_cmd_format_test.cc\n") - file.Write("\n") + file = CHeaderWriter( + filename, + "// This file contains unit tests for gles2 commmands\n" + "// It is included by gles2_cmd_format_test.cc\n" + "\n") for func in self.functions: func.WriteFormatTest(file) @@ -3069,9 +3800,9 @@ class GLGenerator(object): def WriteCommandIdTest(self, filename): """Writes the command id test.""" - file = CWriter(filename) - file.Write("// This file contains unit tests for gles2 commmand ids\n") - file.Write("\n") + file = CHeaderWriter( + filename, + "// This file contains unit tests for gles2 commmand ids\n") file.Write("// *** These IDs MUST NOT CHANGE!!! ***\n") file.Write("// Changing them will break all client programs.\n") @@ -3089,7 +3820,7 @@ class GLGenerator(object): def WriteCmdHelperHeader(self, filename): """Writes the gles2 command helper.""" - file = CWriter(filename) + file = CHeaderWriter(filename) for func in self.functions: func.WriteCmdHelper(file) @@ -3098,24 +3829,32 @@ class GLGenerator(object): def WriteServiceImplementation(self, filename): """Writes the service decorder implementation.""" - file = CWriter(filename) - self.WriteHeader(file) - file.Write("// It is included by gles2_cmd_decoder.cc\n") - file.Write("\n") + file = CHeaderWriter( + filename, + "// It is included by gles2_cmd_decoder.cc\n") for func in self.functions: func.WriteServiceImplementation(file) file.Close() + def WriteServiceUnitTests(self, filename): + """Writes the service decorder unit tests.""" + file = CHeaderWriter( + filename, + "// It is included by gles2_cmd_decoder_unittest.cc\n") + + for func in self.functions: + func.WriteServiceUnitTest(file) + + file.Close() + + def WriteGLES2CLibImplementation(self, filename): """Writes the GLES2 c lib implementation.""" - file = CWriter(filename) - self.WriteHeader(file) - file.Write("\n") - file.Write("// These functions emluate GLES2 over command buffers.\n") - file.Write("\n") - file.Write("\n") + file = CHeaderWriter( + filename, + "// These functions emluate GLES2 over command buffers.\n") for func in self.original_functions: file.Write("%s GLES2%s(%s) {\n" % @@ -3135,25 +3874,21 @@ class GLGenerator(object): def WriteGLES2ImplementationHeader(self, filename): """Writes the GLES2 helper header.""" - file = CWriter(filename) - self.WriteHeader(file) - file.Write( - "// This file is included by gles2_implementation.h to declare the\n") - file.Write("// GL api functions.\n") + file = CHeaderWriter( + filename, + "// This file is included by gles2_implementation.h to declare the\n" + "// GL api functions.\n") for func in self.original_functions: func.WriteGLES2ImplementationHeader(file) file.Close() def WriteGLES2ImplementationImpl(self, filename): """Writes the gles2 helper implementation.""" - file = CWriter(filename) - self.WriteLicense(file) - file.Write("\n") - file.Write("// A class to emluate GLES2 over command buffers.\n") - file.Write("\n") + file = CHeaderWriter( + filename, + "// A class to emluate GLES2 over command buffers.\n") file.Write( "#include \"gpu/command_buffer/client/gles2_implementation.h\"\n") - file.Write("\n") self.WriteNamespaceOpen(file) for func in self.original_functions: func.WriteGLES2ImplementationImpl(file) @@ -3164,23 +3899,19 @@ class GLGenerator(object): def WriteServiceUtilsHeader(self, filename): """Writes the gles2 auto generated utility header.""" - file = CWriter(filename) - self.WriteHeader(file) - file.Write("\n") + file = CHeaderWriter(filename) for enum in _ENUM_LISTS: - file.Write("bool ValidateGLenum%s(GLenum value);\n" % enum) + file.Write("bool Validate%s%s(GLenum value);\n" % (_ENUM_LISTS[enum]['type'], enum)) file.Write("\n") file.Close() def WriteServiceUtilsImplementation(self, filename): """Writes the gles2 auto generated utility implementation.""" - file = CWriter(filename) - self.WriteHeader(file) - file.Write("\n") + file = CHeaderWriter(filename) for enum in _ENUM_LISTS: - file.Write("bool ValidateGLenum%s(GLenum value) {\n" % enum) + file.Write("bool Validate%s%s(GLenum value) {\n" % (_ENUM_LISTS[enum]['type'], enum)) file.Write(" switch (value) {\n") - for value in _ENUM_LISTS[enum]: + for value in _ENUM_LISTS[enum]['valid']: file.Write(" case %s:\n" % value) file.Write(" return true;\n") file.Write(" default:\n") @@ -3215,6 +3946,7 @@ def main(argv): gen.WriteGLES2CLibImplementation("client/gles2_c_lib_autogen.h") gen.WriteCmdHelperHeader("client/gles2_cmd_helper_autogen.h") gen.WriteServiceImplementation("service/gles2_cmd_decoder_autogen.h") + gen.WriteServiceUnitTests("service/gles2_cmd_decoder_unittest_autogen.h") gen.WriteServiceUtilsHeader("service/gles2_cmd_validation_autogen.h") gen.WriteServiceUtilsImplementation( "service/gles2_cmd_validation_implementation_autogen.h") diff --git a/gpu/command_buffer/client/gles2_c_lib_autogen.h b/gpu/command_buffer/client/gles2_c_lib_autogen.h index 76f0973..3aef7b8 100644 --- a/gpu/command_buffer/client/gles2_c_lib_autogen.h +++ b/gpu/command_buffer/client/gles2_c_lib_autogen.h @@ -1,8 +1,12 @@ -// This file is auto-generated. DO NOT EDIT! +// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// This file is auto-generated. DO NOT EDIT! // These functions emluate GLES2 over command buffers. - +#ifndef GPU_COMMAND_BUFFER_CLIENT_GLES2_C_LIB_AUTOGEN_H_ +#define GPU_COMMAND_BUFFER_CLIENT_GLES2_C_LIB_AUTOGEN_H_ void GLES2ActiveTexture(GLenum texture) { gles2::GetGLContext()->ActiveTexture(texture); @@ -76,32 +80,26 @@ void GLES2CompileShader(GLuint shader) { void GLES2CompressedTexImage2D( GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void* data) { - gles2::GetGLContext( - )->CompressedTexImage2D( - target, level, internalformat, width, height, border, imageSize, - data); + gles2::GetGLContext()->CompressedTexImage2D( + target, level, internalformat, width, height, border, imageSize, data); } void GLES2CompressedTexSubImage2D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void* data) { - gles2::GetGLContext( - )->CompressedTexSubImage2D( - target, level, xoffset, yoffset, width, height, format, imageSize, - data); + gles2::GetGLContext()->CompressedTexSubImage2D( + target, level, xoffset, yoffset, width, height, format, imageSize, data); } void GLES2CopyTexImage2D( GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border) { - gles2::GetGLContext( - )->CopyTexImage2D( - target, level, internalformat, x, y, width, height, border); + gles2::GetGLContext()->CopyTexImage2D( + target, level, internalformat, x, y, width, height, border); } void GLES2CopyTexSubImage2D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height) { - gles2::GetGLContext( - )->CopyTexSubImage2D( - target, level, xoffset, yoffset, x, y, width, height); + gles2::GetGLContext()->CopyTexSubImage2D( + target, level, xoffset, yoffset, x, y, width, height); } GLuint GLES2CreateProgram() { return gles2::GetGLContext()->CreateProgram(); @@ -170,15 +168,14 @@ void GLES2Flush() { void GLES2FramebufferRenderbuffer( GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer) { - gles2::GetGLContext( - )->FramebufferRenderbuffer( - target, attachment, renderbuffertarget, renderbuffer); + gles2::GetGLContext()->FramebufferRenderbuffer( + target, attachment, renderbuffertarget, renderbuffer); } void GLES2FramebufferTexture2D( GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level) { - gles2::GetGLContext( - )->FramebufferTexture2D(target, attachment, textarget, texture, level); + gles2::GetGLContext()->FramebufferTexture2D( + target, attachment, textarget, texture, level); } void GLES2FrontFace(GLenum mode) { gles2::GetGLContext()->FrontFace(mode); @@ -201,14 +198,14 @@ void GLES2GenTextures(GLsizei n, GLuint* textures) { void GLES2GetActiveAttrib( GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name) { - gles2::GetGLContext( - )->GetActiveAttrib(program, index, bufsize, length, size, type, name); + gles2::GetGLContext()->GetActiveAttrib( + program, index, bufsize, length, size, type, name); } void GLES2GetActiveUniform( GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name) { - gles2::GetGLContext( - )->GetActiveUniform(program, index, bufsize, length, size, type, name); + gles2::GetGLContext()->GetActiveUniform( + program, index, bufsize, length, size, type, name); } void GLES2GetAttachedShaders( GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders) { @@ -231,9 +228,8 @@ void GLES2GetFloatv(GLenum pname, GLfloat* params) { } void GLES2GetFramebufferAttachmentParameteriv( GLenum target, GLenum attachment, GLenum pname, GLint* params) { - gles2::GetGLContext( - )->GetFramebufferAttachmentParameteriv( - target, attachment, pname, params); + gles2::GetGLContext()->GetFramebufferAttachmentParameteriv( + target, attachment, pname, params); } void GLES2GetIntegerv(GLenum pname, GLint* params) { gles2::GetGLContext()->GetIntegerv(pname, params); @@ -258,8 +254,8 @@ void GLES2GetShaderInfoLog( } void GLES2GetShaderPrecisionFormat( GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision) { - gles2::GetGLContext( - )->GetShaderPrecisionFormat(shadertype, precisiontype, range, precision); + gles2::GetGLContext()->GetShaderPrecisionFormat( + shadertype, precisiontype, range, precision); } void GLES2GetShaderSource( GLuint shader, GLsizei bufsize, GLsizei* length, char* source) { @@ -335,8 +331,8 @@ void GLES2ReadPixels( } void GLES2RenderbufferStorage( GLenum target, GLenum internalformat, GLsizei width, GLsizei height) { - gles2::GetGLContext( - )->RenderbufferStorage(target, internalformat, width, height); + gles2::GetGLContext()->RenderbufferStorage( + target, internalformat, width, height); } void GLES2SampleCoverage(GLclampf value, GLboolean invert) { gles2::GetGLContext()->SampleCoverage(value, invert); @@ -345,8 +341,8 @@ void GLES2Scissor(GLint x, GLint y, GLsizei width, GLsizei height) { gles2::GetGLContext()->Scissor(x, y, width, height); } void GLES2ShaderSource( - GLuint shader, GLsizei count, const char** string, const GLint* length) { - gles2::GetGLContext()->ShaderSource(shader, count, string, length); + GLuint shader, GLsizei count, const char** str, const GLint* length) { + gles2::GetGLContext()->ShaderSource(shader, count, str, length); } void GLES2StencilFunc(GLenum func, GLint ref, GLuint mask) { gles2::GetGLContext()->StencilFunc(func, ref, mask); @@ -372,10 +368,9 @@ void GLES2TexImage2D( GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void* pixels) { - gles2::GetGLContext( - )->TexImage2D( - target, level, internalformat, width, height, border, format, type, - pixels); + gles2::GetGLContext()->TexImage2D( + target, level, internalformat, width, height, border, format, type, + pixels); } void GLES2TexParameterf(GLenum target, GLenum pname, GLfloat param) { gles2::GetGLContext()->TexParameterf(target, pname, param); @@ -392,10 +387,8 @@ void GLES2TexParameteriv(GLenum target, GLenum pname, const GLint* params) { void GLES2TexSubImage2D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void* pixels) { - gles2::GetGLContext( - )->TexSubImage2D( - target, level, xoffset, yoffset, width, height, format, type, - pixels); + gles2::GetGLContext()->TexSubImage2D( + target, level, xoffset, yoffset, width, height, format, type, pixels); } void GLES2Uniform1f(GLint location, GLfloat x) { gles2::GetGLContext()->Uniform1f(location, x); @@ -492,8 +485,8 @@ void GLES2VertexAttrib4fv(GLuint indx, const GLfloat* values) { void GLES2VertexAttribPointer( GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void* ptr) { - gles2::GetGLContext( - )->VertexAttribPointer(indx, size, type, normalized, stride, ptr); + gles2::GetGLContext()->VertexAttribPointer( + indx, size, type, normalized, stride, ptr); } void GLES2Viewport(GLint x, GLint y, GLsizei width, GLsizei height) { gles2::GetGLContext()->Viewport(x, y, width, height); @@ -502,3 +495,5 @@ void GLES2SwapBuffers() { gles2::GetGLContext()->SwapBuffers(); } +#endif // GPU_COMMAND_BUFFER_CLIENT_GLES2_C_LIB_AUTOGEN_H_ + diff --git a/gpu/command_buffer/client/gles2_cmd_helper_autogen.h b/gpu/command_buffer/client/gles2_cmd_helper_autogen.h index f05c14b..66eea9d 100644 --- a/gpu/command_buffer/client/gles2_cmd_helper_autogen.h +++ b/gpu/command_buffer/client/gles2_cmd_helper_autogen.h @@ -1,3 +1,12 @@ +// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// This file is auto-generated. DO NOT EDIT! + +#ifndef GPU_COMMAND_BUFFER_CLIENT_GLES2_CMD_HELPER_AUTOGEN_H_ +#define GPU_COMMAND_BUFFER_CLIENT_GLES2_CMD_HELPER_AUTOGEN_H_ + void ActiveTexture(GLenum texture) { gles2::ActiveTexture& c = GetCmdSpace<gles2::ActiveTexture>(); c.Init(texture); @@ -17,11 +26,10 @@ void BindAttribLocationImmediate( GLuint program, GLuint index, const char* name) { - const uint32 size = gles2::BindAttribLocationImmediate::ComputeSize(name); + const uint32 data_size = strlen(name); gles2::BindAttribLocationImmediate& c = - GetImmediateCmdSpaceTotalSize<gles2::BindAttribLocationImmediate>( - size); - c.Init(program, index, name); + GetImmediateCmdSpace<gles2::BindAttribLocationImmediate>(data_size); + c.Init(program, index, name, data_size); } void BindBuffer(GLenum target, GLuint buffer) { @@ -1112,3 +1120,5 @@ c.Init(); } +#endif // GPU_COMMAND_BUFFER_CLIENT_GLES2_CMD_HELPER_AUTOGEN_H_ + diff --git a/gpu/command_buffer/client/gles2_implementation_autogen.h b/gpu/command_buffer/client/gles2_implementation_autogen.h index c4b34b9..bb7b253 100644 --- a/gpu/command_buffer/client/gles2_implementation_autogen.h +++ b/gpu/command_buffer/client/gles2_implementation_autogen.h @@ -1,7 +1,14 @@ +// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + // This file is auto-generated. DO NOT EDIT! // This file is included by gles2_implementation.h to declare the // GL api functions. +#ifndef GPU_COMMAND_BUFFER_CLIENT_GLES2_IMPLEMENTATION_AUTOGEN_H_ +#define GPU_COMMAND_BUFFER_CLIENT_GLES2_IMPLEMENTATION_AUTOGEN_H_ + void ActiveTexture(GLenum texture) { helper_->ActiveTexture(texture); } @@ -467,7 +474,7 @@ void Scissor(GLint x, GLint y, GLsizei width, GLsizei height) { } void ShaderSource( - GLuint shader, GLsizei count, const char** string, const GLint* length); + GLuint shader, GLsizei count, const char** str, const GLint* length); void StencilFunc(GLenum func, GLint ref, GLuint mask) { helper_->StencilFunc(func, ref, mask); @@ -649,3 +656,5 @@ void SwapBuffers() { helper_->SwapBuffers(); } +#endif // GPU_COMMAND_BUFFER_CLIENT_GLES2_IMPLEMENTATION_AUTOGEN_H_ + diff --git a/gpu/command_buffer/client/gles2_implementation_gen.h b/gpu/command_buffer/client/gles2_implementation_gen.h index 0926960..a6b4ebd 100644 --- a/gpu/command_buffer/client/gles2_implementation_gen.h +++ b/gpu/command_buffer/client/gles2_implementation_gen.h @@ -1,13 +1,14 @@ - // Copyright (c) 2009 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +// This file is auto-generated. DO NOT EDIT! // A class to emluate GLES2 over command buffers. +#ifndef GPU_COMMAND_BUFFER_CLIENT_GLES2_IMPLEMENTATION_GEN_H_ +#define GPU_COMMAND_BUFFER_CLIENT_GLES2_IMPLEMENTATION_GEN_H_ #include "gpu/command_buffer/client/gles2_implementation.h" - namespace gpu { namespace gles2 { @@ -70,3 +71,5 @@ void GLES2Implementation::ReadPixels( } // namespace gles2 } // namespace gpu +#endif // GPU_COMMAND_BUFFER_CLIENT_GLES2_IMPLEMENTATION_GEN_H_ + diff --git a/gpu/command_buffer/common/gles2_cmd_format_autogen.h b/gpu/command_buffer/common/gles2_cmd_format_autogen.h index 5bff473..868fac1 100644 --- a/gpu/command_buffer/common/gles2_cmd_format_autogen.h +++ b/gpu/command_buffer/common/gles2_cmd_format_autogen.h @@ -1,5 +1,12 @@ +// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + // This file is auto-generated. DO NOT EDIT! +#ifndef GPU_COMMAND_BUFFER_COMMON_GLES2_CMD_FORMAT_AUTOGEN_H_ +#define GPU_COMMAND_BUFFER_COMMON_GLES2_CMD_FORMAT_AUTOGEN_H_ + struct ActiveTexture { typedef ActiveTexture ValueType; static const CommandId kCmdId = kActiveTexture; @@ -133,31 +140,29 @@ struct BindAttribLocationImmediate { static const CommandId kCmdId = kBindAttribLocationImmediate; static const cmd::ArgFlags kArgFlags = cmd::kAtLeastN; - static uint32 ComputeDataSize(const char* s) { - return strlen(s); - } - - static uint32 ComputeSize(const char* s) { + static uint32 ComputeSize(uint32 data_size) { return static_cast<uint32>( - sizeof(ValueType) + ComputeDataSize(s)); // NOLINT + sizeof(ValueType) + data_size); // NOLINT } - void SetHeader(const char* s) { - header.SetCmdByTotalSize<ValueType>(ComputeSize(s)); + void SetHeader(uint32 data_size) { + header.SetCmdBySize<ValueType>(data_size); } - void Init(GLuint _program, GLuint _index, const char* _name) { - SetHeader(_name); + void Init( + GLuint _program, GLuint _index, const char* _name, uint32 _data_size) { + SetHeader(_data_size); program = _program; index = _index; - data_size = strlen(_name); - memcpy(ImmediateDataAddress(this), _name, data_size); + data_size = _data_size; + memcpy(ImmediateDataAddress(this), _name, _data_size); } - void* Set(void* cmd, GLuint _program, GLuint _index, const char* _name) { - static_cast<ValueType*>(cmd)->Init(_program, _index, _name); - const uint32 size = ComputeSize(_name); - return NextImmediateCmdAddressTotalSize<ValueType>(cmd, size); + void* Set( + void* cmd, GLuint _program, GLuint _index, const char* _name, + uint32 _data_size) { + static_cast<ValueType*>(cmd)->Init(_program, _index, _name, _data_size); + return NextImmediateCmdAddress<ValueType>(cmd, _data_size); } gpu::CommandHeader header; @@ -8081,3 +8086,5 @@ COMPILE_ASSERT(offsetof(SwapBuffers, header) == 0, OffsetOf_SwapBuffers_header_not_0); +#endif // GPU_COMMAND_BUFFER_COMMON_GLES2_CMD_FORMAT_AUTOGEN_H_ + diff --git a/gpu/command_buffer/common/gles2_cmd_format_test_autogen.h b/gpu/command_buffer/common/gles2_cmd_format_test_autogen.h index e00e834..6dbd8a0c 100644 --- a/gpu/command_buffer/common/gles2_cmd_format_test_autogen.h +++ b/gpu/command_buffer/common/gles2_cmd_format_test_autogen.h @@ -1,30 +1,37 @@ +// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + // This file is auto-generated. DO NOT EDIT! // This file contains unit tests for gles2 commmands // It is included by gles2_cmd_format_test.cc +#ifndef GPU_COMMAND_BUFFER_COMMON_GLES2_CMD_FORMAT_TEST_AUTOGEN_H_ +#define GPU_COMMAND_BUFFER_COMMON_GLES2_CMD_FORMAT_TEST_AUTOGEN_H_ + TEST(GLES2FormatTest, ActiveTexture) { - ActiveTexture cmd = {{0}}; + ActiveTexture cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, static_cast<GLenum>(11)); EXPECT_EQ(static_cast<uint32>(ActiveTexture::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<GLenum>(11), cmd.texture); } TEST(GLES2FormatTest, AttachShader) { - AttachShader cmd = {{0}}; + AttachShader cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, static_cast<GLuint>(11), static_cast<GLuint>(12)); EXPECT_EQ(static_cast<uint32>(AttachShader::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<GLuint>(11), cmd.program); @@ -32,7 +39,7 @@ TEST(GLES2FormatTest, AttachShader) { } TEST(GLES2FormatTest, BindAttribLocation) { - BindAttribLocation cmd = {{0}}; + BindAttribLocation cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, static_cast<GLuint>(11), @@ -42,7 +49,7 @@ TEST(GLES2FormatTest, BindAttribLocation) { static_cast<uint32>(15)); EXPECT_EQ(static_cast<uint32>(BindAttribLocation::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<GLuint>(11), cmd.program); @@ -52,6 +59,7 @@ TEST(GLES2FormatTest, BindAttribLocation) { EXPECT_EQ(static_cast<uint32>(15), cmd.data_size); } + TEST(GLES2FormatTest, BindAttribLocationImmediate) { int8 buf[256] = { 0, }; BindAttribLocationImmediate& cmd = @@ -61,29 +69,30 @@ TEST(GLES2FormatTest, BindAttribLocationImmediate) { &cmd, static_cast<GLuint>(11), static_cast<GLuint>(12), - test_str); + test_str, + strlen(test_str)); EXPECT_EQ(static_cast<uint32>(BindAttribLocationImmediate::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd) + // NOLINT + EXPECT_EQ(sizeof(cmd) + RoundSizeToMultipleOfEntries(strlen(test_str)), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd) + - strlen(test_str) + 1); + RoundSizeToMultipleOfEntries(strlen(test_str))); EXPECT_EQ(static_cast<GLuint>(11), cmd.program); EXPECT_EQ(static_cast<GLuint>(12), cmd.index); - // TODO(gman): check that string got copied. + EXPECT_EQ(static_cast<uint32>(strlen(test_str)), cmd.data_size); + EXPECT_EQ(0, memcmp(test_str, ImmediateDataAddress(&cmd), strlen(test_str))); } - TEST(GLES2FormatTest, BindBuffer) { - BindBuffer cmd = {{0}}; + BindBuffer cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, static_cast<GLenum>(11), static_cast<GLuint>(12)); EXPECT_EQ(static_cast<uint32>(BindBuffer::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<GLenum>(11), cmd.target); @@ -91,14 +100,14 @@ TEST(GLES2FormatTest, BindBuffer) { } TEST(GLES2FormatTest, BindFramebuffer) { - BindFramebuffer cmd = {{0}}; + BindFramebuffer cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, static_cast<GLenum>(11), static_cast<GLuint>(12)); EXPECT_EQ(static_cast<uint32>(BindFramebuffer::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<GLenum>(11), cmd.target); @@ -106,14 +115,14 @@ TEST(GLES2FormatTest, BindFramebuffer) { } TEST(GLES2FormatTest, BindRenderbuffer) { - BindRenderbuffer cmd = {{0}}; + BindRenderbuffer cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, static_cast<GLenum>(11), static_cast<GLuint>(12)); EXPECT_EQ(static_cast<uint32>(BindRenderbuffer::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<GLenum>(11), cmd.target); @@ -121,14 +130,14 @@ TEST(GLES2FormatTest, BindRenderbuffer) { } TEST(GLES2FormatTest, BindTexture) { - BindTexture cmd = {{0}}; + BindTexture cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, static_cast<GLenum>(11), static_cast<GLuint>(12)); EXPECT_EQ(static_cast<uint32>(BindTexture::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<GLenum>(11), cmd.target); @@ -136,7 +145,7 @@ TEST(GLES2FormatTest, BindTexture) { } TEST(GLES2FormatTest, BlendColor) { - BlendColor cmd = {{0}}; + BlendColor cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, static_cast<GLclampf>(11), @@ -145,7 +154,7 @@ TEST(GLES2FormatTest, BlendColor) { static_cast<GLclampf>(14)); EXPECT_EQ(static_cast<uint32>(BlendColor::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<GLclampf>(11), cmd.red); @@ -155,27 +164,27 @@ TEST(GLES2FormatTest, BlendColor) { } TEST(GLES2FormatTest, BlendEquation) { - BlendEquation cmd = {{0}}; + BlendEquation cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, static_cast<GLenum>(11)); EXPECT_EQ(static_cast<uint32>(BlendEquation::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<GLenum>(11), cmd.mode); } TEST(GLES2FormatTest, BlendEquationSeparate) { - BlendEquationSeparate cmd = {{0}}; + BlendEquationSeparate cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, static_cast<GLenum>(11), static_cast<GLenum>(12)); EXPECT_EQ(static_cast<uint32>(BlendEquationSeparate::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<GLenum>(11), cmd.modeRGB); @@ -183,14 +192,14 @@ TEST(GLES2FormatTest, BlendEquationSeparate) { } TEST(GLES2FormatTest, BlendFunc) { - BlendFunc cmd = {{0}}; + BlendFunc cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, static_cast<GLenum>(11), static_cast<GLenum>(12)); EXPECT_EQ(static_cast<uint32>(BlendFunc::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<GLenum>(11), cmd.sfactor); @@ -198,7 +207,7 @@ TEST(GLES2FormatTest, BlendFunc) { } TEST(GLES2FormatTest, BlendFuncSeparate) { - BlendFuncSeparate cmd = {{0}}; + BlendFuncSeparate cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, static_cast<GLenum>(11), @@ -207,7 +216,7 @@ TEST(GLES2FormatTest, BlendFuncSeparate) { static_cast<GLenum>(14)); EXPECT_EQ(static_cast<uint32>(BlendFuncSeparate::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<GLenum>(11), cmd.srcRGB); @@ -217,7 +226,7 @@ TEST(GLES2FormatTest, BlendFuncSeparate) { } TEST(GLES2FormatTest, BufferData) { - BufferData cmd = {{0}}; + BufferData cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, static_cast<GLenum>(11), @@ -227,7 +236,7 @@ TEST(GLES2FormatTest, BufferData) { static_cast<GLenum>(15)); EXPECT_EQ(static_cast<uint32>(BufferData::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<GLenum>(11), cmd.target); @@ -239,7 +248,7 @@ TEST(GLES2FormatTest, BufferData) { // TODO(gman): Implement test for BufferDataImmediate TEST(GLES2FormatTest, BufferSubData) { - BufferSubData cmd = {{0}}; + BufferSubData cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, static_cast<GLenum>(11), @@ -249,7 +258,7 @@ TEST(GLES2FormatTest, BufferSubData) { static_cast<uint32>(15)); EXPECT_EQ(static_cast<uint32>(BufferSubData::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<GLenum>(11), cmd.target); @@ -261,33 +270,33 @@ TEST(GLES2FormatTest, BufferSubData) { // TODO(gman): Implement test for BufferSubDataImmediate TEST(GLES2FormatTest, CheckFramebufferStatus) { - CheckFramebufferStatus cmd = {{0}}; + CheckFramebufferStatus cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, static_cast<GLenum>(11)); EXPECT_EQ(static_cast<uint32>(CheckFramebufferStatus::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<GLenum>(11), cmd.target); } TEST(GLES2FormatTest, Clear) { - Clear cmd = {{0}}; + Clear cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, static_cast<GLbitfield>(11)); EXPECT_EQ(static_cast<uint32>(Clear::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<GLbitfield>(11), cmd.mask); } TEST(GLES2FormatTest, ClearColor) { - ClearColor cmd = {{0}}; + ClearColor cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, static_cast<GLclampf>(11), @@ -296,7 +305,7 @@ TEST(GLES2FormatTest, ClearColor) { static_cast<GLclampf>(14)); EXPECT_EQ(static_cast<uint32>(ClearColor::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<GLclampf>(11), cmd.red); @@ -306,33 +315,33 @@ TEST(GLES2FormatTest, ClearColor) { } TEST(GLES2FormatTest, ClearDepthf) { - ClearDepthf cmd = {{0}}; + ClearDepthf cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, static_cast<GLclampf>(11)); EXPECT_EQ(static_cast<uint32>(ClearDepthf::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<GLclampf>(11), cmd.depth); } TEST(GLES2FormatTest, ClearStencil) { - ClearStencil cmd = {{0}}; + ClearStencil cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, static_cast<GLint>(11)); EXPECT_EQ(static_cast<uint32>(ClearStencil::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<GLint>(11), cmd.s); } TEST(GLES2FormatTest, ColorMask) { - ColorMask cmd = {{0}}; + ColorMask cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, static_cast<GLboolean>(11), @@ -341,7 +350,7 @@ TEST(GLES2FormatTest, ColorMask) { static_cast<GLboolean>(14)); EXPECT_EQ(static_cast<uint32>(ColorMask::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<GLboolean>(11), cmd.red); @@ -351,20 +360,20 @@ TEST(GLES2FormatTest, ColorMask) { } TEST(GLES2FormatTest, CompileShader) { - CompileShader cmd = {{0}}; + CompileShader cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, static_cast<GLuint>(11)); EXPECT_EQ(static_cast<uint32>(CompileShader::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<GLuint>(11), cmd.shader); } TEST(GLES2FormatTest, CompressedTexImage2D) { - CompressedTexImage2D cmd = {{0}}; + CompressedTexImage2D cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, static_cast<GLenum>(11), @@ -378,7 +387,7 @@ TEST(GLES2FormatTest, CompressedTexImage2D) { static_cast<uint32>(19)); EXPECT_EQ(static_cast<uint32>(CompressedTexImage2D::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<GLenum>(11), cmd.target); @@ -394,7 +403,7 @@ TEST(GLES2FormatTest, CompressedTexImage2D) { // TODO(gman): Implement test for CompressedTexImage2DImmediate TEST(GLES2FormatTest, CompressedTexSubImage2D) { - CompressedTexSubImage2D cmd = {{0}}; + CompressedTexSubImage2D cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, static_cast<GLenum>(11), @@ -409,7 +418,7 @@ TEST(GLES2FormatTest, CompressedTexSubImage2D) { static_cast<uint32>(20)); EXPECT_EQ(static_cast<uint32>(CompressedTexSubImage2D::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<GLenum>(11), cmd.target); @@ -426,7 +435,7 @@ TEST(GLES2FormatTest, CompressedTexSubImage2D) { // TODO(gman): Implement test for CompressedTexSubImage2DImmediate TEST(GLES2FormatTest, CopyTexImage2D) { - CopyTexImage2D cmd = {{0}}; + CopyTexImage2D cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, static_cast<GLenum>(11), @@ -439,7 +448,7 @@ TEST(GLES2FormatTest, CopyTexImage2D) { static_cast<GLint>(18)); EXPECT_EQ(static_cast<uint32>(CopyTexImage2D::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<GLenum>(11), cmd.target); @@ -453,7 +462,7 @@ TEST(GLES2FormatTest, CopyTexImage2D) { } TEST(GLES2FormatTest, CopyTexSubImage2D) { - CopyTexSubImage2D cmd = {{0}}; + CopyTexSubImage2D cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, static_cast<GLenum>(11), @@ -466,7 +475,7 @@ TEST(GLES2FormatTest, CopyTexSubImage2D) { static_cast<GLsizei>(18)); EXPECT_EQ(static_cast<uint32>(CopyTexSubImage2D::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<GLenum>(11), cmd.target); @@ -480,27 +489,27 @@ TEST(GLES2FormatTest, CopyTexSubImage2D) { } TEST(GLES2FormatTest, CreateProgram) { - CreateProgram cmd = {{0}}; + CreateProgram cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, static_cast<uint32>(11)); EXPECT_EQ(static_cast<uint32>(CreateProgram::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<uint32>(11), cmd.client_id); } TEST(GLES2FormatTest, CreateShader) { - CreateShader cmd = {{0}}; + CreateShader cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, static_cast<GLenum>(11), static_cast<uint32>(12)); EXPECT_EQ(static_cast<uint32>(CreateShader::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<GLenum>(11), cmd.type); @@ -508,20 +517,20 @@ TEST(GLES2FormatTest, CreateShader) { } TEST(GLES2FormatTest, CullFace) { - CullFace cmd = {{0}}; + CullFace cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, static_cast<GLenum>(11)); EXPECT_EQ(static_cast<uint32>(CullFace::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<GLenum>(11), cmd.mode); } TEST(GLES2FormatTest, DeleteBuffers) { - DeleteBuffers cmd = {{0}}; + DeleteBuffers cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, static_cast<GLsizei>(11), @@ -529,7 +538,7 @@ TEST(GLES2FormatTest, DeleteBuffers) { static_cast<uint32>(13)); EXPECT_EQ(static_cast<uint32>(DeleteBuffers::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<GLsizei>(11), cmd.n); @@ -550,7 +559,7 @@ TEST(GLES2FormatTest, DeleteBuffersImmediate) { cmd.header.command); EXPECT_EQ(sizeof(cmd) + RoundSizeToMultipleOfEntries(cmd.n * 4u), - cmd.header.size * 4u); // NOLINT + cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd) + RoundSizeToMultipleOfEntries(cmd.n * 4u)); @@ -559,7 +568,7 @@ TEST(GLES2FormatTest, DeleteBuffersImmediate) { } TEST(GLES2FormatTest, DeleteFramebuffers) { - DeleteFramebuffers cmd = {{0}}; + DeleteFramebuffers cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, static_cast<GLsizei>(11), @@ -567,7 +576,7 @@ TEST(GLES2FormatTest, DeleteFramebuffers) { static_cast<uint32>(13)); EXPECT_EQ(static_cast<uint32>(DeleteFramebuffers::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<GLsizei>(11), cmd.n); @@ -588,7 +597,7 @@ TEST(GLES2FormatTest, DeleteFramebuffersImmediate) { cmd.header.command); EXPECT_EQ(sizeof(cmd) + RoundSizeToMultipleOfEntries(cmd.n * 4u), - cmd.header.size * 4u); // NOLINT + cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd) + RoundSizeToMultipleOfEntries(cmd.n * 4u)); @@ -597,20 +606,20 @@ TEST(GLES2FormatTest, DeleteFramebuffersImmediate) { } TEST(GLES2FormatTest, DeleteProgram) { - DeleteProgram cmd = {{0}}; + DeleteProgram cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, static_cast<GLuint>(11)); EXPECT_EQ(static_cast<uint32>(DeleteProgram::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<GLuint>(11), cmd.program); } TEST(GLES2FormatTest, DeleteRenderbuffers) { - DeleteRenderbuffers cmd = {{0}}; + DeleteRenderbuffers cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, static_cast<GLsizei>(11), @@ -618,7 +627,7 @@ TEST(GLES2FormatTest, DeleteRenderbuffers) { static_cast<uint32>(13)); EXPECT_EQ(static_cast<uint32>(DeleteRenderbuffers::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<GLsizei>(11), cmd.n); @@ -639,7 +648,7 @@ TEST(GLES2FormatTest, DeleteRenderbuffersImmediate) { cmd.header.command); EXPECT_EQ(sizeof(cmd) + RoundSizeToMultipleOfEntries(cmd.n * 4u), - cmd.header.size * 4u); // NOLINT + cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd) + RoundSizeToMultipleOfEntries(cmd.n * 4u)); @@ -648,20 +657,20 @@ TEST(GLES2FormatTest, DeleteRenderbuffersImmediate) { } TEST(GLES2FormatTest, DeleteShader) { - DeleteShader cmd = {{0}}; + DeleteShader cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, static_cast<GLuint>(11)); EXPECT_EQ(static_cast<uint32>(DeleteShader::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<GLuint>(11), cmd.shader); } TEST(GLES2FormatTest, DeleteTextures) { - DeleteTextures cmd = {{0}}; + DeleteTextures cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, static_cast<GLsizei>(11), @@ -669,7 +678,7 @@ TEST(GLES2FormatTest, DeleteTextures) { static_cast<uint32>(13)); EXPECT_EQ(static_cast<uint32>(DeleteTextures::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<GLsizei>(11), cmd.n); @@ -690,7 +699,7 @@ TEST(GLES2FormatTest, DeleteTexturesImmediate) { cmd.header.command); EXPECT_EQ(sizeof(cmd) + RoundSizeToMultipleOfEntries(cmd.n * 4u), - cmd.header.size * 4u); // NOLINT + cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd) + RoundSizeToMultipleOfEntries(cmd.n * 4u)); @@ -699,40 +708,40 @@ TEST(GLES2FormatTest, DeleteTexturesImmediate) { } TEST(GLES2FormatTest, DepthFunc) { - DepthFunc cmd = {{0}}; + DepthFunc cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, static_cast<GLenum>(11)); EXPECT_EQ(static_cast<uint32>(DepthFunc::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<GLenum>(11), cmd.func); } TEST(GLES2FormatTest, DepthMask) { - DepthMask cmd = {{0}}; + DepthMask cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, static_cast<GLboolean>(11)); EXPECT_EQ(static_cast<uint32>(DepthMask::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<GLboolean>(11), cmd.flag); } TEST(GLES2FormatTest, DepthRangef) { - DepthRangef cmd = {{0}}; + DepthRangef cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, static_cast<GLclampf>(11), static_cast<GLclampf>(12)); EXPECT_EQ(static_cast<uint32>(DepthRangef::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<GLclampf>(11), cmd.zNear); @@ -740,14 +749,14 @@ TEST(GLES2FormatTest, DepthRangef) { } TEST(GLES2FormatTest, DetachShader) { - DetachShader cmd = {{0}}; + DetachShader cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, static_cast<GLuint>(11), static_cast<GLuint>(12)); EXPECT_EQ(static_cast<uint32>(DetachShader::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<GLuint>(11), cmd.program); @@ -755,33 +764,33 @@ TEST(GLES2FormatTest, DetachShader) { } TEST(GLES2FormatTest, Disable) { - Disable cmd = {{0}}; + Disable cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, static_cast<GLenum>(11)); EXPECT_EQ(static_cast<uint32>(Disable::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<GLenum>(11), cmd.cap); } TEST(GLES2FormatTest, DisableVertexAttribArray) { - DisableVertexAttribArray cmd = {{0}}; + DisableVertexAttribArray cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, static_cast<GLuint>(11)); EXPECT_EQ(static_cast<uint32>(DisableVertexAttribArray::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<GLuint>(11), cmd.index); } TEST(GLES2FormatTest, DrawArrays) { - DrawArrays cmd = {{0}}; + DrawArrays cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, static_cast<GLenum>(11), @@ -789,7 +798,7 @@ TEST(GLES2FormatTest, DrawArrays) { static_cast<GLsizei>(13)); EXPECT_EQ(static_cast<uint32>(DrawArrays::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<GLenum>(11), cmd.mode); @@ -798,7 +807,7 @@ TEST(GLES2FormatTest, DrawArrays) { } TEST(GLES2FormatTest, DrawElements) { - DrawElements cmd = {{0}}; + DrawElements cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, static_cast<GLenum>(11), @@ -807,7 +816,7 @@ TEST(GLES2FormatTest, DrawElements) { static_cast<GLuint>(14)); EXPECT_EQ(static_cast<uint32>(DrawElements::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<GLenum>(11), cmd.mode); @@ -817,55 +826,55 @@ TEST(GLES2FormatTest, DrawElements) { } TEST(GLES2FormatTest, Enable) { - Enable cmd = {{0}}; + Enable cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, static_cast<GLenum>(11)); EXPECT_EQ(static_cast<uint32>(Enable::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<GLenum>(11), cmd.cap); } TEST(GLES2FormatTest, EnableVertexAttribArray) { - EnableVertexAttribArray cmd = {{0}}; + EnableVertexAttribArray cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, static_cast<GLuint>(11)); EXPECT_EQ(static_cast<uint32>(EnableVertexAttribArray::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<GLuint>(11), cmd.index); } TEST(GLES2FormatTest, Finish) { - Finish cmd = {{0}}; + Finish cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd); EXPECT_EQ(static_cast<uint32>(Finish::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); } TEST(GLES2FormatTest, Flush) { - Flush cmd = {{0}}; + Flush cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd); EXPECT_EQ(static_cast<uint32>(Flush::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); } TEST(GLES2FormatTest, FramebufferRenderbuffer) { - FramebufferRenderbuffer cmd = {{0}}; + FramebufferRenderbuffer cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, static_cast<GLenum>(11), @@ -874,7 +883,7 @@ TEST(GLES2FormatTest, FramebufferRenderbuffer) { static_cast<GLuint>(14)); EXPECT_EQ(static_cast<uint32>(FramebufferRenderbuffer::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<GLenum>(11), cmd.target); @@ -884,7 +893,7 @@ TEST(GLES2FormatTest, FramebufferRenderbuffer) { } TEST(GLES2FormatTest, FramebufferTexture2D) { - FramebufferTexture2D cmd = {{0}}; + FramebufferTexture2D cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, static_cast<GLenum>(11), @@ -894,7 +903,7 @@ TEST(GLES2FormatTest, FramebufferTexture2D) { static_cast<GLint>(15)); EXPECT_EQ(static_cast<uint32>(FramebufferTexture2D::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<GLenum>(11), cmd.target); @@ -905,20 +914,20 @@ TEST(GLES2FormatTest, FramebufferTexture2D) { } TEST(GLES2FormatTest, FrontFace) { - FrontFace cmd = {{0}}; + FrontFace cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, static_cast<GLenum>(11)); EXPECT_EQ(static_cast<uint32>(FrontFace::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<GLenum>(11), cmd.mode); } TEST(GLES2FormatTest, GenBuffers) { - GenBuffers cmd = {{0}}; + GenBuffers cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, static_cast<GLsizei>(11), @@ -926,7 +935,7 @@ TEST(GLES2FormatTest, GenBuffers) { static_cast<uint32>(13)); EXPECT_EQ(static_cast<uint32>(GenBuffers::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<GLsizei>(11), cmd.n); @@ -947,7 +956,7 @@ TEST(GLES2FormatTest, GenBuffersImmediate) { cmd.header.command); EXPECT_EQ(sizeof(cmd) + RoundSizeToMultipleOfEntries(cmd.n * 4u), - cmd.header.size * 4u); // NOLINT + cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd) + RoundSizeToMultipleOfEntries(cmd.n * 4u)); @@ -956,20 +965,20 @@ TEST(GLES2FormatTest, GenBuffersImmediate) { } TEST(GLES2FormatTest, GenerateMipmap) { - GenerateMipmap cmd = {{0}}; + GenerateMipmap cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, static_cast<GLenum>(11)); EXPECT_EQ(static_cast<uint32>(GenerateMipmap::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<GLenum>(11), cmd.target); } TEST(GLES2FormatTest, GenFramebuffers) { - GenFramebuffers cmd = {{0}}; + GenFramebuffers cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, static_cast<GLsizei>(11), @@ -977,7 +986,7 @@ TEST(GLES2FormatTest, GenFramebuffers) { static_cast<uint32>(13)); EXPECT_EQ(static_cast<uint32>(GenFramebuffers::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<GLsizei>(11), cmd.n); @@ -998,7 +1007,7 @@ TEST(GLES2FormatTest, GenFramebuffersImmediate) { cmd.header.command); EXPECT_EQ(sizeof(cmd) + RoundSizeToMultipleOfEntries(cmd.n * 4u), - cmd.header.size * 4u); // NOLINT + cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd) + RoundSizeToMultipleOfEntries(cmd.n * 4u)); @@ -1007,7 +1016,7 @@ TEST(GLES2FormatTest, GenFramebuffersImmediate) { } TEST(GLES2FormatTest, GenRenderbuffers) { - GenRenderbuffers cmd = {{0}}; + GenRenderbuffers cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, static_cast<GLsizei>(11), @@ -1015,7 +1024,7 @@ TEST(GLES2FormatTest, GenRenderbuffers) { static_cast<uint32>(13)); EXPECT_EQ(static_cast<uint32>(GenRenderbuffers::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<GLsizei>(11), cmd.n); @@ -1036,7 +1045,7 @@ TEST(GLES2FormatTest, GenRenderbuffersImmediate) { cmd.header.command); EXPECT_EQ(sizeof(cmd) + RoundSizeToMultipleOfEntries(cmd.n * 4u), - cmd.header.size * 4u); // NOLINT + cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd) + RoundSizeToMultipleOfEntries(cmd.n * 4u)); @@ -1045,7 +1054,7 @@ TEST(GLES2FormatTest, GenRenderbuffersImmediate) { } TEST(GLES2FormatTest, GenTextures) { - GenTextures cmd = {{0}}; + GenTextures cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, static_cast<GLsizei>(11), @@ -1053,7 +1062,7 @@ TEST(GLES2FormatTest, GenTextures) { static_cast<uint32>(13)); EXPECT_EQ(static_cast<uint32>(GenTextures::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<GLsizei>(11), cmd.n); @@ -1074,7 +1083,7 @@ TEST(GLES2FormatTest, GenTexturesImmediate) { cmd.header.command); EXPECT_EQ(sizeof(cmd) + RoundSizeToMultipleOfEntries(cmd.n * 4u), - cmd.header.size * 4u); // NOLINT + cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd) + RoundSizeToMultipleOfEntries(cmd.n * 4u)); @@ -1083,7 +1092,7 @@ TEST(GLES2FormatTest, GenTexturesImmediate) { } TEST(GLES2FormatTest, GetActiveAttrib) { - GetActiveAttrib cmd = {{0}}; + GetActiveAttrib cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, static_cast<GLuint>(11), @@ -1099,7 +1108,7 @@ TEST(GLES2FormatTest, GetActiveAttrib) { static_cast<uint32>(21)); EXPECT_EQ(static_cast<uint32>(GetActiveAttrib::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<GLuint>(11), cmd.program); @@ -1116,7 +1125,7 @@ TEST(GLES2FormatTest, GetActiveAttrib) { } TEST(GLES2FormatTest, GetActiveUniform) { - GetActiveUniform cmd = {{0}}; + GetActiveUniform cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, static_cast<GLuint>(11), @@ -1132,7 +1141,7 @@ TEST(GLES2FormatTest, GetActiveUniform) { static_cast<uint32>(21)); EXPECT_EQ(static_cast<uint32>(GetActiveUniform::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<GLuint>(11), cmd.program); @@ -1149,7 +1158,7 @@ TEST(GLES2FormatTest, GetActiveUniform) { } TEST(GLES2FormatTest, GetAttachedShaders) { - GetAttachedShaders cmd = {{0}}; + GetAttachedShaders cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, static_cast<GLuint>(11), @@ -1160,7 +1169,7 @@ TEST(GLES2FormatTest, GetAttachedShaders) { static_cast<uint32>(16)); EXPECT_EQ(static_cast<uint32>(GetAttachedShaders::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<GLuint>(11), cmd.program); @@ -1174,7 +1183,7 @@ TEST(GLES2FormatTest, GetAttachedShaders) { // TODO(gman): Write test for GetAttribLocation // TODO(gman): Write test for GetAttribLocationImmediate TEST(GLES2FormatTest, GetBooleanv) { - GetBooleanv cmd = {{0}}; + GetBooleanv cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, static_cast<GLenum>(11), @@ -1182,7 +1191,7 @@ TEST(GLES2FormatTest, GetBooleanv) { static_cast<uint32>(13)); EXPECT_EQ(static_cast<uint32>(GetBooleanv::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<GLenum>(11), cmd.pname); @@ -1191,7 +1200,7 @@ TEST(GLES2FormatTest, GetBooleanv) { } TEST(GLES2FormatTest, GetBufferParameteriv) { - GetBufferParameteriv cmd = {{0}}; + GetBufferParameteriv cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, static_cast<GLenum>(11), @@ -1200,7 +1209,7 @@ TEST(GLES2FormatTest, GetBufferParameteriv) { static_cast<uint32>(14)); EXPECT_EQ(static_cast<uint32>(GetBufferParameteriv::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<GLenum>(11), cmd.target); @@ -1210,14 +1219,14 @@ TEST(GLES2FormatTest, GetBufferParameteriv) { } TEST(GLES2FormatTest, GetError) { - GetError cmd = {{0}}; + GetError cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, static_cast<uint32>(11), static_cast<uint32>(12)); EXPECT_EQ(static_cast<uint32>(GetError::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<uint32>(11), cmd.result_shm_id); @@ -1225,7 +1234,7 @@ TEST(GLES2FormatTest, GetError) { } TEST(GLES2FormatTest, GetFloatv) { - GetFloatv cmd = {{0}}; + GetFloatv cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, static_cast<GLenum>(11), @@ -1233,7 +1242,7 @@ TEST(GLES2FormatTest, GetFloatv) { static_cast<uint32>(13)); EXPECT_EQ(static_cast<uint32>(GetFloatv::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<GLenum>(11), cmd.pname); @@ -1242,7 +1251,7 @@ TEST(GLES2FormatTest, GetFloatv) { } TEST(GLES2FormatTest, GetFramebufferAttachmentParameteriv) { - GetFramebufferAttachmentParameteriv cmd = {{0}}; + GetFramebufferAttachmentParameteriv cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, static_cast<GLenum>(11), @@ -1252,7 +1261,7 @@ TEST(GLES2FormatTest, GetFramebufferAttachmentParameteriv) { static_cast<uint32>(15)); EXPECT_EQ(static_cast<uint32>(GetFramebufferAttachmentParameteriv::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<GLenum>(11), cmd.target); @@ -1263,7 +1272,7 @@ TEST(GLES2FormatTest, GetFramebufferAttachmentParameteriv) { } TEST(GLES2FormatTest, GetIntegerv) { - GetIntegerv cmd = {{0}}; + GetIntegerv cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, static_cast<GLenum>(11), @@ -1271,7 +1280,7 @@ TEST(GLES2FormatTest, GetIntegerv) { static_cast<uint32>(13)); EXPECT_EQ(static_cast<uint32>(GetIntegerv::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<GLenum>(11), cmd.pname); @@ -1280,7 +1289,7 @@ TEST(GLES2FormatTest, GetIntegerv) { } TEST(GLES2FormatTest, GetProgramiv) { - GetProgramiv cmd = {{0}}; + GetProgramiv cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, static_cast<GLuint>(11), @@ -1289,7 +1298,7 @@ TEST(GLES2FormatTest, GetProgramiv) { static_cast<uint32>(14)); EXPECT_EQ(static_cast<uint32>(GetProgramiv::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<GLuint>(11), cmd.program); @@ -1299,7 +1308,7 @@ TEST(GLES2FormatTest, GetProgramiv) { } TEST(GLES2FormatTest, GetProgramInfoLog) { - GetProgramInfoLog cmd = {{0}}; + GetProgramInfoLog cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, static_cast<GLuint>(11), @@ -1310,7 +1319,7 @@ TEST(GLES2FormatTest, GetProgramInfoLog) { static_cast<uint32>(16)); EXPECT_EQ(static_cast<uint32>(GetProgramInfoLog::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<GLuint>(11), cmd.program); @@ -1322,7 +1331,7 @@ TEST(GLES2FormatTest, GetProgramInfoLog) { } TEST(GLES2FormatTest, GetRenderbufferParameteriv) { - GetRenderbufferParameteriv cmd = {{0}}; + GetRenderbufferParameteriv cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, static_cast<GLenum>(11), @@ -1331,7 +1340,7 @@ TEST(GLES2FormatTest, GetRenderbufferParameteriv) { static_cast<uint32>(14)); EXPECT_EQ(static_cast<uint32>(GetRenderbufferParameteriv::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<GLenum>(11), cmd.target); @@ -1341,7 +1350,7 @@ TEST(GLES2FormatTest, GetRenderbufferParameteriv) { } TEST(GLES2FormatTest, GetShaderiv) { - GetShaderiv cmd = {{0}}; + GetShaderiv cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, static_cast<GLuint>(11), @@ -1350,7 +1359,7 @@ TEST(GLES2FormatTest, GetShaderiv) { static_cast<uint32>(14)); EXPECT_EQ(static_cast<uint32>(GetShaderiv::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<GLuint>(11), cmd.shader); @@ -1360,7 +1369,7 @@ TEST(GLES2FormatTest, GetShaderiv) { } TEST(GLES2FormatTest, GetShaderInfoLog) { - GetShaderInfoLog cmd = {{0}}; + GetShaderInfoLog cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, static_cast<GLuint>(11), @@ -1371,7 +1380,7 @@ TEST(GLES2FormatTest, GetShaderInfoLog) { static_cast<uint32>(16)); EXPECT_EQ(static_cast<uint32>(GetShaderInfoLog::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<GLuint>(11), cmd.shader); @@ -1383,7 +1392,7 @@ TEST(GLES2FormatTest, GetShaderInfoLog) { } TEST(GLES2FormatTest, GetShaderPrecisionFormat) { - GetShaderPrecisionFormat cmd = {{0}}; + GetShaderPrecisionFormat cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, static_cast<GLenum>(11), @@ -1394,7 +1403,7 @@ TEST(GLES2FormatTest, GetShaderPrecisionFormat) { static_cast<uint32>(16)); EXPECT_EQ(static_cast<uint32>(GetShaderPrecisionFormat::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<GLenum>(11), cmd.shadertype); @@ -1406,7 +1415,7 @@ TEST(GLES2FormatTest, GetShaderPrecisionFormat) { } TEST(GLES2FormatTest, GetShaderSource) { - GetShaderSource cmd = {{0}}; + GetShaderSource cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, static_cast<GLuint>(11), @@ -1417,7 +1426,7 @@ TEST(GLES2FormatTest, GetShaderSource) { static_cast<uint32>(16)); EXPECT_EQ(static_cast<uint32>(GetShaderSource::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<GLuint>(11), cmd.shader); @@ -1429,20 +1438,20 @@ TEST(GLES2FormatTest, GetShaderSource) { } TEST(GLES2FormatTest, GetString) { - GetString cmd = {{0}}; + GetString cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, static_cast<GLenum>(11)); EXPECT_EQ(static_cast<uint32>(GetString::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<GLenum>(11), cmd.name); } TEST(GLES2FormatTest, GetTexParameterfv) { - GetTexParameterfv cmd = {{0}}; + GetTexParameterfv cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, static_cast<GLenum>(11), @@ -1451,7 +1460,7 @@ TEST(GLES2FormatTest, GetTexParameterfv) { static_cast<uint32>(14)); EXPECT_EQ(static_cast<uint32>(GetTexParameterfv::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<GLenum>(11), cmd.target); @@ -1461,7 +1470,7 @@ TEST(GLES2FormatTest, GetTexParameterfv) { } TEST(GLES2FormatTest, GetTexParameteriv) { - GetTexParameteriv cmd = {{0}}; + GetTexParameteriv cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, static_cast<GLenum>(11), @@ -1470,7 +1479,7 @@ TEST(GLES2FormatTest, GetTexParameteriv) { static_cast<uint32>(14)); EXPECT_EQ(static_cast<uint32>(GetTexParameteriv::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<GLenum>(11), cmd.target); @@ -1480,7 +1489,7 @@ TEST(GLES2FormatTest, GetTexParameteriv) { } TEST(GLES2FormatTest, GetUniformfv) { - GetUniformfv cmd = {{0}}; + GetUniformfv cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, static_cast<GLuint>(11), @@ -1489,7 +1498,7 @@ TEST(GLES2FormatTest, GetUniformfv) { static_cast<uint32>(14)); EXPECT_EQ(static_cast<uint32>(GetUniformfv::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<GLuint>(11), cmd.program); @@ -1499,7 +1508,7 @@ TEST(GLES2FormatTest, GetUniformfv) { } TEST(GLES2FormatTest, GetUniformiv) { - GetUniformiv cmd = {{0}}; + GetUniformiv cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, static_cast<GLuint>(11), @@ -1508,7 +1517,7 @@ TEST(GLES2FormatTest, GetUniformiv) { static_cast<uint32>(14)); EXPECT_EQ(static_cast<uint32>(GetUniformiv::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<GLuint>(11), cmd.program); @@ -1520,7 +1529,7 @@ TEST(GLES2FormatTest, GetUniformiv) { // TODO(gman): Write test for GetUniformLocation // TODO(gman): Write test for GetUniformLocationImmediate TEST(GLES2FormatTest, GetVertexAttribfv) { - GetVertexAttribfv cmd = {{0}}; + GetVertexAttribfv cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, static_cast<GLuint>(11), @@ -1529,7 +1538,7 @@ TEST(GLES2FormatTest, GetVertexAttribfv) { static_cast<uint32>(14)); EXPECT_EQ(static_cast<uint32>(GetVertexAttribfv::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<GLuint>(11), cmd.index); @@ -1539,7 +1548,7 @@ TEST(GLES2FormatTest, GetVertexAttribfv) { } TEST(GLES2FormatTest, GetVertexAttribiv) { - GetVertexAttribiv cmd = {{0}}; + GetVertexAttribiv cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, static_cast<GLuint>(11), @@ -1548,7 +1557,7 @@ TEST(GLES2FormatTest, GetVertexAttribiv) { static_cast<uint32>(14)); EXPECT_EQ(static_cast<uint32>(GetVertexAttribiv::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<GLuint>(11), cmd.index); @@ -1558,7 +1567,7 @@ TEST(GLES2FormatTest, GetVertexAttribiv) { } TEST(GLES2FormatTest, GetVertexAttribPointerv) { - GetVertexAttribPointerv cmd = {{0}}; + GetVertexAttribPointerv cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, static_cast<GLuint>(11), @@ -1567,7 +1576,7 @@ TEST(GLES2FormatTest, GetVertexAttribPointerv) { static_cast<uint32>(14)); EXPECT_EQ(static_cast<uint32>(GetVertexAttribPointerv::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<GLuint>(11), cmd.index); @@ -1577,14 +1586,14 @@ TEST(GLES2FormatTest, GetVertexAttribPointerv) { } TEST(GLES2FormatTest, Hint) { - Hint cmd = {{0}}; + Hint cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, static_cast<GLenum>(11), static_cast<GLenum>(12)); EXPECT_EQ(static_cast<uint32>(Hint::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<GLenum>(11), cmd.target); @@ -1592,7 +1601,7 @@ TEST(GLES2FormatTest, Hint) { } TEST(GLES2FormatTest, IsBuffer) { - IsBuffer cmd = {{0}}; + IsBuffer cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, static_cast<GLuint>(11), @@ -1600,7 +1609,7 @@ TEST(GLES2FormatTest, IsBuffer) { static_cast<uint32>(13)); EXPECT_EQ(static_cast<uint32>(IsBuffer::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<GLuint>(11), cmd.buffer); @@ -1609,7 +1618,7 @@ TEST(GLES2FormatTest, IsBuffer) { } TEST(GLES2FormatTest, IsEnabled) { - IsEnabled cmd = {{0}}; + IsEnabled cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, static_cast<GLenum>(11), @@ -1617,7 +1626,7 @@ TEST(GLES2FormatTest, IsEnabled) { static_cast<uint32>(13)); EXPECT_EQ(static_cast<uint32>(IsEnabled::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<GLenum>(11), cmd.cap); @@ -1626,7 +1635,7 @@ TEST(GLES2FormatTest, IsEnabled) { } TEST(GLES2FormatTest, IsFramebuffer) { - IsFramebuffer cmd = {{0}}; + IsFramebuffer cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, static_cast<GLuint>(11), @@ -1634,7 +1643,7 @@ TEST(GLES2FormatTest, IsFramebuffer) { static_cast<uint32>(13)); EXPECT_EQ(static_cast<uint32>(IsFramebuffer::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<GLuint>(11), cmd.framebuffer); @@ -1643,7 +1652,7 @@ TEST(GLES2FormatTest, IsFramebuffer) { } TEST(GLES2FormatTest, IsProgram) { - IsProgram cmd = {{0}}; + IsProgram cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, static_cast<GLuint>(11), @@ -1651,7 +1660,7 @@ TEST(GLES2FormatTest, IsProgram) { static_cast<uint32>(13)); EXPECT_EQ(static_cast<uint32>(IsProgram::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<GLuint>(11), cmd.program); @@ -1660,7 +1669,7 @@ TEST(GLES2FormatTest, IsProgram) { } TEST(GLES2FormatTest, IsRenderbuffer) { - IsRenderbuffer cmd = {{0}}; + IsRenderbuffer cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, static_cast<GLuint>(11), @@ -1668,7 +1677,7 @@ TEST(GLES2FormatTest, IsRenderbuffer) { static_cast<uint32>(13)); EXPECT_EQ(static_cast<uint32>(IsRenderbuffer::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<GLuint>(11), cmd.renderbuffer); @@ -1677,7 +1686,7 @@ TEST(GLES2FormatTest, IsRenderbuffer) { } TEST(GLES2FormatTest, IsShader) { - IsShader cmd = {{0}}; + IsShader cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, static_cast<GLuint>(11), @@ -1685,7 +1694,7 @@ TEST(GLES2FormatTest, IsShader) { static_cast<uint32>(13)); EXPECT_EQ(static_cast<uint32>(IsShader::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<GLuint>(11), cmd.shader); @@ -1694,7 +1703,7 @@ TEST(GLES2FormatTest, IsShader) { } TEST(GLES2FormatTest, IsTexture) { - IsTexture cmd = {{0}}; + IsTexture cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, static_cast<GLuint>(11), @@ -1702,7 +1711,7 @@ TEST(GLES2FormatTest, IsTexture) { static_cast<uint32>(13)); EXPECT_EQ(static_cast<uint32>(IsTexture::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<GLuint>(11), cmd.texture); @@ -1711,40 +1720,40 @@ TEST(GLES2FormatTest, IsTexture) { } TEST(GLES2FormatTest, LineWidth) { - LineWidth cmd = {{0}}; + LineWidth cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, static_cast<GLfloat>(11)); EXPECT_EQ(static_cast<uint32>(LineWidth::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<GLfloat>(11), cmd.width); } TEST(GLES2FormatTest, LinkProgram) { - LinkProgram cmd = {{0}}; + LinkProgram cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, static_cast<GLuint>(11)); EXPECT_EQ(static_cast<uint32>(LinkProgram::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<GLuint>(11), cmd.program); } TEST(GLES2FormatTest, PixelStorei) { - PixelStorei cmd = {{0}}; + PixelStorei cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, static_cast<GLenum>(11), static_cast<GLint>(12)); EXPECT_EQ(static_cast<uint32>(PixelStorei::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<GLenum>(11), cmd.pname); @@ -1752,14 +1761,14 @@ TEST(GLES2FormatTest, PixelStorei) { } TEST(GLES2FormatTest, PolygonOffset) { - PolygonOffset cmd = {{0}}; + PolygonOffset cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, static_cast<GLfloat>(11), static_cast<GLfloat>(12)); EXPECT_EQ(static_cast<uint32>(PolygonOffset::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<GLfloat>(11), cmd.factor); @@ -1767,7 +1776,7 @@ TEST(GLES2FormatTest, PolygonOffset) { } TEST(GLES2FormatTest, ReadPixels) { - ReadPixels cmd = {{0}}; + ReadPixels cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, static_cast<GLint>(11), @@ -1780,7 +1789,7 @@ TEST(GLES2FormatTest, ReadPixels) { static_cast<uint32>(18)); EXPECT_EQ(static_cast<uint32>(ReadPixels::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<GLint>(11), cmd.x); @@ -1794,7 +1803,7 @@ TEST(GLES2FormatTest, ReadPixels) { } TEST(GLES2FormatTest, RenderbufferStorage) { - RenderbufferStorage cmd = {{0}}; + RenderbufferStorage cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, static_cast<GLenum>(11), @@ -1803,7 +1812,7 @@ TEST(GLES2FormatTest, RenderbufferStorage) { static_cast<GLsizei>(14)); EXPECT_EQ(static_cast<uint32>(RenderbufferStorage::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<GLenum>(11), cmd.target); @@ -1813,14 +1822,14 @@ TEST(GLES2FormatTest, RenderbufferStorage) { } TEST(GLES2FormatTest, SampleCoverage) { - SampleCoverage cmd = {{0}}; + SampleCoverage cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, static_cast<GLclampf>(11), static_cast<GLboolean>(12)); EXPECT_EQ(static_cast<uint32>(SampleCoverage::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<GLclampf>(11), cmd.value); @@ -1828,7 +1837,7 @@ TEST(GLES2FormatTest, SampleCoverage) { } TEST(GLES2FormatTest, Scissor) { - Scissor cmd = {{0}}; + Scissor cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, static_cast<GLint>(11), @@ -1837,7 +1846,7 @@ TEST(GLES2FormatTest, Scissor) { static_cast<GLsizei>(14)); EXPECT_EQ(static_cast<uint32>(Scissor::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<GLint>(11), cmd.x); @@ -1847,7 +1856,7 @@ TEST(GLES2FormatTest, Scissor) { } TEST(GLES2FormatTest, ShaderSource) { - ShaderSource cmd = {{0}}; + ShaderSource cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, static_cast<GLuint>(11), @@ -1857,7 +1866,7 @@ TEST(GLES2FormatTest, ShaderSource) { static_cast<uint32>(15)); EXPECT_EQ(static_cast<uint32>(ShaderSource::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<GLuint>(11), cmd.shader); @@ -1869,7 +1878,7 @@ TEST(GLES2FormatTest, ShaderSource) { // TODO(gman): Implement test for ShaderSourceImmediate TEST(GLES2FormatTest, StencilFunc) { - StencilFunc cmd = {{0}}; + StencilFunc cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, static_cast<GLenum>(11), @@ -1877,7 +1886,7 @@ TEST(GLES2FormatTest, StencilFunc) { static_cast<GLuint>(13)); EXPECT_EQ(static_cast<uint32>(StencilFunc::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<GLenum>(11), cmd.func); @@ -1886,7 +1895,7 @@ TEST(GLES2FormatTest, StencilFunc) { } TEST(GLES2FormatTest, StencilFuncSeparate) { - StencilFuncSeparate cmd = {{0}}; + StencilFuncSeparate cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, static_cast<GLenum>(11), @@ -1895,7 +1904,7 @@ TEST(GLES2FormatTest, StencilFuncSeparate) { static_cast<GLuint>(14)); EXPECT_EQ(static_cast<uint32>(StencilFuncSeparate::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<GLenum>(11), cmd.face); @@ -1905,27 +1914,27 @@ TEST(GLES2FormatTest, StencilFuncSeparate) { } TEST(GLES2FormatTest, StencilMask) { - StencilMask cmd = {{0}}; + StencilMask cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, static_cast<GLuint>(11)); EXPECT_EQ(static_cast<uint32>(StencilMask::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<GLuint>(11), cmd.mask); } TEST(GLES2FormatTest, StencilMaskSeparate) { - StencilMaskSeparate cmd = {{0}}; + StencilMaskSeparate cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, static_cast<GLenum>(11), static_cast<GLuint>(12)); EXPECT_EQ(static_cast<uint32>(StencilMaskSeparate::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<GLenum>(11), cmd.face); @@ -1933,7 +1942,7 @@ TEST(GLES2FormatTest, StencilMaskSeparate) { } TEST(GLES2FormatTest, StencilOp) { - StencilOp cmd = {{0}}; + StencilOp cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, static_cast<GLenum>(11), @@ -1941,7 +1950,7 @@ TEST(GLES2FormatTest, StencilOp) { static_cast<GLenum>(13)); EXPECT_EQ(static_cast<uint32>(StencilOp::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<GLenum>(11), cmd.fail); @@ -1950,7 +1959,7 @@ TEST(GLES2FormatTest, StencilOp) { } TEST(GLES2FormatTest, StencilOpSeparate) { - StencilOpSeparate cmd = {{0}}; + StencilOpSeparate cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, static_cast<GLenum>(11), @@ -1959,7 +1968,7 @@ TEST(GLES2FormatTest, StencilOpSeparate) { static_cast<GLenum>(14)); EXPECT_EQ(static_cast<uint32>(StencilOpSeparate::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<GLenum>(11), cmd.face); @@ -1969,7 +1978,7 @@ TEST(GLES2FormatTest, StencilOpSeparate) { } TEST(GLES2FormatTest, TexImage2D) { - TexImage2D cmd = {{0}}; + TexImage2D cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, static_cast<GLenum>(11), @@ -1984,7 +1993,7 @@ TEST(GLES2FormatTest, TexImage2D) { static_cast<uint32>(20)); EXPECT_EQ(static_cast<uint32>(TexImage2D::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<GLenum>(11), cmd.target); @@ -2001,7 +2010,7 @@ TEST(GLES2FormatTest, TexImage2D) { // TODO(gman): Implement test for TexImage2DImmediate TEST(GLES2FormatTest, TexParameterf) { - TexParameterf cmd = {{0}}; + TexParameterf cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, static_cast<GLenum>(11), @@ -2009,7 +2018,7 @@ TEST(GLES2FormatTest, TexParameterf) { static_cast<GLfloat>(13)); EXPECT_EQ(static_cast<uint32>(TexParameterf::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<GLenum>(11), cmd.target); @@ -2018,7 +2027,7 @@ TEST(GLES2FormatTest, TexParameterf) { } TEST(GLES2FormatTest, TexParameterfv) { - TexParameterfv cmd = {{0}}; + TexParameterfv cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, static_cast<GLenum>(11), @@ -2027,7 +2036,7 @@ TEST(GLES2FormatTest, TexParameterfv) { static_cast<uint32>(14)); EXPECT_EQ(static_cast<uint32>(TexParameterfv::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<GLenum>(11), cmd.target); @@ -2053,7 +2062,7 @@ TEST(GLES2FormatTest, TexParameterfvImmediate) { cmd.header.command); EXPECT_EQ(sizeof(cmd) + RoundSizeToMultipleOfEntries(sizeof(data)), - cmd.header.size * 4u); // NOLINT + cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd) + RoundSizeToMultipleOfEntries(sizeof(data))); @@ -2063,7 +2072,7 @@ TEST(GLES2FormatTest, TexParameterfvImmediate) { } TEST(GLES2FormatTest, TexParameteri) { - TexParameteri cmd = {{0}}; + TexParameteri cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, static_cast<GLenum>(11), @@ -2071,7 +2080,7 @@ TEST(GLES2FormatTest, TexParameteri) { static_cast<GLint>(13)); EXPECT_EQ(static_cast<uint32>(TexParameteri::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<GLenum>(11), cmd.target); @@ -2080,7 +2089,7 @@ TEST(GLES2FormatTest, TexParameteri) { } TEST(GLES2FormatTest, TexParameteriv) { - TexParameteriv cmd = {{0}}; + TexParameteriv cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, static_cast<GLenum>(11), @@ -2089,7 +2098,7 @@ TEST(GLES2FormatTest, TexParameteriv) { static_cast<uint32>(14)); EXPECT_EQ(static_cast<uint32>(TexParameteriv::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<GLenum>(11), cmd.target); @@ -2115,7 +2124,7 @@ TEST(GLES2FormatTest, TexParameterivImmediate) { cmd.header.command); EXPECT_EQ(sizeof(cmd) + RoundSizeToMultipleOfEntries(sizeof(data)), - cmd.header.size * 4u); // NOLINT + cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd) + RoundSizeToMultipleOfEntries(sizeof(data))); @@ -2125,7 +2134,7 @@ TEST(GLES2FormatTest, TexParameterivImmediate) { } TEST(GLES2FormatTest, TexSubImage2D) { - TexSubImage2D cmd = {{0}}; + TexSubImage2D cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, static_cast<GLenum>(11), @@ -2140,7 +2149,7 @@ TEST(GLES2FormatTest, TexSubImage2D) { static_cast<uint32>(20)); EXPECT_EQ(static_cast<uint32>(TexSubImage2D::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<GLenum>(11), cmd.target); @@ -2157,14 +2166,14 @@ TEST(GLES2FormatTest, TexSubImage2D) { // TODO(gman): Implement test for TexSubImage2DImmediate TEST(GLES2FormatTest, Uniform1f) { - Uniform1f cmd = {{0}}; + Uniform1f cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, static_cast<GLint>(11), static_cast<GLfloat>(12)); EXPECT_EQ(static_cast<uint32>(Uniform1f::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<GLint>(11), cmd.location); @@ -2172,7 +2181,7 @@ TEST(GLES2FormatTest, Uniform1f) { } TEST(GLES2FormatTest, Uniform1fv) { - Uniform1fv cmd = {{0}}; + Uniform1fv cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, static_cast<GLint>(11), @@ -2181,7 +2190,7 @@ TEST(GLES2FormatTest, Uniform1fv) { static_cast<uint32>(14)); EXPECT_EQ(static_cast<uint32>(Uniform1fv::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<GLint>(11), cmd.location); @@ -2208,7 +2217,7 @@ TEST(GLES2FormatTest, Uniform1fvImmediate) { cmd.header.command); EXPECT_EQ(sizeof(cmd) + RoundSizeToMultipleOfEntries(sizeof(data)), - cmd.header.size * 4u); // NOLINT + cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd) + RoundSizeToMultipleOfEntries(sizeof(data))); @@ -2218,14 +2227,14 @@ TEST(GLES2FormatTest, Uniform1fvImmediate) { } TEST(GLES2FormatTest, Uniform1i) { - Uniform1i cmd = {{0}}; + Uniform1i cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, static_cast<GLint>(11), static_cast<GLint>(12)); EXPECT_EQ(static_cast<uint32>(Uniform1i::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<GLint>(11), cmd.location); @@ -2233,7 +2242,7 @@ TEST(GLES2FormatTest, Uniform1i) { } TEST(GLES2FormatTest, Uniform1iv) { - Uniform1iv cmd = {{0}}; + Uniform1iv cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, static_cast<GLint>(11), @@ -2242,7 +2251,7 @@ TEST(GLES2FormatTest, Uniform1iv) { static_cast<uint32>(14)); EXPECT_EQ(static_cast<uint32>(Uniform1iv::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<GLint>(11), cmd.location); @@ -2269,7 +2278,7 @@ TEST(GLES2FormatTest, Uniform1ivImmediate) { cmd.header.command); EXPECT_EQ(sizeof(cmd) + RoundSizeToMultipleOfEntries(sizeof(data)), - cmd.header.size * 4u); // NOLINT + cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd) + RoundSizeToMultipleOfEntries(sizeof(data))); @@ -2279,7 +2288,7 @@ TEST(GLES2FormatTest, Uniform1ivImmediate) { } TEST(GLES2FormatTest, Uniform2f) { - Uniform2f cmd = {{0}}; + Uniform2f cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, static_cast<GLint>(11), @@ -2287,7 +2296,7 @@ TEST(GLES2FormatTest, Uniform2f) { static_cast<GLfloat>(13)); EXPECT_EQ(static_cast<uint32>(Uniform2f::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<GLint>(11), cmd.location); @@ -2296,7 +2305,7 @@ TEST(GLES2FormatTest, Uniform2f) { } TEST(GLES2FormatTest, Uniform2fv) { - Uniform2fv cmd = {{0}}; + Uniform2fv cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, static_cast<GLint>(11), @@ -2305,7 +2314,7 @@ TEST(GLES2FormatTest, Uniform2fv) { static_cast<uint32>(14)); EXPECT_EQ(static_cast<uint32>(Uniform2fv::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<GLint>(11), cmd.location); @@ -2334,7 +2343,7 @@ TEST(GLES2FormatTest, Uniform2fvImmediate) { cmd.header.command); EXPECT_EQ(sizeof(cmd) + RoundSizeToMultipleOfEntries(sizeof(data)), - cmd.header.size * 4u); // NOLINT + cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd) + RoundSizeToMultipleOfEntries(sizeof(data))); @@ -2344,7 +2353,7 @@ TEST(GLES2FormatTest, Uniform2fvImmediate) { } TEST(GLES2FormatTest, Uniform2i) { - Uniform2i cmd = {{0}}; + Uniform2i cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, static_cast<GLint>(11), @@ -2352,7 +2361,7 @@ TEST(GLES2FormatTest, Uniform2i) { static_cast<GLint>(13)); EXPECT_EQ(static_cast<uint32>(Uniform2i::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<GLint>(11), cmd.location); @@ -2361,7 +2370,7 @@ TEST(GLES2FormatTest, Uniform2i) { } TEST(GLES2FormatTest, Uniform2iv) { - Uniform2iv cmd = {{0}}; + Uniform2iv cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, static_cast<GLint>(11), @@ -2370,7 +2379,7 @@ TEST(GLES2FormatTest, Uniform2iv) { static_cast<uint32>(14)); EXPECT_EQ(static_cast<uint32>(Uniform2iv::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<GLint>(11), cmd.location); @@ -2399,7 +2408,7 @@ TEST(GLES2FormatTest, Uniform2ivImmediate) { cmd.header.command); EXPECT_EQ(sizeof(cmd) + RoundSizeToMultipleOfEntries(sizeof(data)), - cmd.header.size * 4u); // NOLINT + cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd) + RoundSizeToMultipleOfEntries(sizeof(data))); @@ -2409,7 +2418,7 @@ TEST(GLES2FormatTest, Uniform2ivImmediate) { } TEST(GLES2FormatTest, Uniform3f) { - Uniform3f cmd = {{0}}; + Uniform3f cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, static_cast<GLint>(11), @@ -2418,7 +2427,7 @@ TEST(GLES2FormatTest, Uniform3f) { static_cast<GLfloat>(14)); EXPECT_EQ(static_cast<uint32>(Uniform3f::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<GLint>(11), cmd.location); @@ -2428,7 +2437,7 @@ TEST(GLES2FormatTest, Uniform3f) { } TEST(GLES2FormatTest, Uniform3fv) { - Uniform3fv cmd = {{0}}; + Uniform3fv cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, static_cast<GLint>(11), @@ -2437,7 +2446,7 @@ TEST(GLES2FormatTest, Uniform3fv) { static_cast<uint32>(14)); EXPECT_EQ(static_cast<uint32>(Uniform3fv::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<GLint>(11), cmd.location); @@ -2468,7 +2477,7 @@ TEST(GLES2FormatTest, Uniform3fvImmediate) { cmd.header.command); EXPECT_EQ(sizeof(cmd) + RoundSizeToMultipleOfEntries(sizeof(data)), - cmd.header.size * 4u); // NOLINT + cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd) + RoundSizeToMultipleOfEntries(sizeof(data))); @@ -2478,7 +2487,7 @@ TEST(GLES2FormatTest, Uniform3fvImmediate) { } TEST(GLES2FormatTest, Uniform3i) { - Uniform3i cmd = {{0}}; + Uniform3i cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, static_cast<GLint>(11), @@ -2487,7 +2496,7 @@ TEST(GLES2FormatTest, Uniform3i) { static_cast<GLint>(14)); EXPECT_EQ(static_cast<uint32>(Uniform3i::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<GLint>(11), cmd.location); @@ -2497,7 +2506,7 @@ TEST(GLES2FormatTest, Uniform3i) { } TEST(GLES2FormatTest, Uniform3iv) { - Uniform3iv cmd = {{0}}; + Uniform3iv cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, static_cast<GLint>(11), @@ -2506,7 +2515,7 @@ TEST(GLES2FormatTest, Uniform3iv) { static_cast<uint32>(14)); EXPECT_EQ(static_cast<uint32>(Uniform3iv::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<GLint>(11), cmd.location); @@ -2537,7 +2546,7 @@ TEST(GLES2FormatTest, Uniform3ivImmediate) { cmd.header.command); EXPECT_EQ(sizeof(cmd) + RoundSizeToMultipleOfEntries(sizeof(data)), - cmd.header.size * 4u); // NOLINT + cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd) + RoundSizeToMultipleOfEntries(sizeof(data))); @@ -2547,7 +2556,7 @@ TEST(GLES2FormatTest, Uniform3ivImmediate) { } TEST(GLES2FormatTest, Uniform4f) { - Uniform4f cmd = {{0}}; + Uniform4f cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, static_cast<GLint>(11), @@ -2557,7 +2566,7 @@ TEST(GLES2FormatTest, Uniform4f) { static_cast<GLfloat>(15)); EXPECT_EQ(static_cast<uint32>(Uniform4f::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<GLint>(11), cmd.location); @@ -2568,7 +2577,7 @@ TEST(GLES2FormatTest, Uniform4f) { } TEST(GLES2FormatTest, Uniform4fv) { - Uniform4fv cmd = {{0}}; + Uniform4fv cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, static_cast<GLint>(11), @@ -2577,7 +2586,7 @@ TEST(GLES2FormatTest, Uniform4fv) { static_cast<uint32>(14)); EXPECT_EQ(static_cast<uint32>(Uniform4fv::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<GLint>(11), cmd.location); @@ -2610,7 +2619,7 @@ TEST(GLES2FormatTest, Uniform4fvImmediate) { cmd.header.command); EXPECT_EQ(sizeof(cmd) + RoundSizeToMultipleOfEntries(sizeof(data)), - cmd.header.size * 4u); // NOLINT + cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd) + RoundSizeToMultipleOfEntries(sizeof(data))); @@ -2620,7 +2629,7 @@ TEST(GLES2FormatTest, Uniform4fvImmediate) { } TEST(GLES2FormatTest, Uniform4i) { - Uniform4i cmd = {{0}}; + Uniform4i cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, static_cast<GLint>(11), @@ -2630,7 +2639,7 @@ TEST(GLES2FormatTest, Uniform4i) { static_cast<GLint>(15)); EXPECT_EQ(static_cast<uint32>(Uniform4i::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<GLint>(11), cmd.location); @@ -2641,7 +2650,7 @@ TEST(GLES2FormatTest, Uniform4i) { } TEST(GLES2FormatTest, Uniform4iv) { - Uniform4iv cmd = {{0}}; + Uniform4iv cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, static_cast<GLint>(11), @@ -2650,7 +2659,7 @@ TEST(GLES2FormatTest, Uniform4iv) { static_cast<uint32>(14)); EXPECT_EQ(static_cast<uint32>(Uniform4iv::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<GLint>(11), cmd.location); @@ -2683,7 +2692,7 @@ TEST(GLES2FormatTest, Uniform4ivImmediate) { cmd.header.command); EXPECT_EQ(sizeof(cmd) + RoundSizeToMultipleOfEntries(sizeof(data)), - cmd.header.size * 4u); // NOLINT + cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd) + RoundSizeToMultipleOfEntries(sizeof(data))); @@ -2693,7 +2702,7 @@ TEST(GLES2FormatTest, Uniform4ivImmediate) { } TEST(GLES2FormatTest, UniformMatrix2fv) { - UniformMatrix2fv cmd = {{0}}; + UniformMatrix2fv cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, static_cast<GLint>(11), @@ -2703,7 +2712,7 @@ TEST(GLES2FormatTest, UniformMatrix2fv) { static_cast<uint32>(15)); EXPECT_EQ(static_cast<uint32>(UniformMatrix2fv::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<GLint>(11), cmd.location); @@ -2738,7 +2747,7 @@ TEST(GLES2FormatTest, UniformMatrix2fvImmediate) { cmd.header.command); EXPECT_EQ(sizeof(cmd) + RoundSizeToMultipleOfEntries(sizeof(data)), - cmd.header.size * 4u); // NOLINT + cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd) + RoundSizeToMultipleOfEntries(sizeof(data))); @@ -2749,7 +2758,7 @@ TEST(GLES2FormatTest, UniformMatrix2fvImmediate) { } TEST(GLES2FormatTest, UniformMatrix3fv) { - UniformMatrix3fv cmd = {{0}}; + UniformMatrix3fv cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, static_cast<GLint>(11), @@ -2759,7 +2768,7 @@ TEST(GLES2FormatTest, UniformMatrix3fv) { static_cast<uint32>(15)); EXPECT_EQ(static_cast<uint32>(UniformMatrix3fv::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<GLint>(11), cmd.location); @@ -2804,7 +2813,7 @@ TEST(GLES2FormatTest, UniformMatrix3fvImmediate) { cmd.header.command); EXPECT_EQ(sizeof(cmd) + RoundSizeToMultipleOfEntries(sizeof(data)), - cmd.header.size * 4u); // NOLINT + cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd) + RoundSizeToMultipleOfEntries(sizeof(data))); @@ -2815,7 +2824,7 @@ TEST(GLES2FormatTest, UniformMatrix3fvImmediate) { } TEST(GLES2FormatTest, UniformMatrix4fv) { - UniformMatrix4fv cmd = {{0}}; + UniformMatrix4fv cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, static_cast<GLint>(11), @@ -2825,7 +2834,7 @@ TEST(GLES2FormatTest, UniformMatrix4fv) { static_cast<uint32>(15)); EXPECT_EQ(static_cast<uint32>(UniformMatrix4fv::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<GLint>(11), cmd.location); @@ -2884,7 +2893,7 @@ TEST(GLES2FormatTest, UniformMatrix4fvImmediate) { cmd.header.command); EXPECT_EQ(sizeof(cmd) + RoundSizeToMultipleOfEntries(sizeof(data)), - cmd.header.size * 4u); // NOLINT + cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd) + RoundSizeToMultipleOfEntries(sizeof(data))); @@ -2895,40 +2904,40 @@ TEST(GLES2FormatTest, UniformMatrix4fvImmediate) { } TEST(GLES2FormatTest, UseProgram) { - UseProgram cmd = {{0}}; + UseProgram cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, static_cast<GLuint>(11)); EXPECT_EQ(static_cast<uint32>(UseProgram::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<GLuint>(11), cmd.program); } TEST(GLES2FormatTest, ValidateProgram) { - ValidateProgram cmd = {{0}}; + ValidateProgram cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, static_cast<GLuint>(11)); EXPECT_EQ(static_cast<uint32>(ValidateProgram::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<GLuint>(11), cmd.program); } TEST(GLES2FormatTest, VertexAttrib1f) { - VertexAttrib1f cmd = {{0}}; + VertexAttrib1f cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, static_cast<GLuint>(11), static_cast<GLfloat>(12)); EXPECT_EQ(static_cast<uint32>(VertexAttrib1f::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<GLuint>(11), cmd.indx); @@ -2936,7 +2945,7 @@ TEST(GLES2FormatTest, VertexAttrib1f) { } TEST(GLES2FormatTest, VertexAttrib1fv) { - VertexAttrib1fv cmd = {{0}}; + VertexAttrib1fv cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, static_cast<GLuint>(11), @@ -2944,7 +2953,7 @@ TEST(GLES2FormatTest, VertexAttrib1fv) { static_cast<uint32>(13)); EXPECT_EQ(static_cast<uint32>(VertexAttrib1fv::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<GLuint>(11), cmd.indx); @@ -2968,7 +2977,7 @@ TEST(GLES2FormatTest, VertexAttrib1fvImmediate) { cmd.header.command); EXPECT_EQ(sizeof(cmd) + RoundSizeToMultipleOfEntries(sizeof(data)), - cmd.header.size * 4u); // NOLINT + cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd) + RoundSizeToMultipleOfEntries(sizeof(data))); @@ -2977,7 +2986,7 @@ TEST(GLES2FormatTest, VertexAttrib1fvImmediate) { } TEST(GLES2FormatTest, VertexAttrib2f) { - VertexAttrib2f cmd = {{0}}; + VertexAttrib2f cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, static_cast<GLuint>(11), @@ -2985,7 +2994,7 @@ TEST(GLES2FormatTest, VertexAttrib2f) { static_cast<GLfloat>(13)); EXPECT_EQ(static_cast<uint32>(VertexAttrib2f::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<GLuint>(11), cmd.indx); @@ -2994,7 +3003,7 @@ TEST(GLES2FormatTest, VertexAttrib2f) { } TEST(GLES2FormatTest, VertexAttrib2fv) { - VertexAttrib2fv cmd = {{0}}; + VertexAttrib2fv cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, static_cast<GLuint>(11), @@ -3002,7 +3011,7 @@ TEST(GLES2FormatTest, VertexAttrib2fv) { static_cast<uint32>(13)); EXPECT_EQ(static_cast<uint32>(VertexAttrib2fv::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<GLuint>(11), cmd.indx); @@ -3027,7 +3036,7 @@ TEST(GLES2FormatTest, VertexAttrib2fvImmediate) { cmd.header.command); EXPECT_EQ(sizeof(cmd) + RoundSizeToMultipleOfEntries(sizeof(data)), - cmd.header.size * 4u); // NOLINT + cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd) + RoundSizeToMultipleOfEntries(sizeof(data))); @@ -3036,7 +3045,7 @@ TEST(GLES2FormatTest, VertexAttrib2fvImmediate) { } TEST(GLES2FormatTest, VertexAttrib3f) { - VertexAttrib3f cmd = {{0}}; + VertexAttrib3f cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, static_cast<GLuint>(11), @@ -3045,7 +3054,7 @@ TEST(GLES2FormatTest, VertexAttrib3f) { static_cast<GLfloat>(14)); EXPECT_EQ(static_cast<uint32>(VertexAttrib3f::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<GLuint>(11), cmd.indx); @@ -3055,7 +3064,7 @@ TEST(GLES2FormatTest, VertexAttrib3f) { } TEST(GLES2FormatTest, VertexAttrib3fv) { - VertexAttrib3fv cmd = {{0}}; + VertexAttrib3fv cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, static_cast<GLuint>(11), @@ -3063,7 +3072,7 @@ TEST(GLES2FormatTest, VertexAttrib3fv) { static_cast<uint32>(13)); EXPECT_EQ(static_cast<uint32>(VertexAttrib3fv::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<GLuint>(11), cmd.indx); @@ -3089,7 +3098,7 @@ TEST(GLES2FormatTest, VertexAttrib3fvImmediate) { cmd.header.command); EXPECT_EQ(sizeof(cmd) + RoundSizeToMultipleOfEntries(sizeof(data)), - cmd.header.size * 4u); // NOLINT + cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd) + RoundSizeToMultipleOfEntries(sizeof(data))); @@ -3098,7 +3107,7 @@ TEST(GLES2FormatTest, VertexAttrib3fvImmediate) { } TEST(GLES2FormatTest, VertexAttrib4f) { - VertexAttrib4f cmd = {{0}}; + VertexAttrib4f cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, static_cast<GLuint>(11), @@ -3108,7 +3117,7 @@ TEST(GLES2FormatTest, VertexAttrib4f) { static_cast<GLfloat>(15)); EXPECT_EQ(static_cast<uint32>(VertexAttrib4f::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<GLuint>(11), cmd.indx); @@ -3119,7 +3128,7 @@ TEST(GLES2FormatTest, VertexAttrib4f) { } TEST(GLES2FormatTest, VertexAttrib4fv) { - VertexAttrib4fv cmd = {{0}}; + VertexAttrib4fv cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, static_cast<GLuint>(11), @@ -3127,7 +3136,7 @@ TEST(GLES2FormatTest, VertexAttrib4fv) { static_cast<uint32>(13)); EXPECT_EQ(static_cast<uint32>(VertexAttrib4fv::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<GLuint>(11), cmd.indx); @@ -3154,7 +3163,7 @@ TEST(GLES2FormatTest, VertexAttrib4fvImmediate) { cmd.header.command); EXPECT_EQ(sizeof(cmd) + RoundSizeToMultipleOfEntries(sizeof(data)), - cmd.header.size * 4u); // NOLINT + cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd) + RoundSizeToMultipleOfEntries(sizeof(data))); @@ -3163,7 +3172,7 @@ TEST(GLES2FormatTest, VertexAttrib4fvImmediate) { } TEST(GLES2FormatTest, VertexAttribPointer) { - VertexAttribPointer cmd = {{0}}; + VertexAttribPointer cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, static_cast<GLuint>(11), @@ -3174,7 +3183,7 @@ TEST(GLES2FormatTest, VertexAttribPointer) { static_cast<GLuint>(16)); EXPECT_EQ(static_cast<uint32>(VertexAttribPointer::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<GLuint>(11), cmd.indx); @@ -3186,7 +3195,7 @@ TEST(GLES2FormatTest, VertexAttribPointer) { } TEST(GLES2FormatTest, Viewport) { - Viewport cmd = {{0}}; + Viewport cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd, static_cast<GLint>(11), @@ -3195,7 +3204,7 @@ TEST(GLES2FormatTest, Viewport) { static_cast<GLsizei>(14)); EXPECT_EQ(static_cast<uint32>(Viewport::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); EXPECT_EQ(static_cast<GLint>(11), cmd.x); @@ -3205,13 +3214,15 @@ TEST(GLES2FormatTest, Viewport) { } TEST(GLES2FormatTest, SwapBuffers) { - SwapBuffers cmd = {{0}}; + SwapBuffers cmd = { { 0 } }; void* next_cmd = cmd.Set( &cmd); EXPECT_EQ(static_cast<uint32>(SwapBuffers::kCmdId), cmd.header.command); - EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); // NOLINT + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); EXPECT_EQ(static_cast<char*>(next_cmd), reinterpret_cast<char*>(&cmd) + sizeof(cmd)); } +#endif // GPU_COMMAND_BUFFER_COMMON_GLES2_CMD_FORMAT_TEST_AUTOGEN_H_ + diff --git a/gpu/command_buffer/common/gles2_cmd_id_test_autogen.h b/gpu/command_buffer/common/gles2_cmd_id_test_autogen.h index 4f3e0d9..da6e161 100644 --- a/gpu/command_buffer/common/gles2_cmd_id_test_autogen.h +++ b/gpu/command_buffer/common/gles2_cmd_id_test_autogen.h @@ -1,4 +1,12 @@ +// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// This file is auto-generated. DO NOT EDIT! + // This file contains unit tests for gles2 commmand ids +#ifndef GPU_COMMAND_BUFFER_COMMON_GLES2_CMD_ID_TEST_AUTOGEN_H_ +#define GPU_COMMAND_BUFFER_COMMON_GLES2_CMD_ID_TEST_AUTOGEN_H_ // *** These IDs MUST NOT CHANGE!!! *** // Changing them will break all client programs. @@ -357,3 +365,5 @@ TEST(GLES2CommandIdTest, CommandIdsMatch) { GLES2_SwapBuffers_kCmdId_mismatch); } +#endif // GPU_COMMAND_BUFFER_COMMON_GLES2_CMD_ID_TEST_AUTOGEN_H_ + diff --git a/gpu/command_buffer/common/gles2_cmd_ids_autogen.h b/gpu/command_buffer/common/gles2_cmd_ids_autogen.h index fce51d0..8deb9d8 100644 --- a/gpu/command_buffer/common/gles2_cmd_ids_autogen.h +++ b/gpu/command_buffer/common/gles2_cmd_ids_autogen.h @@ -1,5 +1,12 @@ +// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + // This file is auto-generated. DO NOT EDIT! +#ifndef GPU_COMMAND_BUFFER_COMMON_GLES2_CMD_IDS_AUTOGEN_H_ +#define GPU_COMMAND_BUFFER_COMMON_GLES2_CMD_IDS_AUTOGEN_H_ + #define GLES2_COMMAND_LIST(OP) \ OP(ActiveTexture) /* 256 */ \ OP(AttachShader) /* 257 */ \ @@ -186,3 +193,5 @@ enum CommandId { kNumCommands }; +#endif // GPU_COMMAND_BUFFER_COMMON_GLES2_CMD_IDS_AUTOGEN_H_ + diff --git a/gpu/command_buffer/service/gl_interface.h b/gpu/command_buffer/service/gl_interface.h index 32b061f..ddc2c99 100644 --- a/gpu/command_buffer/service/gl_interface.h +++ b/gpu/command_buffer/service/gl_interface.h @@ -11,6 +11,27 @@ #include <GLES2/gl2types.h> +// These are Desktop GL constants that we want to test that our GLES2 +// implemenation does not let through. +#define GL_PROXY_TEXTURE_CUBE_MAP 0x851B +#define GL_BGR 0x80E0 +#define GL_BGRA 0x80E1 +#define GL_UNPACK_SWAP_BYTES 0x0CF0 +#define GL_PACK_SWAP_BYTES 0x0D00 +#define GL_PERSPECTIVE_CORRECTION_HINT 0x0C50 +#define GL_QUADS 0x0007 +#define GL_POLYGON 0x0009 +#define GL_FOG 0x0B60 +#define GL_CLIP_PLANE0 0x3000 +#define GL_GENERATE_MIPMAP 0x8191 +#define GL_PIXEL_PACK_BUFFER 0x88EB +#define GL_POINT_SPRITE 0x8861 +#define GL_MIN 0x8007 +#define GL_MAX 0x8008 +#define GL_TEXTURE_1D 0x0DE0 +#define GL_TEXTURE_3D 0x806F +#define GL_DOUBLE 0x140A + namespace gles2 { class GLInterface { diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.cc b/gpu/command_buffer/service/gles2_cmd_decoder.cc index 413f383..0345580 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder.cc +++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "gpu/command_buffer/service/gles2_cmd_decoder.h" #include <vector> #include <string> #include <map> @@ -12,7 +13,6 @@ #include "gpu/command_buffer/common/gles2_cmd_utils.h" #include "gpu/command_buffer/service/cmd_buffer_engine.h" #include "gpu/command_buffer/service/gl_utils.h" -#include "gpu/command_buffer/service/gles2_cmd_decoder.h" #include "gpu/command_buffer/service/gles2_cmd_validation.h" namespace gpu { @@ -141,7 +141,8 @@ GLenum GLErrorBitToGLError(uint32 error_bit) { } // anonymous namespace. #if defined(UNIT_TEST) -GLES2Decoder::GLES2Decoder() { +GLES2Decoder::GLES2Decoder() + : debug_(false) { #elif defined(OS_LINUX) GLES2Decoder::GLES2Decoder() : debug_(false), @@ -151,7 +152,8 @@ GLES2Decoder::GLES2Decoder() : debug_(false), hwnd_(NULL) { #else -GLES2Decoder::GLES2Decoder() { +GLES2Decoder::GLES2Decoder() + : debug_(false) { #endif } @@ -271,7 +273,7 @@ class GLES2DecoderImpl : public GLES2Decoder { GLenum type, GLsizei real_stride, GLsizei offset) { - DCHECK(real_stride > 0); + DCHECK_GT(real_stride, 0); buffer_ = buffer; size_ = size; type_ = type; @@ -363,6 +365,9 @@ class GLES2DecoderImpl : public GLES2Decoder { // Overridden from GLES2Decoder. virtual void Destroy(); + // Overridden from GLES2Decoder. + virtual uint32 GetServiceIdForTesting(uint32 client_id); + // Removes any buffers in the VertexAtrribInfos and BufferInfos. This is used // on glDeleteBuffers so we can make sure the user does not try to render // with deleted buffers. @@ -375,10 +380,15 @@ class GLES2DecoderImpl : public GLES2Decoder { // Template to help call glGenXXX functions. template <void gl_gen_function(GLES2DecoderImpl*, GLsizei, GLuint*)> bool GenGLObjects(GLsizei n, const GLuint* client_ids) { - // TODO(gman): Verify client ids are unused. + if (n < 0) { + SetGLError(GL_INVALID_VALUE); + return true; + } + if (!ValidateIdsAreUnused(n, client_ids)) { + return false; + } scoped_array<GLuint>temp(new GLuint[n]); gl_gen_function(this, n, temp.get()); - // TODO(gman): check for success before copying results. return RegisterObjects(n, client_ids, temp.get()); } @@ -391,6 +401,9 @@ class GLES2DecoderImpl : public GLES2Decoder { return true; } + // Check that the given ids are not used. + bool ValidateIdsAreUnused(GLsizei n, const GLuint* client_ids); + // Register client ids with generated service ids. bool RegisterObjects( GLsizei n, const GLuint* client_ids, const GLuint* service_ids); @@ -570,7 +583,7 @@ bool GLES2DecoderImpl::Initialize() { memset(vertex_attrib_infos_.get(), 0, sizeof(vertex_attrib_infos_[0]) * max_vertex_attribs_); - //glBindFramebuffer(0, 0); + // glBindFramebuffer(0, 0); return true; } @@ -793,11 +806,34 @@ void GLDeleteTexturesHelper( } // anonymous namespace +uint32 GLES2DecoderImpl::GetServiceIdForTesting(uint32 client_id) { +#if defined(UNIT_TEST) + GLuint service_id; + bool result = id_map_.GetServiceId(client_id, &service_id); + return result ? service_id : 0u; +#else + DCHECK(false); + return 0u; +#endif +} + +bool GLES2DecoderImpl::ValidateIdsAreUnused( + GLsizei n, const GLuint* client_ids) { + for (GLsizei ii = 0; ii < n; ++ii) { + GLuint service_id; + if (id_map_.GetServiceId(client_ids[ii], &service_id)) { + return false; + } + } + return true; +} + bool GLES2DecoderImpl::RegisterObjects( GLsizei n, const GLuint* client_ids, const GLuint* service_ids) { for (GLsizei ii = 0; ii < n; ++ii) { if (!id_map_.AddMapping(client_ids[ii], service_ids[ii])) { - // TODO(gman): fail. + NOTREACHED(); + return false; } } return true; @@ -805,7 +841,6 @@ bool GLES2DecoderImpl::RegisterObjects( void GLES2DecoderImpl::UnregisterObjects( GLsizei n, const GLuint* client_ids, GLuint* service_ids) { - // TODO(gman): check for success before copying results. for (GLsizei ii = 0; ii < n; ++ii) { if (id_map_.GetServiceId(client_ids[ii], &service_ids[ii])) { id_map_.RemoveMapping(client_ids[ii], service_ids[ii]); @@ -1020,7 +1055,7 @@ void GLES2DecoderImpl::DoBindBuffer(GLenum target, GLuint buffer) { void GLES2DecoderImpl::DoDisableVertexAttribArray(GLuint index) { if (index < max_vertex_attribs_) { vertex_attrib_infos_[index].set_enabled(false); - glEnableVertexAttribArray(index); + glDisableVertexAttribArray(index); } else { SetGLError(GL_INVALID_VALUE); } @@ -1324,7 +1359,7 @@ parse_error::ParseError GLES2DecoderImpl::HandleVertexAttribPointer( GLsizei offset = c.offset; const void* ptr = reinterpret_cast<const void*>(offset); if (!ValidateGLenumVertexAttribType(type) || - !ValidateGLenumVertexAttribSize(size) || + !ValidateGLintVertexAttribSize(size) || indx >= max_vertex_attribs_ || stride < 0) { SetGLError(GL_INVALID_VALUE); @@ -1380,7 +1415,7 @@ parse_error::ParseError GLES2DecoderImpl::HandlePixelStorei( GLenum pname = c.pname; GLenum param = c.param; if (!ValidateGLenumPixelStore(pname) || - !ValidateGLenumPixelStoreAlignment(param)) { + !ValidateGLintPixelStoreAlignment(param)) { SetGLError(GL_INVALID_VALUE); return parse_error::kParseNoError; } diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.h b/gpu/command_buffer/service/gles2_cmd_decoder.h index b10e695..646fbcc 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder.h +++ b/gpu/command_buffer/service/gles2_cmd_decoder.h @@ -63,6 +63,9 @@ class GLES2Decoder : public CommonDecoder { // Destroys the graphics context. virtual void Destroy() = 0; + // Gets a service id by client id. + virtual uint32 GetServiceIdForTesting(uint32 client_id) = 0; + protected: GLES2Decoder(); diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_autogen.h b/gpu/command_buffer/service/gles2_cmd_decoder_autogen.h index 58bb735..c87ac9e 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder_autogen.h +++ b/gpu/command_buffer/service/gles2_cmd_decoder_autogen.h @@ -1,6 +1,12 @@ +// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + // This file is auto-generated. DO NOT EDIT! // It is included by gles2_cmd_decoder.cc +#ifndef GPU_COMMAND_BUFFER_SERVICE_GLES2_CMD_DECODER_AUTOGEN_H_ +#define GPU_COMMAND_BUFFER_SERVICE_GLES2_CMD_DECODER_AUTOGEN_H_ parse_error::ParseError GLES2DecoderImpl::HandleActiveTexture( uint32 immediate_data_size, const gles2::ActiveTexture& c) { @@ -333,7 +339,6 @@ parse_error::ParseError GLES2DecoderImpl::HandleCompressedTexSubImage2D( } parse_error::ParseError GLES2DecoderImpl::HandleCompressedTexSubImage2DImmediate( - uint32 immediate_data_size, const gles2::CompressedTexSubImage2DImmediate& c) { GLenum target = static_cast<GLenum>(c.target); @@ -706,7 +711,9 @@ parse_error::ParseError GLES2DecoderImpl::HandleGenBuffers( if (buffers == NULL) { return parse_error::kParseOutOfBounds; } - GenGLObjects<GLGenBuffersHelper>(n, buffers); + if (!GenGLObjects<GLGenBuffersHelper>(n, buffers)) { + return parse_error::kParseInvalidArguments; + } return parse_error::kParseNoError; } @@ -719,7 +726,9 @@ parse_error::ParseError GLES2DecoderImpl::HandleGenBuffersImmediate( if (buffers == NULL) { return parse_error::kParseOutOfBounds; } - GenGLObjects<GLGenBuffersHelper>(n, buffers); + if (!GenGLObjects<GLGenBuffersHelper>(n, buffers)) { + return parse_error::kParseInvalidArguments; + } return parse_error::kParseNoError; } @@ -743,7 +752,9 @@ parse_error::ParseError GLES2DecoderImpl::HandleGenFramebuffers( if (framebuffers == NULL) { return parse_error::kParseOutOfBounds; } - GenGLObjects<GLGenFramebuffersHelper>(n, framebuffers); + if (!GenGLObjects<GLGenFramebuffersHelper>(n, framebuffers)) { + return parse_error::kParseInvalidArguments; + } return parse_error::kParseNoError; } @@ -756,7 +767,9 @@ parse_error::ParseError GLES2DecoderImpl::HandleGenFramebuffersImmediate( if (framebuffers == NULL) { return parse_error::kParseOutOfBounds; } - GenGLObjects<GLGenFramebuffersHelper>(n, framebuffers); + if (!GenGLObjects<GLGenFramebuffersHelper>(n, framebuffers)) { + return parse_error::kParseInvalidArguments; + } return parse_error::kParseNoError; } @@ -769,7 +782,9 @@ parse_error::ParseError GLES2DecoderImpl::HandleGenRenderbuffers( if (renderbuffers == NULL) { return parse_error::kParseOutOfBounds; } - GenGLObjects<GLGenRenderbuffersHelper>(n, renderbuffers); + if (!GenGLObjects<GLGenRenderbuffersHelper>(n, renderbuffers)) { + return parse_error::kParseInvalidArguments; + } return parse_error::kParseNoError; } @@ -782,7 +797,9 @@ parse_error::ParseError GLES2DecoderImpl::HandleGenRenderbuffersImmediate( if (renderbuffers == NULL) { return parse_error::kParseOutOfBounds; } - GenGLObjects<GLGenRenderbuffersHelper>(n, renderbuffers); + if (!GenGLObjects<GLGenRenderbuffersHelper>(n, renderbuffers)) { + return parse_error::kParseInvalidArguments; + } return parse_error::kParseNoError; } @@ -795,7 +812,9 @@ parse_error::ParseError GLES2DecoderImpl::HandleGenTextures( if (textures == NULL) { return parse_error::kParseOutOfBounds; } - GenGLObjects<GLGenTexturesHelper>(n, textures); + if (!GenGLObjects<GLGenTexturesHelper>(n, textures)) { + return parse_error::kParseInvalidArguments; + } return parse_error::kParseNoError; } @@ -808,7 +827,9 @@ parse_error::ParseError GLES2DecoderImpl::HandleGenTexturesImmediate( if (textures == NULL) { return parse_error::kParseOutOfBounds; } - GenGLObjects<GLGenTexturesHelper>(n, textures); + if (!GenGLObjects<GLGenTexturesHelper>(n, textures)) { + return parse_error::kParseInvalidArguments; + } return parse_error::kParseNoError; } @@ -875,7 +896,6 @@ parse_error::ParseError GLES2DecoderImpl::HandleGetFloatv( } parse_error::ParseError GLES2DecoderImpl::HandleGetFramebufferAttachmentParameteriv( - uint32 immediate_data_size, const gles2::GetFramebufferAttachmentParameteriv& c) { GLenum target = static_cast<GLenum>(c.target); @@ -1957,6 +1977,10 @@ parse_error::ParseError GLES2DecoderImpl::HandleUniformMatrix2fv( ComputeImmediateDataSize(immediate_data_size, 1, sizeof(GLfloat), 4); const GLfloat* value = GetSharedMemoryAs<const GLfloat*>( c.value_shm_id, c.value_shm_offset, data_size); + if (!ValidateGLbooleanFalse(transpose)) { + SetGLError(GL_INVALID_VALUE); + return parse_error::kParseNoError; + } if (value == NULL) { return parse_error::kParseOutOfBounds; } @@ -1973,6 +1997,10 @@ parse_error::ParseError GLES2DecoderImpl::HandleUniformMatrix2fvImmediate( ComputeImmediateDataSize(immediate_data_size, 1, sizeof(GLfloat), 4); const GLfloat* value = GetImmediateDataAs<const GLfloat*>( c, data_size, immediate_data_size); + if (!ValidateGLbooleanFalse(transpose)) { + SetGLError(GL_INVALID_VALUE); + return parse_error::kParseNoError; + } if (value == NULL) { return parse_error::kParseOutOfBounds; } @@ -1989,6 +2017,10 @@ parse_error::ParseError GLES2DecoderImpl::HandleUniformMatrix3fv( ComputeImmediateDataSize(immediate_data_size, 1, sizeof(GLfloat), 9); const GLfloat* value = GetSharedMemoryAs<const GLfloat*>( c.value_shm_id, c.value_shm_offset, data_size); + if (!ValidateGLbooleanFalse(transpose)) { + SetGLError(GL_INVALID_VALUE); + return parse_error::kParseNoError; + } if (value == NULL) { return parse_error::kParseOutOfBounds; } @@ -2005,6 +2037,10 @@ parse_error::ParseError GLES2DecoderImpl::HandleUniformMatrix3fvImmediate( ComputeImmediateDataSize(immediate_data_size, 1, sizeof(GLfloat), 9); const GLfloat* value = GetImmediateDataAs<const GLfloat*>( c, data_size, immediate_data_size); + if (!ValidateGLbooleanFalse(transpose)) { + SetGLError(GL_INVALID_VALUE); + return parse_error::kParseNoError; + } if (value == NULL) { return parse_error::kParseOutOfBounds; } @@ -2021,6 +2057,10 @@ parse_error::ParseError GLES2DecoderImpl::HandleUniformMatrix4fv( ComputeImmediateDataSize(immediate_data_size, 1, sizeof(GLfloat), 16); const GLfloat* value = GetSharedMemoryAs<const GLfloat*>( c.value_shm_id, c.value_shm_offset, data_size); + if (!ValidateGLbooleanFalse(transpose)) { + SetGLError(GL_INVALID_VALUE); + return parse_error::kParseNoError; + } if (value == NULL) { return parse_error::kParseOutOfBounds; } @@ -2037,6 +2077,10 @@ parse_error::ParseError GLES2DecoderImpl::HandleUniformMatrix4fvImmediate( ComputeImmediateDataSize(immediate_data_size, 1, sizeof(GLfloat), 16); const GLfloat* value = GetImmediateDataAs<const GLfloat*>( c, data_size, immediate_data_size); + if (!ValidateGLbooleanFalse(transpose)) { + SetGLError(GL_INVALID_VALUE); + return parse_error::kParseNoError; + } if (value == NULL) { return parse_error::kParseOutOfBounds; } @@ -2232,3 +2276,5 @@ parse_error::ParseError GLES2DecoderImpl::HandleSwapBuffers( return parse_error::kParseNoError; } +#endif // GPU_COMMAND_BUFFER_SERVICE_GLES2_CMD_DECODER_AUTOGEN_H_ + diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc b/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc index 9d2bfcb..4a740d5 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc +++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc @@ -5,35 +5,142 @@ #include "gpu/command_buffer/service/gles2_cmd_decoder.h" #include "gpu/command_buffer/common/gles2_cmd_format.h" #include "gpu/command_buffer/service/gl_mock.h" +#include "gpu/command_buffer/service/cmd_buffer_engine.h" #include "testing/gtest/include/gtest/gtest.h" using ::testing::_; using ::testing::Return; using ::testing::SetArgumentPointee; +using ::testing::InSequence; +using ::testing::Pointee; namespace gpu { namespace gles2 { class GLES2DecoderTest : public testing::Test { + public: + GLES2DecoderTest() + : client_buffer_id_(100), + client_framebuffer_id_(101), + client_program_id_(102), + client_renderbuffer_id_(103), + client_shader_id_(104), + client_texture_id_(105) { + memset(immediate_buffer_, 0xEE, sizeof(immediate_buffer_)); + } + protected: + static const GLint kNumVertexAttribs = 16; + + static const GLuint kServiceBufferId = 301; + static const GLuint kServiceFramebufferId = 302; + static const GLuint kServiceRenderbufferId = 303; + static const GLuint kServiceTextureId = 304; + static const GLuint kServiceProgramId = 305; + static const GLuint kServiceShaderId = 306; + + static const int32 kSharedMemoryId = 401; + static const size_t kSharedBufferSize = 2048; + static const uint32 kSharedMemoryOffset = 132; + static const int32 kInvalidSharedMemoryId = 402; + static const uint32 kInvalidSharedMemoryOffset = kSharedBufferSize + 1; + + static const uint32 kNewClientId = 501; + static const uint32 kNewServiceId = 502; + static const uint32 kInvalidClientId = 601; + + // Template to call glGenXXX functions. + template <typename T> + void GenHelper(GLuint client_id) { + int8 buffer[sizeof(T) + sizeof(client_id)]; + T& cmd = *reinterpret_cast<T*>(&buffer); + cmd.Init(1, &client_id); + EXPECT_EQ(parse_error::kParseNoError, + ExecuteImmediateCmd(cmd, sizeof(client_id))); + } + + // This template exists solely so we can specialize it for + // certain commands. + template <typename T, int id> + void SpecializedSetup() { + } + + template <typename T> + T* GetImmediateAs() { + return reinterpret_cast<T*>(immediate_buffer_); + } + + template <typename T, typename Command> + T GetImmediateDataAs(Command* cmd) { + reinterpret_cast<T>(ImmediateDataAddress(cmd)); + } + virtual void SetUp() { - gl_ = new ::gles2::MockGLInterface(); - ::gles2::GLInterface::SetGLInterface(gl_); + gl_.reset(new ::gles2::MockGLInterface()); + ::gles2::GLInterface::SetGLInterface(gl_.get()); - EXPECT_CALL(*gl_, GetIntegerv(_, _)) - .WillOnce(SetArgumentPointee<1>(16)); + EXPECT_CALL(*gl_, GetIntegerv(GL_MAX_VERTEX_ATTRIBS, _)) + .WillOnce(SetArgumentPointee<1>(kNumVertexAttribs)) + .RetiresOnSaturation(); EXPECT_CALL(*gl_, GetError()) .WillRepeatedly(Return(GL_NO_ERROR)); - decoder_ = GLES2Decoder::Create(); + engine_.reset(new MockCommandBufferEngine()); + Buffer buffer = engine_->GetSharedMemoryBuffer(kSharedMemoryId); + shared_memory_offset_ = kSharedMemoryOffset; + shared_memory_address_ = reinterpret_cast<int8*>(buffer.ptr) + + shared_memory_offset_; + shared_memory_id_ = kSharedMemoryId; + + decoder_.reset(GLES2Decoder::Create()); decoder_->Initialize(); + decoder_->set_engine(engine_.get()); + + EXPECT_CALL(*gl_, GenBuffersARB(_, _)) + .WillOnce(SetArgumentPointee<1>(kServiceBufferId)) + .RetiresOnSaturation(); + EXPECT_CALL(*gl_, GenFramebuffersEXT(_, _)) + .WillOnce(SetArgumentPointee<1>(kServiceFramebufferId)) + .RetiresOnSaturation(); + EXPECT_CALL(*gl_, GenRenderbuffersEXT(_, _)) + .WillOnce(SetArgumentPointee<1>(kServiceRenderbufferId)) + .RetiresOnSaturation(); + EXPECT_CALL(*gl_, GenTextures(_, _)) + .WillOnce(SetArgumentPointee<1>(kServiceTextureId)) + .RetiresOnSaturation(); + + GenHelper<GenBuffersImmediate>(client_buffer_id_); + GenHelper<GenFramebuffersImmediate>(client_framebuffer_id_); + GenHelper<GenRenderbuffersImmediate>(client_renderbuffer_id_); + GenHelper<GenTexturesImmediate>(client_texture_id_); + + { + EXPECT_CALL(*gl_, CreateProgram()) + .Times(1) + .WillOnce(Return(kServiceProgramId)) + .RetiresOnSaturation(); + CreateProgram cmd; + cmd.Init(client_program_id_); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); + } + + { + EXPECT_CALL(*gl_, CreateShader(_)) + .Times(1) + .WillOnce(Return(kServiceShaderId)) + .RetiresOnSaturation(); + CreateShader cmd; + cmd.Init(GL_VERTEX_SHADER, client_shader_id_); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); + } } virtual void TearDown() { decoder_->Destroy(); - delete decoder_; + decoder_.reset(); + engine_.reset(); ::gles2::GLInterface::SetGLInterface(NULL); - delete gl_; + gl_.reset(); } template <typename T> @@ -47,22 +154,77 @@ class GLES2DecoderTest : public testing::Test { template <typename T> parse_error::ParseError ExecuteImmediateCmd(const T& cmd, size_t data_size) { COMPILE_ASSERT(T::kArgFlags == cmd::kAtLeastN, Cmd_kArgFlags_not_kAtLeastN); - return decoder_.DoCommand(cmd.kCmdId, - ComputeNumEntries(sizeof(cmd) + data_size) - 1, - &cmd); + return decoder_->DoCommand(cmd.kCmdId, + ComputeNumEntries(sizeof(cmd) + data_size) - 1, + &cmd); + } + + template <typename T> + T GetSharedMemoryAs() { + return reinterpret_cast<T>(shared_memory_address_); } - ::gles2::MockGLInterface* gl_; - GLES2Decoder* decoder_; + uint32 GetServiceId(uint32 client_id) { + return decoder_->GetServiceIdForTesting(client_id); + } + + scoped_ptr<::gles2::MockGLInterface> gl_; + scoped_ptr<GLES2Decoder> decoder_; + + GLuint client_buffer_id_; + GLuint client_framebuffer_id_; + GLuint client_program_id_; + GLuint client_renderbuffer_id_; + GLuint client_shader_id_; + GLuint client_texture_id_; + + uint32 shared_memory_id_; + uint32 shared_memory_offset_; + void* shared_memory_address_; + + int8 immediate_buffer_[256]; + + private: + class MockCommandBufferEngine : public CommandBufferEngine { + public: + MockCommandBufferEngine() { + data_.reset(new int8[kSharedBufferSize]); + valid_buffer_.ptr = data_.get(); + valid_buffer_.size = kSharedBufferSize; + } + + virtual ~MockCommandBufferEngine() { + } + + Buffer GetSharedMemoryBuffer(int32 shm_id) { + return shm_id == kSharedMemoryId ? valid_buffer_ : invalid_buffer_; + } + + void set_token(int32 token) { + DCHECK(false); + } + + private: + scoped_array<int8> data_; + Buffer valid_buffer_; + Buffer invalid_buffer_; + }; + + scoped_ptr<MockCommandBufferEngine> engine_; }; -TEST_F(GLES2DecoderTest, Enable) { - EXPECT_CALL(*gl_, Enable(GL_BLEND)); +template <> +void GLES2DecoderTest::SpecializedSetup<LinkProgram, 0>() { + InSequence dummy; + EXPECT_CALL(*gl_, GetProgramiv(kServiceProgramId, GL_ACTIVE_ATTRIBUTES, _)) + .WillOnce(SetArgumentPointee<2>(0)); + EXPECT_CALL( + *gl_, + GetProgramiv(kServiceProgramId, GL_ACTIVE_ATTRIBUTE_MAX_LENGTH, _)) + .WillOnce(SetArgumentPointee<2>(0)); +}; - Enable cmd; - cmd.Init(GL_BLEND); - EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); -} +#include "gpu/command_buffer/service/gles2_cmd_decoder_unittest_autogen.h" } // namespace gles2 } // namespace gpu diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_autogen.h b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_autogen.h new file mode 100644 index 0000000..7adb61c --- /dev/null +++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_autogen.h @@ -0,0 +1,2558 @@ +// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// This file is auto-generated. DO NOT EDIT! + +// It is included by gles2_cmd_decoder_unittest.cc +#ifndef GPU_COMMAND_BUFFER_SERVICE_GLES2_CMD_DECODER_UNITTEST_AUTOGEN_H_ +#define GPU_COMMAND_BUFFER_SERVICE_GLES2_CMD_DECODER_UNITTEST_AUTOGEN_H_ + + +TEST_F(GLES2DecoderTest, ActiveTextureValidArgs) { + EXPECT_CALL(*gl_, ActiveTexture(1)); + SpecializedSetup<ActiveTexture, 0>(); + ActiveTexture cmd; + cmd.Init(1); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, AttachShaderValidArgs) { + EXPECT_CALL(*gl_, AttachShader(kServiceProgramId, kServiceShaderId)); + SpecializedSetup<AttachShader, 0>(); + AttachShader cmd; + cmd.Init(client_program_id_, client_shader_id_); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} +// TODO(gman): BindAttribLocation + +// TODO(gman): BindAttribLocationImmediate + + +TEST_F(GLES2DecoderTest, BindBufferValidArgs) { + EXPECT_CALL(*gl_, BindBuffer(GL_ARRAY_BUFFER, kServiceBufferId)); + SpecializedSetup<BindBuffer, 0>(); + BindBuffer cmd; + cmd.Init(GL_ARRAY_BUFFER, client_buffer_id_); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, BindBufferInvalidArgs0_0) { + EXPECT_CALL(*gl_, BindBuffer(_, _)).Times(0); + SpecializedSetup<BindBuffer, 0>(); + BindBuffer cmd; + cmd.Init(GL_RENDERBUFFER, client_buffer_id_); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, BindFramebufferValidArgs) { + EXPECT_CALL(*gl_, BindFramebufferEXT(GL_FRAMEBUFFER, kServiceFramebufferId)); + SpecializedSetup<BindFramebuffer, 0>(); + BindFramebuffer cmd; + cmd.Init(GL_FRAMEBUFFER, client_framebuffer_id_); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, BindRenderbufferValidArgs) { + EXPECT_CALL( + *gl_, BindRenderbufferEXT(GL_RENDERBUFFER, kServiceRenderbufferId)); + SpecializedSetup<BindRenderbuffer, 0>(); + BindRenderbuffer cmd; + cmd.Init(GL_RENDERBUFFER, client_renderbuffer_id_); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, BindTextureValidArgs) { + EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_2D, kServiceTextureId)); + SpecializedSetup<BindTexture, 0>(); + BindTexture cmd; + cmd.Init(GL_TEXTURE_2D, client_texture_id_); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, BindTextureInvalidArgs0_0) { + EXPECT_CALL(*gl_, BindTexture(_, _)).Times(0); + SpecializedSetup<BindTexture, 0>(); + BindTexture cmd; + cmd.Init(GL_TEXTURE_1D, client_texture_id_); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, BindTextureInvalidArgs0_1) { + EXPECT_CALL(*gl_, BindTexture(_, _)).Times(0); + SpecializedSetup<BindTexture, 0>(); + BindTexture cmd; + cmd.Init(GL_TEXTURE_3D, client_texture_id_); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, BlendColorValidArgs) { + EXPECT_CALL(*gl_, BlendColor(1, 2, 3, 4)); + SpecializedSetup<BlendColor, 0>(); + BlendColor cmd; + cmd.Init(1, 2, 3, 4); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, BlendEquationValidArgs) { + EXPECT_CALL(*gl_, BlendEquation(GL_FUNC_ADD)); + SpecializedSetup<BlendEquation, 0>(); + BlendEquation cmd; + cmd.Init(GL_FUNC_ADD); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, BlendEquationInvalidArgs0_0) { + EXPECT_CALL(*gl_, BlendEquation(_)).Times(0); + SpecializedSetup<BlendEquation, 0>(); + BlendEquation cmd; + cmd.Init(GL_MIN); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, BlendEquationInvalidArgs0_1) { + EXPECT_CALL(*gl_, BlendEquation(_)).Times(0); + SpecializedSetup<BlendEquation, 0>(); + BlendEquation cmd; + cmd.Init(GL_MAX); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, BlendEquationSeparateValidArgs) { + EXPECT_CALL(*gl_, BlendEquationSeparate(GL_FUNC_ADD, GL_FUNC_ADD)); + SpecializedSetup<BlendEquationSeparate, 0>(); + BlendEquationSeparate cmd; + cmd.Init(GL_FUNC_ADD, GL_FUNC_ADD); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, BlendEquationSeparateInvalidArgs0_0) { + EXPECT_CALL(*gl_, BlendEquationSeparate(_, _)).Times(0); + SpecializedSetup<BlendEquationSeparate, 0>(); + BlendEquationSeparate cmd; + cmd.Init(GL_MIN, GL_FUNC_ADD); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, BlendEquationSeparateInvalidArgs0_1) { + EXPECT_CALL(*gl_, BlendEquationSeparate(_, _)).Times(0); + SpecializedSetup<BlendEquationSeparate, 0>(); + BlendEquationSeparate cmd; + cmd.Init(GL_MAX, GL_FUNC_ADD); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, BlendEquationSeparateInvalidArgs1_0) { + EXPECT_CALL(*gl_, BlendEquationSeparate(_, _)).Times(0); + SpecializedSetup<BlendEquationSeparate, 0>(); + BlendEquationSeparate cmd; + cmd.Init(GL_FUNC_ADD, GL_MIN); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, BlendEquationSeparateInvalidArgs1_1) { + EXPECT_CALL(*gl_, BlendEquationSeparate(_, _)).Times(0); + SpecializedSetup<BlendEquationSeparate, 0>(); + BlendEquationSeparate cmd; + cmd.Init(GL_FUNC_ADD, GL_MAX); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, BlendFuncValidArgs) { + EXPECT_CALL(*gl_, BlendFunc(GL_ZERO, GL_ZERO)); + SpecializedSetup<BlendFunc, 0>(); + BlendFunc cmd; + cmd.Init(GL_ZERO, GL_ZERO); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, BlendFuncSeparateValidArgs) { + EXPECT_CALL(*gl_, BlendFuncSeparate(GL_ZERO, GL_ZERO, GL_ZERO, GL_ZERO)); + SpecializedSetup<BlendFuncSeparate, 0>(); + BlendFuncSeparate cmd; + cmd.Init(GL_ZERO, GL_ZERO, GL_ZERO, GL_ZERO); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} +// TODO(gman): BufferData + +// TODO(gman): BufferDataImmediate + +// TODO(gman): BufferSubData + +// TODO(gman): BufferSubDataImmediate + + +TEST_F(GLES2DecoderTest, CheckFramebufferStatusValidArgs) { + EXPECT_CALL(*gl_, CheckFramebufferStatusEXT(GL_FRAMEBUFFER)); + SpecializedSetup<CheckFramebufferStatus, 0>(); + CheckFramebufferStatus cmd; + cmd.Init(GL_FRAMEBUFFER); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, ClearValidArgs) { + EXPECT_CALL(*gl_, Clear(1)); + SpecializedSetup<Clear, 0>(); + Clear cmd; + cmd.Init(1); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, ClearColorValidArgs) { + EXPECT_CALL(*gl_, ClearColor(1, 2, 3, 4)); + SpecializedSetup<ClearColor, 0>(); + ClearColor cmd; + cmd.Init(1, 2, 3, 4); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, ClearDepthfValidArgs) { + EXPECT_CALL(*gl_, ClearDepth(1)); + SpecializedSetup<ClearDepthf, 0>(); + ClearDepthf cmd; + cmd.Init(1); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, ClearStencilValidArgs) { + EXPECT_CALL(*gl_, ClearStencil(1)); + SpecializedSetup<ClearStencil, 0>(); + ClearStencil cmd; + cmd.Init(1); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, ColorMaskValidArgs) { + EXPECT_CALL(*gl_, ColorMask(1, 2, 3, 4)); + SpecializedSetup<ColorMask, 0>(); + ColorMask cmd; + cmd.Init(1, 2, 3, 4); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, CompileShaderValidArgs) { + EXPECT_CALL(*gl_, CompileShader(kServiceShaderId)); + SpecializedSetup<CompileShader, 0>(); + CompileShader cmd; + cmd.Init(client_shader_id_); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} +// TODO(gman): CompressedTexImage2D + +// TODO(gman): CompressedTexImage2DImmediate + +// TODO(gman): CompressedTexSubImage2D + +// TODO(gman): CompressedTexSubImage2DImmediate + + +TEST_F(GLES2DecoderTest, CopyTexImage2DValidArgs) { + EXPECT_CALL(*gl_, CopyTexImage2D(GL_TEXTURE_2D, 2, 3, 4, 5, 6, 7, 8)); + SpecializedSetup<CopyTexImage2D, 0>(); + CopyTexImage2D cmd; + cmd.Init(GL_TEXTURE_2D, 2, 3, 4, 5, 6, 7, 8); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, CopyTexImage2DInvalidArgs0_0) { + EXPECT_CALL(*gl_, CopyTexImage2D(_, _, _, _, _, _, _, _)).Times(0); + SpecializedSetup<CopyTexImage2D, 0>(); + CopyTexImage2D cmd; + cmd.Init(GL_PROXY_TEXTURE_CUBE_MAP, 2, 3, 4, 5, 6, 7, 8); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, CopyTexSubImage2DValidArgs) { + EXPECT_CALL(*gl_, CopyTexSubImage2D(GL_TEXTURE_2D, 2, 3, 4, 5, 6, 7, 8)); + SpecializedSetup<CopyTexSubImage2D, 0>(); + CopyTexSubImage2D cmd; + cmd.Init(GL_TEXTURE_2D, 2, 3, 4, 5, 6, 7, 8); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, CopyTexSubImage2DInvalidArgs0_0) { + EXPECT_CALL(*gl_, CopyTexSubImage2D(_, _, _, _, _, _, _, _)).Times(0); + SpecializedSetup<CopyTexSubImage2D, 0>(); + CopyTexSubImage2D cmd; + cmd.Init(GL_PROXY_TEXTURE_CUBE_MAP, 2, 3, 4, 5, 6, 7, 8); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, CreateProgramValidArgs) { + EXPECT_CALL(*gl_, CreateProgram()) + .WillOnce(Return(kNewServiceId)); + SpecializedSetup<CreateProgram, 0>(); + CreateProgram cmd; + cmd.Init(kNewClientId); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); + EXPECT_EQ(GetServiceId(kNewClientId), kNewServiceId); +} + +TEST_F(GLES2DecoderTest, CreateShaderValidArgs) { + EXPECT_CALL(*gl_, CreateShader(GL_VERTEX_SHADER)) + .WillOnce(Return(kNewServiceId)); + SpecializedSetup<CreateShader, 0>(); + CreateShader cmd; + cmd.Init(GL_VERTEX_SHADER, kNewClientId); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); + EXPECT_EQ(GetServiceId(kNewClientId), kNewServiceId); +} + +TEST_F(GLES2DecoderTest, CullFaceValidArgs) { + EXPECT_CALL(*gl_, CullFace(GL_FRONT)); + SpecializedSetup<CullFace, 0>(); + CullFace cmd; + cmd.Init(GL_FRONT); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, DeleteBuffersValidArgs) { + EXPECT_CALL( + *gl_, + DeleteBuffersARB(1, Pointee(kServiceBufferId))) + .Times(1); + GetSharedMemoryAs<GLuint*>()[0] = client_buffer_id_; + SpecializedSetup<DeleteBuffers, 0>(); + DeleteBuffers cmd; + cmd.Init(1, shared_memory_id_, shared_memory_offset_); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); + EXPECT_EQ(GetServiceId(kNewClientId), 0u); +} + +TEST_F(GLES2DecoderTest, DeleteBuffersInvalidArgs) { + EXPECT_CALL(*gl_, DeleteBuffersARB(1, Pointee(0))) + .Times(1); + GetSharedMemoryAs<GLuint*>()[0] = kInvalidClientId; + SpecializedSetup<DeleteBuffers, 0>(); + DeleteBuffers cmd; + cmd.Init(1, shared_memory_id_, shared_memory_offset_); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, DeleteBuffersImmediateValidArgs) { + EXPECT_CALL( + *gl_, + DeleteBuffersARB(1, Pointee(kServiceBufferId))) + .Times(1); + DeleteBuffersImmediate& cmd = *GetImmediateAs<DeleteBuffersImmediate>(); + SpecializedSetup<DeleteBuffersImmediate, 0>(); + cmd.Init(1, &client_buffer_id_); + EXPECT_EQ(parse_error::kParseNoError, + ExecuteImmediateCmd(cmd, sizeof(client_buffer_id_))); + EXPECT_EQ(GetServiceId(kNewClientId), 0u); +} + +TEST_F(GLES2DecoderTest, DeleteBuffersImmediateInvalidArgs) { + EXPECT_CALL(*gl_, DeleteBuffersARB(1, Pointee(0))) + .Times(1); + DeleteBuffersImmediate& cmd = *GetImmediateAs<DeleteBuffersImmediate>(); + SpecializedSetup<DeleteBuffersImmediate, 0>(); + GLuint temp = kInvalidClientId; + cmd.Init(1, &temp); + EXPECT_EQ(parse_error::kParseNoError, + ExecuteImmediateCmd(cmd, sizeof(temp))); +} + +TEST_F(GLES2DecoderTest, DeleteFramebuffersValidArgs) { + EXPECT_CALL( + *gl_, + DeleteFramebuffersEXT(1, Pointee(kServiceFramebufferId))) + .Times(1); + GetSharedMemoryAs<GLuint*>()[0] = client_framebuffer_id_; + SpecializedSetup<DeleteFramebuffers, 0>(); + DeleteFramebuffers cmd; + cmd.Init(1, shared_memory_id_, shared_memory_offset_); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); + EXPECT_EQ(GetServiceId(kNewClientId), 0u); +} + +TEST_F(GLES2DecoderTest, DeleteFramebuffersInvalidArgs) { + EXPECT_CALL(*gl_, DeleteFramebuffersEXT(1, Pointee(0))) + .Times(1); + GetSharedMemoryAs<GLuint*>()[0] = kInvalidClientId; + SpecializedSetup<DeleteFramebuffers, 0>(); + DeleteFramebuffers cmd; + cmd.Init(1, shared_memory_id_, shared_memory_offset_); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, DeleteFramebuffersImmediateValidArgs) { + EXPECT_CALL( + *gl_, + DeleteFramebuffersEXT(1, Pointee(kServiceFramebufferId))) + .Times(1); + DeleteFramebuffersImmediate& cmd = + *GetImmediateAs<DeleteFramebuffersImmediate>(); + SpecializedSetup<DeleteFramebuffersImmediate, 0>(); + cmd.Init(1, &client_framebuffer_id_); + EXPECT_EQ(parse_error::kParseNoError, + ExecuteImmediateCmd(cmd, sizeof(client_framebuffer_id_))); + EXPECT_EQ(GetServiceId(kNewClientId), 0u); +} + +TEST_F(GLES2DecoderTest, DeleteFramebuffersImmediateInvalidArgs) { + EXPECT_CALL(*gl_, DeleteFramebuffersEXT(1, Pointee(0))) + .Times(1); + DeleteFramebuffersImmediate& cmd = + *GetImmediateAs<DeleteFramebuffersImmediate>(); + SpecializedSetup<DeleteFramebuffersImmediate, 0>(); + GLuint temp = kInvalidClientId; + cmd.Init(1, &temp); + EXPECT_EQ(parse_error::kParseNoError, + ExecuteImmediateCmd(cmd, sizeof(temp))); +} +// TODO(gman): DeleteProgram + + +TEST_F(GLES2DecoderTest, DeleteRenderbuffersValidArgs) { + EXPECT_CALL( + *gl_, + DeleteRenderbuffersEXT(1, Pointee(kServiceRenderbufferId))) + .Times(1); + GetSharedMemoryAs<GLuint*>()[0] = client_renderbuffer_id_; + SpecializedSetup<DeleteRenderbuffers, 0>(); + DeleteRenderbuffers cmd; + cmd.Init(1, shared_memory_id_, shared_memory_offset_); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); + EXPECT_EQ(GetServiceId(kNewClientId), 0u); +} + +TEST_F(GLES2DecoderTest, DeleteRenderbuffersInvalidArgs) { + EXPECT_CALL(*gl_, DeleteRenderbuffersEXT(1, Pointee(0))) + .Times(1); + GetSharedMemoryAs<GLuint*>()[0] = kInvalidClientId; + SpecializedSetup<DeleteRenderbuffers, 0>(); + DeleteRenderbuffers cmd; + cmd.Init(1, shared_memory_id_, shared_memory_offset_); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, DeleteRenderbuffersImmediateValidArgs) { + EXPECT_CALL( + *gl_, + DeleteRenderbuffersEXT(1, Pointee(kServiceRenderbufferId))) + .Times(1); + DeleteRenderbuffersImmediate& cmd = + *GetImmediateAs<DeleteRenderbuffersImmediate>(); + SpecializedSetup<DeleteRenderbuffersImmediate, 0>(); + cmd.Init(1, &client_renderbuffer_id_); + EXPECT_EQ(parse_error::kParseNoError, + ExecuteImmediateCmd(cmd, sizeof(client_renderbuffer_id_))); + EXPECT_EQ(GetServiceId(kNewClientId), 0u); +} + +TEST_F(GLES2DecoderTest, DeleteRenderbuffersImmediateInvalidArgs) { + EXPECT_CALL(*gl_, DeleteRenderbuffersEXT(1, Pointee(0))) + .Times(1); + DeleteRenderbuffersImmediate& cmd = + *GetImmediateAs<DeleteRenderbuffersImmediate>(); + SpecializedSetup<DeleteRenderbuffersImmediate, 0>(); + GLuint temp = kInvalidClientId; + cmd.Init(1, &temp); + EXPECT_EQ(parse_error::kParseNoError, + ExecuteImmediateCmd(cmd, sizeof(temp))); +} +// TODO(gman): DeleteShader + + +TEST_F(GLES2DecoderTest, DeleteTexturesValidArgs) { + EXPECT_CALL( + *gl_, + DeleteTextures(1, Pointee(kServiceTextureId))) + .Times(1); + GetSharedMemoryAs<GLuint*>()[0] = client_texture_id_; + SpecializedSetup<DeleteTextures, 0>(); + DeleteTextures cmd; + cmd.Init(1, shared_memory_id_, shared_memory_offset_); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); + EXPECT_EQ(GetServiceId(kNewClientId), 0u); +} + +TEST_F(GLES2DecoderTest, DeleteTexturesInvalidArgs) { + EXPECT_CALL(*gl_, DeleteTextures(1, Pointee(0))) + .Times(1); + GetSharedMemoryAs<GLuint*>()[0] = kInvalidClientId; + SpecializedSetup<DeleteTextures, 0>(); + DeleteTextures cmd; + cmd.Init(1, shared_memory_id_, shared_memory_offset_); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, DeleteTexturesImmediateValidArgs) { + EXPECT_CALL( + *gl_, + DeleteTextures(1, Pointee(kServiceTextureId))) + .Times(1); + DeleteTexturesImmediate& cmd = *GetImmediateAs<DeleteTexturesImmediate>(); + SpecializedSetup<DeleteTexturesImmediate, 0>(); + cmd.Init(1, &client_texture_id_); + EXPECT_EQ(parse_error::kParseNoError, + ExecuteImmediateCmd(cmd, sizeof(client_texture_id_))); + EXPECT_EQ(GetServiceId(kNewClientId), 0u); +} + +TEST_F(GLES2DecoderTest, DeleteTexturesImmediateInvalidArgs) { + EXPECT_CALL(*gl_, DeleteTextures(1, Pointee(0))) + .Times(1); + DeleteTexturesImmediate& cmd = *GetImmediateAs<DeleteTexturesImmediate>(); + SpecializedSetup<DeleteTexturesImmediate, 0>(); + GLuint temp = kInvalidClientId; + cmd.Init(1, &temp); + EXPECT_EQ(parse_error::kParseNoError, + ExecuteImmediateCmd(cmd, sizeof(temp))); +} + +TEST_F(GLES2DecoderTest, DepthFuncValidArgs) { + EXPECT_CALL(*gl_, DepthFunc(GL_NEVER)); + SpecializedSetup<DepthFunc, 0>(); + DepthFunc cmd; + cmd.Init(GL_NEVER); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, DepthMaskValidArgs) { + EXPECT_CALL(*gl_, DepthMask(1)); + SpecializedSetup<DepthMask, 0>(); + DepthMask cmd; + cmd.Init(1); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, DepthRangefValidArgs) { + EXPECT_CALL(*gl_, DepthRange(1, 2)); + SpecializedSetup<DepthRangef, 0>(); + DepthRangef cmd; + cmd.Init(1, 2); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, DetachShaderValidArgs) { + EXPECT_CALL(*gl_, DetachShader(kServiceProgramId, kServiceShaderId)); + SpecializedSetup<DetachShader, 0>(); + DetachShader cmd; + cmd.Init(client_program_id_, client_shader_id_); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, DisableValidArgs) { + EXPECT_CALL(*gl_, Disable(GL_BLEND)); + SpecializedSetup<Disable, 0>(); + Disable cmd; + cmd.Init(GL_BLEND); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, DisableInvalidArgs0_0) { + EXPECT_CALL(*gl_, Disable(_)).Times(0); + SpecializedSetup<Disable, 0>(); + Disable cmd; + cmd.Init(GL_CLIP_PLANE0); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, DisableInvalidArgs0_1) { + EXPECT_CALL(*gl_, Disable(_)).Times(0); + SpecializedSetup<Disable, 0>(); + Disable cmd; + cmd.Init(GL_POINT_SPRITE); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, DisableVertexAttribArrayValidArgs) { + EXPECT_CALL(*gl_, DisableVertexAttribArray(1)); + SpecializedSetup<DisableVertexAttribArray, 0>(); + DisableVertexAttribArray cmd; + cmd.Init(1); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} +// TODO(gman): DrawArrays +// TODO(gman): DrawElements + + +TEST_F(GLES2DecoderTest, EnableValidArgs) { + EXPECT_CALL(*gl_, Enable(GL_BLEND)); + SpecializedSetup<Enable, 0>(); + Enable cmd; + cmd.Init(GL_BLEND); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, EnableInvalidArgs0_0) { + EXPECT_CALL(*gl_, Enable(_)).Times(0); + SpecializedSetup<Enable, 0>(); + Enable cmd; + cmd.Init(GL_CLIP_PLANE0); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, EnableInvalidArgs0_1) { + EXPECT_CALL(*gl_, Enable(_)).Times(0); + SpecializedSetup<Enable, 0>(); + Enable cmd; + cmd.Init(GL_POINT_SPRITE); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, EnableVertexAttribArrayValidArgs) { + EXPECT_CALL(*gl_, EnableVertexAttribArray(1)); + SpecializedSetup<EnableVertexAttribArray, 0>(); + EnableVertexAttribArray cmd; + cmd.Init(1); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, FinishValidArgs) { + EXPECT_CALL(*gl_, Finish()); + SpecializedSetup<Finish, 0>(); + Finish cmd; + cmd.Init(); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, FlushValidArgs) { + EXPECT_CALL(*gl_, Flush()); + SpecializedSetup<Flush, 0>(); + Flush cmd; + cmd.Init(); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, FramebufferRenderbufferValidArgs) { + EXPECT_CALL( + *gl_, FramebufferRenderbufferEXT( + GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, + kServiceRenderbufferId)); + SpecializedSetup<FramebufferRenderbuffer, 0>(); + FramebufferRenderbuffer cmd; + cmd.Init( + GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, + client_renderbuffer_id_); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, FramebufferTexture2DValidArgs) { + EXPECT_CALL( + *gl_, FramebufferTexture2DEXT( + GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, + kServiceTextureId, 5)); + SpecializedSetup<FramebufferTexture2D, 0>(); + FramebufferTexture2D cmd; + cmd.Init( + GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, client_texture_id_, + 5); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, FramebufferTexture2DInvalidArgs2_0) { + EXPECT_CALL(*gl_, FramebufferTexture2DEXT(_, _, _, _, _)).Times(0); + SpecializedSetup<FramebufferTexture2D, 0>(); + FramebufferTexture2D cmd; + cmd.Init( + GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_PROXY_TEXTURE_CUBE_MAP, + client_texture_id_, 5); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, FrontFaceValidArgs) { + EXPECT_CALL(*gl_, FrontFace(GL_CW)); + SpecializedSetup<FrontFace, 0>(); + FrontFace cmd; + cmd.Init(GL_CW); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, GenBuffersValidArgs) { + EXPECT_CALL(*gl_, GenBuffersARB(1, _)) + .WillOnce(SetArgumentPointee<1>(kNewServiceId)); + GetSharedMemoryAs<GLuint*>()[0] = kNewClientId; + SpecializedSetup<GenBuffers, 0>(); + GenBuffers cmd; + cmd.Init(1, shared_memory_id_, shared_memory_offset_); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); + EXPECT_EQ(GetServiceId(kNewClientId), kNewServiceId); +} + +TEST_F(GLES2DecoderTest, GenBuffersInvalidArgs) { + EXPECT_CALL(*gl_, GenBuffersARB(_, _)).Times(0); + GetSharedMemoryAs<GLuint*>()[0] = client_buffer_id_; + SpecializedSetup<GenBuffers, 0>(); + GenBuffers cmd; + cmd.Init(1, shared_memory_id_, shared_memory_offset_); + EXPECT_EQ(parse_error::kParseInvalidArguments, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, GenBuffersImmediateValidArgs) { + EXPECT_CALL(*gl_, GenBuffersARB(1, _)) + .WillOnce(SetArgumentPointee<1>(kNewServiceId)); + GenBuffersImmediate& cmd = *GetImmediateAs<GenBuffersImmediate>(); + GLuint temp = kNewClientId; + SpecializedSetup<GenBuffersImmediate, 0>(); + cmd.Init(1, &temp); + EXPECT_EQ(parse_error::kParseNoError, + ExecuteImmediateCmd(cmd, sizeof(temp))); + EXPECT_EQ(GetServiceId(kNewClientId), kNewServiceId); +} + +TEST_F(GLES2DecoderTest, GenBuffersImmediateInvalidArgs) { + EXPECT_CALL(*gl_, GenBuffersARB(_, _)).Times(0); + GenBuffersImmediate& cmd = *GetImmediateAs<GenBuffersImmediate>(); + SpecializedSetup<GenBuffersImmediate, 0>(); + cmd.Init(1, &client_buffer_id_); + EXPECT_EQ(parse_error::kParseInvalidArguments, + ExecuteImmediateCmd(cmd, sizeof(&client_buffer_id_))); +} + +TEST_F(GLES2DecoderTest, GenerateMipmapValidArgs) { + EXPECT_CALL(*gl_, GenerateMipmapEXT(GL_TEXTURE_2D)); + SpecializedSetup<GenerateMipmap, 0>(); + GenerateMipmap cmd; + cmd.Init(GL_TEXTURE_2D); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, GenerateMipmapInvalidArgs0_0) { + EXPECT_CALL(*gl_, GenerateMipmapEXT(_)).Times(0); + SpecializedSetup<GenerateMipmap, 0>(); + GenerateMipmap cmd; + cmd.Init(GL_TEXTURE_1D); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, GenerateMipmapInvalidArgs0_1) { + EXPECT_CALL(*gl_, GenerateMipmapEXT(_)).Times(0); + SpecializedSetup<GenerateMipmap, 0>(); + GenerateMipmap cmd; + cmd.Init(GL_TEXTURE_3D); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, GenFramebuffersValidArgs) { + EXPECT_CALL(*gl_, GenFramebuffersEXT(1, _)) + .WillOnce(SetArgumentPointee<1>(kNewServiceId)); + GetSharedMemoryAs<GLuint*>()[0] = kNewClientId; + SpecializedSetup<GenFramebuffers, 0>(); + GenFramebuffers cmd; + cmd.Init(1, shared_memory_id_, shared_memory_offset_); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); + EXPECT_EQ(GetServiceId(kNewClientId), kNewServiceId); +} + +TEST_F(GLES2DecoderTest, GenFramebuffersInvalidArgs) { + EXPECT_CALL(*gl_, GenFramebuffersEXT(_, _)).Times(0); + GetSharedMemoryAs<GLuint*>()[0] = client_framebuffer_id_; + SpecializedSetup<GenFramebuffers, 0>(); + GenFramebuffers cmd; + cmd.Init(1, shared_memory_id_, shared_memory_offset_); + EXPECT_EQ(parse_error::kParseInvalidArguments, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, GenFramebuffersImmediateValidArgs) { + EXPECT_CALL(*gl_, GenFramebuffersEXT(1, _)) + .WillOnce(SetArgumentPointee<1>(kNewServiceId)); + GenFramebuffersImmediate& cmd = *GetImmediateAs<GenFramebuffersImmediate>(); + GLuint temp = kNewClientId; + SpecializedSetup<GenFramebuffersImmediate, 0>(); + cmd.Init(1, &temp); + EXPECT_EQ(parse_error::kParseNoError, + ExecuteImmediateCmd(cmd, sizeof(temp))); + EXPECT_EQ(GetServiceId(kNewClientId), kNewServiceId); +} + +TEST_F(GLES2DecoderTest, GenFramebuffersImmediateInvalidArgs) { + EXPECT_CALL(*gl_, GenFramebuffersEXT(_, _)).Times(0); + GenFramebuffersImmediate& cmd = *GetImmediateAs<GenFramebuffersImmediate>(); + SpecializedSetup<GenFramebuffersImmediate, 0>(); + cmd.Init(1, &client_framebuffer_id_); + EXPECT_EQ(parse_error::kParseInvalidArguments, + ExecuteImmediateCmd(cmd, sizeof(&client_framebuffer_id_))); +} + +TEST_F(GLES2DecoderTest, GenRenderbuffersValidArgs) { + EXPECT_CALL(*gl_, GenRenderbuffersEXT(1, _)) + .WillOnce(SetArgumentPointee<1>(kNewServiceId)); + GetSharedMemoryAs<GLuint*>()[0] = kNewClientId; + SpecializedSetup<GenRenderbuffers, 0>(); + GenRenderbuffers cmd; + cmd.Init(1, shared_memory_id_, shared_memory_offset_); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); + EXPECT_EQ(GetServiceId(kNewClientId), kNewServiceId); +} + +TEST_F(GLES2DecoderTest, GenRenderbuffersInvalidArgs) { + EXPECT_CALL(*gl_, GenRenderbuffersEXT(_, _)).Times(0); + GetSharedMemoryAs<GLuint*>()[0] = client_renderbuffer_id_; + SpecializedSetup<GenRenderbuffers, 0>(); + GenRenderbuffers cmd; + cmd.Init(1, shared_memory_id_, shared_memory_offset_); + EXPECT_EQ(parse_error::kParseInvalidArguments, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, GenRenderbuffersImmediateValidArgs) { + EXPECT_CALL(*gl_, GenRenderbuffersEXT(1, _)) + .WillOnce(SetArgumentPointee<1>(kNewServiceId)); + GenRenderbuffersImmediate& cmd = + *GetImmediateAs<GenRenderbuffersImmediate>(); + GLuint temp = kNewClientId; + SpecializedSetup<GenRenderbuffersImmediate, 0>(); + cmd.Init(1, &temp); + EXPECT_EQ(parse_error::kParseNoError, + ExecuteImmediateCmd(cmd, sizeof(temp))); + EXPECT_EQ(GetServiceId(kNewClientId), kNewServiceId); +} + +TEST_F(GLES2DecoderTest, GenRenderbuffersImmediateInvalidArgs) { + EXPECT_CALL(*gl_, GenRenderbuffersEXT(_, _)).Times(0); + GenRenderbuffersImmediate& cmd = + *GetImmediateAs<GenRenderbuffersImmediate>(); + SpecializedSetup<GenRenderbuffersImmediate, 0>(); + cmd.Init(1, &client_renderbuffer_id_); + EXPECT_EQ(parse_error::kParseInvalidArguments, + ExecuteImmediateCmd(cmd, sizeof(&client_renderbuffer_id_))); +} + +TEST_F(GLES2DecoderTest, GenTexturesValidArgs) { + EXPECT_CALL(*gl_, GenTextures(1, _)) + .WillOnce(SetArgumentPointee<1>(kNewServiceId)); + GetSharedMemoryAs<GLuint*>()[0] = kNewClientId; + SpecializedSetup<GenTextures, 0>(); + GenTextures cmd; + cmd.Init(1, shared_memory_id_, shared_memory_offset_); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); + EXPECT_EQ(GetServiceId(kNewClientId), kNewServiceId); +} + +TEST_F(GLES2DecoderTest, GenTexturesInvalidArgs) { + EXPECT_CALL(*gl_, GenTextures(_, _)).Times(0); + GetSharedMemoryAs<GLuint*>()[0] = client_texture_id_; + SpecializedSetup<GenTextures, 0>(); + GenTextures cmd; + cmd.Init(1, shared_memory_id_, shared_memory_offset_); + EXPECT_EQ(parse_error::kParseInvalidArguments, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, GenTexturesImmediateValidArgs) { + EXPECT_CALL(*gl_, GenTextures(1, _)) + .WillOnce(SetArgumentPointee<1>(kNewServiceId)); + GenTexturesImmediate& cmd = *GetImmediateAs<GenTexturesImmediate>(); + GLuint temp = kNewClientId; + SpecializedSetup<GenTexturesImmediate, 0>(); + cmd.Init(1, &temp); + EXPECT_EQ(parse_error::kParseNoError, + ExecuteImmediateCmd(cmd, sizeof(temp))); + EXPECT_EQ(GetServiceId(kNewClientId), kNewServiceId); +} + +TEST_F(GLES2DecoderTest, GenTexturesImmediateInvalidArgs) { + EXPECT_CALL(*gl_, GenTextures(_, _)).Times(0); + GenTexturesImmediate& cmd = *GetImmediateAs<GenTexturesImmediate>(); + SpecializedSetup<GenTexturesImmediate, 0>(); + cmd.Init(1, &client_texture_id_); + EXPECT_EQ(parse_error::kParseInvalidArguments, + ExecuteImmediateCmd(cmd, sizeof(&client_texture_id_))); +} +// TODO(gman): GetActiveAttrib + +// TODO(gman): GetActiveUniform + +// TODO(gman): GetAttachedShaders + +// TODO(gman): GetAttribLocation + +// TODO(gman): GetAttribLocationImmediate + + +TEST_F(GLES2DecoderTest, GetBooleanvValidArgs) { + EXPECT_CALL( + *gl_, GetBooleanv( + 1, reinterpret_cast<GLboolean*>(shared_memory_address_))); + SpecializedSetup<GetBooleanv, 0>(); + GetBooleanv cmd; + cmd.Init(1, shared_memory_id_, shared_memory_offset_); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, GetBooleanvInvalidArgs1_0) { + EXPECT_CALL(*gl_, GetBooleanv(_, _)).Times(0); + SpecializedSetup<GetBooleanv, 0>(); + GetBooleanv cmd; + cmd.Init(1, kInvalidSharedMemoryId, 0); + EXPECT_EQ(parse_error::kParseOutOfBounds, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, GetBooleanvInvalidArgs1_1) { + EXPECT_CALL(*gl_, GetBooleanv(_, _)).Times(0); + SpecializedSetup<GetBooleanv, 0>(); + GetBooleanv cmd; + cmd.Init(1, shared_memory_id_, kInvalidSharedMemoryOffset); + EXPECT_EQ(parse_error::kParseOutOfBounds, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, GetBufferParameterivValidArgs) { + EXPECT_CALL( + *gl_, GetBufferParameteriv( + GL_ARRAY_BUFFER, GL_BUFFER_SIZE, reinterpret_cast<GLint*>( + shared_memory_address_))); + SpecializedSetup<GetBufferParameteriv, 0>(); + GetBufferParameteriv cmd; + cmd.Init( + GL_ARRAY_BUFFER, GL_BUFFER_SIZE, shared_memory_id_, + shared_memory_offset_); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, GetBufferParameterivInvalidArgs0_0) { + EXPECT_CALL(*gl_, GetBufferParameteriv(_, _, _)).Times(0); + SpecializedSetup<GetBufferParameteriv, 0>(); + GetBufferParameteriv cmd; + cmd.Init( + GL_RENDERBUFFER, GL_BUFFER_SIZE, shared_memory_id_, + shared_memory_offset_); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, GetBufferParameterivInvalidArgs1_0) { + EXPECT_CALL(*gl_, GetBufferParameteriv(_, _, _)).Times(0); + SpecializedSetup<GetBufferParameteriv, 0>(); + GetBufferParameteriv cmd; + cmd.Init( + GL_ARRAY_BUFFER, GL_PIXEL_PACK_BUFFER, shared_memory_id_, + shared_memory_offset_); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, GetBufferParameterivInvalidArgs2_0) { + EXPECT_CALL(*gl_, GetBufferParameteriv(_, _, _)).Times(0); + SpecializedSetup<GetBufferParameteriv, 0>(); + GetBufferParameteriv cmd; + cmd.Init(GL_ARRAY_BUFFER, GL_BUFFER_SIZE, kInvalidSharedMemoryId, 0); + EXPECT_EQ(parse_error::kParseOutOfBounds, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, GetBufferParameterivInvalidArgs2_1) { + EXPECT_CALL(*gl_, GetBufferParameteriv(_, _, _)).Times(0); + SpecializedSetup<GetBufferParameteriv, 0>(); + GetBufferParameteriv cmd; + cmd.Init( + GL_ARRAY_BUFFER, GL_BUFFER_SIZE, shared_memory_id_, + kInvalidSharedMemoryOffset); + EXPECT_EQ(parse_error::kParseOutOfBounds, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, GetErrorValidArgs) { + EXPECT_CALL(*gl_, GetError()); + SpecializedSetup<GetError, 0>(); + GetError cmd; + cmd.Init(shared_memory_id_, shared_memory_offset_); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, GetFloatvValidArgs) { + EXPECT_CALL( + *gl_, GetFloatv(1, reinterpret_cast<GLfloat*>(shared_memory_address_))); + SpecializedSetup<GetFloatv, 0>(); + GetFloatv cmd; + cmd.Init(1, shared_memory_id_, shared_memory_offset_); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, GetFloatvInvalidArgs1_0) { + EXPECT_CALL(*gl_, GetFloatv(_, _)).Times(0); + SpecializedSetup<GetFloatv, 0>(); + GetFloatv cmd; + cmd.Init(1, kInvalidSharedMemoryId, 0); + EXPECT_EQ(parse_error::kParseOutOfBounds, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, GetFloatvInvalidArgs1_1) { + EXPECT_CALL(*gl_, GetFloatv(_, _)).Times(0); + SpecializedSetup<GetFloatv, 0>(); + GetFloatv cmd; + cmd.Init(1, shared_memory_id_, kInvalidSharedMemoryOffset); + EXPECT_EQ(parse_error::kParseOutOfBounds, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, GetFramebufferAttachmentParameterivValidArgs) { + EXPECT_CALL( + *gl_, GetFramebufferAttachmentParameterivEXT( + GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, + GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, reinterpret_cast<GLint*>( + shared_memory_address_))); + SpecializedSetup<GetFramebufferAttachmentParameteriv, 0>(); + GetFramebufferAttachmentParameteriv cmd; + cmd.Init( + GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, + GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, shared_memory_id_, + shared_memory_offset_); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, GetFramebufferAttachmentParameterivInvalidArgs3_0) { + EXPECT_CALL( + *gl_, GetFramebufferAttachmentParameterivEXT(_, _, _, _)).Times(0); + SpecializedSetup<GetFramebufferAttachmentParameteriv, 0>(); + GetFramebufferAttachmentParameteriv cmd; + cmd.Init( + GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, + GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, kInvalidSharedMemoryId, 0); + EXPECT_EQ(parse_error::kParseOutOfBounds, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, GetFramebufferAttachmentParameterivInvalidArgs3_1) { + EXPECT_CALL( + *gl_, GetFramebufferAttachmentParameterivEXT(_, _, _, _)).Times(0); + SpecializedSetup<GetFramebufferAttachmentParameteriv, 0>(); + GetFramebufferAttachmentParameteriv cmd; + cmd.Init( + GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, + GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, shared_memory_id_, + kInvalidSharedMemoryOffset); + EXPECT_EQ(parse_error::kParseOutOfBounds, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, GetIntegervValidArgs) { + EXPECT_CALL( + *gl_, GetIntegerv(1, reinterpret_cast<GLint*>(shared_memory_address_))); + SpecializedSetup<GetIntegerv, 0>(); + GetIntegerv cmd; + cmd.Init(1, shared_memory_id_, shared_memory_offset_); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, GetIntegervInvalidArgs1_0) { + EXPECT_CALL(*gl_, GetIntegerv(_, _)).Times(0); + SpecializedSetup<GetIntegerv, 0>(); + GetIntegerv cmd; + cmd.Init(1, kInvalidSharedMemoryId, 0); + EXPECT_EQ(parse_error::kParseOutOfBounds, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, GetIntegervInvalidArgs1_1) { + EXPECT_CALL(*gl_, GetIntegerv(_, _)).Times(0); + SpecializedSetup<GetIntegerv, 0>(); + GetIntegerv cmd; + cmd.Init(1, shared_memory_id_, kInvalidSharedMemoryOffset); + EXPECT_EQ(parse_error::kParseOutOfBounds, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, GetProgramivValidArgs) { + EXPECT_CALL( + *gl_, GetProgramiv( + kServiceProgramId, GL_DELETE_STATUS, reinterpret_cast<GLint*>( + shared_memory_address_))); + SpecializedSetup<GetProgramiv, 0>(); + GetProgramiv cmd; + cmd.Init( + client_program_id_, GL_DELETE_STATUS, shared_memory_id_, + shared_memory_offset_); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, GetProgramivInvalidArgs2_0) { + EXPECT_CALL(*gl_, GetProgramiv(_, _, _)).Times(0); + SpecializedSetup<GetProgramiv, 0>(); + GetProgramiv cmd; + cmd.Init(client_program_id_, GL_DELETE_STATUS, kInvalidSharedMemoryId, 0); + EXPECT_EQ(parse_error::kParseOutOfBounds, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, GetProgramivInvalidArgs2_1) { + EXPECT_CALL(*gl_, GetProgramiv(_, _, _)).Times(0); + SpecializedSetup<GetProgramiv, 0>(); + GetProgramiv cmd; + cmd.Init( + client_program_id_, GL_DELETE_STATUS, shared_memory_id_, + kInvalidSharedMemoryOffset); + EXPECT_EQ(parse_error::kParseOutOfBounds, ExecuteCmd(cmd)); +} +// TODO(gman): GetProgramInfoLog + + +TEST_F(GLES2DecoderTest, GetRenderbufferParameterivValidArgs) { + EXPECT_CALL( + *gl_, GetRenderbufferParameterivEXT( + GL_RENDERBUFFER, GL_RENDERBUFFER_WIDTH, reinterpret_cast<GLint*>( + shared_memory_address_))); + SpecializedSetup<GetRenderbufferParameteriv, 0>(); + GetRenderbufferParameteriv cmd; + cmd.Init( + GL_RENDERBUFFER, GL_RENDERBUFFER_WIDTH, shared_memory_id_, + shared_memory_offset_); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, GetRenderbufferParameterivInvalidArgs2_0) { + EXPECT_CALL(*gl_, GetRenderbufferParameterivEXT(_, _, _)).Times(0); + SpecializedSetup<GetRenderbufferParameteriv, 0>(); + GetRenderbufferParameteriv cmd; + cmd.Init(GL_RENDERBUFFER, GL_RENDERBUFFER_WIDTH, kInvalidSharedMemoryId, 0); + EXPECT_EQ(parse_error::kParseOutOfBounds, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, GetRenderbufferParameterivInvalidArgs2_1) { + EXPECT_CALL(*gl_, GetRenderbufferParameterivEXT(_, _, _)).Times(0); + SpecializedSetup<GetRenderbufferParameteriv, 0>(); + GetRenderbufferParameteriv cmd; + cmd.Init( + GL_RENDERBUFFER, GL_RENDERBUFFER_WIDTH, shared_memory_id_, + kInvalidSharedMemoryOffset); + EXPECT_EQ(parse_error::kParseOutOfBounds, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, GetShaderivValidArgs) { + EXPECT_CALL( + *gl_, GetShaderiv( + kServiceShaderId, GL_SHADER_TYPE, reinterpret_cast<GLint*>( + shared_memory_address_))); + SpecializedSetup<GetShaderiv, 0>(); + GetShaderiv cmd; + cmd.Init( + client_shader_id_, GL_SHADER_TYPE, shared_memory_id_, + shared_memory_offset_); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, GetShaderivInvalidArgs2_0) { + EXPECT_CALL(*gl_, GetShaderiv(_, _, _)).Times(0); + SpecializedSetup<GetShaderiv, 0>(); + GetShaderiv cmd; + cmd.Init(client_shader_id_, GL_SHADER_TYPE, kInvalidSharedMemoryId, 0); + EXPECT_EQ(parse_error::kParseOutOfBounds, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, GetShaderivInvalidArgs2_1) { + EXPECT_CALL(*gl_, GetShaderiv(_, _, _)).Times(0); + SpecializedSetup<GetShaderiv, 0>(); + GetShaderiv cmd; + cmd.Init( + client_shader_id_, GL_SHADER_TYPE, shared_memory_id_, + kInvalidSharedMemoryOffset); + EXPECT_EQ(parse_error::kParseOutOfBounds, ExecuteCmd(cmd)); +} +// TODO(gman): GetShaderInfoLog + +// TODO(gman): GetShaderPrecisionFormat + +// TODO(gman): GetShaderSource + + +TEST_F(GLES2DecoderTest, GetStringValidArgs) { + EXPECT_CALL(*gl_, GetString(GL_VENDOR)); + SpecializedSetup<GetString, 0>(); + GetString cmd; + cmd.Init(GL_VENDOR); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, GetTexParameterfvValidArgs) { + EXPECT_CALL( + *gl_, GetTexParameterfv( + GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, reinterpret_cast<GLfloat*>( + shared_memory_address_))); + SpecializedSetup<GetTexParameterfv, 0>(); + GetTexParameterfv cmd; + cmd.Init( + GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, shared_memory_id_, + shared_memory_offset_); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, GetTexParameterfvInvalidArgs0_0) { + EXPECT_CALL(*gl_, GetTexParameterfv(_, _, _)).Times(0); + SpecializedSetup<GetTexParameterfv, 0>(); + GetTexParameterfv cmd; + cmd.Init( + GL_PROXY_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, shared_memory_id_, + shared_memory_offset_); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, GetTexParameterfvInvalidArgs1_0) { + EXPECT_CALL(*gl_, GetTexParameterfv(_, _, _)).Times(0); + SpecializedSetup<GetTexParameterfv, 0>(); + GetTexParameterfv cmd; + cmd.Init( + GL_TEXTURE_2D, GL_GENERATE_MIPMAP, shared_memory_id_, + shared_memory_offset_); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, GetTexParameterfvInvalidArgs2_0) { + EXPECT_CALL(*gl_, GetTexParameterfv(_, _, _)).Times(0); + SpecializedSetup<GetTexParameterfv, 0>(); + GetTexParameterfv cmd; + cmd.Init(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, kInvalidSharedMemoryId, 0); + EXPECT_EQ(parse_error::kParseOutOfBounds, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, GetTexParameterfvInvalidArgs2_1) { + EXPECT_CALL(*gl_, GetTexParameterfv(_, _, _)).Times(0); + SpecializedSetup<GetTexParameterfv, 0>(); + GetTexParameterfv cmd; + cmd.Init( + GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, shared_memory_id_, + kInvalidSharedMemoryOffset); + EXPECT_EQ(parse_error::kParseOutOfBounds, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, GetTexParameterivValidArgs) { + EXPECT_CALL( + *gl_, GetTexParameteriv( + GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, reinterpret_cast<GLint*>( + shared_memory_address_))); + SpecializedSetup<GetTexParameteriv, 0>(); + GetTexParameteriv cmd; + cmd.Init( + GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, shared_memory_id_, + shared_memory_offset_); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, GetTexParameterivInvalidArgs0_0) { + EXPECT_CALL(*gl_, GetTexParameteriv(_, _, _)).Times(0); + SpecializedSetup<GetTexParameteriv, 0>(); + GetTexParameteriv cmd; + cmd.Init( + GL_PROXY_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, shared_memory_id_, + shared_memory_offset_); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, GetTexParameterivInvalidArgs1_0) { + EXPECT_CALL(*gl_, GetTexParameteriv(_, _, _)).Times(0); + SpecializedSetup<GetTexParameteriv, 0>(); + GetTexParameteriv cmd; + cmd.Init( + GL_TEXTURE_2D, GL_GENERATE_MIPMAP, shared_memory_id_, + shared_memory_offset_); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, GetTexParameterivInvalidArgs2_0) { + EXPECT_CALL(*gl_, GetTexParameteriv(_, _, _)).Times(0); + SpecializedSetup<GetTexParameteriv, 0>(); + GetTexParameteriv cmd; + cmd.Init(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, kInvalidSharedMemoryId, 0); + EXPECT_EQ(parse_error::kParseOutOfBounds, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, GetTexParameterivInvalidArgs2_1) { + EXPECT_CALL(*gl_, GetTexParameteriv(_, _, _)).Times(0); + SpecializedSetup<GetTexParameteriv, 0>(); + GetTexParameteriv cmd; + cmd.Init( + GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, shared_memory_id_, + kInvalidSharedMemoryOffset); + EXPECT_EQ(parse_error::kParseOutOfBounds, ExecuteCmd(cmd)); +} +// TODO(gman): GetUniformfv + +// TODO(gman): GetUniformiv + +// TODO(gman): GetUniformLocation + +// TODO(gman): GetUniformLocationImmediate + + +TEST_F(GLES2DecoderTest, GetVertexAttribfvValidArgs) { + EXPECT_CALL( + *gl_, GetVertexAttribfv( + 1, GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING, reinterpret_cast<GLfloat*>( + shared_memory_address_))); + SpecializedSetup<GetVertexAttribfv, 0>(); + GetVertexAttribfv cmd; + cmd.Init( + 1, GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING, shared_memory_id_, + shared_memory_offset_); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, GetVertexAttribfvInvalidArgs2_0) { + EXPECT_CALL(*gl_, GetVertexAttribfv(_, _, _)).Times(0); + SpecializedSetup<GetVertexAttribfv, 0>(); + GetVertexAttribfv cmd; + cmd.Init( + 1, GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING, kInvalidSharedMemoryId, 0); + EXPECT_EQ(parse_error::kParseOutOfBounds, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, GetVertexAttribfvInvalidArgs2_1) { + EXPECT_CALL(*gl_, GetVertexAttribfv(_, _, _)).Times(0); + SpecializedSetup<GetVertexAttribfv, 0>(); + GetVertexAttribfv cmd; + cmd.Init( + 1, GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING, shared_memory_id_, + kInvalidSharedMemoryOffset); + EXPECT_EQ(parse_error::kParseOutOfBounds, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, GetVertexAttribivValidArgs) { + EXPECT_CALL( + *gl_, GetVertexAttribiv( + 1, GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING, reinterpret_cast<GLint*>( + shared_memory_address_))); + SpecializedSetup<GetVertexAttribiv, 0>(); + GetVertexAttribiv cmd; + cmd.Init( + 1, GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING, shared_memory_id_, + shared_memory_offset_); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, GetVertexAttribivInvalidArgs2_0) { + EXPECT_CALL(*gl_, GetVertexAttribiv(_, _, _)).Times(0); + SpecializedSetup<GetVertexAttribiv, 0>(); + GetVertexAttribiv cmd; + cmd.Init( + 1, GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING, kInvalidSharedMemoryId, 0); + EXPECT_EQ(parse_error::kParseOutOfBounds, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, GetVertexAttribivInvalidArgs2_1) { + EXPECT_CALL(*gl_, GetVertexAttribiv(_, _, _)).Times(0); + SpecializedSetup<GetVertexAttribiv, 0>(); + GetVertexAttribiv cmd; + cmd.Init( + 1, GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING, shared_memory_id_, + kInvalidSharedMemoryOffset); + EXPECT_EQ(parse_error::kParseOutOfBounds, ExecuteCmd(cmd)); +} +// TODO(gman): GetVertexAttribPointerv + + +TEST_F(GLES2DecoderTest, HintValidArgs) { + EXPECT_CALL(*gl_, Hint(GL_GENERATE_MIPMAP_HINT, GL_FASTEST)); + SpecializedSetup<Hint, 0>(); + Hint cmd; + cmd.Init(GL_GENERATE_MIPMAP_HINT, GL_FASTEST); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, HintInvalidArgs0_0) { + EXPECT_CALL(*gl_, Hint(_, _)).Times(0); + SpecializedSetup<Hint, 0>(); + Hint cmd; + cmd.Init(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, IsBufferValidArgs) { + EXPECT_CALL(*gl_, IsBuffer(kServiceBufferId)); + SpecializedSetup<IsBuffer, 0>(); + IsBuffer cmd; + cmd.Init(client_buffer_id_, shared_memory_id_, shared_memory_offset_); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, IsEnabledValidArgs) { + EXPECT_CALL(*gl_, IsEnabled(GL_BLEND)); + SpecializedSetup<IsEnabled, 0>(); + IsEnabled cmd; + cmd.Init(GL_BLEND, shared_memory_id_, shared_memory_offset_); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, IsEnabledInvalidArgs0_0) { + EXPECT_CALL(*gl_, IsEnabled(_)).Times(0); + SpecializedSetup<IsEnabled, 0>(); + IsEnabled cmd; + cmd.Init(GL_CLIP_PLANE0, shared_memory_id_, shared_memory_offset_); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, IsEnabledInvalidArgs0_1) { + EXPECT_CALL(*gl_, IsEnabled(_)).Times(0); + SpecializedSetup<IsEnabled, 0>(); + IsEnabled cmd; + cmd.Init(GL_POINT_SPRITE, shared_memory_id_, shared_memory_offset_); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, IsFramebufferValidArgs) { + EXPECT_CALL(*gl_, IsFramebufferEXT(kServiceFramebufferId)); + SpecializedSetup<IsFramebuffer, 0>(); + IsFramebuffer cmd; + cmd.Init(client_framebuffer_id_, shared_memory_id_, shared_memory_offset_); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, IsProgramValidArgs) { + EXPECT_CALL(*gl_, IsProgram(kServiceProgramId)); + SpecializedSetup<IsProgram, 0>(); + IsProgram cmd; + cmd.Init(client_program_id_, shared_memory_id_, shared_memory_offset_); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, IsRenderbufferValidArgs) { + EXPECT_CALL(*gl_, IsRenderbufferEXT(kServiceRenderbufferId)); + SpecializedSetup<IsRenderbuffer, 0>(); + IsRenderbuffer cmd; + cmd.Init(client_renderbuffer_id_, shared_memory_id_, shared_memory_offset_); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, IsShaderValidArgs) { + EXPECT_CALL(*gl_, IsShader(kServiceShaderId)); + SpecializedSetup<IsShader, 0>(); + IsShader cmd; + cmd.Init(client_shader_id_, shared_memory_id_, shared_memory_offset_); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, IsTextureValidArgs) { + EXPECT_CALL(*gl_, IsTexture(kServiceTextureId)); + SpecializedSetup<IsTexture, 0>(); + IsTexture cmd; + cmd.Init(client_texture_id_, shared_memory_id_, shared_memory_offset_); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, LineWidthValidArgs) { + EXPECT_CALL(*gl_, LineWidth(1)); + SpecializedSetup<LineWidth, 0>(); + LineWidth cmd; + cmd.Init(1); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, LinkProgramValidArgs) { + EXPECT_CALL(*gl_, LinkProgram(kServiceProgramId)); + SpecializedSetup<LinkProgram, 0>(); + LinkProgram cmd; + cmd.Init(client_program_id_); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} +// TODO(gman): PixelStorei + + +TEST_F(GLES2DecoderTest, PolygonOffsetValidArgs) { + EXPECT_CALL(*gl_, PolygonOffset(1, 2)); + SpecializedSetup<PolygonOffset, 0>(); + PolygonOffset cmd; + cmd.Init(1, 2); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} +// TODO(gman): ReadPixels + + +TEST_F(GLES2DecoderTest, RenderbufferStorageValidArgs) { + EXPECT_CALL(*gl_, RenderbufferStorageEXT(GL_RENDERBUFFER, GL_RGBA4, 3, 4)); + SpecializedSetup<RenderbufferStorage, 0>(); + RenderbufferStorage cmd; + cmd.Init(GL_RENDERBUFFER, GL_RGBA4, 3, 4); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, SampleCoverageValidArgs) { + EXPECT_CALL(*gl_, SampleCoverage(1, 2)); + SpecializedSetup<SampleCoverage, 0>(); + SampleCoverage cmd; + cmd.Init(1, 2); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, ScissorValidArgs) { + EXPECT_CALL(*gl_, Scissor(1, 2, 3, 4)); + SpecializedSetup<Scissor, 0>(); + Scissor cmd; + cmd.Init(1, 2, 3, 4); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} +// TODO(gman): ShaderSource + +// TODO(gman): ShaderSourceImmediate + + +TEST_F(GLES2DecoderTest, StencilFuncValidArgs) { + EXPECT_CALL(*gl_, StencilFunc(GL_NEVER, 2, 3)); + SpecializedSetup<StencilFunc, 0>(); + StencilFunc cmd; + cmd.Init(GL_NEVER, 2, 3); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, StencilFuncSeparateValidArgs) { + EXPECT_CALL(*gl_, StencilFuncSeparate(GL_FRONT, GL_NEVER, 3, 4)); + SpecializedSetup<StencilFuncSeparate, 0>(); + StencilFuncSeparate cmd; + cmd.Init(GL_FRONT, GL_NEVER, 3, 4); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, StencilMaskValidArgs) { + EXPECT_CALL(*gl_, StencilMask(1)); + SpecializedSetup<StencilMask, 0>(); + StencilMask cmd; + cmd.Init(1); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, StencilMaskSeparateValidArgs) { + EXPECT_CALL(*gl_, StencilMaskSeparate(GL_FRONT, 2)); + SpecializedSetup<StencilMaskSeparate, 0>(); + StencilMaskSeparate cmd; + cmd.Init(GL_FRONT, 2); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, StencilOpValidArgs) { + EXPECT_CALL(*gl_, StencilOp(GL_KEEP, GL_KEEP, GL_KEEP)); + SpecializedSetup<StencilOp, 0>(); + StencilOp cmd; + cmd.Init(GL_KEEP, GL_KEEP, GL_KEEP); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, StencilOpSeparateValidArgs) { + EXPECT_CALL(*gl_, StencilOpSeparate(GL_FRONT, GL_KEEP, GL_KEEP, GL_KEEP)); + SpecializedSetup<StencilOpSeparate, 0>(); + StencilOpSeparate cmd; + cmd.Init(GL_FRONT, GL_KEEP, GL_KEEP, GL_KEEP); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} +// TODO(gman): TexImage2D + +// TODO(gman): TexImage2DImmediate + + +TEST_F(GLES2DecoderTest, TexParameterfValidArgs) { + EXPECT_CALL(*gl_, TexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, 3)); + SpecializedSetup<TexParameterf, 0>(); + TexParameterf cmd; + cmd.Init(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, 3); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, TexParameterfInvalidArgs0_0) { + EXPECT_CALL(*gl_, TexParameterf(_, _, _)).Times(0); + SpecializedSetup<TexParameterf, 0>(); + TexParameterf cmd; + cmd.Init(GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER, 3); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, TexParameterfInvalidArgs0_1) { + EXPECT_CALL(*gl_, TexParameterf(_, _, _)).Times(0); + SpecializedSetup<TexParameterf, 0>(); + TexParameterf cmd; + cmd.Init(GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, 3); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, TexParameterfInvalidArgs1_0) { + EXPECT_CALL(*gl_, TexParameterf(_, _, _)).Times(0); + SpecializedSetup<TexParameterf, 0>(); + TexParameterf cmd; + cmd.Init(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, 3); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, TexParameterfvValidArgs) { + EXPECT_CALL( + *gl_, TexParameterfv( + GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, + reinterpret_cast<const GLfloat*>(shared_memory_address_))); + SpecializedSetup<TexParameterfv, 0>(); + TexParameterfv cmd; + cmd.Init( + GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, shared_memory_id_, + shared_memory_offset_); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, TexParameterfvInvalidArgs0_0) { + EXPECT_CALL(*gl_, TexParameterfv(_, _, _)).Times(0); + SpecializedSetup<TexParameterfv, 0>(); + TexParameterfv cmd; + cmd.Init( + GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER, shared_memory_id_, + shared_memory_offset_); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, TexParameterfvInvalidArgs0_1) { + EXPECT_CALL(*gl_, TexParameterfv(_, _, _)).Times(0); + SpecializedSetup<TexParameterfv, 0>(); + TexParameterfv cmd; + cmd.Init( + GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, shared_memory_id_, + shared_memory_offset_); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, TexParameterfvInvalidArgs1_0) { + EXPECT_CALL(*gl_, TexParameterfv(_, _, _)).Times(0); + SpecializedSetup<TexParameterfv, 0>(); + TexParameterfv cmd; + cmd.Init( + GL_TEXTURE_2D, GL_GENERATE_MIPMAP, shared_memory_id_, + shared_memory_offset_); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, TexParameterfvInvalidArgs2_0) { + EXPECT_CALL(*gl_, TexParameterfv(_, _, _)).Times(0); + SpecializedSetup<TexParameterfv, 0>(); + TexParameterfv cmd; + cmd.Init(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, kInvalidSharedMemoryId, 0); + EXPECT_EQ(parse_error::kParseOutOfBounds, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, TexParameterfvInvalidArgs2_1) { + EXPECT_CALL(*gl_, TexParameterfv(_, _, _)).Times(0); + SpecializedSetup<TexParameterfv, 0>(); + TexParameterfv cmd; + cmd.Init( + GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, shared_memory_id_, + kInvalidSharedMemoryOffset); + EXPECT_EQ(parse_error::kParseOutOfBounds, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, TexParameterfvImmediateValidArgs) { + TexParameterfvImmediate& cmd = *GetImmediateAs<TexParameterfvImmediate>(); + EXPECT_CALL( + *gl_, + TexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, + reinterpret_cast<GLfloat*>(ImmediateDataAddress(&cmd)))); + SpecializedSetup<TexParameterfvImmediate, 0>(); + GLfloat temp[1] = { 0, }; + cmd.Init(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, &temp[0]); + EXPECT_EQ(parse_error::kParseNoError, + ExecuteImmediateCmd(cmd, sizeof(temp))); +} + +TEST_F(GLES2DecoderTest, TexParameterfvImmediateInvalidArgs0_0) { + TexParameterfvImmediate& cmd = *GetImmediateAs<TexParameterfvImmediate>(); + EXPECT_CALL(*gl_, TexParameterfv(_, _, _)).Times(0); + SpecializedSetup<TexParameterfvImmediate, 0>(); + GLfloat temp[1] = { 0, }; + cmd.Init(GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER, &temp[0]); + EXPECT_EQ(parse_error::kParseNoError, + ExecuteImmediateCmd(cmd, sizeof(temp))); +} + +TEST_F(GLES2DecoderTest, TexParameterfvImmediateInvalidArgs0_1) { + TexParameterfvImmediate& cmd = *GetImmediateAs<TexParameterfvImmediate>(); + EXPECT_CALL(*gl_, TexParameterfv(_, _, _)).Times(0); + SpecializedSetup<TexParameterfvImmediate, 0>(); + GLfloat temp[1] = { 0, }; + cmd.Init(GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, &temp[0]); + EXPECT_EQ(parse_error::kParseNoError, + ExecuteImmediateCmd(cmd, sizeof(temp))); +} + +TEST_F(GLES2DecoderTest, TexParameterfvImmediateInvalidArgs1_0) { + TexParameterfvImmediate& cmd = *GetImmediateAs<TexParameterfvImmediate>(); + EXPECT_CALL(*gl_, TexParameterfv(_, _, _)).Times(0); + SpecializedSetup<TexParameterfvImmediate, 0>(); + GLfloat temp[1] = { 0, }; + cmd.Init(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, &temp[0]); + EXPECT_EQ(parse_error::kParseNoError, + ExecuteImmediateCmd(cmd, sizeof(temp))); +} + +TEST_F(GLES2DecoderTest, TexParameteriValidArgs) { + EXPECT_CALL(*gl_, TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, 3)); + SpecializedSetup<TexParameteri, 0>(); + TexParameteri cmd; + cmd.Init(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, 3); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, TexParameteriInvalidArgs0_0) { + EXPECT_CALL(*gl_, TexParameteri(_, _, _)).Times(0); + SpecializedSetup<TexParameteri, 0>(); + TexParameteri cmd; + cmd.Init(GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER, 3); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, TexParameteriInvalidArgs0_1) { + EXPECT_CALL(*gl_, TexParameteri(_, _, _)).Times(0); + SpecializedSetup<TexParameteri, 0>(); + TexParameteri cmd; + cmd.Init(GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, 3); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, TexParameteriInvalidArgs1_0) { + EXPECT_CALL(*gl_, TexParameteri(_, _, _)).Times(0); + SpecializedSetup<TexParameteri, 0>(); + TexParameteri cmd; + cmd.Init(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, 3); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, TexParameterivValidArgs) { + EXPECT_CALL( + *gl_, TexParameteriv( + GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, reinterpret_cast<const GLint*>( + shared_memory_address_))); + SpecializedSetup<TexParameteriv, 0>(); + TexParameteriv cmd; + cmd.Init( + GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, shared_memory_id_, + shared_memory_offset_); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, TexParameterivInvalidArgs0_0) { + EXPECT_CALL(*gl_, TexParameteriv(_, _, _)).Times(0); + SpecializedSetup<TexParameteriv, 0>(); + TexParameteriv cmd; + cmd.Init( + GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER, shared_memory_id_, + shared_memory_offset_); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, TexParameterivInvalidArgs0_1) { + EXPECT_CALL(*gl_, TexParameteriv(_, _, _)).Times(0); + SpecializedSetup<TexParameteriv, 0>(); + TexParameteriv cmd; + cmd.Init( + GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, shared_memory_id_, + shared_memory_offset_); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, TexParameterivInvalidArgs1_0) { + EXPECT_CALL(*gl_, TexParameteriv(_, _, _)).Times(0); + SpecializedSetup<TexParameteriv, 0>(); + TexParameteriv cmd; + cmd.Init( + GL_TEXTURE_2D, GL_GENERATE_MIPMAP, shared_memory_id_, + shared_memory_offset_); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, TexParameterivInvalidArgs2_0) { + EXPECT_CALL(*gl_, TexParameteriv(_, _, _)).Times(0); + SpecializedSetup<TexParameteriv, 0>(); + TexParameteriv cmd; + cmd.Init(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, kInvalidSharedMemoryId, 0); + EXPECT_EQ(parse_error::kParseOutOfBounds, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, TexParameterivInvalidArgs2_1) { + EXPECT_CALL(*gl_, TexParameteriv(_, _, _)).Times(0); + SpecializedSetup<TexParameteriv, 0>(); + TexParameteriv cmd; + cmd.Init( + GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, shared_memory_id_, + kInvalidSharedMemoryOffset); + EXPECT_EQ(parse_error::kParseOutOfBounds, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, TexParameterivImmediateValidArgs) { + TexParameterivImmediate& cmd = *GetImmediateAs<TexParameterivImmediate>(); + EXPECT_CALL( + *gl_, + TexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, + reinterpret_cast<GLint*>(ImmediateDataAddress(&cmd)))); + SpecializedSetup<TexParameterivImmediate, 0>(); + GLint temp[1] = { 0, }; + cmd.Init(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, &temp[0]); + EXPECT_EQ(parse_error::kParseNoError, + ExecuteImmediateCmd(cmd, sizeof(temp))); +} + +TEST_F(GLES2DecoderTest, TexParameterivImmediateInvalidArgs0_0) { + TexParameterivImmediate& cmd = *GetImmediateAs<TexParameterivImmediate>(); + EXPECT_CALL(*gl_, TexParameteriv(_, _, _)).Times(0); + SpecializedSetup<TexParameterivImmediate, 0>(); + GLint temp[1] = { 0, }; + cmd.Init(GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER, &temp[0]); + EXPECT_EQ(parse_error::kParseNoError, + ExecuteImmediateCmd(cmd, sizeof(temp))); +} + +TEST_F(GLES2DecoderTest, TexParameterivImmediateInvalidArgs0_1) { + TexParameterivImmediate& cmd = *GetImmediateAs<TexParameterivImmediate>(); + EXPECT_CALL(*gl_, TexParameteriv(_, _, _)).Times(0); + SpecializedSetup<TexParameterivImmediate, 0>(); + GLint temp[1] = { 0, }; + cmd.Init(GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, &temp[0]); + EXPECT_EQ(parse_error::kParseNoError, + ExecuteImmediateCmd(cmd, sizeof(temp))); +} + +TEST_F(GLES2DecoderTest, TexParameterivImmediateInvalidArgs1_0) { + TexParameterivImmediate& cmd = *GetImmediateAs<TexParameterivImmediate>(); + EXPECT_CALL(*gl_, TexParameteriv(_, _, _)).Times(0); + SpecializedSetup<TexParameterivImmediate, 0>(); + GLint temp[1] = { 0, }; + cmd.Init(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, &temp[0]); + EXPECT_EQ(parse_error::kParseNoError, + ExecuteImmediateCmd(cmd, sizeof(temp))); +} +// TODO(gman): TexSubImage2D + +// TODO(gman): TexSubImage2DImmediate + + +TEST_F(GLES2DecoderTest, Uniform1fValidArgs) { + EXPECT_CALL(*gl_, Uniform1f(1, 2)); + SpecializedSetup<Uniform1f, 0>(); + Uniform1f cmd; + cmd.Init(1, 2); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, Uniform1fvValidArgs) { + EXPECT_CALL( + *gl_, Uniform1fv( + 1, 2, reinterpret_cast<const GLfloat*>(shared_memory_address_))); + SpecializedSetup<Uniform1fv, 0>(); + Uniform1fv cmd; + cmd.Init(1, 2, shared_memory_id_, shared_memory_offset_); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, Uniform1fvInvalidArgs2_0) { + EXPECT_CALL(*gl_, Uniform1fv(_, _, _)).Times(0); + SpecializedSetup<Uniform1fv, 0>(); + Uniform1fv cmd; + cmd.Init(1, 2, kInvalidSharedMemoryId, 0); + EXPECT_EQ(parse_error::kParseOutOfBounds, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, Uniform1fvInvalidArgs2_1) { + EXPECT_CALL(*gl_, Uniform1fv(_, _, _)).Times(0); + SpecializedSetup<Uniform1fv, 0>(); + Uniform1fv cmd; + cmd.Init(1, 2, shared_memory_id_, kInvalidSharedMemoryOffset); + EXPECT_EQ(parse_error::kParseOutOfBounds, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, Uniform1fvImmediateValidArgs) { + Uniform1fvImmediate& cmd = *GetImmediateAs<Uniform1fvImmediate>(); + EXPECT_CALL( + *gl_, + Uniform1fv(1, 2, + reinterpret_cast<GLfloat*>(ImmediateDataAddress(&cmd)))); + SpecializedSetup<Uniform1fvImmediate, 0>(); + GLfloat temp[1 * 2] = { 0, }; + cmd.Init(1, 2, &temp[0]); + EXPECT_EQ(parse_error::kParseNoError, + ExecuteImmediateCmd(cmd, sizeof(temp))); +} + +TEST_F(GLES2DecoderTest, Uniform1iValidArgs) { + EXPECT_CALL(*gl_, Uniform1i(1, 2)); + SpecializedSetup<Uniform1i, 0>(); + Uniform1i cmd; + cmd.Init(1, 2); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, Uniform1ivValidArgs) { + EXPECT_CALL( + *gl_, Uniform1iv( + 1, 2, reinterpret_cast<const GLint*>(shared_memory_address_))); + SpecializedSetup<Uniform1iv, 0>(); + Uniform1iv cmd; + cmd.Init(1, 2, shared_memory_id_, shared_memory_offset_); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, Uniform1ivInvalidArgs2_0) { + EXPECT_CALL(*gl_, Uniform1iv(_, _, _)).Times(0); + SpecializedSetup<Uniform1iv, 0>(); + Uniform1iv cmd; + cmd.Init(1, 2, kInvalidSharedMemoryId, 0); + EXPECT_EQ(parse_error::kParseOutOfBounds, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, Uniform1ivInvalidArgs2_1) { + EXPECT_CALL(*gl_, Uniform1iv(_, _, _)).Times(0); + SpecializedSetup<Uniform1iv, 0>(); + Uniform1iv cmd; + cmd.Init(1, 2, shared_memory_id_, kInvalidSharedMemoryOffset); + EXPECT_EQ(parse_error::kParseOutOfBounds, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, Uniform1ivImmediateValidArgs) { + Uniform1ivImmediate& cmd = *GetImmediateAs<Uniform1ivImmediate>(); + EXPECT_CALL( + *gl_, + Uniform1iv(1, 2, + reinterpret_cast<GLint*>(ImmediateDataAddress(&cmd)))); + SpecializedSetup<Uniform1ivImmediate, 0>(); + GLint temp[1 * 2] = { 0, }; + cmd.Init(1, 2, &temp[0]); + EXPECT_EQ(parse_error::kParseNoError, + ExecuteImmediateCmd(cmd, sizeof(temp))); +} + +TEST_F(GLES2DecoderTest, Uniform2fValidArgs) { + EXPECT_CALL(*gl_, Uniform2f(1, 2, 3)); + SpecializedSetup<Uniform2f, 0>(); + Uniform2f cmd; + cmd.Init(1, 2, 3); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, Uniform2fvValidArgs) { + EXPECT_CALL( + *gl_, Uniform2fv( + 1, 2, reinterpret_cast<const GLfloat*>(shared_memory_address_))); + SpecializedSetup<Uniform2fv, 0>(); + Uniform2fv cmd; + cmd.Init(1, 2, shared_memory_id_, shared_memory_offset_); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, Uniform2fvInvalidArgs2_0) { + EXPECT_CALL(*gl_, Uniform2fv(_, _, _)).Times(0); + SpecializedSetup<Uniform2fv, 0>(); + Uniform2fv cmd; + cmd.Init(1, 2, kInvalidSharedMemoryId, 0); + EXPECT_EQ(parse_error::kParseOutOfBounds, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, Uniform2fvInvalidArgs2_1) { + EXPECT_CALL(*gl_, Uniform2fv(_, _, _)).Times(0); + SpecializedSetup<Uniform2fv, 0>(); + Uniform2fv cmd; + cmd.Init(1, 2, shared_memory_id_, kInvalidSharedMemoryOffset); + EXPECT_EQ(parse_error::kParseOutOfBounds, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, Uniform2fvImmediateValidArgs) { + Uniform2fvImmediate& cmd = *GetImmediateAs<Uniform2fvImmediate>(); + EXPECT_CALL( + *gl_, + Uniform2fv(1, 2, + reinterpret_cast<GLfloat*>(ImmediateDataAddress(&cmd)))); + SpecializedSetup<Uniform2fvImmediate, 0>(); + GLfloat temp[2 * 2] = { 0, }; + cmd.Init(1, 2, &temp[0]); + EXPECT_EQ(parse_error::kParseNoError, + ExecuteImmediateCmd(cmd, sizeof(temp))); +} + +TEST_F(GLES2DecoderTest, Uniform2iValidArgs) { + EXPECT_CALL(*gl_, Uniform2i(1, 2, 3)); + SpecializedSetup<Uniform2i, 0>(); + Uniform2i cmd; + cmd.Init(1, 2, 3); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, Uniform2ivValidArgs) { + EXPECT_CALL( + *gl_, Uniform2iv( + 1, 2, reinterpret_cast<const GLint*>(shared_memory_address_))); + SpecializedSetup<Uniform2iv, 0>(); + Uniform2iv cmd; + cmd.Init(1, 2, shared_memory_id_, shared_memory_offset_); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, Uniform2ivInvalidArgs2_0) { + EXPECT_CALL(*gl_, Uniform2iv(_, _, _)).Times(0); + SpecializedSetup<Uniform2iv, 0>(); + Uniform2iv cmd; + cmd.Init(1, 2, kInvalidSharedMemoryId, 0); + EXPECT_EQ(parse_error::kParseOutOfBounds, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, Uniform2ivInvalidArgs2_1) { + EXPECT_CALL(*gl_, Uniform2iv(_, _, _)).Times(0); + SpecializedSetup<Uniform2iv, 0>(); + Uniform2iv cmd; + cmd.Init(1, 2, shared_memory_id_, kInvalidSharedMemoryOffset); + EXPECT_EQ(parse_error::kParseOutOfBounds, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, Uniform2ivImmediateValidArgs) { + Uniform2ivImmediate& cmd = *GetImmediateAs<Uniform2ivImmediate>(); + EXPECT_CALL( + *gl_, + Uniform2iv(1, 2, + reinterpret_cast<GLint*>(ImmediateDataAddress(&cmd)))); + SpecializedSetup<Uniform2ivImmediate, 0>(); + GLint temp[2 * 2] = { 0, }; + cmd.Init(1, 2, &temp[0]); + EXPECT_EQ(parse_error::kParseNoError, + ExecuteImmediateCmd(cmd, sizeof(temp))); +} + +TEST_F(GLES2DecoderTest, Uniform3fValidArgs) { + EXPECT_CALL(*gl_, Uniform3f(1, 2, 3, 4)); + SpecializedSetup<Uniform3f, 0>(); + Uniform3f cmd; + cmd.Init(1, 2, 3, 4); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, Uniform3fvValidArgs) { + EXPECT_CALL( + *gl_, Uniform3fv( + 1, 2, reinterpret_cast<const GLfloat*>(shared_memory_address_))); + SpecializedSetup<Uniform3fv, 0>(); + Uniform3fv cmd; + cmd.Init(1, 2, shared_memory_id_, shared_memory_offset_); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, Uniform3fvInvalidArgs2_0) { + EXPECT_CALL(*gl_, Uniform3fv(_, _, _)).Times(0); + SpecializedSetup<Uniform3fv, 0>(); + Uniform3fv cmd; + cmd.Init(1, 2, kInvalidSharedMemoryId, 0); + EXPECT_EQ(parse_error::kParseOutOfBounds, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, Uniform3fvInvalidArgs2_1) { + EXPECT_CALL(*gl_, Uniform3fv(_, _, _)).Times(0); + SpecializedSetup<Uniform3fv, 0>(); + Uniform3fv cmd; + cmd.Init(1, 2, shared_memory_id_, kInvalidSharedMemoryOffset); + EXPECT_EQ(parse_error::kParseOutOfBounds, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, Uniform3fvImmediateValidArgs) { + Uniform3fvImmediate& cmd = *GetImmediateAs<Uniform3fvImmediate>(); + EXPECT_CALL( + *gl_, + Uniform3fv(1, 2, + reinterpret_cast<GLfloat*>(ImmediateDataAddress(&cmd)))); + SpecializedSetup<Uniform3fvImmediate, 0>(); + GLfloat temp[3 * 2] = { 0, }; + cmd.Init(1, 2, &temp[0]); + EXPECT_EQ(parse_error::kParseNoError, + ExecuteImmediateCmd(cmd, sizeof(temp))); +} + +TEST_F(GLES2DecoderTest, Uniform3iValidArgs) { + EXPECT_CALL(*gl_, Uniform3i(1, 2, 3, 4)); + SpecializedSetup<Uniform3i, 0>(); + Uniform3i cmd; + cmd.Init(1, 2, 3, 4); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, Uniform3ivValidArgs) { + EXPECT_CALL( + *gl_, Uniform3iv( + 1, 2, reinterpret_cast<const GLint*>(shared_memory_address_))); + SpecializedSetup<Uniform3iv, 0>(); + Uniform3iv cmd; + cmd.Init(1, 2, shared_memory_id_, shared_memory_offset_); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, Uniform3ivInvalidArgs2_0) { + EXPECT_CALL(*gl_, Uniform3iv(_, _, _)).Times(0); + SpecializedSetup<Uniform3iv, 0>(); + Uniform3iv cmd; + cmd.Init(1, 2, kInvalidSharedMemoryId, 0); + EXPECT_EQ(parse_error::kParseOutOfBounds, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, Uniform3ivInvalidArgs2_1) { + EXPECT_CALL(*gl_, Uniform3iv(_, _, _)).Times(0); + SpecializedSetup<Uniform3iv, 0>(); + Uniform3iv cmd; + cmd.Init(1, 2, shared_memory_id_, kInvalidSharedMemoryOffset); + EXPECT_EQ(parse_error::kParseOutOfBounds, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, Uniform3ivImmediateValidArgs) { + Uniform3ivImmediate& cmd = *GetImmediateAs<Uniform3ivImmediate>(); + EXPECT_CALL( + *gl_, + Uniform3iv(1, 2, + reinterpret_cast<GLint*>(ImmediateDataAddress(&cmd)))); + SpecializedSetup<Uniform3ivImmediate, 0>(); + GLint temp[3 * 2] = { 0, }; + cmd.Init(1, 2, &temp[0]); + EXPECT_EQ(parse_error::kParseNoError, + ExecuteImmediateCmd(cmd, sizeof(temp))); +} + +TEST_F(GLES2DecoderTest, Uniform4fValidArgs) { + EXPECT_CALL(*gl_, Uniform4f(1, 2, 3, 4, 5)); + SpecializedSetup<Uniform4f, 0>(); + Uniform4f cmd; + cmd.Init(1, 2, 3, 4, 5); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, Uniform4fvValidArgs) { + EXPECT_CALL( + *gl_, Uniform4fv( + 1, 2, reinterpret_cast<const GLfloat*>(shared_memory_address_))); + SpecializedSetup<Uniform4fv, 0>(); + Uniform4fv cmd; + cmd.Init(1, 2, shared_memory_id_, shared_memory_offset_); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, Uniform4fvInvalidArgs2_0) { + EXPECT_CALL(*gl_, Uniform4fv(_, _, _)).Times(0); + SpecializedSetup<Uniform4fv, 0>(); + Uniform4fv cmd; + cmd.Init(1, 2, kInvalidSharedMemoryId, 0); + EXPECT_EQ(parse_error::kParseOutOfBounds, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, Uniform4fvInvalidArgs2_1) { + EXPECT_CALL(*gl_, Uniform4fv(_, _, _)).Times(0); + SpecializedSetup<Uniform4fv, 0>(); + Uniform4fv cmd; + cmd.Init(1, 2, shared_memory_id_, kInvalidSharedMemoryOffset); + EXPECT_EQ(parse_error::kParseOutOfBounds, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, Uniform4fvImmediateValidArgs) { + Uniform4fvImmediate& cmd = *GetImmediateAs<Uniform4fvImmediate>(); + EXPECT_CALL( + *gl_, + Uniform4fv(1, 2, + reinterpret_cast<GLfloat*>(ImmediateDataAddress(&cmd)))); + SpecializedSetup<Uniform4fvImmediate, 0>(); + GLfloat temp[4 * 2] = { 0, }; + cmd.Init(1, 2, &temp[0]); + EXPECT_EQ(parse_error::kParseNoError, + ExecuteImmediateCmd(cmd, sizeof(temp))); +} + +TEST_F(GLES2DecoderTest, Uniform4iValidArgs) { + EXPECT_CALL(*gl_, Uniform4i(1, 2, 3, 4, 5)); + SpecializedSetup<Uniform4i, 0>(); + Uniform4i cmd; + cmd.Init(1, 2, 3, 4, 5); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, Uniform4ivValidArgs) { + EXPECT_CALL( + *gl_, Uniform4iv( + 1, 2, reinterpret_cast<const GLint*>(shared_memory_address_))); + SpecializedSetup<Uniform4iv, 0>(); + Uniform4iv cmd; + cmd.Init(1, 2, shared_memory_id_, shared_memory_offset_); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, Uniform4ivInvalidArgs2_0) { + EXPECT_CALL(*gl_, Uniform4iv(_, _, _)).Times(0); + SpecializedSetup<Uniform4iv, 0>(); + Uniform4iv cmd; + cmd.Init(1, 2, kInvalidSharedMemoryId, 0); + EXPECT_EQ(parse_error::kParseOutOfBounds, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, Uniform4ivInvalidArgs2_1) { + EXPECT_CALL(*gl_, Uniform4iv(_, _, _)).Times(0); + SpecializedSetup<Uniform4iv, 0>(); + Uniform4iv cmd; + cmd.Init(1, 2, shared_memory_id_, kInvalidSharedMemoryOffset); + EXPECT_EQ(parse_error::kParseOutOfBounds, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, Uniform4ivImmediateValidArgs) { + Uniform4ivImmediate& cmd = *GetImmediateAs<Uniform4ivImmediate>(); + EXPECT_CALL( + *gl_, + Uniform4iv(1, 2, + reinterpret_cast<GLint*>(ImmediateDataAddress(&cmd)))); + SpecializedSetup<Uniform4ivImmediate, 0>(); + GLint temp[4 * 2] = { 0, }; + cmd.Init(1, 2, &temp[0]); + EXPECT_EQ(parse_error::kParseNoError, + ExecuteImmediateCmd(cmd, sizeof(temp))); +} + +TEST_F(GLES2DecoderTest, UniformMatrix2fvValidArgs) { + EXPECT_CALL( + *gl_, UniformMatrix2fv( + 1, 2, false, reinterpret_cast<const GLfloat*>( + shared_memory_address_))); + SpecializedSetup<UniformMatrix2fv, 0>(); + UniformMatrix2fv cmd; + cmd.Init(1, 2, false, shared_memory_id_, shared_memory_offset_); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, UniformMatrix2fvInvalidArgs2_0) { + EXPECT_CALL(*gl_, UniformMatrix2fv(_, _, _, _)).Times(0); + SpecializedSetup<UniformMatrix2fv, 0>(); + UniformMatrix2fv cmd; + cmd.Init(1, 2, true, shared_memory_id_, shared_memory_offset_); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, UniformMatrix2fvInvalidArgs3_0) { + EXPECT_CALL(*gl_, UniformMatrix2fv(_, _, _, _)).Times(0); + SpecializedSetup<UniformMatrix2fv, 0>(); + UniformMatrix2fv cmd; + cmd.Init(1, 2, false, kInvalidSharedMemoryId, 0); + EXPECT_EQ(parse_error::kParseOutOfBounds, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, UniformMatrix2fvInvalidArgs3_1) { + EXPECT_CALL(*gl_, UniformMatrix2fv(_, _, _, _)).Times(0); + SpecializedSetup<UniformMatrix2fv, 0>(); + UniformMatrix2fv cmd; + cmd.Init(1, 2, false, shared_memory_id_, kInvalidSharedMemoryOffset); + EXPECT_EQ(parse_error::kParseOutOfBounds, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, UniformMatrix2fvImmediateValidArgs) { + UniformMatrix2fvImmediate& cmd = + *GetImmediateAs<UniformMatrix2fvImmediate>(); + EXPECT_CALL( + *gl_, + UniformMatrix2fv(1, 2, false, + reinterpret_cast<GLfloat*>(ImmediateDataAddress(&cmd)))); + SpecializedSetup<UniformMatrix2fvImmediate, 0>(); + GLfloat temp[4 * 2] = { 0, }; + cmd.Init(1, 2, false, &temp[0]); + EXPECT_EQ(parse_error::kParseNoError, + ExecuteImmediateCmd(cmd, sizeof(temp))); +} + +TEST_F(GLES2DecoderTest, UniformMatrix2fvImmediateInvalidArgs2_0) { + UniformMatrix2fvImmediate& cmd = + *GetImmediateAs<UniformMatrix2fvImmediate>(); + EXPECT_CALL(*gl_, UniformMatrix2fv(_, _, _, _)).Times(0); + SpecializedSetup<UniformMatrix2fvImmediate, 0>(); + GLfloat temp[4 * 2] = { 0, }; + cmd.Init(1, 2, true, &temp[0]); + EXPECT_EQ(parse_error::kParseNoError, + ExecuteImmediateCmd(cmd, sizeof(temp))); +} + +TEST_F(GLES2DecoderTest, UniformMatrix3fvValidArgs) { + EXPECT_CALL( + *gl_, UniformMatrix3fv( + 1, 2, false, reinterpret_cast<const GLfloat*>( + shared_memory_address_))); + SpecializedSetup<UniformMatrix3fv, 0>(); + UniformMatrix3fv cmd; + cmd.Init(1, 2, false, shared_memory_id_, shared_memory_offset_); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, UniformMatrix3fvInvalidArgs2_0) { + EXPECT_CALL(*gl_, UniformMatrix3fv(_, _, _, _)).Times(0); + SpecializedSetup<UniformMatrix3fv, 0>(); + UniformMatrix3fv cmd; + cmd.Init(1, 2, true, shared_memory_id_, shared_memory_offset_); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, UniformMatrix3fvInvalidArgs3_0) { + EXPECT_CALL(*gl_, UniformMatrix3fv(_, _, _, _)).Times(0); + SpecializedSetup<UniformMatrix3fv, 0>(); + UniformMatrix3fv cmd; + cmd.Init(1, 2, false, kInvalidSharedMemoryId, 0); + EXPECT_EQ(parse_error::kParseOutOfBounds, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, UniformMatrix3fvInvalidArgs3_1) { + EXPECT_CALL(*gl_, UniformMatrix3fv(_, _, _, _)).Times(0); + SpecializedSetup<UniformMatrix3fv, 0>(); + UniformMatrix3fv cmd; + cmd.Init(1, 2, false, shared_memory_id_, kInvalidSharedMemoryOffset); + EXPECT_EQ(parse_error::kParseOutOfBounds, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, UniformMatrix3fvImmediateValidArgs) { + UniformMatrix3fvImmediate& cmd = + *GetImmediateAs<UniformMatrix3fvImmediate>(); + EXPECT_CALL( + *gl_, + UniformMatrix3fv(1, 2, false, + reinterpret_cast<GLfloat*>(ImmediateDataAddress(&cmd)))); + SpecializedSetup<UniformMatrix3fvImmediate, 0>(); + GLfloat temp[9 * 2] = { 0, }; + cmd.Init(1, 2, false, &temp[0]); + EXPECT_EQ(parse_error::kParseNoError, + ExecuteImmediateCmd(cmd, sizeof(temp))); +} + +TEST_F(GLES2DecoderTest, UniformMatrix3fvImmediateInvalidArgs2_0) { + UniformMatrix3fvImmediate& cmd = + *GetImmediateAs<UniformMatrix3fvImmediate>(); + EXPECT_CALL(*gl_, UniformMatrix3fv(_, _, _, _)).Times(0); + SpecializedSetup<UniformMatrix3fvImmediate, 0>(); + GLfloat temp[9 * 2] = { 0, }; + cmd.Init(1, 2, true, &temp[0]); + EXPECT_EQ(parse_error::kParseNoError, + ExecuteImmediateCmd(cmd, sizeof(temp))); +} + +TEST_F(GLES2DecoderTest, UniformMatrix4fvValidArgs) { + EXPECT_CALL( + *gl_, UniformMatrix4fv( + 1, 2, false, reinterpret_cast<const GLfloat*>( + shared_memory_address_))); + SpecializedSetup<UniformMatrix4fv, 0>(); + UniformMatrix4fv cmd; + cmd.Init(1, 2, false, shared_memory_id_, shared_memory_offset_); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, UniformMatrix4fvInvalidArgs2_0) { + EXPECT_CALL(*gl_, UniformMatrix4fv(_, _, _, _)).Times(0); + SpecializedSetup<UniformMatrix4fv, 0>(); + UniformMatrix4fv cmd; + cmd.Init(1, 2, true, shared_memory_id_, shared_memory_offset_); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, UniformMatrix4fvInvalidArgs3_0) { + EXPECT_CALL(*gl_, UniformMatrix4fv(_, _, _, _)).Times(0); + SpecializedSetup<UniformMatrix4fv, 0>(); + UniformMatrix4fv cmd; + cmd.Init(1, 2, false, kInvalidSharedMemoryId, 0); + EXPECT_EQ(parse_error::kParseOutOfBounds, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, UniformMatrix4fvInvalidArgs3_1) { + EXPECT_CALL(*gl_, UniformMatrix4fv(_, _, _, _)).Times(0); + SpecializedSetup<UniformMatrix4fv, 0>(); + UniformMatrix4fv cmd; + cmd.Init(1, 2, false, shared_memory_id_, kInvalidSharedMemoryOffset); + EXPECT_EQ(parse_error::kParseOutOfBounds, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, UniformMatrix4fvImmediateValidArgs) { + UniformMatrix4fvImmediate& cmd = + *GetImmediateAs<UniformMatrix4fvImmediate>(); + EXPECT_CALL( + *gl_, + UniformMatrix4fv(1, 2, false, + reinterpret_cast<GLfloat*>(ImmediateDataAddress(&cmd)))); + SpecializedSetup<UniformMatrix4fvImmediate, 0>(); + GLfloat temp[16 * 2] = { 0, }; + cmd.Init(1, 2, false, &temp[0]); + EXPECT_EQ(parse_error::kParseNoError, + ExecuteImmediateCmd(cmd, sizeof(temp))); +} + +TEST_F(GLES2DecoderTest, UniformMatrix4fvImmediateInvalidArgs2_0) { + UniformMatrix4fvImmediate& cmd = + *GetImmediateAs<UniformMatrix4fvImmediate>(); + EXPECT_CALL(*gl_, UniformMatrix4fv(_, _, _, _)).Times(0); + SpecializedSetup<UniformMatrix4fvImmediate, 0>(); + GLfloat temp[16 * 2] = { 0, }; + cmd.Init(1, 2, true, &temp[0]); + EXPECT_EQ(parse_error::kParseNoError, + ExecuteImmediateCmd(cmd, sizeof(temp))); +} +// TODO(gman): UseProgram + +TEST_F(GLES2DecoderTest, ValidateProgramValidArgs) { + EXPECT_CALL(*gl_, ValidateProgram(kServiceProgramId)); + SpecializedSetup<ValidateProgram, 0>(); + ValidateProgram cmd; + cmd.Init(client_program_id_); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, VertexAttrib1fValidArgs) { + EXPECT_CALL(*gl_, VertexAttrib1f(1, 2)); + SpecializedSetup<VertexAttrib1f, 0>(); + VertexAttrib1f cmd; + cmd.Init(1, 2); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, VertexAttrib1fvValidArgs) { + EXPECT_CALL( + *gl_, VertexAttrib1fv( + 1, reinterpret_cast<const GLfloat*>(shared_memory_address_))); + SpecializedSetup<VertexAttrib1fv, 0>(); + VertexAttrib1fv cmd; + cmd.Init(1, shared_memory_id_, shared_memory_offset_); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, VertexAttrib1fvInvalidArgs1_0) { + EXPECT_CALL(*gl_, VertexAttrib1fv(_, _)).Times(0); + SpecializedSetup<VertexAttrib1fv, 0>(); + VertexAttrib1fv cmd; + cmd.Init(1, kInvalidSharedMemoryId, 0); + EXPECT_EQ(parse_error::kParseOutOfBounds, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, VertexAttrib1fvInvalidArgs1_1) { + EXPECT_CALL(*gl_, VertexAttrib1fv(_, _)).Times(0); + SpecializedSetup<VertexAttrib1fv, 0>(); + VertexAttrib1fv cmd; + cmd.Init(1, shared_memory_id_, kInvalidSharedMemoryOffset); + EXPECT_EQ(parse_error::kParseOutOfBounds, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, VertexAttrib1fvImmediateValidArgs) { + VertexAttrib1fvImmediate& cmd = *GetImmediateAs<VertexAttrib1fvImmediate>(); + EXPECT_CALL( + *gl_, + VertexAttrib1fv(1, + reinterpret_cast<GLfloat*>(ImmediateDataAddress(&cmd)))); + SpecializedSetup<VertexAttrib1fvImmediate, 0>(); + GLfloat temp[1] = { 0, }; + cmd.Init(1, &temp[0]); + EXPECT_EQ(parse_error::kParseNoError, + ExecuteImmediateCmd(cmd, sizeof(temp))); +} + +TEST_F(GLES2DecoderTest, VertexAttrib2fValidArgs) { + EXPECT_CALL(*gl_, VertexAttrib2f(1, 2, 3)); + SpecializedSetup<VertexAttrib2f, 0>(); + VertexAttrib2f cmd; + cmd.Init(1, 2, 3); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, VertexAttrib2fvValidArgs) { + EXPECT_CALL( + *gl_, VertexAttrib2fv( + 1, reinterpret_cast<const GLfloat*>(shared_memory_address_))); + SpecializedSetup<VertexAttrib2fv, 0>(); + VertexAttrib2fv cmd; + cmd.Init(1, shared_memory_id_, shared_memory_offset_); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, VertexAttrib2fvInvalidArgs1_0) { + EXPECT_CALL(*gl_, VertexAttrib2fv(_, _)).Times(0); + SpecializedSetup<VertexAttrib2fv, 0>(); + VertexAttrib2fv cmd; + cmd.Init(1, kInvalidSharedMemoryId, 0); + EXPECT_EQ(parse_error::kParseOutOfBounds, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, VertexAttrib2fvInvalidArgs1_1) { + EXPECT_CALL(*gl_, VertexAttrib2fv(_, _)).Times(0); + SpecializedSetup<VertexAttrib2fv, 0>(); + VertexAttrib2fv cmd; + cmd.Init(1, shared_memory_id_, kInvalidSharedMemoryOffset); + EXPECT_EQ(parse_error::kParseOutOfBounds, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, VertexAttrib2fvImmediateValidArgs) { + VertexAttrib2fvImmediate& cmd = *GetImmediateAs<VertexAttrib2fvImmediate>(); + EXPECT_CALL( + *gl_, + VertexAttrib2fv(1, + reinterpret_cast<GLfloat*>(ImmediateDataAddress(&cmd)))); + SpecializedSetup<VertexAttrib2fvImmediate, 0>(); + GLfloat temp[2] = { 0, }; + cmd.Init(1, &temp[0]); + EXPECT_EQ(parse_error::kParseNoError, + ExecuteImmediateCmd(cmd, sizeof(temp))); +} + +TEST_F(GLES2DecoderTest, VertexAttrib3fValidArgs) { + EXPECT_CALL(*gl_, VertexAttrib3f(1, 2, 3, 4)); + SpecializedSetup<VertexAttrib3f, 0>(); + VertexAttrib3f cmd; + cmd.Init(1, 2, 3, 4); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, VertexAttrib3fvValidArgs) { + EXPECT_CALL( + *gl_, VertexAttrib3fv( + 1, reinterpret_cast<const GLfloat*>(shared_memory_address_))); + SpecializedSetup<VertexAttrib3fv, 0>(); + VertexAttrib3fv cmd; + cmd.Init(1, shared_memory_id_, shared_memory_offset_); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, VertexAttrib3fvInvalidArgs1_0) { + EXPECT_CALL(*gl_, VertexAttrib3fv(_, _)).Times(0); + SpecializedSetup<VertexAttrib3fv, 0>(); + VertexAttrib3fv cmd; + cmd.Init(1, kInvalidSharedMemoryId, 0); + EXPECT_EQ(parse_error::kParseOutOfBounds, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, VertexAttrib3fvInvalidArgs1_1) { + EXPECT_CALL(*gl_, VertexAttrib3fv(_, _)).Times(0); + SpecializedSetup<VertexAttrib3fv, 0>(); + VertexAttrib3fv cmd; + cmd.Init(1, shared_memory_id_, kInvalidSharedMemoryOffset); + EXPECT_EQ(parse_error::kParseOutOfBounds, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, VertexAttrib3fvImmediateValidArgs) { + VertexAttrib3fvImmediate& cmd = *GetImmediateAs<VertexAttrib3fvImmediate>(); + EXPECT_CALL( + *gl_, + VertexAttrib3fv(1, + reinterpret_cast<GLfloat*>(ImmediateDataAddress(&cmd)))); + SpecializedSetup<VertexAttrib3fvImmediate, 0>(); + GLfloat temp[3] = { 0, }; + cmd.Init(1, &temp[0]); + EXPECT_EQ(parse_error::kParseNoError, + ExecuteImmediateCmd(cmd, sizeof(temp))); +} + +TEST_F(GLES2DecoderTest, VertexAttrib4fValidArgs) { + EXPECT_CALL(*gl_, VertexAttrib4f(1, 2, 3, 4, 5)); + SpecializedSetup<VertexAttrib4f, 0>(); + VertexAttrib4f cmd; + cmd.Init(1, 2, 3, 4, 5); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, VertexAttrib4fvValidArgs) { + EXPECT_CALL( + *gl_, VertexAttrib4fv( + 1, reinterpret_cast<const GLfloat*>(shared_memory_address_))); + SpecializedSetup<VertexAttrib4fv, 0>(); + VertexAttrib4fv cmd; + cmd.Init(1, shared_memory_id_, shared_memory_offset_); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, VertexAttrib4fvInvalidArgs1_0) { + EXPECT_CALL(*gl_, VertexAttrib4fv(_, _)).Times(0); + SpecializedSetup<VertexAttrib4fv, 0>(); + VertexAttrib4fv cmd; + cmd.Init(1, kInvalidSharedMemoryId, 0); + EXPECT_EQ(parse_error::kParseOutOfBounds, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, VertexAttrib4fvInvalidArgs1_1) { + EXPECT_CALL(*gl_, VertexAttrib4fv(_, _)).Times(0); + SpecializedSetup<VertexAttrib4fv, 0>(); + VertexAttrib4fv cmd; + cmd.Init(1, shared_memory_id_, kInvalidSharedMemoryOffset); + EXPECT_EQ(parse_error::kParseOutOfBounds, ExecuteCmd(cmd)); +} + +TEST_F(GLES2DecoderTest, VertexAttrib4fvImmediateValidArgs) { + VertexAttrib4fvImmediate& cmd = *GetImmediateAs<VertexAttrib4fvImmediate>(); + EXPECT_CALL( + *gl_, + VertexAttrib4fv(1, + reinterpret_cast<GLfloat*>(ImmediateDataAddress(&cmd)))); + SpecializedSetup<VertexAttrib4fvImmediate, 0>(); + GLfloat temp[4] = { 0, }; + cmd.Init(1, &temp[0]); + EXPECT_EQ(parse_error::kParseNoError, + ExecuteImmediateCmd(cmd, sizeof(temp))); +} +// TODO(gman): VertexAttribPointer + + +TEST_F(GLES2DecoderTest, ViewportValidArgs) { + EXPECT_CALL(*gl_, Viewport(1, 2, 3, 4)); + SpecializedSetup<Viewport, 0>(); + Viewport cmd; + cmd.Init(1, 2, 3, 4); + EXPECT_EQ(parse_error::kParseNoError, ExecuteCmd(cmd)); +} +// TODO(gman): SwapBuffers +#endif // GPU_COMMAND_BUFFER_SERVICE_GLES2_CMD_DECODER_UNITTEST_AUTOGEN_H_ + diff --git a/gpu/command_buffer/service/gles2_cmd_validation_autogen.h b/gpu/command_buffer/service/gles2_cmd_validation_autogen.h index ea7bdef..fe1ca29 100644 --- a/gpu/command_buffer/service/gles2_cmd_validation_autogen.h +++ b/gpu/command_buffer/service/gles2_cmd_validation_autogen.h @@ -1,5 +1,11 @@ +// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + // This file is auto-generated. DO NOT EDIT! +#ifndef GPU_COMMAND_BUFFER_SERVICE_GLES2_CMD_VALIDATION_AUTOGEN_H_ +#define GPU_COMMAND_BUFFER_SERVICE_GLES2_CMD_VALIDATION_AUTOGEN_H_ bool ValidateGLenumBufferParameter(GLenum value); bool ValidateGLenumProgramParameter(GLenum value); @@ -25,7 +31,8 @@ bool ValidateGLenumHintMode(GLenum value); bool ValidateGLenumTextureFormat(GLenum value); bool ValidateGLenumStringType(GLenum value); bool ValidateGLenumFrameBufferTarget(GLenum value); -bool ValidateGLenumPixelStoreAlignment(GLenum value); +bool ValidateGLbooleanFalse(GLenum value); +bool ValidateGLintPixelStoreAlignment(GLenum value); bool ValidateGLenumTextureParameter(GLenum value); bool ValidateGLenumTextureTarget(GLenum value); bool ValidateGLenumShaderType(GLenum value); @@ -33,10 +40,12 @@ bool ValidateGLenumFaceType(GLenum value); bool ValidateGLenumSrcBlendFactor(GLenum value); bool ValidateGLenumVertexAttribType(GLenum value); bool ValidateGLenumStencilOp(GLenum value); -bool ValidateGLenumVertexAttribSize(GLenum value); +bool ValidateGLintVertexAttribSize(GLenum value); bool ValidateGLenumBufferTarget(GLenum value); bool ValidateGLenumPixelStore(GLenum value); bool ValidateGLenumRenderBufferParameter(GLenum value); bool ValidateGLenumFrameBufferParameter(GLenum value); bool ValidateGLenumVertexPointer(GLenum value); +#endif // GPU_COMMAND_BUFFER_SERVICE_GLES2_CMD_VALIDATION_AUTOGEN_H_ + diff --git a/gpu/command_buffer/service/gles2_cmd_validation_implementation_autogen.h b/gpu/command_buffer/service/gles2_cmd_validation_implementation_autogen.h index ffaaba3..e2bcd97 100644 --- a/gpu/command_buffer/service/gles2_cmd_validation_implementation_autogen.h +++ b/gpu/command_buffer/service/gles2_cmd_validation_implementation_autogen.h @@ -1,5 +1,11 @@ +// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + // This file is auto-generated. DO NOT EDIT! +#ifndef GPU_COMMAND_BUFFER_SERVICE_GLES2_CMD_VALIDATION_IMPLEMENTATION_AUTOGEN_H_ +#define GPU_COMMAND_BUFFER_SERVICE_GLES2_CMD_VALIDATION_IMPLEMENTATION_AUTOGEN_H_ bool ValidateGLenumBufferParameter(GLenum value) { switch (value) { @@ -303,7 +309,16 @@ bool ValidateGLenumFrameBufferTarget(GLenum value) { } } -bool ValidateGLenumPixelStoreAlignment(GLenum value) { +bool ValidateGLbooleanFalse(GLenum value) { + switch (value) { + case false: + return true; + default: + return false; + } +} + +bool ValidateGLintPixelStoreAlignment(GLenum value) { switch (value) { case 1: case 2: @@ -415,7 +430,7 @@ bool ValidateGLenumStencilOp(GLenum value) { } } -bool ValidateGLenumVertexAttribSize(GLenum value) { +bool ValidateGLintVertexAttribSize(GLenum value) { switch (value) { case 1: case 2: @@ -485,3 +500,5 @@ bool ValidateGLenumVertexPointer(GLenum value) { } } +#endif // GPU_COMMAND_BUFFER_SERVICE_GLES2_CMD_VALIDATION_IMPLEMENTATION_AUTOGEN_H_ + diff --git a/gpu/gpu.gyp b/gpu/gpu.gyp index 58294d3..d056bea 100644 --- a/gpu/gpu.gyp +++ b/gpu/gpu.gyp @@ -299,6 +299,7 @@ 'command_buffer/service/gl_mock.h', 'command_buffer/service/gl_mock.cc', 'command_buffer/service/gles2_cmd_decoder_unittest.cc', + 'command_buffer/service/gles2_cmd_decoder_unittest_autogen.h', 'command_buffer/common/gles2_cmd_format_test.cc', 'command_buffer/common/gles2_cmd_format_test_autogen.h', 'command_buffer/common/gles2_cmd_id_test.cc', |