1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef GPU_COMMAND_BUFFER_SERVICE_TEST_HELPER_H_
6 #define GPU_COMMAND_BUFFER_SERVICE_TEST_HELPER_H_
11 #include "gpu/command_buffer/service/shader_translator.h"
12 #include "ui/gl/gl_implementation.h"
13 #include "ui/gl/gl_mock.h"
18 struct DisallowedFeatures
;
28 static const GLuint kServiceBlackTexture2dId
= 701;
29 static const GLuint kServiceDefaultTexture2dId
= 702;
30 static const GLuint kServiceBlackTextureCubemapId
= 703;
31 static const GLuint kServiceDefaultTextureCubemapId
= 704;
32 static const GLuint kServiceBlackExternalTextureId
= 705;
33 static const GLuint kServiceDefaultExternalTextureId
= 706;
34 static const GLuint kServiceBlackRectangleTextureId
= 707;
35 static const GLuint kServiceDefaultRectangleTextureId
= 708;
37 static const GLint kMaxSamples
= 4;
38 static const GLint kMaxRenderbufferSize
= 1024;
39 static const GLint kMaxTextureSize
= 2048;
40 static const GLint kMaxCubeMapTextureSize
= 256;
41 static const GLint kMaxRectangleTextureSize
= 64;
42 static const GLint kNumVertexAttribs
= 16;
43 static const GLint kNumTextureUnits
= 8;
44 static const GLint kMaxTextureImageUnits
= 8;
45 static const GLint kMaxVertexTextureImageUnits
= 2;
46 static const GLint kMaxFragmentUniformVectors
= 16;
47 static const GLint kMaxFragmentUniformComponents
=
48 kMaxFragmentUniformVectors
* 4;
49 static const GLint kMaxVaryingVectors
= 8;
50 static const GLint kMaxVaryingFloats
= kMaxVaryingVectors
* 4;
51 static const GLint kMaxVertexUniformVectors
= 128;
52 static const GLint kMaxVertexUniformComponents
= kMaxVertexUniformVectors
* 4;
67 GLint desired_location
;
68 const char* good_name
;
71 static void SetupContextGroupInitExpectations(
72 ::gfx::MockGLInterface
* gl
,
73 const DisallowedFeatures
& disallowed_features
,
74 const char* extensions
,
75 const char* gl_version
,
76 bool bind_generates_resource
);
77 static void SetupFeatureInfoInitExpectations(
78 ::gfx::MockGLInterface
* gl
, const char* extensions
);
79 static void SetupFeatureInfoInitExpectationsWithGLVersion(
80 ::gfx::MockGLInterface
* gl
,
81 const char* extensions
,
82 const char* gl_renderer
,
83 const char* gl_version
);
84 static void SetupTextureManagerInitExpectations(::gfx::MockGLInterface
* gl
,
85 const char* extensions
,
86 bool use_default_textures
);
87 static void SetupTextureManagerDestructionExpectations(
88 ::gfx::MockGLInterface
* gl
,
89 const char* extensions
,
90 bool use_default_textures
);
92 static void SetupExpectationsForClearingUniforms(
93 ::gfx::MockGLInterface
* gl
, UniformInfo
* uniforms
, size_t num_uniforms
);
95 static void SetupShader(
96 ::gfx::MockGLInterface
* gl
,
97 AttribInfo
* attribs
, size_t num_attribs
,
98 UniformInfo
* uniforms
, size_t num_uniforms
,
101 static void SetupProgramSuccessExpectations(::gfx::MockGLInterface
* gl
,
102 AttribInfo
* attribs
, size_t num_attribs
,
103 UniformInfo
* uniforms
, size_t num_uniforms
,
106 static void DoBufferData(
107 ::gfx::MockGLInterface
* gl
, MockErrorState
* error_state
,
108 BufferManager
* manager
, Buffer
* buffer
, GLsizeiptr size
, GLenum usage
,
109 const GLvoid
* data
, GLenum error
);
111 static void SetTexParameteriWithExpectations(
112 ::gfx::MockGLInterface
* gl
, MockErrorState
* error_state
,
113 TextureManager
* manager
, TextureRef
* texture_ref
,
114 GLenum pname
, GLint value
, GLenum error
);
116 static void SetShaderStates(
117 ::gfx::MockGLInterface
* gl
, Shader
* shader
,
119 const std::string
* const expected_log_info
,
120 const std::string
* const expected_translated_source
,
121 const AttributeMap
* const expected_attrib_map
,
122 const UniformMap
* const expected_uniform_map
,
123 const VaryingMap
* const expected_varying_map
,
124 const NameMap
* const expected_name_map
);
126 static void SetShaderStates(
127 ::gfx::MockGLInterface
* gl
, Shader
* shader
, bool valid
);
129 static sh::Attribute
ConstructAttribute(
130 GLenum type
, GLint array_size
, GLenum precision
,
131 bool static_use
, const std::string
& name
);
132 static sh::Uniform
ConstructUniform(
133 GLenum type
, GLint array_size
, GLenum precision
,
134 bool static_use
, const std::string
& name
);
135 static sh::Varying
ConstructVarying(
136 GLenum type
, GLint array_size
, GLenum precision
,
137 bool static_use
, const std::string
& name
);
140 static void SetupTextureInitializationExpectations(::gfx::MockGLInterface
* gl
,
142 bool use_default_textures
);
143 static void SetupTextureDestructionExpectations(::gfx::MockGLInterface
* gl
,
145 bool use_default_textures
);
147 static std::vector
<std::string
> split_extensions_
;
150 // This object temporaritly Sets what gfx::GetGLImplementation returns. During
151 // testing the GLImplementation is set to kGLImplemenationMockGL but lots of
152 // code branches based on what gfx::GetGLImplementation returns.
153 class ScopedGLImplementationSetter
{
155 explicit ScopedGLImplementationSetter(gfx::GLImplementation implementation
);
156 ~ScopedGLImplementationSetter();
159 gfx::GLImplementation old_implementation_
;
165 #endif // GPU_COMMAND_BUFFER_SERVICE_TEST_HELPER_H_