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

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

Issue 10450030: Defer initializing the CopyTextureCHROMIUMResourceManager (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 7 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/gles2_cmd_decoder_unittest_base.h ('k') | no next file » | 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) 2012 The Chromium Authors. All rights reserved. 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 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/gles2_cmd_decoder_unittest_base.h" 5 #include "gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 9
10 #include "base/string_number_conversions.h" 10 #include "base/string_number_conversions.h"
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 } 65 }
66 66
67 void GLES2DecoderTestBase::AddExpectationsForVertexAttribManager() { 67 void GLES2DecoderTestBase::AddExpectationsForVertexAttribManager() {
68 for (GLint ii = 0; ii < kNumVertexAttribs; ++ii) { 68 for (GLint ii = 0; ii < kNumVertexAttribs; ++ii) {
69 EXPECT_CALL(*gl_, VertexAttrib4f(ii, 0.0f, 0.0f, 0.0f, 1.0f)) 69 EXPECT_CALL(*gl_, VertexAttrib4f(ii, 0.0f, 0.0f, 0.0f, 1.0f))
70 .Times(1) 70 .Times(1)
71 .RetiresOnSaturation(); 71 .RetiresOnSaturation();
72 } 72 }
73 } 73 }
74 74
75 // Setup the expectations required for the inialiazation of the resources
76 // used by the GL_CHROMIUM_copy_texture extension.
77 void GLES2DecoderTestBase::AddExpectationsForCopyTextureCHROMIUM() {
78 static GLuint copy_texture_chromium_buffer_ids[] = {
79 kServiceCopyTextureChromiumVertexBufferId,
80 kServiceCopyTextureChromiumTextureBufferId
81 };
82 EXPECT_CALL(*gl_, GenBuffersARB(arraysize(copy_texture_chromium_buffer_ids),
83 _))
84 .WillOnce(SetArrayArgument<1>(copy_texture_chromium_buffer_ids,
85 copy_texture_chromium_buffer_ids + arraysize(
86 copy_texture_chromium_buffer_ids)))
87 .RetiresOnSaturation();
88
89 EXPECT_CALL(*gl_, BindBuffer(GL_ARRAY_BUFFER,
90 kServiceCopyTextureChromiumVertexBufferId))
91 .Times(1)
92 .RetiresOnSaturation();
93
94 EXPECT_CALL(*gl_, BufferData(GL_ARRAY_BUFFER, 16 * sizeof(GLfloat), _,
95 GL_STATIC_DRAW))
96 .Times(1)
97 .RetiresOnSaturation();
98
99 EXPECT_CALL(*gl_, BindBuffer(GL_ARRAY_BUFFER,
100 kServiceCopyTextureChromiumTextureBufferId))
101 .Times(1)
102 .RetiresOnSaturation();
103
104 EXPECT_CALL(*gl_, BufferData(GL_ARRAY_BUFFER, 8 * sizeof(GLfloat), _,
105 GL_STATIC_DRAW))
106 .Times(1)
107 .RetiresOnSaturation();
108
109 static GLuint copy_texture_chromium_fbo_ids[] = {
110 kServiceCopyTextureChromiumFBOId
111 };
112 EXPECT_CALL(*gl_, GenFramebuffersEXT(arraysize(copy_texture_chromium_fbo_ids),
113 _))
114 .WillOnce(SetArrayArgument<1>(copy_texture_chromium_fbo_ids,
115 copy_texture_chromium_fbo_ids + arraysize(
116 copy_texture_chromium_fbo_ids)))
117 .RetiresOnSaturation();
118
119 for (int shader = 0; shader < 5; ++shader) {
120 EXPECT_CALL(*gl_, CreateShader(
121 shader == 0 ? GL_VERTEX_SHADER : GL_FRAGMENT_SHADER))
122 .WillOnce(Return(kServiceCopyTextureChromiumShaderId + shader))
123 .RetiresOnSaturation();
124
125 EXPECT_CALL(*gl_, ShaderSource(kServiceCopyTextureChromiumShaderId + shader,
126 1, _, 0))
127 .Times(1)
128 .RetiresOnSaturation();
129
130 EXPECT_CALL(*gl_, CompileShader(
131 kServiceCopyTextureChromiumShaderId + shader))
132 .Times(1)
133 .RetiresOnSaturation();
134 #ifndef NDEBUG
135 EXPECT_CALL(*gl_, GetShaderiv(kServiceCopyTextureChromiumShaderId + shader,
136 GL_COMPILE_STATUS, _))
137 .WillOnce(SetArgPointee<2>(GL_TRUE))
138 .RetiresOnSaturation();
139 #endif
140 }
141
142 for (int program = 0; program < 4; ++program) {
143 EXPECT_CALL(*gl_, CreateProgram())
144 .WillOnce(Return(kServiceCopyTextureChromiumProgramId + program))
145 .RetiresOnSaturation();
146
147 EXPECT_CALL(*gl_, AttachShader(
148 kServiceCopyTextureChromiumProgramId + program,
149 kServiceCopyTextureChromiumShaderId))
150 .Times(1)
151 .RetiresOnSaturation();
152
153 EXPECT_CALL(*gl_, AttachShader(
154 kServiceCopyTextureChromiumProgramId + program,
155 kServiceCopyTextureChromiumShaderId + program + 1))
156 .Times(1)
157 .RetiresOnSaturation();
158
159 EXPECT_CALL(*gl_, BindAttribLocation(
160 kServiceCopyTextureChromiumProgramId + program, 0, _))
161 .Times(1)
162 .RetiresOnSaturation();
163
164 EXPECT_CALL(*gl_, BindAttribLocation(
165 kServiceCopyTextureChromiumProgramId + program, 1, _))
166 .Times(1)
167 .RetiresOnSaturation();
168
169 EXPECT_CALL(*gl_, LinkProgram(
170 kServiceCopyTextureChromiumProgramId + program))
171 .Times(1)
172 .RetiresOnSaturation();
173
174 #ifndef NDEBUG
175 EXPECT_CALL(*gl_, GetProgramiv(
176 kServiceCopyTextureChromiumProgramId + program, GL_LINK_STATUS, _))
177 .WillOnce(SetArgPointee<2>(true))
178 .RetiresOnSaturation();
179 #endif
180
181 EXPECT_CALL(*gl_, GetUniformLocation(
182 kServiceCopyTextureChromiumProgramId + program, _))
183 .WillOnce(Return(kServiceCopyTextureChromiumSamplerLocation))
184 .RetiresOnSaturation();
185 }
186
187 for (int shader = 0; shader < 5; ++shader)
188 EXPECT_CALL(*gl_,
189 DeleteShader(kServiceCopyTextureChromiumShaderId + shader))
190 .Times(1)
191 .RetiresOnSaturation();
192 }
193
194 void GLES2DecoderTestBase::InitDecoder( 75 void GLES2DecoderTestBase::InitDecoder(
195 const char* extensions, 76 const char* extensions,
196 bool has_alpha, 77 bool has_alpha,
197 bool has_depth, 78 bool has_depth,
198 bool has_stencil, 79 bool has_stencil,
199 bool request_alpha, 80 bool request_alpha,
200 bool request_depth, 81 bool request_depth,
201 bool request_stencil, 82 bool request_stencil,
202 bool bind_generates_resource) { 83 bool bind_generates_resource) {
203 gl_.reset(new StrictMock<MockGLInterface>()); 84 gl_.reset(new StrictMock<MockGLInterface>());
204 ::gfx::GLInterface::SetGLInterface(gl_.get()); 85 ::gfx::GLInterface::SetGLInterface(gl_.get());
205 group_ = ContextGroup::Ref(new ContextGroup(NULL, bind_generates_resource)); 86 group_ = ContextGroup::Ref(new ContextGroup(NULL, bind_generates_resource));
206 87
207 InSequence sequence; 88 InSequence sequence;
208 89
209 TestHelper::SetupContextGroupInitExpectations(gl_.get(), 90 TestHelper::SetupContextGroupInitExpectations(gl_.get(),
210 DisallowedFeatures(), extensions); 91 DisallowedFeatures(), extensions);
211 92
212 EXPECT_TRUE(group_->Initialize(DisallowedFeatures(), NULL)); 93 EXPECT_TRUE(group_->Initialize(DisallowedFeatures(), NULL));
213 94
214 AddExpectationsForCopyTextureCHROMIUM();
215 AddExpectationsForVertexAttribManager(); 95 AddExpectationsForVertexAttribManager();
216 96
217 EXPECT_CALL(*gl_, EnableVertexAttribArray(0)) 97 EXPECT_CALL(*gl_, EnableVertexAttribArray(0))
218 .Times(1) 98 .Times(1)
219 .RetiresOnSaturation(); 99 .RetiresOnSaturation();
220 static GLuint attrib_0_id[] = { 100 static GLuint attrib_0_id[] = {
221 kServiceAttrib0BufferId, 101 kServiceAttrib0BufferId,
222 }; 102 };
223 static GLuint fixed_attrib_buffer_id[] = { 103 static GLuint fixed_attrib_buffer_id[] = {
224 kServiceFixedAttribBufferId, 104 kServiceFixedAttribBufferId,
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 DoCreateShader(GL_VERTEX_SHADER, client_shader_id_, kServiceShaderId); 250 DoCreateShader(GL_VERTEX_SHADER, client_shader_id_, kServiceShaderId);
371 251
372 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 252 EXPECT_EQ(GL_NO_ERROR, GetGLError());
373 } 253 }
374 254
375 void GLES2DecoderTestBase::TearDown() { 255 void GLES2DecoderTestBase::TearDown() {
376 InSequence sequence; 256 InSequence sequence;
377 257
378 // All Tests should have read all their GLErrors before getting here. 258 // All Tests should have read all their GLErrors before getting here.
379 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 259 EXPECT_EQ(GL_NO_ERROR, GetGLError());
380 EXPECT_CALL(*gl_, DeleteFramebuffersEXT(1,
381 Pointee(kServiceCopyTextureChromiumFBOId)))
382 .Times(1)
383 .RetiresOnSaturation();
384
385 EXPECT_CALL(*gl_, DeleteProgram(_))
386 .Times(4)
387 .RetiresOnSaturation();
388
389 EXPECT_CALL(*gl_, DeleteBuffersARB(2, _))
390 .Times(1)
391 .RetiresOnSaturation();
392 260
393 EXPECT_CALL(*gl_, DeleteBuffersARB(1, _)) 261 EXPECT_CALL(*gl_, DeleteBuffersARB(1, _))
394 .Times(2) 262 .Times(2)
395 .RetiresOnSaturation(); 263 .RetiresOnSaturation();
396 264
397 decoder_->Destroy(true); 265 decoder_->Destroy(true);
398 decoder_.reset(); 266 decoder_.reset();
399 group_->Destroy(false); 267 group_->Destroy(false);
400 engine_.reset(); 268 engine_.reset();
401 ::gfx::GLInterface::SetGLInterface(NULL); 269 ::gfx::GLInterface::SetGLInterface(NULL);
(...skipping 912 matching lines...) Expand 10 before | Expand all | Expand 10 after
1314 num_vertices, buffer_id, GL_NO_ERROR); 1182 num_vertices, buffer_id, GL_NO_ERROR);
1315 } 1183 }
1316 1184
1317 void GLES2DecoderWithShaderTestBase::SetUp() { 1185 void GLES2DecoderWithShaderTestBase::SetUp() {
1318 GLES2DecoderTestBase::SetUp(); 1186 GLES2DecoderTestBase::SetUp();
1319 SetupDefaultProgram(); 1187 SetupDefaultProgram();
1320 } 1188 }
1321 1189
1322 } // namespace gles2 1190 } // namespace gles2
1323 } // namespace gpu 1191 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698