summaryrefslogtreecommitdiffstats
path: root/gpu
diff options
context:
space:
mode:
authorgman@chromium.org <gman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-25 03:20:50 +0000
committergman@chromium.org <gman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-25 03:20:50 +0000
commit3916c97e1bb1ef3fecfdcaf9d80f239016756c06 (patch)
tree5c756aa2feec17d4a5609bcf2a16a06a12b828e8 /gpu
parent84aebedeaa91c3fadf523260c12afa136420c7d3 (diff)
downloadchromium_src-3916c97e1bb1ef3fecfdcaf9d80f239016756c06.zip
chromium_src-3916c97e1bb1ef3fecfdcaf9d80f239016756c06.tar.gz
chromium_src-3916c97e1bb1ef3fecfdcaf9d80f239016756c06.tar.bz2
Reorangizing the GLES2 code to handle shared
resources and non-renderable texture situations. I haven't written enough unit tests for this but the CL is already too big. TEST=none BUG=none Review URL: http://codereview.chromium.org/646070 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@39984 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gpu')
-rwxr-xr-xgpu/command_buffer/build_gles2_cmd_buffer.py193
-rw-r--r--gpu/command_buffer/common/gles2_cmd_utils.cc20
-rw-r--r--gpu/command_buffer/common/gles2_cmd_utils.h4
-rw-r--r--gpu/command_buffer/service/buffer_manager.cc19
-rw-r--r--gpu/command_buffer/service/buffer_manager.h36
-rw-r--r--gpu/command_buffer/service/context_group.cc59
-rw-r--r--gpu/command_buffer/service/context_group.h88
-rw-r--r--gpu/command_buffer/service/context_group_unittest.cc40
-rw-r--r--gpu/command_buffer/service/gles2_cmd_decoder.cc723
-rw-r--r--gpu/command_buffer/service/gles2_cmd_decoder.h11
-rw-r--r--gpu/command_buffer/service/gles2_cmd_decoder_autogen.h72
-rw-r--r--gpu/command_buffer/service/gles2_cmd_decoder_mock.h4
-rw-r--r--gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc730
-rw-r--r--gpu/command_buffer/service/gles2_cmd_decoder_unittest_1.cc47
-rw-r--r--gpu/command_buffer/service/gles2_cmd_decoder_unittest_1_autogen.h1241
-rw-r--r--gpu/command_buffer/service/gles2_cmd_decoder_unittest_2.cc90
-rw-r--r--gpu/command_buffer/service/gles2_cmd_decoder_unittest_2_autogen.h1278
-rw-r--r--gpu/command_buffer/service/gles2_cmd_decoder_unittest_autogen.h2551
-rw-r--r--gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.cc424
-rw-r--r--gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.h310
-rw-r--r--gpu/command_buffer/service/gpu_processor.cc2
-rw-r--r--gpu/command_buffer/service/gpu_processor.h2
-rw-r--r--gpu/command_buffer/service/gpu_processor_unittest.cc6
-rw-r--r--gpu/command_buffer/service/id_manager.h2
-rw-r--r--gpu/command_buffer/service/program_manager.cc94
-rw-r--r--gpu/command_buffer/service/program_manager.h63
-rw-r--r--gpu/command_buffer/service/program_manager_unittest.cc6
-rw-r--r--gpu/command_buffer/service/shader_manager.cc16
-rw-r--r--gpu/command_buffer/service/shader_manager.h34
-rw-r--r--gpu/command_buffer/service/texture_manager.cc73
-rw-r--r--gpu/command_buffer/service/texture_manager.h64
-rw-r--r--gpu/command_buffer/service/texture_manager_unittest.cc40
-rw-r--r--gpu/gpu.gyp14
33 files changed, 4664 insertions, 3692 deletions
diff --git a/gpu/command_buffer/build_gles2_cmd_buffer.py b/gpu/command_buffer/build_gles2_cmd_buffer.py
index a1010ec..5cf8375 100755
--- a/gpu/command_buffer/build_gles2_cmd_buffer.py
+++ b/gpu/command_buffer/build_gles2_cmd_buffer.py
@@ -822,7 +822,7 @@ _ENUM_LISTS = {
#
# cmd_comment: A comment added to the cmd format.
# type: defines which handler will be used to generate code.
-# DecoderFunc: defines which function to call in the decoder to execute the
+# decoder_func: defines which function to call in the decoder to execute the
# corresponding GL command. If not specified the GL command will
# be called directly.
# gl_test_func: GL function that is expected to be called when testing.
@@ -841,16 +841,17 @@ _ENUM_LISTS = {
# unit_test: If False no unit test will be generated.
_FUNCTION_INFO = {
+ 'ActiveTexture': {'decoder_func': 'DoActiveTexture'},
'BindAttribLocation': {'type': 'GLchar'},
- 'BindBuffer': {'DecoderFunc': 'DoBindBuffer'},
- 'BindFramebuffer': {'DecoderFunc': 'glBindFramebufferEXT'},
- 'BindRenderbuffer': {'DecoderFunc': 'glBindRenderbufferEXT'},
- 'BindTexture': {'DecoderFunc': 'DoBindTexture'},
+ 'BindBuffer': {'decoder_func': 'DoBindBuffer'},
+ 'BindFramebuffer': {'decoder_func': 'glBindFramebufferEXT'},
+ 'BindRenderbuffer': {'decoder_func': 'glBindRenderbufferEXT'},
+ 'BindTexture': {'decoder_func': 'DoBindTexture'},
'BufferData': {'type': 'Manual', 'immediate': True},
'BufferSubData': {'type': 'Data'},
- 'CheckFramebufferStatus': {'DecoderFunc': 'glCheckFramebufferStatusEXT'},
- 'ClearDepthf': {'DecoderFunc': 'glClearDepth'},
- 'CompileShader': {'DecoderFunc': 'DoCompileShader', 'unit_test': False},
+ 'CheckFramebufferStatus': {'decoder_func': 'glCheckFramebufferStatusEXT'},
+ 'ClearDepthf': {'decoder_func': 'glClearDepth'},
+ 'CompileShader': {'decoder_func': 'DoCompileShader', 'unit_test': False},
'CompressedTexImage2D': {'type': 'Manual','immediate': True},
'CompressedTexSubImage2D': {'type': 'Data'},
'CreateProgram': {'type': 'Create'},
@@ -860,27 +861,27 @@ _FUNCTION_INFO = {
'type': 'DELn',
'gl_test_func': 'glDeleteFramebuffersEXT',
},
- 'DeleteProgram': {'type': 'Custom', 'DecoderFunc': 'DoDeleteProgram'},
+ 'DeleteProgram': {'type': 'Custom', 'decoder_func': 'DoDeleteProgram'},
'DeleteRenderbuffers': {
'type': 'DELn',
'gl_test_func': 'glDeleteRenderbuffersEXT',
},
- 'DeleteShader': {'type': 'Custom', 'DecoderFunc': 'DoDeleteShader'},
+ 'DeleteShader': {'type': 'Custom', 'decoder_func': 'DoDeleteShader'},
'DeleteTextures': {'type': 'DELn'},
- 'DepthRangef': {'DecoderFunc': 'glDepthRange'},
- 'DisableVertexAttribArray': {'DecoderFunc': 'DoDisableVertexAttribArray'},
- 'DrawArrays': { 'DecoderFunc': 'DoDrawArrays', 'unit_test': False},
+ 'DepthRangef': {'decoder_func': 'glDepthRange'},
+ 'DisableVertexAttribArray': {'decoder_func': 'DoDisableVertexAttribArray'},
+ 'DrawArrays': { 'decoder_func': 'DoDrawArrays', 'unit_test': False},
'DrawElements': {
'type': 'Manual',
'cmd_args': 'GLenum mode, GLsizei count, GLenum type, GLuint index_offset',
},
- 'EnableVertexAttribArray': {'DecoderFunc': 'DoEnableVertexAttribArray'},
+ 'EnableVertexAttribArray': {'decoder_func': 'DoEnableVertexAttribArray'},
'Finish': {'impl_func': False},
'Flush': {'impl_func': False},
- 'FramebufferRenderbuffer': {'DecoderFunc': 'glFramebufferRenderbufferEXT'},
- 'FramebufferTexture2D': {'DecoderFunc': 'glFramebufferTexture2DEXT'},
+ 'FramebufferRenderbuffer': {'decoder_func': 'glFramebufferRenderbufferEXT'},
+ 'FramebufferTexture2D': {'decoder_func': 'glFramebufferTexture2DEXT'},
'GenerateMipmap': {
- 'DecoderFunc': 'DoGenerateMipmap',
+ 'decoder_func': 'DoGenerateMipmap',
'gl_test_func': 'glGenerateMipmapEXT',
},
'GenBuffers': {'type': 'GENn', 'gl_test_func': 'glGenBuffersARB'},
@@ -926,18 +927,18 @@ _FUNCTION_INFO = {
},
'GetBooleanv': {'type': 'GETn'},
'GetBufferParameteriv': {'type': 'GETn'},
- 'GetError': {'type': 'Is', 'DecoderFunc': 'GetGLError'},
+ 'GetError': {'type': 'Is', 'decoder_func': 'GetGLError'},
'GetFloatv': {'type': 'GETn'},
'GetFramebufferAttachmentParameteriv': {
'type': 'GETn',
- 'DecoderFunc': 'glGetFramebufferAttachmentParameterivEXT',
+ 'decoder_func': 'glGetFramebufferAttachmentParameterivEXT',
},
'GetIntegerv': {'type': 'GETn'},
'GetProgramiv': {'type': 'GETn'},
'GetProgramInfoLog': {'type': 'STRn'},
'GetRenderbufferParameteriv': {
'type': 'GETn',
- 'DecoderFunc': 'glGetRenderbufferParameterivEXT',
+ 'decoder_func': 'glGetRenderbufferParameterivEXT',
},
'GetShaderiv': {'type': 'GETn'},
'GetShaderInfoLog': {'type': 'STRn'},
@@ -954,7 +955,7 @@ _FUNCTION_INFO = {
'int32 precision',
],
},
- 'GetShaderSource': {'type': 'STRn', 'DecoderFunc': 'DoGetShaderSource'},
+ 'GetShaderSource': {'type': 'STRn', 'decoder_func': 'DoGetShaderSource'},
'GetTexParameterfv': {'type': 'GETn'},
'GetTexParameteriv': {'type': 'GETn'},
'GetUniformfv': {
@@ -983,14 +984,14 @@ _FUNCTION_INFO = {
},
'IsBuffer': {'type': 'Is'},
'IsEnabled': {'type': 'Is'},
- 'IsFramebuffer': {'type': 'Is', 'DecoderFunc': 'glIsFramebufferEXT'},
+ 'IsFramebuffer': {'type': 'Is', 'decoder_func': 'glIsFramebufferEXT'},
'IsProgram': {'type': 'Is'},
- 'IsRenderbuffer': {'type': 'Is', 'DecoderFunc': 'glIsRenderbufferEXT'},
+ 'IsRenderbuffer': {'type': 'Is', 'decoder_func': 'glIsRenderbufferEXT'},
'IsShader': {'type': 'Is'},
'IsTexture': {'type': 'Is'},
- 'LinkProgram': {'DecoderFunc': 'DoLinkProgram'},
+ 'LinkProgram': {'decoder_func': 'DoLinkProgram'},
'PixelStorei': {'type': 'Manual'},
- 'RenderbufferStorage': {'DecoderFunc': 'glRenderbufferStorageEXT'},
+ 'RenderbufferStorage': {'decoder_func': 'glRenderbufferStorageEXT'},
'ReadPixels': {
'cmd_comment':
'// ReadPixels has the result separated from the pixel buffer so that\n'
@@ -1015,11 +1016,30 @@ _FUNCTION_INFO = {
'GLuint shader, const char* data',
},
'TexImage2D': {'type': 'Manual', 'immediate': True},
- 'TexParameterfv': {'type': 'PUT', 'data_type': 'GLfloat', 'count': 1},
- 'TexParameteriv': {'type': 'PUT', 'data_type': 'GLint', 'count': 1},
+ 'TexParameterf': {'decoder_func': 'DoTexParameterf'},
+ 'TexParameteri': {'decoder_func': 'DoTexParameteri'},
+ 'TexParameterfv': {
+ 'type': 'PUT',
+ 'data_type': 'GLfloat',
+ 'count': 1,
+ 'decoder_func': 'DoTexParameterfv',
+ },
+ 'TexParameteriv': {
+ 'type': 'PUT',
+ 'data_type': 'GLint',
+ 'count': 1,
+ 'decoder_func': 'DoTexParameteriv',
+ },
'TexSubImage2D': {'type': 'Data'},
'Uniform1fv': {'type': 'PUTn', 'data_type': 'GLfloat', 'count': 1},
- 'Uniform1iv': {'type': 'PUTn', 'data_type': 'GLint', 'count': 1},
+ 'Uniform1i': {'decoder_func': 'DoUniform1i', 'unit_test': False},
+ 'Uniform1iv': {
+ 'type': 'PUTn',
+ 'data_type': 'GLint',
+ 'count': 1,
+ 'decoder_func': 'DoUniform1iv',
+ 'unit_test': False,
+ },
'Uniform2fv': {'type': 'PUTn', 'data_type': 'GLfloat', 'count': 2},
'Uniform2iv': {'type': 'PUTn', 'data_type': 'GLint', 'count': 2},
'Uniform3fv': {'type': 'PUTn', 'data_type': 'GLfloat', 'count': 3},
@@ -1029,7 +1049,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', 'unit_test': False},
+ 'UseProgram': {'decoder_func': '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},
@@ -1041,7 +1061,7 @@ _FUNCTION_INFO = {
},
'SwapBuffers': {
'impl_func': False,
- 'DecoderFunc': 'DoSwapBuffers',
+ 'decoder_func': 'DoSwapBuffers',
'unit_test': False,
},
}
@@ -1053,6 +1073,11 @@ class CWriter(object):
def __init__(self, filename):
self.filename = filename
self.file = open(filename, "wb")
+ self.file_num = 0
+
+ def SetFileNum(self, num):
+ """Used to help write number files and tests."""
+ self.file_num = num
def Write(self, string):
"""Writes a string to a file spliting if it's > 80 characters."""
@@ -1351,6 +1376,7 @@ COMPILE_ASSERT(offsetof(%(cmd_name)s::Result, %(field_name)s) == %(offset)d,
count += 1
gl_func_name = func.GetGLTestFunctionName()
vars = {
+ 'test_name': 'GLES2DecoderTest%d' % file.file_num,
'name':name,
'gl_func_name': gl_func_name,
'args': ", ".join(arg_strings),
@@ -1382,14 +1408,15 @@ COMPILE_ASSERT(offsetof(%(cmd_name)s::Result, %(field_name)s) == %(offset)d,
count += 1
gl_func_name = func.GetGLTestFunctionName()
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,
+ 'test_name': 'GLES2DecoderTest%d' % file.file_num ,
+ '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)
@@ -1397,11 +1424,8 @@ COMPILE_ASSERT(offsetof(%(cmd_name)s::Result, %(field_name)s) == %(offset)d,
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) {
+TEST_F(%(test_name)s, %(name)sValidArgs) {
EXPECT_CALL(*gl_, %(gl_func_name)s(%(gl_args)s));
SpecializedSetup<%(name)s, 0>();
%(name)s cmd;
@@ -1412,7 +1436,7 @@ TEST_F(GLES2DecoderTest, %(name)sValidArgs) {
self.WriteValidUnitTest(func, file, valid_test)
invalid_test = """
-TEST_F(GLES2DecoderTest, %(name)sInvalidArgs%(arg_index)d_%(value_index)d) {
+TEST_F(%(test_name)s, %(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;
@@ -1781,7 +1805,7 @@ class GENnHandler(TypeHandler):
def WriteServiceUnitTest(self, func, file):
"""Overrriden from TypeHandler."""
valid_test = """
-TEST_F(GLES2DecoderTest, %(name)sValidArgs) {
+TEST_F(%(test_name)s, %(name)sValidArgs) {
EXPECT_CALL(*gl_, %(gl_func_name)s(1, _))
.WillOnce(SetArgumentPointee<1>(kNewServiceId));
GetSharedMemoryAs<GLuint*>()[0] = kNewClientId;
@@ -1794,7 +1818,7 @@ TEST_F(GLES2DecoderTest, %(name)sValidArgs) {
"""
self.WriteValidUnitTest(func, file, valid_test)
invalid_test = """
-TEST_F(GLES2DecoderTest, %(name)sInvalidArgs) {
+TEST_F(%(test_name)s, %(name)sInvalidArgs) {
EXPECT_CALL(*gl_, %(gl_func_name)s(_, _)).Times(0);
GetSharedMemoryAs<GLuint*>()[0] = client_%(resource_name)s_id_;
SpecializedSetup<%(name)s, 0>();
@@ -1810,7 +1834,7 @@ TEST_F(GLES2DecoderTest, %(name)sInvalidArgs) {
def WriteImmediateServiceUnitTest(self, func, file):
"""Overrriden from TypeHandler."""
valid_test = """
-TEST_F(GLES2DecoderTest, %(name)sValidArgs) {
+TEST_F(%(test_name)s, %(name)sValidArgs) {
EXPECT_CALL(*gl_, %(gl_func_name)s(1, _))
.WillOnce(SetArgumentPointee<1>(kNewServiceId));
%(name)s& cmd = *GetImmediateAs<%(name)s>();
@@ -1824,7 +1848,7 @@ TEST_F(GLES2DecoderTest, %(name)sValidArgs) {
"""
self.WriteValidUnitTest(func, file, valid_test)
invalid_test = """
-TEST_F(GLES2DecoderTest, %(name)sInvalidArgs) {
+TEST_F(%(test_name)s, %(name)sInvalidArgs) {
EXPECT_CALL(*gl_, %(gl_func_name)s(_, _)).Times(0);
%(name)s& cmd = *GetImmediateAs<%(name)s>();
SpecializedSetup<%(name)s, 0>();
@@ -1947,7 +1971,7 @@ class CreateHandler(TypeHandler):
def WriteServiceUnitTest(self, func, file):
"""Overrriden from TypeHandler."""
valid_test = """
-TEST_F(GLES2DecoderTest, %(name)sValidArgs) {
+TEST_F(%(test_name)s, %(name)sValidArgs) {
EXPECT_CALL(*gl_, %(gl_func_name)s(%(gl_args)s))
.WillOnce(Return(kNewServiceId));
SpecializedSetup<%(name)s, 0>();
@@ -1964,7 +1988,7 @@ TEST_F(GLES2DecoderTest, %(name)sValidArgs) {
'comma': comma,
})
invalid_test = """
-TEST_F(GLES2DecoderTest, %(name)sInvalidArgs%(arg_index)d_%(value_index)d) {
+TEST_F(%(test_name)s, %(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;
@@ -2009,7 +2033,7 @@ class DELnHandler(TypeHandler):
def WriteServiceUnitTest(self, func, file):
"""Overrriden from TypeHandler."""
valid_test = """
-TEST_F(GLES2DecoderTest, %(name)sValidArgs) {
+TEST_F(%(test_name)s, %(name)sValidArgs) {
EXPECT_CALL(
*gl_,
%(gl_func_name)s(1, Pointee(kService%(upper_resource_name)sId)))
@@ -2028,7 +2052,7 @@ TEST_F(GLES2DecoderTest, %(name)sValidArgs) {
func.GetOriginalArgs()[1].name[0:-1].capitalize(),
})
invalid_test = """
-TEST_F(GLES2DecoderTest, %(name)sInvalidArgs) {
+TEST_F(%(test_name)s, %(name)sInvalidArgs) {
EXPECT_CALL(*gl_, %(gl_func_name)s(1, Pointee(0)))
.Times(1);
GetSharedMemoryAs<GLuint*>()[0] = kInvalidClientId;
@@ -2043,7 +2067,7 @@ TEST_F(GLES2DecoderTest, %(name)sInvalidArgs) {
def WriteImmediateServiceUnitTest(self, func, file):
"""Overrriden from TypeHandler."""
valid_test = """
-TEST_F(GLES2DecoderTest, %(name)sValidArgs) {
+TEST_F(%(test_name)s, %(name)sValidArgs) {
EXPECT_CALL(
*gl_,
%(gl_func_name)s(1, Pointee(kService%(upper_resource_name)sId)))
@@ -2062,7 +2086,7 @@ TEST_F(GLES2DecoderTest, %(name)sValidArgs) {
func.GetOriginalArgs()[1].name[0:-1].capitalize(),
})
invalid_test = """
-TEST_F(GLES2DecoderTest, %(name)sInvalidArgs) {
+TEST_F(%(test_name)s, %(name)sInvalidArgs) {
EXPECT_CALL(*gl_, %(gl_func_name)s(1, Pointee(0)))
.Times(1);
%(name)s& cmd = *GetImmediateAs<%(name)s>();
@@ -2255,7 +2279,7 @@ class PUTHandler(TypeHandler):
def WriteImmediateServiceUnitTest(self, func, file):
"""Writes the service unit test for a command."""
valid_test = """
-TEST_F(GLES2DecoderTest, %(name)sValidArgs) {
+TEST_F(%(test_name)s, %(name)sValidArgs) {
%(name)s& cmd = *GetImmediateAs<%(name)s>();
EXPECT_CALL(
*gl_,
@@ -2284,7 +2308,7 @@ TEST_F(GLES2DecoderTest, %(name)sValidArgs) {
self.WriteValidUnitTest(func, file, valid_test, extra)
invalid_test = """
-TEST_F(GLES2DecoderTest, %(name)sInvalidArgs%(arg_index)d_%(value_index)d) {
+TEST_F(%(test_name)s, %(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>();
@@ -2426,7 +2450,7 @@ class PUTnHandler(TypeHandler):
def WriteImmediateServiceUnitTest(self, func, file):
"""Writes the service unit test for a command."""
valid_test = """
-TEST_F(GLES2DecoderTest, %(name)sValidArgs) {
+TEST_F(%(test_name)s, %(name)sValidArgs) {
%(name)s& cmd = *GetImmediateAs<%(name)s>();
EXPECT_CALL(
*gl_,
@@ -2455,7 +2479,7 @@ TEST_F(GLES2DecoderTest, %(name)sValidArgs) {
self.WriteValidUnitTest(func, file, valid_test, extra)
invalid_test = """
-TEST_F(GLES2DecoderTest, %(name)sInvalidArgs%(arg_index)d_%(value_index)d) {
+TEST_F(%(test_name)s, %(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>();
@@ -2962,7 +2986,7 @@ class IsHandler(TypeHandler):
def WriteServiceUnitTest(self, func, file):
"""Overrriden from TypeHandler."""
valid_test = """
-TEST_F(GLES2DecoderTest, %(name)sValidArgs) {
+TEST_F(%(test_name)s, %(name)sValidArgs) {
EXPECT_CALL(*gl_, %(gl_func_name)s(%(gl_args)s));
SpecializedSetup<%(name)s, 0>();
%(name)s cmd;
@@ -2978,7 +3002,7 @@ TEST_F(GLES2DecoderTest, %(name)sValidArgs) {
})
invalid_test = """
-TEST_F(GLES2DecoderTest, %(name)sInvalidArgs%(arg_index)d_%(value_index)d) {
+TEST_F(%(test_name)s, %(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;
@@ -3361,7 +3385,7 @@ class ResourceIdArgument(Argument):
def WriteGetCode(self, file):
"""Overridden from Argument."""
file.Write(" %s %s;\n" % (self.type, self.name))
- file.Write(" if (!id_manager_->GetServiceId(c.%s, &%s)) {\n" %
+ file.Write(" if (!id_manager()->GetServiceId(c.%s, &%s)) {\n" %
(self.name, self.name))
file.Write(" SetGLError(GL_INVALID_VALUE);\n")
file.Write(" return error::kNoError;\n")
@@ -3376,10 +3400,10 @@ class ResourceIdArgument(Argument):
class Function(object):
"""A class that represents a function."""
- def __init__(self, name, info, return_type, original_args, args_for_cmds,
- cmd_args, init_args, num_pointer_args):
+ def __init__(self, original_name, name, info, return_type, original_args,
+ args_for_cmds, cmd_args, init_args, num_pointer_args):
self.name = name
- self.original_name = name
+ self.original_name = original_name
self.info = info
self.type_handler = info.type_handler
self.return_type = return_type
@@ -3403,8 +3427,8 @@ class Function(object):
def GetGLFunctionName(self):
"""Gets the function to call to execute GL for this command."""
- if self.GetInfo('DecoderFunc'):
- return self.GetInfo('DecoderFunc')
+ if self.GetInfo('decoder_func'):
+ return self.GetInfo('decoder_func')
return "gl%s" % self.original_name
def GetGLTestFunctionName(self):
@@ -3414,7 +3438,7 @@ class Function(object):
if gl_func_name.startswith("gl"):
gl_func_name = gl_func_name[2:]
else:
- gl_func_name = self.name
+ gl_func_name = self.original_name
return gl_func_name
def AddCmdArg(self, arg):
@@ -3587,6 +3611,7 @@ class ImmediateFunction(Function):
Function.__init__(
self,
+ func.original_name,
"%sImmediate" % func.name,
func.info,
func.return_type,
@@ -3595,7 +3620,6 @@ class ImmediateFunction(Function):
cmd_args,
new_init_args,
0)
- self.original_name = func.name
def WriteServiceImplementation(self, file):
"""Overridden from Function"""
@@ -3795,8 +3819,8 @@ class GLGenerator(object):
return_arg = CreateArg(return_type + " result")
if return_arg:
init_args.append(return_arg)
- f = Function(func_name, func_info, return_type, args, args_for_cmds,
- cmd_args, init_args, num_pointer_args)
+ f = Function(func_name, func_name, func_info, return_type, args,
+ args_for_cmds, cmd_args, init_args, num_pointer_args)
self.original_functions.append(f)
self.AddFunction(f)
f.type_handler.AddImmediateFunction(self, f)
@@ -3898,14 +3922,27 @@ class GLGenerator(object):
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()
+ num_tests = len(self.functions)
+ step = (num_tests + 1) / 2
+ count = 0
+ for test_num in range(0, num_tests, step):
+ count += 1
+ name = filename % count
+ file = CHeaderWriter(
+ name,
+ "// It is included by gles2_cmd_decoder_unittest_%d.cc\n" % count)
+ file.SetFileNum(count)
+ end = test_num + step
+ if end > num_tests:
+ end = num_tests
+ for idx in range(test_num, end):
+ func = self.functions[idx]
+ if func.GetInfo('unit_test') == False:
+ file.Write("// TODO(gman): %s\n" % func.name)
+ else:
+ func.WriteServiceUnitTest(file)
+
+ file.Close()
def WriteGLES2CLibImplementation(self, filename):
@@ -3989,7 +4026,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.WriteServiceUnitTests("service/gles2_cmd_decoder_unittest_%d_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/common/gles2_cmd_utils.cc b/gpu/command_buffer/common/gles2_cmd_utils.cc
index aac4b84..9e376270 100644
--- a/gpu/command_buffer/common/gles2_cmd_utils.cc
+++ b/gpu/command_buffer/common/gles2_cmd_utils.cc
@@ -343,7 +343,7 @@ uint32 GLES2Util::ComputeImageDataSize(
return height * row_size;
}
-uint32 GLES2Util::GetGLDataTypeSize(int type) {
+uint32 GLES2Util::GetGLDataTypeSizeForUniforms(int type) {
switch (type) {
case GL_FLOAT:
return sizeof(GLfloat); // NOLINT
@@ -384,6 +384,24 @@ uint32 GLES2Util::GetGLDataTypeSize(int type) {
}
}
+size_t GLES2Util::GetGLTypeSizeForTexturesAndBuffers(uint32 type) {
+ switch (type) {
+ case GL_BYTE:
+ return sizeof(GLbyte); // NOLINT
+ case GL_UNSIGNED_BYTE:
+ return sizeof(GLubyte); // NOLINT
+ case GL_SHORT:
+ return sizeof(GLshort); // NOLINT
+ case GL_UNSIGNED_SHORT:
+ return sizeof(GLushort); // NOLINT
+ case GL_FLOAT:
+ return sizeof(GLfloat); // NOLINT
+ default:
+ return 0;
+ }
+}
+
+
} // namespace gles2
} // namespace gpu
diff --git a/gpu/command_buffer/common/gles2_cmd_utils.h b/gpu/command_buffer/common/gles2_cmd_utils.h
index 1d2139d..b2da669 100644
--- a/gpu/command_buffer/common/gles2_cmd_utils.h
+++ b/gpu/command_buffer/common/gles2_cmd_utils.h
@@ -30,7 +30,9 @@ class GLES2Util {
static uint32 ComputeImageDataSize(
int width, int height, int format, int type, int unpack_alignment);
- static uint32 GetGLDataTypeSize(int type);
+ static uint32 GetGLDataTypeSizeForUniforms(int type);
+
+ static size_t GetGLTypeSizeForTexturesAndBuffers(uint32 type);
private:
int num_compressed_texture_formats_;
diff --git a/gpu/command_buffer/service/buffer_manager.cc b/gpu/command_buffer/service/buffer_manager.cc
index 3509b86..2dfbc15 100644
--- a/gpu/command_buffer/service/buffer_manager.cc
+++ b/gpu/command_buffer/service/buffer_manager.cc
@@ -4,24 +4,31 @@
#include "gpu/command_buffer/service/buffer_manager.h"
#include "base/logging.h"
+#include "gpu/command_buffer/service/gles2_cmd_decoder.h"
namespace gpu {
namespace gles2 {
-void BufferManager::CreateBufferInfo(GLuint buffer) {
+void BufferManager::CreateBufferInfo(GLuint buffer_id) {
std::pair<BufferInfoMap::iterator, bool> result =
- buffer_infos_.insert(std::make_pair(buffer, BufferInfo()));
+ buffer_infos_.insert(
+ std::make_pair(buffer_id,
+ BufferInfo::Ref(new BufferInfo(buffer_id))));
DCHECK(result.second);
}
BufferManager::BufferInfo* BufferManager::GetBufferInfo(
- GLuint buffer) {
- BufferInfoMap::iterator it = buffer_infos_.find(buffer);
- return it != buffer_infos_.end() ? &it->second : NULL;
+ GLuint buffer_id) {
+ BufferInfoMap::iterator it = buffer_infos_.find(buffer_id);
+ return it != buffer_infos_.end() ? it->second : NULL;
}
void BufferManager::RemoveBufferInfo(GLuint buffer_id) {
- buffer_infos_.erase(buffer_id);
+ BufferInfoMap::iterator it = buffer_infos_.find(buffer_id);
+ if (it != buffer_infos_.end()) {
+ it->second->MarkAsDeleted();
+ buffer_infos_.erase(buffer_id);
+ }
}
GLuint BufferManager::BufferInfo::GetMaxValueForRange(
diff --git a/gpu/command_buffer/service/buffer_manager.h b/gpu/command_buffer/service/buffer_manager.h
index b4dcda1..e278a85 100644
--- a/gpu/command_buffer/service/buffer_manager.h
+++ b/gpu/command_buffer/service/buffer_manager.h
@@ -7,6 +7,7 @@
#include <map>
#include "base/basictypes.h"
+#include "base/ref_counted.h"
#include "gpu/command_buffer/service/gl_utils.h"
namespace gpu {
@@ -20,10 +21,17 @@ namespace gles2 {
class BufferManager {
public:
// Info about Buffers currently in the system.
- class BufferInfo {
+ class BufferInfo : public base::RefCounted<BufferInfo> {
public:
- BufferInfo()
- : size_(0) {
+ typedef scoped_refptr<BufferInfo> Ref;
+
+ explicit BufferInfo(GLuint buffer_id)
+ : buffer_id_(buffer_id),
+ size_(0) {
+ }
+
+ GLuint buffer_id() const {
+ return buffer_id_;
}
GLsizeiptr size() const {
@@ -38,17 +46,31 @@ class BufferManager {
// interpreted as the given type.
GLuint GetMaxValueForRange(GLuint offset, GLsizei count, GLenum type);
+ bool IsDeleted() {
+ return buffer_id_ == 0;
+ }
+
private:
+ friend class BufferManager;
+ friend class base::RefCounted<BufferInfo>;
+
+ ~BufferInfo() { }
+
+ void MarkAsDeleted() {
+ buffer_id_ = 0;
+ }
+
+ GLuint buffer_id_;
GLsizeiptr size_;
};
- BufferManager() { };
+ BufferManager() { }
// Creates a BufferInfo for the given buffer.
- void CreateBufferInfo(GLuint buffer);
+ void CreateBufferInfo(GLuint buffer_id);
// Gets the buffer info for the given buffer.
- BufferInfo* GetBufferInfo(GLuint buffer);
+ BufferInfo* GetBufferInfo(GLuint buffer_id);
// Removes a buffer info for the given buffer.
void RemoveBufferInfo(GLuint buffer_id);
@@ -56,7 +78,7 @@ class BufferManager {
private:
// Info for each buffer in the system.
// TODO(gman): Choose a faster container.
- typedef std::map<GLuint, BufferInfo> BufferInfoMap;
+ typedef std::map<GLuint, BufferInfo::Ref> BufferInfoMap;
BufferInfoMap buffer_infos_;
DISALLOW_COPY_AND_ASSIGN(BufferManager);
diff --git a/gpu/command_buffer/service/context_group.cc b/gpu/command_buffer/service/context_group.cc
new file mode 100644
index 0000000..5bc0ae41
--- /dev/null
+++ b/gpu/command_buffer/service/context_group.cc
@@ -0,0 +1,59 @@
+// Copyright (c) 2010 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.
+
+#include "gpu/command_buffer/service/context_group.h"
+#include "gpu/command_buffer/service/buffer_manager.h"
+#include "gpu/command_buffer/service/id_manager.h"
+#include "gpu/command_buffer/service/program_manager.h"
+#include "gpu/command_buffer/service/shader_manager.h"
+#include "gpu/command_buffer/service/texture_manager.h"
+
+namespace gpu {
+namespace gles2 {
+
+ContextGroup::ContextGroup()
+ : initialized_(false),
+ max_vertex_attribs_(0u),
+ max_texture_units_(0u) {
+}
+
+ContextGroup::~ContextGroup() {
+}
+
+bool ContextGroup::Initialize() {
+ if (initialized_) {
+ return true;
+ }
+
+ id_manager_.reset(new IdManager());
+ buffer_manager_.reset(new BufferManager());
+ shader_manager_.reset(new ShaderManager());
+ program_manager_.reset(new ProgramManager());
+
+ // Lookup GL things we need to know.
+ GLint value;
+ glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &value);
+ max_vertex_attribs_ = value;
+ const GLuint kGLES2RequiredMiniumumVertexAttribs = 8u;
+ DCHECK_GE(max_vertex_attribs_, kGLES2RequiredMiniumumVertexAttribs);
+
+ glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &value);
+ max_texture_units_ = value;
+ const GLuint kGLES2RequiredMiniumumTextureUnits = 8u;
+ DCHECK_GE(max_texture_units_, kGLES2RequiredMiniumumTextureUnits);
+
+ GLint max_texture_size;
+ GLint max_cube_map_texture_size;
+ glGetIntegerv(GL_MAX_TEXTURE_SIZE, &max_texture_size);
+ glGetIntegerv(GL_MAX_CUBE_MAP_TEXTURE_SIZE, &max_cube_map_texture_size);
+ texture_manager_.reset(new TextureManager(max_texture_size,
+ max_cube_map_texture_size));
+ initialized_ = true;
+ return true;
+}
+
+} // namespace gles2
+} // namespace gpu
+
+
diff --git a/gpu/command_buffer/service/context_group.h b/gpu/command_buffer/service/context_group.h
new file mode 100644
index 0000000..362be16
--- /dev/null
+++ b/gpu/command_buffer/service/context_group.h
@@ -0,0 +1,88 @@
+// Copyright (c) 2010 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.
+
+#ifndef GPU_COMMAND_BUFFER_SERVICE_CONTEXT_GROUP_H_
+#define GPU_COMMAND_BUFFER_SERVICE_CONTEXT_GROUP_H_
+
+#include <vector>
+#include "base/basictypes.h"
+#include "base/scoped_ptr.h"
+
+namespace gpu {
+namespace gles2 {
+
+class GLES2Decoder;
+class BufferManager;
+class IdManager;
+class ProgramManager;
+class ShaderManager;
+class TextureManager;
+
+// A Context Group helps manage multiple GLES2Decoders that share
+// resources.
+class ContextGroup {
+ public:
+ ContextGroup();
+ ~ContextGroup();
+
+ // This should only be called by GLES2Decoder.
+ bool Initialize();
+
+ uint32 max_vertex_attribs() const {
+ return max_vertex_attribs_;
+ }
+
+ uint32 max_texture_units() const {
+ return max_texture_units_;
+ }
+
+ // Map of client ids to GL ids.
+ IdManager* id_manager() const {
+ return id_manager_.get();
+ }
+
+ BufferManager* buffer_manager() const {
+ return buffer_manager_.get();
+ }
+
+ TextureManager* texture_manager() const {
+ return texture_manager_.get();
+ }
+
+ ProgramManager* program_manager() const {
+ return program_manager_.get();
+ }
+
+ ShaderManager* shader_manager() const {
+ return shader_manager_.get();
+ }
+
+ private:
+ // Whether or not this context is initialized.
+ bool initialized_;
+
+ uint32 max_vertex_attribs_;
+
+ uint32 max_texture_units_;
+
+ // Map of client ids to GL ids.
+ scoped_ptr<IdManager> id_manager_;
+
+ scoped_ptr<BufferManager> buffer_manager_;
+
+ scoped_ptr<TextureManager> texture_manager_;
+
+ scoped_ptr<ProgramManager> program_manager_;
+
+ scoped_ptr<ShaderManager> shader_manager_;
+
+ DISALLOW_COPY_AND_ASSIGN(ContextGroup);
+};
+
+} // namespace gles2
+} // namespace gpu
+
+#endif // GPU_COMMAND_BUFFER_SERVICE_CONTEXT_GROUP_H_
+
+
diff --git a/gpu/command_buffer/service/context_group_unittest.cc b/gpu/command_buffer/service/context_group_unittest.cc
new file mode 100644
index 0000000..a61077b
--- /dev/null
+++ b/gpu/command_buffer/service/context_group_unittest.cc
@@ -0,0 +1,40 @@
+// Copyright (c) 2010 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.
+
+#include "gpu/command_buffer/service/context_group.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace gpu {
+namespace gles2 {
+
+class ContextGroupTest : public testing::Test {
+ public:
+ ContextGroupTest() {
+ }
+
+ protected:
+ virtual void SetUp() {
+ }
+
+ virtual void TearDown() {
+ }
+
+ ContextGroup group_;
+};
+
+TEST_F(ContextGroupTest, Basic) {
+ // Test it starts off uninitialized.
+ EXPECT_EQ(0u, group_.max_vertex_attribs());
+ EXPECT_EQ(0u, group_.max_texture_units());
+ EXPECT_TRUE(group_.id_manager() == NULL);
+ EXPECT_TRUE(group_.buffer_manager() == NULL);
+ EXPECT_TRUE(group_.texture_manager() == NULL);
+ EXPECT_TRUE(group_.program_manager() == NULL);
+ EXPECT_TRUE(group_.shader_manager() == NULL);
+}
+
+} // namespace gles2
+} // namespace gpu
+
+
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.cc b/gpu/command_buffer/service/gles2_cmd_decoder.cc
index c018356..77bfc3c 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder.cc
+++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc
@@ -15,10 +15,11 @@
#include "base/linked_ptr.h"
#include "base/scoped_ptr.h"
#define GLES2_GPU_SERVICE 1
-#include "gpu/command_buffer/service/buffer_manager.h"
#include "gpu/command_buffer/common/gles2_cmd_format.h"
#include "gpu/command_buffer/common/gles2_cmd_utils.h"
+#include "gpu/command_buffer/service/buffer_manager.h"
#include "gpu/command_buffer/service/cmd_buffer_engine.h"
+#include "gpu/command_buffer/service/context_group.h"
#include "gpu/command_buffer/service/gl_utils.h"
#include "gpu/command_buffer/service/gles2_cmd_validation.h"
#include "gpu/command_buffer/service/id_manager.h"
@@ -59,23 +60,6 @@ COMPILE_ASSERT(sizeof(GLfloat) == sizeof(float), // NOLINT
// linker on Mac OS X 10.6 when the symbol ordering file is used
// namespace {
-static size_t GetGLTypeSize(GLenum type) {
- switch (type) {
- case GL_BYTE:
- return sizeof(GLbyte); // NOLINT
- case GL_UNSIGNED_BYTE:
- return sizeof(GLubyte); // NOLINT
- case GL_SHORT:
- return sizeof(GLshort); // NOLINT
- case GL_UNSIGNED_SHORT:
- return sizeof(GLushort); // NOLINT
- case GL_FLOAT:
- return sizeof(GLfloat); // NOLINT
- default:
- return 0;
- }
-}
-
// Returns the address of the first byte after a struct.
template <typename T>
const void* AddressAfterStruct(const T& pod) {
@@ -168,27 +152,30 @@ GLenum GLErrorBitToGLError(uint32 error_bit) {
// } // anonymous namespace.
+GLES2Decoder::GLES2Decoder(ContextGroup* group)
+ : group_(group),
#if defined(UNIT_TEST)
-GLES2Decoder::GLES2Decoder()
- : debug_(false) {
+ debug_(false) {
#elif defined(OS_LINUX)
-GLES2Decoder::GLES2Decoder()
- : debug_(false),
+ debug_(false),
window_(NULL) {
#elif defined(OS_WIN)
-GLES2Decoder::GLES2Decoder()
- : debug_(false),
+ debug_(false),
hwnd_(NULL) {
#else
-GLES2Decoder::GLES2Decoder()
- : debug_(false) {
+ debug_(false) {
#endif
}
+GLES2Decoder::~GLES2Decoder() {
+}
+
// This class implements GLES2Decoder so we don't have to expose all the GLES2
// cmd stuff to outside this class.
class GLES2DecoderImpl : public GLES2Decoder {
public:
+ explicit GLES2DecoderImpl(ContextGroup* group);
+
// Info about Vertex Attributes. This is used to track what the user currently
// has bound on each Vertex Attribute so that checking can be done at
// glDrawXXX time.
@@ -199,11 +186,9 @@ class GLES2DecoderImpl : public GLES2Decoder {
size_(0),
type_(0),
offset_(0),
- real_stride_(0),
- buffer_(0),
- buffer_size_(0),
- num_elements_(0) {
+ real_stride_(0) {
}
+
// Returns true if this VertexAttrib can access index.
bool CanAccess(GLuint index);
@@ -211,7 +196,7 @@ class GLES2DecoderImpl : public GLES2Decoder {
enabled_ = enabled;
}
- GLuint buffer() const {
+ BufferManager::BufferInfo* buffer() const {
return buffer_;
}
@@ -219,26 +204,8 @@ class GLES2DecoderImpl : public GLES2Decoder {
return offset_;
}
- void Clear() {
- buffer_ = 0;
- SetBufferSize(0);
- }
-
- void SetBufferSize(GLsizeiptr buffer_size) {
- buffer_size_ = buffer_size;
- if (offset_ > buffer_size || real_stride_ == 0) {
- num_elements_ = 0;
- } else {
- uint32 usable_size = buffer_size - offset_;
- num_elements_ = usable_size / real_stride_ +
- ((usable_size % real_stride_) >=
- (GetGLTypeSize(type_) * size_) ? 1 : 0);
- }
- }
-
void SetInfo(
- GLuint buffer,
- GLsizeiptr buffer_size,
+ BufferManager::BufferInfo* buffer,
GLint size,
GLenum type,
GLsizei real_stride,
@@ -249,7 +216,10 @@ class GLES2DecoderImpl : public GLES2Decoder {
type_ = type;
real_stride_ = real_stride;
offset_ = offset;
- SetBufferSize(buffer_size);
+ }
+
+ void ClearBuffer() {
+ buffer_ = NULL;
}
private:
@@ -270,22 +240,14 @@ class GLES2DecoderImpl : public GLES2Decoder {
// of 0.
GLsizei real_stride_;
- // The service side name of the buffer bound to this attribute. 0 = invalid
- GLuint buffer_;
-
- // The size of the buffer.
- GLsizeiptr buffer_size_;
-
- // The number of elements that can be accessed.
- GLuint num_elements_;
+ // The buffer bound to this attribute.
+ BufferManager::BufferInfo::Ref buffer_;
};
- GLES2DecoderImpl();
-
// Overridden from AsyncAPIInterface.
virtual Error DoCommand(unsigned int command,
- unsigned int arg_count,
- const void* args);
+ unsigned int arg_count,
+ const void* args);
// Overridden from AsyncAPIInterface.
virtual const char* GetCommandName(unsigned int command_id) const;
@@ -319,6 +281,21 @@ class GLES2DecoderImpl : public GLES2Decoder {
virtual void SetSwapBuffersCallback(Callback0::Type* callback);
private:
+ // State associated with each texture unit.
+ struct TextureUnit {
+ TextureUnit() : bind_target(GL_TEXTURE_2D) { }
+
+ // The last target that was bound to this texture unit.
+ GLenum bind_target;
+
+ // texture currently bound to this unit's GL_TEXTURE_2D with glBindTexture
+ TextureManager::TextureInfo::Ref bound_texture_2d;
+
+ // texture currently bound to this unit's GL_TEXTURE_CUBE_MAP with
+ // glBindTexture
+ TextureManager::TextureInfo::Ref bound_texture_cube_map;
+ };
+
friend void GLGenTexturesHelper(
GLES2DecoderImpl* decoder, GLsizei n, GLuint* ids);
friend void GLDeleteTexturesHelper(
@@ -328,6 +305,27 @@ class GLES2DecoderImpl : public GLES2Decoder {
friend void GLDeleteBuffersHelper(
GLES2DecoderImpl* decoder, GLsizei n, GLuint* ids);
+ // TODO(gman): Cache these pointers?
+ IdManager* id_manager() {
+ return group_->id_manager();
+ }
+
+ BufferManager* buffer_manager() {
+ return group_->buffer_manager();
+ }
+
+ ProgramManager* program_manager() {
+ return group_->program_manager();
+ }
+
+ ShaderManager* shader_manager() {
+ return group_->shader_manager();
+ }
+
+ TextureManager* texture_manager() {
+ return group_->texture_manager();
+ }
+
bool InitPlatformSpecific();
bool InitGlew();
@@ -368,16 +366,20 @@ class GLES2DecoderImpl : public GLES2Decoder {
// Creates a TextureInfo for the given texture.
void CreateTextureInfo(GLuint texture) {
- texture_manager_->CreateTextureInfo(texture);
+ texture_manager()->CreateTextureInfo(texture);
}
// Gets the texture info for the given texture. Returns NULL if none exists.
TextureManager::TextureInfo* GetTextureInfo(GLuint texture) {
- return texture_manager_->GetTextureInfo(texture);
+ TextureManager::TextureInfo* info =
+ texture_manager()->GetTextureInfo(texture);
+ return (info && !info->IsDeleted()) ? info : NULL;
}
// Deletes the texture info for the given texture.
- void RemoveTextureInfo(GLuint texture);
+ void RemoveTextureInfo(GLuint texture) {
+ texture_manager()->RemoveTextureInfo(texture);
+ }
// Wrapper for CompressedTexImage2D commands.
error::Error DoCompressedTexImage2D(
@@ -405,48 +407,48 @@ class GLES2DecoderImpl : public GLES2Decoder {
// Creates a ProgramInfo for the given program.
void CreateProgramInfo(GLuint program) {
- program_manager_->CreateProgramInfo(program);
+ program_manager()->CreateProgramInfo(program);
}
// Gets the program info for the given program. Returns NULL if none exists.
// Programs that have no had glLinkProgram succesfully called on them will
// not exist.
ProgramManager::ProgramInfo* GetProgramInfo(GLuint program) {
- return program_manager_->GetProgramInfo(program);
+ ProgramManager::ProgramInfo* info =
+ program_manager()->GetProgramInfo(program);
+ return (info && !info->IsDeleted()) ? info : NULL;
}
// Deletes the program info for the given program.
void RemoveProgramInfo(GLuint program) {
- program_manager_->RemoveProgramInfo(program);
+ program_manager()->RemoveProgramInfo(program);
}
// Creates a ShaderInfo for the given shader.
void CreateShaderInfo(GLuint shader) {
- shader_manager_->CreateShaderInfo(shader);
+ shader_manager()->CreateShaderInfo(shader);
}
// Gets the shader info for the given shader. Returns NULL if none exists.
ShaderManager::ShaderInfo* GetShaderInfo(GLuint shader) {
- return shader_manager_->GetShaderInfo(shader);
+ ShaderManager::ShaderInfo* info = shader_manager()->GetShaderInfo(shader);
+ return (info && !info->IsDeleted()) ? info : NULL;
}
// Deletes the shader info for the given shader.
void RemoveShaderInfo(GLuint shader) {
- shader_manager_->RemoveShaderInfo(shader);
+ shader_manager()->RemoveShaderInfo(shader);
}
// Creates a buffer info for the given buffer.
void CreateBufferInfo(GLuint buffer) {
- return buffer_manager_->CreateBufferInfo(buffer);
+ return buffer_manager()->CreateBufferInfo(buffer);
}
- // Helper for glShaderSource.
- error::Error ShaderSourceHelper(
- GLuint shader, const char* data, uint32 data_size);
-
// Gets the buffer info for the given buffer.
BufferManager::BufferInfo* GetBufferInfo(GLuint buffer) {
- return buffer_manager_->GetBufferInfo(buffer);
+ BufferManager::BufferInfo* info = buffer_manager()->GetBufferInfo(buffer);
+ return (info && !info->IsDeleted()) ? info : NULL;
}
// Removes any buffers in the VertexAtrribInfos and BufferInfos. This is used
@@ -454,8 +456,9 @@ class GLES2DecoderImpl : public GLES2Decoder {
// with deleted buffers.
void RemoveBufferInfo(GLuint buffer_id);
- // Update VertexAttribInfo.
- void UpdateVertexAttribInfo(GLuint buffer, GLsizeiptr size);
+ // Helper for glShaderSource.
+ error::Error ShaderSourceHelper(
+ GLuint shader, const char* data, uint32 data_size);
// Wrapper for glCreateProgram
void CreateProgramHelper(GLuint client_id);
@@ -463,6 +466,9 @@ class GLES2DecoderImpl : public GLES2Decoder {
// Wrapper for glCreateShader
void CreateShaderHelper(GLenum type, GLuint client_id);
+ // Wrapper for glActiveTexture
+ void DoActiveTexture(GLenum texture_unit);
+
// Wrapper for glBindBuffer since we need to track the current targets.
void DoBindBuffer(GLenum target, GLuint buffer);
@@ -494,6 +500,17 @@ class GLES2DecoderImpl : public GLES2Decoder {
// Swaps the buffers (copies/renders to the current window).
void DoSwapBuffers();
+ // Wrappers for glTexParameter functions.
+ void DoTexParameterf(GLenum target, GLenum pname, GLfloat param);
+ void DoTexParameteri(GLenum target, GLenum pname, GLint param);
+ void DoTexParameterfv(GLenum target, GLenum pname, const GLfloat* params);
+ void DoTexParameteriv(GLenum target, GLenum pname, const GLint* params);
+
+ // Wrappers for glUniform1i and glUniform1iv as according to the GLES2
+ // spec only these 2 functions can be used to set sampler uniforms.
+ void DoUniform1i(GLint location, GLint v0);
+ void DoUniform1iv(GLint location, GLsizei count, const GLint *value);
+
// Wrapper for glUseProgram
void DoUseProgram(GLuint program);
@@ -512,18 +529,26 @@ class GLES2DecoderImpl : public GLES2Decoder {
// Checks if the current program and vertex attributes are valid for drawing.
bool IsDrawValid(GLuint max_vertex_accessed);
+ void SetBlackTextureForNonRenderableTextures(
+ bool* has_non_renderable_textures);
+ void RestoreStateForNonRenderableTextures();
+
// Gets the buffer id for a given target.
- GLuint GetBufferForTarget(GLenum target) {
+ BufferManager::BufferInfo* GetBufferInfoForTarget(GLenum target) {
DCHECK(target == GL_ARRAY_BUFFER || target == GL_ELEMENT_ARRAY_BUFFER);
- return target == GL_ARRAY_BUFFER ? bound_array_buffer_ :
- bound_element_array_buffer_;
+ BufferManager::BufferInfo* info = target == GL_ARRAY_BUFFER ?
+ bound_array_buffer_ : bound_element_array_buffer_;
+ return (info && !info->IsDeleted()) ? info : NULL;
}
// Gets the texture id for a given target.
- GLuint GetTextureForTarget(GLenum target) {
+ TextureManager::TextureInfo* GetTextureInfoForTarget(GLenum target) {
+ TextureUnit& unit = texture_units_[active_texture_unit_];
+ TextureManager::TextureInfo* info = NULL;
switch (target) {
case GL_TEXTURE_2D:
- return bound_texture_2d_;
+ info = unit.bound_texture_2d;
+ break;
case GL_TEXTURE_CUBE_MAP:
case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
@@ -531,15 +556,17 @@ class GLES2DecoderImpl : public GLES2Decoder {
case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
- return bound_texture_cube_map_;
+ info = unit.bound_texture_cube_map;
+ break;
// Note: If we ever support TEXTURE_RECTANGLE as a target, be sure to
// track |texture_| with the currently bound TEXTURE_RECTANGLE texture,
// because |texture_| is used by the FBO rendering mechanism for readback
// to the bits that get sent to the browser.
default:
NOTREACHED();
- return 0;
+ return NULL;
}
+ return (info && !info->IsDeleted()) ? info : NULL;
}
// Validates the program and location for a glGetUniform call and returns
@@ -578,9 +605,6 @@ class GLES2DecoderImpl : public GLES2Decoder {
// Current GL error bits.
uint32 error_bits_;
- // Map of client ids to GL ids.
- scoped_ptr<IdManager> id_manager_;
-
// Util to help with GL.
GLES2Util util_;
@@ -592,35 +616,32 @@ class GLES2DecoderImpl : public GLES2Decoder {
// The currently bound array buffer. If this is 0 it is illegal to call
// glVertexAttribPointer.
- GLuint bound_array_buffer_;
+ BufferManager::BufferInfo::Ref bound_array_buffer_;
// The currently bound element array buffer. If this is 0 it is illegal
// to call glDrawElements.
- GLuint bound_element_array_buffer_;
-
- // texture currently bound to GL_TEXTURE_2D with glBindTexture
- GLuint bound_texture_2d_;
-
- // texture currently bound to GL_TEXTURE_CUBE_MAP with glBindTexture
- GLuint bound_texture_cube_map_;
-
- // The maximum vertex attributes.
- GLuint max_vertex_attribs_;
+ BufferManager::BufferInfo::Ref bound_element_array_buffer_;
// Info for each vertex attribute saved so we can check at glDrawXXX time
// if it is safe to draw.
scoped_array<VertexAttribInfo> vertex_attrib_infos_;
- scoped_ptr<BufferManager> buffer_manager_;
-
- scoped_ptr<TextureManager> texture_manager_;
+ // Current active texture by 0 - n index.
+ // In other words, if we call glActiveTexture(GL_TEXTURE2) this value would
+ // be 2.
+ GLuint active_texture_unit_;
- scoped_ptr<ProgramManager> program_manager_;
+ // Which textures are bound to texture units through glActiveTexture.
+ scoped_array<TextureUnit> texture_units_;
- scoped_ptr<ShaderManager> shader_manager_;
+ // Black (0,0,0,0) textures for when non-renderable textures are used.
+ // NOTE: There is no corresponding TextureInfo for these textures.
+ // TextureInfos are only for textures the client side can access.
+ GLuint black_2d_texture_id_;
+ GLuint black_cube_texture_id_;
// The program in use by glUseProgram
- GLuint current_program_;
+ ProgramManager::ProgramInfo::Ref current_program_;
#if defined(UNIT_TEST)
#elif defined(OS_WIN)
@@ -662,22 +683,19 @@ class GLES2DecoderImpl : public GLES2Decoder {
DISALLOW_COPY_AND_ASSIGN(GLES2DecoderImpl);
};
-GLES2Decoder* GLES2Decoder::Create() {
- return new GLES2DecoderImpl();
+GLES2Decoder* GLES2Decoder::Create(ContextGroup* group) {
+ return new GLES2DecoderImpl(group);
}
-GLES2DecoderImpl::GLES2DecoderImpl()
- : GLES2Decoder(),
+GLES2DecoderImpl::GLES2DecoderImpl(ContextGroup* group)
+ : GLES2Decoder(group),
error_bits_(0),
util_(0), // TODO(gman): Set to actual num compress texture formats.
pack_alignment_(4),
unpack_alignment_(4),
- bound_array_buffer_(0),
- bound_element_array_buffer_(0),
- bound_texture_2d_(0),
- bound_texture_cube_map_(0),
- max_vertex_attribs_(0),
- current_program_(0),
+ active_texture_unit_(0),
+ black_2d_texture_id_(0),
+ black_cube_texture_id_(0),
#if defined(UNIT_TEST)
#elif defined(OS_WIN)
device_context_(NULL),
@@ -699,35 +717,42 @@ GLES2DecoderImpl::GLES2DecoderImpl()
bool GLES2DecoderImpl::Initialize() {
bool success = false;
- id_manager_.reset(new IdManager());
- buffer_manager_.reset(new BufferManager());
- shader_manager_.reset(new ShaderManager());
- program_manager_.reset(new ProgramManager());
-
if (InitPlatformSpecific()) {
if (MakeCurrent()) {
if (InitGlew()) {
CHECK_GL_ERROR();
-
- // Lookup GL things we need to know.
- GLint value;
- glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &value);
- max_vertex_attribs_ = value;
-
- GLint max_texture_size;
- GLint max_cube_map_texture_size;
- glGetIntegerv(GL_MAX_TEXTURE_SIZE, &max_texture_size);
- glGetIntegerv(GL_MAX_CUBE_MAP_TEXTURE_SIZE, &max_cube_map_texture_size);
- texture_manager_.reset(new TextureManager(max_texture_size,
- max_cube_map_texture_size));
- DCHECK_GE(max_vertex_attribs_, 8u);
-
- vertex_attrib_infos_.reset(new VertexAttribInfo[max_vertex_attribs_]);
- memset(vertex_attrib_infos_.get(), 0,
- sizeof(vertex_attrib_infos_[0]) * max_vertex_attribs_);
-
- // glBindFramebuffer(0, 0);
- success = true;
+ success = group_->Initialize();
+ if (success) {
+ vertex_attrib_infos_.reset(
+ new VertexAttribInfo[group_->max_vertex_attribs()]);
+ texture_units_.reset(
+ new TextureUnit[group_->max_texture_units()]);
+ GLuint ids[2];
+ glGenTextures(2, ids);
+ // Make black textures for replacing non-renderable textures.
+ black_2d_texture_id_ = ids[0];
+ black_cube_texture_id_ = ids[1];
+ static int8 black[] = {0, 0, 0, 0};
+ glBindTexture(GL_TEXTURE_2D, black_2d_texture_id_);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA,
+ GL_UNSIGNED_BYTE, black);
+ glBindTexture(GL_TEXTURE_2D, 0);
+ glBindTexture(GL_TEXTURE_CUBE_MAP, black_cube_texture_id_);
+ static GLenum faces[] = {
+ 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,
+ };
+ for (size_t ii = 0; ii < arraysize(faces); ++ii) {
+ glTexImage2D(faces[ii], 0, GL_RGBA, 1, 1, 0, GL_RGBA,
+ GL_UNSIGNED_BYTE, black);
+ }
+ glBindTexture(GL_TEXTURE_CUBE_MAP, 0);
+ CHECK_GL_ERROR();
+ }
}
}
}
@@ -1001,7 +1026,7 @@ bool GLES2DecoderImpl::MakeCurrent() {
uint32 GLES2DecoderImpl::GetServiceIdForTesting(uint32 client_id) {
#if defined(UNIT_TEST)
GLuint service_id;
- bool result = id_manager_->GetServiceId(client_id, &service_id);
+ bool result = id_manager()->GetServiceId(client_id, &service_id);
return result ? service_id : 0u;
#else
DCHECK(false);
@@ -1013,7 +1038,7 @@ bool GLES2DecoderImpl::ValidateIdsAreUnused(
GLsizei n, const GLuint* client_ids) {
for (GLsizei ii = 0; ii < n; ++ii) {
GLuint service_id;
- if (id_manager_->GetServiceId(client_ids[ii], &service_id)) {
+ if (id_manager()->GetServiceId(client_ids[ii], &service_id)) {
return false;
}
}
@@ -1023,7 +1048,7 @@ bool GLES2DecoderImpl::ValidateIdsAreUnused(
bool GLES2DecoderImpl::RegisterObjects(
GLsizei n, const GLuint* client_ids, const GLuint* service_ids) {
for (GLsizei ii = 0; ii < n; ++ii) {
- if (!id_manager_->AddMapping(client_ids[ii], service_ids[ii])) {
+ if (!id_manager()->AddMapping(client_ids[ii], service_ids[ii])) {
NOTREACHED();
return false;
}
@@ -1034,8 +1059,8 @@ bool GLES2DecoderImpl::RegisterObjects(
void GLES2DecoderImpl::UnregisterObjects(
GLsizei n, const GLuint* client_ids, GLuint* service_ids) {
for (GLsizei ii = 0; ii < n; ++ii) {
- if (id_manager_->GetServiceId(client_ids[ii], &service_ids[ii])) {
- id_manager_->RemoveMapping(client_ids[ii], service_ids[ii]);
+ if (id_manager()->GetServiceId(client_ids[ii], &service_ids[ii])) {
+ id_manager()->RemoveMapping(client_ids[ii], service_ids[ii]);
} else {
service_ids[ii] = 0;
}
@@ -1465,11 +1490,32 @@ error::Error GLES2DecoderImpl::DoCommand(
return result;
}
+void GLES2DecoderImpl::RemoveBufferInfo(GLuint buffer_id) {
+ buffer_manager()->RemoveBufferInfo(buffer_id);
+ // TODO(gman): See if we can remove the rest of this function as
+ // buffers are now reference counted and have a "IsDeleted" function.
+ if (bound_array_buffer_ && bound_array_buffer_->buffer_id() == buffer_id) {
+ bound_array_buffer_ = NULL;
+ }
+ if (bound_element_array_buffer_ &&
+ bound_element_array_buffer_->buffer_id() == buffer_id) {
+ bound_element_array_buffer_ = NULL;
+ }
+
+ // go through VertexAttribInfo and update any info that references the buffer.
+ for (GLuint ii = 0; ii < group_->max_vertex_attribs(); ++ii) {
+ VertexAttribInfo& info = vertex_attrib_infos_[ii];
+ if (info.buffer() && info.buffer()->buffer_id() == buffer_id) {
+ info.ClearBuffer();
+ }
+ }
+}
+
void GLES2DecoderImpl::CreateProgramHelper(GLuint client_id) {
// TODO(gman): verify client_id is unused.
GLuint service_id = glCreateProgram();
if (service_id) {
- id_manager_->AddMapping(client_id, service_id);
+ id_manager()->AddMapping(client_id, service_id);
CreateProgramInfo(service_id);
}
}
@@ -1478,14 +1524,23 @@ void GLES2DecoderImpl::CreateShaderHelper(GLenum type, GLuint client_id) {
// TODO(gman): verify client_id is unused.
GLuint service_id = glCreateShader(type);
if (service_id) {
- id_manager_->AddMapping(client_id, service_id);
+ id_manager()->AddMapping(client_id, service_id);
CreateShaderInfo(service_id);
}
}
+void GLES2DecoderImpl::DoActiveTexture(GLenum texture_unit) {
+ if (texture_unit > group_->max_texture_units()) {
+ SetGLError(GL_INVALID_ENUM);
+ return;
+ }
+ active_texture_unit_ = texture_unit - GL_TEXTURE0;
+}
+
void GLES2DecoderImpl::DoBindBuffer(GLenum target, GLuint buffer) {
+ BufferManager::BufferInfo* info = NULL;
if (buffer) {
- BufferManager::BufferInfo* info = GetBufferInfo(buffer);
+ info = GetBufferInfo(buffer);
if (!info) {
SetGLError(GL_INVALID_OPERATION);
return;
@@ -1493,10 +1548,10 @@ void GLES2DecoderImpl::DoBindBuffer(GLenum target, GLuint buffer) {
}
switch (target) {
case GL_ARRAY_BUFFER:
- bound_array_buffer_ = buffer;
+ bound_array_buffer_ = info;
break;
case GL_ELEMENT_ARRAY_BUFFER:
- bound_element_array_buffer_ = buffer;
+ bound_element_array_buffer_ = info;
break;
default:
NOTREACHED(); // Validation should prevent us getting here.
@@ -1506,23 +1561,28 @@ void GLES2DecoderImpl::DoBindBuffer(GLenum target, GLuint buffer) {
}
void GLES2DecoderImpl::DoBindTexture(GLenum target, GLuint texture) {
+ TextureManager::TextureInfo* info = NULL;
if (texture) {
- TextureManager::TextureInfo* info = GetTextureInfo(texture);
+ info = GetTextureInfo(texture);
+ // Check the texture exists
+ // Check that we are not trying to bind it to a different target.
if (!info || (info->target() != 0 && info->target() != target)) {
SetGLError(GL_INVALID_OPERATION);
return;
}
if (info->target() == 0) {
- texture_manager_->SetInfoTarget(info, target);
+ texture_manager()->SetInfoTarget(info, target);
}
}
glBindTexture(target, texture);
+ TextureUnit& unit = texture_units_[active_texture_unit_];
+ unit.bind_target = target;
switch (target) {
case GL_TEXTURE_2D:
- bound_texture_2d_ = texture;
+ unit.bound_texture_2d = info;
break;
case GL_TEXTURE_CUBE_MAP:
- bound_texture_cube_map_ = texture;
+ unit.bound_texture_cube_map = info;
break;
default:
NOTREACHED(); // Validation should prevent us getting here.
@@ -1531,7 +1591,7 @@ void GLES2DecoderImpl::DoBindTexture(GLenum target, GLuint texture) {
}
void GLES2DecoderImpl::DoDisableVertexAttribArray(GLuint index) {
- if (index < max_vertex_attribs_) {
+ if (index < group_->max_vertex_attribs()) {
vertex_attrib_infos_[index].set_enabled(false);
glDisableVertexAttribArray(index);
} else {
@@ -1540,7 +1600,7 @@ void GLES2DecoderImpl::DoDisableVertexAttribArray(GLuint index) {
}
void GLES2DecoderImpl::DoEnableVertexAttribArray(GLuint index) {
- if (index < max_vertex_attribs_) {
+ if (index < group_->max_vertex_attribs()) {
vertex_attrib_infos_[index].set_enabled(true);
glEnableVertexAttribArray(index);
} else {
@@ -1549,27 +1609,25 @@ void GLES2DecoderImpl::DoEnableVertexAttribArray(GLuint index) {
}
void GLES2DecoderImpl::DoGenerateMipmap(GLenum target) {
- GLuint texture = GetTextureForTarget(target);
- TextureManager::TextureInfo* info = GetTextureInfo(texture);
- if (!info || !info->CanGenerateMipmaps()) {
+ TextureManager::TextureInfo* info = GetTextureInfoForTarget(target);
+ if (!info || !info->MarkMipmapsGenerated()) {
SetGLError(GL_INVALID_OPERATION);
return;
}
glGenerateMipmapEXT(target);
- info->MarkMipmapsGenerated();
}
error::Error GLES2DecoderImpl::HandleDeleteShader(
uint32 immediate_data_size, const gles2::DeleteShader& c) {
GLuint shader = c.shader;
GLuint service_id;
- if (!id_manager_->GetServiceId(shader, &service_id)) {
+ if (!id_manager()->GetServiceId(shader, &service_id)) {
SetGLError(GL_INVALID_VALUE);
return error::kNoError;
}
RemoveShaderInfo(service_id);
glDeleteShader(service_id);
- id_manager_->RemoveMapping(shader, service_id);
+ id_manager()->RemoveMapping(shader, service_id);
return error::kNoError;
}
@@ -1577,20 +1635,25 @@ error::Error GLES2DecoderImpl::HandleDeleteProgram(
uint32 immediate_data_size, const gles2::DeleteProgram& c) {
GLuint program = c.program;
GLuint service_id;
- if (!id_manager_->GetServiceId(program, &service_id)) {
+ if (!id_manager()->GetServiceId(program, &service_id)) {
SetGLError(GL_INVALID_VALUE);
return error::kNoError;
}
RemoveProgramInfo(service_id);
glDeleteProgram(service_id);
- id_manager_->RemoveMapping(program, service_id);
+ id_manager()->RemoveMapping(program, service_id);
return error::kNoError;
}
void GLES2DecoderImpl::DoDrawArrays(
GLenum mode, GLint first, GLsizei count) {
if (IsDrawValid(first + count - 1)) {
+ bool has_non_renderable_textures;
+ SetBlackTextureForNonRenderableTextures(&has_non_renderable_textures);
glDrawArrays(mode, first, count);
+ if (has_non_renderable_textures) {
+ RestoreStateForNonRenderableTextures();
+ }
}
}
@@ -1656,15 +1719,83 @@ void GLES2DecoderImpl::DoSwapBuffers() {
}
}
-void GLES2DecoderImpl::DoUseProgram(GLuint program) {
- ProgramManager::ProgramInfo* info = GetProgramInfo(program);
+void GLES2DecoderImpl::DoTexParameterf(
+ GLenum target, GLenum pname, GLfloat param) {
+ TextureManager::TextureInfo* info = GetTextureInfoForTarget(target);
if (!info) {
- // Program was not linked successfully. (ie, glLinkProgram)
- SetGLError(GL_INVALID_OPERATION);
+ SetGLError(GL_INVALID_VALUE);
+ } else {
+ info->SetParameter(pname, static_cast<GLint>(param));
+ glTexParameterf(target, pname, param);
+ }
+}
+
+void GLES2DecoderImpl::DoTexParameteri(
+ GLenum target, GLenum pname, GLint param) {
+ TextureManager::TextureInfo* info = GetTextureInfoForTarget(target);
+ if (!info) {
+ SetGLError(GL_INVALID_VALUE);
+ } else {
+ info->SetParameter(pname, param);
+ glTexParameteri(target, pname, param);
+ }
+}
+
+void GLES2DecoderImpl::DoTexParameterfv(
+ GLenum target, GLenum pname, const GLfloat* params) {
+ TextureManager::TextureInfo* info = GetTextureInfoForTarget(target);
+ if (!info) {
+ SetGLError(GL_INVALID_VALUE);
+ } else {
+ info->SetParameter(pname, *reinterpret_cast<const GLint*>(params));
+ glTexParameterfv(target, pname, params);
+ }
+}
+
+void GLES2DecoderImpl::DoTexParameteriv(
+ GLenum target, GLenum pname, const GLint* params) {
+ TextureManager::TextureInfo* info = GetTextureInfoForTarget(target);
+ if (!info) {
+ SetGLError(GL_INVALID_VALUE);
} else {
- current_program_ = program;
- glUseProgram(program);
+ info->SetParameter(pname, *params);
+ glTexParameteriv(target, pname, params);
+ }
+}
+
+void GLES2DecoderImpl::DoUniform1i(GLint location, GLint v0) {
+ if (!current_program_ || current_program_->IsDeleted()) {
+ // The program does not exist.
+ SetGLError(GL_INVALID_OPERATION);
+ return;
}
+ current_program_->SetSamplers(location, 1, &v0);
+ glUniform1i(location, v0);
+}
+
+void GLES2DecoderImpl::DoUniform1iv(
+ GLint location, GLsizei count, const GLint *value) {
+ if (!current_program_ || current_program_->IsDeleted()) {
+ // The program does not exist.
+ SetGLError(GL_INVALID_OPERATION);
+ return;
+ }
+ current_program_->SetSamplers(location, count, value);
+ glUniform1iv(location, count, value);
+}
+
+void GLES2DecoderImpl::DoUseProgram(GLuint program) {
+ ProgramManager::ProgramInfo* info = NULL;
+ if (program) {
+ info = GetProgramInfo(program);
+ if (!info) {
+ // Program was not linked successfully. (ie, glLinkProgram)
+ SetGLError(GL_INVALID_OPERATION);
+ return;
+ }
+ }
+ current_program_ = info;
+ glUseProgram(program);
}
GLenum GLES2DecoderImpl::GetGLError() {
@@ -1697,81 +1828,125 @@ void GLES2DecoderImpl::CopyRealGLErrorsToWrapper() {
}
}
-void GLES2DecoderImpl::RemoveTextureInfo(GLuint texture_id) {
- // TODO(gman): This code needs to change for shared resources. It needs to
- // handle a different decoder deleting the texture. (or, the code that gets
- // a texture always needs to check that it still exists).
- if (bound_texture_2d_ == texture_id) {
- bound_texture_2d_ = 0;
+bool GLES2DecoderImpl::VertexAttribInfo::CanAccess(GLuint index) {
+ if (!enabled_) {
+ return true;
}
- if (bound_texture_cube_map_ == texture_id) {
- bound_texture_cube_map_ = 0;
+
+ if (!buffer_ || buffer_->IsDeleted()) {
+ return false;
}
- texture_manager_->RemoveTextureInfo(texture_id);
-}
-void GLES2DecoderImpl::UpdateVertexAttribInfo(GLuint buffer, GLsizeiptr size) {
- // go through VertexAttribInfo and update any info that references the buffer.
- // TODO(gman): This code needs to change for shared resources.
- for (GLuint ii = 0; ii < max_vertex_attribs_; ++ii) {
- if (vertex_attrib_infos_[ii].buffer() == buffer) {
- vertex_attrib_infos_[ii].SetBufferSize(size);
- }
+ // The number of elements that can be accessed.
+ GLsizeiptr buffer_size = buffer_->size();
+ if (offset_ > buffer_size || real_stride_ == 0) {
+ return false;
}
-}
-void GLES2DecoderImpl::RemoveBufferInfo(GLuint buffer_id) {
- // TODO(gman): This code needs to change for shared resources.
- for (GLuint ii = 0; ii < max_vertex_attribs_; ++ii) {
- if (vertex_attrib_infos_[ii].buffer() == buffer_id) {
- vertex_attrib_infos_[ii].Clear();
+ uint32 usable_size = buffer_size - offset_;
+ GLuint num_elements = usable_size / real_stride_ +
+ ((usable_size % real_stride_) >=
+ (GLES2Util::GetGLTypeSizeForTexturesAndBuffers(type_) * size_) ? 1 : 0);
+ return index < num_elements;
+}
+
+void GLES2DecoderImpl::SetBlackTextureForNonRenderableTextures(
+ bool* has_non_renderable_textures) {
+ DCHECK(has_non_renderable_textures);
+ DCHECK(current_program_);
+ DCHECK(!current_program_->IsDeleted());
+ *has_non_renderable_textures = false;
+ const ProgramManager::ProgramInfo::SamplerIndices& sampler_indices =
+ current_program_->sampler_indices();
+ for (size_t ii = 0; ii < sampler_indices.size(); ++ii) {
+ const ProgramManager::ProgramInfo::UniformInfo* uniform_info =
+ current_program_->GetUniformInfo(sampler_indices[ii]);
+ DCHECK(uniform_info);
+ for (size_t jj = 0; jj < uniform_info->texture_units.size(); ++jj) {
+ GLuint texture_unit_index = uniform_info->texture_units[jj];
+ if (texture_unit_index < group_->max_texture_units()) {
+ TextureUnit& texture_unit = texture_units_[texture_unit_index];
+ TextureManager::TextureInfo* texture_info =
+ uniform_info->type == GL_SAMPLER_2D ?
+ texture_unit.bound_texture_2d :
+ texture_unit.bound_texture_cube_map;
+ if (!texture_info || !texture_info->CanRender()) {
+ *has_non_renderable_textures = true;
+ glActiveTexture(GL_TEXTURE0 + texture_unit_index);
+ glBindTexture(
+ uniform_info->type == GL_SAMPLER_2D ? GL_TEXTURE_2D :
+ GL_TEXTURE_CUBE_MAP,
+ uniform_info->type == GL_SAMPLER_2D ? black_2d_texture_id_ :
+ black_cube_texture_id_);
+ }
+ }
+ // else: should this be an error?
}
}
- if (bound_array_buffer_ == buffer_id) {
- bound_array_buffer_ = 0;
- }
- if (bound_element_array_buffer_ == buffer_id) {
- bound_element_array_buffer_ = 0;
- }
- buffer_manager_->RemoveBufferInfo(buffer_id);
}
-bool GLES2DecoderImpl::VertexAttribInfo::CanAccess(GLuint index) {
- return !enabled_ || (buffer_ != 0 && index < num_elements_);
+void GLES2DecoderImpl::RestoreStateForNonRenderableTextures() {
+ DCHECK(current_program_);
+ DCHECK(!current_program_->IsDeleted());
+ const ProgramManager::ProgramInfo::SamplerIndices& sampler_indices =
+ current_program_->sampler_indices();
+ for (size_t ii = 0; ii < sampler_indices.size(); ++ii) {
+ const ProgramManager::ProgramInfo::UniformInfo* uniform_info =
+ current_program_->GetUniformInfo(sampler_indices[ii]);
+ DCHECK(uniform_info);
+ for (size_t jj = 0; jj < uniform_info->texture_units.size(); ++jj) {
+ GLuint texture_unit_index = uniform_info->texture_units[jj];
+ if (texture_unit_index < group_->max_texture_units()) {
+ TextureUnit& texture_unit = texture_units_[texture_unit_index];
+ TextureManager::TextureInfo* texture_info =
+ uniform_info->type == GL_SAMPLER_2D ?
+ texture_unit.bound_texture_2d :
+ texture_unit.bound_texture_cube_map;
+ if (!texture_info || !texture_info->CanRender()) {
+ glActiveTexture(GL_TEXTURE0 + texture_unit_index);
+ // Get the texture info that was previously bound here.
+ texture_info = texture_unit.bind_target == GL_TEXTURE_2D ?
+ texture_unit.bound_texture_2d :
+ texture_unit.bound_texture_cube_map;
+ glBindTexture(texture_unit.bind_target,
+ texture_info ? texture_info->texture_id() : 0);
+ }
+ }
+ }
+ }
+ // Set the active texture back to whatever the user had it as.
+ glActiveTexture(GL_TEXTURE0 + active_texture_unit_);
}
bool GLES2DecoderImpl::IsDrawValid(GLuint max_vertex_accessed) {
- if (current_program_) {
- ProgramManager::ProgramInfo* info = GetProgramInfo(current_program_);
- if (!info) {
- // The program does not exist.
- SetGLError(GL_INVALID_OPERATION);
+ if (!current_program_ || current_program_->IsDeleted()) {
+ // The program does not exist.
+ // But GL says no ERROR.
+ return false;
+ }
+ // Validate that all attribs current program needs are setup correctly.
+ const ProgramManager::ProgramInfo::AttribInfoVector& infos =
+ current_program_->GetAttribInfos();
+ for (size_t ii = 0; ii < infos.size(); ++ii) {
+ GLint location = infos[ii].location;
+ if (location < 0) {
return false;
}
- // Validate that all attribs current program needs are setup correctly.
- const ProgramManager::ProgramInfo::AttribInfoVector& infos =
- info->GetAttribInfos();
- for (size_t ii = 0; ii < infos.size(); ++ii) {
- GLint location = infos[ii].location;
- if (location < 0) {
- return false;
- }
- DCHECK_LT(static_cast<GLuint>(location), max_vertex_attribs_);
- if (!vertex_attrib_infos_[location].CanAccess(max_vertex_accessed)) {
- SetGLError(GL_INVALID_OPERATION);
- return false;
- }
+ DCHECK_LT(static_cast<GLuint>(location), group_->max_vertex_attribs());
+ if (!vertex_attrib_infos_[location].CanAccess(max_vertex_accessed)) {
+ SetGLError(GL_INVALID_OPERATION);
+ return false;
}
- return true;
}
- // We do not set a GL error here because the GL spec says no error if the
- // program is invalid.
- return false;
+ return true;
};
error::Error GLES2DecoderImpl::HandleDrawElements(
uint32 immediate_data_size, const gles2::DrawElements& c) {
- if (bound_element_array_buffer_ != 0) {
+ if (!bound_element_array_buffer_ ||
+ bound_element_array_buffer_->IsDeleted()) {
+ SetGLError(GL_INVALID_OPERATION);
+ } else {
GLenum mode = c.mode;
GLsizei count = c.count;
GLenum type = c.type;
@@ -1780,38 +1955,32 @@ error::Error GLES2DecoderImpl::HandleDrawElements(
!ValidateGLenumIndexType(type)) {
SetGLError(GL_INVALID_ENUM);
} else {
- // TODO(gman): We could cache this lookup in glBindBuffer.
- BufferManager::BufferInfo* info =
- GetBufferInfo(bound_element_array_buffer_);
- if (!info) {
+ GLsizeiptr buffer_size = bound_element_array_buffer_->size();
+ if (offset > buffer_size) {
SetGLError(GL_INVALID_OPERATION);
} else {
- GLsizeiptr buffer_size = info->size();
- if (offset > buffer_size) {
+ GLsizei usable_size = buffer_size - offset;
+ GLsizei num_elements =
+ usable_size / GLES2Util::GetGLTypeSizeForTexturesAndBuffers(type);
+ if (count > num_elements) {
SetGLError(GL_INVALID_OPERATION);
} else {
- GLsizei usable_size = buffer_size - offset;
- GLsizei num_elements = usable_size / GetGLTypeSize(type);
- if (count > num_elements) {
- SetGLError(GL_INVALID_OPERATION);
- } else {
- const GLvoid* indices = reinterpret_cast<const GLvoid*>(offset);
- // TODO(gman): Validate indices. Get maximum index.
- //
- // This value should be computed by walking the index buffer from 0
- // to count and finding the maximum vertex accessed. For now we'll
- // pass 0 so it should always pass.
- GLuint max_vertex_accessed = info->GetMaxValueForRange(
- offset, count, type);
- if (IsDrawValid(max_vertex_accessed)) {
- glDrawElements(mode, count, type, indices);
+ const GLvoid* indices = reinterpret_cast<const GLvoid*>(offset);
+ GLuint max_vertex_accessed =
+ bound_element_array_buffer_->GetMaxValueForRange(
+ offset, count, type);
+ if (IsDrawValid(max_vertex_accessed)) {
+ bool has_non_renderable_textures;
+ SetBlackTextureForNonRenderableTextures(
+ &has_non_renderable_textures);
+ glDrawElements(mode, count, type, indices);
+ if (has_non_renderable_textures) {
+ RestoreStateForNonRenderableTextures();
}
}
}
}
}
- } else {
- SetGLError(GL_INVALID_OPERATION);
}
return error::kNoError;
}
@@ -1836,7 +2005,7 @@ error::Error GLES2DecoderImpl::ShaderSourceHelper(
error::Error GLES2DecoderImpl::HandleShaderSource(
uint32 immediate_data_size, const gles2::ShaderSource& c) {
GLuint shader;
- if (!id_manager_->GetServiceId(c.shader, &shader)) {
+ if (!id_manager()->GetServiceId(c.shader, &shader)) {
SetGLError(GL_INVALID_VALUE);
return error::kNoError;
}
@@ -1852,7 +2021,7 @@ error::Error GLES2DecoderImpl::HandleShaderSource(
error::Error GLES2DecoderImpl::HandleShaderSourceImmediate(
uint32 immediate_data_size, const gles2::ShaderSourceImmediate& c) {
GLuint shader;
- if (!id_manager_->GetServiceId(c.shader, &shader)) {
+ if (!id_manager()->GetServiceId(c.shader, &shader)) {
SetGLError(GL_INVALID_VALUE);
return error::kNoError;
}
@@ -1897,7 +2066,7 @@ void GLES2DecoderImpl::DoGetShaderSource(
error::Error GLES2DecoderImpl::HandleVertexAttribPointer(
uint32 immediate_data_size, const gles2::VertexAttribPointer& c) {
- if (bound_array_buffer_ != 0) {
+ if (bound_array_buffer_ && !bound_array_buffer_->IsDeleted()) {
GLuint indx = c.indx;
GLint size = c.size;
GLenum type = c.type;
@@ -1907,14 +2076,13 @@ error::Error GLES2DecoderImpl::HandleVertexAttribPointer(
const void* ptr = reinterpret_cast<const void*>(offset);
if (!ValidateGLenumVertexAttribType(type) ||
!ValidateGLintVertexAttribSize(size) ||
- indx >= max_vertex_attribs_ ||
+ indx >= group_->max_vertex_attribs() ||
stride < 0) {
SetGLError(GL_INVALID_VALUE);
return error::kNoError;
}
- const BufferManager::BufferInfo* buffer_info =
- GetBufferInfo(bound_array_buffer_);
- GLsizei component_size = GetGLTypeSize(type);
+ GLsizei component_size =
+ GLES2Util::GetGLTypeSizeForTexturesAndBuffers(type);
GLsizei real_stride = stride != 0 ? stride : component_size * size;
if (offset % component_size > 0) {
SetGLError(GL_INVALID_VALUE);
@@ -1922,7 +2090,6 @@ error::Error GLES2DecoderImpl::HandleVertexAttribPointer(
}
vertex_attrib_infos_[indx].SetInfo(
bound_array_buffer_,
- buffer_info ? buffer_info->size() : 0,
size,
type,
real_stride,
@@ -1998,7 +2165,7 @@ error::Error GLES2DecoderImpl::HandlePixelStorei(
error::Error GLES2DecoderImpl::HandleGetAttribLocation(
uint32 immediate_data_size, const gles2::GetAttribLocation& c) {
GLuint program;
- if (!id_manager_->GetServiceId(c.program, &program)) {
+ if (!id_manager()->GetServiceId(c.program, &program)) {
SetGLError(GL_INVALID_VALUE);
return error::kNoError;
}
@@ -2024,7 +2191,7 @@ error::Error GLES2DecoderImpl::HandleGetAttribLocation(
error::Error GLES2DecoderImpl::HandleGetAttribLocationImmediate(
uint32 immediate_data_size, const gles2::GetAttribLocationImmediate& c) {
GLuint program;
- if (!id_manager_->GetServiceId(c.program, &program)) {
+ if (!id_manager()->GetServiceId(c.program, &program)) {
SetGLError(GL_INVALID_VALUE);
return error::kNoError;
}
@@ -2050,7 +2217,7 @@ error::Error GLES2DecoderImpl::HandleGetAttribLocationImmediate(
error::Error GLES2DecoderImpl::HandleGetUniformLocation(
uint32 immediate_data_size, const gles2::GetUniformLocation& c) {
GLuint program;
- if (!id_manager_->GetServiceId(c.program, &program)) {
+ if (!id_manager()->GetServiceId(c.program, &program)) {
SetGLError(GL_INVALID_VALUE);
return error::kNoError;
}
@@ -2076,7 +2243,7 @@ error::Error GLES2DecoderImpl::HandleGetUniformLocation(
error::Error GLES2DecoderImpl::HandleGetUniformLocationImmediate(
uint32 immediate_data_size, const gles2::GetUniformLocationImmediate& c) {
GLuint program;
- if (!id_manager_->GetServiceId(c.program, &program)) {
+ if (!id_manager()->GetServiceId(c.program, &program)) {
SetGLError(GL_INVALID_VALUE);
return error::kNoError;
}
@@ -2118,8 +2285,7 @@ error::Error GLES2DecoderImpl::HandleBufferData(
SetGLError(GL_INVALID_VALUE);
return error::kNoError;
}
- GLuint buffer = GetBufferForTarget(target);
- BufferManager::BufferInfo* info = GetBufferInfo(buffer);
+ BufferManager::BufferInfo* info = GetBufferInfoForTarget(target);
if (!info) {
SetGLError(GL_INVALID_OPERATION);
return error::kNoError;
@@ -2138,7 +2304,6 @@ error::Error GLES2DecoderImpl::HandleBufferData(
SetGLError(error);
} else {
info->set_size(size);
- UpdateVertexAttribInfo(buffer, size);
}
return error::kNoError;
}
@@ -2158,8 +2323,7 @@ error::Error GLES2DecoderImpl::HandleBufferDataImmediate(
SetGLError(GL_INVALID_VALUE);
return error::kNoError;
}
- GLuint buffer = GetBufferForTarget(target);
- BufferManager::BufferInfo* info = GetBufferInfo(buffer);
+ BufferManager::BufferInfo* info = GetBufferInfoForTarget(target);
if (!info) {
SetGLError(GL_INVALID_OPERATION);
return error::kNoError;
@@ -2171,7 +2335,6 @@ error::Error GLES2DecoderImpl::HandleBufferDataImmediate(
SetGLError(error);
} else {
info->set_size(size);
- UpdateVertexAttribInfo(buffer, size);
}
return error::kNoError;
}
@@ -2191,13 +2354,12 @@ error::Error GLES2DecoderImpl::DoCompressedTexImage2D(
SetGLError(GL_INVALID_ENUM);
return error::kNoError;
}
- if (!texture_manager_->ValidForTarget(target, level, width, height, 1) ||
+ if (!texture_manager()->ValidForTarget(target, level, width, height, 1) ||
border != 0) {
SetGLError(GL_INVALID_VALUE);
return error::kNoError;
}
- GLuint texture = GetTextureForTarget(target);
- TextureManager::TextureInfo* info = GetTextureInfo(texture);
+ TextureManager::TextureInfo* info = GetTextureInfoForTarget(target);
if (!info) {
SetGLError(GL_INVALID_OPERATION);
return error::kNoError;
@@ -2276,13 +2438,12 @@ error::Error GLES2DecoderImpl::DoTexImage2D(
SetGLError(GL_INVALID_ENUM);
return error::kNoError;
}
- if (!texture_manager_->ValidForTarget(target, level, width, height, 1) ||
+ if (!texture_manager()->ValidForTarget(target, level, width, height, 1) ||
border != 0) {
SetGLError(GL_INVALID_VALUE);
return error::kNoError;
}
- GLuint texture = GetTextureForTarget(target);
- TextureManager::TextureInfo* info = GetTextureInfo(texture);
+ TextureManager::TextureInfo* info = GetTextureInfoForTarget(target);
if (!info) {
SetGLError(GL_INVALID_OPERATION);
return error::kNoError;
@@ -2369,7 +2530,7 @@ error::Error GLES2DecoderImpl::HandleGetVertexAttribPointerv(
SetGLError(GL_INVALID_ENUM);
return error::kNoError;
}
- if (index >= max_vertex_attribs_) {
+ if (index >= group_->max_vertex_attribs()) {
SetGLError(GL_INVALID_VALUE);
return error::kNoError;
}
@@ -2394,7 +2555,7 @@ bool GLES2DecoderImpl::GetUniformSetup(
*result_pointer = result;
// Set the result size to 0 so the client does not have to check for success.
result->SetNumResults(0);
- if (!id_manager_->GetServiceId(program, service_id)) {
+ if (!id_manager()->GetServiceId(program, service_id)) {
SetGLError(GL_INVALID_VALUE);
return error::kNoError;
}
@@ -2410,7 +2571,7 @@ bool GLES2DecoderImpl::GetUniformSetup(
SetGLError(GL_INVALID_OPERATION);
return false;
}
- GLsizei size = GLES2Util::GetGLDataTypeSize(type);
+ GLsizei size = GLES2Util::GetGLDataTypeSizeForUniforms(type);
if (size == 0) {
SetGLError(GL_INVALID_OPERATION);
return false;
@@ -2506,7 +2667,7 @@ error::Error GLES2DecoderImpl::HandleGetAttachedShaders(
uint32 immediate_data_size, const gles2::GetAttachedShaders& c) {
GLuint service_id;
uint32 result_size = c.result_size;
- if (!id_manager_->GetServiceId(c.program, &service_id)) {
+ if (!id_manager()->GetServiceId(c.program, &service_id)) {
SetGLError(GL_INVALID_VALUE);
return error::kNoError;
}
@@ -2524,7 +2685,7 @@ error::Error GLES2DecoderImpl::HandleGetAttachedShaders(
GLsizei count = 0;
glGetAttachedShaders(service_id, max_count, &count, result->GetData());
for (GLsizei ii = 0; ii < count; ++ii) {
- if (!id_manager_->GetClientId(result->GetData()[ii],
+ if (!id_manager()->GetClientId(result->GetData()[ii],
&result->GetData()[ii])) {
NOTREACHED();
return error::kGenericError;
@@ -2550,7 +2711,7 @@ error::Error GLES2DecoderImpl::HandleGetActiveUniform(
if (result->success != 0) {
return error::kInvalidArguments;
}
- if (!id_manager_->GetServiceId(program, &service_id)) {
+ if (!id_manager()->GetServiceId(program, &service_id)) {
SetGLError(GL_INVALID_VALUE);
return error::kNoError;
}
@@ -2590,7 +2751,7 @@ error::Error GLES2DecoderImpl::HandleGetActiveAttrib(
if (result->success != 0) {
return error::kInvalidArguments;
}
- if (!id_manager_->GetServiceId(program, &service_id)) {
+ if (!id_manager()->GetServiceId(program, &service_id)) {
SetGLError(GL_INVALID_VALUE);
return error::kNoError;
}
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.h b/gpu/command_buffer/service/gles2_cmd_decoder.h
index 2b6f4e0..cfa4c66 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder.h
+++ b/gpu/command_buffer/service/gles2_cmd_decoder.h
@@ -25,6 +25,8 @@ class XWindowWrapper;
namespace gles2 {
+class ContextGroup;
+
// This class implements the AsyncAPIInterface interface, decoding GLES2
// commands and calling GL.
class GLES2Decoder : public CommonDecoder {
@@ -32,10 +34,9 @@ class GLES2Decoder : public CommonDecoder {
typedef error::Error Error;
// Creates a decoder.
- static GLES2Decoder* Create();
+ static GLES2Decoder* Create(ContextGroup* group);
- virtual ~GLES2Decoder() {
- }
+ virtual ~GLES2Decoder();
bool debug() const {
return debug_;
@@ -87,7 +88,9 @@ class GLES2Decoder : public CommonDecoder {
virtual void SetSwapBuffersCallback(Callback0::Type* callback) = 0;
protected:
- GLES2Decoder();
+ explicit GLES2Decoder(ContextGroup* group);
+
+ ContextGroup* group_;
private:
bool debug_;
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_autogen.h b/gpu/command_buffer/service/gles2_cmd_decoder_autogen.h
index a57b644..12d387f 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder_autogen.h
+++ b/gpu/command_buffer/service/gles2_cmd_decoder_autogen.h
@@ -18,12 +18,12 @@ error::Error GLES2DecoderImpl::HandleActiveTexture(
error::Error GLES2DecoderImpl::HandleAttachShader(
uint32 immediate_data_size, const gles2::AttachShader& c) {
GLuint program;
- if (!id_manager_->GetServiceId(c.program, &program)) {
+ if (!id_manager()->GetServiceId(c.program, &program)) {
SetGLError(GL_INVALID_VALUE);
return error::kNoError;
}
GLuint shader;
- if (!id_manager_->GetServiceId(c.shader, &shader)) {
+ if (!id_manager()->GetServiceId(c.shader, &shader)) {
SetGLError(GL_INVALID_VALUE);
return error::kNoError;
}
@@ -34,7 +34,7 @@ error::Error GLES2DecoderImpl::HandleAttachShader(
error::Error GLES2DecoderImpl::HandleBindAttribLocation(
uint32 immediate_data_size, const gles2::BindAttribLocation& c) {
GLuint program;
- if (!id_manager_->GetServiceId(c.program, &program)) {
+ if (!id_manager()->GetServiceId(c.program, &program)) {
SetGLError(GL_INVALID_VALUE);
return error::kNoError;
}
@@ -53,7 +53,7 @@ error::Error GLES2DecoderImpl::HandleBindAttribLocation(
error::Error GLES2DecoderImpl::HandleBindAttribLocationImmediate(
uint32 immediate_data_size, const gles2::BindAttribLocationImmediate& c) {
GLuint program;
- if (!id_manager_->GetServiceId(c.program, &program)) {
+ if (!id_manager()->GetServiceId(c.program, &program)) {
SetGLError(GL_INVALID_VALUE);
return error::kNoError;
}
@@ -73,7 +73,7 @@ error::Error GLES2DecoderImpl::HandleBindBuffer(
uint32 immediate_data_size, const gles2::BindBuffer& c) {
GLenum target = static_cast<GLenum>(c.target);
GLuint buffer;
- if (!id_manager_->GetServiceId(c.buffer, &buffer)) {
+ if (!id_manager()->GetServiceId(c.buffer, &buffer)) {
SetGLError(GL_INVALID_VALUE);
return error::kNoError;
}
@@ -89,7 +89,7 @@ error::Error GLES2DecoderImpl::HandleBindFramebuffer(
uint32 immediate_data_size, const gles2::BindFramebuffer& c) {
GLenum target = static_cast<GLenum>(c.target);
GLuint framebuffer;
- if (!id_manager_->GetServiceId(c.framebuffer, &framebuffer)) {
+ if (!id_manager()->GetServiceId(c.framebuffer, &framebuffer)) {
SetGLError(GL_INVALID_VALUE);
return error::kNoError;
}
@@ -105,7 +105,7 @@ error::Error GLES2DecoderImpl::HandleBindRenderbuffer(
uint32 immediate_data_size, const gles2::BindRenderbuffer& c) {
GLenum target = static_cast<GLenum>(c.target);
GLuint renderbuffer;
- if (!id_manager_->GetServiceId(c.renderbuffer, &renderbuffer)) {
+ if (!id_manager()->GetServiceId(c.renderbuffer, &renderbuffer)) {
SetGLError(GL_INVALID_VALUE);
return error::kNoError;
}
@@ -121,7 +121,7 @@ error::Error GLES2DecoderImpl::HandleBindTexture(
uint32 immediate_data_size, const gles2::BindTexture& c) {
GLenum target = static_cast<GLenum>(c.target);
GLuint texture;
- if (!id_manager_->GetServiceId(c.texture, &texture)) {
+ if (!id_manager()->GetServiceId(c.texture, &texture)) {
SetGLError(GL_INVALID_VALUE);
return error::kNoError;
}
@@ -305,7 +305,7 @@ error::Error GLES2DecoderImpl::HandleColorMask(
error::Error GLES2DecoderImpl::HandleCompileShader(
uint32 immediate_data_size, const gles2::CompileShader& c) {
GLuint shader;
- if (!id_manager_->GetServiceId(c.shader, &shader)) {
+ if (!id_manager()->GetServiceId(c.shader, &shader)) {
SetGLError(GL_INVALID_VALUE);
return error::kNoError;
}
@@ -563,12 +563,12 @@ error::Error GLES2DecoderImpl::HandleDepthRangef(
error::Error GLES2DecoderImpl::HandleDetachShader(
uint32 immediate_data_size, const gles2::DetachShader& c) {
GLuint program;
- if (!id_manager_->GetServiceId(c.program, &program)) {
+ if (!id_manager()->GetServiceId(c.program, &program)) {
SetGLError(GL_INVALID_VALUE);
return error::kNoError;
}
GLuint shader;
- if (!id_manager_->GetServiceId(c.shader, &shader)) {
+ if (!id_manager()->GetServiceId(c.shader, &shader)) {
SetGLError(GL_INVALID_VALUE);
return error::kNoError;
}
@@ -643,7 +643,7 @@ error::Error GLES2DecoderImpl::HandleFramebufferRenderbuffer(
GLenum attachment = static_cast<GLenum>(c.attachment);
GLenum renderbuffertarget = static_cast<GLenum>(c.renderbuffertarget);
GLuint renderbuffer;
- if (!id_manager_->GetServiceId(c.renderbuffer, &renderbuffer)) {
+ if (!id_manager()->GetServiceId(c.renderbuffer, &renderbuffer)) {
SetGLError(GL_INVALID_VALUE);
return error::kNoError;
}
@@ -670,7 +670,7 @@ error::Error GLES2DecoderImpl::HandleFramebufferTexture2D(
GLenum attachment = static_cast<GLenum>(c.attachment);
GLenum textarget = static_cast<GLenum>(c.textarget);
GLuint texture;
- if (!id_manager_->GetServiceId(c.texture, &texture)) {
+ if (!id_manager()->GetServiceId(c.texture, &texture)) {
SetGLError(GL_INVALID_VALUE);
return error::kNoError;
}
@@ -943,7 +943,7 @@ error::Error GLES2DecoderImpl::HandleGetIntegerv(
error::Error GLES2DecoderImpl::HandleGetProgramiv(
uint32 immediate_data_size, const gles2::GetProgramiv& c) {
GLuint program;
- if (!id_manager_->GetServiceId(c.program, &program)) {
+ if (!id_manager()->GetServiceId(c.program, &program)) {
SetGLError(GL_INVALID_VALUE);
return error::kNoError;
}
@@ -967,7 +967,7 @@ error::Error GLES2DecoderImpl::HandleGetProgramiv(
error::Error GLES2DecoderImpl::HandleGetProgramInfoLog(
uint32 immediate_data_size, const gles2::GetProgramInfoLog& c) {
GLuint program;
- if (!id_manager_->GetServiceId(c.program, &program)) {
+ if (!id_manager()->GetServiceId(c.program, &program)) {
SetGLError(GL_INVALID_VALUE);
return error::kNoError;
}
@@ -1018,7 +1018,7 @@ error::Error GLES2DecoderImpl::HandleGetRenderbufferParameteriv(
error::Error GLES2DecoderImpl::HandleGetShaderiv(
uint32 immediate_data_size, const gles2::GetShaderiv& c) {
GLuint shader;
- if (!id_manager_->GetServiceId(c.shader, &shader)) {
+ if (!id_manager()->GetServiceId(c.shader, &shader)) {
SetGLError(GL_INVALID_VALUE);
return error::kNoError;
}
@@ -1042,7 +1042,7 @@ error::Error GLES2DecoderImpl::HandleGetShaderiv(
error::Error GLES2DecoderImpl::HandleGetShaderInfoLog(
uint32 immediate_data_size, const gles2::GetShaderInfoLog& c) {
GLuint shader;
- if (!id_manager_->GetServiceId(c.shader, &shader)) {
+ if (!id_manager()->GetServiceId(c.shader, &shader)) {
SetGLError(GL_INVALID_VALUE);
return error::kNoError;
}
@@ -1069,7 +1069,7 @@ error::Error GLES2DecoderImpl::HandleGetShaderInfoLog(
error::Error GLES2DecoderImpl::HandleGetShaderSource(
uint32 immediate_data_size, const gles2::GetShaderSource& c) {
GLuint shader;
- if (!id_manager_->GetServiceId(c.shader, &shader)) {
+ if (!id_manager()->GetServiceId(c.shader, &shader)) {
SetGLError(GL_INVALID_VALUE);
return error::kNoError;
}
@@ -1211,7 +1211,7 @@ error::Error GLES2DecoderImpl::HandleHint(
error::Error GLES2DecoderImpl::HandleIsBuffer(
uint32 immediate_data_size, const gles2::IsBuffer& c) {
GLuint buffer;
- if (!id_manager_->GetServiceId(c.buffer, &buffer)) {
+ if (!id_manager()->GetServiceId(c.buffer, &buffer)) {
SetGLError(GL_INVALID_VALUE);
return error::kNoError;
}
@@ -1237,7 +1237,7 @@ error::Error GLES2DecoderImpl::HandleIsEnabled(
error::Error GLES2DecoderImpl::HandleIsFramebuffer(
uint32 immediate_data_size, const gles2::IsFramebuffer& c) {
GLuint framebuffer;
- if (!id_manager_->GetServiceId(c.framebuffer, &framebuffer)) {
+ if (!id_manager()->GetServiceId(c.framebuffer, &framebuffer)) {
SetGLError(GL_INVALID_VALUE);
return error::kNoError;
}
@@ -1250,7 +1250,7 @@ error::Error GLES2DecoderImpl::HandleIsFramebuffer(
error::Error GLES2DecoderImpl::HandleIsProgram(
uint32 immediate_data_size, const gles2::IsProgram& c) {
GLuint program;
- if (!id_manager_->GetServiceId(c.program, &program)) {
+ if (!id_manager()->GetServiceId(c.program, &program)) {
SetGLError(GL_INVALID_VALUE);
return error::kNoError;
}
@@ -1263,7 +1263,7 @@ error::Error GLES2DecoderImpl::HandleIsProgram(
error::Error GLES2DecoderImpl::HandleIsRenderbuffer(
uint32 immediate_data_size, const gles2::IsRenderbuffer& c) {
GLuint renderbuffer;
- if (!id_manager_->GetServiceId(c.renderbuffer, &renderbuffer)) {
+ if (!id_manager()->GetServiceId(c.renderbuffer, &renderbuffer)) {
SetGLError(GL_INVALID_VALUE);
return error::kNoError;
}
@@ -1276,7 +1276,7 @@ error::Error GLES2DecoderImpl::HandleIsRenderbuffer(
error::Error GLES2DecoderImpl::HandleIsShader(
uint32 immediate_data_size, const gles2::IsShader& c) {
GLuint shader;
- if (!id_manager_->GetServiceId(c.shader, &shader)) {
+ if (!id_manager()->GetServiceId(c.shader, &shader)) {
SetGLError(GL_INVALID_VALUE);
return error::kNoError;
}
@@ -1289,7 +1289,7 @@ error::Error GLES2DecoderImpl::HandleIsShader(
error::Error GLES2DecoderImpl::HandleIsTexture(
uint32 immediate_data_size, const gles2::IsTexture& c) {
GLuint texture;
- if (!id_manager_->GetServiceId(c.texture, &texture)) {
+ if (!id_manager()->GetServiceId(c.texture, &texture)) {
SetGLError(GL_INVALID_VALUE);
return error::kNoError;
}
@@ -1309,7 +1309,7 @@ error::Error GLES2DecoderImpl::HandleLineWidth(
error::Error GLES2DecoderImpl::HandleLinkProgram(
uint32 immediate_data_size, const gles2::LinkProgram& c) {
GLuint program;
- if (!id_manager_->GetServiceId(c.program, &program)) {
+ if (!id_manager()->GetServiceId(c.program, &program)) {
SetGLError(GL_INVALID_VALUE);
return error::kNoError;
}
@@ -1471,7 +1471,7 @@ error::Error GLES2DecoderImpl::HandleTexParameterf(
SetGLError(GL_INVALID_ENUM);
return error::kNoError;
}
- glTexParameterf(target, pname, param);
+ DoTexParameterf(target, pname, param);
return error::kNoError;
}
@@ -1494,7 +1494,7 @@ error::Error GLES2DecoderImpl::HandleTexParameterfv(
if (params == NULL) {
return error::kOutOfBounds;
}
- glTexParameterfv(target, pname, params);
+ DoTexParameterfv(target, pname, params);
return error::kNoError;
}
@@ -1517,7 +1517,7 @@ error::Error GLES2DecoderImpl::HandleTexParameterfvImmediate(
if (params == NULL) {
return error::kOutOfBounds;
}
- glTexParameterfv(target, pname, params);
+ DoTexParameterfv(target, pname, params);
return error::kNoError;
}
@@ -1534,7 +1534,7 @@ error::Error GLES2DecoderImpl::HandleTexParameteri(
SetGLError(GL_INVALID_ENUM);
return error::kNoError;
}
- glTexParameteri(target, pname, param);
+ DoTexParameteri(target, pname, param);
return error::kNoError;
}
@@ -1557,7 +1557,7 @@ error::Error GLES2DecoderImpl::HandleTexParameteriv(
if (params == NULL) {
return error::kOutOfBounds;
}
- glTexParameteriv(target, pname, params);
+ DoTexParameteriv(target, pname, params);
return error::kNoError;
}
@@ -1580,7 +1580,7 @@ error::Error GLES2DecoderImpl::HandleTexParameterivImmediate(
if (params == NULL) {
return error::kOutOfBounds;
}
- glTexParameteriv(target, pname, params);
+ DoTexParameteriv(target, pname, params);
return error::kNoError;
}
@@ -1694,7 +1694,7 @@ error::Error GLES2DecoderImpl::HandleUniform1i(
uint32 immediate_data_size, const gles2::Uniform1i& c) {
GLint location = static_cast<GLint>(c.location);
GLint x = static_cast<GLint>(c.x);
- glUniform1i(location, x);
+ DoUniform1i(location, x);
return error::kNoError;
}
@@ -1709,7 +1709,7 @@ error::Error GLES2DecoderImpl::HandleUniform1iv(
if (v == NULL) {
return error::kOutOfBounds;
}
- glUniform1iv(location, count, v);
+ DoUniform1iv(location, count, v);
return error::kNoError;
}
@@ -1724,7 +1724,7 @@ error::Error GLES2DecoderImpl::HandleUniform1ivImmediate(
if (v == NULL) {
return error::kOutOfBounds;
}
- glUniform1iv(location, count, v);
+ DoUniform1iv(location, count, v);
return error::kNoError;
}
@@ -2091,7 +2091,7 @@ error::Error GLES2DecoderImpl::HandleUniformMatrix4fvImmediate(
error::Error GLES2DecoderImpl::HandleUseProgram(
uint32 immediate_data_size, const gles2::UseProgram& c) {
GLuint program;
- if (!id_manager_->GetServiceId(c.program, &program)) {
+ if (!id_manager()->GetServiceId(c.program, &program)) {
SetGLError(GL_INVALID_VALUE);
return error::kNoError;
}
@@ -2102,7 +2102,7 @@ error::Error GLES2DecoderImpl::HandleUseProgram(
error::Error GLES2DecoderImpl::HandleValidateProgram(
uint32 immediate_data_size, const gles2::ValidateProgram& c) {
GLuint program;
- if (!id_manager_->GetServiceId(c.program, &program)) {
+ if (!id_manager()->GetServiceId(c.program, &program)) {
SetGLError(GL_INVALID_VALUE);
return error::kNoError;
}
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_mock.h b/gpu/command_buffer/service/gles2_cmd_decoder_mock.h
index f782be4..2beff5a 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder_mock.h
+++ b/gpu/command_buffer/service/gles2_cmd_decoder_mock.h
@@ -14,9 +14,11 @@
namespace gpu {
namespace gles2 {
+class ContextGroup;
class MockGLES2Decoder : public GLES2Decoder {
public:
- MockGLES2Decoder() {
+ explicit MockGLES2Decoder(ContextGroup* group)
+ : GLES2Decoder(group) {
ON_CALL(*this, GetCommandName(testing::_))
.WillByDefault(testing::Return(""));
ON_CALL(*this, MakeCurrent())
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc b/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc
index a656d13..09ddc14 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc
+++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc
@@ -3,11 +3,12 @@
// found in the LICENSE file.
#include "gpu/command_buffer/service/gles2_cmd_decoder.h"
-#include "base/string_util.h"
#include "gpu/command_buffer/common/gles2_cmd_format.h"
#include "gpu/command_buffer/common/gles2_cmd_utils.h"
#include "gpu/command_buffer/service/gl_mock.h"
+#include "gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.h"
#include "gpu/command_buffer/service/cmd_buffer_engine.h"
+#include "gpu/command_buffer/service/context_group.h"
#include "gpu/command_buffer/service/program_manager.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -26,650 +27,56 @@ using ::testing::StrictMock;
namespace gpu {
namespace gles2 {
-class GLES2DecoderTest : public testing::Test {
+class GLES2DecoderTest : public GLES2DecoderTestBase {
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),
- client_element_buffer_id_(106) {
- memset(immediate_buffer_, 0xEE, sizeof(immediate_buffer_));
- }
-
- protected:
- static const GLint kMaxTextureSize = 2048;
- static const GLint kMaxCubeMapTextureSize = 256;
- 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 GLuint kServiceElementBufferId = 307;
-
- 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 kInitialResult = 0xBDBDBDBDu;
- static const uint8 kInitialMemoryValue = 0xBDu;
-
- 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(error::kNoError,
- 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) {
- return reinterpret_cast<T>(ImmediateDataAddress(cmd));
- }
-
- void ClearSharedMemory() {
- engine_->ClearSharedMemory();
- }
-
- virtual void SetUp() {
- gl_.reset(new StrictMock<MockGLInterface>());
- ::gles2::GLInterface::SetGLInterface(gl_.get());
-
- EXPECT_CALL(*gl_, GetIntegerv(GL_MAX_VERTEX_ATTRIBS, _))
- .WillOnce(SetArgumentPointee<1>(kNumVertexAttribs))
- .RetiresOnSaturation();
- EXPECT_CALL(*gl_, GetIntegerv(GL_MAX_TEXTURE_SIZE, _))
- .WillOnce(SetArgumentPointee<1>(kMaxTextureSize))
- .RetiresOnSaturation();
- EXPECT_CALL(*gl_, GetIntegerv(GL_MAX_CUBE_MAP_TEXTURE_SIZE, _))
- .WillOnce(SetArgumentPointee<1>(kMaxCubeMapTextureSize))
- .RetiresOnSaturation();
- EXPECT_CALL(*gl_, GetError())
- .WillRepeatedly(Return(GL_NO_ERROR));
-
- engine_.reset(new StrictMock<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();
- GenHelper<GenBuffersImmediate>(client_buffer_id_);
- EXPECT_CALL(*gl_, GenFramebuffersEXT(_, _))
- .WillOnce(SetArgumentPointee<1>(kServiceFramebufferId))
- .RetiresOnSaturation();
- GenHelper<GenFramebuffersImmediate>(client_framebuffer_id_);
- EXPECT_CALL(*gl_, GenRenderbuffersEXT(_, _))
- .WillOnce(SetArgumentPointee<1>(kServiceRenderbufferId))
- .RetiresOnSaturation();
- GenHelper<GenRenderbuffersImmediate>(client_renderbuffer_id_);
- EXPECT_CALL(*gl_, GenTextures(_, _))
- .WillOnce(SetArgumentPointee<1>(kServiceTextureId))
- .RetiresOnSaturation();
- GenHelper<GenTexturesImmediate>(client_texture_id_);
- EXPECT_CALL(*gl_, GenBuffersARB(_, _))
- .WillOnce(SetArgumentPointee<1>(kServiceElementBufferId))
- .RetiresOnSaturation();
- GenHelper<GenBuffersImmediate>(client_element_buffer_id_);
-
- {
- EXPECT_CALL(*gl_, CreateProgram())
- .Times(1)
- .WillOnce(Return(kServiceProgramId))
- .RetiresOnSaturation();
- CreateProgram cmd;
- cmd.Init(client_program_id_);
- EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
- }
-
- {
- EXPECT_CALL(*gl_, CreateShader(_))
- .Times(1)
- .WillOnce(Return(kServiceShaderId))
- .RetiresOnSaturation();
- CreateShader cmd;
- cmd.Init(GL_VERTEX_SHADER, client_shader_id_);
- EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
- }
-
- EXPECT_EQ(GL_NO_ERROR, GetGLError());
- }
-
- virtual void TearDown() {
- decoder_->Destroy();
- decoder_.reset();
- engine_.reset();
- ::gles2::GLInterface::SetGLInterface(NULL);
- gl_.reset();
- }
-
- template <typename T>
- error::Error ExecuteCmd(const T& cmd) {
- COMPILE_ASSERT(T::kArgFlags == cmd::kFixed, Cmd_kArgFlags_not_kFixed);
- return decoder_->DoCommand(cmd.kCmdId,
- ComputeNumEntries(sizeof(cmd)) - 1,
- &cmd);
- }
-
- template <typename T>
- error::Error 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);
- }
-
- template <typename T>
- T GetSharedMemoryAs() {
- return reinterpret_cast<T>(shared_memory_address_);
- }
-
- template <typename T>
- T GetSharedMemoryAsWithOffset(uint32 offset) {
- void* ptr = reinterpret_cast<int8*>(shared_memory_address_) + offset;
- return reinterpret_cast<T>(ptr);
- }
-
- uint32 GetServiceId(uint32 client_id) {
- return decoder_->GetServiceIdForTesting(client_id);
- }
-
- // Note that the error is returned as GLint instead of GLenum.
- // This is because there is a mismatch in the types of GLenum and
- // the error values GL_NO_ERROR, GL_INVALID_ENUM, etc. GLenum is
- // typedef'd as unsigned int while the error values are defined as
- // integers. This is problematic for template functions such as
- // EXPECT_EQ that expect both types to be the same.
- GLint GetGLError() {
- EXPECT_CALL(*gl_, GetError())
- .WillOnce(Return(GL_NO_ERROR))
- .RetiresOnSaturation();
- GetError cmd;
- cmd.Init(shared_memory_id_, shared_memory_offset_);
- EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
- return static_cast<GLint>(*GetSharedMemoryAs<GLenum*>());
- }
-
- void DoBindTexture(GLenum target, GLuint client_id, GLuint service_id) {
- EXPECT_CALL(*gl_, BindTexture(target, service_id))
- .Times(1)
- .RetiresOnSaturation();
- BindTexture cmd;
- cmd.Init(target, client_id);
- EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
- }
-
- void DoTexImage2D(GLenum target, GLint level, GLenum internal_format,
- GLsizei width, GLsizei height, GLint border,
- GLenum format, GLenum type,
- uint32 shared_memory_id, uint32 shared_memory_offset) {
- EXPECT_CALL(*gl_, TexImage2D(target, level, internal_format,
- width, height, border, format, type, _))
- .Times(1)
- .RetiresOnSaturation();
- TexImage2D cmd;
- cmd.Init(target, level, internal_format, width, height, border, format,
- type, shared_memory_id, shared_memory_offset);
- EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
- }
-
- // Use StrictMock to make 100% sure we know how GL will be called.
- scoped_ptr<StrictMock<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_;
- GLuint client_element_buffer_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]);
- ClearSharedMemory();
- 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 ClearSharedMemory() {
- memset(data_.get(), kInitialMemoryValue, kSharedBufferSize);
- }
-
- void set_token(int32 token) {
- DCHECK(false);
- }
-
- // Overridden from CommandBufferEngine.
- virtual bool SetGetOffset(int32 offset) {
- DCHECK(false);
- return false;
- }
-
- // Overridden from CommandBufferEngine.
- virtual int32 GetGetOffset() {
- DCHECK(false);
- return 0;
- }
-
- private:
- scoped_array<int8> data_;
- Buffer valid_buffer_;
- Buffer invalid_buffer_;
- };
-
- scoped_ptr<StrictMock<MockCommandBufferEngine> > engine_;
+ GLES2DecoderTest() { }
};
-const GLint GLES2DecoderTest::kNumVertexAttribs;
-const GLuint GLES2DecoderTest::kServiceBufferId;
-const GLuint GLES2DecoderTest::kServiceFramebufferId;
-const GLuint GLES2DecoderTest::kServiceRenderbufferId;
-const GLuint GLES2DecoderTest::kServiceTextureId;
-const GLuint GLES2DecoderTest::kServiceProgramId;
-const GLuint GLES2DecoderTest::kServiceShaderId;
-const GLuint GLES2DecoderTest::kServiceElementBufferId;
-const int32 GLES2DecoderTest::kSharedMemoryId;
-const size_t GLES2DecoderTest::kSharedBufferSize;
-const uint32 GLES2DecoderTest::kSharedMemoryOffset;
-const int32 GLES2DecoderTest::kInvalidSharedMemoryId;
-const uint32 GLES2DecoderTest::kInvalidSharedMemoryOffset;
-const uint32 GLES2DecoderTest::kInitialResult;
-const uint32 GLES2DecoderTest::kNewClientId;
-const uint32 GLES2DecoderTest::kNewServiceId;
-const uint32 GLES2DecoderTest::kInvalidClientId;
-
-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));
- EXPECT_CALL(*gl_, GetProgramiv(kServiceProgramId, GL_ACTIVE_UNIFORMS, _))
- .WillOnce(SetArgumentPointee<2>(0));
- EXPECT_CALL(
- *gl_,
- GetProgramiv(kServiceProgramId, GL_ACTIVE_UNIFORM_MAX_LENGTH, _))
- .WillOnce(SetArgumentPointee<2>(0));
-};
-
-template <>
-void GLES2DecoderTest::SpecializedSetup<GenerateMipmap, 0>() {
- DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId);
- DoTexImage2D(
- GL_TEXTURE_2D, 0, GL_RGBA, 16, 16, 0, GL_RGBA, GL_UNSIGNED_BYTE,
- 0, 0);
-};
-
-class GLES2DecoderWithShaderTest : public GLES2DecoderTest {
+class GLES2DecoderWithShaderTest : public GLES2DecoderWithShaderTestBase {
public:
GLES2DecoderWithShaderTest()
- : GLES2DecoderTest() {
- }
-
- static const GLsizei kNumVertices = 100;
- static const GLsizei kNumIndices = 10;
- static const int kValidIndexRangeStart = 1;
- static const int kValidIndexRangeCount = 7;
- static const int kInvalidIndexRangeStart = 0;
- static const int kInvalidIndexRangeCount = 7;
- static const int kOutOfRangeIndexRangeEnd = 10;
-
- static const GLint kMaxAttribLength = 10;
- static const char* kAttrib1Name;
- static const char* kAttrib2Name;
- static const char* kAttrib3Name;
- static const GLint kAttrib1Size = 1;
- static const GLint kAttrib2Size = 1;
- static const GLint kAttrib3Size = 1;
- static const GLint kAttrib1Location = 0;
- static const GLint kAttrib2Location = 1;
- static const GLint kAttrib3Location = 2;
- static const GLenum kAttrib1Type = GL_FLOAT_VEC4;
- static const GLenum kAttrib2Type = GL_FLOAT_VEC2;
- static const GLenum kAttrib3Type = GL_FLOAT_VEC3;
- static const GLint kInvalidAttribLocation = 30;
- static const GLint kBadAttribIndex = kNumVertexAttribs;
-
- static const GLint kMaxUniformLength = 10;
- static const char* kUniform1Name;
- static const char* kUniform2Name;
- static const char* kUniform3Name;
- static const GLint kUniform1Size = 1;
- static const GLint kUniform2Size = 3;
- static const GLint kUniform3Size = 2;
- static const GLint kUniform1Location = 3;
- static const GLint kUniform2Location = 10;
- static const GLint kUniform2ElementLocation = 12;
- static const GLint kUniform3Location = 20;
- static const GLenum kUniform1Type = GL_FLOAT_VEC4;
- static const GLenum kUniform2Type = GL_INT_VEC2;
- static const GLenum kUniform3Type = GL_FLOAT_VEC3;
- static const GLint kInvalidUniformLocation = 30;
- static const GLint kBadUniformIndex = 1000;
-
- protected:
- struct AttribInfo {
- const char* name;
- GLint size;
- GLenum type;
- GLint location;
- };
-
- struct UniformInfo {
- const char* name;
- GLint size;
- GLenum type;
- GLint location;
- };
-
- virtual void SetUp() {
- GLES2DecoderTest::SetUp();
-
- {
- static AttribInfo attribs[] = {
- { kAttrib1Name, kAttrib1Size, kAttrib1Type, kAttrib1Location, },
- { kAttrib2Name, kAttrib2Size, kAttrib2Type, kAttrib2Location, },
- { kAttrib3Name, kAttrib3Size, kAttrib3Type, kAttrib3Location, },
- };
- static UniformInfo uniforms[] = {
- { kUniform1Name, kUniform1Size, kUniform1Type, kUniform1Location, },
- { kUniform2Name, kUniform2Size, kUniform2Type, kUniform2Location, },
- { kUniform3Name, kUniform3Size, kUniform3Type, kUniform3Location, },
- };
- SetupShader(attribs, arraysize(attribs), uniforms, arraysize(uniforms),
- client_program_id_, kServiceProgramId);
- }
-
- {
- EXPECT_CALL(*gl_, UseProgram(kServiceProgramId))
- .Times(1)
- .RetiresOnSaturation();
- UseProgram cmd;
- cmd.Init(client_program_id_);
- EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
- }
- }
-
- virtual void TearDown() {
- GLES2DecoderTest::TearDown();
- }
-
- void SetupShader(AttribInfo* attribs, size_t num_attribs,
- UniformInfo* uniforms, size_t num_uniforms,
- GLuint client_id, GLuint service_id) {
- LinkProgram cmd;
- cmd.Init(client_id);
-
- {
- InSequence s;
- EXPECT_CALL(*gl_, LinkProgram(service_id))
- .Times(1)
- .RetiresOnSaturation();
- EXPECT_CALL(*gl_, GetError())
- .WillOnce(Return(GL_NO_ERROR))
- .RetiresOnSaturation();
- EXPECT_CALL(*gl_,
- GetProgramiv(service_id, GL_ACTIVE_ATTRIBUTES, _))
- .WillOnce(SetArgumentPointee<2>(num_attribs))
- .RetiresOnSaturation();
- EXPECT_CALL(*gl_,
- GetProgramiv(service_id, GL_ACTIVE_ATTRIBUTE_MAX_LENGTH, _))
- .WillOnce(SetArgumentPointee<2>(kMaxAttribLength))
- .RetiresOnSaturation();
- for (size_t ii = 0; ii < num_attribs; ++ii) {
- const AttribInfo& info = attribs[ii];
- EXPECT_CALL(*gl_,
- GetActiveAttrib(service_id, ii,
- kMaxAttribLength, _, _, _, _))
- .WillOnce(DoAll(
- SetArgumentPointee<3>(strlen(info.name)),
- SetArgumentPointee<4>(info.size),
- SetArgumentPointee<5>(info.type),
- SetArrayArgument<6>(info.name,
- info.name + strlen(info.name) + 1)))
- .RetiresOnSaturation();
- if (!ProgramManager::IsInvalidPrefix(info.name, strlen(info.name))) {
- EXPECT_CALL(*gl_, GetAttribLocation(service_id,
- StrEq(info.name)))
- .WillOnce(Return(info.location))
- .RetiresOnSaturation();
- }
- }
- EXPECT_CALL(*gl_,
- GetProgramiv(service_id, GL_ACTIVE_UNIFORMS, _))
- .WillOnce(SetArgumentPointee<2>(num_uniforms))
- .RetiresOnSaturation();
- EXPECT_CALL(*gl_,
- GetProgramiv(service_id, GL_ACTIVE_UNIFORM_MAX_LENGTH, _))
- .WillOnce(SetArgumentPointee<2>(kMaxUniformLength))
- .RetiresOnSaturation();
- for (size_t ii = 0; ii < num_uniforms; ++ii) {
- const UniformInfo& info = uniforms[ii];
- EXPECT_CALL(*gl_,
- GetActiveUniform(service_id, ii,
- kMaxUniformLength, _, _, _, _))
- .WillOnce(DoAll(
- SetArgumentPointee<3>(strlen(info.name)),
- SetArgumentPointee<4>(info.size),
- SetArgumentPointee<5>(info.type),
- SetArrayArgument<6>(info.name,
- info.name + strlen(info.name) + 1)))
- .RetiresOnSaturation();
- if (!ProgramManager::IsInvalidPrefix(info.name, strlen(info.name))) {
- EXPECT_CALL(*gl_, GetUniformLocation(service_id,
- StrEq(info.name)))
- .WillOnce(Return(info.location))
- .RetiresOnSaturation();
- if (info.size > 1) {
- for (GLsizei jj = 1; jj < info.size; ++jj) {
- std::string element_name(
- std::string(info.name) + "[" + IntToString(jj) + "]");
- EXPECT_CALL(*gl_, GetUniformLocation(service_id,
- StrEq(element_name)))
- .WillOnce(Return(info.location + jj))
- .RetiresOnSaturation();
- }
- }
- }
- }
- }
-
- EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
- }
-
- inline GLvoid* BufferOffset(unsigned i) {
- return static_cast<int8 *>(NULL)+(i);
+ : GLES2DecoderWithShaderTestBase() {
}
+};
- void DoEnableVertexAttribArray(GLint index) {
- EXPECT_CALL(*gl_, EnableVertexAttribArray(index))
- .Times(1)
- .RetiresOnSaturation();
- EnableVertexAttribArray cmd;
- cmd.Init(index);
- EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
- }
+TEST_F(GLES2DecoderWithShaderTest, DrawArraysNoAttributesSucceeds) {
+ SetupTexture();
+ EXPECT_CALL(*gl_, DrawArrays(GL_TRIANGLES, 0, kNumVertices))
+ .Times(1)
+ .RetiresOnSaturation();
+ DrawArrays cmd;
+ cmd.Init(GL_TRIANGLES, 0, kNumVertices);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+ EXPECT_EQ(GL_NO_ERROR, GetGLError());
+}
- void DoBindBuffer(GLenum target, GLuint client_id, GLuint service_id) {
- EXPECT_CALL(*gl_, BindBuffer(target, service_id))
+TEST_F(GLES2DecoderWithShaderTest, DrawArraysBadTextureUsesBlack) {
+ DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId);
+ // This is an NPOT texture. As the default filtering requires mips
+ // this should trigger replacing with black textures before rendering.
+ DoTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 3, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE,
+ 0, 0);
+ {
+ InSequence sequence;
+ EXPECT_CALL(*gl_, ActiveTexture(GL_TEXTURE0))
.Times(1)
.RetiresOnSaturation();
- BindBuffer cmd;
- cmd.Init(target, client_id);
- EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
- }
-
- void DoBufferData(GLenum target, GLsizei size) {
- EXPECT_CALL(*gl_, BufferData(target, size, _, GL_STREAM_DRAW))
+ EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_2D, kServiceBlackTexture2dId))
.Times(1)
.RetiresOnSaturation();
- BufferData cmd;
- cmd.Init(target, size, 0, 0, GL_STREAM_DRAW);
- EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
- }
-
- void DoBufferSubData(
- GLenum target, GLint offset, GLsizei size, const void* data) {
- EXPECT_CALL(*gl_, BufferSubData(target, offset, size,
- shared_memory_address_))
+ EXPECT_CALL(*gl_, DrawArrays(GL_TRIANGLES, 0, kNumVertices))
.Times(1)
.RetiresOnSaturation();
- memcpy(shared_memory_address_, data, size);
- BufferSubData cmd;
- cmd.Init(target, offset, size, shared_memory_id_, shared_memory_offset_);
- EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
- }
-
- void DoDeleteBuffer(GLuint client_id, GLuint service_id) {
- EXPECT_CALL(*gl_, DeleteBuffersARB(1, Pointee(service_id)))
+ EXPECT_CALL(*gl_, ActiveTexture(GL_TEXTURE0))
.Times(1)
.RetiresOnSaturation();
- DeleteBuffers cmd;
- cmd.Init(1, shared_memory_id_, shared_memory_offset_);
- memcpy(shared_memory_address_, &client_id, sizeof(client_id));
- EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
- }
-
- void DoDeleteProgram(GLuint client_id, GLuint service_id) {
- EXPECT_CALL(*gl_, DeleteProgram(service_id))
+ EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_2D, kServiceTextureId))
.Times(1)
.RetiresOnSaturation();
- DeleteProgram cmd;
- cmd.Init(client_id);
- EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
- }
-
- void DoVertexAttribPointer(
- GLuint index, GLint size, GLenum type, GLsizei stride, GLuint offset) {
- EXPECT_CALL(*gl_,
- VertexAttribPointer(index, size, type, GL_FALSE, stride,
- BufferOffset(offset)))
+ EXPECT_CALL(*gl_, ActiveTexture(GL_TEXTURE0))
.Times(1)
.RetiresOnSaturation();
- VertexAttribPointer cmd;
- cmd.Init(index, size, GL_FLOAT, GL_FALSE, stride, offset);
- EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
- }
-
- void SetupVertexBuffer() {
- DoEnableVertexAttribArray(1);
- DoBindBuffer(GL_ARRAY_BUFFER, client_buffer_id_, kServiceBufferId);
- GLfloat f = 0;
- DoBufferData(GL_ARRAY_BUFFER, kNumVertices * 2 * sizeof(f));
- }
-
- void SetupIndexBuffer() {
- DoBindBuffer(GL_ELEMENT_ARRAY_BUFFER,
- client_element_buffer_id_,
- kServiceElementBufferId);
- static const GLshort indices[] = {100, 1, 2, 3, 4, 5, 6, 7, 100, 9};
- COMPILE_ASSERT(arraysize(indices) == kNumIndices, Indices_is_not_10);
- DoBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(indices));
- DoBufferSubData(GL_ELEMENT_ARRAY_BUFFER, 0, sizeof(indices), indices);
- }
-
- void DeleteVertexBuffer() {
- DoDeleteBuffer(client_buffer_id_, kServiceBufferId);
}
-
- void DeleteIndexBuffer() {
- DoDeleteBuffer(client_element_buffer_id_, kServiceElementBufferId);
- }
-};
-
-const GLint GLES2DecoderWithShaderTest::kMaxAttribLength;
-const GLsizei GLES2DecoderWithShaderTest::kNumVertices;
-const GLsizei GLES2DecoderWithShaderTest::kNumIndices;
-const int GLES2DecoderWithShaderTest::kValidIndexRangeStart;
-const int GLES2DecoderWithShaderTest::kValidIndexRangeCount;
-const int GLES2DecoderWithShaderTest::kInvalidIndexRangeStart;
-const int GLES2DecoderWithShaderTest::kInvalidIndexRangeCount;
-const int GLES2DecoderWithShaderTest::kOutOfRangeIndexRangeEnd;
-const char* GLES2DecoderWithShaderTest::kAttrib1Name = "attrib1";
-const char* GLES2DecoderWithShaderTest::kAttrib2Name = "attrib2";
-const char* GLES2DecoderWithShaderTest::kAttrib3Name = "attrib3";
-const GLint GLES2DecoderWithShaderTest::kAttrib1Size;
-const GLint GLES2DecoderWithShaderTest::kAttrib2Size;
-const GLint GLES2DecoderWithShaderTest::kAttrib3Size;
-const GLint GLES2DecoderWithShaderTest::kAttrib1Location;
-const GLint GLES2DecoderWithShaderTest::kAttrib2Location;
-const GLint GLES2DecoderWithShaderTest::kAttrib3Location;
-const GLenum GLES2DecoderWithShaderTest::kAttrib1Type;
-const GLenum GLES2DecoderWithShaderTest::kAttrib2Type;
-const GLenum GLES2DecoderWithShaderTest::kAttrib3Type;
-const GLint GLES2DecoderWithShaderTest::kInvalidAttribLocation;
-const GLint GLES2DecoderWithShaderTest::kBadAttribIndex;
-const GLint GLES2DecoderWithShaderTest::kMaxUniformLength;
-const char* GLES2DecoderWithShaderTest::kUniform1Name = "uniform1";
-const char* GLES2DecoderWithShaderTest::kUniform2Name = "uniform2";
-const char* GLES2DecoderWithShaderTest::kUniform3Name = "uniform3";
-const GLint GLES2DecoderWithShaderTest::kUniform1Size;
-const GLint GLES2DecoderWithShaderTest::kUniform2Size;
-const GLint GLES2DecoderWithShaderTest::kUniform3Size;
-const GLint GLES2DecoderWithShaderTest::kUniform1Location;
-const GLint GLES2DecoderWithShaderTest::kUniform2Location;
-const GLint GLES2DecoderWithShaderTest::kUniform2ElementLocation;
-const GLint GLES2DecoderWithShaderTest::kUniform3Location;
-const GLenum GLES2DecoderWithShaderTest::kUniform1Type;
-const GLenum GLES2DecoderWithShaderTest::kUniform2Type;
-const GLenum GLES2DecoderWithShaderTest::kUniform3Type;
-const GLint GLES2DecoderWithShaderTest::kInvalidUniformLocation;
-const GLint GLES2DecoderWithShaderTest::kBadUniformIndex;
-
-TEST_F(GLES2DecoderWithShaderTest, DrawArraysNoAttributesSucceeds) {
- EXPECT_CALL(*gl_, DrawArrays(GL_TRIANGLES, 0, kNumVertices))
- .Times(1)
- .RetiresOnSaturation();
DrawArrays cmd;
cmd.Init(GL_TRIANGLES, 0, kNumVertices);
EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
@@ -688,6 +95,7 @@ TEST_F(GLES2DecoderWithShaderTest, DrawArraysMissingAttributesFails) {
}
TEST_F(GLES2DecoderWithShaderTest, DrawArraysValidAttributesSucceeds) {
+ SetupTexture();
SetupVertexBuffer();
DoVertexAttribPointer(1, 2, GL_FLOAT, 0, 0);
@@ -713,7 +121,8 @@ TEST_F(GLES2DecoderWithShaderTest, DrawArraysDeletedBufferFails) {
EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
}
-TEST_F(GLES2DecoderWithShaderTest, DrawArraysDeletedProgramFails) {
+TEST_F(GLES2DecoderWithShaderTest,
+ DrawArraysDeletedProgramSucceedsWithoutGLCall) {
SetupVertexBuffer();
DoVertexAttribPointer(1, 2, GL_FLOAT, 0, 0);
DoDeleteProgram(client_program_id_, kServiceProgramId);
@@ -723,7 +132,7 @@ TEST_F(GLES2DecoderWithShaderTest, DrawArraysDeletedProgramFails) {
DrawArrays cmd;
cmd.Init(GL_TRIANGLES, 0, kNumVertices);
EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
- EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
+ EXPECT_EQ(GL_NO_ERROR, GetGLError());
}
TEST_F(GLES2DecoderWithShaderTest, DrawArraysWithInvalidModeFails) {
@@ -781,6 +190,7 @@ TEST_F(GLES2DecoderWithShaderTest, DrawArraysInvalidCountFails) {
}
TEST_F(GLES2DecoderWithShaderTest, DrawElementsNoAttributesSucceeds) {
+ SetupTexture();
SetupIndexBuffer();
EXPECT_CALL(*gl_, DrawElements(GL_TRIANGLES, kValidIndexRangeCount,
GL_UNSIGNED_SHORT,
@@ -808,6 +218,7 @@ TEST_F(GLES2DecoderWithShaderTest, DrawElementsMissingAttributesFails) {
}
TEST_F(GLES2DecoderWithShaderTest, DrawElementsValidAttributesSucceeds) {
+ SetupTexture();
SetupVertexBuffer();
SetupIndexBuffer();
DoVertexAttribPointer(1, 2, GL_FLOAT, 0, 0);
@@ -839,7 +250,7 @@ TEST_F(GLES2DecoderWithShaderTest, DrawElementsDeletedBufferFails) {
EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
}
-TEST_F(GLES2DecoderWithShaderTest, DrawElementsDeleteProgramFails) {
+TEST_F(GLES2DecoderWithShaderTest, DrawElementsDeletedProgramSucceedsNoGLCall) {
SetupVertexBuffer();
SetupIndexBuffer();
DoVertexAttribPointer(1, 2, GL_FLOAT, 0, 0);
@@ -851,7 +262,7 @@ TEST_F(GLES2DecoderWithShaderTest, DrawElementsDeleteProgramFails) {
cmd.Init(GL_TRIANGLES, kValidIndexRangeCount, GL_UNSIGNED_SHORT,
kValidIndexRangeStart);
EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
- EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
+ EXPECT_EQ(GL_NO_ERROR, GetGLError());
}
TEST_F(GLES2DecoderWithShaderTest, DrawElementsWithInvalidModeFails) {
@@ -980,7 +391,8 @@ TEST_F(GLES2DecoderWithShaderTest, GetUniformivSucceeds) {
EXPECT_CALL(*gl_, GetUniformiv(kServiceProgramId, kUniform2Location, _))
.Times(1);
EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
- EXPECT_EQ(GLES2Util::GetGLDataTypeSize(kUniform2Type), result->size);
+ EXPECT_EQ(GLES2Util::GetGLDataTypeSizeForUniforms(kUniform2Type),
+ result->size);
}
TEST_F(GLES2DecoderWithShaderTest, GetUniformivArrayElementSucceeds) {
@@ -994,7 +406,8 @@ TEST_F(GLES2DecoderWithShaderTest, GetUniformivArrayElementSucceeds) {
GetUniformiv(kServiceProgramId, kUniform2ElementLocation, _))
.Times(1);
EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
- EXPECT_EQ(GLES2Util::GetGLDataTypeSize(kUniform2Type), result->size);
+ EXPECT_EQ(GLES2Util::GetGLDataTypeSizeForUniforms(kUniform2Type),
+ result->size);
}
TEST_F(GLES2DecoderWithShaderTest, GetUniformivBadProgramFails) {
@@ -1071,7 +484,8 @@ TEST_F(GLES2DecoderWithShaderTest, GetUniformfvSucceeds) {
EXPECT_CALL(*gl_, GetUniformfv(kServiceProgramId, kUniform2Location, _))
.Times(1);
EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
- EXPECT_EQ(GLES2Util::GetGLDataTypeSize(kUniform2Type), result->size);
+ EXPECT_EQ(GLES2Util::GetGLDataTypeSizeForUniforms(kUniform2Type),
+ result->size);
}
TEST_F(GLES2DecoderWithShaderTest, GetUniformfvArrayElementSucceeds) {
@@ -1085,7 +499,8 @@ TEST_F(GLES2DecoderWithShaderTest, GetUniformfvArrayElementSucceeds) {
GetUniformfv(kServiceProgramId, kUniform2ElementLocation, _))
.Times(1);
EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
- EXPECT_EQ(GLES2Util::GetGLDataTypeSize(kUniform2Type), result->size);
+ EXPECT_EQ(GLES2Util::GetGLDataTypeSizeForUniforms(kUniform2Type),
+ result->size);
}
TEST_F(GLES2DecoderWithShaderTest, GetUniformfvBadProgramFails) {
@@ -1526,6 +941,55 @@ TEST_F(GLES2DecoderTest, GenerateMipmapWrongFormatsFails) {
EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
}
+TEST_F(GLES2DecoderWithShaderTest, Uniform1iValidArgs) {
+ EXPECT_CALL(*gl_, Uniform1i(kUniform1Location, 2));
+ SpecializedSetup<Uniform1i, 0>();
+ Uniform1i cmd;
+ cmd.Init(kUniform1Location, 2);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderWithShaderTest, Uniform1ivValidArgs) {
+ EXPECT_CALL(
+ *gl_, Uniform1iv(
+ kUniform1Location, 2,
+ reinterpret_cast<const GLint*>(shared_memory_address_)));
+ SpecializedSetup<Uniform1iv, 0>();
+ Uniform1iv cmd;
+ cmd.Init(kUniform1Location, 2, shared_memory_id_, shared_memory_offset_);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderWithShaderTest, Uniform1ivInvalidArgs2_0) {
+ EXPECT_CALL(*gl_, Uniform1iv(_, _, _)).Times(0);
+ SpecializedSetup<Uniform1iv, 0>();
+ Uniform1iv cmd;
+ cmd.Init(kUniform1Location, 2, kInvalidSharedMemoryId, 0);
+ EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderWithShaderTest, Uniform1ivInvalidArgs2_1) {
+ EXPECT_CALL(*gl_, Uniform1iv(_, _, _)).Times(0);
+ SpecializedSetup<Uniform1iv, 0>();
+ Uniform1iv cmd;
+ cmd.Init(kUniform1Location, 2, shared_memory_id_, kInvalidSharedMemoryOffset);
+ EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderWithShaderTest, Uniform1ivImmediateValidArgs) {
+ Uniform1ivImmediate& cmd = *GetImmediateAs<Uniform1ivImmediate>();
+ EXPECT_CALL(
+ *gl_,
+ Uniform1iv(kUniform1Location, 2,
+ reinterpret_cast<GLint*>(ImmediateDataAddress(&cmd))));
+ SpecializedSetup<Uniform1ivImmediate, 0>();
+ GLint temp[1 * 2] = { 0, };
+ cmd.Init(kUniform1Location, 2, &temp[0]);
+ EXPECT_EQ(error::kNoError,
+ ExecuteImmediateCmd(cmd, sizeof(temp)));
+}
+
+
// TODO(gman): BindAttribLocation
// TODO(gman): BindAttribLocationImmediate
@@ -1576,8 +1040,6 @@ TEST_F(GLES2DecoderTest, GenerateMipmapWrongFormatsFails) {
// TODO(gman): VertexAttribPointer
-#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_1.cc b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_1.cc
new file mode 100644
index 0000000..05f9b8a
--- /dev/null
+++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_1.cc
@@ -0,0 +1,47 @@
+// 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.
+
+#include "gpu/command_buffer/service/gles2_cmd_decoder.h"
+
+#include "gpu/command_buffer/common/gles2_cmd_format.h"
+#include "gpu/command_buffer/common/gles2_cmd_utils.h"
+#include "gpu/command_buffer/service/gl_mock.h"
+#include "gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.h"
+#include "gpu/command_buffer/service/cmd_buffer_engine.h"
+#include "gpu/command_buffer/service/context_group.h"
+#include "gpu/command_buffer/service/program_manager.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+using ::gles2::MockGLInterface;
+using ::testing::_;
+using ::testing::DoAll;
+using ::testing::InSequence;
+using ::testing::MatcherCast;
+using ::testing::Pointee;
+using ::testing::Return;
+using ::testing::SetArrayArgument;
+using ::testing::SetArgumentPointee;
+using ::testing::StrEq;
+
+namespace gpu {
+namespace gles2 {
+
+class GLES2DecoderTest1 : public GLES2DecoderTestBase {
+ public:
+ GLES2DecoderTest1() { }
+};
+
+template <>
+void GLES2DecoderTestBase::SpecializedSetup<GenerateMipmap, 0>() {
+ DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId);
+ DoTexImage2D(
+ GL_TEXTURE_2D, 0, GL_RGBA, 16, 16, 0, GL_RGBA, GL_UNSIGNED_BYTE,
+ 0, 0);
+};
+
+#include "gpu/command_buffer/service/gles2_cmd_decoder_unittest_1_autogen.h"
+
+} // namespace gles2
+} // namespace gpu
+
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_1_autogen.h b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_1_autogen.h
new file mode 100644
index 0000000..bfbbd25
--- /dev/null
+++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_1_autogen.h
@@ -0,0 +1,1241 @@
+// 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_1.cc
+#ifndef GPU_COMMAND_BUFFER_SERVICE_GLES2_CMD_DECODER_UNITTEST_1_AUTOGEN_H_
+#define GPU_COMMAND_BUFFER_SERVICE_GLES2_CMD_DECODER_UNITTEST_1_AUTOGEN_H_
+
+
+TEST_F(GLES2DecoderTest1, ActiveTextureValidArgs) {
+ EXPECT_CALL(*gl_, ActiveTexture(1));
+ SpecializedSetup<ActiveTexture, 0>();
+ ActiveTexture cmd;
+ cmd.Init(1);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest1, AttachShaderValidArgs) {
+ EXPECT_CALL(*gl_, AttachShader(kServiceProgramId, kServiceShaderId));
+ SpecializedSetup<AttachShader, 0>();
+ AttachShader cmd;
+ cmd.Init(client_program_id_, client_shader_id_);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+}
+// TODO(gman): BindAttribLocation
+
+// TODO(gman): BindAttribLocationImmediate
+
+
+TEST_F(GLES2DecoderTest1, BindBufferValidArgs) {
+ EXPECT_CALL(*gl_, BindBuffer(GL_ARRAY_BUFFER, kServiceBufferId));
+ SpecializedSetup<BindBuffer, 0>();
+ BindBuffer cmd;
+ cmd.Init(GL_ARRAY_BUFFER, client_buffer_id_);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest1, BindBufferInvalidArgs0_0) {
+ EXPECT_CALL(*gl_, BindBuffer(_, _)).Times(0);
+ SpecializedSetup<BindBuffer, 0>();
+ BindBuffer cmd;
+ cmd.Init(GL_RENDERBUFFER, client_buffer_id_);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest1, BindFramebufferValidArgs) {
+ EXPECT_CALL(*gl_, BindFramebufferEXT(GL_FRAMEBUFFER, kServiceFramebufferId));
+ SpecializedSetup<BindFramebuffer, 0>();
+ BindFramebuffer cmd;
+ cmd.Init(GL_FRAMEBUFFER, client_framebuffer_id_);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest1, BindRenderbufferValidArgs) {
+ EXPECT_CALL(
+ *gl_, BindRenderbufferEXT(GL_RENDERBUFFER, kServiceRenderbufferId));
+ SpecializedSetup<BindRenderbuffer, 0>();
+ BindRenderbuffer cmd;
+ cmd.Init(GL_RENDERBUFFER, client_renderbuffer_id_);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest1, BindTextureValidArgs) {
+ EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_2D, kServiceTextureId));
+ SpecializedSetup<BindTexture, 0>();
+ BindTexture cmd;
+ cmd.Init(GL_TEXTURE_2D, client_texture_id_);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest1, BindTextureInvalidArgs0_0) {
+ EXPECT_CALL(*gl_, BindTexture(_, _)).Times(0);
+ SpecializedSetup<BindTexture, 0>();
+ BindTexture cmd;
+ cmd.Init(GL_TEXTURE_1D, client_texture_id_);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest1, BindTextureInvalidArgs0_1) {
+ EXPECT_CALL(*gl_, BindTexture(_, _)).Times(0);
+ SpecializedSetup<BindTexture, 0>();
+ BindTexture cmd;
+ cmd.Init(GL_TEXTURE_3D, client_texture_id_);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest1, BlendColorValidArgs) {
+ EXPECT_CALL(*gl_, BlendColor(1, 2, 3, 4));
+ SpecializedSetup<BlendColor, 0>();
+ BlendColor cmd;
+ cmd.Init(1, 2, 3, 4);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest1, BlendEquationValidArgs) {
+ EXPECT_CALL(*gl_, BlendEquation(GL_FUNC_ADD));
+ SpecializedSetup<BlendEquation, 0>();
+ BlendEquation cmd;
+ cmd.Init(GL_FUNC_ADD);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest1, BlendEquationInvalidArgs0_0) {
+ EXPECT_CALL(*gl_, BlendEquation(_)).Times(0);
+ SpecializedSetup<BlendEquation, 0>();
+ BlendEquation cmd;
+ cmd.Init(GL_MIN);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest1, BlendEquationInvalidArgs0_1) {
+ EXPECT_CALL(*gl_, BlendEquation(_)).Times(0);
+ SpecializedSetup<BlendEquation, 0>();
+ BlendEquation cmd;
+ cmd.Init(GL_MAX);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest1, 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(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest1, BlendEquationSeparateInvalidArgs0_0) {
+ EXPECT_CALL(*gl_, BlendEquationSeparate(_, _)).Times(0);
+ SpecializedSetup<BlendEquationSeparate, 0>();
+ BlendEquationSeparate cmd;
+ cmd.Init(GL_MIN, GL_FUNC_ADD);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest1, BlendEquationSeparateInvalidArgs0_1) {
+ EXPECT_CALL(*gl_, BlendEquationSeparate(_, _)).Times(0);
+ SpecializedSetup<BlendEquationSeparate, 0>();
+ BlendEquationSeparate cmd;
+ cmd.Init(GL_MAX, GL_FUNC_ADD);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest1, BlendEquationSeparateInvalidArgs1_0) {
+ EXPECT_CALL(*gl_, BlendEquationSeparate(_, _)).Times(0);
+ SpecializedSetup<BlendEquationSeparate, 0>();
+ BlendEquationSeparate cmd;
+ cmd.Init(GL_FUNC_ADD, GL_MIN);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest1, BlendEquationSeparateInvalidArgs1_1) {
+ EXPECT_CALL(*gl_, BlendEquationSeparate(_, _)).Times(0);
+ SpecializedSetup<BlendEquationSeparate, 0>();
+ BlendEquationSeparate cmd;
+ cmd.Init(GL_FUNC_ADD, GL_MAX);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest1, BlendFuncValidArgs) {
+ EXPECT_CALL(*gl_, BlendFunc(GL_ZERO, GL_ZERO));
+ SpecializedSetup<BlendFunc, 0>();
+ BlendFunc cmd;
+ cmd.Init(GL_ZERO, GL_ZERO);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest1, 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(error::kNoError, ExecuteCmd(cmd));
+}
+// TODO(gman): BufferData
+
+// TODO(gman): BufferDataImmediate
+
+// TODO(gman): BufferSubData
+
+// TODO(gman): BufferSubDataImmediate
+
+
+TEST_F(GLES2DecoderTest1, CheckFramebufferStatusValidArgs) {
+ EXPECT_CALL(*gl_, CheckFramebufferStatusEXT(GL_FRAMEBUFFER));
+ SpecializedSetup<CheckFramebufferStatus, 0>();
+ CheckFramebufferStatus cmd;
+ cmd.Init(GL_FRAMEBUFFER);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest1, ClearValidArgs) {
+ EXPECT_CALL(*gl_, Clear(1));
+ SpecializedSetup<Clear, 0>();
+ Clear cmd;
+ cmd.Init(1);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest1, ClearColorValidArgs) {
+ EXPECT_CALL(*gl_, ClearColor(1, 2, 3, 4));
+ SpecializedSetup<ClearColor, 0>();
+ ClearColor cmd;
+ cmd.Init(1, 2, 3, 4);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest1, ClearDepthfValidArgs) {
+ EXPECT_CALL(*gl_, ClearDepth(1));
+ SpecializedSetup<ClearDepthf, 0>();
+ ClearDepthf cmd;
+ cmd.Init(1);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest1, ClearStencilValidArgs) {
+ EXPECT_CALL(*gl_, ClearStencil(1));
+ SpecializedSetup<ClearStencil, 0>();
+ ClearStencil cmd;
+ cmd.Init(1);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest1, ColorMaskValidArgs) {
+ EXPECT_CALL(*gl_, ColorMask(1, 2, 3, 4));
+ SpecializedSetup<ColorMask, 0>();
+ ColorMask cmd;
+ cmd.Init(1, 2, 3, 4);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+}
+// TODO(gman): CompileShader
+// TODO(gman): CompressedTexImage2D
+
+// TODO(gman): CompressedTexImage2DImmediate
+
+// TODO(gman): CompressedTexSubImage2D
+
+// TODO(gman): CompressedTexSubImage2DImmediate
+
+
+TEST_F(GLES2DecoderTest1, 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(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest1, 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(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest1, 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(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest1, 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(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest1, CreateProgramValidArgs) {
+ EXPECT_CALL(*gl_, CreateProgram())
+ .WillOnce(Return(kNewServiceId));
+ SpecializedSetup<CreateProgram, 0>();
+ CreateProgram cmd;
+ cmd.Init(kNewClientId);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+ EXPECT_EQ(GetServiceId(kNewClientId), kNewServiceId);
+}
+
+TEST_F(GLES2DecoderTest1, CreateShaderValidArgs) {
+ EXPECT_CALL(*gl_, CreateShader(GL_VERTEX_SHADER))
+ .WillOnce(Return(kNewServiceId));
+ SpecializedSetup<CreateShader, 0>();
+ CreateShader cmd;
+ cmd.Init(GL_VERTEX_SHADER, kNewClientId);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+ EXPECT_EQ(GetServiceId(kNewClientId), kNewServiceId);
+}
+
+TEST_F(GLES2DecoderTest1, CullFaceValidArgs) {
+ EXPECT_CALL(*gl_, CullFace(GL_FRONT));
+ SpecializedSetup<CullFace, 0>();
+ CullFace cmd;
+ cmd.Init(GL_FRONT);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest1, 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(error::kNoError, ExecuteCmd(cmd));
+ EXPECT_EQ(GetServiceId(kNewClientId), 0u);
+}
+
+TEST_F(GLES2DecoderTest1, 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(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest1, 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(error::kNoError,
+ ExecuteImmediateCmd(cmd, sizeof(client_buffer_id_)));
+ EXPECT_EQ(GetServiceId(kNewClientId), 0u);
+}
+
+TEST_F(GLES2DecoderTest1, 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(error::kNoError,
+ ExecuteImmediateCmd(cmd, sizeof(temp)));
+}
+
+TEST_F(GLES2DecoderTest1, 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(error::kNoError, ExecuteCmd(cmd));
+ EXPECT_EQ(GetServiceId(kNewClientId), 0u);
+}
+
+TEST_F(GLES2DecoderTest1, 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(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest1, 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(error::kNoError,
+ ExecuteImmediateCmd(cmd, sizeof(client_framebuffer_id_)));
+ EXPECT_EQ(GetServiceId(kNewClientId), 0u);
+}
+
+TEST_F(GLES2DecoderTest1, 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(error::kNoError,
+ ExecuteImmediateCmd(cmd, sizeof(temp)));
+}
+// TODO(gman): DeleteProgram
+
+
+TEST_F(GLES2DecoderTest1, 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(error::kNoError, ExecuteCmd(cmd));
+ EXPECT_EQ(GetServiceId(kNewClientId), 0u);
+}
+
+TEST_F(GLES2DecoderTest1, 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(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest1, 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(error::kNoError,
+ ExecuteImmediateCmd(cmd, sizeof(client_renderbuffer_id_)));
+ EXPECT_EQ(GetServiceId(kNewClientId), 0u);
+}
+
+TEST_F(GLES2DecoderTest1, 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(error::kNoError,
+ ExecuteImmediateCmd(cmd, sizeof(temp)));
+}
+// TODO(gman): DeleteShader
+
+
+TEST_F(GLES2DecoderTest1, 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(error::kNoError, ExecuteCmd(cmd));
+ EXPECT_EQ(GetServiceId(kNewClientId), 0u);
+}
+
+TEST_F(GLES2DecoderTest1, 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(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest1, 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(error::kNoError,
+ ExecuteImmediateCmd(cmd, sizeof(client_texture_id_)));
+ EXPECT_EQ(GetServiceId(kNewClientId), 0u);
+}
+
+TEST_F(GLES2DecoderTest1, 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(error::kNoError,
+ ExecuteImmediateCmd(cmd, sizeof(temp)));
+}
+
+TEST_F(GLES2DecoderTest1, DepthFuncValidArgs) {
+ EXPECT_CALL(*gl_, DepthFunc(GL_NEVER));
+ SpecializedSetup<DepthFunc, 0>();
+ DepthFunc cmd;
+ cmd.Init(GL_NEVER);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest1, DepthMaskValidArgs) {
+ EXPECT_CALL(*gl_, DepthMask(1));
+ SpecializedSetup<DepthMask, 0>();
+ DepthMask cmd;
+ cmd.Init(1);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest1, DepthRangefValidArgs) {
+ EXPECT_CALL(*gl_, DepthRange(1, 2));
+ SpecializedSetup<DepthRangef, 0>();
+ DepthRangef cmd;
+ cmd.Init(1, 2);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest1, DetachShaderValidArgs) {
+ EXPECT_CALL(*gl_, DetachShader(kServiceProgramId, kServiceShaderId));
+ SpecializedSetup<DetachShader, 0>();
+ DetachShader cmd;
+ cmd.Init(client_program_id_, client_shader_id_);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest1, DisableValidArgs) {
+ EXPECT_CALL(*gl_, Disable(GL_BLEND));
+ SpecializedSetup<Disable, 0>();
+ Disable cmd;
+ cmd.Init(GL_BLEND);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest1, DisableInvalidArgs0_0) {
+ EXPECT_CALL(*gl_, Disable(_)).Times(0);
+ SpecializedSetup<Disable, 0>();
+ Disable cmd;
+ cmd.Init(GL_CLIP_PLANE0);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest1, DisableInvalidArgs0_1) {
+ EXPECT_CALL(*gl_, Disable(_)).Times(0);
+ SpecializedSetup<Disable, 0>();
+ Disable cmd;
+ cmd.Init(GL_POINT_SPRITE);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest1, DisableVertexAttribArrayValidArgs) {
+ EXPECT_CALL(*gl_, DisableVertexAttribArray(1));
+ SpecializedSetup<DisableVertexAttribArray, 0>();
+ DisableVertexAttribArray cmd;
+ cmd.Init(1);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+}
+// TODO(gman): DrawArrays
+// TODO(gman): DrawElements
+
+
+TEST_F(GLES2DecoderTest1, EnableValidArgs) {
+ EXPECT_CALL(*gl_, Enable(GL_BLEND));
+ SpecializedSetup<Enable, 0>();
+ Enable cmd;
+ cmd.Init(GL_BLEND);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest1, EnableInvalidArgs0_0) {
+ EXPECT_CALL(*gl_, Enable(_)).Times(0);
+ SpecializedSetup<Enable, 0>();
+ Enable cmd;
+ cmd.Init(GL_CLIP_PLANE0);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest1, EnableInvalidArgs0_1) {
+ EXPECT_CALL(*gl_, Enable(_)).Times(0);
+ SpecializedSetup<Enable, 0>();
+ Enable cmd;
+ cmd.Init(GL_POINT_SPRITE);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest1, EnableVertexAttribArrayValidArgs) {
+ EXPECT_CALL(*gl_, EnableVertexAttribArray(1));
+ SpecializedSetup<EnableVertexAttribArray, 0>();
+ EnableVertexAttribArray cmd;
+ cmd.Init(1);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest1, FinishValidArgs) {
+ EXPECT_CALL(*gl_, Finish());
+ SpecializedSetup<Finish, 0>();
+ Finish cmd;
+ cmd.Init();
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest1, FlushValidArgs) {
+ EXPECT_CALL(*gl_, Flush());
+ SpecializedSetup<Flush, 0>();
+ Flush cmd;
+ cmd.Init();
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest1, 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(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest1, 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(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest1, 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(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest1, FrontFaceValidArgs) {
+ EXPECT_CALL(*gl_, FrontFace(GL_CW));
+ SpecializedSetup<FrontFace, 0>();
+ FrontFace cmd;
+ cmd.Init(GL_CW);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest1, 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(error::kNoError, ExecuteCmd(cmd));
+ EXPECT_EQ(GetServiceId(kNewClientId), kNewServiceId);
+}
+
+TEST_F(GLES2DecoderTest1, 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(error::kInvalidArguments, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest1, 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(error::kNoError,
+ ExecuteImmediateCmd(cmd, sizeof(temp)));
+ EXPECT_EQ(GetServiceId(kNewClientId), kNewServiceId);
+}
+
+TEST_F(GLES2DecoderTest1, GenBuffersImmediateInvalidArgs) {
+ EXPECT_CALL(*gl_, GenBuffersARB(_, _)).Times(0);
+ GenBuffersImmediate& cmd = *GetImmediateAs<GenBuffersImmediate>();
+ SpecializedSetup<GenBuffersImmediate, 0>();
+ cmd.Init(1, &client_buffer_id_);
+ EXPECT_EQ(error::kInvalidArguments,
+ ExecuteImmediateCmd(cmd, sizeof(&client_buffer_id_)));
+}
+
+TEST_F(GLES2DecoderTest1, GenerateMipmapValidArgs) {
+ EXPECT_CALL(*gl_, GenerateMipmapEXT(GL_TEXTURE_2D));
+ SpecializedSetup<GenerateMipmap, 0>();
+ GenerateMipmap cmd;
+ cmd.Init(GL_TEXTURE_2D);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest1, GenerateMipmapInvalidArgs0_0) {
+ EXPECT_CALL(*gl_, GenerateMipmapEXT(_)).Times(0);
+ SpecializedSetup<GenerateMipmap, 0>();
+ GenerateMipmap cmd;
+ cmd.Init(GL_TEXTURE_1D);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest1, GenerateMipmapInvalidArgs0_1) {
+ EXPECT_CALL(*gl_, GenerateMipmapEXT(_)).Times(0);
+ SpecializedSetup<GenerateMipmap, 0>();
+ GenerateMipmap cmd;
+ cmd.Init(GL_TEXTURE_3D);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest1, 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(error::kNoError, ExecuteCmd(cmd));
+ EXPECT_EQ(GetServiceId(kNewClientId), kNewServiceId);
+}
+
+TEST_F(GLES2DecoderTest1, 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(error::kInvalidArguments, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest1, 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(error::kNoError,
+ ExecuteImmediateCmd(cmd, sizeof(temp)));
+ EXPECT_EQ(GetServiceId(kNewClientId), kNewServiceId);
+}
+
+TEST_F(GLES2DecoderTest1, GenFramebuffersImmediateInvalidArgs) {
+ EXPECT_CALL(*gl_, GenFramebuffersEXT(_, _)).Times(0);
+ GenFramebuffersImmediate& cmd = *GetImmediateAs<GenFramebuffersImmediate>();
+ SpecializedSetup<GenFramebuffersImmediate, 0>();
+ cmd.Init(1, &client_framebuffer_id_);
+ EXPECT_EQ(error::kInvalidArguments,
+ ExecuteImmediateCmd(cmd, sizeof(&client_framebuffer_id_)));
+}
+
+TEST_F(GLES2DecoderTest1, 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(error::kNoError, ExecuteCmd(cmd));
+ EXPECT_EQ(GetServiceId(kNewClientId), kNewServiceId);
+}
+
+TEST_F(GLES2DecoderTest1, 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(error::kInvalidArguments, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest1, 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(error::kNoError,
+ ExecuteImmediateCmd(cmd, sizeof(temp)));
+ EXPECT_EQ(GetServiceId(kNewClientId), kNewServiceId);
+}
+
+TEST_F(GLES2DecoderTest1, GenRenderbuffersImmediateInvalidArgs) {
+ EXPECT_CALL(*gl_, GenRenderbuffersEXT(_, _)).Times(0);
+ GenRenderbuffersImmediate& cmd =
+ *GetImmediateAs<GenRenderbuffersImmediate>();
+ SpecializedSetup<GenRenderbuffersImmediate, 0>();
+ cmd.Init(1, &client_renderbuffer_id_);
+ EXPECT_EQ(error::kInvalidArguments,
+ ExecuteImmediateCmd(cmd, sizeof(&client_renderbuffer_id_)));
+}
+
+TEST_F(GLES2DecoderTest1, 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(error::kNoError, ExecuteCmd(cmd));
+ EXPECT_EQ(GetServiceId(kNewClientId), kNewServiceId);
+}
+
+TEST_F(GLES2DecoderTest1, 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(error::kInvalidArguments, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest1, 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(error::kNoError,
+ ExecuteImmediateCmd(cmd, sizeof(temp)));
+ EXPECT_EQ(GetServiceId(kNewClientId), kNewServiceId);
+}
+
+TEST_F(GLES2DecoderTest1, GenTexturesImmediateInvalidArgs) {
+ EXPECT_CALL(*gl_, GenTextures(_, _)).Times(0);
+ GenTexturesImmediate& cmd = *GetImmediateAs<GenTexturesImmediate>();
+ SpecializedSetup<GenTexturesImmediate, 0>();
+ cmd.Init(1, &client_texture_id_);
+ EXPECT_EQ(error::kInvalidArguments,
+ ExecuteImmediateCmd(cmd, sizeof(&client_texture_id_)));
+}
+// TODO(gman): GetActiveAttrib
+
+// TODO(gman): GetActiveUniform
+
+// TODO(gman): GetAttachedShaders
+
+// TODO(gman): GetAttribLocation
+
+// TODO(gman): GetAttribLocationImmediate
+
+
+TEST_F(GLES2DecoderTest1, 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(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest1, GetBooleanvInvalidArgs1_0) {
+ EXPECT_CALL(*gl_, GetBooleanv(_, _)).Times(0);
+ SpecializedSetup<GetBooleanv, 0>();
+ GetBooleanv cmd;
+ cmd.Init(1, kInvalidSharedMemoryId, 0);
+ EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest1, GetBooleanvInvalidArgs1_1) {
+ EXPECT_CALL(*gl_, GetBooleanv(_, _)).Times(0);
+ SpecializedSetup<GetBooleanv, 0>();
+ GetBooleanv cmd;
+ cmd.Init(1, shared_memory_id_, kInvalidSharedMemoryOffset);
+ EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest1, 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(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest1, 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(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest1, 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(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest1, 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(error::kOutOfBounds, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest1, 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(error::kOutOfBounds, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest1, GetErrorValidArgs) {
+ EXPECT_CALL(*gl_, GetError());
+ SpecializedSetup<GetError, 0>();
+ GetError cmd;
+ cmd.Init(shared_memory_id_, shared_memory_offset_);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest1, 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(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest1, GetFloatvInvalidArgs1_0) {
+ EXPECT_CALL(*gl_, GetFloatv(_, _)).Times(0);
+ SpecializedSetup<GetFloatv, 0>();
+ GetFloatv cmd;
+ cmd.Init(1, kInvalidSharedMemoryId, 0);
+ EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest1, GetFloatvInvalidArgs1_1) {
+ EXPECT_CALL(*gl_, GetFloatv(_, _)).Times(0);
+ SpecializedSetup<GetFloatv, 0>();
+ GetFloatv cmd;
+ cmd.Init(1, shared_memory_id_, kInvalidSharedMemoryOffset);
+ EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest1, 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(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest1, 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(error::kOutOfBounds, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest1, 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(error::kOutOfBounds, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest1, 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(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest1, GetIntegervInvalidArgs1_0) {
+ EXPECT_CALL(*gl_, GetIntegerv(_, _)).Times(0);
+ SpecializedSetup<GetIntegerv, 0>();
+ GetIntegerv cmd;
+ cmd.Init(1, kInvalidSharedMemoryId, 0);
+ EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest1, GetIntegervInvalidArgs1_1) {
+ EXPECT_CALL(*gl_, GetIntegerv(_, _)).Times(0);
+ SpecializedSetup<GetIntegerv, 0>();
+ GetIntegerv cmd;
+ cmd.Init(1, shared_memory_id_, kInvalidSharedMemoryOffset);
+ EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest1, 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(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest1, 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(error::kOutOfBounds, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest1, 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(error::kOutOfBounds, ExecuteCmd(cmd));
+}
+// TODO(gman): GetProgramInfoLog
+
+
+TEST_F(GLES2DecoderTest1, 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(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest1, GetRenderbufferParameterivInvalidArgs2_0) {
+ EXPECT_CALL(*gl_, GetRenderbufferParameterivEXT(_, _, _)).Times(0);
+ SpecializedSetup<GetRenderbufferParameteriv, 0>();
+ GetRenderbufferParameteriv cmd;
+ cmd.Init(GL_RENDERBUFFER, GL_RENDERBUFFER_WIDTH, kInvalidSharedMemoryId, 0);
+ EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest1, 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(error::kOutOfBounds, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest1, 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(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest1, 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(error::kOutOfBounds, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest1, 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(error::kOutOfBounds, ExecuteCmd(cmd));
+}
+// TODO(gman): GetShaderInfoLog
+
+// TODO(gman): GetShaderPrecisionFormat
+
+// TODO(gman): GetShaderSource
+
+
+TEST_F(GLES2DecoderTest1, GetStringValidArgs) {
+ EXPECT_CALL(*gl_, GetString(GL_VENDOR));
+ SpecializedSetup<GetString, 0>();
+ GetString cmd;
+ cmd.Init(GL_VENDOR);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest1, 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(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest1, 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(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest1, 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(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest1, 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(error::kOutOfBounds, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest1, 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(error::kOutOfBounds, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest1, 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(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest1, 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(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest1, 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(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest1, 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(error::kOutOfBounds, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest1, 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(error::kOutOfBounds, ExecuteCmd(cmd));
+}
+#endif // GPU_COMMAND_BUFFER_SERVICE_GLES2_CMD_DECODER_UNITTEST_1_AUTOGEN_H_
+
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_2.cc b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_2.cc
new file mode 100644
index 0000000..89cada4
--- /dev/null
+++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_2.cc
@@ -0,0 +1,90 @@
+// 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.
+
+#include "gpu/command_buffer/service/gles2_cmd_decoder.h"
+
+#include "gpu/command_buffer/common/gles2_cmd_format.h"
+#include "gpu/command_buffer/common/gles2_cmd_utils.h"
+#include "gpu/command_buffer/service/gl_mock.h"
+#include "gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.h"
+#include "gpu/command_buffer/service/cmd_buffer_engine.h"
+#include "gpu/command_buffer/service/context_group.h"
+#include "gpu/command_buffer/service/program_manager.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+using ::gles2::MockGLInterface;
+using ::testing::_;
+using ::testing::DoAll;
+using ::testing::InSequence;
+using ::testing::MatcherCast;
+using ::testing::Pointee;
+using ::testing::Return;
+using ::testing::SetArrayArgument;
+using ::testing::SetArgumentPointee;
+using ::testing::StrEq;
+
+namespace gpu {
+namespace gles2 {
+
+class GLES2DecoderTest2 : public GLES2DecoderTestBase {
+ public:
+ GLES2DecoderTest2() { }
+};
+
+template <>
+void GLES2DecoderTestBase::SpecializedSetup<LinkProgram, 0>() {
+ EXPECT_CALL(*gl_, GetError())
+ .WillOnce(Return(GL_NO_ERROR))
+ .WillOnce(Return(GL_NO_ERROR))
+ .RetiresOnSaturation();
+ 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));
+ EXPECT_CALL(*gl_, GetProgramiv(kServiceProgramId, GL_ACTIVE_UNIFORMS, _))
+ .WillOnce(SetArgumentPointee<2>(0));
+ EXPECT_CALL(
+ *gl_,
+ GetProgramiv(kServiceProgramId, GL_ACTIVE_UNIFORM_MAX_LENGTH, _))
+ .WillOnce(SetArgumentPointee<2>(0));
+};
+
+template <>
+void GLES2DecoderTestBase::SpecializedSetup<TexParameterf, 0>() {
+ DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId);
+};
+
+template <>
+void GLES2DecoderTestBase::SpecializedSetup<TexParameteri, 0>() {
+ DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId);
+};
+
+template <>
+void GLES2DecoderTestBase::SpecializedSetup<TexParameterfv, 0>() {
+ DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId);
+};
+
+template <>
+void GLES2DecoderTestBase::SpecializedSetup<TexParameterfvImmediate, 0>() {
+ DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId);
+};
+
+template <>
+void GLES2DecoderTestBase::SpecializedSetup<TexParameteriv, 0>() {
+ DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId);
+};
+
+template <>
+void GLES2DecoderTestBase::SpecializedSetup<TexParameterivImmediate, 0>() {
+ DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId);
+};
+
+#include "gpu/command_buffer/service/gles2_cmd_decoder_unittest_2_autogen.h"
+
+} // namespace gles2
+} // namespace gpu
+
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_2_autogen.h b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_2_autogen.h
new file mode 100644
index 0000000..e9215e7
--- /dev/null
+++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_2_autogen.h
@@ -0,0 +1,1278 @@
+// 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_2.cc
+#ifndef GPU_COMMAND_BUFFER_SERVICE_GLES2_CMD_DECODER_UNITTEST_2_AUTOGEN_H_
+#define GPU_COMMAND_BUFFER_SERVICE_GLES2_CMD_DECODER_UNITTEST_2_AUTOGEN_H_
+
+// TODO(gman): GetUniformfv
+
+// TODO(gman): GetUniformiv
+
+// TODO(gman): GetUniformLocation
+
+// TODO(gman): GetUniformLocationImmediate
+
+
+TEST_F(GLES2DecoderTest2, 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(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest2, 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(error::kOutOfBounds, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest2, 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(error::kOutOfBounds, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest2, 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(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest2, 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(error::kOutOfBounds, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest2, 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(error::kOutOfBounds, ExecuteCmd(cmd));
+}
+// TODO(gman): GetVertexAttribPointerv
+
+
+TEST_F(GLES2DecoderTest2, 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(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest2, HintInvalidArgs0_0) {
+ EXPECT_CALL(*gl_, Hint(_, _)).Times(0);
+ SpecializedSetup<Hint, 0>();
+ Hint cmd;
+ cmd.Init(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest2, IsBufferValidArgs) {
+ EXPECT_CALL(*gl_, IsBuffer(kServiceBufferId));
+ SpecializedSetup<IsBuffer, 0>();
+ IsBuffer cmd;
+ cmd.Init(client_buffer_id_, shared_memory_id_, shared_memory_offset_);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest2, IsEnabledValidArgs) {
+ EXPECT_CALL(*gl_, IsEnabled(GL_BLEND));
+ SpecializedSetup<IsEnabled, 0>();
+ IsEnabled cmd;
+ cmd.Init(GL_BLEND, shared_memory_id_, shared_memory_offset_);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest2, 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(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest2, 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(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest2, IsFramebufferValidArgs) {
+ EXPECT_CALL(*gl_, IsFramebufferEXT(kServiceFramebufferId));
+ SpecializedSetup<IsFramebuffer, 0>();
+ IsFramebuffer cmd;
+ cmd.Init(client_framebuffer_id_, shared_memory_id_, shared_memory_offset_);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest2, IsProgramValidArgs) {
+ EXPECT_CALL(*gl_, IsProgram(kServiceProgramId));
+ SpecializedSetup<IsProgram, 0>();
+ IsProgram cmd;
+ cmd.Init(client_program_id_, shared_memory_id_, shared_memory_offset_);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest2, IsRenderbufferValidArgs) {
+ EXPECT_CALL(*gl_, IsRenderbufferEXT(kServiceRenderbufferId));
+ SpecializedSetup<IsRenderbuffer, 0>();
+ IsRenderbuffer cmd;
+ cmd.Init(client_renderbuffer_id_, shared_memory_id_, shared_memory_offset_);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest2, IsShaderValidArgs) {
+ EXPECT_CALL(*gl_, IsShader(kServiceShaderId));
+ SpecializedSetup<IsShader, 0>();
+ IsShader cmd;
+ cmd.Init(client_shader_id_, shared_memory_id_, shared_memory_offset_);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest2, IsTextureValidArgs) {
+ EXPECT_CALL(*gl_, IsTexture(kServiceTextureId));
+ SpecializedSetup<IsTexture, 0>();
+ IsTexture cmd;
+ cmd.Init(client_texture_id_, shared_memory_id_, shared_memory_offset_);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest2, LineWidthValidArgs) {
+ EXPECT_CALL(*gl_, LineWidth(1));
+ SpecializedSetup<LineWidth, 0>();
+ LineWidth cmd;
+ cmd.Init(1);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest2, LinkProgramValidArgs) {
+ EXPECT_CALL(*gl_, LinkProgram(kServiceProgramId));
+ SpecializedSetup<LinkProgram, 0>();
+ LinkProgram cmd;
+ cmd.Init(client_program_id_);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+}
+// TODO(gman): PixelStorei
+
+
+TEST_F(GLES2DecoderTest2, PolygonOffsetValidArgs) {
+ EXPECT_CALL(*gl_, PolygonOffset(1, 2));
+ SpecializedSetup<PolygonOffset, 0>();
+ PolygonOffset cmd;
+ cmd.Init(1, 2);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+}
+// TODO(gman): ReadPixels
+
+
+TEST_F(GLES2DecoderTest2, 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(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest2, SampleCoverageValidArgs) {
+ EXPECT_CALL(*gl_, SampleCoverage(1, 2));
+ SpecializedSetup<SampleCoverage, 0>();
+ SampleCoverage cmd;
+ cmd.Init(1, 2);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest2, ScissorValidArgs) {
+ EXPECT_CALL(*gl_, Scissor(1, 2, 3, 4));
+ SpecializedSetup<Scissor, 0>();
+ Scissor cmd;
+ cmd.Init(1, 2, 3, 4);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+}
+// TODO(gman): ShaderSource
+
+// TODO(gman): ShaderSourceImmediate
+
+
+TEST_F(GLES2DecoderTest2, StencilFuncValidArgs) {
+ EXPECT_CALL(*gl_, StencilFunc(GL_NEVER, 2, 3));
+ SpecializedSetup<StencilFunc, 0>();
+ StencilFunc cmd;
+ cmd.Init(GL_NEVER, 2, 3);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest2, 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(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest2, StencilMaskValidArgs) {
+ EXPECT_CALL(*gl_, StencilMask(1));
+ SpecializedSetup<StencilMask, 0>();
+ StencilMask cmd;
+ cmd.Init(1);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest2, StencilMaskSeparateValidArgs) {
+ EXPECT_CALL(*gl_, StencilMaskSeparate(GL_FRONT, 2));
+ SpecializedSetup<StencilMaskSeparate, 0>();
+ StencilMaskSeparate cmd;
+ cmd.Init(GL_FRONT, 2);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest2, 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(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest2, 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(error::kNoError, ExecuteCmd(cmd));
+}
+// TODO(gman): TexImage2D
+
+// TODO(gman): TexImage2DImmediate
+
+
+TEST_F(GLES2DecoderTest2, 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(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest2, 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(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest2, 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(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest2, TexParameterfInvalidArgs1_0) {
+ EXPECT_CALL(*gl_, TexParameterf(_, _, _)).Times(0);
+ SpecializedSetup<TexParameterf, 0>();
+ TexParameterf cmd;
+ cmd.Init(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, 3);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest2, 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(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest2, 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(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest2, 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(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest2, 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(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest2, 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(error::kOutOfBounds, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest2, 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(error::kOutOfBounds, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest2, 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(error::kNoError,
+ ExecuteImmediateCmd(cmd, sizeof(temp)));
+}
+
+TEST_F(GLES2DecoderTest2, 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(error::kNoError,
+ ExecuteImmediateCmd(cmd, sizeof(temp)));
+}
+
+TEST_F(GLES2DecoderTest2, 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(error::kNoError,
+ ExecuteImmediateCmd(cmd, sizeof(temp)));
+}
+
+TEST_F(GLES2DecoderTest2, 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(error::kNoError,
+ ExecuteImmediateCmd(cmd, sizeof(temp)));
+}
+
+TEST_F(GLES2DecoderTest2, 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(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest2, 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(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest2, 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(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest2, TexParameteriInvalidArgs1_0) {
+ EXPECT_CALL(*gl_, TexParameteri(_, _, _)).Times(0);
+ SpecializedSetup<TexParameteri, 0>();
+ TexParameteri cmd;
+ cmd.Init(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, 3);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest2, 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(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest2, 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(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest2, 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(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest2, 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(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest2, 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(error::kOutOfBounds, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest2, 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(error::kOutOfBounds, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest2, 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(error::kNoError,
+ ExecuteImmediateCmd(cmd, sizeof(temp)));
+}
+
+TEST_F(GLES2DecoderTest2, 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(error::kNoError,
+ ExecuteImmediateCmd(cmd, sizeof(temp)));
+}
+
+TEST_F(GLES2DecoderTest2, 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(error::kNoError,
+ ExecuteImmediateCmd(cmd, sizeof(temp)));
+}
+
+TEST_F(GLES2DecoderTest2, 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(error::kNoError,
+ ExecuteImmediateCmd(cmd, sizeof(temp)));
+}
+// TODO(gman): TexSubImage2D
+
+// TODO(gman): TexSubImage2DImmediate
+
+
+TEST_F(GLES2DecoderTest2, Uniform1fValidArgs) {
+ EXPECT_CALL(*gl_, Uniform1f(1, 2));
+ SpecializedSetup<Uniform1f, 0>();
+ Uniform1f cmd;
+ cmd.Init(1, 2);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest2, 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(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest2, Uniform1fvInvalidArgs2_0) {
+ EXPECT_CALL(*gl_, Uniform1fv(_, _, _)).Times(0);
+ SpecializedSetup<Uniform1fv, 0>();
+ Uniform1fv cmd;
+ cmd.Init(1, 2, kInvalidSharedMemoryId, 0);
+ EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest2, Uniform1fvInvalidArgs2_1) {
+ EXPECT_CALL(*gl_, Uniform1fv(_, _, _)).Times(0);
+ SpecializedSetup<Uniform1fv, 0>();
+ Uniform1fv cmd;
+ cmd.Init(1, 2, shared_memory_id_, kInvalidSharedMemoryOffset);
+ EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest2, 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(error::kNoError,
+ ExecuteImmediateCmd(cmd, sizeof(temp)));
+}
+// TODO(gman): Uniform1i
+// TODO(gman): Uniform1iv
+// TODO(gman): Uniform1ivImmediate
+
+TEST_F(GLES2DecoderTest2, Uniform2fValidArgs) {
+ EXPECT_CALL(*gl_, Uniform2f(1, 2, 3));
+ SpecializedSetup<Uniform2f, 0>();
+ Uniform2f cmd;
+ cmd.Init(1, 2, 3);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest2, 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(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest2, Uniform2fvInvalidArgs2_0) {
+ EXPECT_CALL(*gl_, Uniform2fv(_, _, _)).Times(0);
+ SpecializedSetup<Uniform2fv, 0>();
+ Uniform2fv cmd;
+ cmd.Init(1, 2, kInvalidSharedMemoryId, 0);
+ EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest2, Uniform2fvInvalidArgs2_1) {
+ EXPECT_CALL(*gl_, Uniform2fv(_, _, _)).Times(0);
+ SpecializedSetup<Uniform2fv, 0>();
+ Uniform2fv cmd;
+ cmd.Init(1, 2, shared_memory_id_, kInvalidSharedMemoryOffset);
+ EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest2, 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(error::kNoError,
+ ExecuteImmediateCmd(cmd, sizeof(temp)));
+}
+
+TEST_F(GLES2DecoderTest2, Uniform2iValidArgs) {
+ EXPECT_CALL(*gl_, Uniform2i(1, 2, 3));
+ SpecializedSetup<Uniform2i, 0>();
+ Uniform2i cmd;
+ cmd.Init(1, 2, 3);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest2, 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(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest2, Uniform2ivInvalidArgs2_0) {
+ EXPECT_CALL(*gl_, Uniform2iv(_, _, _)).Times(0);
+ SpecializedSetup<Uniform2iv, 0>();
+ Uniform2iv cmd;
+ cmd.Init(1, 2, kInvalidSharedMemoryId, 0);
+ EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest2, Uniform2ivInvalidArgs2_1) {
+ EXPECT_CALL(*gl_, Uniform2iv(_, _, _)).Times(0);
+ SpecializedSetup<Uniform2iv, 0>();
+ Uniform2iv cmd;
+ cmd.Init(1, 2, shared_memory_id_, kInvalidSharedMemoryOffset);
+ EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest2, 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(error::kNoError,
+ ExecuteImmediateCmd(cmd, sizeof(temp)));
+}
+
+TEST_F(GLES2DecoderTest2, Uniform3fValidArgs) {
+ EXPECT_CALL(*gl_, Uniform3f(1, 2, 3, 4));
+ SpecializedSetup<Uniform3f, 0>();
+ Uniform3f cmd;
+ cmd.Init(1, 2, 3, 4);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest2, 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(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest2, Uniform3fvInvalidArgs2_0) {
+ EXPECT_CALL(*gl_, Uniform3fv(_, _, _)).Times(0);
+ SpecializedSetup<Uniform3fv, 0>();
+ Uniform3fv cmd;
+ cmd.Init(1, 2, kInvalidSharedMemoryId, 0);
+ EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest2, Uniform3fvInvalidArgs2_1) {
+ EXPECT_CALL(*gl_, Uniform3fv(_, _, _)).Times(0);
+ SpecializedSetup<Uniform3fv, 0>();
+ Uniform3fv cmd;
+ cmd.Init(1, 2, shared_memory_id_, kInvalidSharedMemoryOffset);
+ EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest2, 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(error::kNoError,
+ ExecuteImmediateCmd(cmd, sizeof(temp)));
+}
+
+TEST_F(GLES2DecoderTest2, Uniform3iValidArgs) {
+ EXPECT_CALL(*gl_, Uniform3i(1, 2, 3, 4));
+ SpecializedSetup<Uniform3i, 0>();
+ Uniform3i cmd;
+ cmd.Init(1, 2, 3, 4);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest2, 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(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest2, Uniform3ivInvalidArgs2_0) {
+ EXPECT_CALL(*gl_, Uniform3iv(_, _, _)).Times(0);
+ SpecializedSetup<Uniform3iv, 0>();
+ Uniform3iv cmd;
+ cmd.Init(1, 2, kInvalidSharedMemoryId, 0);
+ EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest2, Uniform3ivInvalidArgs2_1) {
+ EXPECT_CALL(*gl_, Uniform3iv(_, _, _)).Times(0);
+ SpecializedSetup<Uniform3iv, 0>();
+ Uniform3iv cmd;
+ cmd.Init(1, 2, shared_memory_id_, kInvalidSharedMemoryOffset);
+ EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest2, 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(error::kNoError,
+ ExecuteImmediateCmd(cmd, sizeof(temp)));
+}
+
+TEST_F(GLES2DecoderTest2, Uniform4fValidArgs) {
+ EXPECT_CALL(*gl_, Uniform4f(1, 2, 3, 4, 5));
+ SpecializedSetup<Uniform4f, 0>();
+ Uniform4f cmd;
+ cmd.Init(1, 2, 3, 4, 5);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest2, 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(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest2, Uniform4fvInvalidArgs2_0) {
+ EXPECT_CALL(*gl_, Uniform4fv(_, _, _)).Times(0);
+ SpecializedSetup<Uniform4fv, 0>();
+ Uniform4fv cmd;
+ cmd.Init(1, 2, kInvalidSharedMemoryId, 0);
+ EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest2, Uniform4fvInvalidArgs2_1) {
+ EXPECT_CALL(*gl_, Uniform4fv(_, _, _)).Times(0);
+ SpecializedSetup<Uniform4fv, 0>();
+ Uniform4fv cmd;
+ cmd.Init(1, 2, shared_memory_id_, kInvalidSharedMemoryOffset);
+ EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest2, 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(error::kNoError,
+ ExecuteImmediateCmd(cmd, sizeof(temp)));
+}
+
+TEST_F(GLES2DecoderTest2, Uniform4iValidArgs) {
+ EXPECT_CALL(*gl_, Uniform4i(1, 2, 3, 4, 5));
+ SpecializedSetup<Uniform4i, 0>();
+ Uniform4i cmd;
+ cmd.Init(1, 2, 3, 4, 5);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest2, 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(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest2, Uniform4ivInvalidArgs2_0) {
+ EXPECT_CALL(*gl_, Uniform4iv(_, _, _)).Times(0);
+ SpecializedSetup<Uniform4iv, 0>();
+ Uniform4iv cmd;
+ cmd.Init(1, 2, kInvalidSharedMemoryId, 0);
+ EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest2, Uniform4ivInvalidArgs2_1) {
+ EXPECT_CALL(*gl_, Uniform4iv(_, _, _)).Times(0);
+ SpecializedSetup<Uniform4iv, 0>();
+ Uniform4iv cmd;
+ cmd.Init(1, 2, shared_memory_id_, kInvalidSharedMemoryOffset);
+ EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest2, 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(error::kNoError,
+ ExecuteImmediateCmd(cmd, sizeof(temp)));
+}
+
+TEST_F(GLES2DecoderTest2, 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(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest2, 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(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest2, UniformMatrix2fvInvalidArgs3_0) {
+ EXPECT_CALL(*gl_, UniformMatrix2fv(_, _, _, _)).Times(0);
+ SpecializedSetup<UniformMatrix2fv, 0>();
+ UniformMatrix2fv cmd;
+ cmd.Init(1, 2, false, kInvalidSharedMemoryId, 0);
+ EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest2, UniformMatrix2fvInvalidArgs3_1) {
+ EXPECT_CALL(*gl_, UniformMatrix2fv(_, _, _, _)).Times(0);
+ SpecializedSetup<UniformMatrix2fv, 0>();
+ UniformMatrix2fv cmd;
+ cmd.Init(1, 2, false, shared_memory_id_, kInvalidSharedMemoryOffset);
+ EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest2, 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(error::kNoError,
+ ExecuteImmediateCmd(cmd, sizeof(temp)));
+}
+
+TEST_F(GLES2DecoderTest2, 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(error::kNoError,
+ ExecuteImmediateCmd(cmd, sizeof(temp)));
+}
+
+TEST_F(GLES2DecoderTest2, 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(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest2, 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(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest2, UniformMatrix3fvInvalidArgs3_0) {
+ EXPECT_CALL(*gl_, UniformMatrix3fv(_, _, _, _)).Times(0);
+ SpecializedSetup<UniformMatrix3fv, 0>();
+ UniformMatrix3fv cmd;
+ cmd.Init(1, 2, false, kInvalidSharedMemoryId, 0);
+ EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest2, UniformMatrix3fvInvalidArgs3_1) {
+ EXPECT_CALL(*gl_, UniformMatrix3fv(_, _, _, _)).Times(0);
+ SpecializedSetup<UniformMatrix3fv, 0>();
+ UniformMatrix3fv cmd;
+ cmd.Init(1, 2, false, shared_memory_id_, kInvalidSharedMemoryOffset);
+ EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest2, 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(error::kNoError,
+ ExecuteImmediateCmd(cmd, sizeof(temp)));
+}
+
+TEST_F(GLES2DecoderTest2, 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(error::kNoError,
+ ExecuteImmediateCmd(cmd, sizeof(temp)));
+}
+
+TEST_F(GLES2DecoderTest2, 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(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest2, 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(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest2, UniformMatrix4fvInvalidArgs3_0) {
+ EXPECT_CALL(*gl_, UniformMatrix4fv(_, _, _, _)).Times(0);
+ SpecializedSetup<UniformMatrix4fv, 0>();
+ UniformMatrix4fv cmd;
+ cmd.Init(1, 2, false, kInvalidSharedMemoryId, 0);
+ EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest2, UniformMatrix4fvInvalidArgs3_1) {
+ EXPECT_CALL(*gl_, UniformMatrix4fv(_, _, _, _)).Times(0);
+ SpecializedSetup<UniformMatrix4fv, 0>();
+ UniformMatrix4fv cmd;
+ cmd.Init(1, 2, false, shared_memory_id_, kInvalidSharedMemoryOffset);
+ EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest2, 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(error::kNoError,
+ ExecuteImmediateCmd(cmd, sizeof(temp)));
+}
+
+TEST_F(GLES2DecoderTest2, 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(error::kNoError,
+ ExecuteImmediateCmd(cmd, sizeof(temp)));
+}
+// TODO(gman): UseProgram
+
+TEST_F(GLES2DecoderTest2, ValidateProgramValidArgs) {
+ EXPECT_CALL(*gl_, ValidateProgram(kServiceProgramId));
+ SpecializedSetup<ValidateProgram, 0>();
+ ValidateProgram cmd;
+ cmd.Init(client_program_id_);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest2, VertexAttrib1fValidArgs) {
+ EXPECT_CALL(*gl_, VertexAttrib1f(1, 2));
+ SpecializedSetup<VertexAttrib1f, 0>();
+ VertexAttrib1f cmd;
+ cmd.Init(1, 2);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest2, 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(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest2, VertexAttrib1fvInvalidArgs1_0) {
+ EXPECT_CALL(*gl_, VertexAttrib1fv(_, _)).Times(0);
+ SpecializedSetup<VertexAttrib1fv, 0>();
+ VertexAttrib1fv cmd;
+ cmd.Init(1, kInvalidSharedMemoryId, 0);
+ EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest2, VertexAttrib1fvInvalidArgs1_1) {
+ EXPECT_CALL(*gl_, VertexAttrib1fv(_, _)).Times(0);
+ SpecializedSetup<VertexAttrib1fv, 0>();
+ VertexAttrib1fv cmd;
+ cmd.Init(1, shared_memory_id_, kInvalidSharedMemoryOffset);
+ EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest2, 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(error::kNoError,
+ ExecuteImmediateCmd(cmd, sizeof(temp)));
+}
+
+TEST_F(GLES2DecoderTest2, VertexAttrib2fValidArgs) {
+ EXPECT_CALL(*gl_, VertexAttrib2f(1, 2, 3));
+ SpecializedSetup<VertexAttrib2f, 0>();
+ VertexAttrib2f cmd;
+ cmd.Init(1, 2, 3);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest2, 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(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest2, VertexAttrib2fvInvalidArgs1_0) {
+ EXPECT_CALL(*gl_, VertexAttrib2fv(_, _)).Times(0);
+ SpecializedSetup<VertexAttrib2fv, 0>();
+ VertexAttrib2fv cmd;
+ cmd.Init(1, kInvalidSharedMemoryId, 0);
+ EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest2, VertexAttrib2fvInvalidArgs1_1) {
+ EXPECT_CALL(*gl_, VertexAttrib2fv(_, _)).Times(0);
+ SpecializedSetup<VertexAttrib2fv, 0>();
+ VertexAttrib2fv cmd;
+ cmd.Init(1, shared_memory_id_, kInvalidSharedMemoryOffset);
+ EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest2, 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(error::kNoError,
+ ExecuteImmediateCmd(cmd, sizeof(temp)));
+}
+
+TEST_F(GLES2DecoderTest2, VertexAttrib3fValidArgs) {
+ EXPECT_CALL(*gl_, VertexAttrib3f(1, 2, 3, 4));
+ SpecializedSetup<VertexAttrib3f, 0>();
+ VertexAttrib3f cmd;
+ cmd.Init(1, 2, 3, 4);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest2, 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(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest2, VertexAttrib3fvInvalidArgs1_0) {
+ EXPECT_CALL(*gl_, VertexAttrib3fv(_, _)).Times(0);
+ SpecializedSetup<VertexAttrib3fv, 0>();
+ VertexAttrib3fv cmd;
+ cmd.Init(1, kInvalidSharedMemoryId, 0);
+ EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest2, VertexAttrib3fvInvalidArgs1_1) {
+ EXPECT_CALL(*gl_, VertexAttrib3fv(_, _)).Times(0);
+ SpecializedSetup<VertexAttrib3fv, 0>();
+ VertexAttrib3fv cmd;
+ cmd.Init(1, shared_memory_id_, kInvalidSharedMemoryOffset);
+ EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest2, 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(error::kNoError,
+ ExecuteImmediateCmd(cmd, sizeof(temp)));
+}
+
+TEST_F(GLES2DecoderTest2, VertexAttrib4fValidArgs) {
+ EXPECT_CALL(*gl_, VertexAttrib4f(1, 2, 3, 4, 5));
+ SpecializedSetup<VertexAttrib4f, 0>();
+ VertexAttrib4f cmd;
+ cmd.Init(1, 2, 3, 4, 5);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest2, 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(error::kNoError, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest2, VertexAttrib4fvInvalidArgs1_0) {
+ EXPECT_CALL(*gl_, VertexAttrib4fv(_, _)).Times(0);
+ SpecializedSetup<VertexAttrib4fv, 0>();
+ VertexAttrib4fv cmd;
+ cmd.Init(1, kInvalidSharedMemoryId, 0);
+ EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest2, VertexAttrib4fvInvalidArgs1_1) {
+ EXPECT_CALL(*gl_, VertexAttrib4fv(_, _)).Times(0);
+ SpecializedSetup<VertexAttrib4fv, 0>();
+ VertexAttrib4fv cmd;
+ cmd.Init(1, shared_memory_id_, kInvalidSharedMemoryOffset);
+ EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd));
+}
+
+TEST_F(GLES2DecoderTest2, 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(error::kNoError,
+ ExecuteImmediateCmd(cmd, sizeof(temp)));
+}
+// TODO(gman): VertexAttribPointer
+
+
+TEST_F(GLES2DecoderTest2, ViewportValidArgs) {
+ EXPECT_CALL(*gl_, Viewport(1, 2, 3, 4));
+ SpecializedSetup<Viewport, 0>();
+ Viewport cmd;
+ cmd.Init(1, 2, 3, 4);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+}
+// TODO(gman): SwapBuffers
+#endif // GPU_COMMAND_BUFFER_SERVICE_GLES2_CMD_DECODER_UNITTEST_2_AUTOGEN_H_
+
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_autogen.h b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_autogen.h
deleted file mode 100644
index 905a451..0000000
--- a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_autogen.h
+++ /dev/null
@@ -1,2551 +0,0 @@
-// 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(error::kNoError, 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(error::kNoError, 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(error::kNoError, 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(error::kNoError, 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(error::kNoError, 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(error::kNoError, 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(error::kNoError, 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(error::kNoError, 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(error::kNoError, 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(error::kNoError, 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(error::kNoError, ExecuteCmd(cmd));
-}
-
-TEST_F(GLES2DecoderTest, BlendEquationInvalidArgs0_0) {
- EXPECT_CALL(*gl_, BlendEquation(_)).Times(0);
- SpecializedSetup<BlendEquation, 0>();
- BlendEquation cmd;
- cmd.Init(GL_MIN);
- EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
-}
-
-TEST_F(GLES2DecoderTest, BlendEquationInvalidArgs0_1) {
- EXPECT_CALL(*gl_, BlendEquation(_)).Times(0);
- SpecializedSetup<BlendEquation, 0>();
- BlendEquation cmd;
- cmd.Init(GL_MAX);
- EXPECT_EQ(error::kNoError, 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(error::kNoError, 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(error::kNoError, 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(error::kNoError, 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(error::kNoError, 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(error::kNoError, 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(error::kNoError, 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(error::kNoError, 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(error::kNoError, ExecuteCmd(cmd));
-}
-
-TEST_F(GLES2DecoderTest, ClearValidArgs) {
- EXPECT_CALL(*gl_, Clear(1));
- SpecializedSetup<Clear, 0>();
- Clear cmd;
- cmd.Init(1);
- EXPECT_EQ(error::kNoError, 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(error::kNoError, ExecuteCmd(cmd));
-}
-
-TEST_F(GLES2DecoderTest, ClearDepthfValidArgs) {
- EXPECT_CALL(*gl_, ClearDepth(1));
- SpecializedSetup<ClearDepthf, 0>();
- ClearDepthf cmd;
- cmd.Init(1);
- EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
-}
-
-TEST_F(GLES2DecoderTest, ClearStencilValidArgs) {
- EXPECT_CALL(*gl_, ClearStencil(1));
- SpecializedSetup<ClearStencil, 0>();
- ClearStencil cmd;
- cmd.Init(1);
- EXPECT_EQ(error::kNoError, 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(error::kNoError, ExecuteCmd(cmd));
-}
-// TODO(gman): CompileShader
-// 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(error::kNoError, 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(error::kNoError, 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(error::kNoError, 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(error::kNoError, ExecuteCmd(cmd));
-}
-
-TEST_F(GLES2DecoderTest, CreateProgramValidArgs) {
- EXPECT_CALL(*gl_, CreateProgram())
- .WillOnce(Return(kNewServiceId));
- SpecializedSetup<CreateProgram, 0>();
- CreateProgram cmd;
- cmd.Init(kNewClientId);
- EXPECT_EQ(error::kNoError, 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(error::kNoError, 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(error::kNoError, 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(error::kNoError, 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(error::kNoError, 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(error::kNoError,
- 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(error::kNoError,
- 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(error::kNoError, 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(error::kNoError, 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(error::kNoError,
- 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(error::kNoError,
- 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(error::kNoError, 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(error::kNoError, 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(error::kNoError,
- 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(error::kNoError,
- 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(error::kNoError, 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(error::kNoError, 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(error::kNoError,
- 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(error::kNoError,
- 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(error::kNoError, ExecuteCmd(cmd));
-}
-
-TEST_F(GLES2DecoderTest, DepthMaskValidArgs) {
- EXPECT_CALL(*gl_, DepthMask(1));
- SpecializedSetup<DepthMask, 0>();
- DepthMask cmd;
- cmd.Init(1);
- EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
-}
-
-TEST_F(GLES2DecoderTest, DepthRangefValidArgs) {
- EXPECT_CALL(*gl_, DepthRange(1, 2));
- SpecializedSetup<DepthRangef, 0>();
- DepthRangef cmd;
- cmd.Init(1, 2);
- EXPECT_EQ(error::kNoError, 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(error::kNoError, ExecuteCmd(cmd));
-}
-
-TEST_F(GLES2DecoderTest, DisableValidArgs) {
- EXPECT_CALL(*gl_, Disable(GL_BLEND));
- SpecializedSetup<Disable, 0>();
- Disable cmd;
- cmd.Init(GL_BLEND);
- EXPECT_EQ(error::kNoError, 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(error::kNoError, 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(error::kNoError, ExecuteCmd(cmd));
-}
-
-TEST_F(GLES2DecoderTest, DisableVertexAttribArrayValidArgs) {
- EXPECT_CALL(*gl_, DisableVertexAttribArray(1));
- SpecializedSetup<DisableVertexAttribArray, 0>();
- DisableVertexAttribArray cmd;
- cmd.Init(1);
- EXPECT_EQ(error::kNoError, 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(error::kNoError, 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(error::kNoError, 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(error::kNoError, ExecuteCmd(cmd));
-}
-
-TEST_F(GLES2DecoderTest, EnableVertexAttribArrayValidArgs) {
- EXPECT_CALL(*gl_, EnableVertexAttribArray(1));
- SpecializedSetup<EnableVertexAttribArray, 0>();
- EnableVertexAttribArray cmd;
- cmd.Init(1);
- EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
-}
-
-TEST_F(GLES2DecoderTest, FinishValidArgs) {
- EXPECT_CALL(*gl_, Finish());
- SpecializedSetup<Finish, 0>();
- Finish cmd;
- cmd.Init();
- EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
-}
-
-TEST_F(GLES2DecoderTest, FlushValidArgs) {
- EXPECT_CALL(*gl_, Flush());
- SpecializedSetup<Flush, 0>();
- Flush cmd;
- cmd.Init();
- EXPECT_EQ(error::kNoError, 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(error::kNoError, 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(error::kNoError, 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(error::kNoError, ExecuteCmd(cmd));
-}
-
-TEST_F(GLES2DecoderTest, FrontFaceValidArgs) {
- EXPECT_CALL(*gl_, FrontFace(GL_CW));
- SpecializedSetup<FrontFace, 0>();
- FrontFace cmd;
- cmd.Init(GL_CW);
- EXPECT_EQ(error::kNoError, 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(error::kNoError, 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(error::kInvalidArguments, 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(error::kNoError,
- 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(error::kInvalidArguments,
- 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(error::kNoError, 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(error::kNoError, 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(error::kNoError, 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(error::kNoError, 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(error::kInvalidArguments, 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(error::kNoError,
- 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(error::kInvalidArguments,
- 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(error::kNoError, 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(error::kInvalidArguments, 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(error::kNoError,
- 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(error::kInvalidArguments,
- 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(error::kNoError, 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(error::kInvalidArguments, 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(error::kNoError,
- 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(error::kInvalidArguments,
- 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(error::kNoError, 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(error::kOutOfBounds, 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(error::kOutOfBounds, 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(error::kNoError, 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(error::kNoError, 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(error::kNoError, 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(error::kOutOfBounds, 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(error::kOutOfBounds, 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(error::kNoError, 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(error::kNoError, 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(error::kOutOfBounds, 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(error::kOutOfBounds, 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(error::kNoError, 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(error::kOutOfBounds, 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(error::kOutOfBounds, 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(error::kNoError, 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(error::kOutOfBounds, 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(error::kOutOfBounds, 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(error::kNoError, 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(error::kOutOfBounds, 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(error::kOutOfBounds, 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(error::kNoError, 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(error::kOutOfBounds, 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(error::kOutOfBounds, 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(error::kNoError, 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(error::kOutOfBounds, 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(error::kOutOfBounds, 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(error::kNoError, 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(error::kNoError, 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(error::kNoError, 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(error::kNoError, 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(error::kOutOfBounds, 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(error::kOutOfBounds, 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(error::kNoError, 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(error::kNoError, 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(error::kNoError, 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(error::kOutOfBounds, 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(error::kOutOfBounds, 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(error::kNoError, 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(error::kOutOfBounds, 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(error::kOutOfBounds, 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(error::kNoError, 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(error::kOutOfBounds, 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(error::kOutOfBounds, 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(error::kNoError, 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(error::kNoError, 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(error::kNoError, 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(error::kNoError, 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(error::kNoError, 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(error::kNoError, 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(error::kNoError, 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(error::kNoError, 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(error::kNoError, 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(error::kNoError, 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(error::kNoError, ExecuteCmd(cmd));
-}
-
-TEST_F(GLES2DecoderTest, LineWidthValidArgs) {
- EXPECT_CALL(*gl_, LineWidth(1));
- SpecializedSetup<LineWidth, 0>();
- LineWidth cmd;
- cmd.Init(1);
- EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
-}
-
-TEST_F(GLES2DecoderTest, LinkProgramValidArgs) {
- EXPECT_CALL(*gl_, LinkProgram(kServiceProgramId));
- SpecializedSetup<LinkProgram, 0>();
- LinkProgram cmd;
- cmd.Init(client_program_id_);
- EXPECT_EQ(error::kNoError, 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(error::kNoError, 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(error::kNoError, ExecuteCmd(cmd));
-}
-
-TEST_F(GLES2DecoderTest, SampleCoverageValidArgs) {
- EXPECT_CALL(*gl_, SampleCoverage(1, 2));
- SpecializedSetup<SampleCoverage, 0>();
- SampleCoverage cmd;
- cmd.Init(1, 2);
- EXPECT_EQ(error::kNoError, 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(error::kNoError, 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(error::kNoError, 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(error::kNoError, ExecuteCmd(cmd));
-}
-
-TEST_F(GLES2DecoderTest, StencilMaskValidArgs) {
- EXPECT_CALL(*gl_, StencilMask(1));
- SpecializedSetup<StencilMask, 0>();
- StencilMask cmd;
- cmd.Init(1);
- EXPECT_EQ(error::kNoError, 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(error::kNoError, 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(error::kNoError, 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(error::kNoError, 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(error::kNoError, 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(error::kNoError, 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(error::kNoError, 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(error::kNoError, 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(error::kNoError, 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(error::kNoError, 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(error::kNoError, 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(error::kNoError, 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(error::kOutOfBounds, 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(error::kOutOfBounds, 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(error::kNoError,
- 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(error::kNoError,
- 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(error::kNoError,
- 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(error::kNoError,
- 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(error::kNoError, 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(error::kNoError, 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(error::kNoError, 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(error::kNoError, 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(error::kNoError, 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(error::kNoError, 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(error::kNoError, 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(error::kNoError, 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(error::kOutOfBounds, 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(error::kOutOfBounds, 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(error::kNoError,
- 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(error::kNoError,
- 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(error::kNoError,
- 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(error::kNoError,
- 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(error::kNoError, 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(error::kNoError, 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(error::kOutOfBounds, 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(error::kOutOfBounds, 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(error::kNoError,
- 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(error::kNoError, 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(error::kNoError, 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(error::kOutOfBounds, 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(error::kOutOfBounds, 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(error::kNoError,
- 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(error::kNoError, 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(error::kNoError, 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(error::kOutOfBounds, 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(error::kOutOfBounds, 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(error::kNoError,
- 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(error::kNoError, 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(error::kNoError, 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(error::kOutOfBounds, 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(error::kOutOfBounds, 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(error::kNoError,
- 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(error::kNoError, 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(error::kNoError, 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(error::kOutOfBounds, 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(error::kOutOfBounds, 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(error::kNoError,
- 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(error::kNoError, 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(error::kNoError, 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(error::kOutOfBounds, 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(error::kOutOfBounds, 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(error::kNoError,
- 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(error::kNoError, 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(error::kNoError, 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(error::kOutOfBounds, 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(error::kOutOfBounds, 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(error::kNoError,
- 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(error::kNoError, 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(error::kNoError, 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(error::kOutOfBounds, 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(error::kOutOfBounds, 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(error::kNoError,
- 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(error::kNoError, 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(error::kNoError, 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(error::kOutOfBounds, 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(error::kOutOfBounds, 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(error::kNoError,
- 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(error::kNoError,
- 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(error::kNoError, 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(error::kNoError, 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(error::kOutOfBounds, 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(error::kOutOfBounds, 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(error::kNoError,
- 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(error::kNoError,
- 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(error::kNoError, 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(error::kNoError, 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(error::kOutOfBounds, 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(error::kOutOfBounds, 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(error::kNoError,
- 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(error::kNoError,
- 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(error::kNoError, ExecuteCmd(cmd));
-}
-
-TEST_F(GLES2DecoderTest, VertexAttrib1fValidArgs) {
- EXPECT_CALL(*gl_, VertexAttrib1f(1, 2));
- SpecializedSetup<VertexAttrib1f, 0>();
- VertexAttrib1f cmd;
- cmd.Init(1, 2);
- EXPECT_EQ(error::kNoError, 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(error::kNoError, 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(error::kOutOfBounds, 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(error::kOutOfBounds, 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(error::kNoError,
- 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(error::kNoError, 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(error::kNoError, 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(error::kOutOfBounds, 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(error::kOutOfBounds, 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(error::kNoError,
- 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(error::kNoError, 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(error::kNoError, 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(error::kOutOfBounds, 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(error::kOutOfBounds, 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(error::kNoError,
- 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(error::kNoError, 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(error::kNoError, 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(error::kOutOfBounds, 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(error::kOutOfBounds, 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(error::kNoError,
- 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(error::kNoError, 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_decoder_unittest_base.cc b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.cc
new file mode 100644
index 0000000..d0a7ceb
--- /dev/null
+++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.cc
@@ -0,0 +1,424 @@
+// 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.
+
+#include "gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.h"
+#include "base/string_util.h"
+#include "gpu/command_buffer/common/gles2_cmd_format.h"
+#include "gpu/command_buffer/common/gles2_cmd_utils.h"
+#include "gpu/command_buffer/service/gl_mock.h"
+#include "gpu/command_buffer/service/cmd_buffer_engine.h"
+#include "gpu/command_buffer/service/context_group.h"
+#include "gpu/command_buffer/service/program_manager.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+using ::gles2::MockGLInterface;
+using ::testing::_;
+using ::testing::DoAll;
+using ::testing::InSequence;
+using ::testing::MatcherCast;
+using ::testing::Pointee;
+using ::testing::Return;
+using ::testing::SetArrayArgument;
+using ::testing::SetArgumentPointee;
+using ::testing::StrEq;
+using ::testing::StrictMock;
+
+namespace gpu {
+namespace gles2 {
+
+void GLES2DecoderTestBase::SetUp() {
+ gl_.reset(new StrictMock<MockGLInterface>());
+ ::gles2::GLInterface::SetGLInterface(gl_.get());
+
+ InSequence sequence;
+
+ EXPECT_CALL(*gl_, GetIntegerv(GL_MAX_VERTEX_ATTRIBS, _))
+ .WillOnce(SetArgumentPointee<1>(kNumVertexAttribs))
+ .RetiresOnSaturation();
+ EXPECT_CALL(*gl_, GetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, _))
+ .WillOnce(SetArgumentPointee<1>(kNumTextureUnits))
+ .RetiresOnSaturation();
+ EXPECT_CALL(*gl_, GetIntegerv(GL_MAX_TEXTURE_SIZE, _))
+ .WillOnce(SetArgumentPointee<1>(kMaxTextureSize))
+ .RetiresOnSaturation();
+ EXPECT_CALL(*gl_, GetIntegerv(GL_MAX_CUBE_MAP_TEXTURE_SIZE, _))
+ .WillOnce(SetArgumentPointee<1>(kMaxCubeMapTextureSize))
+ .RetiresOnSaturation();
+ static GLuint black_ids[] = {
+ kServiceBlackTexture2dId,
+ kServiceBlackTextureCubemapId,
+ };
+ EXPECT_CALL(*gl_, GenTextures(2, _))
+ .WillOnce(SetArrayArgument<1>(black_ids, black_ids + 2))
+ .RetiresOnSaturation();
+ EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_2D, kServiceBlackTexture2dId))
+ .Times(1)
+ .RetiresOnSaturation();
+ EXPECT_CALL(*gl_, TexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA,
+ GL_UNSIGNED_BYTE, _))
+ .Times(1)
+ .RetiresOnSaturation();
+ EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_2D, 0))
+ .Times(1)
+ .RetiresOnSaturation();
+ EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_CUBE_MAP,
+ kServiceBlackTextureCubemapId))
+ .Times(1)
+ .RetiresOnSaturation();
+ static GLenum faces[] = {
+ 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,
+ };
+ for (size_t ii = 0; ii < arraysize(faces); ++ii) {
+ EXPECT_CALL(*gl_, TexImage2D(faces[ii], 0, GL_RGBA, 1, 1, 0, GL_RGBA,
+ GL_UNSIGNED_BYTE, _))
+ .Times(1)
+ .RetiresOnSaturation();
+ }
+ EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_CUBE_MAP, 0))
+ .Times(1)
+ .RetiresOnSaturation();
+
+ engine_.reset(new StrictMock<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(&group_));
+ decoder_->Initialize();
+ decoder_->set_engine(engine_.get());
+
+ EXPECT_CALL(*gl_, GenBuffersARB(_, _))
+ .WillOnce(SetArgumentPointee<1>(kServiceBufferId))
+ .RetiresOnSaturation();
+ GenHelper<GenBuffersImmediate>(client_buffer_id_);
+ EXPECT_CALL(*gl_, GenFramebuffersEXT(_, _))
+ .WillOnce(SetArgumentPointee<1>(kServiceFramebufferId))
+ .RetiresOnSaturation();
+ GenHelper<GenFramebuffersImmediate>(client_framebuffer_id_);
+ EXPECT_CALL(*gl_, GenRenderbuffersEXT(_, _))
+ .WillOnce(SetArgumentPointee<1>(kServiceRenderbufferId))
+ .RetiresOnSaturation();
+ GenHelper<GenRenderbuffersImmediate>(client_renderbuffer_id_);
+ EXPECT_CALL(*gl_, GenTextures(_, _))
+ .WillOnce(SetArgumentPointee<1>(kServiceTextureId))
+ .RetiresOnSaturation();
+ GenHelper<GenTexturesImmediate>(client_texture_id_);
+ EXPECT_CALL(*gl_, GenBuffersARB(_, _))
+ .WillOnce(SetArgumentPointee<1>(kServiceElementBufferId))
+ .RetiresOnSaturation();
+ GenHelper<GenBuffersImmediate>(client_element_buffer_id_);
+
+ {
+ EXPECT_CALL(*gl_, CreateProgram())
+ .Times(1)
+ .WillOnce(Return(kServiceProgramId))
+ .RetiresOnSaturation();
+ CreateProgram cmd;
+ cmd.Init(client_program_id_);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+ }
+
+ {
+ EXPECT_CALL(*gl_, CreateShader(_))
+ .Times(1)
+ .WillOnce(Return(kServiceShaderId))
+ .RetiresOnSaturation();
+ CreateShader cmd;
+ cmd.Init(GL_VERTEX_SHADER, client_shader_id_);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+ }
+
+ EXPECT_EQ(GL_NO_ERROR, GetGLError());
+}
+
+void GLES2DecoderTestBase::TearDown() {
+ decoder_->Destroy();
+ decoder_.reset();
+ engine_.reset();
+ ::gles2::GLInterface::SetGLInterface(NULL);
+ gl_.reset();
+}
+
+GLint GLES2DecoderTestBase::GetGLError() {
+ EXPECT_CALL(*gl_, GetError())
+ .WillOnce(Return(GL_NO_ERROR))
+ .RetiresOnSaturation();
+ GetError cmd;
+ cmd.Init(shared_memory_id_, shared_memory_offset_);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+ return static_cast<GLint>(*GetSharedMemoryAs<GLenum*>());
+}
+
+void GLES2DecoderTestBase::DoBindTexture(
+ GLenum target, GLuint client_id, GLuint service_id) {
+ EXPECT_CALL(*gl_, BindTexture(target, service_id))
+ .Times(1)
+ .RetiresOnSaturation();
+ BindTexture cmd;
+ cmd.Init(target, client_id);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+}
+
+void GLES2DecoderTestBase::DoTexImage2D(
+ GLenum target, GLint level, GLenum internal_format,
+ GLsizei width, GLsizei height, GLint border,
+ GLenum format, GLenum type,
+ uint32 shared_memory_id, uint32 shared_memory_offset) {
+ EXPECT_CALL(*gl_, TexImage2D(target, level, internal_format,
+ width, height, border, format, type, _))
+ .Times(1)
+ .RetiresOnSaturation();
+ TexImage2D cmd;
+ cmd.Init(target, level, internal_format, width, height, border, format,
+ type, shared_memory_id, shared_memory_offset);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+}
+
+void GLES2DecoderWithShaderTestBase::SetUp() {
+ GLES2DecoderTestBase::SetUp();
+
+ {
+ static AttribInfo attribs[] = {
+ { kAttrib1Name, kAttrib1Size, kAttrib1Type, kAttrib1Location, },
+ { kAttrib2Name, kAttrib2Size, kAttrib2Type, kAttrib2Location, },
+ { kAttrib3Name, kAttrib3Size, kAttrib3Type, kAttrib3Location, },
+ };
+ static UniformInfo uniforms[] = {
+ { kUniform1Name, kUniform1Size, kUniform1Type, kUniform1Location, },
+ { kUniform2Name, kUniform2Size, kUniform2Type, kUniform2Location, },
+ { kUniform3Name, kUniform3Size, kUniform3Type, kUniform3Location, },
+ };
+ SetupShader(attribs, arraysize(attribs), uniforms, arraysize(uniforms),
+ client_program_id_, kServiceProgramId);
+ }
+
+ {
+ EXPECT_CALL(*gl_, UseProgram(kServiceProgramId))
+ .Times(1)
+ .RetiresOnSaturation();
+ UseProgram cmd;
+ cmd.Init(client_program_id_);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+ }
+}
+
+void GLES2DecoderWithShaderTestBase::TearDown() {
+ GLES2DecoderTestBase::TearDown();
+}
+
+void GLES2DecoderWithShaderTestBase::SetupShader(
+ GLES2DecoderWithShaderTestBase::AttribInfo* attribs, size_t num_attribs,
+ GLES2DecoderWithShaderTestBase::UniformInfo* uniforms, size_t num_uniforms,
+ GLuint client_id, GLuint service_id) {
+ LinkProgram cmd;
+ cmd.Init(client_id);
+
+ {
+ InSequence s;
+ EXPECT_CALL(*gl_, GetError())
+ .WillOnce(Return(GL_NO_ERROR))
+ .RetiresOnSaturation();
+ EXPECT_CALL(*gl_, LinkProgram(service_id))
+ .Times(1)
+ .RetiresOnSaturation();
+ EXPECT_CALL(*gl_, GetError())
+ .WillOnce(Return(GL_NO_ERROR))
+ .RetiresOnSaturation();
+ EXPECT_CALL(*gl_,
+ GetProgramiv(service_id, GL_ACTIVE_ATTRIBUTES, _))
+ .WillOnce(SetArgumentPointee<2>(num_attribs))
+ .RetiresOnSaturation();
+ EXPECT_CALL(*gl_,
+ GetProgramiv(service_id, GL_ACTIVE_ATTRIBUTE_MAX_LENGTH, _))
+ .WillOnce(SetArgumentPointee<2>(kMaxAttribLength))
+ .RetiresOnSaturation();
+ for (size_t ii = 0; ii < num_attribs; ++ii) {
+ const AttribInfo& info = attribs[ii];
+ EXPECT_CALL(*gl_,
+ GetActiveAttrib(service_id, ii,
+ kMaxAttribLength, _, _, _, _))
+ .WillOnce(DoAll(
+ SetArgumentPointee<3>(strlen(info.name)),
+ SetArgumentPointee<4>(info.size),
+ SetArgumentPointee<5>(info.type),
+ SetArrayArgument<6>(info.name,
+ info.name + strlen(info.name) + 1)))
+ .RetiresOnSaturation();
+ if (!ProgramManager::IsInvalidPrefix(info.name, strlen(info.name))) {
+ EXPECT_CALL(*gl_, GetAttribLocation(service_id,
+ StrEq(info.name)))
+ .WillOnce(Return(info.location))
+ .RetiresOnSaturation();
+ }
+ }
+ EXPECT_CALL(*gl_,
+ GetProgramiv(service_id, GL_ACTIVE_UNIFORMS, _))
+ .WillOnce(SetArgumentPointee<2>(num_uniforms))
+ .RetiresOnSaturation();
+ EXPECT_CALL(*gl_,
+ GetProgramiv(service_id, GL_ACTIVE_UNIFORM_MAX_LENGTH, _))
+ .WillOnce(SetArgumentPointee<2>(kMaxUniformLength))
+ .RetiresOnSaturation();
+ for (size_t ii = 0; ii < num_uniforms; ++ii) {
+ const UniformInfo& info = uniforms[ii];
+ EXPECT_CALL(*gl_,
+ GetActiveUniform(service_id, ii,
+ kMaxUniformLength, _, _, _, _))
+ .WillOnce(DoAll(
+ SetArgumentPointee<3>(strlen(info.name)),
+ SetArgumentPointee<4>(info.size),
+ SetArgumentPointee<5>(info.type),
+ SetArrayArgument<6>(info.name,
+ info.name + strlen(info.name) + 1)))
+ .RetiresOnSaturation();
+ if (!ProgramManager::IsInvalidPrefix(info.name, strlen(info.name))) {
+ EXPECT_CALL(*gl_, GetUniformLocation(service_id,
+ StrEq(info.name)))
+ .WillOnce(Return(info.location))
+ .RetiresOnSaturation();
+ if (info.size > 1) {
+ for (GLsizei jj = 1; jj < info.size; ++jj) {
+ std::string element_name(
+ std::string(info.name) + "[" + IntToString(jj) + "]");
+ EXPECT_CALL(*gl_, GetUniformLocation(service_id,
+ StrEq(element_name)))
+ .WillOnce(Return(info.location + jj))
+ .RetiresOnSaturation();
+ }
+ }
+ }
+ }
+ }
+
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+}
+
+void GLES2DecoderWithShaderTestBase::DoEnableVertexAttribArray(GLint index) {
+ EXPECT_CALL(*gl_, EnableVertexAttribArray(index))
+ .Times(1)
+ .RetiresOnSaturation();
+ EnableVertexAttribArray cmd;
+ cmd.Init(index);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+}
+
+void GLES2DecoderWithShaderTestBase::DoBindBuffer(
+ GLenum target, GLuint client_id, GLuint service_id) {
+ EXPECT_CALL(*gl_, BindBuffer(target, service_id))
+ .Times(1)
+ .RetiresOnSaturation();
+ BindBuffer cmd;
+ cmd.Init(target, client_id);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+}
+
+void GLES2DecoderWithShaderTestBase::DoBufferData(GLenum target, GLsizei size) {
+ EXPECT_CALL(*gl_, GetError())
+ .WillOnce(Return(GL_NO_ERROR))
+ .RetiresOnSaturation();
+ EXPECT_CALL(*gl_, BufferData(target, size, _, GL_STREAM_DRAW))
+ .Times(1)
+ .RetiresOnSaturation();
+ EXPECT_CALL(*gl_, GetError())
+ .WillOnce(Return(GL_NO_ERROR))
+ .RetiresOnSaturation();
+ BufferData cmd;
+ cmd.Init(target, size, 0, 0, GL_STREAM_DRAW);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+}
+
+void GLES2DecoderWithShaderTestBase::DoBufferSubData(
+ GLenum target, GLint offset, GLsizei size, const void* data) {
+ EXPECT_CALL(*gl_, BufferSubData(target, offset, size,
+ shared_memory_address_))
+ .Times(1)
+ .RetiresOnSaturation();
+ memcpy(shared_memory_address_, data, size);
+ BufferSubData cmd;
+ cmd.Init(target, offset, size, shared_memory_id_, shared_memory_offset_);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+}
+
+void GLES2DecoderWithShaderTestBase::DoDeleteBuffer(
+ GLuint client_id, GLuint service_id) {
+ EXPECT_CALL(*gl_, DeleteBuffersARB(1, Pointee(service_id)))
+ .Times(1)
+ .RetiresOnSaturation();
+ DeleteBuffers cmd;
+ cmd.Init(1, shared_memory_id_, shared_memory_offset_);
+ memcpy(shared_memory_address_, &client_id, sizeof(client_id));
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+}
+
+void GLES2DecoderWithShaderTestBase::DoDeleteProgram(
+ GLuint client_id, GLuint service_id) {
+ EXPECT_CALL(*gl_, DeleteProgram(service_id))
+ .Times(1)
+ .RetiresOnSaturation();
+ DeleteProgram cmd;
+ cmd.Init(client_id);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+}
+
+void GLES2DecoderWithShaderTestBase::DoVertexAttribPointer(
+ GLuint index, GLint size, GLenum type, GLsizei stride, GLuint offset) {
+ EXPECT_CALL(*gl_,
+ VertexAttribPointer(index, size, type, GL_FALSE, stride,
+ BufferOffset(offset)))
+ .Times(1)
+ .RetiresOnSaturation();
+ VertexAttribPointer cmd;
+ cmd.Init(index, size, GL_FLOAT, GL_FALSE, stride, offset);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+}
+
+void GLES2DecoderWithShaderTestBase::SetupVertexBuffer() {
+ DoEnableVertexAttribArray(1);
+ DoBindBuffer(GL_ARRAY_BUFFER, client_buffer_id_, kServiceBufferId);
+ GLfloat f = 0;
+ DoBufferData(GL_ARRAY_BUFFER, kNumVertices * 2 * sizeof(f));
+}
+
+void GLES2DecoderWithShaderTestBase::SetupIndexBuffer() {
+ DoBindBuffer(GL_ELEMENT_ARRAY_BUFFER,
+ client_element_buffer_id_,
+ kServiceElementBufferId);
+ static const GLshort indices[] = {100, 1, 2, 3, 4, 5, 6, 7, 100, 9};
+ COMPILE_ASSERT(arraysize(indices) == kNumIndices, Indices_is_not_10);
+ DoBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(indices));
+ DoBufferSubData(GL_ELEMENT_ARRAY_BUFFER, 0, sizeof(indices), indices);
+}
+
+void GLES2DecoderWithShaderTestBase::SetupTexture() {
+ DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId);
+ DoTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE,
+ 0, 0);
+};
+
+void GLES2DecoderWithShaderTestBase::DeleteVertexBuffer() {
+ DoDeleteBuffer(client_buffer_id_, kServiceBufferId);
+}
+
+void GLES2DecoderWithShaderTestBase::DeleteIndexBuffer() {
+ DoDeleteBuffer(client_element_buffer_id_, kServiceElementBufferId);
+}
+
+const char* GLES2DecoderWithShaderTestBase::kAttrib1Name = "attrib1";
+const char* GLES2DecoderWithShaderTestBase::kAttrib2Name = "attrib2";
+const char* GLES2DecoderWithShaderTestBase::kAttrib3Name = "attrib3";
+const char* GLES2DecoderWithShaderTestBase::kUniform1Name = "uniform1";
+const char* GLES2DecoderWithShaderTestBase::kUniform2Name = "uniform2";
+const char* GLES2DecoderWithShaderTestBase::kUniform3Name = "uniform3";
+
+} // namespace gles2
+} // namespace gpu
+
+
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.h b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.h
new file mode 100644
index 0000000..c732a2c
--- /dev/null
+++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.h
@@ -0,0 +1,310 @@
+// 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.
+
+#ifndef GPU_COMMAND_BUFFER_SERVICE_GLES2_CMD_DECODER_UNITTEST_BASE_H_
+#define GPU_COMMAND_BUFFER_SERVICE_GLES2_CMD_DECODER_UNITTEST_BASE_H_
+
+#include "gpu/command_buffer/common/gles2_cmd_format.h"
+#include "gpu/command_buffer/common/gles2_cmd_utils.h"
+#include "gpu/command_buffer/service/cmd_buffer_engine.h"
+#include "gpu/command_buffer/service/context_group.h"
+#include "gpu/command_buffer/service/gl_mock.h"
+#include "gpu/command_buffer/service/gles2_cmd_decoder.h"
+#include "gpu/command_buffer/service/program_manager.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace gpu {
+namespace gles2 {
+
+class GLES2DecoderTestBase : public testing::Test {
+ public:
+ GLES2DecoderTestBase()
+ : client_buffer_id_(100),
+ client_framebuffer_id_(101),
+ client_program_id_(102),
+ client_renderbuffer_id_(103),
+ client_shader_id_(104),
+ client_texture_id_(105),
+ client_element_buffer_id_(106) {
+ memset(immediate_buffer_, 0xEE, sizeof(immediate_buffer_));
+ }
+
+ protected:
+ static const GLint kMaxTextureSize = 2048;
+ static const GLint kMaxCubeMapTextureSize = 256;
+ static const GLint kNumVertexAttribs = 16;
+ static const GLint kNumTextureUnits = 8;
+
+ static const GLuint kServiceBlackTexture2dId = 701;
+ static const GLuint kServiceBlackTextureCubemapId = 702;
+
+ 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 GLuint kServiceElementBufferId = 307;
+
+ 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 kInitialResult = 0xBDBDBDBDu;
+ static const uint8 kInitialMemoryValue = 0xBDu;
+
+ 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(error::kNoError,
+ 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) {
+ return reinterpret_cast<T>(ImmediateDataAddress(cmd));
+ }
+
+ void ClearSharedMemory() {
+ engine_->ClearSharedMemory();
+ }
+
+ virtual void SetUp();
+ virtual void TearDown();
+
+ template <typename T>
+ error::Error ExecuteCmd(const T& cmd) {
+ COMPILE_ASSERT(T::kArgFlags == cmd::kFixed, Cmd_kArgFlags_not_kFixed);
+ return decoder_->DoCommand(cmd.kCmdId,
+ ComputeNumEntries(sizeof(cmd)) - 1,
+ &cmd);
+ }
+
+ template <typename T>
+ error::Error 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);
+ }
+
+ template <typename T>
+ T GetSharedMemoryAs() {
+ return reinterpret_cast<T>(shared_memory_address_);
+ }
+
+ template <typename T>
+ T GetSharedMemoryAsWithOffset(uint32 offset) {
+ void* ptr = reinterpret_cast<int8*>(shared_memory_address_) + offset;
+ return reinterpret_cast<T>(ptr);
+ }
+
+ uint32 GetServiceId(uint32 client_id) {
+ return decoder_->GetServiceIdForTesting(client_id);
+ }
+
+ // Note that the error is returned as GLint instead of GLenum.
+ // This is because there is a mismatch in the types of GLenum and
+ // the error values GL_NO_ERROR, GL_INVALID_ENUM, etc. GLenum is
+ // typedef'd as unsigned int while the error values are defined as
+ // integers. This is problematic for template functions such as
+ // EXPECT_EQ that expect both types to be the same.
+ GLint GetGLError();
+
+ void DoBindTexture(GLenum target, GLuint client_id, GLuint service_id);
+
+ void DoTexImage2D(GLenum target, GLint level, GLenum internal_format,
+ GLsizei width, GLsizei height, GLint border,
+ GLenum format, GLenum type,
+ uint32 shared_memory_id, uint32 shared_memory_offset);
+
+ // Use StrictMock to make 100% sure we know how GL will be called.
+ scoped_ptr<::testing::StrictMock<::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_;
+ GLuint client_element_buffer_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]);
+ ClearSharedMemory();
+ 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 ClearSharedMemory() {
+ memset(data_.get(), kInitialMemoryValue, kSharedBufferSize);
+ }
+
+ void set_token(int32 token) {
+ DCHECK(false);
+ }
+
+ // Overridden from CommandBufferEngine.
+ virtual bool SetGetOffset(int32 offset) {
+ DCHECK(false);
+ return false;
+ }
+
+ // Overridden from CommandBufferEngine.
+ virtual int32 GetGetOffset() {
+ DCHECK(false);
+ return 0;
+ }
+
+ private:
+ scoped_array<int8> data_;
+ Buffer valid_buffer_;
+ Buffer invalid_buffer_;
+ };
+
+ scoped_ptr<::testing::StrictMock<MockCommandBufferEngine> > engine_;
+ ContextGroup group_;
+};
+
+class GLES2DecoderWithShaderTestBase : public GLES2DecoderTestBase {
+ public:
+ GLES2DecoderWithShaderTestBase()
+ : GLES2DecoderTestBase() {
+ }
+
+ static const GLsizei kNumVertices = 100;
+ static const GLsizei kNumIndices = 10;
+ static const int kValidIndexRangeStart = 1;
+ static const int kValidIndexRangeCount = 7;
+ static const int kInvalidIndexRangeStart = 0;
+ static const int kInvalidIndexRangeCount = 7;
+ static const int kOutOfRangeIndexRangeEnd = 10;
+
+ static const GLint kMaxAttribLength = 10;
+ static const char* kAttrib1Name;
+ static const char* kAttrib2Name;
+ static const char* kAttrib3Name;
+ static const GLint kAttrib1Size = 1;
+ static const GLint kAttrib2Size = 1;
+ static const GLint kAttrib3Size = 1;
+ static const GLint kAttrib1Location = 0;
+ static const GLint kAttrib2Location = 1;
+ static const GLint kAttrib3Location = 2;
+ static const GLenum kAttrib1Type = GL_FLOAT_VEC4;
+ static const GLenum kAttrib2Type = GL_FLOAT_VEC2;
+ static const GLenum kAttrib3Type = GL_FLOAT_VEC3;
+ static const GLint kInvalidAttribLocation = 30;
+ static const GLint kBadAttribIndex = kNumVertexAttribs;
+
+ static const GLint kMaxUniformLength = 10;
+ static const char* kUniform1Name;
+ static const char* kUniform2Name;
+ static const char* kUniform3Name;
+ static const GLint kUniform1Size = 1;
+ static const GLint kUniform2Size = 3;
+ static const GLint kUniform3Size = 2;
+ static const GLint kUniform1Location = 3;
+ static const GLint kUniform2Location = 10;
+ static const GLint kUniform2ElementLocation = 12;
+ static const GLint kUniform3Location = 20;
+ static const GLenum kUniform1Type = GL_SAMPLER_2D;
+ static const GLenum kUniform2Type = GL_INT_VEC2;
+ static const GLenum kUniform3Type = GL_FLOAT_VEC3;
+ static const GLint kInvalidUniformLocation = 30;
+ static const GLint kBadUniformIndex = 1000;
+
+ protected:
+ struct AttribInfo {
+ const char* name;
+ GLint size;
+ GLenum type;
+ GLint location;
+ };
+
+ struct UniformInfo {
+ const char* name;
+ GLint size;
+ GLenum type;
+ GLint location;
+ };
+
+ virtual void SetUp();
+ virtual void TearDown();
+
+ void SetupShader(AttribInfo* attribs, size_t num_attribs,
+ UniformInfo* uniforms, size_t num_uniforms,
+ GLuint client_id, GLuint service_id);
+
+ void SetupTexture();
+
+ GLvoid* BufferOffset(unsigned i) {
+ return static_cast<int8 *>(NULL)+(i);
+ }
+
+ void DoEnableVertexAttribArray(GLint index);
+
+ void DoBindBuffer(GLenum target, GLuint client_id, GLuint service_id);
+
+ void DoBufferData(GLenum target, GLsizei size);
+
+ void DoBufferSubData(
+ GLenum target, GLint offset, GLsizei size, const void* data);
+
+ void DoDeleteBuffer(GLuint client_id, GLuint service_id);
+
+ void DoDeleteProgram(GLuint client_id, GLuint service_id);
+
+ void DoVertexAttribPointer(
+ GLuint index, GLint size, GLenum type, GLsizei stride, GLuint offset);
+
+ void SetupVertexBuffer();
+
+ void SetupIndexBuffer();
+
+ void DeleteVertexBuffer();
+
+ void DeleteIndexBuffer();
+};
+
+} // namespace gles2
+} // namespace gpu
+
+#endif // GPU_COMMAND_BUFFER_SERVICE_GLES2_CMD_DECODER_UNITTEST_BASE_H_
+
diff --git a/gpu/command_buffer/service/gpu_processor.cc b/gpu/command_buffer/service/gpu_processor.cc
index e72ed06..7a748e7 100644
--- a/gpu/command_buffer/service/gpu_processor.cc
+++ b/gpu/command_buffer/service/gpu_processor.cc
@@ -14,7 +14,7 @@ GPUProcessor::GPUProcessor(CommandBuffer* command_buffer)
: command_buffer_(command_buffer),
commands_per_update_(100) {
DCHECK(command_buffer);
- decoder_.reset(gles2::GLES2Decoder::Create());
+ decoder_.reset(gles2::GLES2Decoder::Create(&group_));
decoder_->set_engine(this);
}
diff --git a/gpu/command_buffer/service/gpu_processor.h b/gpu/command_buffer/service/gpu_processor.h
index 4b82374..6cad98d 100644
--- a/gpu/command_buffer/service/gpu_processor.h
+++ b/gpu/command_buffer/service/gpu_processor.h
@@ -13,6 +13,7 @@
#include "gpu/command_buffer/common/command_buffer.h"
#include "gpu/command_buffer/service/cmd_buffer_engine.h"
#include "gpu/command_buffer/service/cmd_parser.h"
+#include "gpu/command_buffer/service/context_group.h"
#include "gpu/command_buffer/service/gles2_cmd_decoder.h"
namespace gpu {
@@ -73,6 +74,7 @@ class GPUProcessor : public base::RefCounted<GPUProcessor>,
scoped_ptr< ::base::SharedMemory> mapped_ring_buffer_;
int commands_per_update_;
+ gles2::ContextGroup group_;
scoped_ptr<gles2::GLES2Decoder> decoder_;
scoped_ptr<CommandParser> parser_;
};
diff --git a/gpu/command_buffer/service/gpu_processor_unittest.cc b/gpu/command_buffer/service/gpu_processor_unittest.cc
index a71905c..51cfe01 100644
--- a/gpu/command_buffer/service/gpu_processor_unittest.cc
+++ b/gpu/command_buffer/service/gpu_processor_unittest.cc
@@ -6,10 +6,11 @@
#include "base/message_loop.h"
#include "base/scoped_nsautorelease_pool.h"
#include "gpu/command_buffer/common/command_buffer_mock.h"
-#include "gpu/command_buffer/service/mocks.h"
+#include "gpu/command_buffer/service/context_group.h"
#include "gpu/command_buffer/service/gpu_processor.h"
#include "gpu/command_buffer/service/gles2_cmd_decoder.h"
#include "gpu/command_buffer/service/gles2_cmd_decoder_mock.h"
+#include "gpu/command_buffer/service/mocks.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "testing/gmock/include/gmock/gmock.h"
@@ -48,7 +49,7 @@ class GPUProcessorTest : public testing::Test {
async_api_.reset(new StrictMock<AsyncAPIMock>);
- decoder_ = new gles2::MockGLES2Decoder();
+ decoder_ = new gles2::MockGLES2Decoder(&group_);
parser_ = new CommandParser(buffer_,
kRingBufferEntries,
@@ -80,6 +81,7 @@ class GPUProcessorTest : public testing::Test {
scoped_ptr<base::SharedMemory> shared_memory_;
Buffer shared_memory_buffer_;
int32* buffer_;
+ gles2::ContextGroup group_;
gles2::MockGLES2Decoder* decoder_;
CommandParser* parser_;
scoped_ptr<AsyncAPIMock> async_api_;
diff --git a/gpu/command_buffer/service/id_manager.h b/gpu/command_buffer/service/id_manager.h
index 5c5f603..9d439be 100644
--- a/gpu/command_buffer/service/id_manager.h
+++ b/gpu/command_buffer/service/id_manager.h
@@ -18,7 +18,7 @@ namespace gles2 {
// need to be shared by multiple GLES2Decoders.
class IdManager {
public:
- IdManager() { };
+ IdManager() { }
// Maps a client_id to a service_id. Return false if the client_id or
// service_id are already mapped to something else.
diff --git a/gpu/command_buffer/service/program_manager.cc b/gpu/command_buffer/service/program_manager.cc
index ade12e2..b53938f 100644
--- a/gpu/command_buffer/service/program_manager.cc
+++ b/gpu/command_buffer/service/program_manager.cc
@@ -7,6 +7,7 @@
#include "base/logging.h"
#include "base/scoped_ptr.h"
#include "base/string_util.h"
+#include "gpu/command_buffer/service/gles2_cmd_decoder.h"
namespace gpu {
namespace gles2 {
@@ -20,9 +21,9 @@ bool ProgramManager::IsInvalidPrefix(const char* name, size_t length) {
void ProgramManager::ProgramInfo::Update() {
GLint num_attribs = 0;
GLint max_len = 0;
- glGetProgramiv(program_, GL_ACTIVE_ATTRIBUTES, &num_attribs);
- SetNumAttributes(num_attribs);
- glGetProgramiv(program_, GL_ACTIVE_ATTRIBUTE_MAX_LENGTH, &max_len);
+ glGetProgramiv(program_id_, GL_ACTIVE_ATTRIBUTES, &num_attribs);
+ attrib_infos_.resize(num_attribs);
+ glGetProgramiv(program_id_, GL_ACTIVE_ATTRIBUTE_MAX_LENGTH, &max_len);
// TODO(gman): Should we check for error?
scoped_array<char> name_buffer(new char[max_len]);
for (GLint ii = 0; ii < num_attribs; ++ii) {
@@ -30,27 +31,49 @@ void ProgramManager::ProgramInfo::Update() {
GLsizei size;
GLenum type;
glGetActiveAttrib(
- program_, ii, max_len, &length, &size, &type, name_buffer.get());
+ program_id_, ii, max_len, &length, &size, &type, name_buffer.get());
// TODO(gman): Should we check for error?
GLint location = IsInvalidPrefix(name_buffer.get(), length) ? -1 :
- glGetAttribLocation(program_, name_buffer.get());
+ glGetAttribLocation(program_id_, name_buffer.get());
SetAttributeInfo(ii, size, type, location, name_buffer.get());
}
GLint num_uniforms;
- glGetProgramiv(program_, GL_ACTIVE_UNIFORMS, &num_uniforms);
- SetNumUniforms(num_uniforms);
- glGetProgramiv(program_, GL_ACTIVE_UNIFORM_MAX_LENGTH, &max_len);
+ glGetProgramiv(program_id_, GL_ACTIVE_UNIFORMS, &num_uniforms);
+ uniform_infos_.resize(num_uniforms);
+ sampler_indices_.clear();
+ glGetProgramiv(program_id_, GL_ACTIVE_UNIFORM_MAX_LENGTH, &max_len);
name_buffer.reset(new char[max_len]);
+ GLint max_location = -1;
for (GLint ii = 0; ii < num_uniforms; ++ii) {
GLsizei length;
GLsizei size;
GLenum type;
glGetActiveUniform(
- program_, ii, max_len, &length, &size, &type, name_buffer.get());
+ program_id_, ii, max_len, &length, &size, &type, name_buffer.get());
// TODO(gman): Should we check for error?
GLint location = IsInvalidPrefix(name_buffer.get(), length) ? -1 :
- glGetUniformLocation(program_, name_buffer.get());
+ glGetUniformLocation(program_id_, name_buffer.get());
SetUniformInfo(ii, size, type, location, name_buffer.get());
+ const UniformInfo& info = uniform_infos_[ii];
+ for (size_t jj = 0; jj < info.element_locations.size(); ++jj) {
+ if (info.element_locations[jj] > max_location) {
+ max_location = info.element_locations[jj];
+ }
+ }
+ if (info.IsSampler()) {
+ sampler_indices_.push_back(ii);
+ }
+ }
+ // Create location to index map.
+ location_to_index_map_.resize(max_location + 1);
+ for (GLint ii = 0; ii <= max_location; ++ii) {
+ location_to_index_map_[ii] = -1;
+ }
+ for (GLint ii = 0; ii < num_uniforms; ++ii) {
+ const UniformInfo& info = uniform_infos_[ii];
+ for (size_t jj = 0; jj < info.element_locations.size(); ++jj) {
+ location_to_index_map_[info.element_locations[jj]] = ii;
+ }
}
}
@@ -96,13 +119,12 @@ GLint ProgramManager::ProgramInfo::GetAttribLocation(
bool ProgramManager::ProgramInfo::GetUniformTypeByLocation(
GLint location, GLenum* type) const {
- for (GLuint ii = 0; ii < uniform_infos_.size(); ++ii) {
- const UniformInfo& info = uniform_infos_[ii];
- for (GLsizei jj = 0; jj < info.size; ++jj) {
- if (info.element_locations[jj] == location) {
- *type = info.type;
- return true;
- }
+ if (location >= 0 &&
+ static_cast<size_t>(location) < location_to_index_map_.size()) {
+ GLint index = location_to_index_map_[location];
+ if (index >= 0) {
+ *type = uniform_infos_[index].type;
+ return true;
}
}
return false;
@@ -118,6 +140,10 @@ void ProgramManager::ProgramInfo::SetUniformInfo(
info.name = name;
info.element_locations.resize(size);
info.element_locations[0] = location;
+ size_t num_texture_units = info.IsSampler() ? size : 0u;
+ info.texture_units.clear();
+ info.texture_units.resize(num_texture_units, 0);
+
// Go through the array element locations looking for a match.
// We can skip the first element because it's the same as the
// the location without the array operators.
@@ -125,26 +151,44 @@ void ProgramManager::ProgramInfo::SetUniformInfo(
for (GLsizei ii = 1; ii < info.size; ++ii) {
std::string element_name(name + "[" + IntToString(ii) + "]");
info.element_locations[ii] =
- glGetUniformLocation(program_, element_name.c_str());
+ glGetUniformLocation(program_id_, element_name.c_str());
+ }
+ }
+}
+
+bool ProgramManager::ProgramInfo::SetSamplers(
+ GLint location, GLsizei count, const GLint* value) {
+ if (location >= 0 &&
+ static_cast<size_t>(location) < location_to_index_map_.size()) {
+ GLint index = location_to_index_map_[location];
+ if (index >= 0) {
+ UniformInfo& info = uniform_infos_[index];
+ if (info.IsSampler() && count <= info.size) {
+ std::copy(value, value + count, info.texture_units.begin());
+ return true;
+ }
}
}
+ return false;
}
-void ProgramManager::CreateProgramInfo(GLuint program) {
+void ProgramManager::CreateProgramInfo(GLuint program_id) {
std::pair<ProgramInfoMap::iterator, bool> result =
program_infos_.insert(
- std::make_pair(program, ProgramInfo(program)));
+ std::make_pair(program_id,
+ ProgramInfo::Ref(new ProgramInfo(program_id))));
DCHECK(result.second);
}
-ProgramManager::ProgramInfo* ProgramManager::GetProgramInfo(GLuint program) {
- ProgramInfoMap::iterator it = program_infos_.find(program);
- return it != program_infos_.end() ? &it->second : NULL;
+ProgramManager::ProgramInfo* ProgramManager::GetProgramInfo(GLuint program_id) {
+ ProgramInfoMap::iterator it = program_infos_.find(program_id);
+ return it != program_infos_.end() ? it->second : NULL;
}
-void ProgramManager::RemoveProgramInfo(GLuint program) {
- ProgramInfoMap::iterator it = program_infos_.find(program);
+void ProgramManager::RemoveProgramInfo(GLuint program_id) {
+ ProgramInfoMap::iterator it = program_infos_.find(program_id);
if (it != program_infos_.end()) {
+ it->second->MarkAsDeleted();
program_infos_.erase(it);
}
}
diff --git a/gpu/command_buffer/service/program_manager.h b/gpu/command_buffer/service/program_manager.h
index ec4fa21..47a1927 100644
--- a/gpu/command_buffer/service/program_manager.h
+++ b/gpu/command_buffer/service/program_manager.h
@@ -10,6 +10,7 @@
#include <vector>
#include "base/basictypes.h"
#include "base/logging.h"
+#include "base/ref_counted.h"
#include "gpu/command_buffer/service/gl_utils.h"
namespace gpu {
@@ -24,13 +25,20 @@ class ProgramManager {
// This is used to track which attributes a particular program needs
// so we can verify at glDrawXXX time that every attribute is either disabled
// or if enabled that it points to a valid source.
- class ProgramInfo {
+ class ProgramInfo : public base::RefCounted<ProgramInfo> {
public:
+ typedef scoped_refptr<ProgramInfo> Ref;
+
struct UniformInfo {
+ bool IsSampler() const {
+ return type == GL_SAMPLER_2D || type == GL_SAMPLER_CUBE;
+ }
+
GLsizei size;
GLenum type;
std::string name;
std::vector<GLint> element_locations;
+ std::vector<GLuint> texture_units;
};
struct VertexAttribInfo {
GLsizei size;
@@ -41,9 +49,14 @@ class ProgramManager {
typedef std::vector<UniformInfo> UniformInfoVector;
typedef std::vector<VertexAttribInfo> AttribInfoVector;
+ typedef std::vector<int> SamplerIndices;
+
+ explicit ProgramInfo(GLuint program_id)
+ : program_id_(program_id) {
+ }
- explicit ProgramInfo(GLuint program)
- : program_(program) {
+ const SamplerIndices& sampler_indices() {
+ return sampler_indices_;
}
void Update();
@@ -64,13 +77,29 @@ class ProgramManager {
&uniform_infos_[index] : NULL;
}
+ // Gets the location of a uniform by name.
GLint GetUniformLocation(const std::string& name);
+ // Gets the type of a uniform by location.
bool GetUniformTypeByLocation(GLint location, GLenum* type) const;
+ // Sets the sampler values for a uniform.
+ // This is safe to call for any location. If the location is not
+ // a sampler uniform nothing will happen.
+ bool SetSamplers(GLint location, GLsizei count, const GLint* value);
+
+ bool IsDeleted() {
+ return program_id_ == 0;
+ }
+
private:
- void SetNumAttributes(int num_attribs) {
- attrib_infos_.resize(num_attribs);
+ friend class base::RefCounted<ProgramInfo>;
+ friend class ProgramManager;
+
+ ~ProgramInfo() { }
+
+ void MarkAsDeleted() {
+ program_id_ = 0;
}
void SetAttributeInfo(
@@ -84,33 +113,35 @@ class ProgramManager {
info.location = location;
}
- void SetNumUniforms(int num_uniforms) {
- uniform_infos_.resize(num_uniforms);
- }
-
void SetUniformInfo(
GLint index, GLsizei size, GLenum type, GLint location,
const std::string& name);
AttribInfoVector attrib_infos_;
- // Uniform info by info.
+ // Uniform info by index.
UniformInfoVector uniform_infos_;
+ // Uniform location to index.
+ std::vector<GLint> location_to_index_map_;
+
+ // The indices of the uniforms that are samplers.
+ SamplerIndices sampler_indices_;
+
// The program this ProgramInfo is tracking.
- GLuint program_;
+ GLuint program_id_;
};
- ProgramManager() { };
+ ProgramManager() { }
// Creates a new program info.
- void CreateProgramInfo(GLuint program);
+ void CreateProgramInfo(GLuint program_id);
// Gets a program info
- ProgramInfo* GetProgramInfo(GLuint program);
+ ProgramInfo* GetProgramInfo(GLuint program_id);
// Deletes the program info for the given program.
- void RemoveProgramInfo(GLuint program);
+ void RemoveProgramInfo(GLuint program_id);
// Returns true if prefix is invalid for gl.
static bool IsInvalidPrefix(const char* name, size_t length);
@@ -118,7 +149,7 @@ class ProgramManager {
private:
// Info for each "successfully linked" program by service side program Id.
// TODO(gman): Choose a faster container.
- typedef std::map<GLuint, ProgramInfo> ProgramInfoMap;
+ typedef std::map<GLuint, ProgramInfo::Ref> ProgramInfoMap;
ProgramInfoMap program_infos_;
DISALLOW_COPY_AND_ASSIGN(ProgramManager);
diff --git a/gpu/command_buffer/service/program_manager_unittest.cc b/gpu/command_buffer/service/program_manager_unittest.cc
index af03f1c..0647884 100644
--- a/gpu/command_buffer/service/program_manager_unittest.cc
+++ b/gpu/command_buffer/service/program_manager_unittest.cc
@@ -25,13 +25,15 @@ namespace gles2 {
class ProgramManagerTest : public testing::Test {
public:
- ProgramManagerTest() {
- }
+ ProgramManagerTest() { }
protected:
virtual void SetUp() {
}
+ virtual void TearDown() {
+ }
+
ProgramManager manager_;
};
diff --git a/gpu/command_buffer/service/shader_manager.cc b/gpu/command_buffer/service/shader_manager.cc
index 0d6fa19..0daa0dc 100644
--- a/gpu/command_buffer/service/shader_manager.cc
+++ b/gpu/command_buffer/service/shader_manager.cc
@@ -8,20 +8,22 @@
namespace gpu {
namespace gles2 {
-void ShaderManager::CreateShaderInfo(GLuint shader) {
+void ShaderManager::CreateShaderInfo(GLuint shader_id) {
std::pair<ShaderInfoMap::iterator, bool> result =
- shader_infos_.insert(std::make_pair(shader, ShaderInfo(shader)));
+ shader_infos_.insert(std::make_pair(
+ shader_id, ShaderInfo::Ref(new ShaderInfo(shader_id))));
DCHECK(result.second);
}
-ShaderManager::ShaderInfo* ShaderManager::GetShaderInfo(GLuint shader) {
- ShaderInfoMap::iterator it = shader_infos_.find(shader);
- return it != shader_infos_.end() ? &it->second : NULL;
+ShaderManager::ShaderInfo* ShaderManager::GetShaderInfo(GLuint shader_id) {
+ ShaderInfoMap::iterator it = shader_infos_.find(shader_id);
+ return it != shader_infos_.end() ? it->second : NULL;
}
-void ShaderManager::RemoveShaderInfo(GLuint shader) {
- ShaderInfoMap::iterator it = shader_infos_.find(shader);
+void ShaderManager::RemoveShaderInfo(GLuint shader_id) {
+ ShaderInfoMap::iterator it = shader_infos_.find(shader_id);
if (it != shader_infos_.end()) {
+ it->second->MarkAsDeleted();
shader_infos_.erase(it);
}
}
diff --git a/gpu/command_buffer/service/shader_manager.h b/gpu/command_buffer/service/shader_manager.h
index 833117b..f9529e9 100644
--- a/gpu/command_buffer/service/shader_manager.h
+++ b/gpu/command_buffer/service/shader_manager.h
@@ -8,6 +8,7 @@
#include <map>
#include <string>
#include "base/basictypes.h"
+#include "base/ref_counted.h"
#include "gpu/command_buffer/service/gl_utils.h"
namespace gpu {
@@ -23,10 +24,12 @@ class ShaderManager {
// to emluate GLES2 the shaders will have to be re-written before passed to
// the underlying OpenGL. But, when the user calls glGetShaderSource they
// should get the source they passed in, not the re-written source.
- class ShaderInfo {
+ class ShaderInfo : public base::RefCounted<ShaderInfo> {
public:
- explicit ShaderInfo(GLuint shader)
- : shader_(shader) {
+ typedef scoped_refptr<ShaderInfo> Ref;
+
+ explicit ShaderInfo(GLuint shader_id)
+ : shader_id_(shader_id) {
}
void Update(const std::string& source) {
@@ -37,29 +40,42 @@ class ShaderManager {
return source_;
}
+ bool IsDeleted() {
+ return shader_id_ == 0;
+ }
+
private:
+ friend class base::RefCounted<ShaderInfo>;
+ friend class ShaderManager;
+ ~ShaderInfo() { }
+
+ void MarkAsDeleted() {
+ shader_id_ = 0;
+ }
+
// The shader this ShaderInfo is tracking.
- GLuint shader_;
+ GLuint shader_id_;
// The shader source as passed to glShaderSource.
std::string source_;
};
- ShaderManager() { };
+ ShaderManager() {
+ }
// Creates a shader info for the given shader ID.
- void CreateShaderInfo(GLuint shader);
+ void CreateShaderInfo(GLuint shader_id);
// Gets an existing shader info for the given shader ID. Returns NULL if none
// exists.
- ShaderInfo* GetShaderInfo(GLuint shader);
+ ShaderInfo* GetShaderInfo(GLuint shader_id);
// Deletes the shader info for the given shader.
- void RemoveShaderInfo(GLuint shader);
+ void RemoveShaderInfo(GLuint shader_id);
private:
// Info for each shader by service side shader Id.
- typedef std::map<GLuint, ShaderInfo> ShaderInfoMap;
+ typedef std::map<GLuint, ShaderInfo::Ref> ShaderInfoMap;
ShaderInfoMap shader_infos_;
DISALLOW_COPY_AND_ASSIGN(ShaderManager);
diff --git a/gpu/command_buffer/service/texture_manager.cc b/gpu/command_buffer/service/texture_manager.cc
index 1496f88..a2f72bb 100644
--- a/gpu/command_buffer/service/texture_manager.cc
+++ b/gpu/command_buffer/service/texture_manager.cc
@@ -4,6 +4,8 @@
#include "gpu/command_buffer/service/texture_manager.h"
#include "base/bits.h"
+#include "gpu/command_buffer/service/context_group.h"
+#include "gpu/command_buffer/service/gles2_cmd_decoder.h"
namespace gpu {
namespace gles2 {
@@ -55,8 +57,31 @@ static size_t FaceIndexToGLTarget(size_t index) {
}
}
-void TextureManager::TextureInfo::MarkMipmapsGenerated() {
- DCHECK(CanGenerateMipmaps());
+bool TextureManager::TextureInfo::CanRender() const {
+ if (target_ == 0 || IsDeleted()) {
+ return false;
+ }
+ bool needs_mips = NeedsMips();
+ if (npot()) {
+ return !needs_mips &&
+ wrap_s_ == GL_CLAMP_TO_EDGE &&
+ wrap_t_ == GL_CLAMP_TO_EDGE;
+ }
+ if (needs_mips) {
+ if (target_ == GL_TEXTURE_2D) {
+ return texture_complete();
+ } else {
+ return texture_complete() && cube_complete();
+ }
+ } else {
+ return true;
+ }
+}
+
+bool TextureManager::TextureInfo::MarkMipmapsGenerated() {
+ if (!CanGenerateMipmaps()) {
+ return false;
+ }
for (size_t ii = 0; ii < level_infos_.size(); ++ii) {
const TextureInfo::LevelInfo& info1 = level_infos_[ii][0];
GLsizei width = info1.width;
@@ -79,10 +104,11 @@ void TextureManager::TextureInfo::MarkMipmapsGenerated() {
info1.type);
}
}
+ return true;
}
bool TextureManager::TextureInfo::CanGenerateMipmaps() const {
- if (npot()) {
+ if (npot() || level_infos_.empty()) {
return false;
}
const TextureInfo::LevelInfo& first = level_infos_[0][0];
@@ -134,6 +160,26 @@ void TextureManager::TextureInfo::SetLevelInfo(
Update();
}
+void TextureManager::TextureInfo::SetParameter(GLenum pname, GLint param) {
+ switch (pname) {
+ case GL_TEXTURE_MIN_FILTER:
+ min_filter_ = param;
+ break;
+ case GL_TEXTURE_MAG_FILTER:
+ mag_filter_ = param;
+ break;
+ case GL_TEXTURE_WRAP_S:
+ wrap_s_ = param;
+ break;
+ case GL_TEXTURE_WRAP_T:
+ wrap_t_ = param;
+ break;
+ default:
+ NOTREACHED();
+ break;
+ }
+}
+
void TextureManager::TextureInfo::Update() {
// Update npot status.
npot_ = false;
@@ -194,7 +240,8 @@ void TextureManager::TextureInfo::Update() {
}
TextureManager::TextureManager(
- GLint max_texture_size, GLint max_cube_map_texture_size)
+ GLint max_texture_size,
+ GLint max_cube_map_texture_size)
: max_texture_size_(max_texture_size),
max_cube_map_texture_size_(max_cube_map_texture_size),
max_levels_(ComputeMipMapCount(max_texture_size,
@@ -205,22 +252,26 @@ TextureManager::TextureManager(
max_cube_map_texture_size)) {
}
-void TextureManager::CreateTextureInfo(GLuint texture) {
- TextureInfo* info = new TextureInfo(texture);
+void TextureManager::CreateTextureInfo(GLuint texture_id) {
std::pair<TextureInfoMap::iterator, bool> result =
texture_infos_.insert(
- std::make_pair(texture, linked_ptr<TextureInfo>(info)));
+ std::make_pair(texture_id,
+ TextureInfo::Ref(new TextureInfo(texture_id))));
DCHECK(result.second);
}
TextureManager::TextureInfo* TextureManager::GetTextureInfo(
- GLuint texture) {
- TextureInfoMap::iterator it = texture_infos_.find(texture);
- return it != texture_infos_.end() ? &(*it->second) : NULL;
+ GLuint texture_id) {
+ TextureInfoMap::iterator it = texture_infos_.find(texture_id);
+ return it != texture_infos_.end() ? it->second : NULL;
}
void TextureManager::RemoveTextureInfo(GLuint texture_id) {
- texture_infos_.erase(texture_id);
+ TextureInfoMap::iterator it = texture_infos_.find(texture_id);
+ if (it != texture_infos_.end()) {
+ it->second->MarkAsDeleted();
+ texture_infos_.erase(texture_id);
+ }
}
} // namespace gles2
diff --git a/gpu/command_buffer/service/texture_manager.h b/gpu/command_buffer/service/texture_manager.h
index efb08f0..6407721 100644
--- a/gpu/command_buffer/service/texture_manager.h
+++ b/gpu/command_buffer/service/texture_manager.h
@@ -8,7 +8,8 @@
#include <map>
#include <vector>
#include "base/basictypes.h"
-#include "base/linked_ptr.h"
+#include "base/logging.h"
+#include "base/ref_counted.h"
#include "gpu/command_buffer/service/gl_utils.h"
namespace gpu {
@@ -22,21 +23,36 @@ namespace gles2 {
class TextureManager {
public:
// Info about Textures currently in the system.
- class TextureInfo {
+ class TextureInfo : public base::RefCounted<TextureInfo> {
public:
- explicit TextureInfo(GLuint texture)
- : texture_(texture),
+ typedef scoped_refptr<TextureInfo> Ref;
+
+ explicit TextureInfo(GLuint texture_id)
+ : texture_id_(texture_id),
target_(0),
+ min_filter_(GL_NEAREST_MIPMAP_LINEAR),
+ mag_filter_(GL_LINEAR),
+ wrap_s_(GL_REPEAT),
+ wrap_t_(GL_REPEAT),
max_level_set_(-1),
texture_complete_(false),
cube_complete_(false),
npot_(false) {
}
+ // True if this texture meets all the GLES2 criteria for rendering.
+ // See section 3.8.2 of the GLES2 spec.
+ bool CanRender() const;
+
+ // The service side OpenGL id of the texture.
+ GLuint texture_id() const {
+ return texture_id_;
+ }
+
// Returns the target this texure was first bound to or 0 if it has not
// been bound. Once a texture is bound to a specific target it can never be
// bound to a different target.
- GLenum target() {
+ GLenum target() const {
return target_;
}
@@ -62,7 +78,7 @@ class TextureManager {
bool CanGenerateMipmaps() const;
// Makes each of the mip levels as though they were generated.
- void MarkMipmapsGenerated();
+ bool MarkMipmapsGenerated();
// Set the info for a particular level.
void SetLevelInfo(
@@ -76,8 +92,19 @@ class TextureManager {
GLenum format,
GLenum type);
+ // Sets a texture parameter.
+ // TODO(gman): Expand to SetParameteri,f,iv,fv
+ void SetParameter(GLenum pname, GLint param);
+
+ bool IsDeleted() const {
+ return texture_id_ == 0;
+ }
+
private:
friend class TextureManager;
+ friend class base::RefCounted<TextureInfo>;
+
+ ~TextureInfo() { }
struct LevelInfo {
LevelInfo()
@@ -101,6 +128,14 @@ class TextureManager {
GLenum type;
};
+ void MarkAsDeleted() {
+ texture_id_ = 0;
+ }
+
+ bool NeedsMips() const {
+ return min_filter_ != GL_NEAREST && min_filter_ != GL_LINEAR;
+ }
+
// Sets the TextureInfo's target
// Parameters:
// target: GL_TEXTURE_2D or GL_TEXTURE_CUBE_MAP
@@ -122,11 +157,17 @@ class TextureManager {
std::vector<std::vector<LevelInfo> > level_infos_;
// The id of the texure
- GLuint texture_;
+ GLuint texture_id_;
// The target. 0 if unset, otherwise GL_TEXTURE_2D or GL_TEXTURE_CUBE_MAP.
GLenum target_;
+ // Texture parameters.
+ GLenum min_filter_;
+ GLenum mag_filter_;
+ GLenum wrap_s_;
+ GLenum wrap_t_;
+
// The maximum level that has been set.
GLint max_level_set_;
@@ -142,7 +183,8 @@ class TextureManager {
DISALLOW_COPY_AND_ASSIGN(TextureInfo);
};
- TextureManager(GLsizei max_texture_size, GLsizei max_cube_map_texture_size);
+ TextureManager(GLsizei max_texture_size,
+ GLsizei max_cube_map_texture_size);
// Returns the maximum number of levels.
GLint MaxLevelsForTarget(GLenum target) const {
@@ -182,10 +224,10 @@ class TextureManager {
}
// Creates a new texture info.
- void CreateTextureInfo(GLuint texture);
+ void CreateTextureInfo(GLuint texture_id);
// Gets the texture info for the given texture.
- TextureInfo* GetTextureInfo(GLuint texture);
+ TextureInfo* GetTextureInfo(GLuint texture_id);
// Removes a texture info.
void RemoveTextureInfo(GLuint texture_id);
@@ -193,7 +235,7 @@ class TextureManager {
private:
// Info for each texture in the system.
// TODO(gman): Choose a faster container.
- typedef std::map<GLuint, linked_ptr<TextureInfo> > TextureInfoMap;
+ typedef std::map<GLuint, TextureInfo::Ref> TextureInfoMap;
TextureInfoMap texture_infos_;
GLsizei max_texture_size_;
diff --git a/gpu/command_buffer/service/texture_manager_unittest.cc b/gpu/command_buffer/service/texture_manager_unittest.cc
index 8bf2814..dc74605 100644
--- a/gpu/command_buffer/service/texture_manager_unittest.cc
+++ b/gpu/command_buffer/service/texture_manager_unittest.cc
@@ -127,6 +127,15 @@ class TextureInfoTest : public testing::Test {
TextureManager::TextureInfo* info_;
};
+TEST_F(TextureInfoTest, Basic) {
+ EXPECT_EQ(0, info_->target());
+ EXPECT_FALSE(info_->texture_complete());
+ EXPECT_FALSE(info_->cube_complete());
+ EXPECT_FALSE(info_->CanGenerateMipmaps());
+ EXPECT_FALSE(info_->npot());
+ EXPECT_FALSE(info_->CanRender());
+}
+
TEST_F(TextureInfoTest, POT2D) {
manager_.SetInfoTarget(info_, GL_TEXTURE_2D);
EXPECT_EQ(GL_TEXTURE_2D, info_->target());
@@ -135,22 +144,32 @@ TEST_F(TextureInfoTest, POT2D) {
GL_TEXTURE_2D, 0, GL_RGBA, 4, 4, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE);
EXPECT_FALSE(info_->npot());
EXPECT_FALSE(info_->texture_complete());
+ EXPECT_FALSE(info_->CanRender());
+ // Set filters to something that will work with a single mip.
+ info_->SetParameter(GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ EXPECT_TRUE(info_->CanRender());
+ // Set them back.
+ info_->SetParameter(GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
+
EXPECT_TRUE(info_->CanGenerateMipmaps());
// Make mips.
- info_->MarkMipmapsGenerated();
+ EXPECT_TRUE(info_->MarkMipmapsGenerated());
EXPECT_TRUE(info_->texture_complete());
+ EXPECT_TRUE(info_->CanRender());
// Change a mip.
info_->SetLevelInfo(
GL_TEXTURE_2D, 1, GL_RGBA, 4, 4, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE);
EXPECT_FALSE(info_->npot());
EXPECT_FALSE(info_->texture_complete());
EXPECT_TRUE(info_->CanGenerateMipmaps());
+ EXPECT_FALSE(info_->CanRender());
// Set a level past the number of mips that would get generated.
info_->SetLevelInfo(
GL_TEXTURE_2D, 3, GL_RGBA, 4, 4, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE);
EXPECT_TRUE(info_->CanGenerateMipmaps());
// Make mips.
- info_->MarkMipmapsGenerated();
+ EXPECT_TRUE(info_->MarkMipmapsGenerated());
+ EXPECT_FALSE(info_->CanRender());
EXPECT_FALSE(info_->texture_complete());
}
@@ -163,6 +182,13 @@ TEST_F(TextureInfoTest, NPOT2D) {
EXPECT_TRUE(info_->npot());
EXPECT_FALSE(info_->texture_complete());
EXPECT_FALSE(info_->CanGenerateMipmaps());
+ EXPECT_FALSE(info_->CanRender());
+ info_->SetParameter(GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ EXPECT_FALSE(info_->CanRender());
+ info_->SetParameter(GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+ EXPECT_FALSE(info_->CanRender());
+ info_->SetParameter(GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+ EXPECT_TRUE(info_->CanRender());
// Change it to POT.
info_->SetLevelInfo(
GL_TEXTURE_2D, 0, GL_RGBA, 4, 4, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE);
@@ -182,6 +208,7 @@ TEST_F(TextureInfoTest, POTCubeMap) {
EXPECT_FALSE(info_->texture_complete());
EXPECT_FALSE(info_->cube_complete());
EXPECT_FALSE(info_->CanGenerateMipmaps());
+ EXPECT_FALSE(info_->CanRender());
info_->SetLevelInfo(
GL_TEXTURE_CUBE_MAP_NEGATIVE_X,
0, GL_RGBA, 4, 4, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE);
@@ -189,6 +216,7 @@ TEST_F(TextureInfoTest, POTCubeMap) {
EXPECT_FALSE(info_->texture_complete());
EXPECT_FALSE(info_->cube_complete());
EXPECT_FALSE(info_->CanGenerateMipmaps());
+ EXPECT_FALSE(info_->CanRender());
info_->SetLevelInfo(
GL_TEXTURE_CUBE_MAP_POSITIVE_Y,
0, GL_RGBA, 4, 4, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE);
@@ -196,12 +224,14 @@ TEST_F(TextureInfoTest, POTCubeMap) {
EXPECT_FALSE(info_->texture_complete());
EXPECT_FALSE(info_->cube_complete());
EXPECT_FALSE(info_->CanGenerateMipmaps());
+ EXPECT_FALSE(info_->CanRender());
info_->SetLevelInfo(
GL_TEXTURE_CUBE_MAP_NEGATIVE_Y,
0, GL_RGBA, 4, 4, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE);
EXPECT_FALSE(info_->npot());
EXPECT_FALSE(info_->texture_complete());
EXPECT_FALSE(info_->cube_complete());
+ EXPECT_FALSE(info_->CanRender());
EXPECT_FALSE(info_->CanGenerateMipmaps());
info_->SetLevelInfo(
GL_TEXTURE_CUBE_MAP_POSITIVE_Z,
@@ -210,6 +240,7 @@ TEST_F(TextureInfoTest, POTCubeMap) {
EXPECT_FALSE(info_->texture_complete());
EXPECT_FALSE(info_->cube_complete());
EXPECT_FALSE(info_->CanGenerateMipmaps());
+ EXPECT_FALSE(info_->CanRender());
info_->SetLevelInfo(
GL_TEXTURE_CUBE_MAP_NEGATIVE_Z,
0, GL_RGBA, 4, 4, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE);
@@ -217,9 +248,10 @@ TEST_F(TextureInfoTest, POTCubeMap) {
EXPECT_FALSE(info_->texture_complete());
EXPECT_TRUE(info_->cube_complete());
EXPECT_TRUE(info_->CanGenerateMipmaps());
+ EXPECT_FALSE(info_->CanRender());
// Make mips.
- info_->MarkMipmapsGenerated();
+ EXPECT_TRUE(info_->MarkMipmapsGenerated());
EXPECT_TRUE(info_->texture_complete());
EXPECT_TRUE(info_->cube_complete());
@@ -237,7 +269,7 @@ TEST_F(TextureInfoTest, POTCubeMap) {
3, GL_RGBA, 4, 4, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE);
EXPECT_TRUE(info_->CanGenerateMipmaps());
// Make mips.
- info_->MarkMipmapsGenerated();
+ EXPECT_TRUE(info_->MarkMipmapsGenerated());
EXPECT_FALSE(info_->texture_complete());
EXPECT_TRUE(info_->cube_complete());
}
diff --git a/gpu/gpu.gyp b/gpu/gpu.gyp
index 678fc96..9fedfb3 100644
--- a/gpu/gpu.gyp
+++ b/gpu/gpu.gyp
@@ -11,6 +11,8 @@
'gpu_source_files': [
'command_buffer/service/buffer_manager.h',
'command_buffer/service/buffer_manager.cc',
+ 'command_buffer/service/context_group.h',
+ 'command_buffer/service/context_group.cc',
'command_buffer/service/gles2_cmd_decoder.h',
'command_buffer/service/gles2_cmd_decoder_autogen.h',
'command_buffer/service/gles2_cmd_decoder.cc',
@@ -242,6 +244,7 @@
},
'dependencies': [
'command_buffer_common',
+ 'gl_libs',
],
'sources': [
'command_buffer/service/common_decoder.cc',
@@ -269,7 +272,6 @@
'command_buffer/service/x_utils.h',
],
'dependencies': [
- 'gl_libs',
'../build/linux/system.gyp:gtk',
]
},
@@ -320,8 +322,9 @@
'command_buffer/common/gles2_cmd_id_test.cc',
'command_buffer/common/gles2_cmd_id_test_autogen.h',
'command_buffer/service/buffer_manager_unittest.cc',
+ 'command_buffer/service/context_group_unittest.cc',
+ 'command_buffer/service/cmd_parser_test.cc',
'command_buffer/service/cmd_parser_test.cc',
- 'command_buffer/service/command_buffer_service_unittest.cc',
'command_buffer/service/common_decoder_unittest.cc',
'command_buffer/service/gpu_processor_unittest.cc',
'command_buffer/service/resource_test.cc',
@@ -329,8 +332,13 @@
'command_buffer/service/gl_interface.cc',
'command_buffer/service/gl_mock.h',
'command_buffer/service/gl_mock.cc',
+ 'command_buffer/service/gles2_cmd_decoder_unittest_base.h',
+ 'command_buffer/service/gles2_cmd_decoder_unittest_base.cc',
'command_buffer/service/gles2_cmd_decoder_unittest.cc',
- 'command_buffer/service/gles2_cmd_decoder_unittest_autogen.h',
+ 'command_buffer/service/gles2_cmd_decoder_unittest_1.cc',
+ 'command_buffer/service/gles2_cmd_decoder_unittest_1_autogen.h',
+ 'command_buffer/service/gles2_cmd_decoder_unittest_2.cc',
+ 'command_buffer/service/gles2_cmd_decoder_unittest_2_autogen.h',
'command_buffer/service/id_manager_unittest.cc',
'command_buffer/service/program_manager_unittest.cc',
'command_buffer/service/shader_manager_unittest.cc',