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

Side by Side Diff: gpu/command_buffer/service/test_helper.cc

Issue 7458008: Support GL_OES_EGL_image_external (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: fix typo which hung the windows gpu_unittests by corrupting the stack Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « gpu/command_buffer/service/test_helper.h ('k') | gpu/command_buffer/service/texture_manager.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "gpu/command_buffer/service/test_helper.h" 5 #include "gpu/command_buffer/service/test_helper.h"
6 6
7 #include "base/string_tokenizer.h"
7 #include "gpu/command_buffer/common/gl_mock.h" 8 #include "gpu/command_buffer/common/gl_mock.h"
8 #include "gpu/command_buffer/common/types.h" 9 #include "gpu/command_buffer/common/types.h"
10 #include "gpu/command_buffer/service/gl_utils.h"
9 #include "gpu/GLES2/gles2_command_buffer.h" 11 #include "gpu/GLES2/gles2_command_buffer.h"
10 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
11 13
14 #include <string.h>
15
12 using ::testing::_; 16 using ::testing::_;
13 using ::testing::DoAll; 17 using ::testing::DoAll;
14 using ::testing::InSequence; 18 using ::testing::InSequence;
15 using ::testing::MatcherCast; 19 using ::testing::MatcherCast;
16 using ::testing::Pointee; 20 using ::testing::Pointee;
17 using ::testing::Return; 21 using ::testing::Return;
18 using ::testing::SetArrayArgument; 22 using ::testing::SetArrayArgument;
19 using ::testing::SetArgumentPointee; 23 using ::testing::SetArgumentPointee;
20 using ::testing::StrEq; 24 using ::testing::StrEq;
21 using ::testing::StrictMock; 25 using ::testing::StrictMock;
22 26
23 namespace gpu { 27 namespace gpu {
24 namespace gles2 { 28 namespace gles2 {
25 29
26 // GCC requires these declarations, but MSVC requires they not be present 30 // GCC requires these declarations, but MSVC requires they not be present
27 #ifndef COMPILER_MSVC 31 #ifndef COMPILER_MSVC
28 const GLuint TestHelper::kServiceBlackTexture2dId; 32 const GLuint TestHelper::kServiceBlackTexture2dId;
29 const GLuint TestHelper::kServiceBlackTextureCubemapId; 33 const GLuint TestHelper::kServiceBlackTextureCubemapId;
30 const GLuint TestHelper::kServiceDefaultTexture2dId; 34 const GLuint TestHelper::kServiceDefaultTexture2dId;
31 const GLuint TestHelper::kServiceDefaultTextureCubemapId; 35 const GLuint TestHelper::kServiceDefaultTextureCubemapId;
36 const GLuint TestHelper::kServiceDefaultExternalTextureId;
37 const GLuint TestHelper::kServiceBlackExternalTextureId;
32 38
33 const GLint TestHelper::kMaxRenderbufferSize; 39 const GLint TestHelper::kMaxRenderbufferSize;
34 const GLint TestHelper::kMaxTextureSize; 40 const GLint TestHelper::kMaxTextureSize;
35 const GLint TestHelper::kMaxCubeMapTextureSize; 41 const GLint TestHelper::kMaxCubeMapTextureSize;
36 const GLint TestHelper::kNumVertexAttribs; 42 const GLint TestHelper::kNumVertexAttribs;
37 const GLint TestHelper::kNumTextureUnits; 43 const GLint TestHelper::kNumTextureUnits;
38 const GLint TestHelper::kMaxTextureImageUnits; 44 const GLint TestHelper::kMaxTextureImageUnits;
39 const GLint TestHelper::kMaxVertexTextureImageUnits; 45 const GLint TestHelper::kMaxVertexTextureImageUnits;
40 const GLint TestHelper::kMaxFragmentUniformVectors; 46 const GLint TestHelper::kMaxFragmentUniformVectors;
41 const GLint TestHelper::kMaxFragmentUniformComponents; 47 const GLint TestHelper::kMaxFragmentUniformComponents;
42 const GLint TestHelper::kMaxVaryingVectors; 48 const GLint TestHelper::kMaxVaryingVectors;
43 const GLint TestHelper::kMaxVaryingFloats; 49 const GLint TestHelper::kMaxVaryingFloats;
44 const GLint TestHelper::kMaxVertexUniformVectors; 50 const GLint TestHelper::kMaxVertexUniformVectors;
45 const GLint TestHelper::kMaxVertexUniformComponents; 51 const GLint TestHelper::kMaxVertexUniformComponents;
46 #endif 52 #endif
47 53
48 void TestHelper::SetupTextureManagerInitExpectations( 54 void TestHelper::SetupTextureManagerInitExpectations(
49 ::gfx::MockGLInterface* gl) { 55 ::gfx::MockGLInterface* gl,
56 const char* extensions) {
50 static GLuint texture_ids[] = { 57 static GLuint texture_ids[] = {
51 kServiceBlackTexture2dId, 58 kServiceBlackTexture2dId,
52 kServiceDefaultTexture2dId, 59 kServiceDefaultTexture2dId,
53 kServiceBlackTextureCubemapId, 60 kServiceBlackTextureCubemapId,
54 kServiceDefaultTextureCubemapId, 61 kServiceDefaultTextureCubemapId,
55 }; 62 };
56 EXPECT_CALL(*gl, GenTextures(arraysize(texture_ids), _)) 63 EXPECT_CALL(*gl, GenTextures(arraysize(texture_ids), _))
57 .WillOnce(SetArrayArgument<1>(texture_ids, 64 .WillOnce(SetArrayArgument<1>(texture_ids,
58 texture_ids + arraysize(texture_ids))) 65 texture_ids + arraysize(texture_ids)))
59 .RetiresOnSaturation(); 66 .RetiresOnSaturation();
(...skipping 22 matching lines...) Expand all
82 .Times(1) 89 .Times(1)
83 .RetiresOnSaturation(); 90 .RetiresOnSaturation();
84 } 91 }
85 } 92 }
86 EXPECT_CALL(*gl, BindTexture(GL_TEXTURE_2D, 0)) 93 EXPECT_CALL(*gl, BindTexture(GL_TEXTURE_2D, 0))
87 .Times(1) 94 .Times(1)
88 .RetiresOnSaturation(); 95 .RetiresOnSaturation();
89 EXPECT_CALL(*gl, BindTexture(GL_TEXTURE_CUBE_MAP, 0)) 96 EXPECT_CALL(*gl, BindTexture(GL_TEXTURE_CUBE_MAP, 0))
90 .Times(1) 97 .Times(1)
91 .RetiresOnSaturation(); 98 .RetiresOnSaturation();
99
100 bool ext_image_external = false;
101 CStringTokenizer t(extensions, extensions + strlen(extensions), " ");
102 while (t.GetNext()) {
103 if (t.token() == "GL_OES_EGL_image_external") {
104 ext_image_external = true;
105 break;
106 }
107 }
108
109 if (ext_image_external) {
110 static GLuint external_texture_ids[] = {
111 kServiceDefaultExternalTextureId,
112 kServiceBlackExternalTextureId,
113 };
114 EXPECT_CALL(*gl, GenTextures(arraysize(external_texture_ids), _))
115 .WillOnce(SetArrayArgument<1>(
116 external_texture_ids,
117 external_texture_ids + arraysize(external_texture_ids)))
118 .RetiresOnSaturation();
119 EXPECT_CALL(*gl, BindTexture(GL_TEXTURE_EXTERNAL_OES, 0))
120 .Times(1)
121 .RetiresOnSaturation();
122 }
92 } 123 }
93 124
94 void TestHelper::SetupContextGroupInitExpectations( 125 void TestHelper::SetupContextGroupInitExpectations(
95 ::gfx::MockGLInterface* gl, 126 ::gfx::MockGLInterface* gl,
96 const DisallowedExtensions& disallowed_extensions, 127 const DisallowedExtensions& disallowed_extensions,
97 const char* extensions) { 128 const char* extensions) {
98 InSequence sequence; 129 InSequence sequence;
99 130
100 SetupFeatureInfoInitExpectations(gl, extensions); 131 SetupFeatureInfoInitExpectations(gl, extensions);
101 132
(...skipping 22 matching lines...) Expand all
124 EXPECT_CALL(*gl, GetIntegerv(GL_MAX_FRAGMENT_UNIFORM_COMPONENTS, _)) 155 EXPECT_CALL(*gl, GetIntegerv(GL_MAX_FRAGMENT_UNIFORM_COMPONENTS, _))
125 .WillOnce(SetArgumentPointee<1>(kMaxFragmentUniformComponents)) 156 .WillOnce(SetArgumentPointee<1>(kMaxFragmentUniformComponents))
126 .RetiresOnSaturation(); 157 .RetiresOnSaturation();
127 EXPECT_CALL(*gl, GetIntegerv(GL_MAX_VARYING_FLOATS, _)) 158 EXPECT_CALL(*gl, GetIntegerv(GL_MAX_VARYING_FLOATS, _))
128 .WillOnce(SetArgumentPointee<1>(kMaxVaryingFloats)) 159 .WillOnce(SetArgumentPointee<1>(kMaxVaryingFloats))
129 .RetiresOnSaturation(); 160 .RetiresOnSaturation();
130 EXPECT_CALL(*gl, GetIntegerv(GL_MAX_VERTEX_UNIFORM_COMPONENTS, _)) 161 EXPECT_CALL(*gl, GetIntegerv(GL_MAX_VERTEX_UNIFORM_COMPONENTS, _))
131 .WillOnce(SetArgumentPointee<1>(kMaxVertexUniformComponents)) 162 .WillOnce(SetArgumentPointee<1>(kMaxVertexUniformComponents))
132 .RetiresOnSaturation(); 163 .RetiresOnSaturation();
133 164
134 SetupTextureManagerInitExpectations(gl); 165 SetupTextureManagerInitExpectations(gl, extensions);
135 } 166 }
136 167
137 void TestHelper::SetupFeatureInfoInitExpectations( 168 void TestHelper::SetupFeatureInfoInitExpectations(
138 ::gfx::MockGLInterface* gl, const char* extensions) { 169 ::gfx::MockGLInterface* gl, const char* extensions) {
139 InSequence sequence; 170 InSequence sequence;
140 171
141 EXPECT_CALL(*gl, GetString(GL_EXTENSIONS)) 172 EXPECT_CALL(*gl, GetString(GL_EXTENSIONS))
142 .WillOnce(Return(reinterpret_cast<const uint8*>(extensions))) 173 .WillOnce(Return(reinterpret_cast<const uint8*>(extensions)))
143 .RetiresOnSaturation(); 174 .RetiresOnSaturation();
144 } 175 }
145 176
146 } // namespace gles2 177 } // namespace gles2
147 } // namespace gpu 178 } // namespace gpu
148 179
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/test_helper.h ('k') | gpu/command_buffer/service/texture_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698