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

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

Issue 262793002: Revert of Optimize GLES2DecoderImpl::ApplyDirtyState. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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
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.h" 5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/strings/string_number_conversions.h" 8 #include "base/strings/string_number_conversions.h"
9 #include "gpu/command_buffer/common/gles2_cmd_format.h" 9 #include "gpu/command_buffer/common/gles2_cmd_format.h"
10 #include "gpu/command_buffer/common/gles2_cmd_utils.h" 10 #include "gpu/command_buffer/common/gles2_cmd_utils.h"
(...skipping 21 matching lines...) Expand all
32 #if !defined(GL_DEPTH24_STENCIL8) 32 #if !defined(GL_DEPTH24_STENCIL8)
33 #define GL_DEPTH24_STENCIL8 0x88F0 33 #define GL_DEPTH24_STENCIL8 0x88F0
34 #endif 34 #endif
35 35
36 using ::gfx::MockGLInterface; 36 using ::gfx::MockGLInterface;
37 using ::testing::_; 37 using ::testing::_;
38 using ::testing::DoAll; 38 using ::testing::DoAll;
39 using ::testing::InSequence; 39 using ::testing::InSequence;
40 using ::testing::Invoke; 40 using ::testing::Invoke;
41 using ::testing::MatcherCast; 41 using ::testing::MatcherCast;
42 using ::testing::Mock;
43 using ::testing::Pointee; 42 using ::testing::Pointee;
44 using ::testing::Return; 43 using ::testing::Return;
45 using ::testing::SaveArg; 44 using ::testing::SaveArg;
46 using ::testing::SetArrayArgument; 45 using ::testing::SetArrayArgument;
47 using ::testing::SetArgumentPointee; 46 using ::testing::SetArgumentPointee;
48 using ::testing::SetArgPointee; 47 using ::testing::SetArgPointee;
49 using ::testing::StrEq; 48 using ::testing::StrEq;
50 using ::testing::StrictMock; 49 using ::testing::StrictMock;
51 50
52 namespace gpu { 51 namespace gpu {
53 namespace gles2 { 52 namespace gles2 {
54 53
55 using namespace cmds; 54 using namespace cmds;
56 55
57 class GLES2DecoderTest : public GLES2DecoderTestBase { 56 class GLES2DecoderTest : public GLES2DecoderTestBase {
58 public: 57 public:
59 GLES2DecoderTest() { } 58 GLES2DecoderTest() { }
60 59
61 protected: 60 protected:
62 void CheckReadPixelsOutOfRange( 61 void CheckReadPixelsOutOfRange(
63 GLint in_read_x, GLint in_read_y, 62 GLint in_read_x, GLint in_read_y,
64 GLsizei in_read_width, GLsizei in_read_height, 63 GLsizei in_read_width, GLsizei in_read_height,
65 bool init); 64 bool init);
66 }; 65 };
67 66
68 class GLES2DecoderTestWithExtensionsOnGLES2 : public GLES2DecoderTest { 67 class GLES2DecoderTestWithExtensionsOnGLES2
68 : public GLES2DecoderTest,
69 public ::testing::WithParamInterface<const char*> {
69 public: 70 public:
70 GLES2DecoderTestWithExtensionsOnGLES2() {} 71 GLES2DecoderTestWithExtensionsOnGLES2() {}
71 72
72 virtual void SetUp() {} 73 virtual void SetUp() {
73
74 void Init(const char* extensions) {
75 InitState init; 74 InitState init;
76 init.extensions = extensions; 75 init.extensions = GetParam();
77 init.gl_version = "opengl es 2.0"; 76 init.gl_version = "opengl es 2.0";
78 init.has_alpha = true; 77 init.has_alpha = true;
79 init.has_depth = true; 78 init.has_depth = true;
80 init.request_alpha = true; 79 init.request_alpha = true;
81 init.request_depth = true; 80 init.request_depth = true;
82 InitDecoder(init); 81 InitDecoder(init);
83 } 82 }
84 }; 83 };
85 84
86 class GLES2DecoderWithShaderTest : public GLES2DecoderWithShaderTestBase { 85 class GLES2DecoderWithShaderTest : public GLES2DecoderWithShaderTestBase {
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 } 131 }
133 }; 132 };
134 133
135 class GLES2DecoderManualInitTest : public GLES2DecoderWithShaderTest { 134 class GLES2DecoderManualInitTest : public GLES2DecoderWithShaderTest {
136 public: 135 public:
137 GLES2DecoderManualInitTest() { } 136 GLES2DecoderManualInitTest() { }
138 137
139 // Override default setup so nothing gets setup. 138 // Override default setup so nothing gets setup.
140 virtual void SetUp() { 139 virtual void SetUp() {
141 } 140 }
142
143 void DirtyStateMaskTest(GLuint color_bits,
144 bool depth_mask,
145 GLuint front_stencil_mask,
146 GLuint back_stencil_mask) {
147 ColorMask color_mask_cmd;
148 color_mask_cmd.Init((color_bits & 0x1000) != 0,
149 (color_bits & 0x0100) != 0,
150 (color_bits & 0x0010) != 0,
151 (color_bits & 0x0001) != 0);
152 EXPECT_EQ(error::kNoError, ExecuteCmd(color_mask_cmd));
153 EXPECT_EQ(GL_NO_ERROR, GetGLError());
154
155 DepthMask depth_mask_cmd;
156 depth_mask_cmd.Init(depth_mask);
157 EXPECT_EQ(error::kNoError, ExecuteCmd(depth_mask_cmd));
158 EXPECT_EQ(GL_NO_ERROR, GetGLError());
159
160 StencilMaskSeparate front_stencil_mask_cmd;
161 front_stencil_mask_cmd.Init(GL_FRONT, front_stencil_mask);
162 EXPECT_EQ(error::kNoError, ExecuteCmd(front_stencil_mask_cmd));
163 EXPECT_EQ(GL_NO_ERROR, GetGLError());
164
165 StencilMaskSeparate back_stencil_mask_cmd;
166 back_stencil_mask_cmd.Init(GL_BACK, back_stencil_mask);
167 EXPECT_EQ(error::kNoError, ExecuteCmd(back_stencil_mask_cmd));
168 EXPECT_EQ(GL_NO_ERROR, GetGLError());
169
170 SetupExpectationsForApplyingDirtyState(
171 false, // Framebuffer is RGB
172 true, // Framebuffer has depth
173 true, // Framebuffer has stencil
174 color_bits, // color bits
175 depth_mask, // depth mask
176 false, // depth enabled
177 front_stencil_mask, // front stencil mask
178 back_stencil_mask, // back stencil mask
179 false); // stencil enabled
180
181 EXPECT_CALL(*gl_, DrawArrays(GL_TRIANGLES, 0, kNumVertices))
182 .Times(1)
183 .RetiresOnSaturation();
184 DrawArrays draw_cmd;
185 draw_cmd.Init(GL_TRIANGLES, 0, kNumVertices);
186 EXPECT_EQ(error::kNoError, ExecuteCmd(draw_cmd));
187 EXPECT_EQ(GL_NO_ERROR, GetGLError());
188 }
189
190 void EnableDisableTest(GLenum cap, bool enable, bool expect_set) {
191 if (expect_set) {
192 SetupExpectationsForEnableDisable(cap, enable);
193 }
194 if (enable) {
195 Enable cmd;
196 cmd.Init(cap);
197 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
198 EXPECT_EQ(GL_NO_ERROR, GetGLError());
199 } else {
200 Disable cmd;
201 cmd.Init(cap);
202 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
203 EXPECT_EQ(GL_NO_ERROR, GetGLError());
204 }
205 }
206 }; 141 };
207 142
208 class GLES2DecoderCompressedFormatsTest : public GLES2DecoderManualInitTest { 143 class GLES2DecoderCompressedFormatsTest : public GLES2DecoderManualInitTest {
209 public: 144 public:
210 GLES2DecoderCompressedFormatsTest() { } 145 GLES2DecoderCompressedFormatsTest() { }
211 146
212 static bool ValueInArray(GLint value, GLint* array, GLint count) { 147 static bool ValueInArray(GLint value, GLint* array, GLint count) {
213 for (GLint ii = 0; ii < count; ++ii) { 148 for (GLint ii = 0; ii < count; ++ii) {
214 if (array[ii] == value) { 149 if (array[ii] == value) {
215 return true; 150 return true;
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 state->texture_units[tt].bound_texture_cube_map = ref_cube_map; 234 state->texture_units[tt].bound_texture_cube_map = ref_cube_map;
300 TextureRef* ref_2d = 235 TextureRef* ref_2d =
301 (tt == non_default_unit) 236 (tt == non_default_unit)
302 ? group().texture_manager()->GetTexture(client_texture_id_) 237 ? group().texture_manager()->GetTexture(client_texture_id_)
303 : group().texture_manager()->GetDefaultTextureInfo(GL_TEXTURE_2D); 238 : group().texture_manager()->GetDefaultTextureInfo(GL_TEXTURE_2D);
304 state->texture_units[tt].bound_texture_2d = ref_2d; 239 state->texture_units[tt].bound_texture_2d = ref_2d;
305 } 240 }
306 state->active_texture_unit = active_unit; 241 state->active_texture_unit = active_unit;
307 } 242 }
308 243
309 TEST_P(GLES2DecoderWithShaderTest, DrawArraysNoAttributesSucceeds) { 244 TEST_F(GLES2DecoderWithShaderTest, DrawArraysNoAttributesSucceeds) {
310 SetupTexture(); 245 SetupTexture();
311 AddExpectationsForSimulatedAttrib0(kNumVertices, 0); 246 AddExpectationsForSimulatedAttrib0(kNumVertices, 0);
312 SetupExpectationsForApplyingDefaultDirtyState(); 247 SetupExpectationsForApplyingDefaultDirtyState();
313 248
314 EXPECT_CALL(*gl_, DrawArrays(GL_TRIANGLES, 0, kNumVertices)) 249 EXPECT_CALL(*gl_, DrawArrays(GL_TRIANGLES, 0, kNumVertices))
315 .Times(1) 250 .Times(1)
316 .RetiresOnSaturation(); 251 .RetiresOnSaturation();
317 DrawArrays cmd; 252 DrawArrays cmd;
318 cmd.Init(GL_TRIANGLES, 0, kNumVertices); 253 cmd.Init(GL_TRIANGLES, 0, kNumVertices);
319 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 254 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
320 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 255 EXPECT_EQ(GL_NO_ERROR, GetGLError());
321 } 256 }
322 257
323 // Tests when the math overflows (0x40000000 * sizeof GLfloat) 258 // Tests when the math overflows (0x40000000 * sizeof GLfloat)
324 TEST_P(GLES2DecoderWithShaderTest, DrawArraysSimulatedAttrib0OverflowFails) { 259 TEST_F(GLES2DecoderWithShaderTest, DrawArraysSimulatedAttrib0OverflowFails) {
325 const GLsizei kLargeCount = 0x40000000; 260 const GLsizei kLargeCount = 0x40000000;
326 SetupTexture(); 261 SetupTexture();
327 EXPECT_CALL(*gl_, DrawArrays(_, _, _)) 262 EXPECT_CALL(*gl_, DrawArrays(_, _, _))
328 .Times(0) 263 .Times(0)
329 .RetiresOnSaturation(); 264 .RetiresOnSaturation();
330 DrawArrays cmd; 265 DrawArrays cmd;
331 cmd.Init(GL_TRIANGLES, 0, kLargeCount); 266 cmd.Init(GL_TRIANGLES, 0, kLargeCount);
332 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 267 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
333 EXPECT_EQ(GL_OUT_OF_MEMORY, GetGLError()); 268 EXPECT_EQ(GL_OUT_OF_MEMORY, GetGLError());
334 EXPECT_FALSE(GetDecoder()->WasContextLost()); 269 EXPECT_FALSE(GetDecoder()->WasContextLost());
335 } 270 }
336 271
337 // Tests when the math overflows (0x7FFFFFFF + 1 = 0x8000000 verts) 272 // Tests when the math overflows (0x7FFFFFFF + 1 = 0x8000000 verts)
338 TEST_P(GLES2DecoderWithShaderTest, DrawArraysSimulatedAttrib0PosToNegFails) { 273 TEST_F(GLES2DecoderWithShaderTest, DrawArraysSimulatedAttrib0PosToNegFails) {
339 const GLsizei kLargeCount = 0x7FFFFFFF; 274 const GLsizei kLargeCount = 0x7FFFFFFF;
340 SetupTexture(); 275 SetupTexture();
341 EXPECT_CALL(*gl_, DrawArrays(_, _, _)) 276 EXPECT_CALL(*gl_, DrawArrays(_, _, _))
342 .Times(0) 277 .Times(0)
343 .RetiresOnSaturation(); 278 .RetiresOnSaturation();
344 DrawArrays cmd; 279 DrawArrays cmd;
345 cmd.Init(GL_TRIANGLES, 0, kLargeCount); 280 cmd.Init(GL_TRIANGLES, 0, kLargeCount);
346 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 281 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
347 EXPECT_EQ(GL_OUT_OF_MEMORY, GetGLError()); 282 EXPECT_EQ(GL_OUT_OF_MEMORY, GetGLError());
348 EXPECT_FALSE(GetDecoder()->WasContextLost()); 283 EXPECT_FALSE(GetDecoder()->WasContextLost());
349 } 284 }
350 285
351 // Tests when the driver returns an error 286 // Tests when the driver returns an error
352 TEST_P(GLES2DecoderWithShaderTest, DrawArraysSimulatedAttrib0OOMFails) { 287 TEST_F(GLES2DecoderWithShaderTest, DrawArraysSimulatedAttrib0OOMFails) {
353 const GLsizei kFakeLargeCount = 0x1234; 288 const GLsizei kFakeLargeCount = 0x1234;
354 SetupTexture(); 289 SetupTexture();
355 AddExpectationsForSimulatedAttrib0WithError( 290 AddExpectationsForSimulatedAttrib0WithError(
356 kFakeLargeCount, 0, GL_OUT_OF_MEMORY); 291 kFakeLargeCount, 0, GL_OUT_OF_MEMORY);
357 EXPECT_CALL(*gl_, DrawArrays(_, _, _)) 292 EXPECT_CALL(*gl_, DrawArrays(_, _, _))
358 .Times(0) 293 .Times(0)
359 .RetiresOnSaturation(); 294 .RetiresOnSaturation();
360 DrawArrays cmd; 295 DrawArrays cmd;
361 cmd.Init(GL_TRIANGLES, 0, kFakeLargeCount); 296 cmd.Init(GL_TRIANGLES, 0, kFakeLargeCount);
362 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 297 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
363 EXPECT_EQ(GL_OUT_OF_MEMORY, GetGLError()); 298 EXPECT_EQ(GL_OUT_OF_MEMORY, GetGLError());
364 EXPECT_FALSE(GetDecoder()->WasContextLost()); 299 EXPECT_FALSE(GetDecoder()->WasContextLost());
365 } 300 }
366 301
367 // Test that we lose context. 302 // Test that we lose context.
368 TEST_P(GLES2DecoderManualInitTest, LoseContextWhenOOM) { 303 TEST_F(GLES2DecoderManualInitTest, LoseContextWhenOOM) {
369 InitState init; 304 InitState init;
370 init.gl_version = "3.0"; 305 init.gl_version = "3.0";
371 init.has_alpha = true; 306 init.has_alpha = true;
372 init.has_depth = true; 307 init.has_depth = true;
373 init.request_alpha = true; 308 init.request_alpha = true;
374 init.request_depth = true; 309 init.request_depth = true;
375 init.bind_generates_resource = true; 310 init.bind_generates_resource = true;
376 init.lose_context_when_out_of_memory = true; 311 init.lose_context_when_out_of_memory = true;
377 InitDecoder(init); 312 InitDecoder(init);
378 SetupDefaultProgram(); 313 SetupDefaultProgram();
379 314
380 const GLsizei kFakeLargeCount = 0x1234; 315 const GLsizei kFakeLargeCount = 0x1234;
381 SetupTexture(); 316 SetupTexture();
382 AddExpectationsForSimulatedAttrib0WithError( 317 AddExpectationsForSimulatedAttrib0WithError(
383 kFakeLargeCount, 0, GL_OUT_OF_MEMORY); 318 kFakeLargeCount, 0, GL_OUT_OF_MEMORY);
384 EXPECT_CALL(*gl_, DrawArrays(_, _, _)).Times(0).RetiresOnSaturation(); 319 EXPECT_CALL(*gl_, DrawArrays(_, _, _)).Times(0).RetiresOnSaturation();
385 // Other contexts in the group should be lost also. 320 // Other contexts in the group should be lost also.
386 EXPECT_CALL(*mock_decoder_, LoseContext(GL_UNKNOWN_CONTEXT_RESET_ARB)) 321 EXPECT_CALL(*mock_decoder_, LoseContext(GL_UNKNOWN_CONTEXT_RESET_ARB))
387 .Times(1) 322 .Times(1)
388 .RetiresOnSaturation(); 323 .RetiresOnSaturation();
389 DrawArrays cmd; 324 DrawArrays cmd;
390 cmd.Init(GL_TRIANGLES, 0, kFakeLargeCount); 325 cmd.Init(GL_TRIANGLES, 0, kFakeLargeCount);
391 // This context should be lost. 326 // This context should be lost.
392 EXPECT_EQ(error::kLostContext, ExecuteCmd(cmd)); 327 EXPECT_EQ(error::kLostContext, ExecuteCmd(cmd));
393 EXPECT_EQ(GL_OUT_OF_MEMORY, GetGLError()); 328 EXPECT_EQ(GL_OUT_OF_MEMORY, GetGLError());
394 EXPECT_TRUE(decoder_->WasContextLost()); 329 EXPECT_TRUE(decoder_->WasContextLost());
395 } 330 }
396 331
397 TEST_P(GLES2DecoderWithShaderTest, DrawArraysBadTextureUsesBlack) { 332 TEST_F(GLES2DecoderWithShaderTest, DrawArraysBadTextureUsesBlack) {
398 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); 333 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId);
399 // This is an NPOT texture. As the default filtering requires mips 334 // This is an NPOT texture. As the default filtering requires mips
400 // this should trigger replacing with black textures before rendering. 335 // this should trigger replacing with black textures before rendering.
401 DoTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 3, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 336 DoTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 3, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE,
402 kSharedMemoryId, kSharedMemoryOffset); 337 kSharedMemoryId, kSharedMemoryOffset);
403 AddExpectationsForSimulatedAttrib0(kNumVertices, 0); 338 AddExpectationsForSimulatedAttrib0(kNumVertices, 0);
404 { 339 {
405 InSequence sequence; 340 InSequence sequence;
406 EXPECT_CALL(*gl_, ActiveTexture(GL_TEXTURE0)) 341 EXPECT_CALL(*gl_, ActiveTexture(GL_TEXTURE0))
407 .Times(1) 342 .Times(1)
(...skipping 15 matching lines...) Expand all
423 .Times(1) 358 .Times(1)
424 .RetiresOnSaturation(); 359 .RetiresOnSaturation();
425 } 360 }
426 SetupExpectationsForApplyingDefaultDirtyState(); 361 SetupExpectationsForApplyingDefaultDirtyState();
427 DrawArrays cmd; 362 DrawArrays cmd;
428 cmd.Init(GL_TRIANGLES, 0, kNumVertices); 363 cmd.Init(GL_TRIANGLES, 0, kNumVertices);
429 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 364 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
430 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 365 EXPECT_EQ(GL_NO_ERROR, GetGLError());
431 } 366 }
432 367
433 TEST_P(GLES2DecoderWithShaderTest, DrawArraysMissingAttributesFails) { 368 TEST_F(GLES2DecoderWithShaderTest, DrawArraysMissingAttributesFails) {
434 DoEnableVertexAttribArray(1); 369 DoEnableVertexAttribArray(1);
435 370
436 EXPECT_CALL(*gl_, DrawArrays(_, _, _)) 371 EXPECT_CALL(*gl_, DrawArrays(_, _, _))
437 .Times(0); 372 .Times(0);
438 DrawArrays cmd; 373 DrawArrays cmd;
439 cmd.Init(GL_TRIANGLES, 0, kNumVertices); 374 cmd.Init(GL_TRIANGLES, 0, kNumVertices);
440 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 375 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
441 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); 376 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
442 } 377 }
443 378
444 TEST_P(GLES2DecoderWithShaderTest, 379 TEST_F(GLES2DecoderWithShaderTest,
445 DrawArraysMissingAttributesZeroCountSucceeds) { 380 DrawArraysMissingAttributesZeroCountSucceeds) {
446 DoEnableVertexAttribArray(1); 381 DoEnableVertexAttribArray(1);
447 382
448 EXPECT_CALL(*gl_, DrawArrays(_, _, _)) 383 EXPECT_CALL(*gl_, DrawArrays(_, _, _))
449 .Times(0); 384 .Times(0);
450 DrawArrays cmd; 385 DrawArrays cmd;
451 cmd.Init(GL_TRIANGLES, 0, 0); 386 cmd.Init(GL_TRIANGLES, 0, 0);
452 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 387 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
453 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 388 EXPECT_EQ(GL_NO_ERROR, GetGLError());
454 } 389 }
455 390
456 TEST_P(GLES2DecoderWithShaderTest, DrawArraysValidAttributesSucceeds) { 391 TEST_F(GLES2DecoderWithShaderTest, DrawArraysValidAttributesSucceeds) {
457 SetupTexture(); 392 SetupTexture();
458 SetupVertexBuffer(); 393 SetupVertexBuffer();
459 DoEnableVertexAttribArray(1); 394 DoEnableVertexAttribArray(1);
460 DoVertexAttribPointer(1, 2, GL_FLOAT, 0, 0); 395 DoVertexAttribPointer(1, 2, GL_FLOAT, 0, 0);
461 AddExpectationsForSimulatedAttrib0(kNumVertices, kServiceBufferId); 396 AddExpectationsForSimulatedAttrib0(kNumVertices, kServiceBufferId);
462 SetupExpectationsForApplyingDefaultDirtyState(); 397 SetupExpectationsForApplyingDefaultDirtyState();
463 398
464 EXPECT_CALL(*gl_, DrawArrays(GL_TRIANGLES, 0, kNumVertices)) 399 EXPECT_CALL(*gl_, DrawArrays(GL_TRIANGLES, 0, kNumVertices))
465 .Times(1) 400 .Times(1)
466 .RetiresOnSaturation(); 401 .RetiresOnSaturation();
467 DrawArrays cmd; 402 DrawArrays cmd;
468 cmd.Init(GL_TRIANGLES, 0, kNumVertices); 403 cmd.Init(GL_TRIANGLES, 0, kNumVertices);
469 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 404 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
470 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 405 EXPECT_EQ(GL_NO_ERROR, GetGLError());
471 } 406 }
472 407
473 // Same as DrawArraysValidAttributesSucceeds, but with workaround 408 // Same as DrawArraysValidAttributesSucceeds, but with workaround
474 // |init_vertex_attributes|. 409 // |init_vertex_attributes|.
475 TEST_P(GLES2DecoderManualInitTest, InitVertexAttributes) { 410 TEST_F(GLES2DecoderManualInitTest, InitVertexAttributes) {
476 CommandLine command_line(0, NULL); 411 CommandLine command_line(0, NULL);
477 command_line.AppendSwitchASCII( 412 command_line.AppendSwitchASCII(
478 switches::kGpuDriverBugWorkarounds, 413 switches::kGpuDriverBugWorkarounds,
479 base::IntToString(gpu::INIT_VERTEX_ATTRIBUTES)); 414 base::IntToString(gpu::INIT_VERTEX_ATTRIBUTES));
480 InitState init; 415 InitState init;
481 init.gl_version = "3.0"; 416 init.gl_version = "3.0";
482 init.has_alpha = true; 417 init.has_alpha = true;
483 init.has_depth = true; 418 init.has_depth = true;
484 init.request_alpha = true; 419 init.request_alpha = true;
485 init.request_depth = true; 420 init.request_depth = true;
486 init.bind_generates_resource = true; 421 init.bind_generates_resource = true;
487 InitDecoderWithCommandLine(init, &command_line); 422 InitDecoderWithCommandLine(init, &command_line);
488 SetupDefaultProgram(); 423 SetupDefaultProgram();
489 SetupTexture(); 424 SetupTexture();
490 SetupVertexBuffer(); 425 SetupVertexBuffer();
491 DoEnableVertexAttribArray(1); 426 DoEnableVertexAttribArray(1);
492 DoVertexAttribPointer(1, 2, GL_FLOAT, 0, 0); 427 DoVertexAttribPointer(1, 2, GL_FLOAT, 0, 0);
493 AddExpectationsForSimulatedAttrib0(kNumVertices, kServiceBufferId); 428 AddExpectationsForSimulatedAttrib0(kNumVertices, kServiceBufferId);
494 SetupExpectationsForApplyingDefaultDirtyState(); 429 SetupExpectationsForApplyingDefaultDirtyState();
495 430
496 EXPECT_CALL(*gl_, DrawArrays(GL_TRIANGLES, 0, kNumVertices)) 431 EXPECT_CALL(*gl_, DrawArrays(GL_TRIANGLES, 0, kNumVertices))
497 .Times(1) 432 .Times(1)
498 .RetiresOnSaturation(); 433 .RetiresOnSaturation();
499 DrawArrays cmd; 434 DrawArrays cmd;
500 cmd.Init(GL_TRIANGLES, 0, kNumVertices); 435 cmd.Init(GL_TRIANGLES, 0, kNumVertices);
501 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 436 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
502 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 437 EXPECT_EQ(GL_NO_ERROR, GetGLError());
503 } 438 }
504 439
505 TEST_P(GLES2DecoderWithShaderTest, DrawArraysDeletedBufferFails) { 440 TEST_F(GLES2DecoderWithShaderTest, DrawArraysDeletedBufferFails) {
506 SetupVertexBuffer(); 441 SetupVertexBuffer();
507 DoVertexAttribPointer(1, 2, GL_FLOAT, 0, 0); 442 DoVertexAttribPointer(1, 2, GL_FLOAT, 0, 0);
508 DeleteVertexBuffer(); 443 DeleteVertexBuffer();
509 444
510 EXPECT_CALL(*gl_, DrawArrays(_, _, _)) 445 EXPECT_CALL(*gl_, DrawArrays(_, _, _))
511 .Times(0); 446 .Times(0);
512 DrawArrays cmd; 447 DrawArrays cmd;
513 cmd.Init(GL_TRIANGLES, 0, kNumVertices); 448 cmd.Init(GL_TRIANGLES, 0, kNumVertices);
514 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 449 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
515 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); 450 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
516 } 451 }
517 452
518 TEST_P(GLES2DecoderWithShaderTest, DrawArraysDeletedProgramSucceeds) { 453 TEST_F(GLES2DecoderWithShaderTest, DrawArraysDeletedProgramSucceeds) {
519 SetupTexture(); 454 SetupTexture();
520 AddExpectationsForSimulatedAttrib0(kNumVertices, 0); 455 AddExpectationsForSimulatedAttrib0(kNumVertices, 0);
521 SetupExpectationsForApplyingDefaultDirtyState(); 456 SetupExpectationsForApplyingDefaultDirtyState();
522 DoDeleteProgram(client_program_id_, kServiceProgramId); 457 DoDeleteProgram(client_program_id_, kServiceProgramId);
523 458
524 EXPECT_CALL(*gl_, DrawArrays(_, _, _)) 459 EXPECT_CALL(*gl_, DrawArrays(_, _, _))
525 .Times(1) 460 .Times(1)
526 .RetiresOnSaturation(); 461 .RetiresOnSaturation();
527 EXPECT_CALL(*gl_, DeleteProgram(kServiceProgramId)) 462 EXPECT_CALL(*gl_, DeleteProgram(kServiceProgramId))
528 .Times(1); 463 .Times(1);
529 DrawArrays cmd; 464 DrawArrays cmd;
530 cmd.Init(GL_TRIANGLES, 0, kNumVertices); 465 cmd.Init(GL_TRIANGLES, 0, kNumVertices);
531 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 466 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
532 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 467 EXPECT_EQ(GL_NO_ERROR, GetGLError());
533 } 468 }
534 469
535 TEST_P(GLES2DecoderWithShaderTest, DrawArraysWithInvalidModeFails) { 470 TEST_F(GLES2DecoderWithShaderTest, DrawArraysWithInvalidModeFails) {
536 SetupVertexBuffer(); 471 SetupVertexBuffer();
537 DoVertexAttribPointer(1, 2, GL_FLOAT, 0, 0); 472 DoVertexAttribPointer(1, 2, GL_FLOAT, 0, 0);
538 473
539 EXPECT_CALL(*gl_, DrawArrays(_, _, _)) 474 EXPECT_CALL(*gl_, DrawArrays(_, _, _))
540 .Times(0); 475 .Times(0);
541 DrawArrays cmd; 476 DrawArrays cmd;
542 cmd.Init(GL_QUADS, 0, 1); 477 cmd.Init(GL_QUADS, 0, 1);
543 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 478 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
544 EXPECT_EQ(GL_INVALID_ENUM, GetGLError()); 479 EXPECT_EQ(GL_INVALID_ENUM, GetGLError());
545 cmd.Init(GL_POLYGON, 0, 1); 480 cmd.Init(GL_POLYGON, 0, 1);
546 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 481 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
547 EXPECT_EQ(GL_INVALID_ENUM, GetGLError()); 482 EXPECT_EQ(GL_INVALID_ENUM, GetGLError());
548 } 483 }
549 484
550 TEST_P(GLES2DecoderWithShaderTest, DrawArraysInvalidCountFails) { 485 TEST_F(GLES2DecoderWithShaderTest, DrawArraysInvalidCountFails) {
551 SetupVertexBuffer(); 486 SetupVertexBuffer();
552 DoVertexAttribPointer(1, 2, GL_FLOAT, 0, 0); 487 DoVertexAttribPointer(1, 2, GL_FLOAT, 0, 0);
553 488
554 // Try start > 0 489 // Try start > 0
555 EXPECT_CALL(*gl_, DrawArrays(_, _, _)).Times(0); 490 EXPECT_CALL(*gl_, DrawArrays(_, _, _)).Times(0);
556 DrawArrays cmd; 491 DrawArrays cmd;
557 cmd.Init(GL_TRIANGLES, 1, kNumVertices); 492 cmd.Init(GL_TRIANGLES, 1, kNumVertices);
558 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 493 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
559 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); 494 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
560 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 495 EXPECT_EQ(GL_NO_ERROR, GetGLError());
(...skipping 17 matching lines...) Expand all
578 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); 513 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
579 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 514 EXPECT_EQ(GL_NO_ERROR, GetGLError());
580 515
581 // Try with stride > 8 (vec2 + vec2 byte) 516 // Try with stride > 8 (vec2 + vec2 byte)
582 DoVertexAttribPointer(1, 2, GL_FLOAT, sizeof(GLfloat) * 3, 0); 517 DoVertexAttribPointer(1, 2, GL_FLOAT, sizeof(GLfloat) * 3, 0);
583 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 518 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
584 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); 519 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
585 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 520 EXPECT_EQ(GL_NO_ERROR, GetGLError());
586 } 521 }
587 522
588 TEST_P(GLES2DecoderWithShaderTest, DrawArraysInstancedANGLEFails) { 523 TEST_F(GLES2DecoderWithShaderTest, DrawArraysInstancedANGLEFails) {
589 SetupTexture(); 524 SetupTexture();
590 SetupVertexBuffer(); 525 SetupVertexBuffer();
591 DoEnableVertexAttribArray(1); 526 DoEnableVertexAttribArray(1);
592 DoVertexAttribPointer(1, 2, GL_FLOAT, 0, 0); 527 DoVertexAttribPointer(1, 2, GL_FLOAT, 0, 0);
593 528
594 EXPECT_CALL(*gl_, DrawArraysInstancedANGLE(_, _, _, _)) 529 EXPECT_CALL(*gl_, DrawArraysInstancedANGLE(_, _, _, _))
595 .Times(0) 530 .Times(0)
596 .RetiresOnSaturation(); 531 .RetiresOnSaturation();
597 DrawArraysInstancedANGLE cmd; 532 DrawArraysInstancedANGLE cmd;
598 cmd.Init(GL_TRIANGLES, 0, kNumVertices, 1); 533 cmd.Init(GL_TRIANGLES, 0, kNumVertices, 1);
599 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 534 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
600 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); 535 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
601 } 536 }
602 537
603 TEST_P(GLES2DecoderGeometryInstancingTest, 538 TEST_F(GLES2DecoderGeometryInstancingTest,
604 DrawArraysInstancedANGLENoAttributesFails) { 539 DrawArraysInstancedANGLENoAttributesFails) {
605 SetupTexture(); 540 SetupTexture();
606 541
607 EXPECT_CALL(*gl_, DrawArraysInstancedANGLE(_, _, _, _)) 542 EXPECT_CALL(*gl_, DrawArraysInstancedANGLE(_, _, _, _))
608 .Times(0) 543 .Times(0)
609 .RetiresOnSaturation(); 544 .RetiresOnSaturation();
610 DrawArraysInstancedANGLE cmd; 545 DrawArraysInstancedANGLE cmd;
611 cmd.Init(GL_TRIANGLES, 0, kNumVertices, 1); 546 cmd.Init(GL_TRIANGLES, 0, kNumVertices, 1);
612 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 547 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
613 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); 548 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
614 } 549 }
615 550
616 TEST_P(GLES2DecoderGeometryInstancingTest, 551 TEST_F(GLES2DecoderGeometryInstancingTest,
617 DrawArraysInstancedANGLESimulatedAttrib0) { 552 DrawArraysInstancedANGLESimulatedAttrib0) {
618 SetupTexture(); 553 SetupTexture();
619 SetupVertexBuffer(); 554 SetupVertexBuffer();
620 DoVertexAttribPointer(1, 2, GL_FLOAT, 0, 0); 555 DoVertexAttribPointer(1, 2, GL_FLOAT, 0, 0);
621 556
622 AddExpectationsForSimulatedAttrib0(kNumVertices, kServiceBufferId); 557 AddExpectationsForSimulatedAttrib0(kNumVertices, kServiceBufferId);
623 SetupExpectationsForApplyingDefaultDirtyState(); 558 SetupExpectationsForApplyingDefaultDirtyState();
624 559
625 DoVertexAttribDivisorANGLE(0, 1); 560 DoVertexAttribDivisorANGLE(0, 1);
626 EXPECT_CALL(*gl_, DrawArraysInstancedANGLE(GL_TRIANGLES, 0, kNumVertices, 3)) 561 EXPECT_CALL(*gl_, DrawArraysInstancedANGLE(GL_TRIANGLES, 0, kNumVertices, 3))
627 .Times(1) 562 .Times(1)
628 .RetiresOnSaturation(); 563 .RetiresOnSaturation();
629 EXPECT_CALL(*gl_, VertexAttribDivisorANGLE(0, 0)) 564 EXPECT_CALL(*gl_, VertexAttribDivisorANGLE(0, 0))
630 .Times(1) 565 .Times(1)
631 .RetiresOnSaturation(); 566 .RetiresOnSaturation();
632 EXPECT_CALL(*gl_, VertexAttribDivisorANGLE(0, 1)) 567 EXPECT_CALL(*gl_, VertexAttribDivisorANGLE(0, 1))
633 .Times(1) 568 .Times(1)
634 .RetiresOnSaturation(); 569 .RetiresOnSaturation();
635 DrawArraysInstancedANGLE cmd; 570 DrawArraysInstancedANGLE cmd;
636 cmd.Init(GL_TRIANGLES, 0, kNumVertices, 3); 571 cmd.Init(GL_TRIANGLES, 0, kNumVertices, 3);
637 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 572 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
638 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 573 EXPECT_EQ(GL_NO_ERROR, GetGLError());
639 } 574 }
640 575
641 TEST_P(GLES2DecoderGeometryInstancingTest, 576 TEST_F(GLES2DecoderGeometryInstancingTest,
642 DrawArraysInstancedANGLEMissingAttributesFails) { 577 DrawArraysInstancedANGLEMissingAttributesFails) {
643 DoEnableVertexAttribArray(1); 578 DoEnableVertexAttribArray(1);
644 579
645 EXPECT_CALL(*gl_, DrawArraysInstancedANGLE(_, _, _, _)) 580 EXPECT_CALL(*gl_, DrawArraysInstancedANGLE(_, _, _, _))
646 .Times(0); 581 .Times(0);
647 DrawArraysInstancedANGLE cmd; 582 DrawArraysInstancedANGLE cmd;
648 cmd.Init(GL_TRIANGLES, 0, kNumVertices, 1); 583 cmd.Init(GL_TRIANGLES, 0, kNumVertices, 1);
649 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 584 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
650 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); 585 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
651 } 586 }
652 587
653 TEST_P(GLES2DecoderGeometryInstancingTest, 588 TEST_F(GLES2DecoderGeometryInstancingTest,
654 DrawArraysInstancedANGLEMissingAttributesZeroCountSucceeds) { 589 DrawArraysInstancedANGLEMissingAttributesZeroCountSucceeds) {
655 DoEnableVertexAttribArray(1); 590 DoEnableVertexAttribArray(1);
656 591
657 EXPECT_CALL(*gl_, DrawArraysInstancedANGLE(_, _, _, _)) 592 EXPECT_CALL(*gl_, DrawArraysInstancedANGLE(_, _, _, _))
658 .Times(0); 593 .Times(0);
659 DrawArraysInstancedANGLE cmd; 594 DrawArraysInstancedANGLE cmd;
660 cmd.Init(GL_TRIANGLES, 0, 0, 1); 595 cmd.Init(GL_TRIANGLES, 0, 0, 1);
661 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 596 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
662 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 597 EXPECT_EQ(GL_NO_ERROR, GetGLError());
663 } 598 }
664 599
665 TEST_P(GLES2DecoderGeometryInstancingTest, 600 TEST_F(GLES2DecoderGeometryInstancingTest,
666 DrawArraysInstancedANGLEValidAttributesSucceeds) { 601 DrawArraysInstancedANGLEValidAttributesSucceeds) {
667 SetupTexture(); 602 SetupTexture();
668 SetupVertexBuffer(); 603 SetupVertexBuffer();
669 DoEnableVertexAttribArray(1); 604 DoEnableVertexAttribArray(1);
670 DoVertexAttribPointer(1, 2, GL_FLOAT, 0, 0); 605 DoVertexAttribPointer(1, 2, GL_FLOAT, 0, 0);
671 AddExpectationsForSimulatedAttrib0(kNumVertices, kServiceBufferId); 606 AddExpectationsForSimulatedAttrib0(kNumVertices, kServiceBufferId);
672 SetupExpectationsForApplyingDefaultDirtyState(); 607 SetupExpectationsForApplyingDefaultDirtyState();
673 608
674 EXPECT_CALL(*gl_, DrawArraysInstancedANGLE(GL_TRIANGLES, 0, kNumVertices, 1)) 609 EXPECT_CALL(*gl_, DrawArraysInstancedANGLE(GL_TRIANGLES, 0, kNumVertices, 1))
675 .Times(1) 610 .Times(1)
676 .RetiresOnSaturation(); 611 .RetiresOnSaturation();
677 DrawArraysInstancedANGLE cmd; 612 DrawArraysInstancedANGLE cmd;
678 cmd.Init(GL_TRIANGLES, 0, kNumVertices, 1); 613 cmd.Init(GL_TRIANGLES, 0, kNumVertices, 1);
679 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 614 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
680 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 615 EXPECT_EQ(GL_NO_ERROR, GetGLError());
681 } 616 }
682 617
683 TEST_P(GLES2DecoderGeometryInstancingTest, 618 TEST_F(GLES2DecoderGeometryInstancingTest,
684 DrawArraysInstancedANGLEWithInvalidModeFails) { 619 DrawArraysInstancedANGLEWithInvalidModeFails) {
685 SetupVertexBuffer(); 620 SetupVertexBuffer();
686 DoVertexAttribPointer(1, 2, GL_FLOAT, 0, 0); 621 DoVertexAttribPointer(1, 2, GL_FLOAT, 0, 0);
687 622
688 EXPECT_CALL(*gl_, DrawArraysInstancedANGLE(_, _, _, _)) 623 EXPECT_CALL(*gl_, DrawArraysInstancedANGLE(_, _, _, _))
689 .Times(0); 624 .Times(0);
690 DrawArraysInstancedANGLE cmd; 625 DrawArraysInstancedANGLE cmd;
691 cmd.Init(GL_QUADS, 0, 1, 1); 626 cmd.Init(GL_QUADS, 0, 1, 1);
692 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 627 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
693 EXPECT_EQ(GL_INVALID_ENUM, GetGLError()); 628 EXPECT_EQ(GL_INVALID_ENUM, GetGLError());
694 cmd.Init(GL_POLYGON, 0, 1, 1); 629 cmd.Init(GL_POLYGON, 0, 1, 1);
695 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 630 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
696 EXPECT_EQ(GL_INVALID_ENUM, GetGLError()); 631 EXPECT_EQ(GL_INVALID_ENUM, GetGLError());
697 } 632 }
698 633
699 TEST_P(GLES2DecoderGeometryInstancingTest, 634 TEST_F(GLES2DecoderGeometryInstancingTest,
700 DrawArraysInstancedANGLEInvalidPrimcountFails) { 635 DrawArraysInstancedANGLEInvalidPrimcountFails) {
701 SetupVertexBuffer(); 636 SetupVertexBuffer();
702 DoVertexAttribPointer(1, 2, GL_FLOAT, 0, 0); 637 DoVertexAttribPointer(1, 2, GL_FLOAT, 0, 0);
703 638
704 EXPECT_CALL(*gl_, DrawArraysInstancedANGLE(_, _, _, _)) 639 EXPECT_CALL(*gl_, DrawArraysInstancedANGLE(_, _, _, _))
705 .Times(0); 640 .Times(0);
706 DrawArraysInstancedANGLE cmd; 641 DrawArraysInstancedANGLE cmd;
707 cmd.Init(GL_TRIANGLES, 0, 1, -1); 642 cmd.Init(GL_TRIANGLES, 0, 1, -1);
708 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 643 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
709 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); 644 EXPECT_EQ(GL_INVALID_VALUE, GetGLError());
710 } 645 }
711 646
712 // Per-instance data is twice as large, but number of instances is half 647 // Per-instance data is twice as large, but number of instances is half
713 TEST_P(GLES2DecoderGeometryInstancingTest, 648 TEST_F(GLES2DecoderGeometryInstancingTest,
714 DrawArraysInstancedANGLELargeInstanceSucceeds) { 649 DrawArraysInstancedANGLELargeInstanceSucceeds) {
715 SetupTexture(); 650 SetupTexture();
716 SetupVertexBuffer(); 651 SetupVertexBuffer();
717 SetupExpectationsForApplyingDefaultDirtyState(); 652 SetupExpectationsForApplyingDefaultDirtyState();
718 DoVertexAttribPointer(1, 2, GL_FLOAT, 0, 0); 653 DoVertexAttribPointer(1, 2, GL_FLOAT, 0, 0);
719 654
720 DoEnableVertexAttribArray(0); 655 DoEnableVertexAttribArray(0);
721 DoVertexAttribPointer(0, 4, GL_FLOAT, 0, 0); 656 DoVertexAttribPointer(0, 4, GL_FLOAT, 0, 0);
722 DoVertexAttribDivisorANGLE(0, 1); 657 DoVertexAttribDivisorANGLE(0, 1);
723 EXPECT_CALL(*gl_, DrawArraysInstancedANGLE(GL_TRIANGLES, 0, kNumVertices, 658 EXPECT_CALL(*gl_, DrawArraysInstancedANGLE(GL_TRIANGLES, 0, kNumVertices,
724 kNumVertices / 2)) 659 kNumVertices / 2))
725 .Times(1) 660 .Times(1)
726 .RetiresOnSaturation(); 661 .RetiresOnSaturation();
727 DrawArraysInstancedANGLE cmd; 662 DrawArraysInstancedANGLE cmd;
728 cmd.Init(GL_TRIANGLES, 0, kNumVertices, kNumVertices / 2); 663 cmd.Init(GL_TRIANGLES, 0, kNumVertices, kNumVertices / 2);
729 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 664 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
730 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 665 EXPECT_EQ(GL_NO_ERROR, GetGLError());
731 } 666 }
732 667
733 // Per-instance data is twice as large, but divisor is twice 668 // Per-instance data is twice as large, but divisor is twice
734 TEST_P(GLES2DecoderGeometryInstancingTest, 669 TEST_F(GLES2DecoderGeometryInstancingTest,
735 DrawArraysInstancedANGLELargeDivisorSucceeds) { 670 DrawArraysInstancedANGLELargeDivisorSucceeds) {
736 SetupTexture(); 671 SetupTexture();
737 SetupVertexBuffer(); 672 SetupVertexBuffer();
738 SetupExpectationsForApplyingDefaultDirtyState(); 673 SetupExpectationsForApplyingDefaultDirtyState();
739 DoVertexAttribPointer(1, 2, GL_FLOAT, 0, 0); 674 DoVertexAttribPointer(1, 2, GL_FLOAT, 0, 0);
740 675
741 DoEnableVertexAttribArray(0); 676 DoEnableVertexAttribArray(0);
742 DoVertexAttribPointer(0, 4, GL_FLOAT, 0, 0); 677 DoVertexAttribPointer(0, 4, GL_FLOAT, 0, 0);
743 DoVertexAttribDivisorANGLE(0, 2); 678 DoVertexAttribDivisorANGLE(0, 2);
744 EXPECT_CALL(*gl_, DrawArraysInstancedANGLE(GL_TRIANGLES, 0, kNumVertices, 679 EXPECT_CALL(*gl_, DrawArraysInstancedANGLE(GL_TRIANGLES, 0, kNumVertices,
745 kNumVertices)) 680 kNumVertices))
746 .Times(1) 681 .Times(1)
747 .RetiresOnSaturation(); 682 .RetiresOnSaturation();
748 DrawArraysInstancedANGLE cmd; 683 DrawArraysInstancedANGLE cmd;
749 cmd.Init(GL_TRIANGLES, 0, kNumVertices, kNumVertices); 684 cmd.Init(GL_TRIANGLES, 0, kNumVertices, kNumVertices);
750 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 685 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
751 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 686 EXPECT_EQ(GL_NO_ERROR, GetGLError());
752 } 687 }
753 688
754 TEST_P(GLES2DecoderGeometryInstancingTest, DrawArraysInstancedANGLELargeFails) { 689 TEST_F(GLES2DecoderGeometryInstancingTest, DrawArraysInstancedANGLELargeFails) {
755 SetupTexture(); 690 SetupTexture();
756 SetupVertexBuffer(); 691 SetupVertexBuffer();
757 DoVertexAttribPointer(1, 2, GL_FLOAT, 0, 0); 692 DoVertexAttribPointer(1, 2, GL_FLOAT, 0, 0);
758 693
759 DoEnableVertexAttribArray(0); 694 DoEnableVertexAttribArray(0);
760 DoVertexAttribPointer(0, 2, GL_FLOAT, 0, 0); 695 DoVertexAttribPointer(0, 2, GL_FLOAT, 0, 0);
761 DoVertexAttribDivisorANGLE(0, 1); 696 DoVertexAttribDivisorANGLE(0, 1);
762 EXPECT_CALL(*gl_, DrawArraysInstancedANGLE(_, _, _, _)) 697 EXPECT_CALL(*gl_, DrawArraysInstancedANGLE(_, _, _, _))
763 .Times(0) 698 .Times(0)
764 .RetiresOnSaturation(); 699 .RetiresOnSaturation();
765 DrawArraysInstancedANGLE cmd; 700 DrawArraysInstancedANGLE cmd;
766 cmd.Init(GL_TRIANGLES, 0, kNumVertices, kNumVertices + 1); 701 cmd.Init(GL_TRIANGLES, 0, kNumVertices, kNumVertices + 1);
767 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 702 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
768 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); 703 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
769 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 704 EXPECT_EQ(GL_NO_ERROR, GetGLError());
770 705
771 EXPECT_CALL(*gl_, DrawArraysInstancedANGLE(_, _, _, _)) 706 EXPECT_CALL(*gl_, DrawArraysInstancedANGLE(_, _, _, _))
772 .Times(0) 707 .Times(0)
773 .RetiresOnSaturation(); 708 .RetiresOnSaturation();
774 cmd.Init(GL_TRIANGLES, 0, kNumVertices + 1, kNumVertices); 709 cmd.Init(GL_TRIANGLES, 0, kNumVertices + 1, kNumVertices);
775 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 710 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
776 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); 711 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
777 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 712 EXPECT_EQ(GL_NO_ERROR, GetGLError());
778 } 713 }
779 714
780 // Per-index data is twice as large, but number of indices is half 715 // Per-index data is twice as large, but number of indices is half
781 TEST_P(GLES2DecoderGeometryInstancingTest, 716 TEST_F(GLES2DecoderGeometryInstancingTest,
782 DrawArraysInstancedANGLELargeIndexSucceeds) { 717 DrawArraysInstancedANGLELargeIndexSucceeds) {
783 SetupTexture(); 718 SetupTexture();
784 SetupVertexBuffer(); 719 SetupVertexBuffer();
785 SetupExpectationsForApplyingDefaultDirtyState(); 720 SetupExpectationsForApplyingDefaultDirtyState();
786 DoVertexAttribPointer(1, 4, GL_FLOAT, 0, 0); 721 DoVertexAttribPointer(1, 4, GL_FLOAT, 0, 0);
787 722
788 DoEnableVertexAttribArray(0); 723 DoEnableVertexAttribArray(0);
789 DoVertexAttribPointer(0, 2, GL_FLOAT, 0, 0); 724 DoVertexAttribPointer(0, 2, GL_FLOAT, 0, 0);
790 DoVertexAttribDivisorANGLE(0, 1); 725 DoVertexAttribDivisorANGLE(0, 1);
791 EXPECT_CALL(*gl_, DrawArraysInstancedANGLE(GL_TRIANGLES, 0, kNumVertices / 2, 726 EXPECT_CALL(*gl_, DrawArraysInstancedANGLE(GL_TRIANGLES, 0, kNumVertices / 2,
792 kNumVertices)) 727 kNumVertices))
793 .Times(1) 728 .Times(1)
794 .RetiresOnSaturation(); 729 .RetiresOnSaturation();
795 DrawArraysInstancedANGLE cmd; 730 DrawArraysInstancedANGLE cmd;
796 cmd.Init(GL_TRIANGLES, 0, kNumVertices / 2, kNumVertices); 731 cmd.Init(GL_TRIANGLES, 0, kNumVertices / 2, kNumVertices);
797 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 732 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
798 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 733 EXPECT_EQ(GL_NO_ERROR, GetGLError());
799 } 734 }
800 735
801 TEST_P(GLES2DecoderGeometryInstancingTest, 736 TEST_F(GLES2DecoderGeometryInstancingTest,
802 DrawArraysInstancedANGLENoDivisor0Fails) { 737 DrawArraysInstancedANGLENoDivisor0Fails) {
803 SetupTexture(); 738 SetupTexture();
804 SetupVertexBuffer(); 739 SetupVertexBuffer();
805 DoVertexAttribPointer(1, 2, GL_FLOAT, 0, 0); 740 DoVertexAttribPointer(1, 2, GL_FLOAT, 0, 0);
806 741
807 DoEnableVertexAttribArray(0); 742 DoEnableVertexAttribArray(0);
808 DoVertexAttribPointer(0, 2, GL_FLOAT, 0, 0); 743 DoVertexAttribPointer(0, 2, GL_FLOAT, 0, 0);
809 DoVertexAttribDivisorANGLE(0, 1); 744 DoVertexAttribDivisorANGLE(0, 1);
810 DoVertexAttribDivisorANGLE(1, 1); 745 DoVertexAttribDivisorANGLE(1, 1);
811 EXPECT_CALL(*gl_, DrawArraysInstancedANGLE(_, _, _, _)) 746 EXPECT_CALL(*gl_, DrawArraysInstancedANGLE(_, _, _, _))
812 .Times(0) 747 .Times(0)
813 .RetiresOnSaturation(); 748 .RetiresOnSaturation();
814 DrawArraysInstancedANGLE cmd; 749 DrawArraysInstancedANGLE cmd;
815 cmd.Init(GL_TRIANGLES, 0, kNumVertices, 1); 750 cmd.Init(GL_TRIANGLES, 0, kNumVertices, 1);
816 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 751 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
817 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); 752 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
818 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 753 EXPECT_EQ(GL_NO_ERROR, GetGLError());
819 } 754 }
820 755
821 TEST_P(GLES2DecoderWithShaderTest, DrawElementsNoAttributesSucceeds) { 756 TEST_F(GLES2DecoderWithShaderTest, DrawElementsNoAttributesSucceeds) {
822 SetupTexture(); 757 SetupTexture();
823 SetupIndexBuffer(); 758 SetupIndexBuffer();
824 AddExpectationsForSimulatedAttrib0(kMaxValidIndex + 1, 0); 759 AddExpectationsForSimulatedAttrib0(kMaxValidIndex + 1, 0);
825 SetupExpectationsForApplyingDefaultDirtyState(); 760 SetupExpectationsForApplyingDefaultDirtyState();
826 EXPECT_CALL(*gl_, DrawElements(GL_TRIANGLES, kValidIndexRangeCount, 761 EXPECT_CALL(*gl_, DrawElements(GL_TRIANGLES, kValidIndexRangeCount,
827 GL_UNSIGNED_SHORT, 762 GL_UNSIGNED_SHORT,
828 BufferOffset(kValidIndexRangeStart * 2))) 763 BufferOffset(kValidIndexRangeStart * 2)))
829 .Times(1) 764 .Times(1)
830 .RetiresOnSaturation(); 765 .RetiresOnSaturation();
831 DrawElements cmd; 766 DrawElements cmd;
832 cmd.Init(GL_TRIANGLES, kValidIndexRangeCount, GL_UNSIGNED_SHORT, 767 cmd.Init(GL_TRIANGLES, kValidIndexRangeCount, GL_UNSIGNED_SHORT,
833 kValidIndexRangeStart * 2); 768 kValidIndexRangeStart * 2);
834 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 769 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
835 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 770 EXPECT_EQ(GL_NO_ERROR, GetGLError());
836 } 771 }
837 772
838 TEST_P(GLES2DecoderWithShaderTest, DrawElementsMissingAttributesFails) { 773 TEST_F(GLES2DecoderWithShaderTest, DrawElementsMissingAttributesFails) {
839 SetupIndexBuffer(); 774 SetupIndexBuffer();
840 DoEnableVertexAttribArray(1); 775 DoEnableVertexAttribArray(1);
841 776
842 EXPECT_CALL(*gl_, DrawElements(_, _, _, _)) 777 EXPECT_CALL(*gl_, DrawElements(_, _, _, _))
843 .Times(0); 778 .Times(0);
844 DrawElements cmd; 779 DrawElements cmd;
845 cmd.Init(GL_TRIANGLES, kValidIndexRangeCount, GL_UNSIGNED_SHORT, 780 cmd.Init(GL_TRIANGLES, kValidIndexRangeCount, GL_UNSIGNED_SHORT,
846 kValidIndexRangeStart * 2); 781 kValidIndexRangeStart * 2);
847 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 782 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
848 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); 783 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
849 } 784 }
850 785
851 TEST_P(GLES2DecoderWithShaderTest, 786 TEST_F(GLES2DecoderWithShaderTest,
852 DrawElementsMissingAttributesZeroCountSucceeds) { 787 DrawElementsMissingAttributesZeroCountSucceeds) {
853 SetupIndexBuffer(); 788 SetupIndexBuffer();
854 DoEnableVertexAttribArray(1); 789 DoEnableVertexAttribArray(1);
855 790
856 EXPECT_CALL(*gl_, DrawElements(_, _, _, _)) 791 EXPECT_CALL(*gl_, DrawElements(_, _, _, _))
857 .Times(0); 792 .Times(0);
858 DrawElements cmd; 793 DrawElements cmd;
859 cmd.Init(GL_TRIANGLES, 0, GL_UNSIGNED_SHORT, 794 cmd.Init(GL_TRIANGLES, 0, GL_UNSIGNED_SHORT,
860 kValidIndexRangeStart * 2); 795 kValidIndexRangeStart * 2);
861 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 796 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
862 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 797 EXPECT_EQ(GL_NO_ERROR, GetGLError());
863 } 798 }
864 799
865 TEST_P(GLES2DecoderWithShaderTest, DrawElementsExtraAttributesFails) { 800 TEST_F(GLES2DecoderWithShaderTest, DrawElementsExtraAttributesFails) {
866 SetupIndexBuffer(); 801 SetupIndexBuffer();
867 DoEnableVertexAttribArray(6); 802 DoEnableVertexAttribArray(6);
868 803
869 EXPECT_CALL(*gl_, DrawElements(_, _, _, _)) 804 EXPECT_CALL(*gl_, DrawElements(_, _, _, _))
870 .Times(0); 805 .Times(0);
871 DrawElements cmd; 806 DrawElements cmd;
872 cmd.Init(GL_TRIANGLES, kValidIndexRangeCount, GL_UNSIGNED_SHORT, 807 cmd.Init(GL_TRIANGLES, kValidIndexRangeCount, GL_UNSIGNED_SHORT,
873 kValidIndexRangeStart * 2); 808 kValidIndexRangeStart * 2);
874 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 809 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
875 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); 810 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
876 } 811 }
877 812
878 TEST_P(GLES2DecoderWithShaderTest, DrawElementsValidAttributesSucceeds) { 813 TEST_F(GLES2DecoderWithShaderTest, DrawElementsValidAttributesSucceeds) {
879 SetupTexture(); 814 SetupTexture();
880 SetupVertexBuffer(); 815 SetupVertexBuffer();
881 SetupIndexBuffer(); 816 SetupIndexBuffer();
882 DoVertexAttribPointer(1, 2, GL_FLOAT, 0, 0); 817 DoVertexAttribPointer(1, 2, GL_FLOAT, 0, 0);
883 AddExpectationsForSimulatedAttrib0(kMaxValidIndex + 1, kServiceBufferId); 818 AddExpectationsForSimulatedAttrib0(kMaxValidIndex + 1, kServiceBufferId);
884 SetupExpectationsForApplyingDefaultDirtyState(); 819 SetupExpectationsForApplyingDefaultDirtyState();
885 820
886 EXPECT_CALL(*gl_, DrawElements(GL_TRIANGLES, kValidIndexRangeCount, 821 EXPECT_CALL(*gl_, DrawElements(GL_TRIANGLES, kValidIndexRangeCount,
887 GL_UNSIGNED_SHORT, 822 GL_UNSIGNED_SHORT,
888 BufferOffset(kValidIndexRangeStart * 2))) 823 BufferOffset(kValidIndexRangeStart * 2)))
889 .Times(1) 824 .Times(1)
890 .RetiresOnSaturation(); 825 .RetiresOnSaturation();
891 DrawElements cmd; 826 DrawElements cmd;
892 cmd.Init(GL_TRIANGLES, kValidIndexRangeCount, GL_UNSIGNED_SHORT, 827 cmd.Init(GL_TRIANGLES, kValidIndexRangeCount, GL_UNSIGNED_SHORT,
893 kValidIndexRangeStart * 2); 828 kValidIndexRangeStart * 2);
894 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 829 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
895 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 830 EXPECT_EQ(GL_NO_ERROR, GetGLError());
896 } 831 }
897 832
898 TEST_P(GLES2DecoderWithShaderTest, DrawElementsDeletedBufferFails) { 833 TEST_F(GLES2DecoderWithShaderTest, DrawElementsDeletedBufferFails) {
899 SetupVertexBuffer(); 834 SetupVertexBuffer();
900 SetupIndexBuffer(); 835 SetupIndexBuffer();
901 DoVertexAttribPointer(1, 2, GL_FLOAT, 0, 0); 836 DoVertexAttribPointer(1, 2, GL_FLOAT, 0, 0);
902 DeleteIndexBuffer(); 837 DeleteIndexBuffer();
903 838
904 EXPECT_CALL(*gl_, DrawElements(_, _, _, _)) 839 EXPECT_CALL(*gl_, DrawElements(_, _, _, _))
905 .Times(0); 840 .Times(0);
906 DrawElements cmd; 841 DrawElements cmd;
907 cmd.Init(GL_TRIANGLES, kValidIndexRangeCount, GL_UNSIGNED_SHORT, 842 cmd.Init(GL_TRIANGLES, kValidIndexRangeCount, GL_UNSIGNED_SHORT,
908 kValidIndexRangeStart * 2); 843 kValidIndexRangeStart * 2);
909 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 844 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
910 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); 845 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
911 } 846 }
912 847
913 TEST_P(GLES2DecoderWithShaderTest, DrawElementsDeletedProgramSucceeds) { 848 TEST_F(GLES2DecoderWithShaderTest, DrawElementsDeletedProgramSucceeds) {
914 SetupTexture(); 849 SetupTexture();
915 SetupIndexBuffer(); 850 SetupIndexBuffer();
916 AddExpectationsForSimulatedAttrib0(kMaxValidIndex + 1, 0); 851 AddExpectationsForSimulatedAttrib0(kMaxValidIndex + 1, 0);
917 SetupExpectationsForApplyingDefaultDirtyState(); 852 SetupExpectationsForApplyingDefaultDirtyState();
918 DoDeleteProgram(client_program_id_, kServiceProgramId); 853 DoDeleteProgram(client_program_id_, kServiceProgramId);
919 854
920 EXPECT_CALL(*gl_, DrawElements(_, _, _, _)) 855 EXPECT_CALL(*gl_, DrawElements(_, _, _, _))
921 .Times(1); 856 .Times(1);
922 EXPECT_CALL(*gl_, DeleteProgram(kServiceProgramId)) 857 EXPECT_CALL(*gl_, DeleteProgram(kServiceProgramId))
923 .Times(1); 858 .Times(1);
924 DrawElements cmd; 859 DrawElements cmd;
925 cmd.Init(GL_TRIANGLES, kValidIndexRangeCount, GL_UNSIGNED_SHORT, 860 cmd.Init(GL_TRIANGLES, kValidIndexRangeCount, GL_UNSIGNED_SHORT,
926 kValidIndexRangeStart * 2); 861 kValidIndexRangeStart * 2);
927 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 862 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
928 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 863 EXPECT_EQ(GL_NO_ERROR, GetGLError());
929 } 864 }
930 865
931 TEST_P(GLES2DecoderWithShaderTest, DrawElementsWithInvalidModeFails) { 866 TEST_F(GLES2DecoderWithShaderTest, DrawElementsWithInvalidModeFails) {
932 SetupVertexBuffer(); 867 SetupVertexBuffer();
933 SetupIndexBuffer(); 868 SetupIndexBuffer();
934 DoVertexAttribPointer(1, 2, GL_FLOAT, 0, 0); 869 DoVertexAttribPointer(1, 2, GL_FLOAT, 0, 0);
935 870
936 EXPECT_CALL(*gl_, DrawElements(_, _, _, _)) 871 EXPECT_CALL(*gl_, DrawElements(_, _, _, _))
937 .Times(0); 872 .Times(0);
938 DrawElements cmd; 873 DrawElements cmd;
939 cmd.Init(GL_QUADS, kValidIndexRangeCount, GL_UNSIGNED_SHORT, 874 cmd.Init(GL_QUADS, kValidIndexRangeCount, GL_UNSIGNED_SHORT,
940 kValidIndexRangeStart * 2); 875 kValidIndexRangeStart * 2);
941 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 876 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
942 EXPECT_EQ(GL_INVALID_ENUM, GetGLError()); 877 EXPECT_EQ(GL_INVALID_ENUM, GetGLError());
943 cmd.Init(GL_POLYGON, kValidIndexRangeCount, GL_UNSIGNED_SHORT, 878 cmd.Init(GL_POLYGON, kValidIndexRangeCount, GL_UNSIGNED_SHORT,
944 kValidIndexRangeStart); 879 kValidIndexRangeStart);
945 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 880 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
946 EXPECT_EQ(GL_INVALID_ENUM, GetGLError()); 881 EXPECT_EQ(GL_INVALID_ENUM, GetGLError());
947 } 882 }
948 883
949 TEST_P(GLES2DecoderWithShaderTest, DrawElementsInvalidCountFails) { 884 TEST_F(GLES2DecoderWithShaderTest, DrawElementsInvalidCountFails) {
950 SetupVertexBuffer(); 885 SetupVertexBuffer();
951 SetupIndexBuffer(); 886 SetupIndexBuffer();
952 DoVertexAttribPointer(1, 2, GL_FLOAT, 0, 0); 887 DoVertexAttribPointer(1, 2, GL_FLOAT, 0, 0);
953 888
954 // Try start > 0 889 // Try start > 0
955 EXPECT_CALL(*gl_, DrawElements(_, _, _, _)).Times(0); 890 EXPECT_CALL(*gl_, DrawElements(_, _, _, _)).Times(0);
956 DrawElements cmd; 891 DrawElements cmd;
957 cmd.Init(GL_TRIANGLES, kNumIndices, GL_UNSIGNED_SHORT, 2); 892 cmd.Init(GL_TRIANGLES, kNumIndices, GL_UNSIGNED_SHORT, 2);
958 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 893 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
959 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); 894 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
960 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 895 EXPECT_EQ(GL_NO_ERROR, GetGLError());
961 896
962 // Try with count > size 897 // Try with count > size
963 cmd.Init(GL_TRIANGLES, kNumIndices + 1, GL_UNSIGNED_SHORT, 0); 898 cmd.Init(GL_TRIANGLES, kNumIndices + 1, GL_UNSIGNED_SHORT, 0);
964 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 899 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
965 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); 900 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
966 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 901 EXPECT_EQ(GL_NO_ERROR, GetGLError());
967 } 902 }
968 903
969 TEST_P(GLES2DecoderWithShaderTest, DrawElementsOutOfRangeIndicesFails) { 904 TEST_F(GLES2DecoderWithShaderTest, DrawElementsOutOfRangeIndicesFails) {
970 SetupVertexBuffer(); 905 SetupVertexBuffer();
971 SetupIndexBuffer(); 906 SetupIndexBuffer();
972 DoVertexAttribPointer(1, 2, GL_FLOAT, 0, 0); 907 DoVertexAttribPointer(1, 2, GL_FLOAT, 0, 0);
973 908
974 EXPECT_CALL(*gl_, DrawElements(_, _, _, _)).Times(0); 909 EXPECT_CALL(*gl_, DrawElements(_, _, _, _)).Times(0);
975 DrawElements cmd; 910 DrawElements cmd;
976 cmd.Init(GL_TRIANGLES, kInvalidIndexRangeCount, GL_UNSIGNED_SHORT, 911 cmd.Init(GL_TRIANGLES, kInvalidIndexRangeCount, GL_UNSIGNED_SHORT,
977 kInvalidIndexRangeStart * 2); 912 kInvalidIndexRangeStart * 2);
978 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 913 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
979 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); 914 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
980 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 915 EXPECT_EQ(GL_NO_ERROR, GetGLError());
981 } 916 }
982 917
983 TEST_P(GLES2DecoderWithShaderTest, DrawElementsOddOffsetForUint16Fails) { 918 TEST_F(GLES2DecoderWithShaderTest, DrawElementsOddOffsetForUint16Fails) {
984 SetupVertexBuffer(); 919 SetupVertexBuffer();
985 SetupIndexBuffer(); 920 SetupIndexBuffer();
986 DoVertexAttribPointer(1, 2, GL_FLOAT, 0, 0); 921 DoVertexAttribPointer(1, 2, GL_FLOAT, 0, 0);
987 922
988 EXPECT_CALL(*gl_, DrawElements(_, _, _, _)).Times(0); 923 EXPECT_CALL(*gl_, DrawElements(_, _, _, _)).Times(0);
989 DrawElements cmd; 924 DrawElements cmd;
990 cmd.Init(GL_TRIANGLES, kInvalidIndexRangeCount, GL_UNSIGNED_SHORT, 1); 925 cmd.Init(GL_TRIANGLES, kInvalidIndexRangeCount, GL_UNSIGNED_SHORT, 1);
991 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 926 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
992 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); 927 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
993 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 928 EXPECT_EQ(GL_NO_ERROR, GetGLError());
994 } 929 }
995 930
996 TEST_P(GLES2DecoderWithShaderTest, DrawElementsInstancedANGLEFails) { 931 TEST_F(GLES2DecoderWithShaderTest, DrawElementsInstancedANGLEFails) {
997 SetupTexture(); 932 SetupTexture();
998 SetupVertexBuffer(); 933 SetupVertexBuffer();
999 SetupIndexBuffer(); 934 SetupIndexBuffer();
1000 DoEnableVertexAttribArray(1); 935 DoEnableVertexAttribArray(1);
1001 DoVertexAttribPointer(1, 2, GL_FLOAT, 0, 0); 936 DoVertexAttribPointer(1, 2, GL_FLOAT, 0, 0);
1002 937
1003 EXPECT_CALL(*gl_, DrawElementsInstancedANGLE(_, _, _, _, _)) 938 EXPECT_CALL(*gl_, DrawElementsInstancedANGLE(_, _, _, _, _))
1004 .Times(0) 939 .Times(0)
1005 .RetiresOnSaturation(); 940 .RetiresOnSaturation();
1006 DrawElementsInstancedANGLE cmd; 941 DrawElementsInstancedANGLE cmd;
1007 cmd.Init(GL_TRIANGLES, kValidIndexRangeCount, GL_UNSIGNED_SHORT, 942 cmd.Init(GL_TRIANGLES, kValidIndexRangeCount, GL_UNSIGNED_SHORT,
1008 kValidIndexRangeStart * 2, 1); 943 kValidIndexRangeStart * 2, 1);
1009 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 944 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
1010 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); 945 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
1011 } 946 }
1012 947
1013 TEST_P(GLES2DecoderGeometryInstancingTest, 948 TEST_F(GLES2DecoderGeometryInstancingTest,
1014 DrawElementsInstancedANGLENoAttributesFails) { 949 DrawElementsInstancedANGLENoAttributesFails) {
1015 SetupTexture(); 950 SetupTexture();
1016 SetupIndexBuffer(); 951 SetupIndexBuffer();
1017 952
1018 EXPECT_CALL(*gl_, DrawElementsInstancedANGLE(_, _, _, _, _)) 953 EXPECT_CALL(*gl_, DrawElementsInstancedANGLE(_, _, _, _, _))
1019 .Times(0) 954 .Times(0)
1020 .RetiresOnSaturation(); 955 .RetiresOnSaturation();
1021 DrawElementsInstancedANGLE cmd; 956 DrawElementsInstancedANGLE cmd;
1022 cmd.Init(GL_TRIANGLES, kValidIndexRangeCount, GL_UNSIGNED_SHORT, 957 cmd.Init(GL_TRIANGLES, kValidIndexRangeCount, GL_UNSIGNED_SHORT,
1023 kValidIndexRangeStart * 2, 1); 958 kValidIndexRangeStart * 2, 1);
1024 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 959 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
1025 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); 960 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
1026 } 961 }
1027 962
1028 TEST_P(GLES2DecoderGeometryInstancingTest, 963 TEST_F(GLES2DecoderGeometryInstancingTest,
1029 DrawElementsInstancedANGLESimulatedAttrib0) { 964 DrawElementsInstancedANGLESimulatedAttrib0) {
1030 SetupTexture(); 965 SetupTexture();
1031 SetupVertexBuffer(); 966 SetupVertexBuffer();
1032 SetupIndexBuffer(); 967 SetupIndexBuffer();
1033 DoVertexAttribPointer(1, 2, GL_FLOAT, 0, 0); 968 DoVertexAttribPointer(1, 2, GL_FLOAT, 0, 0);
1034 969
1035 AddExpectationsForSimulatedAttrib0(kMaxValidIndex + 1, kServiceBufferId); 970 AddExpectationsForSimulatedAttrib0(kMaxValidIndex + 1, kServiceBufferId);
1036 SetupExpectationsForApplyingDefaultDirtyState(); 971 SetupExpectationsForApplyingDefaultDirtyState();
1037 972
1038 DoVertexAttribDivisorANGLE(0, 1); 973 DoVertexAttribDivisorANGLE(0, 1);
(...skipping 11 matching lines...) Expand all
1050 EXPECT_CALL(*gl_, VertexAttribDivisorANGLE(0, 1)) 985 EXPECT_CALL(*gl_, VertexAttribDivisorANGLE(0, 1))
1051 .Times(1) 986 .Times(1)
1052 .RetiresOnSaturation(); 987 .RetiresOnSaturation();
1053 DrawElementsInstancedANGLE cmd; 988 DrawElementsInstancedANGLE cmd;
1054 cmd.Init(GL_TRIANGLES, kValidIndexRangeCount, GL_UNSIGNED_SHORT, 989 cmd.Init(GL_TRIANGLES, kValidIndexRangeCount, GL_UNSIGNED_SHORT,
1055 kValidIndexRangeStart * 2, 3); 990 kValidIndexRangeStart * 2, 3);
1056 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 991 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
1057 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 992 EXPECT_EQ(GL_NO_ERROR, GetGLError());
1058 } 993 }
1059 994
1060 TEST_P(GLES2DecoderGeometryInstancingTest, 995 TEST_F(GLES2DecoderGeometryInstancingTest,
1061 DrawElementsInstancedANGLEMissingAttributesFails) { 996 DrawElementsInstancedANGLEMissingAttributesFails) {
1062 SetupIndexBuffer(); 997 SetupIndexBuffer();
1063 DoEnableVertexAttribArray(1); 998 DoEnableVertexAttribArray(1);
1064 999
1065 EXPECT_CALL(*gl_, DrawElementsInstancedANGLE(_, _, _, _, _)) 1000 EXPECT_CALL(*gl_, DrawElementsInstancedANGLE(_, _, _, _, _))
1066 .Times(0); 1001 .Times(0);
1067 DrawElementsInstancedANGLE cmd; 1002 DrawElementsInstancedANGLE cmd;
1068 cmd.Init(GL_TRIANGLES, kValidIndexRangeCount, GL_UNSIGNED_SHORT, 1003 cmd.Init(GL_TRIANGLES, kValidIndexRangeCount, GL_UNSIGNED_SHORT,
1069 kValidIndexRangeStart * 2, 1); 1004 kValidIndexRangeStart * 2, 1);
1070 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 1005 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
1071 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); 1006 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
1072 } 1007 }
1073 1008
1074 TEST_P(GLES2DecoderGeometryInstancingTest, 1009 TEST_F(GLES2DecoderGeometryInstancingTest,
1075 DrawElementsInstancedANGLEMissingAttributesZeroCountSucceeds) { 1010 DrawElementsInstancedANGLEMissingAttributesZeroCountSucceeds) {
1076 SetupIndexBuffer(); 1011 SetupIndexBuffer();
1077 DoEnableVertexAttribArray(1); 1012 DoEnableVertexAttribArray(1);
1078 1013
1079 EXPECT_CALL(*gl_, DrawElementsInstancedANGLE(_, _, _, _, _)) 1014 EXPECT_CALL(*gl_, DrawElementsInstancedANGLE(_, _, _, _, _))
1080 .Times(0); 1015 .Times(0);
1081 DrawElementsInstancedANGLE cmd; 1016 DrawElementsInstancedANGLE cmd;
1082 cmd.Init(GL_TRIANGLES, 0, GL_UNSIGNED_SHORT, 1017 cmd.Init(GL_TRIANGLES, 0, GL_UNSIGNED_SHORT,
1083 kValidIndexRangeStart * 2, 1); 1018 kValidIndexRangeStart * 2, 1);
1084 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 1019 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
1085 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 1020 EXPECT_EQ(GL_NO_ERROR, GetGLError());
1086 } 1021 }
1087 1022
1088 TEST_P(GLES2DecoderGeometryInstancingTest, 1023 TEST_F(GLES2DecoderGeometryInstancingTest,
1089 DrawElementsInstancedANGLEValidAttributesSucceeds) { 1024 DrawElementsInstancedANGLEValidAttributesSucceeds) {
1090 SetupIndexBuffer(); 1025 SetupIndexBuffer();
1091 SetupTexture(); 1026 SetupTexture();
1092 SetupVertexBuffer(); 1027 SetupVertexBuffer();
1093 DoEnableVertexAttribArray(1); 1028 DoEnableVertexAttribArray(1);
1094 DoVertexAttribPointer(1, 2, GL_FLOAT, 0, 0); 1029 DoVertexAttribPointer(1, 2, GL_FLOAT, 0, 0);
1095 AddExpectationsForSimulatedAttrib0(kMaxValidIndex + 1, kServiceBufferId); 1030 AddExpectationsForSimulatedAttrib0(kMaxValidIndex + 1, kServiceBufferId);
1096 SetupExpectationsForApplyingDefaultDirtyState(); 1031 SetupExpectationsForApplyingDefaultDirtyState();
1097 1032
1098 EXPECT_CALL(*gl_, DrawElementsInstancedANGLE( 1033 EXPECT_CALL(*gl_, DrawElementsInstancedANGLE(
1099 GL_TRIANGLES, 1034 GL_TRIANGLES,
1100 kValidIndexRangeCount, 1035 kValidIndexRangeCount,
1101 GL_UNSIGNED_SHORT, 1036 GL_UNSIGNED_SHORT,
1102 BufferOffset(kValidIndexRangeStart * 2), 1037 BufferOffset(kValidIndexRangeStart * 2),
1103 1)) 1038 1))
1104 .Times(1) 1039 .Times(1)
1105 .RetiresOnSaturation(); 1040 .RetiresOnSaturation();
1106 DrawElementsInstancedANGLE cmd; 1041 DrawElementsInstancedANGLE cmd;
1107 cmd.Init(GL_TRIANGLES, kValidIndexRangeCount, GL_UNSIGNED_SHORT, 1042 cmd.Init(GL_TRIANGLES, kValidIndexRangeCount, GL_UNSIGNED_SHORT,
1108 kValidIndexRangeStart * 2, 1); 1043 kValidIndexRangeStart * 2, 1);
1109 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 1044 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
1110 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 1045 EXPECT_EQ(GL_NO_ERROR, GetGLError());
1111 } 1046 }
1112 1047
1113 TEST_P(GLES2DecoderGeometryInstancingTest, 1048 TEST_F(GLES2DecoderGeometryInstancingTest,
1114 DrawElementsInstancedANGLEWithInvalidModeFails) { 1049 DrawElementsInstancedANGLEWithInvalidModeFails) {
1115 SetupIndexBuffer(); 1050 SetupIndexBuffer();
1116 SetupVertexBuffer(); 1051 SetupVertexBuffer();
1117 DoVertexAttribPointer(1, 2, GL_FLOAT, 0, 0); 1052 DoVertexAttribPointer(1, 2, GL_FLOAT, 0, 0);
1118 1053
1119 EXPECT_CALL(*gl_, DrawElementsInstancedANGLE(_, _, _, _, _)) 1054 EXPECT_CALL(*gl_, DrawElementsInstancedANGLE(_, _, _, _, _))
1120 .Times(0); 1055 .Times(0);
1121 DrawElementsInstancedANGLE cmd; 1056 DrawElementsInstancedANGLE cmd;
1122 cmd.Init(GL_QUADS, kValidIndexRangeCount, GL_UNSIGNED_SHORT, 1057 cmd.Init(GL_QUADS, kValidIndexRangeCount, GL_UNSIGNED_SHORT,
1123 kValidIndexRangeStart * 2, 1); 1058 kValidIndexRangeStart * 2, 1);
1124 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 1059 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
1125 EXPECT_EQ(GL_INVALID_ENUM, GetGLError()); 1060 EXPECT_EQ(GL_INVALID_ENUM, GetGLError());
1126 cmd.Init(GL_INVALID_ENUM, kValidIndexRangeCount, GL_UNSIGNED_SHORT, 1061 cmd.Init(GL_INVALID_ENUM, kValidIndexRangeCount, GL_UNSIGNED_SHORT,
1127 kValidIndexRangeStart * 2, 1); 1062 kValidIndexRangeStart * 2, 1);
1128 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 1063 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
1129 EXPECT_EQ(GL_INVALID_ENUM, GetGLError()); 1064 EXPECT_EQ(GL_INVALID_ENUM, GetGLError());
1130 } 1065 }
1131 1066
1132 // Per-instance data is twice as large, but number of instances is half 1067 // Per-instance data is twice as large, but number of instances is half
1133 TEST_P(GLES2DecoderGeometryInstancingTest, 1068 TEST_F(GLES2DecoderGeometryInstancingTest,
1134 DrawElementsInstancedANGLELargeInstanceSucceeds) { 1069 DrawElementsInstancedANGLELargeInstanceSucceeds) {
1135 SetupTexture(); 1070 SetupTexture();
1136 SetupIndexBuffer(); 1071 SetupIndexBuffer();
1137 SetupVertexBuffer(); 1072 SetupVertexBuffer();
1138 SetupExpectationsForApplyingDefaultDirtyState(); 1073 SetupExpectationsForApplyingDefaultDirtyState();
1139 //Add offset so we're sure we're accessing data near the end of the buffer. 1074 //Add offset so we're sure we're accessing data near the end of the buffer.
1140 DoVertexAttribPointer(1, 2, GL_FLOAT, 0, 1075 DoVertexAttribPointer(1, 2, GL_FLOAT, 0,
1141 (kNumVertices - kMaxValidIndex - 1) * 2 * 1076 (kNumVertices - kMaxValidIndex - 1) * 2 *
1142 sizeof(GLfloat)); 1077 sizeof(GLfloat));
1143 1078
1144 DoEnableVertexAttribArray(0); 1079 DoEnableVertexAttribArray(0);
1145 DoVertexAttribPointer(0, 4, GL_FLOAT, 0, 0); 1080 DoVertexAttribPointer(0, 4, GL_FLOAT, 0, 0);
1146 DoVertexAttribDivisorANGLE(0, 1); 1081 DoVertexAttribDivisorANGLE(0, 1);
1147 EXPECT_CALL(*gl_, DrawElementsInstancedANGLE( 1082 EXPECT_CALL(*gl_, DrawElementsInstancedANGLE(
1148 GL_TRIANGLES, 1083 GL_TRIANGLES,
1149 kValidIndexRangeCount, 1084 kValidIndexRangeCount,
1150 GL_UNSIGNED_SHORT, 1085 GL_UNSIGNED_SHORT,
1151 BufferOffset(kValidIndexRangeStart * 2), 1086 BufferOffset(kValidIndexRangeStart * 2),
1152 kNumVertices / 2)) 1087 kNumVertices / 2))
1153 .Times(1) 1088 .Times(1)
1154 .RetiresOnSaturation(); 1089 .RetiresOnSaturation();
1155 DrawElementsInstancedANGLE cmd; 1090 DrawElementsInstancedANGLE cmd;
1156 cmd.Init(GL_TRIANGLES, kValidIndexRangeCount, GL_UNSIGNED_SHORT, 1091 cmd.Init(GL_TRIANGLES, kValidIndexRangeCount, GL_UNSIGNED_SHORT,
1157 kValidIndexRangeStart * 2, kNumVertices / 2); 1092 kValidIndexRangeStart * 2, kNumVertices / 2);
1158 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 1093 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
1159 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 1094 EXPECT_EQ(GL_NO_ERROR, GetGLError());
1160 } 1095 }
1161 1096
1162 // Per-instance data is twice as large, but divisor is twice 1097 // Per-instance data is twice as large, but divisor is twice
1163 TEST_P(GLES2DecoderGeometryInstancingTest, 1098 TEST_F(GLES2DecoderGeometryInstancingTest,
1164 DrawElementsInstancedANGLELargeDivisorSucceeds) { 1099 DrawElementsInstancedANGLELargeDivisorSucceeds) {
1165 SetupTexture(); 1100 SetupTexture();
1166 SetupIndexBuffer(); 1101 SetupIndexBuffer();
1167 SetupVertexBuffer(); 1102 SetupVertexBuffer();
1168 SetupExpectationsForApplyingDefaultDirtyState(); 1103 SetupExpectationsForApplyingDefaultDirtyState();
1169 DoVertexAttribPointer(1, 2, GL_FLOAT, 0, 0); 1104 DoVertexAttribPointer(1, 2, GL_FLOAT, 0, 0);
1170 1105
1171 DoEnableVertexAttribArray(0); 1106 DoEnableVertexAttribArray(0);
1172 DoVertexAttribPointer(0, 4, GL_FLOAT, 0, 0); 1107 DoVertexAttribPointer(0, 4, GL_FLOAT, 0, 0);
1173 DoVertexAttribDivisorANGLE(0, 2); 1108 DoVertexAttribDivisorANGLE(0, 2);
1174 EXPECT_CALL(*gl_, DrawElementsInstancedANGLE( 1109 EXPECT_CALL(*gl_, DrawElementsInstancedANGLE(
1175 GL_TRIANGLES, 1110 GL_TRIANGLES,
1176 kValidIndexRangeCount, 1111 kValidIndexRangeCount,
1177 GL_UNSIGNED_SHORT, 1112 GL_UNSIGNED_SHORT,
1178 BufferOffset(kValidIndexRangeStart * 2), 1113 BufferOffset(kValidIndexRangeStart * 2),
1179 kNumVertices)) 1114 kNumVertices))
1180 .Times(1) 1115 .Times(1)
1181 .RetiresOnSaturation(); 1116 .RetiresOnSaturation();
1182 DrawElementsInstancedANGLE cmd; 1117 DrawElementsInstancedANGLE cmd;
1183 cmd.Init(GL_TRIANGLES, kValidIndexRangeCount, GL_UNSIGNED_SHORT, 1118 cmd.Init(GL_TRIANGLES, kValidIndexRangeCount, GL_UNSIGNED_SHORT,
1184 kValidIndexRangeStart * 2, kNumVertices); 1119 kValidIndexRangeStart * 2, kNumVertices);
1185 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 1120 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
1186 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 1121 EXPECT_EQ(GL_NO_ERROR, GetGLError());
1187 } 1122 }
1188 1123
1189 TEST_P(GLES2DecoderGeometryInstancingTest, 1124 TEST_F(GLES2DecoderGeometryInstancingTest,
1190 DrawElementsInstancedANGLELargeFails) { 1125 DrawElementsInstancedANGLELargeFails) {
1191 SetupTexture(); 1126 SetupTexture();
1192 SetupIndexBuffer(); 1127 SetupIndexBuffer();
1193 SetupVertexBuffer(); 1128 SetupVertexBuffer();
1194 DoVertexAttribPointer(1, 2, GL_FLOAT, 0, 0); 1129 DoVertexAttribPointer(1, 2, GL_FLOAT, 0, 0);
1195 1130
1196 DoEnableVertexAttribArray(0); 1131 DoEnableVertexAttribArray(0);
1197 DoVertexAttribPointer(0, 2, GL_FLOAT, 0, 0); 1132 DoVertexAttribPointer(0, 2, GL_FLOAT, 0, 0);
1198 DoVertexAttribDivisorANGLE(0, 1); 1133 DoVertexAttribDivisorANGLE(0, 1);
1199 EXPECT_CALL(*gl_, DrawElementsInstancedANGLE(_, _, _, _, _)) 1134 EXPECT_CALL(*gl_, DrawElementsInstancedANGLE(_, _, _, _, _))
1200 .Times(0) 1135 .Times(0)
1201 .RetiresOnSaturation(); 1136 .RetiresOnSaturation();
1202 DrawElementsInstancedANGLE cmd; 1137 DrawElementsInstancedANGLE cmd;
1203 cmd.Init(GL_TRIANGLES, kValidIndexRangeCount, GL_UNSIGNED_SHORT, 1138 cmd.Init(GL_TRIANGLES, kValidIndexRangeCount, GL_UNSIGNED_SHORT,
1204 kValidIndexRangeStart * 2, kNumVertices + 1); 1139 kValidIndexRangeStart * 2, kNumVertices + 1);
1205 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 1140 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
1206 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); 1141 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
1207 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 1142 EXPECT_EQ(GL_NO_ERROR, GetGLError());
1208 1143
1209 EXPECT_CALL(*gl_, DrawElementsInstancedANGLE(_, _, _, _, _)) 1144 EXPECT_CALL(*gl_, DrawElementsInstancedANGLE(_, _, _, _, _))
1210 .Times(0) 1145 .Times(0)
1211 .RetiresOnSaturation(); 1146 .RetiresOnSaturation();
1212 cmd.Init(GL_TRIANGLES, kInvalidIndexRangeCount, GL_UNSIGNED_SHORT, 1147 cmd.Init(GL_TRIANGLES, kInvalidIndexRangeCount, GL_UNSIGNED_SHORT,
1213 kInvalidIndexRangeStart * 2, kNumVertices); 1148 kInvalidIndexRangeStart * 2, kNumVertices);
1214 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 1149 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
1215 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); 1150 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
1216 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 1151 EXPECT_EQ(GL_NO_ERROR, GetGLError());
1217 } 1152 }
1218 1153
1219 TEST_P(GLES2DecoderGeometryInstancingTest, 1154 TEST_F(GLES2DecoderGeometryInstancingTest,
1220 DrawElementsInstancedANGLEInvalidPrimcountFails) { 1155 DrawElementsInstancedANGLEInvalidPrimcountFails) {
1221 SetupTexture(); 1156 SetupTexture();
1222 SetupIndexBuffer(); 1157 SetupIndexBuffer();
1223 SetupVertexBuffer(); 1158 SetupVertexBuffer();
1224 DoVertexAttribPointer(1, 2, GL_FLOAT, 0, 0); 1159 DoVertexAttribPointer(1, 2, GL_FLOAT, 0, 0);
1225 1160
1226 DoEnableVertexAttribArray(0); 1161 DoEnableVertexAttribArray(0);
1227 DoVertexAttribPointer(0, 2, GL_FLOAT, 0, 0); 1162 DoVertexAttribPointer(0, 2, GL_FLOAT, 0, 0);
1228 DoVertexAttribDivisorANGLE(0, 1); 1163 DoVertexAttribDivisorANGLE(0, 1);
1229 EXPECT_CALL(*gl_, DrawElementsInstancedANGLE(_, _, _, _, _)) 1164 EXPECT_CALL(*gl_, DrawElementsInstancedANGLE(_, _, _, _, _))
1230 .Times(0) 1165 .Times(0)
1231 .RetiresOnSaturation(); 1166 .RetiresOnSaturation();
1232 DrawElementsInstancedANGLE cmd; 1167 DrawElementsInstancedANGLE cmd;
1233 cmd.Init(GL_TRIANGLES, kValidIndexRangeCount, GL_UNSIGNED_SHORT, 1168 cmd.Init(GL_TRIANGLES, kValidIndexRangeCount, GL_UNSIGNED_SHORT,
1234 kValidIndexRangeStart * 2, -1); 1169 kValidIndexRangeStart * 2, -1);
1235 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 1170 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
1236 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); 1171 EXPECT_EQ(GL_INVALID_VALUE, GetGLError());
1237 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 1172 EXPECT_EQ(GL_NO_ERROR, GetGLError());
1238 } 1173 }
1239 1174
1240 // Per-index data is twice as large, but values of indices are smaller 1175 // Per-index data is twice as large, but values of indices are smaller
1241 TEST_P(GLES2DecoderGeometryInstancingTest, 1176 TEST_F(GLES2DecoderGeometryInstancingTest,
1242 DrawElementsInstancedANGLELargeIndexSucceeds) { 1177 DrawElementsInstancedANGLELargeIndexSucceeds) {
1243 SetupTexture(); 1178 SetupTexture();
1244 SetupIndexBuffer(); 1179 SetupIndexBuffer();
1245 SetupVertexBuffer(); 1180 SetupVertexBuffer();
1246 SetupExpectationsForApplyingDefaultDirtyState(); 1181 SetupExpectationsForApplyingDefaultDirtyState();
1247 DoVertexAttribPointer(1, 4, GL_FLOAT, 0, 0); 1182 DoVertexAttribPointer(1, 4, GL_FLOAT, 0, 0);
1248 1183
1249 DoEnableVertexAttribArray(0); 1184 DoEnableVertexAttribArray(0);
1250 DoVertexAttribPointer(0, 2, GL_FLOAT, 0, 0); 1185 DoVertexAttribPointer(0, 2, GL_FLOAT, 0, 0);
1251 DoVertexAttribDivisorANGLE(0, 1); 1186 DoVertexAttribDivisorANGLE(0, 1);
1252 EXPECT_CALL(*gl_, DrawElementsInstancedANGLE( 1187 EXPECT_CALL(*gl_, DrawElementsInstancedANGLE(
1253 GL_TRIANGLES, 1188 GL_TRIANGLES,
1254 kValidIndexRangeCount, 1189 kValidIndexRangeCount,
1255 GL_UNSIGNED_SHORT, 1190 GL_UNSIGNED_SHORT,
1256 BufferOffset(kValidIndexRangeStart * 2), 1191 BufferOffset(kValidIndexRangeStart * 2),
1257 kNumVertices)) 1192 kNumVertices))
1258 .Times(1) 1193 .Times(1)
1259 .RetiresOnSaturation(); 1194 .RetiresOnSaturation();
1260 DrawElementsInstancedANGLE cmd; 1195 DrawElementsInstancedANGLE cmd;
1261 cmd.Init(GL_TRIANGLES, kValidIndexRangeCount, GL_UNSIGNED_SHORT, 1196 cmd.Init(GL_TRIANGLES, kValidIndexRangeCount, GL_UNSIGNED_SHORT,
1262 kValidIndexRangeStart * 2, kNumVertices); 1197 kValidIndexRangeStart * 2, kNumVertices);
1263 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 1198 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
1264 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 1199 EXPECT_EQ(GL_NO_ERROR, GetGLError());
1265 } 1200 }
1266 1201
1267 TEST_P(GLES2DecoderGeometryInstancingTest, 1202 TEST_F(GLES2DecoderGeometryInstancingTest,
1268 DrawElementsInstancedANGLENoDivisor0Fails) { 1203 DrawElementsInstancedANGLENoDivisor0Fails) {
1269 SetupTexture(); 1204 SetupTexture();
1270 SetupIndexBuffer(); 1205 SetupIndexBuffer();
1271 SetupVertexBuffer(); 1206 SetupVertexBuffer();
1272 DoVertexAttribPointer(1, 2, GL_FLOAT, 0, 0); 1207 DoVertexAttribPointer(1, 2, GL_FLOAT, 0, 0);
1273 1208
1274 DoEnableVertexAttribArray(0); 1209 DoEnableVertexAttribArray(0);
1275 DoVertexAttribPointer(0, 2, GL_FLOAT, 0, 0); 1210 DoVertexAttribPointer(0, 2, GL_FLOAT, 0, 0);
1276 DoVertexAttribDivisorANGLE(0, 1); 1211 DoVertexAttribDivisorANGLE(0, 1);
1277 DoVertexAttribDivisorANGLE(1, 1); 1212 DoVertexAttribDivisorANGLE(1, 1);
1278 EXPECT_CALL(*gl_, DrawElementsInstancedANGLE(_, _, _, _, _)) 1213 EXPECT_CALL(*gl_, DrawElementsInstancedANGLE(_, _, _, _, _))
1279 .Times(0) 1214 .Times(0)
1280 .RetiresOnSaturation(); 1215 .RetiresOnSaturation();
1281 DrawElementsInstancedANGLE cmd; 1216 DrawElementsInstancedANGLE cmd;
1282 cmd.Init(GL_TRIANGLES, kValidIndexRangeCount, GL_UNSIGNED_SHORT, 1217 cmd.Init(GL_TRIANGLES, kValidIndexRangeCount, GL_UNSIGNED_SHORT,
1283 kValidIndexRangeStart * 2, kNumVertices); 1218 kValidIndexRangeStart * 2, kNumVertices);
1284 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 1219 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
1285 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); 1220 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
1286 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 1221 EXPECT_EQ(GL_NO_ERROR, GetGLError());
1287 } 1222 }
1288 1223
1289 TEST_P(GLES2DecoderWithShaderTest, GetVertexAttribPointervSucceeds) { 1224 TEST_F(GLES2DecoderWithShaderTest, GetVertexAttribPointervSucceeds) {
1290 const float dummy = 0; 1225 const float dummy = 0;
1291 const GLuint kOffsetToTestFor = sizeof(dummy) * 4; 1226 const GLuint kOffsetToTestFor = sizeof(dummy) * 4;
1292 const GLuint kIndexToTest = 1; 1227 const GLuint kIndexToTest = 1;
1293 GetVertexAttribPointerv::Result* result = 1228 GetVertexAttribPointerv::Result* result =
1294 static_cast<GetVertexAttribPointerv::Result*>(shared_memory_address_); 1229 static_cast<GetVertexAttribPointerv::Result*>(shared_memory_address_);
1295 result->size = 0; 1230 result->size = 0;
1296 const GLuint* result_value = result->GetData(); 1231 const GLuint* result_value = result->GetData();
1297 // Test that initial value is 0. 1232 // Test that initial value is 0.
1298 GetVertexAttribPointerv cmd; 1233 GetVertexAttribPointerv cmd;
1299 cmd.Init(kIndexToTest, GL_VERTEX_ATTRIB_ARRAY_POINTER, 1234 cmd.Init(kIndexToTest, GL_VERTEX_ATTRIB_ARRAY_POINTER,
1300 shared_memory_id_, shared_memory_offset_); 1235 shared_memory_id_, shared_memory_offset_);
1301 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 1236 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
1302 EXPECT_EQ(sizeof(*result_value), result->size); 1237 EXPECT_EQ(sizeof(*result_value), result->size);
1303 EXPECT_EQ(0u, *result_value); 1238 EXPECT_EQ(0u, *result_value);
1304 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 1239 EXPECT_EQ(GL_NO_ERROR, GetGLError());
1305 1240
1306 // Set the value and see that we get it. 1241 // Set the value and see that we get it.
1307 SetupVertexBuffer(); 1242 SetupVertexBuffer();
1308 DoVertexAttribPointer(kIndexToTest, 2, GL_FLOAT, 0, kOffsetToTestFor); 1243 DoVertexAttribPointer(kIndexToTest, 2, GL_FLOAT, 0, kOffsetToTestFor);
1309 result->size = 0; 1244 result->size = 0;
1310 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 1245 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
1311 EXPECT_EQ(sizeof(*result_value), result->size); 1246 EXPECT_EQ(sizeof(*result_value), result->size);
1312 EXPECT_EQ(kOffsetToTestFor, *result_value); 1247 EXPECT_EQ(kOffsetToTestFor, *result_value);
1313 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 1248 EXPECT_EQ(GL_NO_ERROR, GetGLError());
1314 } 1249 }
1315 1250
1316 TEST_P(GLES2DecoderWithShaderTest, GetVertexAttribPointervBadArgsFails) { 1251 TEST_F(GLES2DecoderWithShaderTest, GetVertexAttribPointervBadArgsFails) {
1317 const GLuint kIndexToTest = 1; 1252 const GLuint kIndexToTest = 1;
1318 GetVertexAttribPointerv::Result* result = 1253 GetVertexAttribPointerv::Result* result =
1319 static_cast<GetVertexAttribPointerv::Result*>(shared_memory_address_); 1254 static_cast<GetVertexAttribPointerv::Result*>(shared_memory_address_);
1320 result->size = 0; 1255 result->size = 0;
1321 const GLuint* result_value = result->GetData(); 1256 const GLuint* result_value = result->GetData();
1322 // Test pname invalid fails. 1257 // Test pname invalid fails.
1323 GetVertexAttribPointerv cmd; 1258 GetVertexAttribPointerv cmd;
1324 cmd.Init(kIndexToTest, GL_VERTEX_ATTRIB_ARRAY_POINTER + 1, 1259 cmd.Init(kIndexToTest, GL_VERTEX_ATTRIB_ARRAY_POINTER + 1,
1325 shared_memory_id_, shared_memory_offset_); 1260 shared_memory_id_, shared_memory_offset_);
1326 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 1261 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
(...skipping 14 matching lines...) Expand all
1341 cmd.Init(kIndexToTest, GL_VERTEX_ATTRIB_ARRAY_POINTER, 1276 cmd.Init(kIndexToTest, GL_VERTEX_ATTRIB_ARRAY_POINTER,
1342 kInvalidSharedMemoryId, shared_memory_offset_); 1277 kInvalidSharedMemoryId, shared_memory_offset_);
1343 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); 1278 EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
1344 1279
1345 // Test memory offset bad fails. 1280 // Test memory offset bad fails.
1346 cmd.Init(kIndexToTest, GL_VERTEX_ATTRIB_ARRAY_POINTER, 1281 cmd.Init(kIndexToTest, GL_VERTEX_ATTRIB_ARRAY_POINTER,
1347 shared_memory_id_, kInvalidSharedMemoryOffset); 1282 shared_memory_id_, kInvalidSharedMemoryOffset);
1348 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); 1283 EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
1349 } 1284 }
1350 1285
1351 TEST_P(GLES2DecoderWithShaderTest, GetUniformivSucceeds) { 1286 TEST_F(GLES2DecoderWithShaderTest, GetUniformivSucceeds) {
1352 GetUniformiv::Result* result = 1287 GetUniformiv::Result* result =
1353 static_cast<GetUniformiv::Result*>(shared_memory_address_); 1288 static_cast<GetUniformiv::Result*>(shared_memory_address_);
1354 result->size = 0; 1289 result->size = 0;
1355 GetUniformiv cmd; 1290 GetUniformiv cmd;
1356 cmd.Init(client_program_id_, 1291 cmd.Init(client_program_id_,
1357 kUniform2FakeLocation, 1292 kUniform2FakeLocation,
1358 kSharedMemoryId, kSharedMemoryOffset); 1293 kSharedMemoryId, kSharedMemoryOffset);
1359 EXPECT_CALL(*gl_, GetUniformiv(kServiceProgramId, kUniform2RealLocation, _)) 1294 EXPECT_CALL(*gl_, GetUniformiv(kServiceProgramId, kUniform2RealLocation, _))
1360 .Times(1); 1295 .Times(1);
1361 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 1296 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
1362 EXPECT_EQ(GLES2Util::GetGLDataTypeSizeForUniforms(kUniform2Type), 1297 EXPECT_EQ(GLES2Util::GetGLDataTypeSizeForUniforms(kUniform2Type),
1363 result->size); 1298 result->size);
1364 } 1299 }
1365 1300
1366 TEST_P(GLES2DecoderWithShaderTest, GetUniformivArrayElementSucceeds) { 1301 TEST_F(GLES2DecoderWithShaderTest, GetUniformivArrayElementSucceeds) {
1367 GetUniformiv::Result* result = 1302 GetUniformiv::Result* result =
1368 static_cast<GetUniformiv::Result*>(shared_memory_address_); 1303 static_cast<GetUniformiv::Result*>(shared_memory_address_);
1369 result->size = 0; 1304 result->size = 0;
1370 GetUniformiv cmd; 1305 GetUniformiv cmd;
1371 cmd.Init(client_program_id_, 1306 cmd.Init(client_program_id_,
1372 kUniform2ElementFakeLocation, 1307 kUniform2ElementFakeLocation,
1373 kSharedMemoryId, kSharedMemoryOffset); 1308 kSharedMemoryId, kSharedMemoryOffset);
1374 EXPECT_CALL(*gl_, 1309 EXPECT_CALL(*gl_,
1375 GetUniformiv(kServiceProgramId, kUniform2ElementRealLocation, _)) 1310 GetUniformiv(kServiceProgramId, kUniform2ElementRealLocation, _))
1376 .Times(1); 1311 .Times(1);
1377 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 1312 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
1378 EXPECT_EQ(GLES2Util::GetGLDataTypeSizeForUniforms(kUniform2Type), 1313 EXPECT_EQ(GLES2Util::GetGLDataTypeSizeForUniforms(kUniform2Type),
1379 result->size); 1314 result->size);
1380 } 1315 }
1381 1316
1382 TEST_P(GLES2DecoderWithShaderTest, GetUniformivBadProgramFails) { 1317 TEST_F(GLES2DecoderWithShaderTest, GetUniformivBadProgramFails) {
1383 GetUniformiv::Result* result = 1318 GetUniformiv::Result* result =
1384 static_cast<GetUniformiv::Result*>(shared_memory_address_); 1319 static_cast<GetUniformiv::Result*>(shared_memory_address_);
1385 result->size = 0; 1320 result->size = 0;
1386 GetUniformiv cmd; 1321 GetUniformiv cmd;
1387 // non-existant program 1322 // non-existant program
1388 cmd.Init(kInvalidClientId, 1323 cmd.Init(kInvalidClientId,
1389 kUniform2FakeLocation, 1324 kUniform2FakeLocation,
1390 kSharedMemoryId, kSharedMemoryOffset); 1325 kSharedMemoryId, kSharedMemoryOffset);
1391 EXPECT_CALL(*gl_, GetUniformiv(_, _, _)) 1326 EXPECT_CALL(*gl_, GetUniformiv(_, _, _))
1392 .Times(0); 1327 .Times(0);
(...skipping 21 matching lines...) Expand all
1414 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2)); 1349 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2));
1415 result->size = kInitialResult; 1350 result->size = kInitialResult;
1416 cmd.Init(kNewClientId, 1351 cmd.Init(kNewClientId,
1417 kUniform2FakeLocation, 1352 kUniform2FakeLocation,
1418 kSharedMemoryId, kSharedMemoryOffset); 1353 kSharedMemoryId, kSharedMemoryOffset);
1419 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 1354 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
1420 EXPECT_EQ(0U, result->size); 1355 EXPECT_EQ(0U, result->size);
1421 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); 1356 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
1422 } 1357 }
1423 1358
1424 TEST_P(GLES2DecoderWithShaderTest, GetUniformivBadLocationFails) { 1359 TEST_F(GLES2DecoderWithShaderTest, GetUniformivBadLocationFails) {
1425 GetUniformiv::Result* result = 1360 GetUniformiv::Result* result =
1426 static_cast<GetUniformiv::Result*>(shared_memory_address_); 1361 static_cast<GetUniformiv::Result*>(shared_memory_address_);
1427 result->size = 0; 1362 result->size = 0;
1428 GetUniformiv cmd; 1363 GetUniformiv cmd;
1429 // invalid location 1364 // invalid location
1430 cmd.Init(client_program_id_, kInvalidUniformLocation, 1365 cmd.Init(client_program_id_, kInvalidUniformLocation,
1431 kSharedMemoryId, kSharedMemoryOffset); 1366 kSharedMemoryId, kSharedMemoryOffset);
1432 EXPECT_CALL(*gl_, GetUniformiv(_, _, _)) 1367 EXPECT_CALL(*gl_, GetUniformiv(_, _, _))
1433 .Times(0); 1368 .Times(0);
1434 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 1369 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
1435 EXPECT_EQ(0U, result->size); 1370 EXPECT_EQ(0U, result->size);
1436 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); 1371 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
1437 } 1372 }
1438 1373
1439 TEST_P(GLES2DecoderWithShaderTest, GetUniformivBadSharedMemoryFails) { 1374 TEST_F(GLES2DecoderWithShaderTest, GetUniformivBadSharedMemoryFails) {
1440 GetUniformiv cmd; 1375 GetUniformiv cmd;
1441 cmd.Init(client_program_id_, 1376 cmd.Init(client_program_id_,
1442 kUniform2FakeLocation, 1377 kUniform2FakeLocation,
1443 kInvalidSharedMemoryId, kSharedMemoryOffset); 1378 kInvalidSharedMemoryId, kSharedMemoryOffset);
1444 EXPECT_CALL(*gl_, GetUniformiv(_, _, _)) 1379 EXPECT_CALL(*gl_, GetUniformiv(_, _, _))
1445 .Times(0); 1380 .Times(0);
1446 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); 1381 EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
1447 cmd.Init(client_program_id_, kUniform2FakeLocation, 1382 cmd.Init(client_program_id_, kUniform2FakeLocation,
1448 kSharedMemoryId, kInvalidSharedMemoryOffset); 1383 kSharedMemoryId, kInvalidSharedMemoryOffset);
1449 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); 1384 EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
1450 }; 1385 };
1451 1386
1452 TEST_P(GLES2DecoderWithShaderTest, GetUniformfvSucceeds) { 1387 TEST_F(GLES2DecoderWithShaderTest, GetUniformfvSucceeds) {
1453 GetUniformfv::Result* result = 1388 GetUniformfv::Result* result =
1454 static_cast<GetUniformfv::Result*>(shared_memory_address_); 1389 static_cast<GetUniformfv::Result*>(shared_memory_address_);
1455 result->size = 0; 1390 result->size = 0;
1456 GetUniformfv cmd; 1391 GetUniformfv cmd;
1457 cmd.Init(client_program_id_, 1392 cmd.Init(client_program_id_,
1458 kUniform2FakeLocation, 1393 kUniform2FakeLocation,
1459 kSharedMemoryId, kSharedMemoryOffset); 1394 kSharedMemoryId, kSharedMemoryOffset);
1460 EXPECT_CALL(*gl_, GetUniformfv(kServiceProgramId, kUniform2RealLocation, _)) 1395 EXPECT_CALL(*gl_, GetUniformfv(kServiceProgramId, kUniform2RealLocation, _))
1461 .Times(1); 1396 .Times(1);
1462 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 1397 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
1463 EXPECT_EQ(GLES2Util::GetGLDataTypeSizeForUniforms(kUniform2Type), 1398 EXPECT_EQ(GLES2Util::GetGLDataTypeSizeForUniforms(kUniform2Type),
1464 result->size); 1399 result->size);
1465 } 1400 }
1466 1401
1467 TEST_P(GLES2DecoderWithShaderTest, GetUniformfvArrayElementSucceeds) { 1402 TEST_F(GLES2DecoderWithShaderTest, GetUniformfvArrayElementSucceeds) {
1468 GetUniformfv::Result* result = 1403 GetUniformfv::Result* result =
1469 static_cast<GetUniformfv::Result*>(shared_memory_address_); 1404 static_cast<GetUniformfv::Result*>(shared_memory_address_);
1470 result->size = 0; 1405 result->size = 0;
1471 GetUniformfv cmd; 1406 GetUniformfv cmd;
1472 cmd.Init(client_program_id_, 1407 cmd.Init(client_program_id_,
1473 kUniform2ElementFakeLocation, 1408 kUniform2ElementFakeLocation,
1474 kSharedMemoryId, kSharedMemoryOffset); 1409 kSharedMemoryId, kSharedMemoryOffset);
1475 EXPECT_CALL(*gl_, 1410 EXPECT_CALL(*gl_,
1476 GetUniformfv(kServiceProgramId, kUniform2ElementRealLocation, _)) 1411 GetUniformfv(kServiceProgramId, kUniform2ElementRealLocation, _))
1477 .Times(1); 1412 .Times(1);
1478 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 1413 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
1479 EXPECT_EQ(GLES2Util::GetGLDataTypeSizeForUniforms(kUniform2Type), 1414 EXPECT_EQ(GLES2Util::GetGLDataTypeSizeForUniforms(kUniform2Type),
1480 result->size); 1415 result->size);
1481 } 1416 }
1482 1417
1483 TEST_P(GLES2DecoderWithShaderTest, GetUniformfvBadProgramFails) { 1418 TEST_F(GLES2DecoderWithShaderTest, GetUniformfvBadProgramFails) {
1484 GetUniformfv::Result* result = 1419 GetUniformfv::Result* result =
1485 static_cast<GetUniformfv::Result*>(shared_memory_address_); 1420 static_cast<GetUniformfv::Result*>(shared_memory_address_);
1486 result->size = 0; 1421 result->size = 0;
1487 GetUniformfv cmd; 1422 GetUniformfv cmd;
1488 // non-existant program 1423 // non-existant program
1489 cmd.Init(kInvalidClientId, 1424 cmd.Init(kInvalidClientId,
1490 kUniform2FakeLocation, 1425 kUniform2FakeLocation,
1491 kSharedMemoryId, kSharedMemoryOffset); 1426 kSharedMemoryId, kSharedMemoryOffset);
1492 EXPECT_CALL(*gl_, GetUniformfv(_, _, _)) 1427 EXPECT_CALL(*gl_, GetUniformfv(_, _, _))
1493 .Times(0); 1428 .Times(0);
(...skipping 21 matching lines...) Expand all
1515 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2)); 1450 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2));
1516 result->size = kInitialResult; 1451 result->size = kInitialResult;
1517 cmd.Init(kNewClientId, 1452 cmd.Init(kNewClientId,
1518 kUniform2FakeLocation, 1453 kUniform2FakeLocation,
1519 kSharedMemoryId, kSharedMemoryOffset); 1454 kSharedMemoryId, kSharedMemoryOffset);
1520 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 1455 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
1521 EXPECT_EQ(0U, result->size); 1456 EXPECT_EQ(0U, result->size);
1522 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); 1457 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
1523 } 1458 }
1524 1459
1525 TEST_P(GLES2DecoderWithShaderTest, GetUniformfvBadLocationFails) { 1460 TEST_F(GLES2DecoderWithShaderTest, GetUniformfvBadLocationFails) {
1526 GetUniformfv::Result* result = 1461 GetUniformfv::Result* result =
1527 static_cast<GetUniformfv::Result*>(shared_memory_address_); 1462 static_cast<GetUniformfv::Result*>(shared_memory_address_);
1528 result->size = 0; 1463 result->size = 0;
1529 GetUniformfv cmd; 1464 GetUniformfv cmd;
1530 // invalid location 1465 // invalid location
1531 cmd.Init(client_program_id_, kInvalidUniformLocation, 1466 cmd.Init(client_program_id_, kInvalidUniformLocation,
1532 kSharedMemoryId, kSharedMemoryOffset); 1467 kSharedMemoryId, kSharedMemoryOffset);
1533 EXPECT_CALL(*gl_, GetUniformfv(_, _, _)) 1468 EXPECT_CALL(*gl_, GetUniformfv(_, _, _))
1534 .Times(0); 1469 .Times(0);
1535 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 1470 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
1536 EXPECT_EQ(0U, result->size); 1471 EXPECT_EQ(0U, result->size);
1537 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); 1472 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
1538 } 1473 }
1539 1474
1540 TEST_P(GLES2DecoderWithShaderTest, GetUniformfvBadSharedMemoryFails) { 1475 TEST_F(GLES2DecoderWithShaderTest, GetUniformfvBadSharedMemoryFails) {
1541 GetUniformfv cmd; 1476 GetUniformfv cmd;
1542 cmd.Init(client_program_id_, 1477 cmd.Init(client_program_id_,
1543 kUniform2FakeLocation, 1478 kUniform2FakeLocation,
1544 kInvalidSharedMemoryId, kSharedMemoryOffset); 1479 kInvalidSharedMemoryId, kSharedMemoryOffset);
1545 EXPECT_CALL(*gl_, GetUniformfv(_, _, _)) 1480 EXPECT_CALL(*gl_, GetUniformfv(_, _, _))
1546 .Times(0); 1481 .Times(0);
1547 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); 1482 EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
1548 cmd.Init(client_program_id_, kUniform2FakeLocation, 1483 cmd.Init(client_program_id_, kUniform2FakeLocation,
1549 kSharedMemoryId, kInvalidSharedMemoryOffset); 1484 kSharedMemoryId, kInvalidSharedMemoryOffset);
1550 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); 1485 EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
1551 }; 1486 };
1552 1487
1553 TEST_P(GLES2DecoderWithShaderTest, GetAttachedShadersSucceeds) { 1488 TEST_F(GLES2DecoderWithShaderTest, GetAttachedShadersSucceeds) {
1554 GetAttachedShaders cmd; 1489 GetAttachedShaders cmd;
1555 typedef GetAttachedShaders::Result Result; 1490 typedef GetAttachedShaders::Result Result;
1556 Result* result = static_cast<Result*>(shared_memory_address_); 1491 Result* result = static_cast<Result*>(shared_memory_address_);
1557 result->size = 0; 1492 result->size = 0;
1558 EXPECT_CALL(*gl_, GetAttachedShaders(kServiceProgramId, 1, _, _)) 1493 EXPECT_CALL(*gl_, GetAttachedShaders(kServiceProgramId, 1, _, _))
1559 .WillOnce(DoAll(SetArgumentPointee<2>(1), 1494 .WillOnce(DoAll(SetArgumentPointee<2>(1),
1560 SetArgumentPointee<3>(kServiceShaderId))); 1495 SetArgumentPointee<3>(kServiceShaderId)));
1561 cmd.Init(client_program_id_, shared_memory_id_, shared_memory_offset_, 1496 cmd.Init(client_program_id_, shared_memory_id_, shared_memory_offset_,
1562 Result::ComputeSize(1)); 1497 Result::ComputeSize(1));
1563 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 1498 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
1564 EXPECT_EQ(1, result->GetNumResults()); 1499 EXPECT_EQ(1, result->GetNumResults());
1565 EXPECT_EQ(client_shader_id_, result->GetData()[0]); 1500 EXPECT_EQ(client_shader_id_, result->GetData()[0]);
1566 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 1501 EXPECT_EQ(GL_NO_ERROR, GetGLError());
1567 } 1502 }
1568 1503
1569 TEST_P(GLES2DecoderWithShaderTest, GetAttachedShadersResultNotInitFail) { 1504 TEST_F(GLES2DecoderWithShaderTest, GetAttachedShadersResultNotInitFail) {
1570 GetAttachedShaders cmd; 1505 GetAttachedShaders cmd;
1571 typedef GetAttachedShaders::Result Result; 1506 typedef GetAttachedShaders::Result Result;
1572 Result* result = static_cast<Result*>(shared_memory_address_); 1507 Result* result = static_cast<Result*>(shared_memory_address_);
1573 result->size = 1; 1508 result->size = 1;
1574 EXPECT_CALL(*gl_, GetAttachedShaders(_, _, _, _)) 1509 EXPECT_CALL(*gl_, GetAttachedShaders(_, _, _, _))
1575 .Times(0); 1510 .Times(0);
1576 cmd.Init(client_program_id_, shared_memory_id_, shared_memory_offset_, 1511 cmd.Init(client_program_id_, shared_memory_id_, shared_memory_offset_,
1577 Result::ComputeSize(1)); 1512 Result::ComputeSize(1));
1578 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); 1513 EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
1579 } 1514 }
1580 1515
1581 TEST_P(GLES2DecoderWithShaderTest, GetAttachedShadersBadProgramFails) { 1516 TEST_F(GLES2DecoderWithShaderTest, GetAttachedShadersBadProgramFails) {
1582 GetAttachedShaders cmd; 1517 GetAttachedShaders cmd;
1583 typedef GetAttachedShaders::Result Result; 1518 typedef GetAttachedShaders::Result Result;
1584 Result* result = static_cast<Result*>(shared_memory_address_); 1519 Result* result = static_cast<Result*>(shared_memory_address_);
1585 result->size = 0; 1520 result->size = 0;
1586 EXPECT_CALL(*gl_, GetAttachedShaders(_, _, _, _)) 1521 EXPECT_CALL(*gl_, GetAttachedShaders(_, _, _, _))
1587 .Times(0); 1522 .Times(0);
1588 cmd.Init(kInvalidClientId, shared_memory_id_, shared_memory_offset_, 1523 cmd.Init(kInvalidClientId, shared_memory_id_, shared_memory_offset_,
1589 Result::ComputeSize(1)); 1524 Result::ComputeSize(1));
1590 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 1525 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
1591 EXPECT_EQ(0U, result->size); 1526 EXPECT_EQ(0U, result->size);
1592 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); 1527 EXPECT_EQ(GL_INVALID_VALUE, GetGLError());
1593 } 1528 }
1594 1529
1595 TEST_P(GLES2DecoderWithShaderTest, GetAttachedShadersBadSharedMemoryFails) { 1530 TEST_F(GLES2DecoderWithShaderTest, GetAttachedShadersBadSharedMemoryFails) {
1596 GetAttachedShaders cmd; 1531 GetAttachedShaders cmd;
1597 typedef GetAttachedShaders::Result Result; 1532 typedef GetAttachedShaders::Result Result;
1598 cmd.Init(client_program_id_, kInvalidSharedMemoryId, shared_memory_offset_, 1533 cmd.Init(client_program_id_, kInvalidSharedMemoryId, shared_memory_offset_,
1599 Result::ComputeSize(1)); 1534 Result::ComputeSize(1));
1600 EXPECT_CALL(*gl_, GetAttachedShaders(_, _, _, _)) 1535 EXPECT_CALL(*gl_, GetAttachedShaders(_, _, _, _))
1601 .Times(0); 1536 .Times(0);
1602 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); 1537 EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
1603 cmd.Init(client_program_id_, shared_memory_id_, kInvalidSharedMemoryOffset, 1538 cmd.Init(client_program_id_, shared_memory_id_, kInvalidSharedMemoryOffset,
1604 Result::ComputeSize(1)); 1539 Result::ComputeSize(1));
1605 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); 1540 EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
1606 } 1541 }
1607 1542
1608 TEST_P(GLES2DecoderWithShaderTest, GetShaderPrecisionFormatSucceeds) { 1543 TEST_F(GLES2DecoderWithShaderTest, GetShaderPrecisionFormatSucceeds) {
1609 ScopedGLImplementationSetter gl_impl(::gfx::kGLImplementationEGLGLES2); 1544 ScopedGLImplementationSetter gl_impl(::gfx::kGLImplementationEGLGLES2);
1610 GetShaderPrecisionFormat cmd; 1545 GetShaderPrecisionFormat cmd;
1611 typedef GetShaderPrecisionFormat::Result Result; 1546 typedef GetShaderPrecisionFormat::Result Result;
1612 Result* result = static_cast<Result*>(shared_memory_address_); 1547 Result* result = static_cast<Result*>(shared_memory_address_);
1613 result->success = 0; 1548 result->success = 0;
1614 const GLint range[2] = { 62, 62 }; 1549 const GLint range[2] = { 62, 62 };
1615 const GLint precision = 16; 1550 const GLint precision = 16;
1616 EXPECT_CALL(*gl_,GetShaderPrecisionFormat(_, _, _, _)) 1551 EXPECT_CALL(*gl_,GetShaderPrecisionFormat(_, _, _, _))
1617 .WillOnce(DoAll(SetArrayArgument<2>(range,range+2), 1552 .WillOnce(DoAll(SetArrayArgument<2>(range,range+2),
1618 SetArgumentPointee<3>(precision))) 1553 SetArgumentPointee<3>(precision)))
1619 .RetiresOnSaturation(); 1554 .RetiresOnSaturation();
1620 cmd.Init(GL_VERTEX_SHADER, GL_HIGH_FLOAT, 1555 cmd.Init(GL_VERTEX_SHADER, GL_HIGH_FLOAT,
1621 shared_memory_id_, shared_memory_offset_); 1556 shared_memory_id_, shared_memory_offset_);
1622 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 1557 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
1623 EXPECT_NE(0, result->success); 1558 EXPECT_NE(0, result->success);
1624 EXPECT_EQ(range[0], result->min_range); 1559 EXPECT_EQ(range[0], result->min_range);
1625 EXPECT_EQ(range[1], result->max_range); 1560 EXPECT_EQ(range[1], result->max_range);
1626 EXPECT_EQ(precision, result->precision); 1561 EXPECT_EQ(precision, result->precision);
1627 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 1562 EXPECT_EQ(GL_NO_ERROR, GetGLError());
1628 } 1563 }
1629 1564
1630 TEST_P(GLES2DecoderWithShaderTest, GetShaderPrecisionFormatResultNotInitFails) { 1565 TEST_F(GLES2DecoderWithShaderTest, GetShaderPrecisionFormatResultNotInitFails) {
1631 GetShaderPrecisionFormat cmd; 1566 GetShaderPrecisionFormat cmd;
1632 typedef GetShaderPrecisionFormat::Result Result; 1567 typedef GetShaderPrecisionFormat::Result Result;
1633 Result* result = static_cast<Result*>(shared_memory_address_); 1568 Result* result = static_cast<Result*>(shared_memory_address_);
1634 result->success = 1; 1569 result->success = 1;
1635 // NOTE: GL might not be called. There is no Desktop OpenGL equivalent 1570 // NOTE: GL might not be called. There is no Desktop OpenGL equivalent
1636 cmd.Init(GL_VERTEX_SHADER, GL_HIGH_FLOAT, 1571 cmd.Init(GL_VERTEX_SHADER, GL_HIGH_FLOAT,
1637 shared_memory_id_, shared_memory_offset_); 1572 shared_memory_id_, shared_memory_offset_);
1638 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); 1573 EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
1639 } 1574 }
1640 1575
1641 TEST_P(GLES2DecoderWithShaderTest, GetShaderPrecisionFormatBadArgsFails) { 1576 TEST_F(GLES2DecoderWithShaderTest, GetShaderPrecisionFormatBadArgsFails) {
1642 typedef GetShaderPrecisionFormat::Result Result; 1577 typedef GetShaderPrecisionFormat::Result Result;
1643 Result* result = static_cast<Result*>(shared_memory_address_); 1578 Result* result = static_cast<Result*>(shared_memory_address_);
1644 result->success = 0; 1579 result->success = 0;
1645 GetShaderPrecisionFormat cmd; 1580 GetShaderPrecisionFormat cmd;
1646 cmd.Init(GL_TEXTURE_2D, GL_HIGH_FLOAT, 1581 cmd.Init(GL_TEXTURE_2D, GL_HIGH_FLOAT,
1647 shared_memory_id_, shared_memory_offset_); 1582 shared_memory_id_, shared_memory_offset_);
1648 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 1583 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
1649 EXPECT_EQ(GL_INVALID_ENUM, GetGLError()); 1584 EXPECT_EQ(GL_INVALID_ENUM, GetGLError());
1650 result->success = 0; 1585 result->success = 0;
1651 cmd.Init(GL_VERTEX_SHADER, GL_TEXTURE_2D, 1586 cmd.Init(GL_VERTEX_SHADER, GL_TEXTURE_2D,
1652 shared_memory_id_, shared_memory_offset_); 1587 shared_memory_id_, shared_memory_offset_);
1653 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 1588 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
1654 EXPECT_EQ(GL_INVALID_ENUM, GetGLError()); 1589 EXPECT_EQ(GL_INVALID_ENUM, GetGLError());
1655 } 1590 }
1656 1591
1657 TEST_P(GLES2DecoderWithShaderTest, 1592 TEST_F(GLES2DecoderWithShaderTest,
1658 GetShaderPrecisionFormatBadSharedMemoryFails) { 1593 GetShaderPrecisionFormatBadSharedMemoryFails) {
1659 GetShaderPrecisionFormat cmd; 1594 GetShaderPrecisionFormat cmd;
1660 cmd.Init(GL_VERTEX_SHADER, GL_HIGH_FLOAT, 1595 cmd.Init(GL_VERTEX_SHADER, GL_HIGH_FLOAT,
1661 kInvalidSharedMemoryId, shared_memory_offset_); 1596 kInvalidSharedMemoryId, shared_memory_offset_);
1662 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); 1597 EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
1663 cmd.Init(GL_VERTEX_SHADER, GL_TEXTURE_2D, 1598 cmd.Init(GL_VERTEX_SHADER, GL_TEXTURE_2D,
1664 shared_memory_id_, kInvalidSharedMemoryOffset); 1599 shared_memory_id_, kInvalidSharedMemoryOffset);
1665 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); 1600 EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
1666 } 1601 }
1667 1602
1668 TEST_P(GLES2DecoderWithShaderTest, GetActiveUniformSucceeds) { 1603 TEST_F(GLES2DecoderWithShaderTest, GetActiveUniformSucceeds) {
1669 const GLuint kUniformIndex = 1; 1604 const GLuint kUniformIndex = 1;
1670 const uint32 kBucketId = 123; 1605 const uint32 kBucketId = 123;
1671 GetActiveUniform cmd; 1606 GetActiveUniform cmd;
1672 typedef GetActiveUniform::Result Result; 1607 typedef GetActiveUniform::Result Result;
1673 Result* result = static_cast<Result*>(shared_memory_address_); 1608 Result* result = static_cast<Result*>(shared_memory_address_);
1674 result->success = 0; 1609 result->success = 0;
1675 cmd.Init(client_program_id_, kUniformIndex, kBucketId, 1610 cmd.Init(client_program_id_, kUniformIndex, kBucketId,
1676 shared_memory_id_, shared_memory_offset_); 1611 shared_memory_id_, shared_memory_offset_);
1677 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 1612 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
1678 EXPECT_NE(0, result->success); 1613 EXPECT_NE(0, result->success);
1679 EXPECT_EQ(kUniform2Size, result->size); 1614 EXPECT_EQ(kUniform2Size, result->size);
1680 EXPECT_EQ(kUniform2Type, result->type); 1615 EXPECT_EQ(kUniform2Type, result->type);
1681 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 1616 EXPECT_EQ(GL_NO_ERROR, GetGLError());
1682 CommonDecoder::Bucket* bucket = decoder_->GetBucket(kBucketId); 1617 CommonDecoder::Bucket* bucket = decoder_->GetBucket(kBucketId);
1683 ASSERT_TRUE(bucket != NULL); 1618 ASSERT_TRUE(bucket != NULL);
1684 EXPECT_EQ(0, memcmp(bucket->GetData(0, bucket->size()), kUniform2Name, 1619 EXPECT_EQ(0, memcmp(bucket->GetData(0, bucket->size()), kUniform2Name,
1685 bucket->size())); 1620 bucket->size()));
1686 } 1621 }
1687 1622
1688 TEST_P(GLES2DecoderWithShaderTest, GetActiveUniformResultNotInitFails) { 1623 TEST_F(GLES2DecoderWithShaderTest, GetActiveUniformResultNotInitFails) {
1689 const GLuint kUniformIndex = 1; 1624 const GLuint kUniformIndex = 1;
1690 const uint32 kBucketId = 123; 1625 const uint32 kBucketId = 123;
1691 GetActiveUniform cmd; 1626 GetActiveUniform cmd;
1692 typedef GetActiveUniform::Result Result; 1627 typedef GetActiveUniform::Result Result;
1693 Result* result = static_cast<Result*>(shared_memory_address_); 1628 Result* result = static_cast<Result*>(shared_memory_address_);
1694 result->success = 1; 1629 result->success = 1;
1695 cmd.Init(client_program_id_, kUniformIndex, kBucketId, 1630 cmd.Init(client_program_id_, kUniformIndex, kBucketId,
1696 shared_memory_id_, shared_memory_offset_); 1631 shared_memory_id_, shared_memory_offset_);
1697 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); 1632 EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
1698 } 1633 }
1699 1634
1700 TEST_P(GLES2DecoderWithShaderTest, GetActiveUniformBadProgramFails) { 1635 TEST_F(GLES2DecoderWithShaderTest, GetActiveUniformBadProgramFails) {
1701 const GLuint kUniformIndex = 1; 1636 const GLuint kUniformIndex = 1;
1702 const uint32 kBucketId = 123; 1637 const uint32 kBucketId = 123;
1703 GetActiveUniform cmd; 1638 GetActiveUniform cmd;
1704 typedef GetActiveUniform::Result Result; 1639 typedef GetActiveUniform::Result Result;
1705 Result* result = static_cast<Result*>(shared_memory_address_); 1640 Result* result = static_cast<Result*>(shared_memory_address_);
1706 result->success = 0; 1641 result->success = 0;
1707 cmd.Init(kInvalidClientId, kUniformIndex, kBucketId, 1642 cmd.Init(kInvalidClientId, kUniformIndex, kBucketId,
1708 shared_memory_id_, shared_memory_offset_); 1643 shared_memory_id_, shared_memory_offset_);
1709 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 1644 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
1710 EXPECT_EQ(0, result->success); 1645 EXPECT_EQ(0, result->success);
1711 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); 1646 EXPECT_EQ(GL_INVALID_VALUE, GetGLError());
1712 #if GLES2_TEST_SHADER_VS_PROGRAM_IDS 1647 #if GLES2_TEST_SHADER_VS_PROGRAM_IDS
1713 result->success = 0; 1648 result->success = 0;
1714 cmd.Init(client_shader_id_, kUniformIndex, kBucketId, 1649 cmd.Init(client_shader_id_, kUniformIndex, kBucketId,
1715 shared_memory_id_, shared_memory_offset_); 1650 shared_memory_id_, shared_memory_offset_);
1716 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 1651 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
1717 EXPECT_EQ(0, result->success); 1652 EXPECT_EQ(0, result->success);
1718 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); 1653 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
1719 #endif // GLES2_TEST_SHADER_VS_PROGRAM_IDS 1654 #endif // GLES2_TEST_SHADER_VS_PROGRAM_IDS
1720 } 1655 }
1721 1656
1722 TEST_P(GLES2DecoderWithShaderTest, GetActiveUniformBadIndexFails) { 1657 TEST_F(GLES2DecoderWithShaderTest, GetActiveUniformBadIndexFails) {
1723 const uint32 kBucketId = 123; 1658 const uint32 kBucketId = 123;
1724 GetActiveUniform cmd; 1659 GetActiveUniform cmd;
1725 typedef GetActiveUniform::Result Result; 1660 typedef GetActiveUniform::Result Result;
1726 Result* result = static_cast<Result*>(shared_memory_address_); 1661 Result* result = static_cast<Result*>(shared_memory_address_);
1727 result->success = 0; 1662 result->success = 0;
1728 cmd.Init(client_program_id_, kBadUniformIndex, kBucketId, 1663 cmd.Init(client_program_id_, kBadUniformIndex, kBucketId,
1729 shared_memory_id_, shared_memory_offset_); 1664 shared_memory_id_, shared_memory_offset_);
1730 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 1665 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
1731 EXPECT_EQ(0, result->success); 1666 EXPECT_EQ(0, result->success);
1732 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); 1667 EXPECT_EQ(GL_INVALID_VALUE, GetGLError());
1733 } 1668 }
1734 1669
1735 TEST_P(GLES2DecoderWithShaderTest, GetActiveUniformBadSharedMemoryFails) { 1670 TEST_F(GLES2DecoderWithShaderTest, GetActiveUniformBadSharedMemoryFails) {
1736 const GLuint kUniformIndex = 1; 1671 const GLuint kUniformIndex = 1;
1737 const uint32 kBucketId = 123; 1672 const uint32 kBucketId = 123;
1738 GetActiveUniform cmd; 1673 GetActiveUniform cmd;
1739 cmd.Init(client_program_id_, kUniformIndex, kBucketId, 1674 cmd.Init(client_program_id_, kUniformIndex, kBucketId,
1740 kInvalidSharedMemoryId, shared_memory_offset_); 1675 kInvalidSharedMemoryId, shared_memory_offset_);
1741 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); 1676 EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
1742 cmd.Init(client_program_id_, kUniformIndex, kBucketId, 1677 cmd.Init(client_program_id_, kUniformIndex, kBucketId,
1743 shared_memory_id_, kInvalidSharedMemoryOffset); 1678 shared_memory_id_, kInvalidSharedMemoryOffset);
1744 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); 1679 EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
1745 } 1680 }
1746 1681
1747 TEST_P(GLES2DecoderWithShaderTest, GetActiveAttribSucceeds) { 1682 TEST_F(GLES2DecoderWithShaderTest, GetActiveAttribSucceeds) {
1748 const GLuint kAttribIndex = 1; 1683 const GLuint kAttribIndex = 1;
1749 const uint32 kBucketId = 123; 1684 const uint32 kBucketId = 123;
1750 GetActiveAttrib cmd; 1685 GetActiveAttrib cmd;
1751 typedef GetActiveAttrib::Result Result; 1686 typedef GetActiveAttrib::Result Result;
1752 Result* result = static_cast<Result*>(shared_memory_address_); 1687 Result* result = static_cast<Result*>(shared_memory_address_);
1753 result->success = 0; 1688 result->success = 0;
1754 cmd.Init(client_program_id_, kAttribIndex, kBucketId, 1689 cmd.Init(client_program_id_, kAttribIndex, kBucketId,
1755 shared_memory_id_, shared_memory_offset_); 1690 shared_memory_id_, shared_memory_offset_);
1756 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 1691 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
1757 EXPECT_NE(0, result->success); 1692 EXPECT_NE(0, result->success);
1758 EXPECT_EQ(kAttrib2Size, result->size); 1693 EXPECT_EQ(kAttrib2Size, result->size);
1759 EXPECT_EQ(kAttrib2Type, result->type); 1694 EXPECT_EQ(kAttrib2Type, result->type);
1760 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 1695 EXPECT_EQ(GL_NO_ERROR, GetGLError());
1761 CommonDecoder::Bucket* bucket = decoder_->GetBucket(kBucketId); 1696 CommonDecoder::Bucket* bucket = decoder_->GetBucket(kBucketId);
1762 ASSERT_TRUE(bucket != NULL); 1697 ASSERT_TRUE(bucket != NULL);
1763 EXPECT_EQ(0, memcmp(bucket->GetData(0, bucket->size()), kAttrib2Name, 1698 EXPECT_EQ(0, memcmp(bucket->GetData(0, bucket->size()), kAttrib2Name,
1764 bucket->size())); 1699 bucket->size()));
1765 } 1700 }
1766 1701
1767 TEST_P(GLES2DecoderWithShaderTest, GetActiveAttribResultNotInitFails) { 1702 TEST_F(GLES2DecoderWithShaderTest, GetActiveAttribResultNotInitFails) {
1768 const GLuint kAttribIndex = 1; 1703 const GLuint kAttribIndex = 1;
1769 const uint32 kBucketId = 123; 1704 const uint32 kBucketId = 123;
1770 GetActiveAttrib cmd; 1705 GetActiveAttrib cmd;
1771 typedef GetActiveAttrib::Result Result; 1706 typedef GetActiveAttrib::Result Result;
1772 Result* result = static_cast<Result*>(shared_memory_address_); 1707 Result* result = static_cast<Result*>(shared_memory_address_);
1773 result->success = 1; 1708 result->success = 1;
1774 cmd.Init(client_program_id_, kAttribIndex, kBucketId, 1709 cmd.Init(client_program_id_, kAttribIndex, kBucketId,
1775 shared_memory_id_, shared_memory_offset_); 1710 shared_memory_id_, shared_memory_offset_);
1776 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); 1711 EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
1777 } 1712 }
1778 1713
1779 TEST_P(GLES2DecoderWithShaderTest, GetActiveAttribBadProgramFails) { 1714 TEST_F(GLES2DecoderWithShaderTest, GetActiveAttribBadProgramFails) {
1780 const GLuint kAttribIndex = 1; 1715 const GLuint kAttribIndex = 1;
1781 const uint32 kBucketId = 123; 1716 const uint32 kBucketId = 123;
1782 GetActiveAttrib cmd; 1717 GetActiveAttrib cmd;
1783 typedef GetActiveAttrib::Result Result; 1718 typedef GetActiveAttrib::Result Result;
1784 Result* result = static_cast<Result*>(shared_memory_address_); 1719 Result* result = static_cast<Result*>(shared_memory_address_);
1785 result->success = 0; 1720 result->success = 0;
1786 cmd.Init(kInvalidClientId, kAttribIndex, kBucketId, 1721 cmd.Init(kInvalidClientId, kAttribIndex, kBucketId,
1787 shared_memory_id_, shared_memory_offset_); 1722 shared_memory_id_, shared_memory_offset_);
1788 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 1723 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
1789 EXPECT_EQ(0, result->success); 1724 EXPECT_EQ(0, result->success);
1790 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); 1725 EXPECT_EQ(GL_INVALID_VALUE, GetGLError());
1791 #if GLES2_TEST_SHADER_VS_PROGRAM_IDS 1726 #if GLES2_TEST_SHADER_VS_PROGRAM_IDS
1792 result->success = 0; 1727 result->success = 0;
1793 cmd.Init(client_shader_id_, kAttribIndex, kBucketId, 1728 cmd.Init(client_shader_id_, kAttribIndex, kBucketId,
1794 shared_memory_id_, shared_memory_offset_); 1729 shared_memory_id_, shared_memory_offset_);
1795 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 1730 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
1796 EXPECT_EQ(0, result->success); 1731 EXPECT_EQ(0, result->success);
1797 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); 1732 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
1798 #endif // GLES2_TEST_SHADER_VS_PROGRAM_IDS 1733 #endif // GLES2_TEST_SHADER_VS_PROGRAM_IDS
1799 } 1734 }
1800 1735
1801 TEST_P(GLES2DecoderWithShaderTest, GetActiveAttribBadIndexFails) { 1736 TEST_F(GLES2DecoderWithShaderTest, GetActiveAttribBadIndexFails) {
1802 const uint32 kBucketId = 123; 1737 const uint32 kBucketId = 123;
1803 GetActiveAttrib cmd; 1738 GetActiveAttrib cmd;
1804 typedef GetActiveAttrib::Result Result; 1739 typedef GetActiveAttrib::Result Result;
1805 Result* result = static_cast<Result*>(shared_memory_address_); 1740 Result* result = static_cast<Result*>(shared_memory_address_);
1806 result->success = 0; 1741 result->success = 0;
1807 cmd.Init(client_program_id_, kBadAttribIndex, kBucketId, 1742 cmd.Init(client_program_id_, kBadAttribIndex, kBucketId,
1808 shared_memory_id_, shared_memory_offset_); 1743 shared_memory_id_, shared_memory_offset_);
1809 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 1744 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
1810 EXPECT_EQ(0, result->success); 1745 EXPECT_EQ(0, result->success);
1811 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); 1746 EXPECT_EQ(GL_INVALID_VALUE, GetGLError());
1812 } 1747 }
1813 1748
1814 TEST_P(GLES2DecoderWithShaderTest, GetActiveAttribBadSharedMemoryFails) { 1749 TEST_F(GLES2DecoderWithShaderTest, GetActiveAttribBadSharedMemoryFails) {
1815 const GLuint kAttribIndex = 1; 1750 const GLuint kAttribIndex = 1;
1816 const uint32 kBucketId = 123; 1751 const uint32 kBucketId = 123;
1817 GetActiveAttrib cmd; 1752 GetActiveAttrib cmd;
1818 cmd.Init(client_program_id_, kAttribIndex, kBucketId, 1753 cmd.Init(client_program_id_, kAttribIndex, kBucketId,
1819 kInvalidSharedMemoryId, shared_memory_offset_); 1754 kInvalidSharedMemoryId, shared_memory_offset_);
1820 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); 1755 EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
1821 cmd.Init(client_program_id_, kAttribIndex, kBucketId, 1756 cmd.Init(client_program_id_, kAttribIndex, kBucketId,
1822 shared_memory_id_, kInvalidSharedMemoryOffset); 1757 shared_memory_id_, kInvalidSharedMemoryOffset);
1823 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); 1758 EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
1824 } 1759 }
1825 1760
1826 TEST_P(GLES2DecoderWithShaderTest, GetShaderInfoLogValidArgs) { 1761 TEST_F(GLES2DecoderWithShaderTest, GetShaderInfoLogValidArgs) {
1827 const char* kInfo = "hello"; 1762 const char* kInfo = "hello";
1828 const uint32 kBucketId = 123; 1763 const uint32 kBucketId = 123;
1829 CompileShader compile_cmd; 1764 CompileShader compile_cmd;
1830 GetShaderInfoLog cmd; 1765 GetShaderInfoLog cmd;
1831 EXPECT_CALL(*gl_, ShaderSource(kServiceShaderId, 1, _, _)); 1766 EXPECT_CALL(*gl_, ShaderSource(kServiceShaderId, 1, _, _));
1832 EXPECT_CALL(*gl_, CompileShader(kServiceShaderId)); 1767 EXPECT_CALL(*gl_, CompileShader(kServiceShaderId));
1833 EXPECT_CALL(*gl_, GetShaderiv(kServiceShaderId, GL_COMPILE_STATUS, _)) 1768 EXPECT_CALL(*gl_, GetShaderiv(kServiceShaderId, GL_COMPILE_STATUS, _))
1834 .WillOnce(SetArgumentPointee<2>(GL_FALSE)) 1769 .WillOnce(SetArgumentPointee<2>(GL_FALSE))
1835 .RetiresOnSaturation(); 1770 .RetiresOnSaturation();
1836 EXPECT_CALL(*gl_, GetShaderiv(kServiceShaderId, GL_INFO_LOG_LENGTH, _)) 1771 EXPECT_CALL(*gl_, GetShaderiv(kServiceShaderId, GL_INFO_LOG_LENGTH, _))
1837 .WillOnce(SetArgumentPointee<2>(strlen(kInfo) + 1)) 1772 .WillOnce(SetArgumentPointee<2>(strlen(kInfo) + 1))
1838 .RetiresOnSaturation(); 1773 .RetiresOnSaturation();
1839 EXPECT_CALL( 1774 EXPECT_CALL(
1840 *gl_, GetShaderInfoLog(kServiceShaderId, strlen(kInfo) + 1, _, _)) 1775 *gl_, GetShaderInfoLog(kServiceShaderId, strlen(kInfo) + 1, _, _))
1841 .WillOnce(DoAll(SetArgumentPointee<2>(strlen(kInfo)), 1776 .WillOnce(DoAll(SetArgumentPointee<2>(strlen(kInfo)),
1842 SetArrayArgument<3>(kInfo, kInfo + strlen(kInfo) + 1))); 1777 SetArrayArgument<3>(kInfo, kInfo + strlen(kInfo) + 1)));
1843 compile_cmd.Init(client_shader_id_); 1778 compile_cmd.Init(client_shader_id_);
1844 cmd.Init(client_shader_id_, kBucketId); 1779 cmd.Init(client_shader_id_, kBucketId);
1845 EXPECT_EQ(error::kNoError, ExecuteCmd(compile_cmd)); 1780 EXPECT_EQ(error::kNoError, ExecuteCmd(compile_cmd));
1846 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 1781 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
1847 CommonDecoder::Bucket* bucket = decoder_->GetBucket(kBucketId); 1782 CommonDecoder::Bucket* bucket = decoder_->GetBucket(kBucketId);
1848 ASSERT_TRUE(bucket != NULL); 1783 ASSERT_TRUE(bucket != NULL);
1849 EXPECT_EQ(strlen(kInfo) + 1, bucket->size()); 1784 EXPECT_EQ(strlen(kInfo) + 1, bucket->size());
1850 EXPECT_EQ(0, memcmp(bucket->GetData(0, bucket->size()), kInfo, 1785 EXPECT_EQ(0, memcmp(bucket->GetData(0, bucket->size()), kInfo,
1851 bucket->size())); 1786 bucket->size()));
1852 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 1787 EXPECT_EQ(GL_NO_ERROR, GetGLError());
1853 } 1788 }
1854 1789
1855 TEST_P(GLES2DecoderWithShaderTest, GetShaderInfoLogInvalidArgs) { 1790 TEST_F(GLES2DecoderWithShaderTest, GetShaderInfoLogInvalidArgs) {
1856 const uint32 kBucketId = 123; 1791 const uint32 kBucketId = 123;
1857 GetShaderInfoLog cmd; 1792 GetShaderInfoLog cmd;
1858 cmd.Init(kInvalidClientId, kBucketId); 1793 cmd.Init(kInvalidClientId, kBucketId);
1859 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 1794 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
1860 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); 1795 EXPECT_EQ(GL_INVALID_VALUE, GetGLError());
1861 } 1796 }
1862 1797
1863 TEST_P(GLES2DecoderTest, GetIntegervCached) { 1798 TEST_F(GLES2DecoderTest, GetIntegervCached) {
1864 struct TestInfo { 1799 struct TestInfo {
1865 GLenum pname; 1800 GLenum pname;
1866 GLint expected; 1801 GLint expected;
1867 }; 1802 };
1868 TestInfo tests[] = { 1803 TestInfo tests[] = {
1869 { GL_MAX_TEXTURE_SIZE, TestHelper::kMaxTextureSize, }, 1804 { GL_MAX_TEXTURE_SIZE, TestHelper::kMaxTextureSize, },
1870 { GL_MAX_CUBE_MAP_TEXTURE_SIZE, TestHelper::kMaxCubeMapTextureSize, }, 1805 { GL_MAX_CUBE_MAP_TEXTURE_SIZE, TestHelper::kMaxCubeMapTextureSize, },
1871 { GL_MAX_RENDERBUFFER_SIZE, TestHelper::kMaxRenderbufferSize, }, 1806 { GL_MAX_RENDERBUFFER_SIZE, TestHelper::kMaxRenderbufferSize, },
1872 }; 1807 };
1873 typedef GetIntegerv::Result Result; 1808 typedef GetIntegerv::Result Result;
(...skipping 11 matching lines...) Expand all
1885 cmd2.Init(test.pname, shared_memory_id_, shared_memory_offset_); 1820 cmd2.Init(test.pname, shared_memory_id_, shared_memory_offset_);
1886 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2)); 1821 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2));
1887 EXPECT_EQ( 1822 EXPECT_EQ(
1888 decoder_->GetGLES2Util()->GLGetNumValuesReturned(test.pname), 1823 decoder_->GetGLES2Util()->GLGetNumValuesReturned(test.pname),
1889 result->GetNumResults()); 1824 result->GetNumResults());
1890 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 1825 EXPECT_EQ(GL_NO_ERROR, GetGLError());
1891 EXPECT_EQ(test.expected, result->GetData()[0]); 1826 EXPECT_EQ(test.expected, result->GetData()[0]);
1892 } 1827 }
1893 } 1828 }
1894 1829
1895 TEST_P(GLES2DecoderTest, CompileShaderValidArgs) { 1830 TEST_F(GLES2DecoderTest, CompileShaderValidArgs) {
1896 EXPECT_CALL(*gl_, ShaderSource(kServiceShaderId, 1, _, _)); 1831 EXPECT_CALL(*gl_, ShaderSource(kServiceShaderId, 1, _, _));
1897 EXPECT_CALL(*gl_, CompileShader(kServiceShaderId)); 1832 EXPECT_CALL(*gl_, CompileShader(kServiceShaderId));
1898 EXPECT_CALL(*gl_, GetShaderiv(kServiceShaderId, GL_COMPILE_STATUS, _)) 1833 EXPECT_CALL(*gl_, GetShaderiv(kServiceShaderId, GL_COMPILE_STATUS, _))
1899 .WillOnce(SetArgumentPointee<2>(GL_TRUE)) 1834 .WillOnce(SetArgumentPointee<2>(GL_TRUE))
1900 .RetiresOnSaturation(); 1835 .RetiresOnSaturation();
1901 CompileShader cmd; 1836 CompileShader cmd;
1902 cmd.Init(client_shader_id_); 1837 cmd.Init(client_shader_id_);
1903 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 1838 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
1904 } 1839 }
1905 1840
1906 TEST_P(GLES2DecoderTest, CompileShaderInvalidArgs) { 1841 TEST_F(GLES2DecoderTest, CompileShaderInvalidArgs) {
1907 CompileShader cmd; 1842 CompileShader cmd;
1908 cmd.Init(kInvalidClientId); 1843 cmd.Init(kInvalidClientId);
1909 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 1844 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
1910 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); 1845 EXPECT_EQ(GL_INVALID_VALUE, GetGLError());
1911 #if GLES2_TEST_SHADER_VS_PROGRAM_IDS 1846 #if GLES2_TEST_SHADER_VS_PROGRAM_IDS
1912 cmd.Init(client_program_id_); 1847 cmd.Init(client_program_id_);
1913 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 1848 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
1914 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); 1849 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
1915 #endif // GLES2_TEST_SHADER_VS_PROGRAM_IDS 1850 #endif // GLES2_TEST_SHADER_VS_PROGRAM_IDS
1916 } 1851 }
1917 1852
1918 TEST_P(GLES2DecoderTest, ShaderSourceAndGetShaderSourceValidArgs) { 1853 TEST_F(GLES2DecoderTest, ShaderSourceAndGetShaderSourceValidArgs) {
1919 const uint32 kBucketId = 123; 1854 const uint32 kBucketId = 123;
1920 const char kSource[] = "hello"; 1855 const char kSource[] = "hello";
1921 const uint32 kSourceSize = sizeof(kSource) - 1; 1856 const uint32 kSourceSize = sizeof(kSource) - 1;
1922 memcpy(shared_memory_address_, kSource, kSourceSize); 1857 memcpy(shared_memory_address_, kSource, kSourceSize);
1923 ShaderSource cmd; 1858 ShaderSource cmd;
1924 cmd.Init(client_shader_id_, 1859 cmd.Init(client_shader_id_,
1925 kSharedMemoryId, kSharedMemoryOffset, kSourceSize); 1860 kSharedMemoryId, kSharedMemoryOffset, kSourceSize);
1926 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 1861 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
1927 memset(shared_memory_address_, 0, kSourceSize); 1862 memset(shared_memory_address_, 0, kSourceSize);
1928 GetShaderSource get_cmd; 1863 GetShaderSource get_cmd;
1929 get_cmd.Init(client_shader_id_, kBucketId); 1864 get_cmd.Init(client_shader_id_, kBucketId);
1930 EXPECT_EQ(error::kNoError, ExecuteCmd(get_cmd)); 1865 EXPECT_EQ(error::kNoError, ExecuteCmd(get_cmd));
1931 CommonDecoder::Bucket* bucket = decoder_->GetBucket(kBucketId); 1866 CommonDecoder::Bucket* bucket = decoder_->GetBucket(kBucketId);
1932 ASSERT_TRUE(bucket != NULL); 1867 ASSERT_TRUE(bucket != NULL);
1933 EXPECT_EQ(kSourceSize + 1, bucket->size()); 1868 EXPECT_EQ(kSourceSize + 1, bucket->size());
1934 EXPECT_EQ(0, memcmp(bucket->GetData(0, bucket->size()), kSource, 1869 EXPECT_EQ(0, memcmp(bucket->GetData(0, bucket->size()), kSource,
1935 bucket->size())); 1870 bucket->size()));
1936 } 1871 }
1937 1872
1938 TEST_P(GLES2DecoderTest, ShaderSourceInvalidArgs) { 1873 TEST_F(GLES2DecoderTest, ShaderSourceInvalidArgs) {
1939 const char kSource[] = "hello"; 1874 const char kSource[] = "hello";
1940 const uint32 kSourceSize = sizeof(kSource) - 1; 1875 const uint32 kSourceSize = sizeof(kSource) - 1;
1941 memcpy(shared_memory_address_, kSource, kSourceSize); 1876 memcpy(shared_memory_address_, kSource, kSourceSize);
1942 ShaderSource cmd; 1877 ShaderSource cmd;
1943 cmd.Init(kInvalidClientId, 1878 cmd.Init(kInvalidClientId,
1944 kSharedMemoryId, kSharedMemoryOffset, kSourceSize); 1879 kSharedMemoryId, kSharedMemoryOffset, kSourceSize);
1945 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 1880 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
1946 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); 1881 EXPECT_EQ(GL_INVALID_VALUE, GetGLError());
1947 #if GLES2_TEST_SHADER_VS_PROGRAM_IDS 1882 #if GLES2_TEST_SHADER_VS_PROGRAM_IDS
1948 cmd.Init(client_program_id_, 1883 cmd.Init(client_program_id_,
1949 kSharedMemoryId, kSharedMemoryOffset, kSourceSize); 1884 kSharedMemoryId, kSharedMemoryOffset, kSourceSize);
1950 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 1885 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
1951 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); 1886 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
1952 #endif // GLES2_TEST_SHADER_VS_PROGRAM_IDS 1887 #endif // GLES2_TEST_SHADER_VS_PROGRAM_IDS
1953 cmd.Init(client_shader_id_, 1888 cmd.Init(client_shader_id_,
1954 kInvalidSharedMemoryId, kSharedMemoryOffset, kSourceSize); 1889 kInvalidSharedMemoryId, kSharedMemoryOffset, kSourceSize);
1955 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); 1890 EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
1956 cmd.Init(client_shader_id_, 1891 cmd.Init(client_shader_id_,
1957 kSharedMemoryId, kInvalidSharedMemoryOffset, kSourceSize); 1892 kSharedMemoryId, kInvalidSharedMemoryOffset, kSourceSize);
1958 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); 1893 EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
1959 cmd.Init(client_shader_id_, 1894 cmd.Init(client_shader_id_,
1960 kSharedMemoryId, kSharedMemoryOffset, kSharedBufferSize); 1895 kSharedMemoryId, kSharedMemoryOffset, kSharedBufferSize);
1961 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); 1896 EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
1962 } 1897 }
1963 1898
1964 TEST_P(GLES2DecoderTest, ShaderSourceBucketAndGetShaderSourceValidArgs) { 1899 TEST_F(GLES2DecoderTest, ShaderSourceBucketAndGetShaderSourceValidArgs) {
1965 const uint32 kInBucketId = 123; 1900 const uint32 kInBucketId = 123;
1966 const uint32 kOutBucketId = 125; 1901 const uint32 kOutBucketId = 125;
1967 const char kSource[] = "hello"; 1902 const char kSource[] = "hello";
1968 const uint32 kSourceSize = sizeof(kSource) - 1; 1903 const uint32 kSourceSize = sizeof(kSource) - 1;
1969 SetBucketAsCString(kInBucketId, kSource); 1904 SetBucketAsCString(kInBucketId, kSource);
1970 ShaderSourceBucket cmd; 1905 ShaderSourceBucket cmd;
1971 cmd.Init(client_shader_id_, kInBucketId); 1906 cmd.Init(client_shader_id_, kInBucketId);
1972 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 1907 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
1973 ClearSharedMemory(); 1908 ClearSharedMemory();
1974 GetShaderSource get_cmd; 1909 GetShaderSource get_cmd;
1975 get_cmd.Init(client_shader_id_, kOutBucketId); 1910 get_cmd.Init(client_shader_id_, kOutBucketId);
1976 EXPECT_EQ(error::kNoError, ExecuteCmd(get_cmd)); 1911 EXPECT_EQ(error::kNoError, ExecuteCmd(get_cmd));
1977 CommonDecoder::Bucket* bucket = decoder_->GetBucket(kOutBucketId); 1912 CommonDecoder::Bucket* bucket = decoder_->GetBucket(kOutBucketId);
1978 ASSERT_TRUE(bucket != NULL); 1913 ASSERT_TRUE(bucket != NULL);
1979 EXPECT_EQ(kSourceSize + 1, bucket->size()); 1914 EXPECT_EQ(kSourceSize + 1, bucket->size());
1980 EXPECT_EQ(0, memcmp(bucket->GetData(0, bucket->size()), kSource, 1915 EXPECT_EQ(0, memcmp(bucket->GetData(0, bucket->size()), kSource,
1981 bucket->size())); 1916 bucket->size()));
1982 } 1917 }
1983 1918
1984 TEST_P(GLES2DecoderTest, ShaderSourceBucketInvalidArgs) { 1919 TEST_F(GLES2DecoderTest, ShaderSourceBucketInvalidArgs) {
1985 const uint32 kBucketId = 123; 1920 const uint32 kBucketId = 123;
1986 const char kSource[] = "hello"; 1921 const char kSource[] = "hello";
1987 const uint32 kSourceSize = sizeof(kSource) - 1; 1922 const uint32 kSourceSize = sizeof(kSource) - 1;
1988 memcpy(shared_memory_address_, kSource, kSourceSize); 1923 memcpy(shared_memory_address_, kSource, kSourceSize);
1989 ShaderSourceBucket cmd; 1924 ShaderSourceBucket cmd;
1990 // Test no bucket. 1925 // Test no bucket.
1991 cmd.Init(client_texture_id_, kBucketId); 1926 cmd.Init(client_texture_id_, kBucketId);
1992 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); 1927 EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
1993 // Test invalid client. 1928 // Test invalid client.
1994 SetBucketAsCString(kBucketId, kSource); 1929 SetBucketAsCString(kBucketId, kSource);
1995 cmd.Init(kInvalidClientId, kBucketId); 1930 cmd.Init(kInvalidClientId, kBucketId);
1996 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 1931 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
1997 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); 1932 EXPECT_EQ(GL_INVALID_VALUE, GetGLError());
1998 } 1933 }
1999 1934
2000 TEST_P(GLES2DecoderTest, ShaderSourceStripComments) { 1935 TEST_F(GLES2DecoderTest, ShaderSourceStripComments) {
2001 const uint32 kInBucketId = 123; 1936 const uint32 kInBucketId = 123;
2002 const char kSource[] = "hello/*te\ast*/world//a\ab"; 1937 const char kSource[] = "hello/*te\ast*/world//a\ab";
2003 SetBucketAsCString(kInBucketId, kSource); 1938 SetBucketAsCString(kInBucketId, kSource);
2004 ShaderSourceBucket cmd; 1939 ShaderSourceBucket cmd;
2005 cmd.Init(client_shader_id_, kInBucketId); 1940 cmd.Init(client_shader_id_, kInBucketId);
2006 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 1941 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
2007 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 1942 EXPECT_EQ(GL_NO_ERROR, GetGLError());
2008 } 1943 }
2009 1944
2010 TEST_P(GLES2DecoderTest, GenerateMipmapWrongFormatsFails) { 1945 TEST_F(GLES2DecoderTest, GenerateMipmapWrongFormatsFails) {
2011 EXPECT_CALL(*gl_, GenerateMipmapEXT(_)) 1946 EXPECT_CALL(*gl_, GenerateMipmapEXT(_))
2012 .Times(0); 1947 .Times(0);
2013 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); 1948 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId);
2014 DoTexImage2D( 1949 DoTexImage2D(
2015 GL_TEXTURE_2D, 0, GL_RGBA, 16, 17, 0, GL_RGBA, GL_UNSIGNED_BYTE, 1950 GL_TEXTURE_2D, 0, GL_RGBA, 16, 17, 0, GL_RGBA, GL_UNSIGNED_BYTE,
2016 0, 0); 1951 0, 0);
2017 GenerateMipmap cmd; 1952 GenerateMipmap cmd;
2018 cmd.Init(GL_TEXTURE_2D); 1953 cmd.Init(GL_TEXTURE_2D);
2019 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 1954 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
2020 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); 1955 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
2021 } 1956 }
2022 1957
2023 TEST_P(GLES2DecoderTest, GenerateMipmapHandlesOutOfMemory) { 1958 TEST_F(GLES2DecoderTest, GenerateMipmapHandlesOutOfMemory) {
2024 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); 1959 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId);
2025 TextureManager* manager = group().texture_manager(); 1960 TextureManager* manager = group().texture_manager();
2026 TextureRef* texture_ref = manager->GetTexture(client_texture_id_); 1961 TextureRef* texture_ref = manager->GetTexture(client_texture_id_);
2027 ASSERT_TRUE(texture_ref != NULL); 1962 ASSERT_TRUE(texture_ref != NULL);
2028 Texture* texture = texture_ref->texture(); 1963 Texture* texture = texture_ref->texture();
2029 GLint width = 0; 1964 GLint width = 0;
2030 GLint height = 0; 1965 GLint height = 0;
2031 EXPECT_FALSE(texture->GetLevelSize(GL_TEXTURE_2D, 2, &width, &height)); 1966 EXPECT_FALSE(texture->GetLevelSize(GL_TEXTURE_2D, 2, &width, &height));
2032 DoTexImage2D( 1967 DoTexImage2D(
2033 GL_TEXTURE_2D, 0, GL_RGBA, 16, 16, 0, GL_RGBA, GL_UNSIGNED_BYTE, 1968 GL_TEXTURE_2D, 0, GL_RGBA, 16, 16, 0, GL_RGBA, GL_UNSIGNED_BYTE,
2034 kSharedMemoryId, kSharedMemoryOffset); 1969 kSharedMemoryId, kSharedMemoryOffset);
2035 EXPECT_CALL(*gl_, GenerateMipmapEXT(GL_TEXTURE_2D)) 1970 EXPECT_CALL(*gl_, GenerateMipmapEXT(GL_TEXTURE_2D))
2036 .Times(1); 1971 .Times(1);
2037 EXPECT_CALL(*gl_, GetError()) 1972 EXPECT_CALL(*gl_, GetError())
2038 .WillOnce(Return(GL_NO_ERROR)) 1973 .WillOnce(Return(GL_NO_ERROR))
2039 .WillOnce(Return(GL_OUT_OF_MEMORY)) 1974 .WillOnce(Return(GL_OUT_OF_MEMORY))
2040 .RetiresOnSaturation(); 1975 .RetiresOnSaturation();
2041 GenerateMipmap cmd; 1976 GenerateMipmap cmd;
2042 cmd.Init(GL_TEXTURE_2D); 1977 cmd.Init(GL_TEXTURE_2D);
2043 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 1978 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
2044 EXPECT_EQ(GL_OUT_OF_MEMORY, GetGLError()); 1979 EXPECT_EQ(GL_OUT_OF_MEMORY, GetGLError());
2045 EXPECT_FALSE(texture->GetLevelSize(GL_TEXTURE_2D, 2, &width, &height)); 1980 EXPECT_FALSE(texture->GetLevelSize(GL_TEXTURE_2D, 2, &width, &height));
2046 } 1981 }
2047 1982
2048 TEST_P(GLES2DecoderTest, GenerateMipmapClearsUnclearedTexture) { 1983 TEST_F(GLES2DecoderTest, GenerateMipmapClearsUnclearedTexture) {
2049 EXPECT_CALL(*gl_, GenerateMipmapEXT(_)) 1984 EXPECT_CALL(*gl_, GenerateMipmapEXT(_))
2050 .Times(0); 1985 .Times(0);
2051 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); 1986 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId);
2052 DoTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, 1987 DoTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE,
2053 0, 0); 1988 0, 0);
2054 SetupClearTextureExpectations( 1989 SetupClearTextureExpectations(
2055 kServiceTextureId, kServiceTextureId, GL_TEXTURE_2D, GL_TEXTURE_2D, 1990 kServiceTextureId, kServiceTextureId, GL_TEXTURE_2D, GL_TEXTURE_2D,
2056 0, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, 2, 2); 1991 0, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, 2, 2);
2057 EXPECT_CALL(*gl_, GenerateMipmapEXT(GL_TEXTURE_2D)); 1992 EXPECT_CALL(*gl_, GenerateMipmapEXT(GL_TEXTURE_2D));
2058 EXPECT_CALL(*gl_, GetError()) 1993 EXPECT_CALL(*gl_, GetError())
2059 .WillOnce(Return(GL_NO_ERROR)) 1994 .WillOnce(Return(GL_NO_ERROR))
2060 .WillOnce(Return(GL_NO_ERROR)) 1995 .WillOnce(Return(GL_NO_ERROR))
2061 .RetiresOnSaturation(); 1996 .RetiresOnSaturation();
2062 GenerateMipmap cmd; 1997 GenerateMipmap cmd;
2063 cmd.Init(GL_TEXTURE_2D); 1998 cmd.Init(GL_TEXTURE_2D);
2064 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 1999 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
2065 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 2000 EXPECT_EQ(GL_NO_ERROR, GetGLError());
2066 } 2001 }
2067 2002
2068 // Same as GenerateMipmapClearsUnclearedTexture, but with workaround 2003 // Same as GenerateMipmapClearsUnclearedTexture, but with workaround
2069 // |set_texture_filters_before_generating_mipmap|. 2004 // |set_texture_filters_before_generating_mipmap|.
2070 TEST_P(GLES2DecoderManualInitTest, SetTextureFiltersBeforeGenerateMipmap) { 2005 TEST_F(GLES2DecoderManualInitTest, SetTextureFiltersBeforeGenerateMipmap) {
2071 CommandLine command_line(0, NULL); 2006 CommandLine command_line(0, NULL);
2072 command_line.AppendSwitchASCII( 2007 command_line.AppendSwitchASCII(
2073 switches::kGpuDriverBugWorkarounds, 2008 switches::kGpuDriverBugWorkarounds,
2074 base::IntToString(gpu::SET_TEXTURE_FILTER_BEFORE_GENERATING_MIPMAP)); 2009 base::IntToString(gpu::SET_TEXTURE_FILTER_BEFORE_GENERATING_MIPMAP));
2075 InitState init; 2010 InitState init;
2076 init.gl_version = "3.0"; 2011 init.gl_version = "3.0";
2077 init.bind_generates_resource = true; 2012 init.bind_generates_resource = true;
2078 InitDecoderWithCommandLine(init, &command_line); 2013 InitDecoderWithCommandLine(init, &command_line);
2079 2014
2080 EXPECT_CALL(*gl_, GenerateMipmapEXT(_)) 2015 EXPECT_CALL(*gl_, GenerateMipmapEXT(_))
(...skipping 16 matching lines...) Expand all
2097 EXPECT_CALL(*gl_, GetError()) 2032 EXPECT_CALL(*gl_, GetError())
2098 .WillOnce(Return(GL_NO_ERROR)) 2033 .WillOnce(Return(GL_NO_ERROR))
2099 .WillOnce(Return(GL_NO_ERROR)) 2034 .WillOnce(Return(GL_NO_ERROR))
2100 .RetiresOnSaturation(); 2035 .RetiresOnSaturation();
2101 GenerateMipmap cmd; 2036 GenerateMipmap cmd;
2102 cmd.Init(GL_TEXTURE_2D); 2037 cmd.Init(GL_TEXTURE_2D);
2103 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 2038 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
2104 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 2039 EXPECT_EQ(GL_NO_ERROR, GetGLError());
2105 } 2040 }
2106 2041
2107 TEST_P(GLES2DecoderWithShaderTest, Uniform1iValidArgs) { 2042 TEST_F(GLES2DecoderWithShaderTest, Uniform1iValidArgs) {
2108 EXPECT_CALL(*gl_, Uniform1i(kUniform1RealLocation, 2)); 2043 EXPECT_CALL(*gl_, Uniform1i(kUniform1RealLocation, 2));
2109 Uniform1i cmd; 2044 Uniform1i cmd;
2110 cmd.Init(kUniform1FakeLocation, 2); 2045 cmd.Init(kUniform1FakeLocation, 2);
2111 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 2046 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
2112 } 2047 }
2113 2048
2114 TEST_P(GLES2DecoderWithShaderTest, Uniform1ivValidArgs) { 2049 TEST_F(GLES2DecoderWithShaderTest, Uniform1ivValidArgs) {
2115 EXPECT_CALL( 2050 EXPECT_CALL(
2116 *gl_, Uniform1iv(kUniform1RealLocation, 1, 2051 *gl_, Uniform1iv(kUniform1RealLocation, 1,
2117 reinterpret_cast<const GLint*>(shared_memory_address_))); 2052 reinterpret_cast<const GLint*>(shared_memory_address_)));
2118 Uniform1iv cmd; 2053 Uniform1iv cmd;
2119 cmd.Init(kUniform1FakeLocation, 2054 cmd.Init(kUniform1FakeLocation,
2120 1, shared_memory_id_, shared_memory_offset_); 2055 1, shared_memory_id_, shared_memory_offset_);
2121 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 2056 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
2122 } 2057 }
2123 2058
2124 TEST_P(GLES2DecoderWithShaderTest, Uniform1ivInvalidArgs2_0) { 2059 TEST_F(GLES2DecoderWithShaderTest, Uniform1ivInvalidArgs2_0) {
2125 EXPECT_CALL(*gl_, Uniform1iv(_, _, _)).Times(0); 2060 EXPECT_CALL(*gl_, Uniform1iv(_, _, _)).Times(0);
2126 Uniform1iv cmd; 2061 Uniform1iv cmd;
2127 cmd.Init(kUniform1FakeLocation, 2062 cmd.Init(kUniform1FakeLocation,
2128 1, kInvalidSharedMemoryId, 0); 2063 1, kInvalidSharedMemoryId, 0);
2129 EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); 2064 EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd));
2130 } 2065 }
2131 2066
2132 TEST_P(GLES2DecoderWithShaderTest, Uniform1ivInvalidArgs2_1) { 2067 TEST_F(GLES2DecoderWithShaderTest, Uniform1ivInvalidArgs2_1) {
2133 EXPECT_CALL(*gl_, Uniform1iv(_, _, _)).Times(0); 2068 EXPECT_CALL(*gl_, Uniform1iv(_, _, _)).Times(0);
2134 Uniform1iv cmd; 2069 Uniform1iv cmd;
2135 cmd.Init(kUniform1FakeLocation, 2070 cmd.Init(kUniform1FakeLocation,
2136 1, shared_memory_id_, kInvalidSharedMemoryOffset); 2071 1, shared_memory_id_, kInvalidSharedMemoryOffset);
2137 EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); 2072 EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd));
2138 } 2073 }
2139 2074
2140 TEST_P(GLES2DecoderWithShaderTest, Uniform1ivImmediateValidArgs) { 2075 TEST_F(GLES2DecoderWithShaderTest, Uniform1ivImmediateValidArgs) {
2141 Uniform1ivImmediate& cmd = *GetImmediateAs<Uniform1ivImmediate>(); 2076 Uniform1ivImmediate& cmd = *GetImmediateAs<Uniform1ivImmediate>();
2142 EXPECT_CALL( 2077 EXPECT_CALL(
2143 *gl_, 2078 *gl_,
2144 Uniform1iv(kUniform1RealLocation, 1, 2079 Uniform1iv(kUniform1RealLocation, 1,
2145 reinterpret_cast<GLint*>(ImmediateDataAddress(&cmd)))); 2080 reinterpret_cast<GLint*>(ImmediateDataAddress(&cmd))));
2146 GLint temp[1 * 2] = { 0, }; 2081 GLint temp[1 * 2] = { 0, };
2147 cmd.Init(kUniform1FakeLocation, 1, 2082 cmd.Init(kUniform1FakeLocation, 1,
2148 &temp[0]); 2083 &temp[0]);
2149 EXPECT_EQ(error::kNoError, 2084 EXPECT_EQ(error::kNoError,
2150 ExecuteImmediateCmd(cmd, sizeof(temp))); 2085 ExecuteImmediateCmd(cmd, sizeof(temp)));
2151 } 2086 }
2152 2087
2153 TEST_P(GLES2DecoderWithShaderTest, Uniform1ivInvalidValidArgs) { 2088 TEST_F(GLES2DecoderWithShaderTest, Uniform1ivInvalidValidArgs) {
2154 EXPECT_CALL(*gl_, Uniform1iv(_, _, _)).Times(0); 2089 EXPECT_CALL(*gl_, Uniform1iv(_, _, _)).Times(0);
2155 Uniform1iv cmd; 2090 Uniform1iv cmd;
2156 cmd.Init(kUniform1FakeLocation, 2091 cmd.Init(kUniform1FakeLocation,
2157 2, shared_memory_id_, shared_memory_offset_); 2092 2, shared_memory_id_, shared_memory_offset_);
2158 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 2093 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
2159 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); 2094 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
2160 } 2095 }
2161 2096
2162 TEST_P(GLES2DecoderWithShaderTest, Uniform1ivZeroCount) { 2097 TEST_F(GLES2DecoderWithShaderTest, Uniform1ivZeroCount) {
2163 EXPECT_CALL(*gl_, Uniform1iv(_, _, _)).Times(0); 2098 EXPECT_CALL(*gl_, Uniform1iv(_, _, _)).Times(0);
2164 Uniform1iv cmd; 2099 Uniform1iv cmd;
2165 cmd.Init(kUniform1FakeLocation, 2100 cmd.Init(kUniform1FakeLocation,
2166 0, shared_memory_id_, shared_memory_offset_); 2101 0, shared_memory_id_, shared_memory_offset_);
2167 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 2102 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
2168 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 2103 EXPECT_EQ(GL_NO_ERROR, GetGLError());
2169 } 2104 }
2170 2105
2171 TEST_P(GLES2DecoderWithShaderTest, Uniform1iSamplerIsLmited) { 2106 TEST_F(GLES2DecoderWithShaderTest, Uniform1iSamplerIsLmited) {
2172 EXPECT_CALL(*gl_, Uniform1i(_, _)).Times(0); 2107 EXPECT_CALL(*gl_, Uniform1i(_, _)).Times(0);
2173 Uniform1i cmd; 2108 Uniform1i cmd;
2174 cmd.Init( 2109 cmd.Init(
2175 kUniform1FakeLocation, 2110 kUniform1FakeLocation,
2176 kNumTextureUnits); 2111 kNumTextureUnits);
2177 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 2112 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
2178 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); 2113 EXPECT_EQ(GL_INVALID_VALUE, GetGLError());
2179 } 2114 }
2180 2115
2181 TEST_P(GLES2DecoderWithShaderTest, Uniform1ivSamplerIsLimited) { 2116 TEST_F(GLES2DecoderWithShaderTest, Uniform1ivSamplerIsLimited) {
2182 EXPECT_CALL(*gl_, Uniform1iv(_, _, _)).Times(0); 2117 EXPECT_CALL(*gl_, Uniform1iv(_, _, _)).Times(0);
2183 Uniform1ivImmediate& cmd = *GetImmediateAs<Uniform1ivImmediate>(); 2118 Uniform1ivImmediate& cmd = *GetImmediateAs<Uniform1ivImmediate>();
2184 GLint temp[] = { kNumTextureUnits }; 2119 GLint temp[] = { kNumTextureUnits };
2185 cmd.Init(kUniform1FakeLocation, 1, 2120 cmd.Init(kUniform1FakeLocation, 1,
2186 &temp[0]); 2121 &temp[0]);
2187 EXPECT_EQ(error::kNoError, 2122 EXPECT_EQ(error::kNoError,
2188 ExecuteImmediateCmd(cmd, sizeof(temp))); 2123 ExecuteImmediateCmd(cmd, sizeof(temp)));
2189 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); 2124 EXPECT_EQ(GL_INVALID_VALUE, GetGLError());
2190 } 2125 }
2191 2126
2192 TEST_P(GLES2DecoderWithShaderTest, BindBufferToDifferentTargetFails) { 2127 TEST_F(GLES2DecoderWithShaderTest, BindBufferToDifferentTargetFails) {
2193 // Bind the buffer to GL_ARRAY_BUFFER 2128 // Bind the buffer to GL_ARRAY_BUFFER
2194 DoBindBuffer(GL_ARRAY_BUFFER, client_buffer_id_, kServiceBufferId); 2129 DoBindBuffer(GL_ARRAY_BUFFER, client_buffer_id_, kServiceBufferId);
2195 // Attempt to rebind to GL_ELEMENT_ARRAY_BUFFER 2130 // Attempt to rebind to GL_ELEMENT_ARRAY_BUFFER
2196 // NOTE: Real GLES2 does not have this restriction but WebGL and we do. 2131 // NOTE: Real GLES2 does not have this restriction but WebGL and we do.
2197 // This can be restriction can be removed at runtime. 2132 // This can be restriction can be removed at runtime.
2198 EXPECT_CALL(*gl_, BindBuffer(_, _)) 2133 EXPECT_CALL(*gl_, BindBuffer(_, _))
2199 .Times(0); 2134 .Times(0);
2200 BindBuffer cmd; 2135 BindBuffer cmd;
2201 cmd.Init(GL_ELEMENT_ARRAY_BUFFER, client_buffer_id_); 2136 cmd.Init(GL_ELEMENT_ARRAY_BUFFER, client_buffer_id_);
2202 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 2137 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
2203 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); 2138 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
2204 } 2139 }
2205 2140
2206 TEST_P(GLES2DecoderTest, ActiveTextureValidArgs) { 2141 TEST_F(GLES2DecoderTest, ActiveTextureValidArgs) {
2207 EXPECT_CALL(*gl_, ActiveTexture(GL_TEXTURE1)); 2142 EXPECT_CALL(*gl_, ActiveTexture(GL_TEXTURE1));
2208 SpecializedSetup<ActiveTexture, 0>(true); 2143 SpecializedSetup<ActiveTexture, 0>(true);
2209 ActiveTexture cmd; 2144 ActiveTexture cmd;
2210 cmd.Init(GL_TEXTURE1); 2145 cmd.Init(GL_TEXTURE1);
2211 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 2146 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
2212 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 2147 EXPECT_EQ(GL_NO_ERROR, GetGLError());
2213 } 2148 }
2214 2149
2215 TEST_P(GLES2DecoderTest, ActiveTextureInvalidArgs) { 2150 TEST_F(GLES2DecoderTest, ActiveTextureInvalidArgs) {
2216 EXPECT_CALL(*gl_, ActiveTexture(_)).Times(0); 2151 EXPECT_CALL(*gl_, ActiveTexture(_)).Times(0);
2217 SpecializedSetup<ActiveTexture, 0>(false); 2152 SpecializedSetup<ActiveTexture, 0>(false);
2218 ActiveTexture cmd; 2153 ActiveTexture cmd;
2219 cmd.Init(GL_TEXTURE0 - 1); 2154 cmd.Init(GL_TEXTURE0 - 1);
2220 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 2155 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
2221 EXPECT_EQ(GL_INVALID_ENUM, GetGLError()); 2156 EXPECT_EQ(GL_INVALID_ENUM, GetGLError());
2222 cmd.Init(kNumTextureUnits); 2157 cmd.Init(kNumTextureUnits);
2223 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 2158 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
2224 EXPECT_EQ(GL_INVALID_ENUM, GetGLError()); 2159 EXPECT_EQ(GL_INVALID_ENUM, GetGLError());
2225 } 2160 }
2226 2161
2227 TEST_P(GLES2DecoderTest, CheckFramebufferStatusWithNoBoundTarget) { 2162 TEST_F(GLES2DecoderTest, CheckFramebufferStatusWithNoBoundTarget) {
2228 EXPECT_CALL(*gl_, CheckFramebufferStatusEXT(_)) 2163 EXPECT_CALL(*gl_, CheckFramebufferStatusEXT(_))
2229 .Times(0); 2164 .Times(0);
2230 CheckFramebufferStatus::Result* result = 2165 CheckFramebufferStatus::Result* result =
2231 static_cast<CheckFramebufferStatus::Result*>(shared_memory_address_); 2166 static_cast<CheckFramebufferStatus::Result*>(shared_memory_address_);
2232 *result = 0; 2167 *result = 0;
2233 CheckFramebufferStatus cmd; 2168 CheckFramebufferStatus cmd;
2234 cmd.Init(GL_FRAMEBUFFER, shared_memory_id_, shared_memory_offset_); 2169 cmd.Init(GL_FRAMEBUFFER, shared_memory_id_, shared_memory_offset_);
2235 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 2170 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
2236 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE), *result); 2171 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE), *result);
2237 } 2172 }
2238 2173
2239 TEST_P(GLES2DecoderWithShaderTest, BindAndDeleteFramebuffer) { 2174 TEST_F(GLES2DecoderWithShaderTest, BindAndDeleteFramebuffer) {
2240 SetupTexture(); 2175 SetupTexture();
2241 AddExpectationsForSimulatedAttrib0(kNumVertices, 0); 2176 AddExpectationsForSimulatedAttrib0(kNumVertices, 0);
2242 SetupExpectationsForApplyingDefaultDirtyState(); 2177 SetupExpectationsForApplyingDefaultDirtyState();
2243 DoBindFramebuffer(GL_FRAMEBUFFER, client_framebuffer_id_, 2178 DoBindFramebuffer(GL_FRAMEBUFFER, client_framebuffer_id_,
2244 kServiceFramebufferId); 2179 kServiceFramebufferId);
2245 DoDeleteFramebuffer( 2180 DoDeleteFramebuffer(
2246 client_framebuffer_id_, kServiceFramebufferId, 2181 client_framebuffer_id_, kServiceFramebufferId,
2247 true, GL_FRAMEBUFFER, 0, 2182 true, GL_FRAMEBUFFER, 0,
2248 true, GL_FRAMEBUFFER, 0); 2183 true, GL_FRAMEBUFFER, 0);
2249 EXPECT_CALL(*gl_, DrawArrays(GL_TRIANGLES, 0, kNumVertices)) 2184 EXPECT_CALL(*gl_, DrawArrays(GL_TRIANGLES, 0, kNumVertices))
2250 .Times(1) 2185 .Times(1)
2251 .RetiresOnSaturation(); 2186 .RetiresOnSaturation();
2252 DrawArrays cmd; 2187 DrawArrays cmd;
2253 cmd.Init(GL_TRIANGLES, 0, kNumVertices); 2188 cmd.Init(GL_TRIANGLES, 0, kNumVertices);
2254 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 2189 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
2255 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 2190 EXPECT_EQ(GL_NO_ERROR, GetGLError());
2256 } 2191 }
2257 2192
2258 TEST_P(GLES2DecoderTest, FramebufferRenderbufferWithNoBoundTarget) { 2193 TEST_F(GLES2DecoderTest, FramebufferRenderbufferWithNoBoundTarget) {
2259 EXPECT_CALL(*gl_, FramebufferRenderbufferEXT(_, _, _, _)) 2194 EXPECT_CALL(*gl_, FramebufferRenderbufferEXT(_, _, _, _))
2260 .Times(0); 2195 .Times(0);
2261 FramebufferRenderbuffer cmd; 2196 FramebufferRenderbuffer cmd;
2262 cmd.Init( 2197 cmd.Init(
2263 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, 2198 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER,
2264 client_renderbuffer_id_); 2199 client_renderbuffer_id_);
2265 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 2200 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
2266 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); 2201 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
2267 } 2202 }
2268 2203
2269 TEST_P(GLES2DecoderTest, FramebufferTexture2DWithNoBoundTarget) { 2204 TEST_F(GLES2DecoderTest, FramebufferTexture2DWithNoBoundTarget) {
2270 EXPECT_CALL(*gl_, FramebufferTexture2DEXT(_, _, _, _, _)) 2205 EXPECT_CALL(*gl_, FramebufferTexture2DEXT(_, _, _, _, _))
2271 .Times(0); 2206 .Times(0);
2272 FramebufferTexture2D cmd; 2207 FramebufferTexture2D cmd;
2273 cmd.Init( 2208 cmd.Init(
2274 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, client_texture_id_, 2209 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, client_texture_id_,
2275 0); 2210 0);
2276 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 2211 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
2277 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); 2212 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
2278 } 2213 }
2279 2214
2280 TEST_P(GLES2DecoderTest, GetFramebufferAttachmentParameterivWithNoBoundTarget) { 2215 TEST_F(GLES2DecoderTest, GetFramebufferAttachmentParameterivWithNoBoundTarget) {
2281 EXPECT_CALL(*gl_, GetError()) 2216 EXPECT_CALL(*gl_, GetError())
2282 .WillOnce(Return(GL_NO_ERROR)) 2217 .WillOnce(Return(GL_NO_ERROR))
2283 .WillOnce(Return(GL_NO_ERROR)) 2218 .WillOnce(Return(GL_NO_ERROR))
2284 .RetiresOnSaturation(); 2219 .RetiresOnSaturation();
2285 EXPECT_CALL(*gl_, GetFramebufferAttachmentParameterivEXT(_, _, _, _)) 2220 EXPECT_CALL(*gl_, GetFramebufferAttachmentParameterivEXT(_, _, _, _))
2286 .Times(0); 2221 .Times(0);
2287 GetFramebufferAttachmentParameteriv cmd; 2222 GetFramebufferAttachmentParameteriv cmd;
2288 cmd.Init( 2223 cmd.Init(
2289 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, 2224 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
2290 GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, shared_memory_id_, 2225 GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, shared_memory_id_,
2291 shared_memory_offset_); 2226 shared_memory_offset_);
2292 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 2227 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
2293 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); 2228 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
2294 } 2229 }
2295 2230
2296 TEST_P(GLES2DecoderTest, GetFramebufferAttachmentParameterivWithRenderbuffer) { 2231 TEST_F(GLES2DecoderTest, GetFramebufferAttachmentParameterivWithRenderbuffer) {
2297 DoBindFramebuffer(GL_FRAMEBUFFER, client_framebuffer_id_, 2232 DoBindFramebuffer(GL_FRAMEBUFFER, client_framebuffer_id_,
2298 kServiceFramebufferId); 2233 kServiceFramebufferId);
2299 EXPECT_CALL(*gl_, GetError()) 2234 EXPECT_CALL(*gl_, GetError())
2300 .WillOnce(Return(GL_NO_ERROR)) 2235 .WillOnce(Return(GL_NO_ERROR))
2301 .RetiresOnSaturation(); 2236 .RetiresOnSaturation();
2302 EXPECT_CALL(*gl_, FramebufferRenderbufferEXT( 2237 EXPECT_CALL(*gl_, FramebufferRenderbufferEXT(
2303 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, 2238 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER,
2304 kServiceRenderbufferId)) 2239 kServiceRenderbufferId))
2305 .Times(1) 2240 .Times(1)
2306 .RetiresOnSaturation(); 2241 .RetiresOnSaturation();
(...skipping 17 matching lines...) Expand all
2324 cmd.Init( 2259 cmd.Init(
2325 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, 2260 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
2326 GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, shared_memory_id_, 2261 GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, shared_memory_id_,
2327 shared_memory_offset_); 2262 shared_memory_offset_);
2328 EXPECT_EQ(error::kNoError, ExecuteCmd(fbrb_cmd)); 2263 EXPECT_EQ(error::kNoError, ExecuteCmd(fbrb_cmd));
2329 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 2264 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
2330 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 2265 EXPECT_EQ(GL_NO_ERROR, GetGLError());
2331 EXPECT_EQ(static_cast<GLuint>(*result_value), client_renderbuffer_id_); 2266 EXPECT_EQ(static_cast<GLuint>(*result_value), client_renderbuffer_id_);
2332 } 2267 }
2333 2268
2334 TEST_P(GLES2DecoderTest, GetFramebufferAttachmentParameterivWithTexture) { 2269 TEST_F(GLES2DecoderTest, GetFramebufferAttachmentParameterivWithTexture) {
2335 DoBindFramebuffer(GL_FRAMEBUFFER, client_framebuffer_id_, 2270 DoBindFramebuffer(GL_FRAMEBUFFER, client_framebuffer_id_,
2336 kServiceFramebufferId); 2271 kServiceFramebufferId);
2337 EXPECT_CALL(*gl_, GetError()) 2272 EXPECT_CALL(*gl_, GetError())
2338 .WillOnce(Return(GL_NO_ERROR)) 2273 .WillOnce(Return(GL_NO_ERROR))
2339 .RetiresOnSaturation(); 2274 .RetiresOnSaturation();
2340 EXPECT_CALL(*gl_, FramebufferTexture2DEXT( 2275 EXPECT_CALL(*gl_, FramebufferTexture2DEXT(
2341 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 2276 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
2342 kServiceTextureId, 0)) 2277 kServiceTextureId, 0))
2343 .Times(1) 2278 .Times(1)
2344 .RetiresOnSaturation(); 2279 .RetiresOnSaturation();
(...skipping 17 matching lines...) Expand all
2362 cmd.Init( 2297 cmd.Init(
2363 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, 2298 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
2364 GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, shared_memory_id_, 2299 GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, shared_memory_id_,
2365 shared_memory_offset_); 2300 shared_memory_offset_);
2366 EXPECT_EQ(error::kNoError, ExecuteCmd(fbtex_cmd)); 2301 EXPECT_EQ(error::kNoError, ExecuteCmd(fbtex_cmd));
2367 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 2302 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
2368 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 2303 EXPECT_EQ(GL_NO_ERROR, GetGLError());
2369 EXPECT_EQ(static_cast<GLuint>(*result_value), client_texture_id_); 2304 EXPECT_EQ(static_cast<GLuint>(*result_value), client_texture_id_);
2370 } 2305 }
2371 2306
2372 TEST_P(GLES2DecoderTest, GetRenderbufferParameterivWithNoBoundTarget) { 2307 TEST_F(GLES2DecoderTest, GetRenderbufferParameterivWithNoBoundTarget) {
2373 EXPECT_CALL(*gl_, GetError()) 2308 EXPECT_CALL(*gl_, GetError())
2374 .WillOnce(Return(GL_NO_ERROR)) 2309 .WillOnce(Return(GL_NO_ERROR))
2375 .WillOnce(Return(GL_NO_ERROR)) 2310 .WillOnce(Return(GL_NO_ERROR))
2376 .RetiresOnSaturation(); 2311 .RetiresOnSaturation();
2377 EXPECT_CALL(*gl_, GetRenderbufferParameterivEXT(_, _, _)) 2312 EXPECT_CALL(*gl_, GetRenderbufferParameterivEXT(_, _, _))
2378 .Times(0); 2313 .Times(0);
2379 GetRenderbufferParameteriv cmd; 2314 GetRenderbufferParameteriv cmd;
2380 cmd.Init( 2315 cmd.Init(
2381 GL_RENDERBUFFER, GL_RENDERBUFFER_WIDTH, shared_memory_id_, 2316 GL_RENDERBUFFER, GL_RENDERBUFFER_WIDTH, shared_memory_id_,
2382 shared_memory_offset_); 2317 shared_memory_offset_);
2383 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 2318 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
2384 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); 2319 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
2385 } 2320 }
2386 2321
2387 TEST_P(GLES2DecoderTest, RenderbufferStorageWithNoBoundTarget) { 2322 TEST_F(GLES2DecoderTest, RenderbufferStorageWithNoBoundTarget) {
2388 EXPECT_CALL(*gl_, RenderbufferStorageEXT(_, _, _, _)) 2323 EXPECT_CALL(*gl_, RenderbufferStorageEXT(_, _, _, _))
2389 .Times(0); 2324 .Times(0);
2390 RenderbufferStorage cmd; 2325 RenderbufferStorage cmd;
2391 cmd.Init(GL_RENDERBUFFER, GL_RGBA4, 3, 4); 2326 cmd.Init(GL_RENDERBUFFER, GL_RGBA4, 3, 4);
2392 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 2327 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
2393 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); 2328 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
2394 } 2329 }
2395 2330
2396 namespace { 2331 namespace {
2397 2332
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
2577 // check padding 2512 // check padding
2578 if (yy != in_read_height - 1) { 2513 if (yy != in_read_height - 1) {
2579 GLint num_padding_bytes = 2514 GLint num_padding_bytes =
2580 (kPackAlignment - 1) - (unpadded_row_size % kPackAlignment); 2515 (kPackAlignment - 1) - (unpadded_row_size % kPackAlignment);
2581 EXPECT_EQ(0, 2516 EXPECT_EQ(0,
2582 memcmp(pack.get(), row + unpadded_row_size, num_padding_bytes)); 2517 memcmp(pack.get(), row + unpadded_row_size, num_padding_bytes));
2583 } 2518 }
2584 } 2519 }
2585 } 2520 }
2586 2521
2587 TEST_P(GLES2DecoderTest, ReadPixels) { 2522 TEST_F(GLES2DecoderTest, ReadPixels) {
2588 const GLsizei kWidth = 5; 2523 const GLsizei kWidth = 5;
2589 const GLsizei kHeight = 3; 2524 const GLsizei kHeight = 3;
2590 const GLint kBytesPerPixel = 3; 2525 const GLint kBytesPerPixel = 3;
2591 const GLint kPackAlignment = 4; 2526 const GLint kPackAlignment = 4;
2592 static const int8 kSrcPixels[kWidth * kHeight * kBytesPerPixel] = { 2527 static const int8 kSrcPixels[kWidth * kHeight * kBytesPerPixel] = {
2593 12, 13, 14, 18, 19, 18, 19, 12, 13, 14, 18, 19, 18, 19, 13, 2528 12, 13, 14, 18, 19, 18, 19, 12, 13, 14, 18, 19, 18, 19, 13,
2594 29, 28, 23, 22, 21, 22, 21, 29, 28, 23, 22, 21, 22, 21, 28, 2529 29, 28, 23, 22, 21, 22, 21, 29, 28, 23, 22, 21, 22, 21, 28,
2595 31, 34, 39, 37, 32, 37, 32, 31, 34, 39, 37, 32, 37, 32, 34, 2530 31, 34, 39, 37, 32, 37, 32, 31, 34, 39, 37, 32, 37, 32, 34,
2596 }; 2531 };
2597 2532
(...skipping 21 matching lines...) Expand all
2619 result_shm_id, result_shm_offset, 2554 result_shm_id, result_shm_offset,
2620 false); 2555 false);
2621 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 2556 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
2622 for (GLint yy = 0; yy < kHeight; ++yy) { 2557 for (GLint yy = 0; yy < kHeight; ++yy) {
2623 EXPECT_TRUE(emu.CompareRowSegment( 2558 EXPECT_TRUE(emu.CompareRowSegment(
2624 0, yy, kWidth, 2559 0, yy, kWidth,
2625 emu.ComputePackAlignmentAddress(0, yy, kWidth, dest))); 2560 emu.ComputePackAlignmentAddress(0, yy, kWidth, dest)));
2626 } 2561 }
2627 } 2562 }
2628 2563
2629 TEST_P(GLES2DecoderRGBBackbufferTest, ReadPixelsNoAlphaBackbuffer) { 2564 TEST_F(GLES2DecoderRGBBackbufferTest, ReadPixelsNoAlphaBackbuffer) {
2630 const GLsizei kWidth = 3; 2565 const GLsizei kWidth = 3;
2631 const GLsizei kHeight = 3; 2566 const GLsizei kHeight = 3;
2632 const GLint kBytesPerPixel = 4; 2567 const GLint kBytesPerPixel = 4;
2633 const GLint kPackAlignment = 4; 2568 const GLint kPackAlignment = 4;
2634 static const uint8 kExpectedPixels[kWidth * kHeight * kBytesPerPixel] = { 2569 static const uint8 kExpectedPixels[kWidth * kHeight * kBytesPerPixel] = {
2635 12, 13, 14, 255, 19, 18, 19, 255, 13, 14, 18, 255, 2570 12, 13, 14, 255, 19, 18, 19, 255, 13, 14, 18, 255,
2636 29, 28, 23, 255, 21, 22, 21, 255, 28, 23, 22, 255, 2571 29, 28, 23, 255, 21, 22, 21, 255, 28, 23, 22, 255,
2637 31, 34, 39, 255, 32, 37, 32, 255, 34, 39, 37, 255, 2572 31, 34, 39, 255, 32, 37, 32, 255, 34, 39, 37, 255,
2638 }; 2573 };
2639 static const uint8 kSrcPixels[kWidth * kHeight * kBytesPerPixel] = { 2574 static const uint8 kSrcPixels[kWidth * kHeight * kBytesPerPixel] = {
(...skipping 27 matching lines...) Expand all
2667 result_shm_id, result_shm_offset, 2602 result_shm_id, result_shm_offset,
2668 false); 2603 false);
2669 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 2604 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
2670 for (GLint yy = 0; yy < kHeight; ++yy) { 2605 for (GLint yy = 0; yy < kHeight; ++yy) {
2671 EXPECT_TRUE(emu.CompareRowSegment( 2606 EXPECT_TRUE(emu.CompareRowSegment(
2672 0, yy, kWidth, 2607 0, yy, kWidth,
2673 emu.ComputePackAlignmentAddress(0, yy, kWidth, dest))); 2608 emu.ComputePackAlignmentAddress(0, yy, kWidth, dest)));
2674 } 2609 }
2675 } 2610 }
2676 2611
2677 TEST_P(GLES2DecoderTest, ReadPixelsOutOfRange) { 2612 TEST_F(GLES2DecoderTest, ReadPixelsOutOfRange) {
2678 static GLint tests[][4] = { 2613 static GLint tests[][4] = {
2679 { -2, -1, 9, 5, }, // out of range on all sides 2614 { -2, -1, 9, 5, }, // out of range on all sides
2680 { 2, 1, 9, 5, }, // out of range on right, bottom 2615 { 2, 1, 9, 5, }, // out of range on right, bottom
2681 { -7, -4, 9, 5, }, // out of range on left, top 2616 { -7, -4, 9, 5, }, // out of range on left, top
2682 { 0, -5, 9, 5, }, // completely off top 2617 { 0, -5, 9, 5, }, // completely off top
2683 { 0, 3, 9, 5, }, // completely off bottom 2618 { 0, 3, 9, 5, }, // completely off bottom
2684 { -9, 0, 9, 5, }, // completely off left 2619 { -9, 0, 9, 5, }, // completely off left
2685 { 5, 0, 9, 5, }, // completely off right 2620 { 5, 0, 9, 5, }, // completely off right
2686 }; 2621 };
2687 2622
2688 for (size_t tt = 0; tt < arraysize(tests); ++tt) { 2623 for (size_t tt = 0; tt < arraysize(tests); ++tt) {
2689 CheckReadPixelsOutOfRange( 2624 CheckReadPixelsOutOfRange(
2690 tests[tt][0], tests[tt][1], tests[tt][2], tests[tt][3], tt == 0); 2625 tests[tt][0], tests[tt][1], tests[tt][2], tests[tt][3], tt == 0);
2691 } 2626 }
2692 } 2627 }
2693 2628
2694 TEST_P(GLES2DecoderTest, ReadPixelsInvalidArgs) { 2629 TEST_F(GLES2DecoderTest, ReadPixelsInvalidArgs) {
2695 typedef ReadPixels::Result Result; 2630 typedef ReadPixels::Result Result;
2696 Result* result = GetSharedMemoryAs<Result*>(); 2631 Result* result = GetSharedMemoryAs<Result*>();
2697 uint32 result_shm_id = kSharedMemoryId; 2632 uint32 result_shm_id = kSharedMemoryId;
2698 uint32 result_shm_offset = kSharedMemoryOffset; 2633 uint32 result_shm_offset = kSharedMemoryOffset;
2699 uint32 pixels_shm_id = kSharedMemoryId; 2634 uint32 pixels_shm_id = kSharedMemoryId;
2700 uint32 pixels_shm_offset = kSharedMemoryOffset + sizeof(*result); 2635 uint32 pixels_shm_offset = kSharedMemoryOffset + sizeof(*result);
2701 EXPECT_CALL(*gl_, ReadPixels(_, _, _, _, _, _, _)).Times(0); 2636 EXPECT_CALL(*gl_, ReadPixels(_, _, _, _, _, _, _)).Times(0);
2702 ReadPixels cmd; 2637 ReadPixels cmd;
2703 cmd.Init(0, 0, -1, 1, GL_RGB, GL_UNSIGNED_BYTE, 2638 cmd.Init(0, 0, -1, 1, GL_RGB, GL_UNSIGNED_BYTE,
2704 pixels_shm_id, pixels_shm_offset, 2639 pixels_shm_id, pixels_shm_offset,
(...skipping 28 matching lines...) Expand all
2733 kInvalidSharedMemoryId, result_shm_offset, 2668 kInvalidSharedMemoryId, result_shm_offset,
2734 false); 2669 false);
2735 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); 2670 EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
2736 cmd.Init(0, 0, 1, 1, GL_RGB, GL_UNSIGNED_BYTE, 2671 cmd.Init(0, 0, 1, 1, GL_RGB, GL_UNSIGNED_BYTE,
2737 pixels_shm_id, pixels_shm_offset, 2672 pixels_shm_id, pixels_shm_offset,
2738 result_shm_id, kInvalidSharedMemoryOffset, 2673 result_shm_id, kInvalidSharedMemoryOffset,
2739 false); 2674 false);
2740 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); 2675 EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
2741 } 2676 }
2742 2677
2743 TEST_P(GLES2DecoderManualInitTest, ReadPixelsAsyncError) { 2678 TEST_F(GLES2DecoderManualInitTest, ReadPixelsAsyncError) {
2744 InitState init; 2679 InitState init;
2745 init.extensions = "GL_ARB_sync"; 2680 init.extensions = "GL_ARB_sync";
2746 init.gl_version = "opengl es 3.0"; 2681 init.gl_version = "opengl es 3.0";
2747 init.has_alpha = true; 2682 init.has_alpha = true;
2748 init.request_alpha = true; 2683 init.request_alpha = true;
2749 init.bind_generates_resource = true; 2684 init.bind_generates_resource = true;
2750 InitDecoder(init); 2685 InitDecoder(init);
2751 2686
2752 typedef ReadPixels::Result Result; 2687 typedef ReadPixels::Result Result;
2753 Result* result = GetSharedMemoryAs<Result*>(); 2688 Result* result = GetSharedMemoryAs<Result*>();
(...skipping 22 matching lines...) Expand all
2776 GL_STREAM_READ)).Times(1); 2711 GL_STREAM_READ)).Times(1);
2777 2712
2778 ReadPixels cmd; 2713 ReadPixels cmd;
2779 cmd.Init(0, 0, kWidth, kHeight, GL_RGB, GL_UNSIGNED_BYTE, 2714 cmd.Init(0, 0, kWidth, kHeight, GL_RGB, GL_UNSIGNED_BYTE,
2780 pixels_shm_id, pixels_shm_offset, 2715 pixels_shm_id, pixels_shm_offset,
2781 result_shm_id, result_shm_offset, 2716 result_shm_id, result_shm_offset,
2782 true); 2717 true);
2783 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 2718 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
2784 } 2719 }
2785 2720
2786 TEST_P(GLES2DecoderTest, BindAttribLocation) { 2721 TEST_F(GLES2DecoderTest, BindAttribLocation) {
2787 const GLint kLocation = 2; 2722 const GLint kLocation = 2;
2788 const char* kName = "testing"; 2723 const char* kName = "testing";
2789 const uint32 kNameSize = strlen(kName); 2724 const uint32 kNameSize = strlen(kName);
2790 EXPECT_CALL( 2725 EXPECT_CALL(
2791 *gl_, BindAttribLocation(kServiceProgramId, kLocation, StrEq(kName))) 2726 *gl_, BindAttribLocation(kServiceProgramId, kLocation, StrEq(kName)))
2792 .Times(1); 2727 .Times(1);
2793 memcpy(shared_memory_address_, kName, kNameSize); 2728 memcpy(shared_memory_address_, kName, kNameSize);
2794 BindAttribLocation cmd; 2729 BindAttribLocation cmd;
2795 cmd.Init(client_program_id_, kLocation, kSharedMemoryId, kSharedMemoryOffset, 2730 cmd.Init(client_program_id_, kLocation, kSharedMemoryId, kSharedMemoryOffset,
2796 kNameSize); 2731 kNameSize);
2797 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 2732 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
2798 } 2733 }
2799 2734
2800 TEST_P(GLES2DecoderTest, BindAttribLocationInvalidArgs) { 2735 TEST_F(GLES2DecoderTest, BindAttribLocationInvalidArgs) {
2801 const GLint kLocation = 2; 2736 const GLint kLocation = 2;
2802 const char* kName = "testing"; 2737 const char* kName = "testing";
2803 const char* kBadName = "test\aing"; 2738 const char* kBadName = "test\aing";
2804 const uint32 kNameSize = strlen(kName); 2739 const uint32 kNameSize = strlen(kName);
2805 const uint32 kBadNameSize = strlen(kBadName); 2740 const uint32 kBadNameSize = strlen(kBadName);
2806 EXPECT_CALL(*gl_, BindAttribLocation(_, _, _)).Times(0); 2741 EXPECT_CALL(*gl_, BindAttribLocation(_, _, _)).Times(0);
2807 memcpy(shared_memory_address_, kName, kNameSize); 2742 memcpy(shared_memory_address_, kName, kNameSize);
2808 BindAttribLocation cmd; 2743 BindAttribLocation cmd;
2809 cmd.Init(kInvalidClientId, kLocation, 2744 cmd.Init(kInvalidClientId, kLocation,
2810 kSharedMemoryId, kSharedMemoryOffset, kNameSize); 2745 kSharedMemoryId, kSharedMemoryOffset, kNameSize);
2811 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 2746 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
2812 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); 2747 EXPECT_EQ(GL_INVALID_VALUE, GetGLError());
2813 cmd.Init(client_program_id_, kLocation, 2748 cmd.Init(client_program_id_, kLocation,
2814 kInvalidSharedMemoryId, kSharedMemoryOffset, kNameSize); 2749 kInvalidSharedMemoryId, kSharedMemoryOffset, kNameSize);
2815 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); 2750 EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
2816 cmd.Init(client_program_id_, kLocation, 2751 cmd.Init(client_program_id_, kLocation,
2817 kSharedMemoryId, kInvalidSharedMemoryOffset, kNameSize); 2752 kSharedMemoryId, kInvalidSharedMemoryOffset, kNameSize);
2818 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); 2753 EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
2819 cmd.Init(client_program_id_, kLocation, 2754 cmd.Init(client_program_id_, kLocation,
2820 kSharedMemoryId, kSharedMemoryOffset, kSharedBufferSize); 2755 kSharedMemoryId, kSharedMemoryOffset, kSharedBufferSize);
2821 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); 2756 EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
2822 memcpy(shared_memory_address_, kBadName, kBadNameSize); 2757 memcpy(shared_memory_address_, kBadName, kBadNameSize);
2823 cmd.Init(client_program_id_, kLocation, 2758 cmd.Init(client_program_id_, kLocation,
2824 kSharedMemoryId, kSharedMemoryOffset, kBadNameSize); 2759 kSharedMemoryId, kSharedMemoryOffset, kBadNameSize);
2825 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 2760 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
2826 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); 2761 EXPECT_EQ(GL_INVALID_VALUE, GetGLError());
2827 } 2762 }
2828 2763
2829 TEST_P(GLES2DecoderTest, BindAttribLocationBucket) { 2764 TEST_F(GLES2DecoderTest, BindAttribLocationBucket) {
2830 const uint32 kBucketId = 123; 2765 const uint32 kBucketId = 123;
2831 const GLint kLocation = 2; 2766 const GLint kLocation = 2;
2832 const char* kName = "testing"; 2767 const char* kName = "testing";
2833 EXPECT_CALL( 2768 EXPECT_CALL(
2834 *gl_, BindAttribLocation(kServiceProgramId, kLocation, StrEq(kName))) 2769 *gl_, BindAttribLocation(kServiceProgramId, kLocation, StrEq(kName)))
2835 .Times(1); 2770 .Times(1);
2836 SetBucketAsCString(kBucketId, kName); 2771 SetBucketAsCString(kBucketId, kName);
2837 BindAttribLocationBucket cmd; 2772 BindAttribLocationBucket cmd;
2838 cmd.Init(client_program_id_, kLocation, kBucketId); 2773 cmd.Init(client_program_id_, kLocation, kBucketId);
2839 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 2774 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
2840 } 2775 }
2841 2776
2842 TEST_P(GLES2DecoderTest, BindAttribLocationBucketInvalidArgs) { 2777 TEST_F(GLES2DecoderTest, BindAttribLocationBucketInvalidArgs) {
2843 const uint32 kBucketId = 123; 2778 const uint32 kBucketId = 123;
2844 const GLint kLocation = 2; 2779 const GLint kLocation = 2;
2845 const char* kName = "testing"; 2780 const char* kName = "testing";
2846 EXPECT_CALL(*gl_, BindAttribLocation(_, _, _)).Times(0); 2781 EXPECT_CALL(*gl_, BindAttribLocation(_, _, _)).Times(0);
2847 BindAttribLocationBucket cmd; 2782 BindAttribLocationBucket cmd;
2848 // check bucket does not exist. 2783 // check bucket does not exist.
2849 cmd.Init(client_program_id_, kLocation, kBucketId); 2784 cmd.Init(client_program_id_, kLocation, kBucketId);
2850 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); 2785 EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
2851 // check bucket is empty. 2786 // check bucket is empty.
2852 SetBucketAsCString(kBucketId, NULL); 2787 SetBucketAsCString(kBucketId, NULL);
2853 cmd.Init(client_program_id_, kLocation, kBucketId); 2788 cmd.Init(client_program_id_, kLocation, kBucketId);
2854 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); 2789 EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
2855 // Check bad program id 2790 // Check bad program id
2856 SetBucketAsCString(kBucketId, kName); 2791 SetBucketAsCString(kBucketId, kName);
2857 cmd.Init(kInvalidClientId, kLocation, kBucketId); 2792 cmd.Init(kInvalidClientId, kLocation, kBucketId);
2858 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 2793 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
2859 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); 2794 EXPECT_EQ(GL_INVALID_VALUE, GetGLError());
2860 } 2795 }
2861 2796
2862 TEST_P(GLES2DecoderWithShaderTest, GetAttribLocation) { 2797 TEST_F(GLES2DecoderWithShaderTest, GetAttribLocation) {
2863 const uint32 kNameSize = strlen(kAttrib2Name); 2798 const uint32 kNameSize = strlen(kAttrib2Name);
2864 const char* kNonExistentName = "foobar"; 2799 const char* kNonExistentName = "foobar";
2865 const uint32 kNonExistentNameSize = strlen(kNonExistentName); 2800 const uint32 kNonExistentNameSize = strlen(kNonExistentName);
2866 typedef GetAttribLocation::Result Result; 2801 typedef GetAttribLocation::Result Result;
2867 Result* result = GetSharedMemoryAs<Result*>(); 2802 Result* result = GetSharedMemoryAs<Result*>();
2868 *result = -1; 2803 *result = -1;
2869 char* name = GetSharedMemoryAsWithOffset<char*>(sizeof(*result)); 2804 char* name = GetSharedMemoryAsWithOffset<char*>(sizeof(*result));
2870 const uint32 kNameOffset = kSharedMemoryOffset + sizeof(*result); 2805 const uint32 kNameOffset = kSharedMemoryOffset + sizeof(*result);
2871 memcpy(name, kAttrib2Name, kNameSize); 2806 memcpy(name, kAttrib2Name, kNameSize);
2872 GetAttribLocation cmd; 2807 GetAttribLocation cmd;
2873 cmd.Init(client_program_id_, 2808 cmd.Init(client_program_id_,
2874 kSharedMemoryId, kNameOffset, 2809 kSharedMemoryId, kNameOffset,
2875 kSharedMemoryId, kSharedMemoryOffset, 2810 kSharedMemoryId, kSharedMemoryOffset,
2876 kNameSize); 2811 kNameSize);
2877 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 2812 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
2878 EXPECT_EQ(kAttrib2Location, *result); 2813 EXPECT_EQ(kAttrib2Location, *result);
2879 *result = -1; 2814 *result = -1;
2880 memcpy(name, kNonExistentName, kNonExistentNameSize); 2815 memcpy(name, kNonExistentName, kNonExistentNameSize);
2881 cmd.Init(client_program_id_, 2816 cmd.Init(client_program_id_,
2882 kSharedMemoryId, kNameOffset, 2817 kSharedMemoryId, kNameOffset,
2883 kSharedMemoryId, kSharedMemoryOffset, 2818 kSharedMemoryId, kSharedMemoryOffset,
2884 kNonExistentNameSize); 2819 kNonExistentNameSize);
2885 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 2820 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
2886 EXPECT_EQ(-1, *result); 2821 EXPECT_EQ(-1, *result);
2887 } 2822 }
2888 2823
2889 TEST_P(GLES2DecoderWithShaderTest, GetAttribLocationInvalidArgs) { 2824 TEST_F(GLES2DecoderWithShaderTest, GetAttribLocationInvalidArgs) {
2890 const uint32 kNameSize = strlen(kAttrib2Name); 2825 const uint32 kNameSize = strlen(kAttrib2Name);
2891 const char* kBadName = "foo\abar"; 2826 const char* kBadName = "foo\abar";
2892 const uint32 kBadNameSize = strlen(kBadName); 2827 const uint32 kBadNameSize = strlen(kBadName);
2893 typedef GetAttribLocation::Result Result; 2828 typedef GetAttribLocation::Result Result;
2894 Result* result = GetSharedMemoryAs<Result*>(); 2829 Result* result = GetSharedMemoryAs<Result*>();
2895 *result = -1; 2830 *result = -1;
2896 char* name = GetSharedMemoryAsWithOffset<char*>(sizeof(*result)); 2831 char* name = GetSharedMemoryAsWithOffset<char*>(sizeof(*result));
2897 const uint32 kNameOffset = kSharedMemoryOffset + sizeof(*result); 2832 const uint32 kNameOffset = kSharedMemoryOffset + sizeof(*result);
2898 memcpy(name, kAttrib2Name, kNameSize); 2833 memcpy(name, kAttrib2Name, kNameSize);
2899 GetAttribLocation cmd; 2834 GetAttribLocation cmd;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
2937 EXPECT_EQ(-1, *result); 2872 EXPECT_EQ(-1, *result);
2938 memcpy(name, kBadName, kBadNameSize); 2873 memcpy(name, kBadName, kBadNameSize);
2939 cmd.Init(client_program_id_, 2874 cmd.Init(client_program_id_,
2940 kSharedMemoryId, kNameOffset, 2875 kSharedMemoryId, kNameOffset,
2941 kSharedMemoryId, kSharedMemoryOffset, 2876 kSharedMemoryId, kSharedMemoryOffset,
2942 kBadNameSize); 2877 kBadNameSize);
2943 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 2878 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
2944 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); 2879 EXPECT_EQ(GL_INVALID_VALUE, GetGLError());
2945 } 2880 }
2946 2881
2947 TEST_P(GLES2DecoderWithShaderTest, GetAttribLocationBucket) { 2882 TEST_F(GLES2DecoderWithShaderTest, GetAttribLocationBucket) {
2948 const uint32 kBucketId = 123; 2883 const uint32 kBucketId = 123;
2949 const char* kNonExistentName = "foobar"; 2884 const char* kNonExistentName = "foobar";
2950 typedef GetAttribLocationBucket::Result Result; 2885 typedef GetAttribLocationBucket::Result Result;
2951 Result* result = GetSharedMemoryAs<Result*>(); 2886 Result* result = GetSharedMemoryAs<Result*>();
2952 SetBucketAsCString(kBucketId, kAttrib2Name); 2887 SetBucketAsCString(kBucketId, kAttrib2Name);
2953 *result = -1; 2888 *result = -1;
2954 GetAttribLocationBucket cmd; 2889 GetAttribLocationBucket cmd;
2955 cmd.Init(client_program_id_, kBucketId, 2890 cmd.Init(client_program_id_, kBucketId,
2956 kSharedMemoryId, kSharedMemoryOffset); 2891 kSharedMemoryId, kSharedMemoryOffset);
2957 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 2892 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
2958 EXPECT_EQ(kAttrib2Location, *result); 2893 EXPECT_EQ(kAttrib2Location, *result);
2959 SetBucketAsCString(kBucketId, kNonExistentName); 2894 SetBucketAsCString(kBucketId, kNonExistentName);
2960 *result = -1; 2895 *result = -1;
2961 cmd.Init(client_program_id_, kBucketId, 2896 cmd.Init(client_program_id_, kBucketId,
2962 kSharedMemoryId, kSharedMemoryOffset); 2897 kSharedMemoryId, kSharedMemoryOffset);
2963 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 2898 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
2964 EXPECT_EQ(-1, *result); 2899 EXPECT_EQ(-1, *result);
2965 } 2900 }
2966 2901
2967 TEST_P(GLES2DecoderWithShaderTest, GetAttribLocationBucketInvalidArgs) { 2902 TEST_F(GLES2DecoderWithShaderTest, GetAttribLocationBucketInvalidArgs) {
2968 const uint32 kBucketId = 123; 2903 const uint32 kBucketId = 123;
2969 typedef GetAttribLocationBucket::Result Result; 2904 typedef GetAttribLocationBucket::Result Result;
2970 Result* result = GetSharedMemoryAs<Result*>(); 2905 Result* result = GetSharedMemoryAs<Result*>();
2971 *result = -1; 2906 *result = -1;
2972 GetAttribLocationBucket cmd; 2907 GetAttribLocationBucket cmd;
2973 // Check no bucket 2908 // Check no bucket
2974 cmd.Init(client_program_id_, kBucketId, 2909 cmd.Init(client_program_id_, kBucketId,
2975 kSharedMemoryId, kSharedMemoryOffset); 2910 kSharedMemoryId, kSharedMemoryOffset);
2976 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); 2911 EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
2977 EXPECT_EQ(-1, *result); 2912 EXPECT_EQ(-1, *result);
2978 // Check bad program id. 2913 // Check bad program id.
2979 SetBucketAsCString(kBucketId, kAttrib2Name); 2914 SetBucketAsCString(kBucketId, kAttrib2Name);
2980 cmd.Init(kInvalidClientId, kBucketId, 2915 cmd.Init(kInvalidClientId, kBucketId,
2981 kSharedMemoryId, kSharedMemoryOffset); 2916 kSharedMemoryId, kSharedMemoryOffset);
2982 *result = -1; 2917 *result = -1;
2983 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 2918 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
2984 EXPECT_EQ(-1, *result); 2919 EXPECT_EQ(-1, *result);
2985 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); 2920 EXPECT_EQ(GL_INVALID_VALUE, GetGLError());
2986 // Check bad memory 2921 // Check bad memory
2987 cmd.Init(client_program_id_, kBucketId, 2922 cmd.Init(client_program_id_, kBucketId,
2988 kInvalidSharedMemoryId, kSharedMemoryOffset); 2923 kInvalidSharedMemoryId, kSharedMemoryOffset);
2989 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); 2924 EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
2990 cmd.Init(client_program_id_, kBucketId, 2925 cmd.Init(client_program_id_, kBucketId,
2991 kSharedMemoryId, kInvalidSharedMemoryOffset); 2926 kSharedMemoryId, kInvalidSharedMemoryOffset);
2992 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); 2927 EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
2993 } 2928 }
2994 2929
2995 TEST_P(GLES2DecoderWithShaderTest, GetUniformLocation) { 2930 TEST_F(GLES2DecoderWithShaderTest, GetUniformLocation) {
2996 const uint32 kNameSize = strlen(kUniform2Name); 2931 const uint32 kNameSize = strlen(kUniform2Name);
2997 const char* kNonExistentName = "foobar"; 2932 const char* kNonExistentName = "foobar";
2998 const uint32 kNonExistentNameSize = strlen(kNonExistentName); 2933 const uint32 kNonExistentNameSize = strlen(kNonExistentName);
2999 typedef GetUniformLocation::Result Result; 2934 typedef GetUniformLocation::Result Result;
3000 Result* result = GetSharedMemoryAs<Result*>(); 2935 Result* result = GetSharedMemoryAs<Result*>();
3001 *result = -1; 2936 *result = -1;
3002 char* name = GetSharedMemoryAsWithOffset<char*>(sizeof(*result)); 2937 char* name = GetSharedMemoryAsWithOffset<char*>(sizeof(*result));
3003 const uint32 kNameOffset = kSharedMemoryOffset + sizeof(*result); 2938 const uint32 kNameOffset = kSharedMemoryOffset + sizeof(*result);
3004 memcpy(name, kUniform2Name, kNameSize); 2939 memcpy(name, kUniform2Name, kNameSize);
3005 GetUniformLocation cmd; 2940 GetUniformLocation cmd;
3006 cmd.Init(client_program_id_, 2941 cmd.Init(client_program_id_,
3007 kSharedMemoryId, kNameOffset, 2942 kSharedMemoryId, kNameOffset,
3008 kSharedMemoryId, kSharedMemoryOffset, 2943 kSharedMemoryId, kSharedMemoryOffset,
3009 kNameSize); 2944 kNameSize);
3010 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 2945 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
3011 EXPECT_EQ(kUniform2FakeLocation, *result); 2946 EXPECT_EQ(kUniform2FakeLocation, *result);
3012 memcpy(name, kNonExistentName, kNonExistentNameSize); 2947 memcpy(name, kNonExistentName, kNonExistentNameSize);
3013 *result = -1; 2948 *result = -1;
3014 cmd.Init(client_program_id_, 2949 cmd.Init(client_program_id_,
3015 kSharedMemoryId, kNameOffset, 2950 kSharedMemoryId, kNameOffset,
3016 kSharedMemoryId, kSharedMemoryOffset, 2951 kSharedMemoryId, kSharedMemoryOffset,
3017 kNonExistentNameSize); 2952 kNonExistentNameSize);
3018 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 2953 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
3019 EXPECT_EQ(-1, *result); 2954 EXPECT_EQ(-1, *result);
3020 } 2955 }
3021 2956
3022 TEST_P(GLES2DecoderWithShaderTest, GetUniformLocationInvalidArgs) { 2957 TEST_F(GLES2DecoderWithShaderTest, GetUniformLocationInvalidArgs) {
3023 const uint32 kNameSize = strlen(kUniform2Name); 2958 const uint32 kNameSize = strlen(kUniform2Name);
3024 const char* kBadName = "foo\abar"; 2959 const char* kBadName = "foo\abar";
3025 const uint32 kBadNameSize = strlen(kBadName); 2960 const uint32 kBadNameSize = strlen(kBadName);
3026 typedef GetUniformLocation::Result Result; 2961 typedef GetUniformLocation::Result Result;
3027 Result* result = GetSharedMemoryAs<Result*>(); 2962 Result* result = GetSharedMemoryAs<Result*>();
3028 *result = -1; 2963 *result = -1;
3029 char* name = GetSharedMemoryAsWithOffset<char*>(sizeof(*result)); 2964 char* name = GetSharedMemoryAsWithOffset<char*>(sizeof(*result));
3030 const uint32 kNameOffset = kSharedMemoryOffset + sizeof(*result); 2965 const uint32 kNameOffset = kSharedMemoryOffset + sizeof(*result);
3031 memcpy(name, kUniform2Name, kNameSize); 2966 memcpy(name, kUniform2Name, kNameSize);
3032 GetUniformLocation cmd; 2967 GetUniformLocation cmd;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
3070 EXPECT_EQ(-1, *result); 3005 EXPECT_EQ(-1, *result);
3071 memcpy(name, kBadName, kBadNameSize); 3006 memcpy(name, kBadName, kBadNameSize);
3072 cmd.Init(client_program_id_, 3007 cmd.Init(client_program_id_,
3073 kSharedMemoryId, kNameOffset, 3008 kSharedMemoryId, kNameOffset,
3074 kSharedMemoryId, kSharedMemoryOffset, 3009 kSharedMemoryId, kSharedMemoryOffset,
3075 kBadNameSize); 3010 kBadNameSize);
3076 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 3011 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
3077 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); 3012 EXPECT_EQ(GL_INVALID_VALUE, GetGLError());
3078 } 3013 }
3079 3014
3080 TEST_P(GLES2DecoderWithShaderTest, GetUniformLocationBucket) { 3015 TEST_F(GLES2DecoderWithShaderTest, GetUniformLocationBucket) {
3081 const uint32 kBucketId = 123; 3016 const uint32 kBucketId = 123;
3082 const char* kNonExistentName = "foobar"; 3017 const char* kNonExistentName = "foobar";
3083 typedef GetUniformLocationBucket::Result Result; 3018 typedef GetUniformLocationBucket::Result Result;
3084 Result* result = GetSharedMemoryAs<Result*>(); 3019 Result* result = GetSharedMemoryAs<Result*>();
3085 SetBucketAsCString(kBucketId, kUniform2Name); 3020 SetBucketAsCString(kBucketId, kUniform2Name);
3086 *result = -1; 3021 *result = -1;
3087 GetUniformLocationBucket cmd; 3022 GetUniformLocationBucket cmd;
3088 cmd.Init(client_program_id_, kBucketId, 3023 cmd.Init(client_program_id_, kBucketId,
3089 kSharedMemoryId, kSharedMemoryOffset); 3024 kSharedMemoryId, kSharedMemoryOffset);
3090 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 3025 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
3091 EXPECT_EQ(kUniform2FakeLocation, *result); 3026 EXPECT_EQ(kUniform2FakeLocation, *result);
3092 SetBucketAsCString(kBucketId, kNonExistentName); 3027 SetBucketAsCString(kBucketId, kNonExistentName);
3093 *result = -1; 3028 *result = -1;
3094 cmd.Init(client_program_id_, kBucketId, 3029 cmd.Init(client_program_id_, kBucketId,
3095 kSharedMemoryId, kSharedMemoryOffset); 3030 kSharedMemoryId, kSharedMemoryOffset);
3096 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 3031 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
3097 EXPECT_EQ(-1, *result); 3032 EXPECT_EQ(-1, *result);
3098 } 3033 }
3099 3034
3100 TEST_P(GLES2DecoderWithShaderTest, GetUniformLocationBucketInvalidArgs) { 3035 TEST_F(GLES2DecoderWithShaderTest, GetUniformLocationBucketInvalidArgs) {
3101 const uint32 kBucketId = 123; 3036 const uint32 kBucketId = 123;
3102 typedef GetUniformLocationBucket::Result Result; 3037 typedef GetUniformLocationBucket::Result Result;
3103 Result* result = GetSharedMemoryAs<Result*>(); 3038 Result* result = GetSharedMemoryAs<Result*>();
3104 *result = -1; 3039 *result = -1;
3105 GetUniformLocationBucket cmd; 3040 GetUniformLocationBucket cmd;
3106 // Check no bucket 3041 // Check no bucket
3107 cmd.Init(client_program_id_, kBucketId, 3042 cmd.Init(client_program_id_, kBucketId,
3108 kSharedMemoryId, kSharedMemoryOffset); 3043 kSharedMemoryId, kSharedMemoryOffset);
3109 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); 3044 EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
3110 EXPECT_EQ(-1, *result); 3045 EXPECT_EQ(-1, *result);
3111 // Check bad program id. 3046 // Check bad program id.
3112 SetBucketAsCString(kBucketId, kUniform2Name); 3047 SetBucketAsCString(kBucketId, kUniform2Name);
3113 cmd.Init(kInvalidClientId, kBucketId, 3048 cmd.Init(kInvalidClientId, kBucketId,
3114 kSharedMemoryId, kSharedMemoryOffset); 3049 kSharedMemoryId, kSharedMemoryOffset);
3115 *result = -1; 3050 *result = -1;
3116 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 3051 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
3117 EXPECT_EQ(-1, *result); 3052 EXPECT_EQ(-1, *result);
3118 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); 3053 EXPECT_EQ(GL_INVALID_VALUE, GetGLError());
3119 // Check bad memory 3054 // Check bad memory
3120 cmd.Init(client_program_id_, kBucketId, 3055 cmd.Init(client_program_id_, kBucketId,
3121 kInvalidSharedMemoryId, kSharedMemoryOffset); 3056 kInvalidSharedMemoryId, kSharedMemoryOffset);
3122 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); 3057 EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
3123 cmd.Init(client_program_id_, kBucketId, 3058 cmd.Init(client_program_id_, kBucketId,
3124 kSharedMemoryId, kInvalidSharedMemoryOffset); 3059 kSharedMemoryId, kInvalidSharedMemoryOffset);
3125 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); 3060 EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
3126 } 3061 }
3127 3062
3128 TEST_P(GLES2DecoderWithShaderTest, GetMaxValueInBufferCHROMIUM) { 3063 TEST_F(GLES2DecoderWithShaderTest, GetMaxValueInBufferCHROMIUM) {
3129 SetupIndexBuffer(); 3064 SetupIndexBuffer();
3130 GetMaxValueInBufferCHROMIUM::Result* result = 3065 GetMaxValueInBufferCHROMIUM::Result* result =
3131 static_cast<GetMaxValueInBufferCHROMIUM::Result*>(shared_memory_address_); 3066 static_cast<GetMaxValueInBufferCHROMIUM::Result*>(shared_memory_address_);
3132 *result = 0; 3067 *result = 0;
3133 3068
3134 GetMaxValueInBufferCHROMIUM cmd; 3069 GetMaxValueInBufferCHROMIUM cmd;
3135 cmd.Init(client_element_buffer_id_, kValidIndexRangeCount, GL_UNSIGNED_SHORT, 3070 cmd.Init(client_element_buffer_id_, kValidIndexRangeCount, GL_UNSIGNED_SHORT,
3136 kValidIndexRangeStart * 2, kSharedMemoryId, kSharedMemoryOffset); 3071 kValidIndexRangeStart * 2, kSharedMemoryId, kSharedMemoryOffset);
3137 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 3072 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
3138 EXPECT_EQ(7u, *result); 3073 EXPECT_EQ(7u, *result);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
3173 kValidIndexRangeStart * 2, 3108 kValidIndexRangeStart * 2,
3174 kInvalidSharedMemoryId, kSharedMemoryOffset); 3109 kInvalidSharedMemoryId, kSharedMemoryOffset);
3175 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); 3110 EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
3176 cmd.Init(client_element_buffer_id_, kValidIndexRangeCount + 1, 3111 cmd.Init(client_element_buffer_id_, kValidIndexRangeCount + 1,
3177 GL_UNSIGNED_SHORT, 3112 GL_UNSIGNED_SHORT,
3178 kValidIndexRangeStart * 2, 3113 kValidIndexRangeStart * 2,
3179 kSharedMemoryId, kInvalidSharedMemoryOffset); 3114 kSharedMemoryId, kInvalidSharedMemoryOffset);
3180 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); 3115 EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
3181 } 3116 }
3182 3117
3183 TEST_P(GLES2DecoderTest, SharedIds) { 3118 TEST_F(GLES2DecoderTest, SharedIds) {
3184 GenSharedIdsCHROMIUM gen_cmd; 3119 GenSharedIdsCHROMIUM gen_cmd;
3185 RegisterSharedIdsCHROMIUM reg_cmd; 3120 RegisterSharedIdsCHROMIUM reg_cmd;
3186 DeleteSharedIdsCHROMIUM del_cmd; 3121 DeleteSharedIdsCHROMIUM del_cmd;
3187 3122
3188 const GLuint kNamespaceId = id_namespaces::kTextures; 3123 const GLuint kNamespaceId = id_namespaces::kTextures;
3189 const GLuint kExpectedId1 = 1; 3124 const GLuint kExpectedId1 = 1;
3190 const GLuint kExpectedId2 = 2; 3125 const GLuint kExpectedId2 = 2;
3191 const GLuint kExpectedId3 = 4; 3126 const GLuint kExpectedId3 = 4;
3192 const GLuint kRegisterId = 3; 3127 const GLuint kRegisterId = 3;
3193 GLuint* ids = GetSharedMemoryAs<GLuint*>(); 3128 GLuint* ids = GetSharedMemoryAs<GLuint*>();
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
3244 3179
3245 // Check passing in an id_offset. 3180 // Check passing in an id_offset.
3246 ClearSharedMemory(); 3181 ClearSharedMemory();
3247 const GLuint kOffset = 0xABCDEF; 3182 const GLuint kOffset = 0xABCDEF;
3248 gen_cmd.Init(kNamespaceId, kOffset, 2, kSharedMemoryId, kSharedMemoryOffset); 3183 gen_cmd.Init(kNamespaceId, kOffset, 2, kSharedMemoryId, kSharedMemoryOffset);
3249 EXPECT_EQ(error::kNoError, ExecuteCmd(gen_cmd)); 3184 EXPECT_EQ(error::kNoError, ExecuteCmd(gen_cmd));
3250 EXPECT_EQ(kOffset, ids[0]); 3185 EXPECT_EQ(kOffset, ids[0]);
3251 EXPECT_EQ(kOffset + 1, ids[1]); 3186 EXPECT_EQ(kOffset + 1, ids[1]);
3252 } 3187 }
3253 3188
3254 TEST_P(GLES2DecoderTest, GenSharedIdsCHROMIUMBadArgs) { 3189 TEST_F(GLES2DecoderTest, GenSharedIdsCHROMIUMBadArgs) {
3255 const GLuint kNamespaceId = id_namespaces::kTextures; 3190 const GLuint kNamespaceId = id_namespaces::kTextures;
3256 GenSharedIdsCHROMIUM cmd; 3191 GenSharedIdsCHROMIUM cmd;
3257 cmd.Init(kNamespaceId, 0, -1, kSharedMemoryId, kSharedMemoryOffset); 3192 cmd.Init(kNamespaceId, 0, -1, kSharedMemoryId, kSharedMemoryOffset);
3258 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); 3193 EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
3259 cmd.Init(kNamespaceId, 0, 1, kInvalidSharedMemoryId, kSharedMemoryOffset); 3194 cmd.Init(kNamespaceId, 0, 1, kInvalidSharedMemoryId, kSharedMemoryOffset);
3260 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); 3195 EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
3261 cmd.Init(kNamespaceId, 0, 1, kSharedMemoryId, kInvalidSharedMemoryOffset); 3196 cmd.Init(kNamespaceId, 0, 1, kSharedMemoryId, kInvalidSharedMemoryOffset);
3262 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); 3197 EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
3263 } 3198 }
3264 3199
3265 TEST_P(GLES2DecoderTest, RegisterSharedIdsCHROMIUMBadArgs) { 3200 TEST_F(GLES2DecoderTest, RegisterSharedIdsCHROMIUMBadArgs) {
3266 const GLuint kNamespaceId = id_namespaces::kTextures; 3201 const GLuint kNamespaceId = id_namespaces::kTextures;
3267 RegisterSharedIdsCHROMIUM cmd; 3202 RegisterSharedIdsCHROMIUM cmd;
3268 cmd.Init(kNamespaceId, -1, kSharedMemoryId, kSharedMemoryOffset); 3203 cmd.Init(kNamespaceId, -1, kSharedMemoryId, kSharedMemoryOffset);
3269 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); 3204 EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
3270 cmd.Init(kNamespaceId, 1, kInvalidSharedMemoryId, kSharedMemoryOffset); 3205 cmd.Init(kNamespaceId, 1, kInvalidSharedMemoryId, kSharedMemoryOffset);
3271 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); 3206 EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
3272 cmd.Init(kNamespaceId, 1, kSharedMemoryId, kInvalidSharedMemoryOffset); 3207 cmd.Init(kNamespaceId, 1, kSharedMemoryId, kInvalidSharedMemoryOffset);
3273 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); 3208 EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
3274 } 3209 }
3275 3210
3276 TEST_P(GLES2DecoderTest, RegisterSharedIdsCHROMIUMDuplicateIds) { 3211 TEST_F(GLES2DecoderTest, RegisterSharedIdsCHROMIUMDuplicateIds) {
3277 const GLuint kNamespaceId = id_namespaces::kTextures; 3212 const GLuint kNamespaceId = id_namespaces::kTextures;
3278 const GLuint kRegisterId = 3; 3213 const GLuint kRegisterId = 3;
3279 RegisterSharedIdsCHROMIUM cmd; 3214 RegisterSharedIdsCHROMIUM cmd;
3280 GLuint* ids = GetSharedMemoryAs<GLuint*>(); 3215 GLuint* ids = GetSharedMemoryAs<GLuint*>();
3281 ids[0] = kRegisterId; 3216 ids[0] = kRegisterId;
3282 cmd.Init(kNamespaceId, 1, kSharedMemoryId, kSharedMemoryOffset); 3217 cmd.Init(kNamespaceId, 1, kSharedMemoryId, kSharedMemoryOffset);
3283 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 3218 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
3284 cmd.Init(kNamespaceId, 1, kSharedMemoryId, kSharedMemoryOffset); 3219 cmd.Init(kNamespaceId, 1, kSharedMemoryId, kSharedMemoryOffset);
3285 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 3220 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
3286 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); 3221 EXPECT_EQ(GL_INVALID_VALUE, GetGLError());
3287 } 3222 }
3288 3223
3289 TEST_P(GLES2DecoderTest, DeleteSharedIdsCHROMIUMBadArgs) { 3224 TEST_F(GLES2DecoderTest, DeleteSharedIdsCHROMIUMBadArgs) {
3290 const GLuint kNamespaceId = id_namespaces::kTextures; 3225 const GLuint kNamespaceId = id_namespaces::kTextures;
3291 DeleteSharedIdsCHROMIUM cmd; 3226 DeleteSharedIdsCHROMIUM cmd;
3292 cmd.Init(kNamespaceId, -1, kSharedMemoryId, kSharedMemoryOffset); 3227 cmd.Init(kNamespaceId, -1, kSharedMemoryId, kSharedMemoryOffset);
3293 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); 3228 EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
3294 cmd.Init(kNamespaceId, 1, kInvalidSharedMemoryId, kSharedMemoryOffset); 3229 cmd.Init(kNamespaceId, 1, kInvalidSharedMemoryId, kSharedMemoryOffset);
3295 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); 3230 EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
3296 cmd.Init(kNamespaceId, 1, kSharedMemoryId, kInvalidSharedMemoryOffset); 3231 cmd.Init(kNamespaceId, 1, kSharedMemoryId, kInvalidSharedMemoryOffset);
3297 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); 3232 EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
3298 } 3233 }
3299 3234
3300 TEST_P(GLES2DecoderTest, TexSubImage2DValidArgs) { 3235 TEST_F(GLES2DecoderTest, TexSubImage2DValidArgs) {
3301 const int kWidth = 16; 3236 const int kWidth = 16;
3302 const int kHeight = 8; 3237 const int kHeight = 8;
3303 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); 3238 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId);
3304 DoTexImage2D( 3239 DoTexImage2D(
3305 GL_TEXTURE_2D, 1, GL_RGBA, kWidth, kHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, 3240 GL_TEXTURE_2D, 1, GL_RGBA, kWidth, kHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE,
3306 kSharedMemoryId, kSharedMemoryOffset); 3241 kSharedMemoryId, kSharedMemoryOffset);
3307 EXPECT_CALL(*gl_, TexSubImage2D( 3242 EXPECT_CALL(*gl_, TexSubImage2D(
3308 GL_TEXTURE_2D, 1, 1, 0, kWidth - 1, kHeight, GL_RGBA, GL_UNSIGNED_BYTE, 3243 GL_TEXTURE_2D, 1, 1, 0, kWidth - 1, kHeight, GL_RGBA, GL_UNSIGNED_BYTE,
3309 shared_memory_address_)) 3244 shared_memory_address_))
3310 .Times(1) 3245 .Times(1)
3311 .RetiresOnSaturation(); 3246 .RetiresOnSaturation();
3312 TexSubImage2D cmd; 3247 TexSubImage2D cmd;
3313 cmd.Init( 3248 cmd.Init(
3314 GL_TEXTURE_2D, 1, 1, 0, kWidth - 1, kHeight, GL_RGBA, GL_UNSIGNED_BYTE, 3249 GL_TEXTURE_2D, 1, 1, 0, kWidth - 1, kHeight, GL_RGBA, GL_UNSIGNED_BYTE,
3315 kSharedMemoryId, kSharedMemoryOffset, GL_FALSE); 3250 kSharedMemoryId, kSharedMemoryOffset, GL_FALSE);
3316 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 3251 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
3317 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 3252 EXPECT_EQ(GL_NO_ERROR, GetGLError());
3318 } 3253 }
3319 3254
3320 TEST_P(GLES2DecoderTest, TexSubImage2DBadArgs) { 3255 TEST_F(GLES2DecoderTest, TexSubImage2DBadArgs) {
3321 const int kWidth = 16; 3256 const int kWidth = 16;
3322 const int kHeight = 8; 3257 const int kHeight = 8;
3323 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); 3258 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId);
3324 DoTexImage2D( 3259 DoTexImage2D(
3325 GL_TEXTURE_2D, 1, GL_RGBA, kWidth, kHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, 3260 GL_TEXTURE_2D, 1, GL_RGBA, kWidth, kHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE,
3326 0, 0); 3261 0, 0);
3327 TexSubImage2D cmd; 3262 TexSubImage2D cmd;
3328 cmd.Init(GL_TEXTURE0, 1, 0, 0, kWidth, kHeight, GL_RGBA, GL_UNSIGNED_BYTE, 3263 cmd.Init(GL_TEXTURE0, 1, 0, 0, kWidth, kHeight, GL_RGBA, GL_UNSIGNED_BYTE,
3329 kSharedMemoryId, kSharedMemoryOffset, GL_FALSE); 3264 kSharedMemoryId, kSharedMemoryOffset, GL_FALSE);
3330 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 3265 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
3371 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 3306 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
3372 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); 3307 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
3373 cmd.Init(GL_TEXTURE_2D, 1, 0, 0, kWidth, kHeight, GL_RGBA, GL_UNSIGNED_BYTE, 3308 cmd.Init(GL_TEXTURE_2D, 1, 0, 0, kWidth, kHeight, GL_RGBA, GL_UNSIGNED_BYTE,
3374 kInvalidSharedMemoryId, kSharedMemoryOffset, GL_FALSE); 3309 kInvalidSharedMemoryId, kSharedMemoryOffset, GL_FALSE);
3375 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); 3310 EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
3376 cmd.Init(GL_TEXTURE_2D, 1, 0, 0, kWidth, kHeight, GL_RGBA, GL_UNSIGNED_BYTE, 3311 cmd.Init(GL_TEXTURE_2D, 1, 0, 0, kWidth, kHeight, GL_RGBA, GL_UNSIGNED_BYTE,
3377 kSharedMemoryId, kInvalidSharedMemoryOffset, GL_FALSE); 3312 kSharedMemoryId, kInvalidSharedMemoryOffset, GL_FALSE);
3378 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); 3313 EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
3379 } 3314 }
3380 3315
3381 TEST_P(GLES2DecoderTest, CopyTexSubImage2DValidArgs) { 3316 TEST_F(GLES2DecoderTest, CopyTexSubImage2DValidArgs) {
3382 const int kWidth = 16; 3317 const int kWidth = 16;
3383 const int kHeight = 8; 3318 const int kHeight = 8;
3384 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); 3319 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId);
3385 DoTexImage2D( 3320 DoTexImage2D(
3386 GL_TEXTURE_2D, 1, GL_RGBA, kWidth, kHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, 3321 GL_TEXTURE_2D, 1, GL_RGBA, kWidth, kHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE,
3387 kSharedMemoryId, kSharedMemoryOffset); 3322 kSharedMemoryId, kSharedMemoryOffset);
3388 EXPECT_CALL(*gl_, CopyTexSubImage2D( 3323 EXPECT_CALL(*gl_, CopyTexSubImage2D(
3389 GL_TEXTURE_2D, 1, 0, 0, 0, 0, kWidth, kHeight)) 3324 GL_TEXTURE_2D, 1, 0, 0, 0, 0, kWidth, kHeight))
3390 .Times(1) 3325 .Times(1)
3391 .RetiresOnSaturation(); 3326 .RetiresOnSaturation();
3392 CopyTexSubImage2D cmd; 3327 CopyTexSubImage2D cmd;
3393 cmd.Init(GL_TEXTURE_2D, 1, 0, 0, 0, 0, kWidth, kHeight); 3328 cmd.Init(GL_TEXTURE_2D, 1, 0, 0, 0, 0, kWidth, kHeight);
3394 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 3329 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
3395 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 3330 EXPECT_EQ(GL_NO_ERROR, GetGLError());
3396 } 3331 }
3397 3332
3398 TEST_P(GLES2DecoderTest, CopyTexSubImage2DBadArgs) { 3333 TEST_F(GLES2DecoderTest, CopyTexSubImage2DBadArgs) {
3399 const int kWidth = 16; 3334 const int kWidth = 16;
3400 const int kHeight = 8; 3335 const int kHeight = 8;
3401 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); 3336 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId);
3402 DoTexImage2D( 3337 DoTexImage2D(
3403 GL_TEXTURE_2D, 1, GL_RGBA, kWidth, kHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, 3338 GL_TEXTURE_2D, 1, GL_RGBA, kWidth, kHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE,
3404 0, 0); 3339 0, 0);
3405 CopyTexSubImage2D cmd; 3340 CopyTexSubImage2D cmd;
3406 cmd.Init(GL_TEXTURE0, 1, 0, 0, 0, 0, kWidth, kHeight); 3341 cmd.Init(GL_TEXTURE0, 1, 0, 0, 0, 0, kWidth, kHeight);
3407 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 3342 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
3408 EXPECT_EQ(GL_INVALID_ENUM, GetGLError()); 3343 EXPECT_EQ(GL_INVALID_ENUM, GetGLError());
(...skipping 12 matching lines...) Expand all
3421 cmd.Init(GL_TEXTURE_2D, 1, 0, 0, 0, 0, kWidth + 1, kHeight); 3356 cmd.Init(GL_TEXTURE_2D, 1, 0, 0, 0, 0, kWidth + 1, kHeight);
3422 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 3357 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
3423 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); 3358 EXPECT_EQ(GL_INVALID_VALUE, GetGLError());
3424 cmd.Init(GL_TEXTURE_2D, 1, 0, 0, 0, 0, kWidth, kHeight + 1); 3359 cmd.Init(GL_TEXTURE_2D, 1, 0, 0, 0, 0, kWidth, kHeight + 1);
3425 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 3360 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
3426 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); 3361 EXPECT_EQ(GL_INVALID_VALUE, GetGLError());
3427 } 3362 }
3428 3363
3429 // Check that if a renderbuffer is attached and GL returns 3364 // Check that if a renderbuffer is attached and GL returns
3430 // GL_FRAMEBUFFER_COMPLETE that the buffer is cleared and state is restored. 3365 // GL_FRAMEBUFFER_COMPLETE that the buffer is cleared and state is restored.
3431 TEST_P(GLES2DecoderManualInitTest, FramebufferRenderbufferClearColor) { 3366 TEST_F(GLES2DecoderTest, FramebufferRenderbufferClearColor) {
3432 InitState init;
3433 init.gl_version = "opengl es 2.0";
3434 init.has_alpha = true;
3435 init.has_depth = true;
3436 init.request_alpha = true;
3437 init.request_depth = true;
3438 InitDecoder(init);
3439
3440 DoBindFramebuffer(GL_FRAMEBUFFER, client_framebuffer_id_, 3367 DoBindFramebuffer(GL_FRAMEBUFFER, client_framebuffer_id_,
3441 kServiceFramebufferId); 3368 kServiceFramebufferId);
3442 ClearColor color_cmd; 3369 ClearColor color_cmd;
3443 ColorMask color_mask_cmd; 3370 ColorMask color_mask_cmd;
3444 Enable enable_cmd; 3371 Enable enable_cmd;
3445 FramebufferRenderbuffer cmd; 3372 FramebufferRenderbuffer cmd;
3446 color_cmd.Init(0.1f, 0.2f, 0.3f, 0.4f); 3373 color_cmd.Init(0.1f, 0.2f, 0.3f, 0.4f);
3447 color_mask_cmd.Init(0, 1, 0, 1); 3374 color_mask_cmd.Init(0, 1, 0, 1);
3448 enable_cmd.Init(GL_SCISSOR_TEST); 3375 enable_cmd.Init(GL_SCISSOR_TEST);
3449 cmd.Init( 3376 cmd.Init(
3450 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, 3377 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER,
3451 client_renderbuffer_id_); 3378 client_renderbuffer_id_);
3452 InSequence sequence; 3379 InSequence sequence;
3453 EXPECT_CALL(*gl_, ClearColor(0.1f, 0.2f, 0.3f, 0.4f)) 3380 EXPECT_CALL(*gl_, ClearColor(0.1f, 0.2f, 0.3f, 0.4f))
3454 .Times(1) 3381 .Times(1)
3455 .RetiresOnSaturation(); 3382 .RetiresOnSaturation();
3456 SetupExpectationsForEnableDisable(GL_SCISSOR_TEST, true);
3457 EXPECT_CALL(*gl_, GetError()) 3383 EXPECT_CALL(*gl_, GetError())
3458 .WillOnce(Return(GL_NO_ERROR)) 3384 .WillOnce(Return(GL_NO_ERROR))
3459 .RetiresOnSaturation(); 3385 .RetiresOnSaturation();
3460 EXPECT_CALL(*gl_, FramebufferRenderbufferEXT( 3386 EXPECT_CALL(*gl_, FramebufferRenderbufferEXT(
3461 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, 3387 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER,
3462 kServiceRenderbufferId)) 3388 kServiceRenderbufferId))
3463 .Times(1) 3389 .Times(1)
3464 .RetiresOnSaturation(); 3390 .RetiresOnSaturation();
3465 EXPECT_CALL(*gl_, GetError()) 3391 EXPECT_CALL(*gl_, GetError())
3466 .WillOnce(Return(GL_NO_ERROR)) 3392 .WillOnce(Return(GL_NO_ERROR))
3467 .RetiresOnSaturation(); 3393 .RetiresOnSaturation();
3468 EXPECT_EQ(error::kNoError, ExecuteCmd(color_cmd)); 3394 EXPECT_EQ(error::kNoError, ExecuteCmd(color_cmd));
3469 EXPECT_EQ(error::kNoError, ExecuteCmd(color_mask_cmd)); 3395 EXPECT_EQ(error::kNoError, ExecuteCmd(color_mask_cmd));
3470 EXPECT_EQ(error::kNoError, ExecuteCmd(enable_cmd)); 3396 EXPECT_EQ(error::kNoError, ExecuteCmd(enable_cmd));
3471 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 3397 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
3472 } 3398 }
3473 3399
3474 TEST_P(GLES2DecoderTest, FramebufferRenderbufferClearDepth) { 3400 TEST_F(GLES2DecoderTest, FramebufferRenderbufferClearDepth) {
3475 DoBindFramebuffer(GL_FRAMEBUFFER, client_framebuffer_id_, 3401 DoBindFramebuffer(GL_FRAMEBUFFER, client_framebuffer_id_,
3476 kServiceFramebufferId); 3402 kServiceFramebufferId);
3477 ClearDepthf depth_cmd; 3403 ClearDepthf depth_cmd;
3478 DepthMask depth_mask_cmd; 3404 DepthMask depth_mask_cmd;
3479 FramebufferRenderbuffer cmd; 3405 FramebufferRenderbuffer cmd;
3480 depth_cmd.Init(0.5f); 3406 depth_cmd.Init(0.5f);
3481 depth_mask_cmd.Init(false); 3407 depth_mask_cmd.Init(false);
3482 cmd.Init( 3408 cmd.Init(
3483 GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, 3409 GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER,
3484 client_renderbuffer_id_); 3410 client_renderbuffer_id_);
(...skipping 10 matching lines...) Expand all
3495 .Times(1) 3421 .Times(1)
3496 .RetiresOnSaturation(); 3422 .RetiresOnSaturation();
3497 EXPECT_CALL(*gl_, GetError()) 3423 EXPECT_CALL(*gl_, GetError())
3498 .WillOnce(Return(GL_NO_ERROR)) 3424 .WillOnce(Return(GL_NO_ERROR))
3499 .RetiresOnSaturation(); 3425 .RetiresOnSaturation();
3500 EXPECT_EQ(error::kNoError, ExecuteCmd(depth_cmd)); 3426 EXPECT_EQ(error::kNoError, ExecuteCmd(depth_cmd));
3501 EXPECT_EQ(error::kNoError, ExecuteCmd(depth_mask_cmd)); 3427 EXPECT_EQ(error::kNoError, ExecuteCmd(depth_mask_cmd));
3502 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 3428 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
3503 } 3429 }
3504 3430
3505 TEST_P(GLES2DecoderTest, FramebufferRenderbufferClearStencil) { 3431 TEST_F(GLES2DecoderTest, FramebufferRenderbufferClearStencil) {
3506 DoBindFramebuffer(GL_FRAMEBUFFER, client_framebuffer_id_, 3432 DoBindFramebuffer(GL_FRAMEBUFFER, client_framebuffer_id_,
3507 kServiceFramebufferId); 3433 kServiceFramebufferId);
3508 ClearStencil stencil_cmd; 3434 ClearStencil stencil_cmd;
3509 StencilMaskSeparate stencil_mask_separate_cmd; 3435 StencilMaskSeparate stencil_mask_separate_cmd;
3510 FramebufferRenderbuffer cmd; 3436 FramebufferRenderbuffer cmd;
3511 stencil_cmd.Init(123); 3437 stencil_cmd.Init(123);
3512 stencil_mask_separate_cmd.Init(GL_BACK, 0x1234u); 3438 stencil_mask_separate_cmd.Init(GL_BACK, 0x1234u);
3513 cmd.Init( 3439 cmd.Init(
3514 GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, 3440 GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER,
3515 client_renderbuffer_id_); 3441 client_renderbuffer_id_);
(...skipping 10 matching lines...) Expand all
3526 .Times(1) 3452 .Times(1)
3527 .RetiresOnSaturation(); 3453 .RetiresOnSaturation();
3528 EXPECT_CALL(*gl_, GetError()) 3454 EXPECT_CALL(*gl_, GetError())
3529 .WillOnce(Return(GL_NO_ERROR)) 3455 .WillOnce(Return(GL_NO_ERROR))
3530 .RetiresOnSaturation(); 3456 .RetiresOnSaturation();
3531 EXPECT_EQ(error::kNoError, ExecuteCmd(stencil_cmd)); 3457 EXPECT_EQ(error::kNoError, ExecuteCmd(stencil_cmd));
3532 EXPECT_EQ(error::kNoError, ExecuteCmd(stencil_mask_separate_cmd)); 3458 EXPECT_EQ(error::kNoError, ExecuteCmd(stencil_mask_separate_cmd));
3533 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 3459 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
3534 } 3460 }
3535 3461
3536 TEST_P(GLES2DecoderTest, IsBuffer) { 3462 TEST_F(GLES2DecoderTest, IsBuffer) {
3537 EXPECT_FALSE(DoIsBuffer(client_buffer_id_)); 3463 EXPECT_FALSE(DoIsBuffer(client_buffer_id_));
3538 DoBindBuffer(GL_ARRAY_BUFFER, client_buffer_id_, kServiceBufferId); 3464 DoBindBuffer(GL_ARRAY_BUFFER, client_buffer_id_, kServiceBufferId);
3539 EXPECT_TRUE(DoIsBuffer(client_buffer_id_)); 3465 EXPECT_TRUE(DoIsBuffer(client_buffer_id_));
3540 DoDeleteBuffer(client_buffer_id_, kServiceBufferId); 3466 DoDeleteBuffer(client_buffer_id_, kServiceBufferId);
3541 EXPECT_FALSE(DoIsBuffer(client_buffer_id_)); 3467 EXPECT_FALSE(DoIsBuffer(client_buffer_id_));
3542 } 3468 }
3543 3469
3544 TEST_P(GLES2DecoderTest, IsFramebuffer) { 3470 TEST_F(GLES2DecoderTest, IsFramebuffer) {
3545 EXPECT_FALSE(DoIsFramebuffer(client_framebuffer_id_)); 3471 EXPECT_FALSE(DoIsFramebuffer(client_framebuffer_id_));
3546 DoBindFramebuffer(GL_FRAMEBUFFER, client_framebuffer_id_, 3472 DoBindFramebuffer(GL_FRAMEBUFFER, client_framebuffer_id_,
3547 kServiceFramebufferId); 3473 kServiceFramebufferId);
3548 EXPECT_TRUE(DoIsFramebuffer(client_framebuffer_id_)); 3474 EXPECT_TRUE(DoIsFramebuffer(client_framebuffer_id_));
3549 DoDeleteFramebuffer( 3475 DoDeleteFramebuffer(
3550 client_framebuffer_id_, kServiceFramebufferId, 3476 client_framebuffer_id_, kServiceFramebufferId,
3551 true, GL_FRAMEBUFFER, 0, 3477 true, GL_FRAMEBUFFER, 0,
3552 true, GL_FRAMEBUFFER, 0); 3478 true, GL_FRAMEBUFFER, 0);
3553 EXPECT_FALSE(DoIsFramebuffer(client_framebuffer_id_)); 3479 EXPECT_FALSE(DoIsFramebuffer(client_framebuffer_id_));
3554 } 3480 }
3555 3481
3556 TEST_P(GLES2DecoderTest, IsProgram) { 3482 TEST_F(GLES2DecoderTest, IsProgram) {
3557 // IsProgram is true as soon as the program is created. 3483 // IsProgram is true as soon as the program is created.
3558 EXPECT_TRUE(DoIsProgram(client_program_id_)); 3484 EXPECT_TRUE(DoIsProgram(client_program_id_));
3559 EXPECT_CALL(*gl_, DeleteProgram(kServiceProgramId)) 3485 EXPECT_CALL(*gl_, DeleteProgram(kServiceProgramId))
3560 .Times(1) 3486 .Times(1)
3561 .RetiresOnSaturation(); 3487 .RetiresOnSaturation();
3562 DoDeleteProgram(client_program_id_, kServiceProgramId); 3488 DoDeleteProgram(client_program_id_, kServiceProgramId);
3563 EXPECT_FALSE(DoIsProgram(client_program_id_)); 3489 EXPECT_FALSE(DoIsProgram(client_program_id_));
3564 3490
3565 } 3491 }
3566 3492
3567 TEST_P(GLES2DecoderTest, IsRenderbuffer) { 3493 TEST_F(GLES2DecoderTest, IsRenderbuffer) {
3568 EXPECT_FALSE(DoIsRenderbuffer(client_renderbuffer_id_)); 3494 EXPECT_FALSE(DoIsRenderbuffer(client_renderbuffer_id_));
3569 DoBindRenderbuffer(GL_RENDERBUFFER, client_renderbuffer_id_, 3495 DoBindRenderbuffer(GL_RENDERBUFFER, client_renderbuffer_id_,
3570 kServiceRenderbufferId); 3496 kServiceRenderbufferId);
3571 EXPECT_TRUE(DoIsRenderbuffer(client_renderbuffer_id_)); 3497 EXPECT_TRUE(DoIsRenderbuffer(client_renderbuffer_id_));
3572 DoDeleteRenderbuffer(client_renderbuffer_id_, kServiceRenderbufferId); 3498 DoDeleteRenderbuffer(client_renderbuffer_id_, kServiceRenderbufferId);
3573 EXPECT_FALSE(DoIsRenderbuffer(client_renderbuffer_id_)); 3499 EXPECT_FALSE(DoIsRenderbuffer(client_renderbuffer_id_));
3574 } 3500 }
3575 3501
3576 TEST_P(GLES2DecoderTest, IsShader) { 3502 TEST_F(GLES2DecoderTest, IsShader) {
3577 // IsShader is true as soon as the program is created. 3503 // IsShader is true as soon as the program is created.
3578 EXPECT_TRUE(DoIsShader(client_shader_id_)); 3504 EXPECT_TRUE(DoIsShader(client_shader_id_));
3579 DoDeleteShader(client_shader_id_, kServiceShaderId); 3505 DoDeleteShader(client_shader_id_, kServiceShaderId);
3580 EXPECT_FALSE(DoIsShader(client_shader_id_)); 3506 EXPECT_FALSE(DoIsShader(client_shader_id_));
3581 } 3507 }
3582 3508
3583 TEST_P(GLES2DecoderTest, IsTexture) { 3509 TEST_F(GLES2DecoderTest, IsTexture) {
3584 EXPECT_FALSE(DoIsTexture(client_texture_id_)); 3510 EXPECT_FALSE(DoIsTexture(client_texture_id_));
3585 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); 3511 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId);
3586 EXPECT_TRUE(DoIsTexture(client_texture_id_)); 3512 EXPECT_TRUE(DoIsTexture(client_texture_id_));
3587 DoDeleteTexture(client_texture_id_, kServiceTextureId); 3513 DoDeleteTexture(client_texture_id_, kServiceTextureId);
3588 EXPECT_FALSE(DoIsTexture(client_texture_id_)); 3514 EXPECT_FALSE(DoIsTexture(client_texture_id_));
3589 } 3515 }
3590 3516
3591 #if 0 // Turn this test on once we allow GL_DEPTH_STENCIL_ATTACHMENT 3517 #if 0 // Turn this test on once we allow GL_DEPTH_STENCIL_ATTACHMENT
3592 TEST_P(GLES2DecoderTest, FramebufferRenderbufferClearDepthStencil) { 3518 TEST_F(GLES2DecoderTest, FramebufferRenderbufferClearDepthStencil) {
3593 DoBindFramebuffer(GL_FRAMEBUFFER, client_framebuffer_id_, 3519 DoBindFramebuffer(GL_FRAMEBUFFER, client_framebuffer_id_,
3594 kServiceFramebufferId); 3520 kServiceFramebufferId);
3595 ClearDepthf depth_cmd; 3521 ClearDepthf depth_cmd;
3596 ClearStencil stencil_cmd; 3522 ClearStencil stencil_cmd;
3597 FramebufferRenderbuffer cmd; 3523 FramebufferRenderbuffer cmd;
3598 depth_cmd.Init(0.5f); 3524 depth_cmd.Init(0.5f);
3599 stencil_cmd.Init(123); 3525 stencil_cmd.Init(123);
3600 cmd.Init( 3526 cmd.Init(
3601 GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, 3527 GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER,
3602 client_renderbuffer_id_); 3528 client_renderbuffer_id_);
3603 InSequence sequence; 3529 InSequence sequence;
3604 EXPECT_CALL(*gl_, ClearDepth(0.5f)) 3530 EXPECT_CALL(*gl_, ClearDepth(0.5f))
3605 .Times(1) 3531 .Times(1)
3606 .RetiresOnSaturation(); 3532 .RetiresOnSaturation();
3607 EXPECT_CALL(*gl_, ClearStencil(123)) 3533 EXPECT_CALL(*gl_, ClearStencil(123))
3608 .Times(1) 3534 .Times(1)
3609 .RetiresOnSaturation(); 3535 .RetiresOnSaturation();
3610 EXPECT_CALL(*gl_, FramebufferRenderbufferEXT( 3536 EXPECT_CALL(*gl_, FramebufferRenderbufferEXT(
3611 GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, 3537 GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER,
3612 kServiceRenderbufferId)) 3538 kServiceRenderbufferId))
3613 .Times(1) 3539 .Times(1)
3614 .RetiresOnSaturation(); 3540 .RetiresOnSaturation();
3615 EXPECT_EQ(error::kNoError, ExecuteCmd(depth_cmd)); 3541 EXPECT_EQ(error::kNoError, ExecuteCmd(depth_cmd));
3616 EXPECT_EQ(error::kNoError, ExecuteCmd(stencil_cmd)); 3542 EXPECT_EQ(error::kNoError, ExecuteCmd(stencil_cmd));
3617 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 3543 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
3618 } 3544 }
3619 #endif 3545 #endif
3620 3546
3621 TEST_P(GLES2DecoderWithShaderTest, VertexAttribPointer) { 3547 TEST_F(GLES2DecoderWithShaderTest, VertexAttribPointer) {
3622 SetupVertexBuffer(); 3548 SetupVertexBuffer();
3623 static const GLenum types[] = { 3549 static const GLenum types[] = {
3624 GL_BYTE, 3550 GL_BYTE,
3625 GL_UNSIGNED_BYTE, 3551 GL_UNSIGNED_BYTE,
3626 GL_SHORT, 3552 GL_SHORT,
3627 GL_UNSIGNED_SHORT, 3553 GL_UNSIGNED_SHORT,
3628 GL_FLOAT, 3554 GL_FLOAT,
3629 GL_FIXED, 3555 GL_FIXED,
3630 GL_INT, 3556 GL_INT,
3631 GL_UNSIGNED_INT, 3557 GL_UNSIGNED_INT,
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
3751 } 3677 }
3752 } 3678 }
3753 } 3679 }
3754 } 3680 }
3755 } 3681 }
3756 } 3682 }
3757 } 3683 }
3758 3684
3759 // Test that with an RGB backbuffer if we set the color mask to 1,1,1,1 it is 3685 // Test that with an RGB backbuffer if we set the color mask to 1,1,1,1 it is
3760 // set to 1,1,1,0 at Draw time but is 1,1,1,1 at query time. 3686 // set to 1,1,1,0 at Draw time but is 1,1,1,1 at query time.
3761 TEST_P(GLES2DecoderRGBBackbufferTest, RGBBackbufferColorMask) { 3687 TEST_F(GLES2DecoderRGBBackbufferTest, RGBBackbufferColorMask) {
3762 ColorMask cmd; 3688 ColorMask cmd;
3763 cmd.Init(true, true, true, true); 3689 cmd.Init(true, true, true, true);
3764 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 3690 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
3765 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 3691 EXPECT_EQ(GL_NO_ERROR, GetGLError());
3766 3692
3767 SetupTexture(); 3693 SetupTexture();
3768 AddExpectationsForSimulatedAttrib0(kNumVertices, 0); 3694 AddExpectationsForSimulatedAttrib0(kNumVertices, 0);
3769 SetupExpectationsForApplyingDirtyState(true, // Framebuffer is RGB 3695 SetupExpectationsForApplyingDirtyState(
3770 false, // Framebuffer has depth 3696 true, // Framebuffer is RGB
3771 false, // Framebuffer has stencil 3697 false, // Framebuffer has depth
3772 0x1110, // color bits 3698 false, // Framebuffer has stencil
3773 false, // depth mask 3699 0x1110, // color bits
3774 false, // depth enabled 3700 false, // depth mask
3775 0, // front stencil mask 3701 false, // depth enabled
3776 0, // back stencil mask 3702 0, // front stencil mask
3777 false); // stencil enabled 3703 0, // back stencil mask
3704 false, // stencil enabled
3705 false, // cull_face_enabled
3706 false, // scissor_test_enabled
3707 false); // blend_enabled
3778 3708
3779 EXPECT_CALL(*gl_, DrawArrays(GL_TRIANGLES, 0, kNumVertices)) 3709 EXPECT_CALL(*gl_, DrawArrays(GL_TRIANGLES, 0, kNumVertices))
3780 .Times(1) 3710 .Times(1)
3781 .RetiresOnSaturation(); 3711 .RetiresOnSaturation();
3782 DrawArrays draw_cmd; 3712 DrawArrays draw_cmd;
3783 draw_cmd.Init(GL_TRIANGLES, 0, kNumVertices); 3713 draw_cmd.Init(GL_TRIANGLES, 0, kNumVertices);
3784 EXPECT_EQ(error::kNoError, ExecuteCmd(draw_cmd)); 3714 EXPECT_EQ(error::kNoError, ExecuteCmd(draw_cmd));
3785 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 3715 EXPECT_EQ(GL_NO_ERROR, GetGLError());
3786 3716
3787 EXPECT_CALL(*gl_, GetError()) 3717 EXPECT_CALL(*gl_, GetError())
(...skipping 13 matching lines...) Expand all
3801 result->GetNumResults()); 3731 result->GetNumResults());
3802 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 3732 EXPECT_EQ(GL_NO_ERROR, GetGLError());
3803 EXPECT_EQ(1, result->GetData()[0]); 3733 EXPECT_EQ(1, result->GetData()[0]);
3804 EXPECT_EQ(1, result->GetData()[1]); 3734 EXPECT_EQ(1, result->GetData()[1]);
3805 EXPECT_EQ(1, result->GetData()[2]); 3735 EXPECT_EQ(1, result->GetData()[2]);
3806 EXPECT_EQ(1, result->GetData()[3]); 3736 EXPECT_EQ(1, result->GetData()[3]);
3807 } 3737 }
3808 3738
3809 // Test that with no depth if we set DepthMask true that it's set to false at 3739 // Test that with no depth if we set DepthMask true that it's set to false at
3810 // draw time but querying it returns true. 3740 // draw time but querying it returns true.
3811 TEST_P(GLES2DecoderRGBBackbufferTest, RGBBackbufferDepthMask) { 3741 TEST_F(GLES2DecoderRGBBackbufferTest, RGBBackbufferDepthMask) {
3812 EXPECT_CALL(*gl_, DepthMask(true)) 3742 EXPECT_CALL(*gl_, DepthMask(true))
3813 .Times(0) 3743 .Times(0)
3814 .RetiresOnSaturation(); 3744 .RetiresOnSaturation();
3815 DepthMask cmd; 3745 DepthMask cmd;
3816 cmd.Init(true); 3746 cmd.Init(true);
3817 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 3747 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
3818 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 3748 EXPECT_EQ(GL_NO_ERROR, GetGLError());
3819 3749
3820 SetupTexture(); 3750 SetupTexture();
3821 AddExpectationsForSimulatedAttrib0(kNumVertices, 0); 3751 AddExpectationsForSimulatedAttrib0(kNumVertices, 0);
3822 SetupExpectationsForApplyingDirtyState(true, // Framebuffer is RGB 3752 SetupExpectationsForApplyingDirtyState(
3823 false, // Framebuffer has depth 3753 true, // Framebuffer is RGB
3824 false, // Framebuffer has stencil 3754 false, // Framebuffer has depth
3825 0x1110, // color bits 3755 false, // Framebuffer has stencil
3826 false, // depth mask 3756 0x1110, // color bits
3827 false, // depth enabled 3757 false, // depth mask
3828 0, // front stencil mask 3758 false, // depth enabled
3829 0, // back stencil mask 3759 0, // front stencil mask
3830 false); // stencil enabled 3760 0, // back stencil mask
3761 false, // stencil enabled
3762 false, // cull_face_enabled
3763 false, // scissor_test_enabled
3764 false); // blend_enabled
3831 3765
3832 EXPECT_CALL(*gl_, DrawArrays(GL_TRIANGLES, 0, kNumVertices)) 3766 EXPECT_CALL(*gl_, DrawArrays(GL_TRIANGLES, 0, kNumVertices))
3833 .Times(1) 3767 .Times(1)
3834 .RetiresOnSaturation(); 3768 .RetiresOnSaturation();
3835 DrawArrays draw_cmd; 3769 DrawArrays draw_cmd;
3836 draw_cmd.Init(GL_TRIANGLES, 0, kNumVertices); 3770 draw_cmd.Init(GL_TRIANGLES, 0, kNumVertices);
3837 EXPECT_EQ(error::kNoError, ExecuteCmd(draw_cmd)); 3771 EXPECT_EQ(error::kNoError, ExecuteCmd(draw_cmd));
3838 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 3772 EXPECT_EQ(GL_NO_ERROR, GetGLError());
3839 3773
3840 EXPECT_CALL(*gl_, GetError()) 3774 EXPECT_CALL(*gl_, GetError())
(...skipping 10 matching lines...) Expand all
3851 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2)); 3785 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2));
3852 EXPECT_EQ( 3786 EXPECT_EQ(
3853 decoder_->GetGLES2Util()->GLGetNumValuesReturned(GL_DEPTH_WRITEMASK), 3787 decoder_->GetGLES2Util()->GLGetNumValuesReturned(GL_DEPTH_WRITEMASK),
3854 result->GetNumResults()); 3788 result->GetNumResults());
3855 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 3789 EXPECT_EQ(GL_NO_ERROR, GetGLError());
3856 EXPECT_EQ(1, result->GetData()[0]); 3790 EXPECT_EQ(1, result->GetData()[0]);
3857 } 3791 }
3858 3792
3859 // Test that with no stencil if we set the stencil mask it's still set to 0 at 3793 // Test that with no stencil if we set the stencil mask it's still set to 0 at
3860 // draw time but gets our value if we query. 3794 // draw time but gets our value if we query.
3861 TEST_P(GLES2DecoderRGBBackbufferTest, RGBBackbufferStencilMask) { 3795 TEST_F(GLES2DecoderRGBBackbufferTest, RGBBackbufferStencilMask) {
3862 const GLint kMask = 123; 3796 const GLint kMask = 123;
3863 EXPECT_CALL(*gl_, StencilMask(kMask)) 3797 EXPECT_CALL(*gl_, StencilMask(kMask))
3864 .Times(0) 3798 .Times(0)
3865 .RetiresOnSaturation(); 3799 .RetiresOnSaturation();
3866 StencilMask cmd; 3800 StencilMask cmd;
3867 cmd.Init(kMask); 3801 cmd.Init(kMask);
3868 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 3802 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
3869 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 3803 EXPECT_EQ(GL_NO_ERROR, GetGLError());
3870 3804
3871 SetupTexture(); 3805 SetupTexture();
3872 AddExpectationsForSimulatedAttrib0(kNumVertices, 0); 3806 AddExpectationsForSimulatedAttrib0(kNumVertices, 0);
3873 SetupExpectationsForApplyingDirtyState(true, // Framebuffer is RGB 3807 SetupExpectationsForApplyingDirtyState(
3874 false, // Framebuffer has depth 3808 true, // Framebuffer is RGB
3875 false, // Framebuffer has stencil 3809 false, // Framebuffer has depth
3876 0x1110, // color bits 3810 false, // Framebuffer has stencil
3877 false, // depth mask 3811 0x1110, // color bits
3878 false, // depth enabled 3812 false, // depth mask
3879 0, // front stencil mask 3813 false, // depth enabled
3880 0, // back stencil mask 3814 0, // front stencil mask
3881 false); // stencil enabled 3815 0, // back stencil mask
3816 false, // stencil enabled
3817 false, // cull_face_enabled
3818 false, // scissor_test_enabled
3819 false); // blend_enabled
3882 3820
3883 EXPECT_CALL(*gl_, DrawArrays(GL_TRIANGLES, 0, kNumVertices)) 3821 EXPECT_CALL(*gl_, DrawArrays(GL_TRIANGLES, 0, kNumVertices))
3884 .Times(1) 3822 .Times(1)
3885 .RetiresOnSaturation(); 3823 .RetiresOnSaturation();
3886 DrawArrays draw_cmd; 3824 DrawArrays draw_cmd;
3887 draw_cmd.Init(GL_TRIANGLES, 0, kNumVertices); 3825 draw_cmd.Init(GL_TRIANGLES, 0, kNumVertices);
3888 EXPECT_EQ(error::kNoError, ExecuteCmd(draw_cmd)); 3826 EXPECT_EQ(error::kNoError, ExecuteCmd(draw_cmd));
3889 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 3827 EXPECT_EQ(GL_NO_ERROR, GetGLError());
3890 3828
3891 EXPECT_CALL(*gl_, GetError()) 3829 EXPECT_CALL(*gl_, GetError())
3892 .WillOnce(Return(GL_NO_ERROR)) 3830 .WillOnce(Return(GL_NO_ERROR))
3893 .WillOnce(Return(GL_NO_ERROR)) 3831 .WillOnce(Return(GL_NO_ERROR))
3894 .RetiresOnSaturation(); 3832 .RetiresOnSaturation();
3895 typedef GetIntegerv::Result Result; 3833 typedef GetIntegerv::Result Result;
3896 Result* result = static_cast<Result*>(shared_memory_address_); 3834 Result* result = static_cast<Result*>(shared_memory_address_);
3897 EXPECT_CALL(*gl_, GetIntegerv(GL_STENCIL_WRITEMASK, result->GetData())) 3835 EXPECT_CALL(*gl_, GetIntegerv(GL_STENCIL_WRITEMASK, result->GetData()))
3898 .Times(0); 3836 .Times(0);
3899 result->size = 0; 3837 result->size = 0;
3900 GetIntegerv cmd2; 3838 GetIntegerv cmd2;
3901 cmd2.Init(GL_STENCIL_WRITEMASK, shared_memory_id_, shared_memory_offset_); 3839 cmd2.Init(GL_STENCIL_WRITEMASK, shared_memory_id_, shared_memory_offset_);
3902 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2)); 3840 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2));
3903 EXPECT_EQ( 3841 EXPECT_EQ(
3904 decoder_->GetGLES2Util()->GLGetNumValuesReturned(GL_STENCIL_WRITEMASK), 3842 decoder_->GetGLES2Util()->GLGetNumValuesReturned(GL_STENCIL_WRITEMASK),
3905 result->GetNumResults()); 3843 result->GetNumResults());
3906 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 3844 EXPECT_EQ(GL_NO_ERROR, GetGLError());
3907 EXPECT_EQ(kMask, result->GetData()[0]); 3845 EXPECT_EQ(kMask, result->GetData()[0]);
3908 } 3846 }
3909 3847
3910 // Test that if an FBO is bound we get the correct masks. 3848 // Test that if an FBO is bound we get the correct masks.
3911 TEST_P(GLES2DecoderRGBBackbufferTest, RGBBackbufferColorMaskFBO) { 3849 TEST_F(GLES2DecoderRGBBackbufferTest, RGBBackbufferColorMaskFBO) {
3912 ColorMask cmd; 3850 ColorMask cmd;
3913 cmd.Init(true, true, true, true); 3851 cmd.Init(true, true, true, true);
3914 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 3852 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
3915 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 3853 EXPECT_EQ(GL_NO_ERROR, GetGLError());
3916 3854
3917 SetupTexture(); 3855 SetupTexture();
3918 SetupVertexBuffer(); 3856 SetupVertexBuffer();
3919 DoEnableVertexAttribArray(0); 3857 DoEnableVertexAttribArray(0);
3920 DoVertexAttribPointer(0, 2, GL_FLOAT, 0, 0); 3858 DoVertexAttribPointer(0, 2, GL_FLOAT, 0, 0);
3921 DoEnableVertexAttribArray(1); 3859 DoEnableVertexAttribArray(1);
3922 DoVertexAttribPointer(1, 2, GL_FLOAT, 0, 0); 3860 DoVertexAttribPointer(1, 2, GL_FLOAT, 0, 0);
3923 DoEnableVertexAttribArray(2); 3861 DoEnableVertexAttribArray(2);
3924 DoVertexAttribPointer(2, 2, GL_FLOAT, 0, 0); 3862 DoVertexAttribPointer(2, 2, GL_FLOAT, 0, 0);
3925 SetupExpectationsForApplyingDirtyState(true, // Framebuffer is RGB 3863 SetupExpectationsForApplyingDirtyState(
3926 false, // Framebuffer has depth 3864 true, // Framebuffer is RGB
3927 false, // Framebuffer has stencil 3865 false, // Framebuffer has depth
3928 0x1110, // color bits 3866 false, // Framebuffer has stencil
3929 false, // depth mask 3867 0x1110, // color bits
3930 false, // depth enabled 3868 false, // depth mask
3931 0, // front stencil mask 3869 false, // depth enabled
3932 0, // back stencil mask 3870 0, // front stencil mask
3933 false); // stencil enabled 3871 0, // back stencil mask
3872 false, // stencil enabled
3873 false, // cull_face_enabled
3874 false, // scissor_test_enabled
3875 false); // blend_enabled
3934 3876
3935 EXPECT_CALL(*gl_, DrawArrays(GL_TRIANGLES, 0, kNumVertices)) 3877 EXPECT_CALL(*gl_, DrawArrays(GL_TRIANGLES, 0, kNumVertices))
3936 .Times(1) 3878 .Times(1)
3937 .RetiresOnSaturation(); 3879 .RetiresOnSaturation();
3938 DrawArrays draw_cmd; 3880 DrawArrays draw_cmd;
3939 draw_cmd.Init(GL_TRIANGLES, 0, kNumVertices); 3881 draw_cmd.Init(GL_TRIANGLES, 0, kNumVertices);
3940 EXPECT_EQ(error::kNoError, ExecuteCmd(draw_cmd)); 3882 EXPECT_EQ(error::kNoError, ExecuteCmd(draw_cmd));
3941 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 3883 EXPECT_EQ(GL_NO_ERROR, GetGLError());
3942 3884
3943 // Check that no extra calls are made on the next draw. 3885 // Check that no extra calls are made on the next draw.
(...skipping 16 matching lines...) Expand all
3960 DoBindFramebuffer( 3902 DoBindFramebuffer(
3961 GL_FRAMEBUFFER, client_framebuffer_id_, kServiceFramebufferId); 3903 GL_FRAMEBUFFER, client_framebuffer_id_, kServiceFramebufferId);
3962 DoFramebufferTexture2D( 3904 DoFramebufferTexture2D(
3963 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 3905 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
3964 client_texture_id_, kServiceTextureId, 0, GL_NO_ERROR); 3906 client_texture_id_, kServiceTextureId, 0, GL_NO_ERROR);
3965 EXPECT_CALL(*gl_, CheckFramebufferStatusEXT(GL_FRAMEBUFFER)) 3907 EXPECT_CALL(*gl_, CheckFramebufferStatusEXT(GL_FRAMEBUFFER))
3966 .WillOnce(Return(GL_FRAMEBUFFER_COMPLETE)) 3908 .WillOnce(Return(GL_FRAMEBUFFER_COMPLETE))
3967 .RetiresOnSaturation(); 3909 .RetiresOnSaturation();
3968 3910
3969 // This time state needs to be set. 3911 // This time state needs to be set.
3970 SetupExpectationsForApplyingDirtyState(false, // Framebuffer is RGB 3912 SetupExpectationsForApplyingDirtyState(
3971 false, // Framebuffer has depth 3913 false, // Framebuffer is RGB
3972 false, // Framebuffer has stencil 3914 false, // Framebuffer has depth
3973 0x1110, // color bits 3915 false, // Framebuffer has stencil
3974 false, // depth mask 3916 0x1110, // color bits
3975 false, // depth enabled 3917 false, // depth mask
3976 0, // front stencil mask 3918 false, // depth enabled
3977 0, // back stencil mask 3919 0, // front stencil mask
3978 false); // stencil enabled 3920 0, // back stencil mask
3921 false, // stencil enabled
3922 false, // cull_face_enabled
3923 false, // scissor_test_enabled
3924 false); // blend_enabled
3979 3925
3980 EXPECT_CALL(*gl_, DrawArrays(GL_TRIANGLES, 0, kNumVertices)) 3926 EXPECT_CALL(*gl_, DrawArrays(GL_TRIANGLES, 0, kNumVertices))
3981 .Times(1) 3927 .Times(1)
3982 .RetiresOnSaturation(); 3928 .RetiresOnSaturation();
3983 EXPECT_EQ(error::kNoError, ExecuteCmd(draw_cmd)); 3929 EXPECT_EQ(error::kNoError, ExecuteCmd(draw_cmd));
3984 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 3930 EXPECT_EQ(GL_NO_ERROR, GetGLError());
3985 3931
3986 // Check that no extra calls are made on the next draw. 3932 // Check that no extra calls are made on the next draw.
3987 EXPECT_CALL(*gl_, DrawArrays(GL_TRIANGLES, 0, kNumVertices)) 3933 EXPECT_CALL(*gl_, DrawArrays(GL_TRIANGLES, 0, kNumVertices))
3988 .Times(1) 3934 .Times(1)
3989 .RetiresOnSaturation(); 3935 .RetiresOnSaturation();
3990 EXPECT_EQ(error::kNoError, ExecuteCmd(draw_cmd)); 3936 EXPECT_EQ(error::kNoError, ExecuteCmd(draw_cmd));
3991 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 3937 EXPECT_EQ(GL_NO_ERROR, GetGLError());
3992 3938
3993 // Unbind 3939 // Unbind
3994 DoBindFramebuffer(GL_FRAMEBUFFER, 0, 0); 3940 DoBindFramebuffer(GL_FRAMEBUFFER, 0, 0);
3995 3941
3996 SetupExpectationsForApplyingDirtyState(true, // Framebuffer is RGB 3942 SetupExpectationsForApplyingDirtyState(
3997 false, // Framebuffer has depth 3943 true, // Framebuffer is RGB
3998 false, // Framebuffer has stencil 3944 false, // Framebuffer has depth
3999 0x1110, // color bits 3945 false, // Framebuffer has stencil
4000 false, // depth mask 3946 0x1110, // color bits
4001 false, // depth enabled 3947 false, // depth mask
4002 0, // front stencil mask 3948 false, // depth enabled
4003 0, // back stencil mask 3949 0, // front stencil mask
4004 false); // stencil enabled 3950 0, // back stencil mask
3951 false, // stencil enabled
3952 false, // cull_face_enabled
3953 false, // scissor_test_enabled
3954 false); // blend_enabled
4005 3955
4006 EXPECT_CALL(*gl_, DrawArrays(GL_TRIANGLES, 0, kNumVertices)) 3956 EXPECT_CALL(*gl_, DrawArrays(GL_TRIANGLES, 0, kNumVertices))
4007 .Times(1) 3957 .Times(1)
4008 .RetiresOnSaturation(); 3958 .RetiresOnSaturation();
4009 EXPECT_EQ(error::kNoError, ExecuteCmd(draw_cmd)); 3959 EXPECT_EQ(error::kNoError, ExecuteCmd(draw_cmd));
4010 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 3960 EXPECT_EQ(GL_NO_ERROR, GetGLError());
4011 } 3961 }
4012 3962
4013 TEST_P(GLES2DecoderManualInitTest, CachedColorMask) { 3963 TEST_F(GLES2DecoderManualInitTest, ActualAlphaMatchesRequestedAlpha) {
4014 InitState init; 3964 InitState init;
4015 init.gl_version = "3.0"; 3965 init.gl_version = "3.0";
4016 init.has_alpha = true; 3966 init.has_alpha = true;
4017 init.has_depth = true;
4018 init.has_stencil = true;
4019 init.request_alpha = true;
4020 init.request_depth = true;
4021 init.request_stencil = true;
4022 init.bind_generates_resource = true;
4023 InitDecoder(init);
4024
4025 SetupDefaultProgram();
4026 SetupAllNeededVertexBuffers();
4027 SetupTexture();
4028
4029 // Test all color_bits combinations twice.
4030 for (int i = 0; i < 32; i++) {
4031 GLuint color_bits = (i & 1 ? 0x0001 : 0x0000) | (i & 2 ? 0x0010 : 0x0000) |
4032 (i & 4 ? 0x0100 : 0x0000) | (i & 8 ? 0x1000 : 0x0000);
4033
4034 // Toggle depth_test to force ApplyDirtyState each time.
4035 DirtyStateMaskTest(color_bits, false, 0xffffffff, 0xffffffff);
4036 DirtyStateMaskTest(color_bits, true, 0xffffffff, 0xffffffff);
4037 DirtyStateMaskTest(color_bits, false, 0xffffffff, 0xffffffff);
4038 }
4039 }
4040
4041 TEST_P(GLES2DecoderManualInitTest, CachedDepthMask) {
4042 InitState init;
4043 init.gl_version = "3.0";
4044 init.has_alpha = true;
4045 init.has_depth = true;
4046 init.has_stencil = true;
4047 init.request_alpha = true;
4048 init.request_depth = true;
4049 init.request_stencil = true;
4050 init.bind_generates_resource = true;
4051 InitDecoder(init);
4052
4053 SetupDefaultProgram();
4054 SetupAllNeededVertexBuffers();
4055 SetupTexture();
4056
4057 // Test all depth_mask combinations twice.
4058 for (int i = 0; i < 4; i++) {
4059 bool depth_mask = (i & 1) == 1;
4060
4061 // Toggle color masks to force ApplyDirtyState each time.
4062 DirtyStateMaskTest(0x1010, depth_mask, 0xffffffff, 0xffffffff);
4063 DirtyStateMaskTest(0x0101, depth_mask, 0xffffffff, 0xffffffff);
4064 DirtyStateMaskTest(0x1010, depth_mask, 0xffffffff, 0xffffffff);
4065 }
4066 }
4067
4068 TEST_P(GLES2DecoderManualInitTest, CachedStencilMask) {
4069 InitState init;
4070 init.gl_version = "3.0";
4071 init.has_alpha = true;
4072 init.has_depth = true;
4073 init.has_stencil = true;
4074 init.request_alpha = true;
4075 init.request_depth = true;
4076 init.request_stencil = true;
4077 init.bind_generates_resource = true;
4078 InitDecoder(init);
4079
4080 SetupDefaultProgram();
4081 SetupAllNeededVertexBuffers();
4082 SetupTexture();
4083
4084 // Test all stencil_mask combinations twice.
4085 for (int i = 0; i < 4; i++) {
4086 GLuint stencil_mask = (i & 1) ? 0xf0f0f0f0 : 0x0f0f0f0f;
4087
4088 // Toggle color masks to force ApplyDirtyState each time.
4089 DirtyStateMaskTest(0x1010, true, stencil_mask, 0xffffffff);
4090 DirtyStateMaskTest(0x0101, true, stencil_mask, 0xffffffff);
4091 DirtyStateMaskTest(0x1010, true, stencil_mask, 0xffffffff);
4092 }
4093
4094 for (int i = 0; i < 4; i++) {
4095 GLuint stencil_mask = (i & 1) ? 0xf0f0f0f0 : 0x0f0f0f0f;
4096
4097 // Toggle color masks to force ApplyDirtyState each time.
4098 DirtyStateMaskTest(0x1010, true, 0xffffffff, stencil_mask);
4099 DirtyStateMaskTest(0x0101, true, 0xffffffff, stencil_mask);
4100 DirtyStateMaskTest(0x1010, true, 0xffffffff, stencil_mask);
4101 }
4102 }
4103
4104 TEST_P(GLES2DecoderManualInitTest, ActualAlphaMatchesRequestedAlpha) {
4105 InitState init;
4106 init.gl_version = "3.0";
4107 init.has_alpha = true;
4108 init.request_alpha = true; 3967 init.request_alpha = true;
4109 init.bind_generates_resource = true; 3968 init.bind_generates_resource = true;
4110 InitDecoder(init); 3969 InitDecoder(init);
4111 3970
4112 EXPECT_CALL(*gl_, GetError()) 3971 EXPECT_CALL(*gl_, GetError())
4113 .WillOnce(Return(GL_NO_ERROR)) 3972 .WillOnce(Return(GL_NO_ERROR))
4114 .WillOnce(Return(GL_NO_ERROR)) 3973 .WillOnce(Return(GL_NO_ERROR))
4115 .RetiresOnSaturation(); 3974 .RetiresOnSaturation();
4116 typedef GetIntegerv::Result Result; 3975 typedef GetIntegerv::Result Result;
4117 Result* result = static_cast<Result*>(shared_memory_address_); 3976 Result* result = static_cast<Result*>(shared_memory_address_);
4118 EXPECT_CALL(*gl_, GetIntegerv(GL_ALPHA_BITS, _)) 3977 EXPECT_CALL(*gl_, GetIntegerv(GL_ALPHA_BITS, _))
4119 .WillOnce(SetArgumentPointee<1>(8)) 3978 .WillOnce(SetArgumentPointee<1>(8))
4120 .RetiresOnSaturation(); 3979 .RetiresOnSaturation();
4121 result->size = 0; 3980 result->size = 0;
4122 GetIntegerv cmd2; 3981 GetIntegerv cmd2;
4123 cmd2.Init(GL_ALPHA_BITS, shared_memory_id_, shared_memory_offset_); 3982 cmd2.Init(GL_ALPHA_BITS, shared_memory_id_, shared_memory_offset_);
4124 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2)); 3983 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2));
4125 EXPECT_EQ( 3984 EXPECT_EQ(
4126 decoder_->GetGLES2Util()->GLGetNumValuesReturned(GL_ALPHA_BITS), 3985 decoder_->GetGLES2Util()->GLGetNumValuesReturned(GL_ALPHA_BITS),
4127 result->GetNumResults()); 3986 result->GetNumResults());
4128 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 3987 EXPECT_EQ(GL_NO_ERROR, GetGLError());
4129 EXPECT_EQ(8, result->GetData()[0]); 3988 EXPECT_EQ(8, result->GetData()[0]);
4130 } 3989 }
4131 3990
4132 TEST_P(GLES2DecoderManualInitTest, ActualAlphaDoesNotMatchRequestedAlpha) { 3991 TEST_F(GLES2DecoderManualInitTest, ActualAlphaDoesNotMatchRequestedAlpha) {
4133 InitState init; 3992 InitState init;
4134 init.gl_version = "3.0"; 3993 init.gl_version = "3.0";
4135 init.has_alpha = true; 3994 init.has_alpha = true;
4136 init.bind_generates_resource = true; 3995 init.bind_generates_resource = true;
4137 InitDecoder(init); 3996 InitDecoder(init);
4138 3997
4139 EXPECT_CALL(*gl_, GetError()) 3998 EXPECT_CALL(*gl_, GetError())
4140 .WillOnce(Return(GL_NO_ERROR)) 3999 .WillOnce(Return(GL_NO_ERROR))
4141 .WillOnce(Return(GL_NO_ERROR)) 4000 .WillOnce(Return(GL_NO_ERROR))
4142 .RetiresOnSaturation(); 4001 .RetiresOnSaturation();
4143 typedef GetIntegerv::Result Result; 4002 typedef GetIntegerv::Result Result;
4144 Result* result = static_cast<Result*>(shared_memory_address_); 4003 Result* result = static_cast<Result*>(shared_memory_address_);
4145 EXPECT_CALL(*gl_, GetIntegerv(GL_ALPHA_BITS, _)) 4004 EXPECT_CALL(*gl_, GetIntegerv(GL_ALPHA_BITS, _))
4146 .WillOnce(SetArgumentPointee<1>(8)) 4005 .WillOnce(SetArgumentPointee<1>(8))
4147 .RetiresOnSaturation(); 4006 .RetiresOnSaturation();
4148 result->size = 0; 4007 result->size = 0;
4149 GetIntegerv cmd2; 4008 GetIntegerv cmd2;
4150 cmd2.Init(GL_ALPHA_BITS, shared_memory_id_, shared_memory_offset_); 4009 cmd2.Init(GL_ALPHA_BITS, shared_memory_id_, shared_memory_offset_);
4151 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2)); 4010 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2));
4152 EXPECT_EQ( 4011 EXPECT_EQ(
4153 decoder_->GetGLES2Util()->GLGetNumValuesReturned(GL_ALPHA_BITS), 4012 decoder_->GetGLES2Util()->GLGetNumValuesReturned(GL_ALPHA_BITS),
4154 result->GetNumResults()); 4013 result->GetNumResults());
4155 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 4014 EXPECT_EQ(GL_NO_ERROR, GetGLError());
4156 EXPECT_EQ(0, result->GetData()[0]); 4015 EXPECT_EQ(0, result->GetData()[0]);
4157 } 4016 }
4158 4017
4159 TEST_P(GLES2DecoderManualInitTest, ActualDepthMatchesRequestedDepth) { 4018 TEST_F(GLES2DecoderManualInitTest, ActualDepthMatchesRequestedDepth) {
4160 InitState init; 4019 InitState init;
4161 init.gl_version = "3.0"; 4020 init.gl_version = "3.0";
4162 init.has_depth = true; 4021 init.has_depth = true;
4163 init.request_depth = true; 4022 init.request_depth = true;
4164 init.bind_generates_resource = true; 4023 init.bind_generates_resource = true;
4165 InitDecoder(init); 4024 InitDecoder(init);
4166 4025
4167 EXPECT_CALL(*gl_, GetError()) 4026 EXPECT_CALL(*gl_, GetError())
4168 .WillOnce(Return(GL_NO_ERROR)) 4027 .WillOnce(Return(GL_NO_ERROR))
4169 .WillOnce(Return(GL_NO_ERROR)) 4028 .WillOnce(Return(GL_NO_ERROR))
4170 .RetiresOnSaturation(); 4029 .RetiresOnSaturation();
4171 typedef GetIntegerv::Result Result; 4030 typedef GetIntegerv::Result Result;
4172 Result* result = static_cast<Result*>(shared_memory_address_); 4031 Result* result = static_cast<Result*>(shared_memory_address_);
4173 EXPECT_CALL(*gl_, GetIntegerv(GL_DEPTH_BITS, _)) 4032 EXPECT_CALL(*gl_, GetIntegerv(GL_DEPTH_BITS, _))
4174 .WillOnce(SetArgumentPointee<1>(24)) 4033 .WillOnce(SetArgumentPointee<1>(24))
4175 .RetiresOnSaturation(); 4034 .RetiresOnSaturation();
4176 result->size = 0; 4035 result->size = 0;
4177 GetIntegerv cmd2; 4036 GetIntegerv cmd2;
4178 cmd2.Init(GL_DEPTH_BITS, shared_memory_id_, shared_memory_offset_); 4037 cmd2.Init(GL_DEPTH_BITS, shared_memory_id_, shared_memory_offset_);
4179 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2)); 4038 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2));
4180 EXPECT_EQ( 4039 EXPECT_EQ(
4181 decoder_->GetGLES2Util()->GLGetNumValuesReturned(GL_DEPTH_BITS), 4040 decoder_->GetGLES2Util()->GLGetNumValuesReturned(GL_DEPTH_BITS),
4182 result->GetNumResults()); 4041 result->GetNumResults());
4183 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 4042 EXPECT_EQ(GL_NO_ERROR, GetGLError());
4184 EXPECT_EQ(24, result->GetData()[0]); 4043 EXPECT_EQ(24, result->GetData()[0]);
4185 } 4044 }
4186 4045
4187 TEST_P(GLES2DecoderManualInitTest, ActualDepthDoesNotMatchRequestedDepth) { 4046 TEST_F(GLES2DecoderManualInitTest, ActualDepthDoesNotMatchRequestedDepth) {
4188 InitState init; 4047 InitState init;
4189 init.gl_version = "3.0"; 4048 init.gl_version = "3.0";
4190 init.has_depth = true; 4049 init.has_depth = true;
4191 init.bind_generates_resource = true; 4050 init.bind_generates_resource = true;
4192 InitDecoder(init); 4051 InitDecoder(init);
4193 4052
4194 EXPECT_CALL(*gl_, GetError()) 4053 EXPECT_CALL(*gl_, GetError())
4195 .WillOnce(Return(GL_NO_ERROR)) 4054 .WillOnce(Return(GL_NO_ERROR))
4196 .WillOnce(Return(GL_NO_ERROR)) 4055 .WillOnce(Return(GL_NO_ERROR))
4197 .RetiresOnSaturation(); 4056 .RetiresOnSaturation();
4198 typedef GetIntegerv::Result Result; 4057 typedef GetIntegerv::Result Result;
4199 Result* result = static_cast<Result*>(shared_memory_address_); 4058 Result* result = static_cast<Result*>(shared_memory_address_);
4200 EXPECT_CALL(*gl_, GetIntegerv(GL_DEPTH_BITS, _)) 4059 EXPECT_CALL(*gl_, GetIntegerv(GL_DEPTH_BITS, _))
4201 .WillOnce(SetArgumentPointee<1>(24)) 4060 .WillOnce(SetArgumentPointee<1>(24))
4202 .RetiresOnSaturation(); 4061 .RetiresOnSaturation();
4203 result->size = 0; 4062 result->size = 0;
4204 GetIntegerv cmd2; 4063 GetIntegerv cmd2;
4205 cmd2.Init(GL_DEPTH_BITS, shared_memory_id_, shared_memory_offset_); 4064 cmd2.Init(GL_DEPTH_BITS, shared_memory_id_, shared_memory_offset_);
4206 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2)); 4065 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2));
4207 EXPECT_EQ( 4066 EXPECT_EQ(
4208 decoder_->GetGLES2Util()->GLGetNumValuesReturned(GL_DEPTH_BITS), 4067 decoder_->GetGLES2Util()->GLGetNumValuesReturned(GL_DEPTH_BITS),
4209 result->GetNumResults()); 4068 result->GetNumResults());
4210 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 4069 EXPECT_EQ(GL_NO_ERROR, GetGLError());
4211 EXPECT_EQ(0, result->GetData()[0]); 4070 EXPECT_EQ(0, result->GetData()[0]);
4212 } 4071 }
4213 4072
4214 TEST_P(GLES2DecoderManualInitTest, ActualStencilMatchesRequestedStencil) { 4073 TEST_F(GLES2DecoderManualInitTest, ActualStencilMatchesRequestedStencil) {
4215 InitState init; 4074 InitState init;
4216 init.gl_version = "3.0"; 4075 init.gl_version = "3.0";
4217 init.has_stencil = true; 4076 init.has_stencil = true;
4218 init.request_stencil = true; 4077 init.request_stencil = true;
4219 init.bind_generates_resource = true; 4078 init.bind_generates_resource = true;
4220 InitDecoder(init); 4079 InitDecoder(init);
4221 4080
4222 EXPECT_CALL(*gl_, GetError()) 4081 EXPECT_CALL(*gl_, GetError())
4223 .WillOnce(Return(GL_NO_ERROR)) 4082 .WillOnce(Return(GL_NO_ERROR))
4224 .WillOnce(Return(GL_NO_ERROR)) 4083 .WillOnce(Return(GL_NO_ERROR))
4225 .RetiresOnSaturation(); 4084 .RetiresOnSaturation();
4226 typedef GetIntegerv::Result Result; 4085 typedef GetIntegerv::Result Result;
4227 Result* result = static_cast<Result*>(shared_memory_address_); 4086 Result* result = static_cast<Result*>(shared_memory_address_);
4228 EXPECT_CALL(*gl_, GetIntegerv(GL_STENCIL_BITS, _)) 4087 EXPECT_CALL(*gl_, GetIntegerv(GL_STENCIL_BITS, _))
4229 .WillOnce(SetArgumentPointee<1>(8)) 4088 .WillOnce(SetArgumentPointee<1>(8))
4230 .RetiresOnSaturation(); 4089 .RetiresOnSaturation();
4231 result->size = 0; 4090 result->size = 0;
4232 GetIntegerv cmd2; 4091 GetIntegerv cmd2;
4233 cmd2.Init(GL_STENCIL_BITS, shared_memory_id_, shared_memory_offset_); 4092 cmd2.Init(GL_STENCIL_BITS, shared_memory_id_, shared_memory_offset_);
4234 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2)); 4093 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2));
4235 EXPECT_EQ( 4094 EXPECT_EQ(
4236 decoder_->GetGLES2Util()->GLGetNumValuesReturned(GL_STENCIL_BITS), 4095 decoder_->GetGLES2Util()->GLGetNumValuesReturned(GL_STENCIL_BITS),
4237 result->GetNumResults()); 4096 result->GetNumResults());
4238 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 4097 EXPECT_EQ(GL_NO_ERROR, GetGLError());
4239 EXPECT_EQ(8, result->GetData()[0]); 4098 EXPECT_EQ(8, result->GetData()[0]);
4240 } 4099 }
4241 4100
4242 TEST_P(GLES2DecoderManualInitTest, ActualStencilDoesNotMatchRequestedStencil) { 4101 TEST_F(GLES2DecoderManualInitTest, ActualStencilDoesNotMatchRequestedStencil) {
4243 InitState init; 4102 InitState init;
4244 init.gl_version = "3.0"; 4103 init.gl_version = "3.0";
4245 init.has_stencil = true; 4104 init.has_stencil = true;
4246 init.bind_generates_resource = true; 4105 init.bind_generates_resource = true;
4247 InitDecoder(init); 4106 InitDecoder(init);
4248 4107
4249 EXPECT_CALL(*gl_, GetError()) 4108 EXPECT_CALL(*gl_, GetError())
4250 .WillOnce(Return(GL_NO_ERROR)) 4109 .WillOnce(Return(GL_NO_ERROR))
4251 .WillOnce(Return(GL_NO_ERROR)) 4110 .WillOnce(Return(GL_NO_ERROR))
4252 .RetiresOnSaturation(); 4111 .RetiresOnSaturation();
4253 typedef GetIntegerv::Result Result; 4112 typedef GetIntegerv::Result Result;
4254 Result* result = static_cast<Result*>(shared_memory_address_); 4113 Result* result = static_cast<Result*>(shared_memory_address_);
4255 EXPECT_CALL(*gl_, GetIntegerv(GL_STENCIL_BITS, _)) 4114 EXPECT_CALL(*gl_, GetIntegerv(GL_STENCIL_BITS, _))
4256 .WillOnce(SetArgumentPointee<1>(8)) 4115 .WillOnce(SetArgumentPointee<1>(8))
4257 .RetiresOnSaturation(); 4116 .RetiresOnSaturation();
4258 result->size = 0; 4117 result->size = 0;
4259 GetIntegerv cmd2; 4118 GetIntegerv cmd2;
4260 cmd2.Init(GL_STENCIL_BITS, shared_memory_id_, shared_memory_offset_); 4119 cmd2.Init(GL_STENCIL_BITS, shared_memory_id_, shared_memory_offset_);
4261 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2)); 4120 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2));
4262 EXPECT_EQ( 4121 EXPECT_EQ(
4263 decoder_->GetGLES2Util()->GLGetNumValuesReturned(GL_STENCIL_BITS), 4122 decoder_->GetGLES2Util()->GLGetNumValuesReturned(GL_STENCIL_BITS),
4264 result->GetNumResults()); 4123 result->GetNumResults());
4265 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 4124 EXPECT_EQ(GL_NO_ERROR, GetGLError());
4266 EXPECT_EQ(0, result->GetData()[0]); 4125 EXPECT_EQ(0, result->GetData()[0]);
4267 } 4126 }
4268 4127
4269 TEST_P(GLES2DecoderManualInitTest, DepthEnableWithDepth) { 4128 TEST_F(GLES2DecoderManualInitTest, DepthEnableWithDepth) {
4270 InitState init; 4129 InitState init;
4271 init.gl_version = "3.0"; 4130 init.gl_version = "3.0";
4272 init.has_depth = true; 4131 init.has_depth = true;
4273 init.request_depth = true; 4132 init.request_depth = true;
4274 init.bind_generates_resource = true; 4133 init.bind_generates_resource = true;
4275 InitDecoder(init); 4134 InitDecoder(init);
4276 4135
4277 Enable cmd; 4136 Enable cmd;
4278 cmd.Init(GL_DEPTH_TEST); 4137 cmd.Init(GL_DEPTH_TEST);
4279 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 4138 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
4280 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 4139 EXPECT_EQ(GL_NO_ERROR, GetGLError());
4281 4140
4282 SetupDefaultProgram(); 4141 SetupDefaultProgram();
4283 SetupTexture(); 4142 SetupTexture();
4284 AddExpectationsForSimulatedAttrib0(kNumVertices, 0); 4143 AddExpectationsForSimulatedAttrib0(kNumVertices, 0);
4285 SetupExpectationsForApplyingDirtyState(true, // Framebuffer is RGB 4144 SetupExpectationsForApplyingDirtyState(
4286 true, // Framebuffer has depth 4145 true, // Framebuffer is RGB
4287 false, // Framebuffer has stencil 4146 true, // Framebuffer has depth
4288 0x1110, // color bits 4147 false, // Framebuffer has stencil
4289 true, // depth mask 4148 0x1110, // color bits
4290 true, // depth enabled 4149 true, // depth mask
4291 0, // front stencil mask 4150 true, // depth enabled
4292 0, // back stencil mask 4151 0, // front stencil mask
4293 false); // stencil enabled 4152 0, // back stencil mask
4153 false, // stencil enabled
4154 false, // cull_face_enabled
4155 false, // scissor_test_enabled
4156 false); // blend_enabled
4157
4294 4158
4295 EXPECT_CALL(*gl_, DrawArrays(GL_TRIANGLES, 0, kNumVertices)) 4159 EXPECT_CALL(*gl_, DrawArrays(GL_TRIANGLES, 0, kNumVertices))
4296 .Times(1) 4160 .Times(1)
4297 .RetiresOnSaturation(); 4161 .RetiresOnSaturation();
4298 DrawArrays draw_cmd; 4162 DrawArrays draw_cmd;
4299 draw_cmd.Init(GL_TRIANGLES, 0, kNumVertices); 4163 draw_cmd.Init(GL_TRIANGLES, 0, kNumVertices);
4300 EXPECT_EQ(error::kNoError, ExecuteCmd(draw_cmd)); 4164 EXPECT_EQ(error::kNoError, ExecuteCmd(draw_cmd));
4301 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 4165 EXPECT_EQ(GL_NO_ERROR, GetGLError());
4302 4166
4303 EXPECT_CALL(*gl_, GetError()) 4167 EXPECT_CALL(*gl_, GetError())
4304 .WillOnce(Return(GL_NO_ERROR)) 4168 .WillOnce(Return(GL_NO_ERROR))
4305 .WillOnce(Return(GL_NO_ERROR)) 4169 .WillOnce(Return(GL_NO_ERROR))
4306 .RetiresOnSaturation(); 4170 .RetiresOnSaturation();
4307 typedef GetIntegerv::Result Result; 4171 typedef GetIntegerv::Result Result;
4308 Result* result = static_cast<Result*>(shared_memory_address_); 4172 Result* result = static_cast<Result*>(shared_memory_address_);
4309 EXPECT_CALL(*gl_, GetIntegerv(GL_DEPTH_TEST, _)) 4173 EXPECT_CALL(*gl_, GetIntegerv(GL_DEPTH_TEST, _))
4310 .Times(0) 4174 .Times(0)
4311 .RetiresOnSaturation(); 4175 .RetiresOnSaturation();
4312 result->size = 0; 4176 result->size = 0;
4313 GetIntegerv cmd2; 4177 GetIntegerv cmd2;
4314 cmd2.Init(GL_DEPTH_TEST, shared_memory_id_, shared_memory_offset_); 4178 cmd2.Init(GL_DEPTH_TEST, shared_memory_id_, shared_memory_offset_);
4315 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2)); 4179 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2));
4316 EXPECT_EQ( 4180 EXPECT_EQ(
4317 decoder_->GetGLES2Util()->GLGetNumValuesReturned(GL_DEPTH_TEST), 4181 decoder_->GetGLES2Util()->GLGetNumValuesReturned(GL_DEPTH_TEST),
4318 result->GetNumResults()); 4182 result->GetNumResults());
4319 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 4183 EXPECT_EQ(GL_NO_ERROR, GetGLError());
4320 EXPECT_EQ(1, result->GetData()[0]); 4184 EXPECT_EQ(1, result->GetData()[0]);
4321 } 4185 }
4322 4186
4323 TEST_P(GLES2DecoderManualInitTest, DepthEnableWithoutRequestedDepth) { 4187 TEST_F(GLES2DecoderManualInitTest, DepthEnableWithoutRequestedDepth) {
4324 InitState init; 4188 InitState init;
4325 init.gl_version = "3.0"; 4189 init.gl_version = "3.0";
4326 init.has_depth = true; 4190 init.has_depth = true;
4327 init.bind_generates_resource = true; 4191 init.bind_generates_resource = true;
4328 InitDecoder(init); 4192 InitDecoder(init);
4329 4193
4330 Enable cmd; 4194 Enable cmd;
4331 cmd.Init(GL_DEPTH_TEST); 4195 cmd.Init(GL_DEPTH_TEST);
4332 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 4196 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
4333 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 4197 EXPECT_EQ(GL_NO_ERROR, GetGLError());
4334 4198
4335 SetupDefaultProgram(); 4199 SetupDefaultProgram();
4336 SetupTexture(); 4200 SetupTexture();
4337 AddExpectationsForSimulatedAttrib0(kNumVertices, 0); 4201 AddExpectationsForSimulatedAttrib0(kNumVertices, 0);
4338 SetupExpectationsForApplyingDirtyState(true, // Framebuffer is RGB 4202 SetupExpectationsForApplyingDirtyState(
4339 false, // Framebuffer has depth 4203 true, // Framebuffer is RGB
4340 false, // Framebuffer has stencil 4204 false, // Framebuffer has depth
4341 0x1110, // color bits 4205 false, // Framebuffer has stencil
4342 false, // depth mask 4206 0x1110, // color bits
4343 false, // depth enabled 4207 false, // depth mask
4344 0, // front stencil mask 4208 false, // depth enabled
4345 0, // back stencil mask 4209 0, // front stencil mask
4346 false); // stencil enabled 4210 0, // back stencil mask
4211 false, // stencil enabled
4212 false, // cull_face_enabled
4213 false, // scissor_test_enabled
4214 false); // blend_enabled
4347 4215
4348 EXPECT_CALL(*gl_, DrawArrays(GL_TRIANGLES, 0, kNumVertices)) 4216 EXPECT_CALL(*gl_, DrawArrays(GL_TRIANGLES, 0, kNumVertices))
4349 .Times(1) 4217 .Times(1)
4350 .RetiresOnSaturation(); 4218 .RetiresOnSaturation();
4351 DrawArrays draw_cmd; 4219 DrawArrays draw_cmd;
4352 draw_cmd.Init(GL_TRIANGLES, 0, kNumVertices); 4220 draw_cmd.Init(GL_TRIANGLES, 0, kNumVertices);
4353 EXPECT_EQ(error::kNoError, ExecuteCmd(draw_cmd)); 4221 EXPECT_EQ(error::kNoError, ExecuteCmd(draw_cmd));
4354 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 4222 EXPECT_EQ(GL_NO_ERROR, GetGLError());
4355 4223
4356 EXPECT_CALL(*gl_, GetError()) 4224 EXPECT_CALL(*gl_, GetError())
4357 .WillOnce(Return(GL_NO_ERROR)) 4225 .WillOnce(Return(GL_NO_ERROR))
4358 .WillOnce(Return(GL_NO_ERROR)) 4226 .WillOnce(Return(GL_NO_ERROR))
4359 .RetiresOnSaturation(); 4227 .RetiresOnSaturation();
4360 typedef GetIntegerv::Result Result; 4228 typedef GetIntegerv::Result Result;
4361 Result* result = static_cast<Result*>(shared_memory_address_); 4229 Result* result = static_cast<Result*>(shared_memory_address_);
4362 EXPECT_CALL(*gl_, GetIntegerv(GL_DEPTH_TEST, _)) 4230 EXPECT_CALL(*gl_, GetIntegerv(GL_DEPTH_TEST, _))
4363 .Times(0) 4231 .Times(0)
4364 .RetiresOnSaturation(); 4232 .RetiresOnSaturation();
4365 result->size = 0; 4233 result->size = 0;
4366 GetIntegerv cmd2; 4234 GetIntegerv cmd2;
4367 cmd2.Init(GL_DEPTH_TEST, shared_memory_id_, shared_memory_offset_); 4235 cmd2.Init(GL_DEPTH_TEST, shared_memory_id_, shared_memory_offset_);
4368 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2)); 4236 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2));
4369 EXPECT_EQ( 4237 EXPECT_EQ(
4370 decoder_->GetGLES2Util()->GLGetNumValuesReturned(GL_DEPTH_TEST), 4238 decoder_->GetGLES2Util()->GLGetNumValuesReturned(GL_DEPTH_TEST),
4371 result->GetNumResults()); 4239 result->GetNumResults());
4372 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 4240 EXPECT_EQ(GL_NO_ERROR, GetGLError());
4373 EXPECT_EQ(1, result->GetData()[0]); 4241 EXPECT_EQ(1, result->GetData()[0]);
4374 } 4242 }
4375 4243
4376 TEST_P(GLES2DecoderManualInitTest, StencilEnableWithStencil) { 4244 TEST_F(GLES2DecoderManualInitTest, StencilEnableWithStencil) {
4377 InitState init; 4245 InitState init;
4378 init.gl_version = "3.0"; 4246 init.gl_version = "3.0";
4379 init.has_stencil = true; 4247 init.has_stencil = true;
4380 init.request_stencil = true; 4248 init.request_stencil = true;
4381 init.bind_generates_resource = true; 4249 init.bind_generates_resource = true;
4382 InitDecoder(init); 4250 InitDecoder(init);
4383 4251
4384 Enable cmd; 4252 Enable cmd;
4385 cmd.Init(GL_STENCIL_TEST); 4253 cmd.Init(GL_STENCIL_TEST);
4386 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 4254 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
4387 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 4255 EXPECT_EQ(GL_NO_ERROR, GetGLError());
4388 4256
4389 SetupDefaultProgram(); 4257 SetupDefaultProgram();
4390 SetupTexture(); 4258 SetupTexture();
4391 AddExpectationsForSimulatedAttrib0(kNumVertices, 0); 4259 AddExpectationsForSimulatedAttrib0(kNumVertices, 0);
4392 SetupExpectationsForApplyingDirtyState(true, // Framebuffer is RGB 4260 SetupExpectationsForApplyingDirtyState(
4393 false, // Framebuffer has depth 4261 true, // Framebuffer is RGB
4394 true, // Framebuffer has stencil 4262 false, // Framebuffer has depth
4395 0x1110, // color bits 4263 true, // Framebuffer has stencil
4396 false, // depth mask 4264 0x1110, // color bits
4397 false, // depth enabled 4265 false, // depth mask
4398 -1, // front stencil mask 4266 false, // depth enabled
4399 -1, // back stencil mask 4267 -1, // front stencil mask
4400 true); // stencil enabled 4268 -1, // back stencil mask
4269 true, // stencil enabled
4270 false, // cull_face_enabled
4271 false, // scissor_test_enabled
4272 false); // blend_enabled
4401 4273
4402 EXPECT_CALL(*gl_, DrawArrays(GL_TRIANGLES, 0, kNumVertices)) 4274 EXPECT_CALL(*gl_, DrawArrays(GL_TRIANGLES, 0, kNumVertices))
4403 .Times(1) 4275 .Times(1)
4404 .RetiresOnSaturation(); 4276 .RetiresOnSaturation();
4405 DrawArrays draw_cmd; 4277 DrawArrays draw_cmd;
4406 draw_cmd.Init(GL_TRIANGLES, 0, kNumVertices); 4278 draw_cmd.Init(GL_TRIANGLES, 0, kNumVertices);
4407 EXPECT_EQ(error::kNoError, ExecuteCmd(draw_cmd)); 4279 EXPECT_EQ(error::kNoError, ExecuteCmd(draw_cmd));
4408 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 4280 EXPECT_EQ(GL_NO_ERROR, GetGLError());
4409 4281
4410 EXPECT_CALL(*gl_, GetError()) 4282 EXPECT_CALL(*gl_, GetError())
4411 .WillOnce(Return(GL_NO_ERROR)) 4283 .WillOnce(Return(GL_NO_ERROR))
4412 .WillOnce(Return(GL_NO_ERROR)) 4284 .WillOnce(Return(GL_NO_ERROR))
4413 .RetiresOnSaturation(); 4285 .RetiresOnSaturation();
4414 typedef GetIntegerv::Result Result; 4286 typedef GetIntegerv::Result Result;
4415 Result* result = static_cast<Result*>(shared_memory_address_); 4287 Result* result = static_cast<Result*>(shared_memory_address_);
4416 EXPECT_CALL(*gl_, GetIntegerv(GL_STENCIL_TEST, _)) 4288 EXPECT_CALL(*gl_, GetIntegerv(GL_STENCIL_TEST, _))
4417 .Times(0) 4289 .Times(0)
4418 .RetiresOnSaturation(); 4290 .RetiresOnSaturation();
4419 result->size = 0; 4291 result->size = 0;
4420 GetIntegerv cmd2; 4292 GetIntegerv cmd2;
4421 cmd2.Init(GL_STENCIL_TEST, shared_memory_id_, shared_memory_offset_); 4293 cmd2.Init(GL_STENCIL_TEST, shared_memory_id_, shared_memory_offset_);
4422 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2)); 4294 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2));
4423 EXPECT_EQ( 4295 EXPECT_EQ(
4424 decoder_->GetGLES2Util()->GLGetNumValuesReturned(GL_STENCIL_TEST), 4296 decoder_->GetGLES2Util()->GLGetNumValuesReturned(GL_STENCIL_TEST),
4425 result->GetNumResults()); 4297 result->GetNumResults());
4426 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 4298 EXPECT_EQ(GL_NO_ERROR, GetGLError());
4427 EXPECT_EQ(1, result->GetData()[0]); 4299 EXPECT_EQ(1, result->GetData()[0]);
4428 } 4300 }
4429 4301
4430 TEST_P(GLES2DecoderManualInitTest, StencilEnableWithoutRequestedStencil) { 4302 TEST_F(GLES2DecoderManualInitTest, StencilEnableWithoutRequestedStencil) {
4431 InitState init; 4303 InitState init;
4432 init.gl_version = "3.0"; 4304 init.gl_version = "3.0";
4433 init.has_stencil = true; 4305 init.has_stencil = true;
4434 init.bind_generates_resource = true; 4306 init.bind_generates_resource = true;
4435 InitDecoder(init); 4307 InitDecoder(init);
4436 4308
4437 Enable cmd; 4309 Enable cmd;
4438 cmd.Init(GL_STENCIL_TEST); 4310 cmd.Init(GL_STENCIL_TEST);
4439 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 4311 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
4440 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 4312 EXPECT_EQ(GL_NO_ERROR, GetGLError());
4441 4313
4442 SetupDefaultProgram(); 4314 SetupDefaultProgram();
4443 SetupTexture(); 4315 SetupTexture();
4444 AddExpectationsForSimulatedAttrib0(kNumVertices, 0); 4316 AddExpectationsForSimulatedAttrib0(kNumVertices, 0);
4445 SetupExpectationsForApplyingDirtyState(true, // Framebuffer is RGB 4317 SetupExpectationsForApplyingDirtyState(
4446 false, // Framebuffer has depth 4318 true, // Framebuffer is RGB
4447 false, // Framebuffer has stencil 4319 false, // Framebuffer has depth
4448 0x1110, // color bits 4320 false, // Framebuffer has stencil
4449 false, // depth mask 4321 0x1110, // color bits
4450 false, // depth enabled 4322 false, // depth mask
4451 0, // front stencil mask 4323 false, // depth enabled
4452 0, // back stencil mask 4324 0, // front stencil mask
4453 false); // stencil enabled 4325 0, // back stencil mask
4326 false, // stencil enabled
4327 false, // cull_face_enabled
4328 false, // scissor_test_enabled
4329 false); // blend_enabled
4454 4330
4455 EXPECT_CALL(*gl_, DrawArrays(GL_TRIANGLES, 0, kNumVertices)) 4331 EXPECT_CALL(*gl_, DrawArrays(GL_TRIANGLES, 0, kNumVertices))
4456 .Times(1) 4332 .Times(1)
4457 .RetiresOnSaturation(); 4333 .RetiresOnSaturation();
4458 DrawArrays draw_cmd; 4334 DrawArrays draw_cmd;
4459 draw_cmd.Init(GL_TRIANGLES, 0, kNumVertices); 4335 draw_cmd.Init(GL_TRIANGLES, 0, kNumVertices);
4460 EXPECT_EQ(error::kNoError, ExecuteCmd(draw_cmd)); 4336 EXPECT_EQ(error::kNoError, ExecuteCmd(draw_cmd));
4461 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 4337 EXPECT_EQ(GL_NO_ERROR, GetGLError());
4462 4338
4463 EXPECT_CALL(*gl_, GetError()) 4339 EXPECT_CALL(*gl_, GetError())
4464 .WillOnce(Return(GL_NO_ERROR)) 4340 .WillOnce(Return(GL_NO_ERROR))
4465 .WillOnce(Return(GL_NO_ERROR)) 4341 .WillOnce(Return(GL_NO_ERROR))
4466 .RetiresOnSaturation(); 4342 .RetiresOnSaturation();
4467 typedef GetIntegerv::Result Result; 4343 typedef GetIntegerv::Result Result;
4468 Result* result = static_cast<Result*>(shared_memory_address_); 4344 Result* result = static_cast<Result*>(shared_memory_address_);
4469 EXPECT_CALL(*gl_, GetIntegerv(GL_STENCIL_TEST, _)) 4345 EXPECT_CALL(*gl_, GetIntegerv(GL_STENCIL_TEST, _))
4470 .Times(0) 4346 .Times(0)
4471 .RetiresOnSaturation(); 4347 .RetiresOnSaturation();
4472 result->size = 0; 4348 result->size = 0;
4473 GetIntegerv cmd2; 4349 GetIntegerv cmd2;
4474 cmd2.Init(GL_STENCIL_TEST, shared_memory_id_, shared_memory_offset_); 4350 cmd2.Init(GL_STENCIL_TEST, shared_memory_id_, shared_memory_offset_);
4475 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2)); 4351 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2));
4476 EXPECT_EQ( 4352 EXPECT_EQ(
4477 decoder_->GetGLES2Util()->GLGetNumValuesReturned(GL_STENCIL_TEST), 4353 decoder_->GetGLES2Util()->GLGetNumValuesReturned(GL_STENCIL_TEST),
4478 result->GetNumResults()); 4354 result->GetNumResults());
4479 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 4355 EXPECT_EQ(GL_NO_ERROR, GetGLError());
4480 EXPECT_EQ(1, result->GetData()[0]); 4356 EXPECT_EQ(1, result->GetData()[0]);
4481 } 4357 }
4482 4358
4483 TEST_P(GLES2DecoderManualInitTest, PackedDepthStencilReportsCorrectValues) { 4359 TEST_F(GLES2DecoderManualInitTest, PackedDepthStencilReportsCorrectValues) {
4484 InitState init; 4360 InitState init;
4485 init.extensions = "GL_OES_packed_depth_stencil"; 4361 init.extensions = "GL_OES_packed_depth_stencil";
4486 init.gl_version = "opengl es 2.0"; 4362 init.gl_version = "opengl es 2.0";
4487 init.has_depth = true; 4363 init.has_depth = true;
4488 init.has_stencil = true; 4364 init.has_stencil = true;
4489 init.request_depth = true; 4365 init.request_depth = true;
4490 init.request_stencil = true; 4366 init.request_stencil = true;
4491 init.bind_generates_resource = true; 4367 init.bind_generates_resource = true;
4492 InitDecoder(init); 4368 InitDecoder(init);
4493 4369
(...skipping 23 matching lines...) Expand all
4517 .WillOnce(SetArgumentPointee<1>(24)) 4393 .WillOnce(SetArgumentPointee<1>(24))
4518 .RetiresOnSaturation(); 4394 .RetiresOnSaturation();
4519 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2)); 4395 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2));
4520 EXPECT_EQ( 4396 EXPECT_EQ(
4521 decoder_->GetGLES2Util()->GLGetNumValuesReturned(GL_DEPTH_BITS), 4397 decoder_->GetGLES2Util()->GLGetNumValuesReturned(GL_DEPTH_BITS),
4522 result->GetNumResults()); 4398 result->GetNumResults());
4523 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 4399 EXPECT_EQ(GL_NO_ERROR, GetGLError());
4524 EXPECT_EQ(24, result->GetData()[0]); 4400 EXPECT_EQ(24, result->GetData()[0]);
4525 } 4401 }
4526 4402
4527 TEST_P(GLES2DecoderManualInitTest, PackedDepthStencilNoRequestedStencil) { 4403 TEST_F(GLES2DecoderManualInitTest, PackedDepthStencilNoRequestedStencil) {
4528 InitState init; 4404 InitState init;
4529 init.extensions = "GL_OES_packed_depth_stencil"; 4405 init.extensions = "GL_OES_packed_depth_stencil";
4530 init.gl_version = "opengl es 2.0"; 4406 init.gl_version = "opengl es 2.0";
4531 init.has_depth = true; 4407 init.has_depth = true;
4532 init.has_stencil = true; 4408 init.has_stencil = true;
4533 init.request_depth = true; 4409 init.request_depth = true;
4534 init.bind_generates_resource = true; 4410 init.bind_generates_resource = true;
4535 InitDecoder(init); 4411 InitDecoder(init);
4536 4412
4537 EXPECT_CALL(*gl_, GetError()) 4413 EXPECT_CALL(*gl_, GetError())
(...skipping 22 matching lines...) Expand all
4560 .WillOnce(SetArgumentPointee<1>(24)) 4436 .WillOnce(SetArgumentPointee<1>(24))
4561 .RetiresOnSaturation(); 4437 .RetiresOnSaturation();
4562 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2)); 4438 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2));
4563 EXPECT_EQ( 4439 EXPECT_EQ(
4564 decoder_->GetGLES2Util()->GLGetNumValuesReturned(GL_DEPTH_BITS), 4440 decoder_->GetGLES2Util()->GLGetNumValuesReturned(GL_DEPTH_BITS),
4565 result->GetNumResults()); 4441 result->GetNumResults());
4566 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 4442 EXPECT_EQ(GL_NO_ERROR, GetGLError());
4567 EXPECT_EQ(24, result->GetData()[0]); 4443 EXPECT_EQ(24, result->GetData()[0]);
4568 } 4444 }
4569 4445
4570 TEST_P(GLES2DecoderManualInitTest, PackedDepthStencilRenderbufferDepth) { 4446 TEST_F(GLES2DecoderManualInitTest, PackedDepthStencilRenderbufferDepth) {
4571 InitState init; 4447 InitState init;
4572 init.extensions = "GL_OES_packed_depth_stencil"; 4448 init.extensions = "GL_OES_packed_depth_stencil";
4573 init.gl_version = "opengl es 2.0"; 4449 init.gl_version = "opengl es 2.0";
4574 init.bind_generates_resource = true; 4450 init.bind_generates_resource = true;
4575 InitDecoder(init); 4451 InitDecoder(init);
4576 DoBindRenderbuffer(GL_RENDERBUFFER, client_renderbuffer_id_, 4452 DoBindRenderbuffer(GL_RENDERBUFFER, client_renderbuffer_id_,
4577 kServiceRenderbufferId); 4453 kServiceRenderbufferId);
4578 DoBindFramebuffer(GL_FRAMEBUFFER, client_framebuffer_id_, 4454 DoBindFramebuffer(GL_FRAMEBUFFER, client_framebuffer_id_,
4579 kServiceFramebufferId); 4455 kServiceFramebufferId);
4580 4456
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
4627 .WillOnce(SetArgumentPointee<1>(24)) 4503 .WillOnce(SetArgumentPointee<1>(24))
4628 .RetiresOnSaturation(); 4504 .RetiresOnSaturation();
4629 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2)); 4505 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2));
4630 EXPECT_EQ( 4506 EXPECT_EQ(
4631 decoder_->GetGLES2Util()->GLGetNumValuesReturned(GL_DEPTH_BITS), 4507 decoder_->GetGLES2Util()->GLGetNumValuesReturned(GL_DEPTH_BITS),
4632 result->GetNumResults()); 4508 result->GetNumResults());
4633 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 4509 EXPECT_EQ(GL_NO_ERROR, GetGLError());
4634 EXPECT_EQ(24, result->GetData()[0]); 4510 EXPECT_EQ(24, result->GetData()[0]);
4635 } 4511 }
4636 4512
4637 TEST_P(GLES2DecoderManualInitTest, PackedDepthStencilRenderbufferStencil) { 4513 TEST_F(GLES2DecoderManualInitTest, PackedDepthStencilRenderbufferStencil) {
4638 InitState init; 4514 InitState init;
4639 init.extensions = "GL_OES_packed_depth_stencil"; 4515 init.extensions = "GL_OES_packed_depth_stencil";
4640 init.gl_version = "opengl es 2.0"; 4516 init.gl_version = "opengl es 2.0";
4641 init.bind_generates_resource = true; 4517 init.bind_generates_resource = true;
4642 InitDecoder(init); 4518 InitDecoder(init);
4643 DoBindRenderbuffer(GL_RENDERBUFFER, client_renderbuffer_id_, 4519 DoBindRenderbuffer(GL_RENDERBUFFER, client_renderbuffer_id_,
4644 kServiceRenderbufferId); 4520 kServiceRenderbufferId);
4645 DoBindFramebuffer(GL_FRAMEBUFFER, client_framebuffer_id_, 4521 DoBindFramebuffer(GL_FRAMEBUFFER, client_framebuffer_id_,
4646 kServiceFramebufferId); 4522 kServiceFramebufferId);
4647 4523
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
4694 .WillOnce(SetArgumentPointee<1>(24)) 4570 .WillOnce(SetArgumentPointee<1>(24))
4695 .RetiresOnSaturation(); 4571 .RetiresOnSaturation();
4696 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2)); 4572 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2));
4697 EXPECT_EQ( 4573 EXPECT_EQ(
4698 decoder_->GetGLES2Util()->GLGetNumValuesReturned(GL_DEPTH_BITS), 4574 decoder_->GetGLES2Util()->GLGetNumValuesReturned(GL_DEPTH_BITS),
4699 result->GetNumResults()); 4575 result->GetNumResults());
4700 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 4576 EXPECT_EQ(GL_NO_ERROR, GetGLError());
4701 EXPECT_EQ(0, result->GetData()[0]); 4577 EXPECT_EQ(0, result->GetData()[0]);
4702 } 4578 }
4703 4579
4704 TEST_P(GLES2DecoderTest, GetMultipleIntegervCHROMIUMValidArgs) { 4580 TEST_F(GLES2DecoderTest, GetMultipleIntegervCHROMIUMValidArgs) {
4705 const GLsizei kCount = 3; 4581 const GLsizei kCount = 3;
4706 GLenum* pnames = GetSharedMemoryAs<GLenum*>(); 4582 GLenum* pnames = GetSharedMemoryAs<GLenum*>();
4707 pnames[0] = GL_DEPTH_WRITEMASK; 4583 pnames[0] = GL_DEPTH_WRITEMASK;
4708 pnames[1] = GL_COLOR_WRITEMASK; 4584 pnames[1] = GL_COLOR_WRITEMASK;
4709 pnames[2] = GL_STENCIL_WRITEMASK; 4585 pnames[2] = GL_STENCIL_WRITEMASK;
4710 GLint* results = 4586 GLint* results =
4711 GetSharedMemoryAsWithOffset<GLint*>(sizeof(*pnames) * kCount); 4587 GetSharedMemoryAsWithOffset<GLint*>(sizeof(*pnames) * kCount);
4712 4588
4713 GLsizei num_results = 0; 4589 GLsizei num_results = 0;
4714 for (GLsizei ii = 0; ii < kCount; ++ii) { 4590 for (GLsizei ii = 0; ii < kCount; ++ii) {
(...skipping 15 matching lines...) Expand all
4730 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 4606 EXPECT_EQ(GL_NO_ERROR, GetGLError());
4731 EXPECT_EQ(1, results[0]); // Depth writemask 4607 EXPECT_EQ(1, results[0]); // Depth writemask
4732 EXPECT_EQ(1, results[1]); // color writemask red 4608 EXPECT_EQ(1, results[1]); // color writemask red
4733 EXPECT_EQ(1, results[2]); // color writemask green 4609 EXPECT_EQ(1, results[2]); // color writemask green
4734 EXPECT_EQ(1, results[3]); // color writemask blue 4610 EXPECT_EQ(1, results[3]); // color writemask blue
4735 EXPECT_EQ(1, results[4]); // color writemask alpha 4611 EXPECT_EQ(1, results[4]); // color writemask alpha
4736 EXPECT_EQ(-1, results[5]); // stencil writemask alpha 4612 EXPECT_EQ(-1, results[5]); // stencil writemask alpha
4737 EXPECT_EQ(kSentinel, results[num_results]); // End of results 4613 EXPECT_EQ(kSentinel, results[num_results]); // End of results
4738 } 4614 }
4739 4615
4740 TEST_P(GLES2DecoderTest, GetMultipleIntegervCHROMIUMInvalidArgs) { 4616 TEST_F(GLES2DecoderTest, GetMultipleIntegervCHROMIUMInvalidArgs) {
4741 const GLsizei kCount = 3; 4617 const GLsizei kCount = 3;
4742 // Offset the pnames because GLGetError will use the first uint32. 4618 // Offset the pnames because GLGetError will use the first uint32.
4743 const uint32 kPnameOffset = sizeof(uint32); 4619 const uint32 kPnameOffset = sizeof(uint32);
4744 const uint32 kResultsOffset = kPnameOffset + sizeof(GLint) * kCount; 4620 const uint32 kResultsOffset = kPnameOffset + sizeof(GLint) * kCount;
4745 GLenum* pnames = GetSharedMemoryAsWithOffset<GLenum*>(kPnameOffset); 4621 GLenum* pnames = GetSharedMemoryAsWithOffset<GLenum*>(kPnameOffset);
4746 pnames[0] = GL_DEPTH_WRITEMASK; 4622 pnames[0] = GL_DEPTH_WRITEMASK;
4747 pnames[1] = GL_COLOR_WRITEMASK; 4623 pnames[1] = GL_COLOR_WRITEMASK;
4748 pnames[2] = GL_STENCIL_WRITEMASK; 4624 pnames[2] = GL_STENCIL_WRITEMASK;
4749 GLint* results = GetSharedMemoryAsWithOffset<GLint*>(kResultsOffset); 4625 GLint* results = GetSharedMemoryAsWithOffset<GLint*>(kResultsOffset);
4750 4626
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
4824 // Check buffer is what we expect 4700 // Check buffer is what we expect
4825 EXPECT_EQ(0, results[0]); 4701 EXPECT_EQ(0, results[0]);
4826 EXPECT_EQ(1, results[1]); 4702 EXPECT_EQ(1, results[1]);
4827 EXPECT_EQ(0, results[2]); 4703 EXPECT_EQ(0, results[2]);
4828 EXPECT_EQ(0, results[3]); 4704 EXPECT_EQ(0, results[3]);
4829 EXPECT_EQ(0, results[4]); 4705 EXPECT_EQ(0, results[4]);
4830 EXPECT_EQ(0, results[5]); 4706 EXPECT_EQ(0, results[5]);
4831 EXPECT_EQ(kSentinel, results[num_results]); // End of results 4707 EXPECT_EQ(kSentinel, results[num_results]); // End of results
4832 } 4708 }
4833 4709
4834 TEST_P(GLES2DecoderTest, TexImage2DRedefinitionSucceeds) { 4710 TEST_F(GLES2DecoderTest, TexImage2DRedefinitionSucceeds) {
4835 const int kWidth = 16; 4711 const int kWidth = 16;
4836 const int kHeight = 8; 4712 const int kHeight = 8;
4837 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); 4713 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId);
4838 EXPECT_CALL(*gl_, GetError()) 4714 EXPECT_CALL(*gl_, GetError())
4839 .WillRepeatedly(Return(GL_NO_ERROR)); 4715 .WillRepeatedly(Return(GL_NO_ERROR));
4840 for (int ii = 0; ii < 2; ++ii) { 4716 for (int ii = 0; ii < 2; ++ii) {
4841 TexImage2D cmd; 4717 TexImage2D cmd;
4842 if (ii == 0) { 4718 if (ii == 0) {
4843 EXPECT_CALL(*gl_, TexImage2D( 4719 EXPECT_CALL(*gl_, TexImage2D(
4844 GL_TEXTURE_2D, 0, GL_RGBA, kWidth, kHeight, 0, GL_RGBA, 4720 GL_TEXTURE_2D, 0, GL_RGBA, kWidth, kHeight, 0, GL_RGBA,
(...skipping 21 matching lines...) Expand all
4866 // (last GL_TRUE argument). It will be skipped if there are bugs in the 4742 // (last GL_TRUE argument). It will be skipped if there are bugs in the
4867 // redefinition case. 4743 // redefinition case.
4868 TexSubImage2D cmd2; 4744 TexSubImage2D cmd2;
4869 cmd2.Init( 4745 cmd2.Init(
4870 GL_TEXTURE_2D, 0, 0, 0, kWidth, kHeight - 1, GL_RGBA, GL_UNSIGNED_BYTE, 4746 GL_TEXTURE_2D, 0, 0, 0, kWidth, kHeight - 1, GL_RGBA, GL_UNSIGNED_BYTE,
4871 kSharedMemoryId, kSharedMemoryOffset, GL_TRUE); 4747 kSharedMemoryId, kSharedMemoryOffset, GL_TRUE);
4872 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2)); 4748 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2));
4873 } 4749 }
4874 } 4750 }
4875 4751
4876 TEST_P(GLES2DecoderTest, TexImage2DGLError) { 4752 TEST_F(GLES2DecoderTest, TexImage2DGLError) {
4877 GLenum target = GL_TEXTURE_2D; 4753 GLenum target = GL_TEXTURE_2D;
4878 GLint level = 0; 4754 GLint level = 0;
4879 GLenum internal_format = GL_RGBA; 4755 GLenum internal_format = GL_RGBA;
4880 GLsizei width = 2; 4756 GLsizei width = 2;
4881 GLsizei height = 4; 4757 GLsizei height = 4;
4882 GLint border = 0; 4758 GLint border = 0;
4883 GLenum format = GL_RGBA; 4759 GLenum format = GL_RGBA;
4884 GLenum type = GL_UNSIGNED_BYTE; 4760 GLenum type = GL_UNSIGNED_BYTE;
4885 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); 4761 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId);
4886 TextureManager* manager = group().texture_manager(); 4762 TextureManager* manager = group().texture_manager();
(...skipping 10 matching lines...) Expand all
4897 .Times(1) 4773 .Times(1)
4898 .RetiresOnSaturation(); 4774 .RetiresOnSaturation();
4899 TexImage2D cmd; 4775 TexImage2D cmd;
4900 cmd.Init(target, level, internal_format, width, height, border, format, 4776 cmd.Init(target, level, internal_format, width, height, border, format,
4901 type, kSharedMemoryId, kSharedMemoryOffset); 4777 type, kSharedMemoryId, kSharedMemoryOffset);
4902 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 4778 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
4903 EXPECT_EQ(GL_OUT_OF_MEMORY, GetGLError()); 4779 EXPECT_EQ(GL_OUT_OF_MEMORY, GetGLError());
4904 EXPECT_FALSE(texture->GetLevelSize(GL_TEXTURE_2D, level, &width, &height)); 4780 EXPECT_FALSE(texture->GetLevelSize(GL_TEXTURE_2D, level, &width, &height));
4905 } 4781 }
4906 4782
4907 TEST_P(GLES2DecoderTest, BufferDataGLError) { 4783 TEST_F(GLES2DecoderTest, BufferDataGLError) {
4908 GLenum target = GL_ARRAY_BUFFER; 4784 GLenum target = GL_ARRAY_BUFFER;
4909 GLsizeiptr size = 4; 4785 GLsizeiptr size = 4;
4910 DoBindBuffer(GL_ARRAY_BUFFER, client_buffer_id_, kServiceBufferId); 4786 DoBindBuffer(GL_ARRAY_BUFFER, client_buffer_id_, kServiceBufferId);
4911 BufferManager* manager = group().buffer_manager(); 4787 BufferManager* manager = group().buffer_manager();
4912 Buffer* buffer = manager->GetBuffer(client_buffer_id_); 4788 Buffer* buffer = manager->GetBuffer(client_buffer_id_);
4913 ASSERT_TRUE(buffer != NULL); 4789 ASSERT_TRUE(buffer != NULL);
4914 EXPECT_EQ(0, buffer->size()); 4790 EXPECT_EQ(0, buffer->size());
4915 EXPECT_CALL(*gl_, GetError()) 4791 EXPECT_CALL(*gl_, GetError())
4916 .WillOnce(Return(GL_NO_ERROR)) 4792 .WillOnce(Return(GL_NO_ERROR))
4917 .WillOnce(Return(GL_OUT_OF_MEMORY)) 4793 .WillOnce(Return(GL_OUT_OF_MEMORY))
4918 .RetiresOnSaturation(); 4794 .RetiresOnSaturation();
4919 EXPECT_CALL(*gl_, BufferData(target, size, _, GL_STREAM_DRAW)) 4795 EXPECT_CALL(*gl_, BufferData(target, size, _, GL_STREAM_DRAW))
4920 .Times(1) 4796 .Times(1)
4921 .RetiresOnSaturation(); 4797 .RetiresOnSaturation();
4922 BufferData cmd; 4798 BufferData cmd;
4923 cmd.Init(target, size, 0, 0, GL_STREAM_DRAW); 4799 cmd.Init(target, size, 0, 0, GL_STREAM_DRAW);
4924 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 4800 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
4925 EXPECT_EQ(GL_OUT_OF_MEMORY, GetGLError()); 4801 EXPECT_EQ(GL_OUT_OF_MEMORY, GetGLError());
4926 EXPECT_EQ(0, buffer->size()); 4802 EXPECT_EQ(0, buffer->size());
4927 } 4803 }
4928 4804
4929 TEST_P(GLES2DecoderTest, CopyTexImage2DGLError) { 4805 TEST_F(GLES2DecoderTest, CopyTexImage2DGLError) {
4930 GLenum target = GL_TEXTURE_2D; 4806 GLenum target = GL_TEXTURE_2D;
4931 GLint level = 0; 4807 GLint level = 0;
4932 GLenum internal_format = GL_RGBA; 4808 GLenum internal_format = GL_RGBA;
4933 GLsizei width = 2; 4809 GLsizei width = 2;
4934 GLsizei height = 4; 4810 GLsizei height = 4;
4935 GLint border = 0; 4811 GLint border = 0;
4936 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); 4812 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId);
4937 TextureManager* manager = group().texture_manager(); 4813 TextureManager* manager = group().texture_manager();
4938 TextureRef* texture_ref = manager->GetTexture(client_texture_id_); 4814 TextureRef* texture_ref = manager->GetTexture(client_texture_id_);
4939 ASSERT_TRUE(texture_ref != NULL); 4815 ASSERT_TRUE(texture_ref != NULL);
4940 Texture* texture = texture_ref->texture(); 4816 Texture* texture = texture_ref->texture();
4941 EXPECT_FALSE(texture->GetLevelSize(GL_TEXTURE_2D, level, &width, &height)); 4817 EXPECT_FALSE(texture->GetLevelSize(GL_TEXTURE_2D, level, &width, &height));
4942 EXPECT_CALL(*gl_, GetError()) 4818 EXPECT_CALL(*gl_, GetError())
4943 .WillOnce(Return(GL_NO_ERROR)) 4819 .WillOnce(Return(GL_NO_ERROR))
4944 .WillOnce(Return(GL_OUT_OF_MEMORY)) 4820 .WillOnce(Return(GL_OUT_OF_MEMORY))
4945 .RetiresOnSaturation(); 4821 .RetiresOnSaturation();
4946 EXPECT_CALL(*gl_, CopyTexImage2D( 4822 EXPECT_CALL(*gl_, CopyTexImage2D(
4947 target, level, internal_format, 0, 0, width, height, border)) 4823 target, level, internal_format, 0, 0, width, height, border))
4948 .Times(1) 4824 .Times(1)
4949 .RetiresOnSaturation(); 4825 .RetiresOnSaturation();
4950 CopyTexImage2D cmd; 4826 CopyTexImage2D cmd;
4951 cmd.Init(target, level, internal_format, 0, 0, width, height, border); 4827 cmd.Init(target, level, internal_format, 0, 0, width, height, border);
4952 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 4828 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
4953 EXPECT_EQ(GL_OUT_OF_MEMORY, GetGLError()); 4829 EXPECT_EQ(GL_OUT_OF_MEMORY, GetGLError());
4954 EXPECT_FALSE(texture->GetLevelSize(GL_TEXTURE_2D, level, &width, &height)); 4830 EXPECT_FALSE(texture->GetLevelSize(GL_TEXTURE_2D, level, &width, &height));
4955 } 4831 }
4956 4832
4957 TEST_P(GLES2DecoderTest, FramebufferRenderbufferGLError) { 4833 TEST_F(GLES2DecoderTest, FramebufferRenderbufferGLError) {
4958 DoBindFramebuffer(GL_FRAMEBUFFER, client_framebuffer_id_, 4834 DoBindFramebuffer(GL_FRAMEBUFFER, client_framebuffer_id_,
4959 kServiceFramebufferId); 4835 kServiceFramebufferId);
4960 EXPECT_CALL(*gl_, GetError()) 4836 EXPECT_CALL(*gl_, GetError())
4961 .WillOnce(Return(GL_NO_ERROR)) 4837 .WillOnce(Return(GL_NO_ERROR))
4962 .WillOnce(Return(GL_OUT_OF_MEMORY)) 4838 .WillOnce(Return(GL_OUT_OF_MEMORY))
4963 .RetiresOnSaturation(); 4839 .RetiresOnSaturation();
4964 EXPECT_CALL(*gl_, FramebufferRenderbufferEXT( 4840 EXPECT_CALL(*gl_, FramebufferRenderbufferEXT(
4965 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, 4841 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER,
4966 kServiceRenderbufferId)) 4842 kServiceRenderbufferId))
4967 .Times(1) 4843 .Times(1)
4968 .RetiresOnSaturation(); 4844 .RetiresOnSaturation();
4969 FramebufferRenderbuffer cmd; 4845 FramebufferRenderbuffer cmd;
4970 cmd.Init( 4846 cmd.Init(
4971 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, 4847 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER,
4972 client_renderbuffer_id_); 4848 client_renderbuffer_id_);
4973 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 4849 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
4974 EXPECT_EQ(GL_OUT_OF_MEMORY, GetGLError()); 4850 EXPECT_EQ(GL_OUT_OF_MEMORY, GetGLError());
4975 } 4851 }
4976 4852
4977 TEST_P(GLES2DecoderTest, FramebufferTexture2DGLError) { 4853 TEST_F(GLES2DecoderTest, FramebufferTexture2DGLError) {
4978 const GLsizei kWidth = 5; 4854 const GLsizei kWidth = 5;
4979 const GLsizei kHeight = 3; 4855 const GLsizei kHeight = 3;
4980 const GLenum kFormat = GL_RGB; 4856 const GLenum kFormat = GL_RGB;
4981 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); 4857 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId);
4982 DoTexImage2D(GL_TEXTURE_2D, 0, kFormat, kWidth, kHeight, 0, 4858 DoTexImage2D(GL_TEXTURE_2D, 0, kFormat, kWidth, kHeight, 0,
4983 kFormat, GL_UNSIGNED_BYTE, 0, 0); 4859 kFormat, GL_UNSIGNED_BYTE, 0, 0);
4984 DoBindFramebuffer(GL_FRAMEBUFFER, client_framebuffer_id_, 4860 DoBindFramebuffer(GL_FRAMEBUFFER, client_framebuffer_id_,
4985 kServiceFramebufferId); 4861 kServiceFramebufferId);
4986 EXPECT_CALL(*gl_, GetError()) 4862 EXPECT_CALL(*gl_, GetError())
4987 .WillOnce(Return(GL_NO_ERROR)) 4863 .WillOnce(Return(GL_NO_ERROR))
4988 .WillOnce(Return(GL_OUT_OF_MEMORY)) 4864 .WillOnce(Return(GL_OUT_OF_MEMORY))
4989 .RetiresOnSaturation(); 4865 .RetiresOnSaturation();
4990 EXPECT_CALL(*gl_, FramebufferTexture2DEXT( 4866 EXPECT_CALL(*gl_, FramebufferTexture2DEXT(
4991 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 4867 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
4992 kServiceTextureId, 0)) 4868 kServiceTextureId, 0))
4993 .Times(1) 4869 .Times(1)
4994 .RetiresOnSaturation(); 4870 .RetiresOnSaturation();
4995 FramebufferTexture2D fbtex_cmd; 4871 FramebufferTexture2D fbtex_cmd;
4996 fbtex_cmd.Init( 4872 fbtex_cmd.Init(
4997 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, client_texture_id_, 4873 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, client_texture_id_,
4998 0); 4874 0);
4999 EXPECT_EQ(error::kNoError, ExecuteCmd(fbtex_cmd)); 4875 EXPECT_EQ(error::kNoError, ExecuteCmd(fbtex_cmd));
5000 EXPECT_EQ(GL_OUT_OF_MEMORY, GetGLError()); 4876 EXPECT_EQ(GL_OUT_OF_MEMORY, GetGLError());
5001 } 4877 }
5002 4878
5003 TEST_P(GLES2DecoderTest, RenderbufferStorageGLError) { 4879 TEST_F(GLES2DecoderTest, RenderbufferStorageGLError) {
5004 DoBindRenderbuffer(GL_RENDERBUFFER, client_renderbuffer_id_, 4880 DoBindRenderbuffer(GL_RENDERBUFFER, client_renderbuffer_id_,
5005 kServiceRenderbufferId); 4881 kServiceRenderbufferId);
5006 EXPECT_CALL(*gl_, GetError()) 4882 EXPECT_CALL(*gl_, GetError())
5007 .WillOnce(Return(GL_NO_ERROR)) 4883 .WillOnce(Return(GL_NO_ERROR))
5008 .WillOnce(Return(GL_OUT_OF_MEMORY)) 4884 .WillOnce(Return(GL_OUT_OF_MEMORY))
5009 .RetiresOnSaturation(); 4885 .RetiresOnSaturation();
5010 EXPECT_CALL(*gl_, RenderbufferStorageEXT( 4886 EXPECT_CALL(*gl_, RenderbufferStorageEXT(
5011 GL_RENDERBUFFER, GL_RGBA, 100, 50)) 4887 GL_RENDERBUFFER, GL_RGBA, 100, 50))
5012 .Times(1) 4888 .Times(1)
5013 .RetiresOnSaturation(); 4889 .RetiresOnSaturation();
5014 RenderbufferStorage cmd; 4890 RenderbufferStorage cmd;
5015 cmd.Init(GL_RENDERBUFFER, GL_RGBA4, 100, 50); 4891 cmd.Init(GL_RENDERBUFFER, GL_RGBA4, 100, 50);
5016 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 4892 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
5017 EXPECT_EQ(GL_OUT_OF_MEMORY, GetGLError()); 4893 EXPECT_EQ(GL_OUT_OF_MEMORY, GetGLError());
5018 } 4894 }
5019 4895
5020 TEST_P(GLES2DecoderTest, RenderbufferStorageBadArgs) { 4896 TEST_F(GLES2DecoderTest, RenderbufferStorageBadArgs) {
5021 DoBindRenderbuffer(GL_RENDERBUFFER, client_renderbuffer_id_, 4897 DoBindRenderbuffer(GL_RENDERBUFFER, client_renderbuffer_id_,
5022 kServiceRenderbufferId); 4898 kServiceRenderbufferId);
5023 EXPECT_CALL(*gl_, RenderbufferStorageEXT(_, _, _, _)) 4899 EXPECT_CALL(*gl_, RenderbufferStorageEXT(_, _, _, _))
5024 .Times(0) 4900 .Times(0)
5025 .RetiresOnSaturation(); 4901 .RetiresOnSaturation();
5026 RenderbufferStorage cmd; 4902 RenderbufferStorage cmd;
5027 cmd.Init(GL_RENDERBUFFER, GL_RGBA4, TestHelper::kMaxRenderbufferSize + 1, 1); 4903 cmd.Init(GL_RENDERBUFFER, GL_RGBA4, TestHelper::kMaxRenderbufferSize + 1, 1);
5028 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 4904 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
5029 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); 4905 EXPECT_EQ(GL_INVALID_VALUE, GetGLError());
5030 cmd.Init(GL_RENDERBUFFER, GL_RGBA4, 1, TestHelper::kMaxRenderbufferSize + 1); 4906 cmd.Init(GL_RENDERBUFFER, GL_RGBA4, 1, TestHelper::kMaxRenderbufferSize + 1);
5031 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 4907 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
5032 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); 4908 EXPECT_EQ(GL_INVALID_VALUE, GetGLError());
5033 } 4909 }
5034 4910
5035 TEST_P(GLES2DecoderManualInitTest, 4911 TEST_F(GLES2DecoderManualInitTest,
5036 RenderbufferStorageMultisampleCHROMIUMGLError) { 4912 RenderbufferStorageMultisampleCHROMIUMGLError) {
5037 InitState init; 4913 InitState init;
5038 init.extensions = "GL_EXT_framebuffer_multisample"; 4914 init.extensions = "GL_EXT_framebuffer_multisample";
5039 init.gl_version = "2.1"; 4915 init.gl_version = "2.1";
5040 init.bind_generates_resource = true; 4916 init.bind_generates_resource = true;
5041 InitDecoder(init); 4917 InitDecoder(init);
5042 DoBindRenderbuffer(GL_RENDERBUFFER, client_renderbuffer_id_, 4918 DoBindRenderbuffer(GL_RENDERBUFFER, client_renderbuffer_id_,
5043 kServiceRenderbufferId); 4919 kServiceRenderbufferId);
5044 EXPECT_CALL(*gl_, GetError()) 4920 EXPECT_CALL(*gl_, GetError())
5045 .WillOnce(Return(GL_NO_ERROR)) 4921 .WillOnce(Return(GL_NO_ERROR))
5046 .WillOnce(Return(GL_OUT_OF_MEMORY)) 4922 .WillOnce(Return(GL_OUT_OF_MEMORY))
5047 .RetiresOnSaturation(); 4923 .RetiresOnSaturation();
5048 EXPECT_CALL(*gl_, RenderbufferStorageMultisampleEXT( 4924 EXPECT_CALL(*gl_, RenderbufferStorageMultisampleEXT(
5049 GL_RENDERBUFFER, 1, GL_RGBA, 100, 50)) 4925 GL_RENDERBUFFER, 1, GL_RGBA, 100, 50))
5050 .Times(1) 4926 .Times(1)
5051 .RetiresOnSaturation(); 4927 .RetiresOnSaturation();
5052 RenderbufferStorageMultisampleCHROMIUM cmd; 4928 RenderbufferStorageMultisampleCHROMIUM cmd;
5053 cmd.Init(GL_RENDERBUFFER, 1, GL_RGBA4, 100, 50); 4929 cmd.Init(GL_RENDERBUFFER, 1, GL_RGBA4, 100, 50);
5054 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 4930 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
5055 EXPECT_EQ(GL_OUT_OF_MEMORY, GetGLError()); 4931 EXPECT_EQ(GL_OUT_OF_MEMORY, GetGLError());
5056 } 4932 }
5057 4933
5058 TEST_P(GLES2DecoderManualInitTest, 4934 TEST_F(GLES2DecoderManualInitTest,
5059 RenderbufferStorageMultisampleCHROMIUMBadArgs) { 4935 RenderbufferStorageMultisampleCHROMIUMBadArgs) {
5060 InitState init; 4936 InitState init;
5061 init.extensions = "GL_EXT_framebuffer_multisample"; 4937 init.extensions = "GL_EXT_framebuffer_multisample";
5062 init.gl_version = "2.1"; 4938 init.gl_version = "2.1";
5063 init.bind_generates_resource = true; 4939 init.bind_generates_resource = true;
5064 InitDecoder(init); 4940 InitDecoder(init);
5065 DoBindRenderbuffer(GL_RENDERBUFFER, client_renderbuffer_id_, 4941 DoBindRenderbuffer(GL_RENDERBUFFER, client_renderbuffer_id_,
5066 kServiceRenderbufferId); 4942 kServiceRenderbufferId);
5067 EXPECT_CALL(*gl_, RenderbufferStorageMultisampleEXT(_, _, _, _, _)) 4943 EXPECT_CALL(*gl_, RenderbufferStorageMultisampleEXT(_, _, _, _, _))
5068 .Times(0) 4944 .Times(0)
5069 .RetiresOnSaturation(); 4945 .RetiresOnSaturation();
5070 RenderbufferStorageMultisampleCHROMIUM cmd; 4946 RenderbufferStorageMultisampleCHROMIUM cmd;
5071 cmd.Init(GL_RENDERBUFFER, TestHelper::kMaxSamples + 1, 4947 cmd.Init(GL_RENDERBUFFER, TestHelper::kMaxSamples + 1,
5072 GL_RGBA4, TestHelper::kMaxRenderbufferSize, 1); 4948 GL_RGBA4, TestHelper::kMaxRenderbufferSize, 1);
5073 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 4949 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
5074 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); 4950 EXPECT_EQ(GL_INVALID_VALUE, GetGLError());
5075 cmd.Init(GL_RENDERBUFFER, TestHelper::kMaxSamples, 4951 cmd.Init(GL_RENDERBUFFER, TestHelper::kMaxSamples,
5076 GL_RGBA4, TestHelper::kMaxRenderbufferSize + 1, 1); 4952 GL_RGBA4, TestHelper::kMaxRenderbufferSize + 1, 1);
5077 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 4953 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
5078 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); 4954 EXPECT_EQ(GL_INVALID_VALUE, GetGLError());
5079 cmd.Init(GL_RENDERBUFFER, TestHelper::kMaxSamples, 4955 cmd.Init(GL_RENDERBUFFER, TestHelper::kMaxSamples,
5080 GL_RGBA4, 1, TestHelper::kMaxRenderbufferSize + 1); 4956 GL_RGBA4, 1, TestHelper::kMaxRenderbufferSize + 1);
5081 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 4957 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
5082 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); 4958 EXPECT_EQ(GL_INVALID_VALUE, GetGLError());
5083 } 4959 }
5084 4960
5085 TEST_P(GLES2DecoderManualInitTest, RenderbufferStorageMultisampleCHROMIUM) { 4961 TEST_F(GLES2DecoderManualInitTest, RenderbufferStorageMultisampleCHROMIUM) {
5086 InitState init; 4962 InitState init;
5087 init.extensions = "GL_EXT_framebuffer_multisample"; 4963 init.extensions = "GL_EXT_framebuffer_multisample";
5088 init.gl_version = "2.1"; 4964 init.gl_version = "2.1";
5089 InitDecoder(init); 4965 InitDecoder(init);
5090 DoBindRenderbuffer(GL_RENDERBUFFER, client_renderbuffer_id_, 4966 DoBindRenderbuffer(GL_RENDERBUFFER, client_renderbuffer_id_,
5091 kServiceRenderbufferId); 4967 kServiceRenderbufferId);
5092 InSequence sequence; 4968 InSequence sequence;
5093 EXPECT_CALL(*gl_, GetError()) 4969 EXPECT_CALL(*gl_, GetError())
5094 .WillOnce(Return(GL_NO_ERROR)) 4970 .WillOnce(Return(GL_NO_ERROR))
5095 .RetiresOnSaturation(); 4971 .RetiresOnSaturation();
5096 EXPECT_CALL( 4972 EXPECT_CALL(
5097 *gl_, 4973 *gl_,
5098 RenderbufferStorageMultisampleEXT(GL_RENDERBUFFER, 4974 RenderbufferStorageMultisampleEXT(GL_RENDERBUFFER,
5099 TestHelper::kMaxSamples, 4975 TestHelper::kMaxSamples,
5100 GL_RGBA, 4976 GL_RGBA,
5101 TestHelper::kMaxRenderbufferSize, 4977 TestHelper::kMaxRenderbufferSize,
5102 1)) 4978 1))
5103 .Times(1) 4979 .Times(1)
5104 .RetiresOnSaturation(); 4980 .RetiresOnSaturation();
5105 EXPECT_CALL(*gl_, GetError()) 4981 EXPECT_CALL(*gl_, GetError())
5106 .WillOnce(Return(GL_NO_ERROR)) 4982 .WillOnce(Return(GL_NO_ERROR))
5107 .RetiresOnSaturation(); 4983 .RetiresOnSaturation();
5108 RenderbufferStorageMultisampleCHROMIUM cmd; 4984 RenderbufferStorageMultisampleCHROMIUM cmd;
5109 cmd.Init(GL_RENDERBUFFER, TestHelper::kMaxSamples, 4985 cmd.Init(GL_RENDERBUFFER, TestHelper::kMaxSamples,
5110 GL_RGBA4, TestHelper::kMaxRenderbufferSize, 1); 4986 GL_RGBA4, TestHelper::kMaxRenderbufferSize, 1);
5111 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 4987 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
5112 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 4988 EXPECT_EQ(GL_NO_ERROR, GetGLError());
5113 } 4989 }
5114 4990
5115 TEST_P(GLES2DecoderManualInitTest, 4991 TEST_F(GLES2DecoderManualInitTest,
5116 RenderbufferStorageMultisampleEXTNotSupported) { 4992 RenderbufferStorageMultisampleEXTNotSupported) {
5117 InitState init; 4993 InitState init;
5118 init.extensions = "GL_EXT_framebuffer_multisample"; 4994 init.extensions = "GL_EXT_framebuffer_multisample";
5119 init.gl_version = "2.1"; 4995 init.gl_version = "2.1";
5120 init.bind_generates_resource = true; 4996 init.bind_generates_resource = true;
5121 InitDecoder(init); 4997 InitDecoder(init);
5122 DoBindRenderbuffer(GL_RENDERBUFFER, client_renderbuffer_id_, 4998 DoBindRenderbuffer(GL_RENDERBUFFER, client_renderbuffer_id_,
5123 kServiceRenderbufferId); 4999 kServiceRenderbufferId);
5124 InSequence sequence; 5000 InSequence sequence;
5125 // GL_EXT_framebuffer_multisample uses RenderbufferStorageMultisampleCHROMIUM. 5001 // GL_EXT_framebuffer_multisample uses RenderbufferStorageMultisampleCHROMIUM.
5126 RenderbufferStorageMultisampleEXT cmd; 5002 RenderbufferStorageMultisampleEXT cmd;
5127 cmd.Init(GL_RENDERBUFFER, TestHelper::kMaxSamples, 5003 cmd.Init(GL_RENDERBUFFER, TestHelper::kMaxSamples,
5128 GL_RGBA4, TestHelper::kMaxRenderbufferSize, 1); 5004 GL_RGBA4, TestHelper::kMaxRenderbufferSize, 1);
5129 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 5005 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
5130 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); 5006 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
5131 } 5007 }
5132 5008
5133 class GLES2DecoderMultisampledRenderToTextureTest 5009 class GLES2DecoderMultisampledRenderToTextureTest
5134 : public GLES2DecoderTestWithExtensionsOnGLES2 { 5010 : public GLES2DecoderTestWithExtensionsOnGLES2 {};
5135 public:
5136 void TestNotCompatibleWithRenderbufferStorageMultisampleCHROMIUM() {
5137 DoBindRenderbuffer(
5138 GL_RENDERBUFFER, client_renderbuffer_id_, kServiceRenderbufferId);
5139 RenderbufferStorageMultisampleCHROMIUM cmd;
5140 cmd.Init(GL_RENDERBUFFER,
5141 TestHelper::kMaxSamples,
5142 GL_RGBA4,
5143 TestHelper::kMaxRenderbufferSize,
5144 1);
5145 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
5146 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
5147 }
5148
5149 void TestRenderbufferStorageMultisampleEXT(const char* extension) {
5150 DoBindRenderbuffer(
5151 GL_RENDERBUFFER, client_renderbuffer_id_, kServiceRenderbufferId);
5152 InSequence sequence;
5153 EXPECT_CALL(*gl_, GetError())
5154 .WillOnce(Return(GL_NO_ERROR))
5155 .RetiresOnSaturation();
5156 if (strstr(extension, "GL_IMG_multisampled_render_to_texture")) {
5157 EXPECT_CALL(
5158 *gl_,
5159 RenderbufferStorageMultisampleIMG(GL_RENDERBUFFER,
5160 TestHelper::kMaxSamples,
5161 GL_RGBA,
5162 TestHelper::kMaxRenderbufferSize,
5163 1))
5164 .Times(1)
5165 .RetiresOnSaturation();
5166 } else {
5167 EXPECT_CALL(
5168 *gl_,
5169 RenderbufferStorageMultisampleEXT(GL_RENDERBUFFER,
5170 TestHelper::kMaxSamples,
5171 GL_RGBA,
5172 TestHelper::kMaxRenderbufferSize,
5173 1))
5174 .Times(1)
5175 .RetiresOnSaturation();
5176 }
5177 EXPECT_CALL(*gl_, GetError())
5178 .WillOnce(Return(GL_NO_ERROR))
5179 .RetiresOnSaturation();
5180 RenderbufferStorageMultisampleEXT cmd;
5181 cmd.Init(GL_RENDERBUFFER,
5182 TestHelper::kMaxSamples,
5183 GL_RGBA4,
5184 TestHelper::kMaxRenderbufferSize,
5185 1);
5186 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
5187 EXPECT_EQ(GL_NO_ERROR, GetGLError());
5188 }
5189 };
5190 5011
5191 TEST_P(GLES2DecoderMultisampledRenderToTextureTest, 5012 TEST_P(GLES2DecoderMultisampledRenderToTextureTest,
5192 NotCompatibleWithRenderbufferStorageMultisampleCHROMIUM_EXT) { 5013 NotCompatibleWithRenderbufferStorageMultisampleCHROMIUM) {
5193 Init("GL_EXT_multisampled_render_to_texture"); 5014 DoBindRenderbuffer(GL_RENDERBUFFER, client_renderbuffer_id_,
5194 TestNotCompatibleWithRenderbufferStorageMultisampleCHROMIUM(); 5015 kServiceRenderbufferId);
5016 RenderbufferStorageMultisampleCHROMIUM cmd;
5017 cmd.Init(GL_RENDERBUFFER, TestHelper::kMaxSamples,
5018 GL_RGBA4, TestHelper::kMaxRenderbufferSize, 1);
5019 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
5020 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
5195 } 5021 }
5196 5022
5197 TEST_P(GLES2DecoderMultisampledRenderToTextureTest, 5023 TEST_P(GLES2DecoderMultisampledRenderToTextureTest,
5198 NotCompatibleWithRenderbufferStorageMultisampleCHROMIUM_IMG) { 5024 RenderbufferStorageMultisampleEXT) {
5199 Init("GL_IMG_multisampled_render_to_texture"); 5025 DoBindRenderbuffer(GL_RENDERBUFFER, client_renderbuffer_id_,
5200 TestNotCompatibleWithRenderbufferStorageMultisampleCHROMIUM(); 5026 kServiceRenderbufferId);
5027 InSequence sequence;
5028 EXPECT_CALL(*gl_, GetError())
5029 .WillOnce(Return(GL_NO_ERROR))
5030 .RetiresOnSaturation();
5031 if (strstr(GetParam(), "GL_IMG_multisampled_render_to_texture")) {
5032 EXPECT_CALL(
5033 *gl_,
5034 RenderbufferStorageMultisampleIMG(GL_RENDERBUFFER,
5035 TestHelper::kMaxSamples,
5036 GL_RGBA,
5037 TestHelper::kMaxRenderbufferSize,
5038 1))
5039 .Times(1)
5040 .RetiresOnSaturation();
5041 } else {
5042 EXPECT_CALL(
5043 *gl_,
5044 RenderbufferStorageMultisampleEXT(GL_RENDERBUFFER,
5045 TestHelper::kMaxSamples,
5046 GL_RGBA,
5047 TestHelper::kMaxRenderbufferSize,
5048 1))
5049 .Times(1)
5050 .RetiresOnSaturation();
5051 }
5052 EXPECT_CALL(*gl_, GetError())
5053 .WillOnce(Return(GL_NO_ERROR))
5054 .RetiresOnSaturation();
5055 RenderbufferStorageMultisampleEXT cmd;
5056 cmd.Init(GL_RENDERBUFFER, TestHelper::kMaxSamples,
5057 GL_RGBA4, TestHelper::kMaxRenderbufferSize, 1);
5058 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
5059 EXPECT_EQ(GL_NO_ERROR, GetGLError());
5201 } 5060 }
5202 5061
5203 TEST_P(GLES2DecoderMultisampledRenderToTextureTest, 5062 INSTANTIATE_TEST_CASE_P(
5204 RenderbufferStorageMultisampleEXT_EXT) { 5063 GLES2DecoderMultisampledRenderToTextureTests,
5205 Init("GL_EXT_multisampled_render_to_texture"); 5064 GLES2DecoderMultisampledRenderToTextureTest,
5206 TestRenderbufferStorageMultisampleEXT( 5065 ::testing::Values("GL_EXT_multisampled_render_to_texture",
5207 "GL_EXT_multisampled_render_to_texture"); 5066 "GL_IMG_multisampled_render_to_texture"));
5208 }
5209 5067
5210 TEST_P(GLES2DecoderMultisampledRenderToTextureTest, 5068 TEST_F(GLES2DecoderTest, ReadPixelsGLError) {
5211 RenderbufferStorageMultisampleEXT_IMG) {
5212 Init("GL_IMG_multisampled_render_to_texture");
5213 TestRenderbufferStorageMultisampleEXT(
5214 "GL_IMG_multisampled_render_to_texture");
5215 }
5216
5217 TEST_P(GLES2DecoderTest, ReadPixelsGLError) {
5218 GLenum kFormat = GL_RGBA; 5069 GLenum kFormat = GL_RGBA;
5219 GLint x = 0; 5070 GLint x = 0;
5220 GLint y = 0; 5071 GLint y = 0;
5221 GLsizei width = 2; 5072 GLsizei width = 2;
5222 GLsizei height = 4; 5073 GLsizei height = 4;
5223 typedef ReadPixels::Result Result; 5074 typedef ReadPixels::Result Result;
5224 Result* result = GetSharedMemoryAs<Result*>(); 5075 Result* result = GetSharedMemoryAs<Result*>();
5225 uint32 result_shm_id = kSharedMemoryId; 5076 uint32 result_shm_id = kSharedMemoryId;
5226 uint32 result_shm_offset = kSharedMemoryOffset; 5077 uint32 result_shm_offset = kSharedMemoryOffset;
5227 uint32 pixels_shm_id = kSharedMemoryId; 5078 uint32 pixels_shm_id = kSharedMemoryId;
5228 uint32 pixels_shm_offset = kSharedMemoryOffset + sizeof(*result); 5079 uint32 pixels_shm_offset = kSharedMemoryOffset + sizeof(*result);
5229 EXPECT_CALL(*gl_, GetError()) 5080 EXPECT_CALL(*gl_, GetError())
5230 .WillOnce(Return(GL_NO_ERROR)) 5081 .WillOnce(Return(GL_NO_ERROR))
5231 .WillOnce(Return(GL_OUT_OF_MEMORY)) 5082 .WillOnce(Return(GL_OUT_OF_MEMORY))
5232 .RetiresOnSaturation(); 5083 .RetiresOnSaturation();
5233 EXPECT_CALL( 5084 EXPECT_CALL(
5234 *gl_, ReadPixels(x, y, width, height, kFormat, GL_UNSIGNED_BYTE, _)) 5085 *gl_, ReadPixels(x, y, width, height, kFormat, GL_UNSIGNED_BYTE, _))
5235 .Times(1) 5086 .Times(1)
5236 .RetiresOnSaturation(); 5087 .RetiresOnSaturation();
5237 ReadPixels cmd; 5088 ReadPixels cmd;
5238 cmd.Init(x, y, width, height, kFormat, GL_UNSIGNED_BYTE, 5089 cmd.Init(x, y, width, height, kFormat, GL_UNSIGNED_BYTE,
5239 pixels_shm_id, pixels_shm_offset, 5090 pixels_shm_id, pixels_shm_offset,
5240 result_shm_id, result_shm_offset, 5091 result_shm_id, result_shm_offset,
5241 false); 5092 false);
5242 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 5093 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
5243 EXPECT_EQ(GL_OUT_OF_MEMORY, GetGLError()); 5094 EXPECT_EQ(GL_OUT_OF_MEMORY, GetGLError());
5244 } 5095 }
5245 5096
5246 TEST_P(GLES2DecoderCompressedFormatsTest, GetCompressedTextureFormatsS3TC) { 5097 TEST_F(GLES2DecoderCompressedFormatsTest, GetCompressedTextureFormatsS3TC) {
5247 const GLenum formats[] = { 5098 const GLenum formats[] = {
5248 GL_COMPRESSED_RGB_S3TC_DXT1_EXT, 5099 GL_COMPRESSED_RGB_S3TC_DXT1_EXT,
5249 GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, 5100 GL_COMPRESSED_RGBA_S3TC_DXT1_EXT,
5250 GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, 5101 GL_COMPRESSED_RGBA_S3TC_DXT3_EXT,
5251 GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 5102 GL_COMPRESSED_RGBA_S3TC_DXT5_EXT
5252 }; 5103 };
5253 CheckFormats("GL_EXT_texture_compression_s3tc", formats, 4); 5104 CheckFormats("GL_EXT_texture_compression_s3tc", formats, 4);
5254 } 5105 }
5255 5106
5256 TEST_P(GLES2DecoderCompressedFormatsTest, GetCompressedTextureFormatsATC) { 5107 TEST_F(GLES2DecoderCompressedFormatsTest, GetCompressedTextureFormatsATC) {
5257 const GLenum formats[] = { 5108 const GLenum formats[] = {
5258 GL_ATC_RGB_AMD, 5109 GL_ATC_RGB_AMD,
5259 GL_ATC_RGBA_EXPLICIT_ALPHA_AMD, 5110 GL_ATC_RGBA_EXPLICIT_ALPHA_AMD,
5260 GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD 5111 GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD
5261 }; 5112 };
5262 CheckFormats("GL_AMD_compressed_ATC_texture", formats, 3); 5113 CheckFormats("GL_AMD_compressed_ATC_texture", formats, 3);
5263 } 5114 }
5264 5115
5265 TEST_P(GLES2DecoderCompressedFormatsTest, GetCompressedTextureFormatsPVRTC) { 5116 TEST_F(GLES2DecoderCompressedFormatsTest, GetCompressedTextureFormatsPVRTC) {
5266 const GLenum formats[] = { 5117 const GLenum formats[] = {
5267 GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG, 5118 GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG,
5268 GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG, 5119 GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG,
5269 GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG, 5120 GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG,
5270 GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG 5121 GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG
5271 }; 5122 };
5272 CheckFormats("GL_IMG_texture_compression_pvrtc", formats, 4); 5123 CheckFormats("GL_IMG_texture_compression_pvrtc", formats, 4);
5273 } 5124 }
5274 5125
5275 TEST_P(GLES2DecoderCompressedFormatsTest, GetCompressedTextureFormatsETC1) { 5126 TEST_F(GLES2DecoderCompressedFormatsTest, GetCompressedTextureFormatsETC1) {
5276 const GLenum formats[] = { 5127 const GLenum formats[] = {
5277 GL_ETC1_RGB8_OES 5128 GL_ETC1_RGB8_OES
5278 }; 5129 };
5279 CheckFormats("GL_OES_compressed_ETC1_RGB8_texture", formats, 1); 5130 CheckFormats("GL_OES_compressed_ETC1_RGB8_texture", formats, 1);
5280 } 5131 }
5281 5132
5282 TEST_P(GLES2DecoderManualInitTest, GetNoCompressedTextureFormats) { 5133 TEST_F(GLES2DecoderManualInitTest, GetNoCompressedTextureFormats) {
5283 InitState init; 5134 InitState init;
5284 init.gl_version = "3.0"; 5135 init.gl_version = "3.0";
5285 init.bind_generates_resource = true; 5136 init.bind_generates_resource = true;
5286 InitDecoder(init); 5137 InitDecoder(init);
5287 5138
5288 EXPECT_CALL(*gl_, GetError()) 5139 EXPECT_CALL(*gl_, GetError())
5289 .WillOnce(Return(GL_NO_ERROR)) 5140 .WillOnce(Return(GL_NO_ERROR))
5290 .WillOnce(Return(GL_NO_ERROR)) 5141 .WillOnce(Return(GL_NO_ERROR))
5291 .WillOnce(Return(GL_NO_ERROR)) 5142 .WillOnce(Return(GL_NO_ERROR))
5292 .WillOnce(Return(GL_NO_ERROR)) 5143 .WillOnce(Return(GL_NO_ERROR))
(...skipping 18 matching lines...) Expand all
5311 result->size = 0; 5162 result->size = 0;
5312 cmd.Init( 5163 cmd.Init(
5313 GL_COMPRESSED_TEXTURE_FORMATS, 5164 GL_COMPRESSED_TEXTURE_FORMATS,
5314 shared_memory_id_, shared_memory_offset_); 5165 shared_memory_id_, shared_memory_offset_);
5315 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 5166 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
5316 EXPECT_EQ(num_formats, result->GetNumResults()); 5167 EXPECT_EQ(num_formats, result->GetNumResults());
5317 5168
5318 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 5169 EXPECT_EQ(GL_NO_ERROR, GetGLError());
5319 } 5170 }
5320 5171
5321 TEST_P(GLES2DecoderManualInitTest, CompressedTexImage2DBucketBadBucket) { 5172 TEST_F(GLES2DecoderManualInitTest, CompressedTexImage2DBucketBadBucket) {
5322 InitState init; 5173 InitState init;
5323 init.extensions = "GL_EXT_texture_compression_s3tc"; 5174 init.extensions = "GL_EXT_texture_compression_s3tc";
5324 init.gl_version = "3.0"; 5175 init.gl_version = "3.0";
5325 init.bind_generates_resource = true; 5176 init.bind_generates_resource = true;
5326 InitDecoder(init); 5177 InitDecoder(init);
5327 5178
5328 const uint32 kBadBucketId = 123; 5179 const uint32 kBadBucketId = 123;
5329 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); 5180 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId);
5330 CompressedTexImage2DBucket cmd; 5181 CompressedTexImage2DBucket cmd;
5331 cmd.Init( 5182 cmd.Init(
5332 GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, 4, 4, 0, 5183 GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, 4, 4, 0,
5333 kBadBucketId); 5184 kBadBucketId);
5334 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); 5185 EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
5335 CompressedTexSubImage2DBucket cmd2; 5186 CompressedTexSubImage2DBucket cmd2;
5336 cmd2.Init( 5187 cmd2.Init(
5337 GL_TEXTURE_2D, 0, 0, 0, 4, 4, GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, 5188 GL_TEXTURE_2D, 0, 0, 0, 4, 4, GL_COMPRESSED_RGBA_S3TC_DXT5_EXT,
5338 kBadBucketId); 5189 kBadBucketId);
5339 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); 5190 EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
5340 } 5191 }
5341 5192
5342 namespace { 5193 namespace {
5343 5194
5344 struct S3TCTestData { 5195 struct S3TCTestData {
5345 GLenum format; 5196 GLenum format;
5346 size_t block_size; 5197 size_t block_size;
5347 }; 5198 };
5348 5199
5349 } // anonymous namespace. 5200 } // anonymous namespace.
5350 5201
5351 TEST_P(GLES2DecoderManualInitTest, CompressedTexImage2DS3TC) { 5202 TEST_F(GLES2DecoderManualInitTest, CompressedTexImage2DS3TC) {
5352 InitState init; 5203 InitState init;
5353 init.extensions = "GL_EXT_texture_compression_s3tc"; 5204 init.extensions = "GL_EXT_texture_compression_s3tc";
5354 init.gl_version = "3.0"; 5205 init.gl_version = "3.0";
5355 init.bind_generates_resource = true; 5206 init.bind_generates_resource = true;
5356 InitDecoder(init); 5207 InitDecoder(init);
5357 const uint32 kBucketId = 123; 5208 const uint32 kBucketId = 123;
5358 CommonDecoder::Bucket* bucket = decoder_->CreateBucket(kBucketId); 5209 CommonDecoder::Bucket* bucket = decoder_->CreateBucket(kBucketId);
5359 ASSERT_TRUE(bucket != NULL); 5210 ASSERT_TRUE(bucket != NULL);
5360 5211
5361 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); 5212 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId);
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
5491 kBucketId); 5342 kBucketId);
5492 EXPECT_EQ(error::kNoError, ExecuteCmd(sub_cmd)); 5343 EXPECT_EQ(error::kNoError, ExecuteCmd(sub_cmd));
5493 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 5344 EXPECT_EQ(GL_NO_ERROR, GetGLError());
5494 } 5345 }
5495 } 5346 }
5496 } 5347 }
5497 } 5348 }
5498 } 5349 }
5499 } 5350 }
5500 5351
5501 TEST_P(GLES2DecoderManualInitTest, CompressedTexImage2DETC1) { 5352 TEST_F(GLES2DecoderManualInitTest, CompressedTexImage2DETC1) {
5502 InitState init; 5353 InitState init;
5503 init.extensions = "GL_OES_compressed_ETC1_RGB8_texture"; 5354 init.extensions = "GL_OES_compressed_ETC1_RGB8_texture";
5504 init.gl_version = "opengl es 2.0"; 5355 init.gl_version = "opengl es 2.0";
5505 init.bind_generates_resource = true; 5356 init.bind_generates_resource = true;
5506 InitDecoder(init); 5357 InitDecoder(init);
5507 const uint32 kBucketId = 123; 5358 const uint32 kBucketId = 123;
5508 CommonDecoder::Bucket* bucket = decoder_->CreateBucket(kBucketId); 5359 CommonDecoder::Bucket* bucket = decoder_->CreateBucket(kBucketId);
5509 ASSERT_TRUE(bucket != NULL); 5360 ASSERT_TRUE(bucket != NULL);
5510 5361
5511 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); 5362 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId);
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
5559 EXPECT_EQ(error::kNoError, ExecuteCmd(texsub_cmd)); 5410 EXPECT_EQ(error::kNoError, ExecuteCmd(texsub_cmd));
5560 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); 5411 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
5561 5412
5562 // Test CopyTexSubImage not allowed for ETC1 compressed texture 5413 // Test CopyTexSubImage not allowed for ETC1 compressed texture
5563 CopyTexSubImage2D copy_cmd; 5414 CopyTexSubImage2D copy_cmd;
5564 copy_cmd.Init(GL_TEXTURE_2D, 0, 0, 0, 0, 0, 4, 4); 5415 copy_cmd.Init(GL_TEXTURE_2D, 0, 0, 0, 0, 0, 4, 4);
5565 EXPECT_EQ(error::kNoError, ExecuteCmd(copy_cmd)); 5416 EXPECT_EQ(error::kNoError, ExecuteCmd(copy_cmd));
5566 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); 5417 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
5567 } 5418 }
5568 5419
5569 TEST_P(GLES2DecoderWithShaderTest, GetProgramInfoCHROMIUMValidArgs) { 5420 TEST_F(GLES2DecoderWithShaderTest, GetProgramInfoCHROMIUMValidArgs) {
5570 const uint32 kBucketId = 123; 5421 const uint32 kBucketId = 123;
5571 GetProgramInfoCHROMIUM cmd; 5422 GetProgramInfoCHROMIUM cmd;
5572 cmd.Init(client_program_id_, kBucketId); 5423 cmd.Init(client_program_id_, kBucketId);
5573 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 5424 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
5574 CommonDecoder::Bucket* bucket = decoder_->GetBucket(kBucketId); 5425 CommonDecoder::Bucket* bucket = decoder_->GetBucket(kBucketId);
5575 EXPECT_GT(bucket->size(), 0u); 5426 EXPECT_GT(bucket->size(), 0u);
5576 } 5427 }
5577 5428
5578 TEST_P(GLES2DecoderWithShaderTest, GetProgramInfoCHROMIUMInvalidArgs) { 5429 TEST_F(GLES2DecoderWithShaderTest, GetProgramInfoCHROMIUMInvalidArgs) {
5579 const uint32 kBucketId = 123; 5430 const uint32 kBucketId = 123;
5580 CommonDecoder::Bucket* bucket = decoder_->GetBucket(kBucketId); 5431 CommonDecoder::Bucket* bucket = decoder_->GetBucket(kBucketId);
5581 EXPECT_TRUE(bucket == NULL); 5432 EXPECT_TRUE(bucket == NULL);
5582 GetProgramInfoCHROMIUM cmd; 5433 GetProgramInfoCHROMIUM cmd;
5583 cmd.Init(kInvalidClientId, kBucketId); 5434 cmd.Init(kInvalidClientId, kBucketId);
5584 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 5435 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
5585 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 5436 EXPECT_EQ(GL_NO_ERROR, GetGLError());
5586 bucket = decoder_->GetBucket(kBucketId); 5437 bucket = decoder_->GetBucket(kBucketId);
5587 ASSERT_TRUE(bucket != NULL); 5438 ASSERT_TRUE(bucket != NULL);
5588 EXPECT_EQ(sizeof(ProgramInfoHeader), bucket->size()); 5439 EXPECT_EQ(sizeof(ProgramInfoHeader), bucket->size());
5589 ProgramInfoHeader* info = bucket->GetDataAs<ProgramInfoHeader*>( 5440 ProgramInfoHeader* info = bucket->GetDataAs<ProgramInfoHeader*>(
5590 0, sizeof(ProgramInfoHeader)); 5441 0, sizeof(ProgramInfoHeader));
5591 ASSERT_TRUE(info != 0); 5442 ASSERT_TRUE(info != 0);
5592 EXPECT_EQ(0u, info->link_status); 5443 EXPECT_EQ(0u, info->link_status);
5593 EXPECT_EQ(0u, info->num_attribs); 5444 EXPECT_EQ(0u, info->num_attribs);
5594 EXPECT_EQ(0u, info->num_uniforms); 5445 EXPECT_EQ(0u, info->num_uniforms);
5595 } 5446 }
5596 5447
5597 TEST_P(GLES2DecoderManualInitTest, EGLImageExternalBindTexture) { 5448 TEST_F(GLES2DecoderManualInitTest, EGLImageExternalBindTexture) {
5598 InitState init; 5449 InitState init;
5599 init.extensions = "GL_OES_EGL_image_external"; 5450 init.extensions = "GL_OES_EGL_image_external";
5600 init.gl_version = "opengl es 2.0"; 5451 init.gl_version = "opengl es 2.0";
5601 init.bind_generates_resource = true; 5452 init.bind_generates_resource = true;
5602 InitDecoder(init); 5453 InitDecoder(init);
5603 EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_EXTERNAL_OES, kNewServiceId)); 5454 EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_EXTERNAL_OES, kNewServiceId));
5604 EXPECT_CALL(*gl_, GenTextures(1, _)) 5455 EXPECT_CALL(*gl_, GenTextures(1, _))
5605 .WillOnce(SetArgumentPointee<1>(kNewServiceId)); 5456 .WillOnce(SetArgumentPointee<1>(kNewServiceId));
5606 BindTexture cmd; 5457 BindTexture cmd;
5607 cmd.Init(GL_TEXTURE_EXTERNAL_OES, kNewClientId); 5458 cmd.Init(GL_TEXTURE_EXTERNAL_OES, kNewClientId);
5608 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 5459 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
5609 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 5460 EXPECT_EQ(GL_NO_ERROR, GetGLError());
5610 TextureRef* texture_ref = GetTexture(kNewClientId); 5461 TextureRef* texture_ref = GetTexture(kNewClientId);
5611 EXPECT_TRUE(texture_ref != NULL); 5462 EXPECT_TRUE(texture_ref != NULL);
5612 EXPECT_TRUE(texture_ref->texture()->target() == GL_TEXTURE_EXTERNAL_OES); 5463 EXPECT_TRUE(texture_ref->texture()->target() == GL_TEXTURE_EXTERNAL_OES);
5613 } 5464 }
5614 5465
5615 TEST_P(GLES2DecoderManualInitTest, EGLImageExternalGetBinding) { 5466 TEST_F(GLES2DecoderManualInitTest, EGLImageExternalGetBinding) {
5616 InitState init; 5467 InitState init;
5617 init.extensions = "GL_OES_EGL_image_external"; 5468 init.extensions = "GL_OES_EGL_image_external";
5618 init.gl_version = "opengl es 2.0"; 5469 init.gl_version = "opengl es 2.0";
5619 init.bind_generates_resource = true; 5470 init.bind_generates_resource = true;
5620 InitDecoder(init); 5471 InitDecoder(init);
5621 DoBindTexture(GL_TEXTURE_EXTERNAL_OES, client_texture_id_, kServiceTextureId); 5472 DoBindTexture(GL_TEXTURE_EXTERNAL_OES, client_texture_id_, kServiceTextureId);
5622 5473
5623 EXPECT_CALL(*gl_, GetError()) 5474 EXPECT_CALL(*gl_, GetError())
5624 .WillOnce(Return(GL_NO_ERROR)) 5475 .WillOnce(Return(GL_NO_ERROR))
5625 .WillOnce(Return(GL_NO_ERROR)) 5476 .WillOnce(Return(GL_NO_ERROR))
5626 .RetiresOnSaturation(); 5477 .RetiresOnSaturation();
5627 typedef GetIntegerv::Result Result; 5478 typedef GetIntegerv::Result Result;
5628 Result* result = static_cast<Result*>(shared_memory_address_); 5479 Result* result = static_cast<Result*>(shared_memory_address_);
5629 EXPECT_CALL(*gl_, GetIntegerv(GL_TEXTURE_BINDING_EXTERNAL_OES, 5480 EXPECT_CALL(*gl_, GetIntegerv(GL_TEXTURE_BINDING_EXTERNAL_OES,
5630 result->GetData())) 5481 result->GetData()))
5631 .Times(0); 5482 .Times(0);
5632 result->size = 0; 5483 result->size = 0;
5633 GetIntegerv cmd; 5484 GetIntegerv cmd;
5634 cmd.Init(GL_TEXTURE_BINDING_EXTERNAL_OES, 5485 cmd.Init(GL_TEXTURE_BINDING_EXTERNAL_OES,
5635 shared_memory_id_, 5486 shared_memory_id_,
5636 shared_memory_offset_); 5487 shared_memory_offset_);
5637 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 5488 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
5638 EXPECT_EQ(decoder_->GetGLES2Util()->GLGetNumValuesReturned( 5489 EXPECT_EQ(decoder_->GetGLES2Util()->GLGetNumValuesReturned(
5639 GL_TEXTURE_BINDING_EXTERNAL_OES), result->GetNumResults()); 5490 GL_TEXTURE_BINDING_EXTERNAL_OES), result->GetNumResults());
5640 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 5491 EXPECT_EQ(GL_NO_ERROR, GetGLError());
5641 EXPECT_EQ(client_texture_id_, (uint32)result->GetData()[0]); 5492 EXPECT_EQ(client_texture_id_, (uint32)result->GetData()[0]);
5642 } 5493 }
5643 5494
5644 TEST_P(GLES2DecoderManualInitTest, EGLImageExternalTextureDefaults) { 5495 TEST_F(GLES2DecoderManualInitTest, EGLImageExternalTextureDefaults) {
5645 InitState init; 5496 InitState init;
5646 init.extensions = "GL_OES_EGL_image_external"; 5497 init.extensions = "GL_OES_EGL_image_external";
5647 init.gl_version = "opengl es 2.0"; 5498 init.gl_version = "opengl es 2.0";
5648 init.bind_generates_resource = true; 5499 init.bind_generates_resource = true;
5649 InitDecoder(init); 5500 InitDecoder(init);
5650 DoBindTexture(GL_TEXTURE_EXTERNAL_OES, client_texture_id_, kServiceTextureId); 5501 DoBindTexture(GL_TEXTURE_EXTERNAL_OES, client_texture_id_, kServiceTextureId);
5651 5502
5652 TextureRef* texture_ref = GetTexture(client_texture_id_); 5503 TextureRef* texture_ref = GetTexture(client_texture_id_);
5653 EXPECT_TRUE(texture_ref != NULL); 5504 EXPECT_TRUE(texture_ref != NULL);
5654 Texture* texture = texture_ref->texture(); 5505 Texture* texture = texture_ref->texture();
5655 EXPECT_TRUE(texture->target() == GL_TEXTURE_EXTERNAL_OES); 5506 EXPECT_TRUE(texture->target() == GL_TEXTURE_EXTERNAL_OES);
5656 EXPECT_TRUE(texture->min_filter() == GL_LINEAR); 5507 EXPECT_TRUE(texture->min_filter() == GL_LINEAR);
5657 EXPECT_TRUE(texture->wrap_s() == GL_CLAMP_TO_EDGE); 5508 EXPECT_TRUE(texture->wrap_s() == GL_CLAMP_TO_EDGE);
5658 EXPECT_TRUE(texture->wrap_t() == GL_CLAMP_TO_EDGE); 5509 EXPECT_TRUE(texture->wrap_t() == GL_CLAMP_TO_EDGE);
5659 } 5510 }
5660 5511
5661 TEST_P(GLES2DecoderManualInitTest, EGLImageExternalTextureParam) { 5512 TEST_F(GLES2DecoderManualInitTest, EGLImageExternalTextureParam) {
5662 InitState init; 5513 InitState init;
5663 init.extensions = "GL_OES_EGL_image_external"; 5514 init.extensions = "GL_OES_EGL_image_external";
5664 init.gl_version = "opengl es 2.0"; 5515 init.gl_version = "opengl es 2.0";
5665 init.bind_generates_resource = true; 5516 init.bind_generates_resource = true;
5666 InitDecoder(init); 5517 InitDecoder(init);
5667 DoBindTexture(GL_TEXTURE_EXTERNAL_OES, client_texture_id_, kServiceTextureId); 5518 DoBindTexture(GL_TEXTURE_EXTERNAL_OES, client_texture_id_, kServiceTextureId);
5668 5519
5669 EXPECT_CALL(*gl_, TexParameteri(GL_TEXTURE_EXTERNAL_OES, 5520 EXPECT_CALL(*gl_, TexParameteri(GL_TEXTURE_EXTERNAL_OES,
5670 GL_TEXTURE_MIN_FILTER, 5521 GL_TEXTURE_MIN_FILTER,
5671 GL_NEAREST)); 5522 GL_NEAREST));
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
5705 5556
5706 TextureRef* texture_ref = GetTexture(client_texture_id_); 5557 TextureRef* texture_ref = GetTexture(client_texture_id_);
5707 EXPECT_TRUE(texture_ref != NULL); 5558 EXPECT_TRUE(texture_ref != NULL);
5708 Texture* texture = texture_ref->texture(); 5559 Texture* texture = texture_ref->texture();
5709 EXPECT_TRUE(texture->target() == GL_TEXTURE_EXTERNAL_OES); 5560 EXPECT_TRUE(texture->target() == GL_TEXTURE_EXTERNAL_OES);
5710 EXPECT_TRUE(texture->min_filter() == GL_LINEAR); 5561 EXPECT_TRUE(texture->min_filter() == GL_LINEAR);
5711 EXPECT_TRUE(texture->wrap_s() == GL_CLAMP_TO_EDGE); 5562 EXPECT_TRUE(texture->wrap_s() == GL_CLAMP_TO_EDGE);
5712 EXPECT_TRUE(texture->wrap_t() == GL_CLAMP_TO_EDGE); 5563 EXPECT_TRUE(texture->wrap_t() == GL_CLAMP_TO_EDGE);
5713 } 5564 }
5714 5565
5715 TEST_P(GLES2DecoderManualInitTest, EGLImageExternalTextureParamInvalid) { 5566 TEST_F(GLES2DecoderManualInitTest, EGLImageExternalTextureParamInvalid) {
5716 InitState init; 5567 InitState init;
5717 init.extensions = "GL_OES_EGL_image_external"; 5568 init.extensions = "GL_OES_EGL_image_external";
5718 init.gl_version = "opengl es 2.0"; 5569 init.gl_version = "opengl es 2.0";
5719 init.bind_generates_resource = true; 5570 init.bind_generates_resource = true;
5720 InitDecoder(init); 5571 InitDecoder(init);
5721 DoBindTexture(GL_TEXTURE_EXTERNAL_OES, client_texture_id_, kServiceTextureId); 5572 DoBindTexture(GL_TEXTURE_EXTERNAL_OES, client_texture_id_, kServiceTextureId);
5722 5573
5723 TexParameteri cmd; 5574 TexParameteri cmd;
5724 cmd.Init(GL_TEXTURE_EXTERNAL_OES, 5575 cmd.Init(GL_TEXTURE_EXTERNAL_OES,
5725 GL_TEXTURE_MIN_FILTER, 5576 GL_TEXTURE_MIN_FILTER,
(...skipping 15 matching lines...) Expand all
5741 5592
5742 TextureRef* texture_ref = GetTexture(client_texture_id_); 5593 TextureRef* texture_ref = GetTexture(client_texture_id_);
5743 EXPECT_TRUE(texture_ref != NULL); 5594 EXPECT_TRUE(texture_ref != NULL);
5744 Texture* texture = texture_ref->texture(); 5595 Texture* texture = texture_ref->texture();
5745 EXPECT_TRUE(texture->target() == GL_TEXTURE_EXTERNAL_OES); 5596 EXPECT_TRUE(texture->target() == GL_TEXTURE_EXTERNAL_OES);
5746 EXPECT_TRUE(texture->min_filter() == GL_LINEAR); 5597 EXPECT_TRUE(texture->min_filter() == GL_LINEAR);
5747 EXPECT_TRUE(texture->wrap_s() == GL_CLAMP_TO_EDGE); 5598 EXPECT_TRUE(texture->wrap_s() == GL_CLAMP_TO_EDGE);
5748 EXPECT_TRUE(texture->wrap_t() == GL_CLAMP_TO_EDGE); 5599 EXPECT_TRUE(texture->wrap_t() == GL_CLAMP_TO_EDGE);
5749 } 5600 }
5750 5601
5751 TEST_P(GLES2DecoderManualInitTest, EGLImageExternalTexImage2DError) { 5602 TEST_F(GLES2DecoderManualInitTest, EGLImageExternalTexImage2DError) {
5752 InitState init; 5603 InitState init;
5753 init.extensions = "GL_OES_EGL_image_external"; 5604 init.extensions = "GL_OES_EGL_image_external";
5754 init.gl_version = "opengl es 2.0"; 5605 init.gl_version = "opengl es 2.0";
5755 init.bind_generates_resource = true; 5606 init.bind_generates_resource = true;
5756 InitDecoder(init); 5607 InitDecoder(init);
5757 5608
5758 GLenum target = GL_TEXTURE_EXTERNAL_OES; 5609 GLenum target = GL_TEXTURE_EXTERNAL_OES;
5759 GLint level = 0; 5610 GLint level = 0;
5760 GLenum internal_format = GL_RGBA; 5611 GLenum internal_format = GL_RGBA;
5761 GLsizei width = 2; 5612 GLsizei width = 2;
5762 GLsizei height = 4; 5613 GLsizei height = 4;
5763 GLint border = 0; 5614 GLint border = 0;
5764 GLenum format = GL_RGBA; 5615 GLenum format = GL_RGBA;
5765 GLenum type = GL_UNSIGNED_BYTE; 5616 GLenum type = GL_UNSIGNED_BYTE;
5766 DoBindTexture(GL_TEXTURE_EXTERNAL_OES, client_texture_id_, kServiceTextureId); 5617 DoBindTexture(GL_TEXTURE_EXTERNAL_OES, client_texture_id_, kServiceTextureId);
5767 ASSERT_TRUE(GetTexture(client_texture_id_) != NULL); 5618 ASSERT_TRUE(GetTexture(client_texture_id_) != NULL);
5768 TexImage2D cmd; 5619 TexImage2D cmd;
5769 cmd.Init(target, level, internal_format, width, height, border, format, 5620 cmd.Init(target, level, internal_format, width, height, border, format,
5770 type, kSharedMemoryId, kSharedMemoryOffset); 5621 type, kSharedMemoryId, kSharedMemoryOffset);
5771 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 5622 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
5772 5623
5773 // TexImage2D is not allowed with GL_TEXTURE_EXTERNAL_OES targets. 5624 // TexImage2D is not allowed with GL_TEXTURE_EXTERNAL_OES targets.
5774 EXPECT_EQ(GL_INVALID_ENUM, GetGLError()); 5625 EXPECT_EQ(GL_INVALID_ENUM, GetGLError());
5775 } 5626 }
5776 5627
5777 TEST_P(GLES2DecoderManualInitTest, BindGeneratesResourceFalse) { 5628 TEST_F(GLES2DecoderManualInitTest, BindGeneratesResourceFalse) {
5778 InitState init; 5629 InitState init;
5779 init.gl_version = "3.0"; 5630 init.gl_version = "3.0";
5780 InitDecoder(init); 5631 InitDecoder(init);
5781 5632
5782 BindTexture cmd1; 5633 BindTexture cmd1;
5783 cmd1.Init(GL_TEXTURE_2D, kInvalidClientId); 5634 cmd1.Init(GL_TEXTURE_2D, kInvalidClientId);
5784 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd1)); 5635 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd1));
5785 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); 5636 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
5786 5637
5787 BindBuffer cmd2; 5638 BindBuffer cmd2;
5788 cmd2.Init(GL_ARRAY_BUFFER, kInvalidClientId); 5639 cmd2.Init(GL_ARRAY_BUFFER, kInvalidClientId);
5789 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2)); 5640 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2));
5790 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); 5641 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
5791 5642
5792 BindFramebuffer cmd3; 5643 BindFramebuffer cmd3;
5793 cmd3.Init(GL_FRAMEBUFFER, kInvalidClientId); 5644 cmd3.Init(GL_FRAMEBUFFER, kInvalidClientId);
5794 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd3)); 5645 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd3));
5795 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); 5646 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
5796 5647
5797 BindRenderbuffer cmd4; 5648 BindRenderbuffer cmd4;
5798 cmd4.Init(GL_RENDERBUFFER, kInvalidClientId); 5649 cmd4.Init(GL_RENDERBUFFER, kInvalidClientId);
5799 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd4)); 5650 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd4));
5800 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); 5651 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
5801 } 5652 }
5802 5653
5803 TEST_P(GLES2DecoderManualInitTest, DefaultTextureZero) { 5654 TEST_F(GLES2DecoderManualInitTest, DefaultTextureZero) {
5804 InitState init; 5655 InitState init;
5805 init.gl_version = "3.0"; 5656 init.gl_version = "3.0";
5806 InitDecoder(init); 5657 InitDecoder(init);
5807 5658
5808 BindTexture cmd1; 5659 BindTexture cmd1;
5809 cmd1.Init(GL_TEXTURE_2D, 0); 5660 cmd1.Init(GL_TEXTURE_2D, 0);
5810 EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_2D, 0)); 5661 EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_2D, 0));
5811 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd1)); 5662 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd1));
5812 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 5663 EXPECT_EQ(GL_NO_ERROR, GetGLError());
5813 5664
5814 BindTexture cmd2; 5665 BindTexture cmd2;
5815 cmd2.Init(GL_TEXTURE_CUBE_MAP, 0); 5666 cmd2.Init(GL_TEXTURE_CUBE_MAP, 0);
5816 EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_CUBE_MAP, 0)); 5667 EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_CUBE_MAP, 0));
5817 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2)); 5668 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2));
5818 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 5669 EXPECT_EQ(GL_NO_ERROR, GetGLError());
5819 } 5670 }
5820 5671
5821 TEST_P(GLES2DecoderManualInitTest, DefaultTextureBGR) { 5672 TEST_F(GLES2DecoderManualInitTest, DefaultTextureBGR) {
5822 InitState init; 5673 InitState init;
5823 init.gl_version = "3.0"; 5674 init.gl_version = "3.0";
5824 init.bind_generates_resource = true; 5675 init.bind_generates_resource = true;
5825 InitDecoder(init); 5676 InitDecoder(init);
5826 5677
5827 BindTexture cmd1; 5678 BindTexture cmd1;
5828 cmd1.Init(GL_TEXTURE_2D, 0); 5679 cmd1.Init(GL_TEXTURE_2D, 0);
5829 EXPECT_CALL( 5680 EXPECT_CALL(
5830 *gl_, BindTexture(GL_TEXTURE_2D, TestHelper::kServiceDefaultTexture2dId)); 5681 *gl_, BindTexture(GL_TEXTURE_2D, TestHelper::kServiceDefaultTexture2dId));
5831 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd1)); 5682 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd1));
5832 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 5683 EXPECT_EQ(GL_NO_ERROR, GetGLError());
5833 5684
5834 BindTexture cmd2; 5685 BindTexture cmd2;
5835 cmd2.Init(GL_TEXTURE_CUBE_MAP, 0); 5686 cmd2.Init(GL_TEXTURE_CUBE_MAP, 0);
5836 EXPECT_CALL(*gl_, 5687 EXPECT_CALL(*gl_,
5837 BindTexture(GL_TEXTURE_CUBE_MAP, 5688 BindTexture(GL_TEXTURE_CUBE_MAP,
5838 TestHelper::kServiceDefaultTextureCubemapId)); 5689 TestHelper::kServiceDefaultTextureCubemapId));
5839 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2)); 5690 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2));
5840 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 5691 EXPECT_EQ(GL_NO_ERROR, GetGLError());
5841 } 5692 }
5842 5693
5843 // Test that default texture 0 is immutable. 5694 // Test that default texture 0 is immutable.
5844 TEST_P(GLES2DecoderManualInitTest, NoDefaultTexParameterf) { 5695 TEST_F(GLES2DecoderManualInitTest, NoDefaultTexParameterf) {
5845 InitState init; 5696 InitState init;
5846 init.gl_version = "3.0"; 5697 init.gl_version = "3.0";
5847 InitDecoder(init); 5698 InitDecoder(init);
5848 5699
5849 { 5700 {
5850 BindTexture cmd1; 5701 BindTexture cmd1;
5851 cmd1.Init(GL_TEXTURE_2D, 0); 5702 cmd1.Init(GL_TEXTURE_2D, 0);
5852 EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_2D, 0)); 5703 EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_2D, 0));
5853 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd1)); 5704 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd1));
5854 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 5705 EXPECT_EQ(GL_NO_ERROR, GetGLError());
(...skipping 11 matching lines...) Expand all
5866 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd1)); 5717 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd1));
5867 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 5718 EXPECT_EQ(GL_NO_ERROR, GetGLError());
5868 5719
5869 TexParameterf cmd2; 5720 TexParameterf cmd2;
5870 cmd2.Init(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 5721 cmd2.Init(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
5871 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2)); 5722 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2));
5872 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); 5723 EXPECT_EQ(GL_INVALID_VALUE, GetGLError());
5873 } 5724 }
5874 } 5725 }
5875 5726
5876 TEST_P(GLES2DecoderManualInitTest, NoDefaultTexParameteri) { 5727 TEST_F(GLES2DecoderManualInitTest, NoDefaultTexParameteri) {
5877 InitState init; 5728 InitState init;
5878 init.gl_version = "3.0"; 5729 init.gl_version = "3.0";
5879 InitDecoder(init); 5730 InitDecoder(init);
5880 5731
5881 { 5732 {
5882 BindTexture cmd1; 5733 BindTexture cmd1;
5883 cmd1.Init(GL_TEXTURE_2D, 0); 5734 cmd1.Init(GL_TEXTURE_2D, 0);
5884 EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_2D, 0)); 5735 EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_2D, 0));
5885 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd1)); 5736 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd1));
5886 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 5737 EXPECT_EQ(GL_NO_ERROR, GetGLError());
(...skipping 11 matching lines...) Expand all
5898 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd1)); 5749 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd1));
5899 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 5750 EXPECT_EQ(GL_NO_ERROR, GetGLError());
5900 5751
5901 TexParameteri cmd2; 5752 TexParameteri cmd2;
5902 cmd2.Init(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 5753 cmd2.Init(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
5903 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2)); 5754 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2));
5904 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); 5755 EXPECT_EQ(GL_INVALID_VALUE, GetGLError());
5905 } 5756 }
5906 } 5757 }
5907 5758
5908 TEST_P(GLES2DecoderManualInitTest, NoDefaultTexParameterfv) { 5759 TEST_F(GLES2DecoderManualInitTest, NoDefaultTexParameterfv) {
5909 InitState init; 5760 InitState init;
5910 init.gl_version = "3.0"; 5761 init.gl_version = "3.0";
5911 InitDecoder(init); 5762 InitDecoder(init);
5912 5763
5913 { 5764 {
5914 BindTexture cmd1; 5765 BindTexture cmd1;
5915 cmd1.Init(GL_TEXTURE_2D, 0); 5766 cmd1.Init(GL_TEXTURE_2D, 0);
5916 EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_2D, 0)); 5767 EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_2D, 0));
5917 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd1)); 5768 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd1));
5918 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 5769 EXPECT_EQ(GL_NO_ERROR, GetGLError());
(...skipping 19 matching lines...) Expand all
5938 cmd2.Init(GL_TEXTURE_CUBE_MAP, 5789 cmd2.Init(GL_TEXTURE_CUBE_MAP,
5939 GL_TEXTURE_MAG_FILTER, 5790 GL_TEXTURE_MAG_FILTER,
5940 shared_memory_id_, 5791 shared_memory_id_,
5941 shared_memory_offset_); 5792 shared_memory_offset_);
5942 GetSharedMemoryAs<GLfloat*>()[0] = GL_NEAREST; 5793 GetSharedMemoryAs<GLfloat*>()[0] = GL_NEAREST;
5943 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2)); 5794 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2));
5944 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); 5795 EXPECT_EQ(GL_INVALID_VALUE, GetGLError());
5945 } 5796 }
5946 } 5797 }
5947 5798
5948 TEST_P(GLES2DecoderManualInitTest, NoDefaultTexParameteriv) { 5799 TEST_F(GLES2DecoderManualInitTest, NoDefaultTexParameteriv) {
5949 InitState init; 5800 InitState init;
5950 init.gl_version = "3.0"; 5801 init.gl_version = "3.0";
5951 InitDecoder(init); 5802 InitDecoder(init);
5952 5803
5953 { 5804 {
5954 BindTexture cmd1; 5805 BindTexture cmd1;
5955 cmd1.Init(GL_TEXTURE_2D, 0); 5806 cmd1.Init(GL_TEXTURE_2D, 0);
5956 EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_2D, 0)); 5807 EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_2D, 0));
5957 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd1)); 5808 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd1));
5958 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 5809 EXPECT_EQ(GL_NO_ERROR, GetGLError());
(...skipping 19 matching lines...) Expand all
5978 cmd2.Init(GL_TEXTURE_CUBE_MAP, 5829 cmd2.Init(GL_TEXTURE_CUBE_MAP,
5979 GL_TEXTURE_MAG_FILTER, 5830 GL_TEXTURE_MAG_FILTER,
5980 shared_memory_id_, 5831 shared_memory_id_,
5981 shared_memory_offset_); 5832 shared_memory_offset_);
5982 GetSharedMemoryAs<GLint*>()[0] = GL_NEAREST; 5833 GetSharedMemoryAs<GLint*>()[0] = GL_NEAREST;
5983 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2)); 5834 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2));
5984 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); 5835 EXPECT_EQ(GL_INVALID_VALUE, GetGLError());
5985 } 5836 }
5986 } 5837 }
5987 5838
5988 TEST_P(GLES2DecoderManualInitTest, NoDefaultTexImage2D) { 5839 TEST_F(GLES2DecoderManualInitTest, NoDefaultTexImage2D) {
5989 InitState init; 5840 InitState init;
5990 init.gl_version = "3.0"; 5841 init.gl_version = "3.0";
5991 InitDecoder(init); 5842 InitDecoder(init);
5992 5843
5993 BindTexture cmd1; 5844 BindTexture cmd1;
5994 cmd1.Init(GL_TEXTURE_2D, 0); 5845 cmd1.Init(GL_TEXTURE_2D, 0);
5995 EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_2D, 0)); 5846 EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_2D, 0));
5996 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd1)); 5847 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd1));
5997 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 5848 EXPECT_EQ(GL_NO_ERROR, GetGLError());
5998 5849
5999 TexImage2D cmd2; 5850 TexImage2D cmd2;
6000 cmd2.Init(GL_TEXTURE_2D, 5851 cmd2.Init(GL_TEXTURE_2D,
6001 0, 5852 0,
6002 GL_RGBA, 5853 GL_RGBA,
6003 2, 5854 2,
6004 2, 5855 2,
6005 0, 5856 0,
6006 GL_RGBA, 5857 GL_RGBA,
6007 GL_UNSIGNED_BYTE, 5858 GL_UNSIGNED_BYTE,
6008 kSharedMemoryId, 5859 kSharedMemoryId,
6009 kSharedMemoryOffset); 5860 kSharedMemoryOffset);
6010 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2)); 5861 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2));
6011 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); 5862 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
6012 } 5863 }
6013 5864
6014 TEST_P(GLES2DecoderManualInitTest, NoDefaultTexSubImage2D) { 5865 TEST_F(GLES2DecoderManualInitTest, NoDefaultTexSubImage2D) {
6015 InitState init; 5866 InitState init;
6016 init.gl_version = "3.0"; 5867 init.gl_version = "3.0";
6017 InitDecoder(init); 5868 InitDecoder(init);
6018 5869
6019 BindTexture cmd1; 5870 BindTexture cmd1;
6020 cmd1.Init(GL_TEXTURE_2D, 0); 5871 cmd1.Init(GL_TEXTURE_2D, 0);
6021 EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_2D, 0)); 5872 EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_2D, 0));
6022 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd1)); 5873 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd1));
6023 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 5874 EXPECT_EQ(GL_NO_ERROR, GetGLError());
6024 5875
6025 TexSubImage2D cmd2; 5876 TexSubImage2D cmd2;
6026 cmd2.Init(GL_TEXTURE_2D, 5877 cmd2.Init(GL_TEXTURE_2D,
6027 0, 5878 0,
6028 1, 5879 1,
6029 1, 5880 1,
6030 1, 5881 1,
6031 1, 5882 1,
6032 GL_RGBA, 5883 GL_RGBA,
6033 GL_UNSIGNED_BYTE, 5884 GL_UNSIGNED_BYTE,
6034 kSharedMemoryId, 5885 kSharedMemoryId,
6035 kSharedMemoryOffset, 5886 kSharedMemoryOffset,
6036 GL_FALSE); 5887 GL_FALSE);
6037 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2)); 5888 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2));
6038 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); 5889 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
6039 } 5890 }
6040 5891
6041 TEST_P(GLES2DecoderManualInitTest, ARBTextureRectangleBindTexture) { 5892 TEST_F(GLES2DecoderManualInitTest, ARBTextureRectangleBindTexture) {
6042 InitState init; 5893 InitState init;
6043 init.extensions = "GL_ARB_texture_rectangle"; 5894 init.extensions = "GL_ARB_texture_rectangle";
6044 init.gl_version = "3.0"; 5895 init.gl_version = "3.0";
6045 init.bind_generates_resource = true; 5896 init.bind_generates_resource = true;
6046 InitDecoder(init); 5897 InitDecoder(init);
6047 EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_RECTANGLE_ARB, kNewServiceId)); 5898 EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_RECTANGLE_ARB, kNewServiceId));
6048 EXPECT_CALL(*gl_, GenTextures(1, _)) 5899 EXPECT_CALL(*gl_, GenTextures(1, _))
6049 .WillOnce(SetArgumentPointee<1>(kNewServiceId)); 5900 .WillOnce(SetArgumentPointee<1>(kNewServiceId));
6050 BindTexture cmd; 5901 BindTexture cmd;
6051 cmd.Init(GL_TEXTURE_RECTANGLE_ARB, kNewClientId); 5902 cmd.Init(GL_TEXTURE_RECTANGLE_ARB, kNewClientId);
6052 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 5903 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
6053 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 5904 EXPECT_EQ(GL_NO_ERROR, GetGLError());
6054 Texture* texture = GetTexture(kNewClientId)->texture(); 5905 Texture* texture = GetTexture(kNewClientId)->texture();
6055 EXPECT_TRUE(texture != NULL); 5906 EXPECT_TRUE(texture != NULL);
6056 EXPECT_TRUE(texture->target() == GL_TEXTURE_RECTANGLE_ARB); 5907 EXPECT_TRUE(texture->target() == GL_TEXTURE_RECTANGLE_ARB);
6057 } 5908 }
6058 5909
6059 TEST_P(GLES2DecoderManualInitTest, ARBTextureRectangleGetBinding) { 5910 TEST_F(GLES2DecoderManualInitTest, ARBTextureRectangleGetBinding) {
6060 InitState init; 5911 InitState init;
6061 init.extensions = "GL_ARB_texture_rectangle"; 5912 init.extensions = "GL_ARB_texture_rectangle";
6062 init.gl_version = "3.0"; 5913 init.gl_version = "3.0";
6063 init.bind_generates_resource = true; 5914 init.bind_generates_resource = true;
6064 InitDecoder(init); 5915 InitDecoder(init);
6065 DoBindTexture( 5916 DoBindTexture(
6066 GL_TEXTURE_RECTANGLE_ARB, client_texture_id_, kServiceTextureId); 5917 GL_TEXTURE_RECTANGLE_ARB, client_texture_id_, kServiceTextureId);
6067 5918
6068 EXPECT_CALL(*gl_, GetError()) 5919 EXPECT_CALL(*gl_, GetError())
6069 .WillOnce(Return(GL_NO_ERROR)) 5920 .WillOnce(Return(GL_NO_ERROR))
6070 .WillOnce(Return(GL_NO_ERROR)) 5921 .WillOnce(Return(GL_NO_ERROR))
6071 .RetiresOnSaturation(); 5922 .RetiresOnSaturation();
6072 typedef GetIntegerv::Result Result; 5923 typedef GetIntegerv::Result Result;
6073 Result* result = static_cast<Result*>(shared_memory_address_); 5924 Result* result = static_cast<Result*>(shared_memory_address_);
6074 EXPECT_CALL(*gl_, GetIntegerv(GL_TEXTURE_BINDING_RECTANGLE_ARB, 5925 EXPECT_CALL(*gl_, GetIntegerv(GL_TEXTURE_BINDING_RECTANGLE_ARB,
6075 result->GetData())) 5926 result->GetData()))
6076 .Times(0); 5927 .Times(0);
6077 result->size = 0; 5928 result->size = 0;
6078 GetIntegerv cmd; 5929 GetIntegerv cmd;
6079 cmd.Init(GL_TEXTURE_BINDING_RECTANGLE_ARB, 5930 cmd.Init(GL_TEXTURE_BINDING_RECTANGLE_ARB,
6080 shared_memory_id_, 5931 shared_memory_id_,
6081 shared_memory_offset_); 5932 shared_memory_offset_);
6082 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 5933 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
6083 EXPECT_EQ(decoder_->GetGLES2Util()->GLGetNumValuesReturned( 5934 EXPECT_EQ(decoder_->GetGLES2Util()->GLGetNumValuesReturned(
6084 GL_TEXTURE_BINDING_RECTANGLE_ARB), result->GetNumResults()); 5935 GL_TEXTURE_BINDING_RECTANGLE_ARB), result->GetNumResults());
6085 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 5936 EXPECT_EQ(GL_NO_ERROR, GetGLError());
6086 EXPECT_EQ(client_texture_id_, (uint32)result->GetData()[0]); 5937 EXPECT_EQ(client_texture_id_, (uint32)result->GetData()[0]);
6087 } 5938 }
6088 5939
6089 TEST_P(GLES2DecoderManualInitTest, ARBTextureRectangleTextureDefaults) { 5940 TEST_F(GLES2DecoderManualInitTest, ARBTextureRectangleTextureDefaults) {
6090 InitState init; 5941 InitState init;
6091 init.extensions = "GL_ARB_texture_rectangle"; 5942 init.extensions = "GL_ARB_texture_rectangle";
6092 init.gl_version = "3.0"; 5943 init.gl_version = "3.0";
6093 init.bind_generates_resource = true; 5944 init.bind_generates_resource = true;
6094 InitDecoder(init); 5945 InitDecoder(init);
6095 DoBindTexture( 5946 DoBindTexture(
6096 GL_TEXTURE_RECTANGLE_ARB, client_texture_id_, kServiceTextureId); 5947 GL_TEXTURE_RECTANGLE_ARB, client_texture_id_, kServiceTextureId);
6097 5948
6098 Texture* texture = GetTexture(client_texture_id_)->texture(); 5949 Texture* texture = GetTexture(client_texture_id_)->texture();
6099 EXPECT_TRUE(texture != NULL); 5950 EXPECT_TRUE(texture != NULL);
6100 EXPECT_TRUE(texture->target() == GL_TEXTURE_RECTANGLE_ARB); 5951 EXPECT_TRUE(texture->target() == GL_TEXTURE_RECTANGLE_ARB);
6101 EXPECT_TRUE(texture->min_filter() == GL_LINEAR); 5952 EXPECT_TRUE(texture->min_filter() == GL_LINEAR);
6102 EXPECT_TRUE(texture->wrap_s() == GL_CLAMP_TO_EDGE); 5953 EXPECT_TRUE(texture->wrap_s() == GL_CLAMP_TO_EDGE);
6103 EXPECT_TRUE(texture->wrap_t() == GL_CLAMP_TO_EDGE); 5954 EXPECT_TRUE(texture->wrap_t() == GL_CLAMP_TO_EDGE);
6104 } 5955 }
6105 5956
6106 TEST_P(GLES2DecoderManualInitTest, ARBTextureRectangleTextureParam) { 5957 TEST_F(GLES2DecoderManualInitTest, ARBTextureRectangleTextureParam) {
6107 InitState init; 5958 InitState init;
6108 init.extensions = "GL_ARB_texture_rectangle"; 5959 init.extensions = "GL_ARB_texture_rectangle";
6109 init.gl_version = "3.0"; 5960 init.gl_version = "3.0";
6110 init.bind_generates_resource = true; 5961 init.bind_generates_resource = true;
6111 InitDecoder(init); 5962 InitDecoder(init);
6112 5963
6113 DoBindTexture( 5964 DoBindTexture(
6114 GL_TEXTURE_RECTANGLE_ARB, client_texture_id_, kServiceTextureId); 5965 GL_TEXTURE_RECTANGLE_ARB, client_texture_id_, kServiceTextureId);
6115 5966
6116 EXPECT_CALL(*gl_, TexParameteri(GL_TEXTURE_RECTANGLE_ARB, 5967 EXPECT_CALL(*gl_, TexParameteri(GL_TEXTURE_RECTANGLE_ARB,
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
6151 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 6002 EXPECT_EQ(GL_NO_ERROR, GetGLError());
6152 6003
6153 Texture* texture = GetTexture(client_texture_id_)->texture(); 6004 Texture* texture = GetTexture(client_texture_id_)->texture();
6154 EXPECT_TRUE(texture != NULL); 6005 EXPECT_TRUE(texture != NULL);
6155 EXPECT_TRUE(texture->target() == GL_TEXTURE_RECTANGLE_ARB); 6006 EXPECT_TRUE(texture->target() == GL_TEXTURE_RECTANGLE_ARB);
6156 EXPECT_TRUE(texture->min_filter() == GL_LINEAR); 6007 EXPECT_TRUE(texture->min_filter() == GL_LINEAR);
6157 EXPECT_TRUE(texture->wrap_s() == GL_CLAMP_TO_EDGE); 6008 EXPECT_TRUE(texture->wrap_s() == GL_CLAMP_TO_EDGE);
6158 EXPECT_TRUE(texture->wrap_t() == GL_CLAMP_TO_EDGE); 6009 EXPECT_TRUE(texture->wrap_t() == GL_CLAMP_TO_EDGE);
6159 } 6010 }
6160 6011
6161 TEST_P(GLES2DecoderManualInitTest, ARBTextureRectangleTextureParamInvalid) { 6012 TEST_F(GLES2DecoderManualInitTest, ARBTextureRectangleTextureParamInvalid) {
6162 InitState init; 6013 InitState init;
6163 init.extensions = "GL_ARB_texture_rectangle"; 6014 init.extensions = "GL_ARB_texture_rectangle";
6164 init.gl_version = "3.0"; 6015 init.gl_version = "3.0";
6165 init.bind_generates_resource = true; 6016 init.bind_generates_resource = true;
6166 InitDecoder(init); 6017 InitDecoder(init);
6167 6018
6168 DoBindTexture( 6019 DoBindTexture(
6169 GL_TEXTURE_RECTANGLE_ARB, client_texture_id_, kServiceTextureId); 6020 GL_TEXTURE_RECTANGLE_ARB, client_texture_id_, kServiceTextureId);
6170 6021
6171 TexParameteri cmd; 6022 TexParameteri cmd;
(...skipping 16 matching lines...) Expand all
6188 EXPECT_EQ(GL_INVALID_ENUM, GetGLError()); 6039 EXPECT_EQ(GL_INVALID_ENUM, GetGLError());
6189 6040
6190 Texture* texture = GetTexture(client_texture_id_)->texture(); 6041 Texture* texture = GetTexture(client_texture_id_)->texture();
6191 EXPECT_TRUE(texture != NULL); 6042 EXPECT_TRUE(texture != NULL);
6192 EXPECT_TRUE(texture->target() == GL_TEXTURE_RECTANGLE_ARB); 6043 EXPECT_TRUE(texture->target() == GL_TEXTURE_RECTANGLE_ARB);
6193 EXPECT_TRUE(texture->min_filter() == GL_LINEAR); 6044 EXPECT_TRUE(texture->min_filter() == GL_LINEAR);
6194 EXPECT_TRUE(texture->wrap_s() == GL_CLAMP_TO_EDGE); 6045 EXPECT_TRUE(texture->wrap_s() == GL_CLAMP_TO_EDGE);
6195 EXPECT_TRUE(texture->wrap_t() == GL_CLAMP_TO_EDGE); 6046 EXPECT_TRUE(texture->wrap_t() == GL_CLAMP_TO_EDGE);
6196 } 6047 }
6197 6048
6198 TEST_P(GLES2DecoderManualInitTest, ARBTextureRectangleTexImage2DError) { 6049 TEST_F(GLES2DecoderManualInitTest, ARBTextureRectangleTexImage2DError) {
6199 InitState init; 6050 InitState init;
6200 init.extensions = "GL_ARB_texture_rectangle"; 6051 init.extensions = "GL_ARB_texture_rectangle";
6201 init.gl_version = "3.0"; 6052 init.gl_version = "3.0";
6202 init.bind_generates_resource = true; 6053 init.bind_generates_resource = true;
6203 InitDecoder(init); 6054 InitDecoder(init);
6204 6055
6205 GLenum target = GL_TEXTURE_RECTANGLE_ARB; 6056 GLenum target = GL_TEXTURE_RECTANGLE_ARB;
6206 GLint level = 0; 6057 GLint level = 0;
6207 GLenum internal_format = GL_RGBA; 6058 GLenum internal_format = GL_RGBA;
6208 GLsizei width = 2; 6059 GLsizei width = 2;
6209 GLsizei height = 4; 6060 GLsizei height = 4;
6210 GLint border = 0; 6061 GLint border = 0;
6211 GLenum format = GL_RGBA; 6062 GLenum format = GL_RGBA;
6212 GLenum type = GL_UNSIGNED_BYTE; 6063 GLenum type = GL_UNSIGNED_BYTE;
6213 DoBindTexture( 6064 DoBindTexture(
6214 GL_TEXTURE_RECTANGLE_ARB, client_texture_id_, kServiceTextureId); 6065 GL_TEXTURE_RECTANGLE_ARB, client_texture_id_, kServiceTextureId);
6215 ASSERT_TRUE(GetTexture(client_texture_id_) != NULL); 6066 ASSERT_TRUE(GetTexture(client_texture_id_) != NULL);
6216 TexImage2D cmd; 6067 TexImage2D cmd;
6217 cmd.Init(target, level, internal_format, width, height, border, format, 6068 cmd.Init(target, level, internal_format, width, height, border, format,
6218 type, kSharedMemoryId, kSharedMemoryOffset); 6069 type, kSharedMemoryId, kSharedMemoryOffset);
6219 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 6070 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
6220 6071
6221 // TexImage2D is not allowed with GL_TEXTURE_RECTANGLE_ARB targets. 6072 // TexImage2D is not allowed with GL_TEXTURE_RECTANGLE_ARB targets.
6222 EXPECT_EQ(GL_INVALID_ENUM, GetGLError()); 6073 EXPECT_EQ(GL_INVALID_ENUM, GetGLError());
6223 } 6074 }
6224 6075
6225 TEST_P(GLES2DecoderTest, EnableFeatureCHROMIUMBadBucket) { 6076 TEST_F(GLES2DecoderTest, EnableFeatureCHROMIUMBadBucket) {
6226 const uint32 kBadBucketId = 123; 6077 const uint32 kBadBucketId = 123;
6227 EnableFeatureCHROMIUM cmd; 6078 EnableFeatureCHROMIUM cmd;
6228 cmd.Init(kBadBucketId, shared_memory_id_, shared_memory_offset_); 6079 cmd.Init(kBadBucketId, shared_memory_id_, shared_memory_offset_);
6229 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); 6080 EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
6230 } 6081 }
6231 6082
6232 TEST_P(GLES2DecoderTest, RequestExtensionCHROMIUMBadBucket) { 6083 TEST_F(GLES2DecoderTest, RequestExtensionCHROMIUMBadBucket) {
6233 const uint32 kBadBucketId = 123; 6084 const uint32 kBadBucketId = 123;
6234 RequestExtensionCHROMIUM cmd; 6085 RequestExtensionCHROMIUM cmd;
6235 cmd.Init(kBadBucketId); 6086 cmd.Init(kBadBucketId);
6236 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); 6087 EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
6237 } 6088 }
6238 6089
6239 TEST_P(GLES2DecoderManualInitTest, TexSubImage2DClearsAfterTexImage2DNULL) { 6090 TEST_F(GLES2DecoderTest, TexSubImage2DClearsAfterTexImage2DNULL) {
6240 InitState init;
6241 init.gl_version = "opengl es 2.0";
6242 init.has_alpha = true;
6243 init.has_depth = true;
6244 init.request_alpha = true;
6245 init.request_depth = true;
6246 InitDecoder(init);
6247
6248 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); 6091 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId);
6249 DoTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, 6092 DoTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE,
6250 0, 0); 6093 0, 0);
6251 SetupClearTextureExpectations( 6094 SetupClearTextureExpectations(
6252 kServiceTextureId, kServiceTextureId, GL_TEXTURE_2D, GL_TEXTURE_2D, 6095 kServiceTextureId, kServiceTextureId, GL_TEXTURE_2D, GL_TEXTURE_2D,
6253 0, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, 2, 2); 6096 0, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, 2, 2);
6254 EXPECT_CALL(*gl_, TexSubImage2D( 6097 EXPECT_CALL(*gl_, TexSubImage2D(
6255 GL_TEXTURE_2D, 0, 1, 1, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, 6098 GL_TEXTURE_2D, 0, 1, 1, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE,
6256 shared_memory_address_)) 6099 shared_memory_address_))
6257 .Times(1) 6100 .Times(1)
6258 .RetiresOnSaturation(); 6101 .RetiresOnSaturation();
6259 TexSubImage2D cmd; 6102 TexSubImage2D cmd;
6260 cmd.Init( 6103 cmd.Init(
6261 GL_TEXTURE_2D, 0, 1, 1, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, 6104 GL_TEXTURE_2D, 0, 1, 1, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE,
6262 kSharedMemoryId, kSharedMemoryOffset, GL_FALSE); 6105 kSharedMemoryId, kSharedMemoryOffset, GL_FALSE);
6263 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 6106 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
6264 // Test if we call it again it does not clear. 6107 // Test if we call it again it does not clear.
6265 EXPECT_CALL(*gl_, TexSubImage2D( 6108 EXPECT_CALL(*gl_, TexSubImage2D(
6266 GL_TEXTURE_2D, 0, 1, 1, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, 6109 GL_TEXTURE_2D, 0, 1, 1, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE,
6267 shared_memory_address_)) 6110 shared_memory_address_))
6268 .Times(1) 6111 .Times(1)
6269 .RetiresOnSaturation(); 6112 .RetiresOnSaturation();
6270 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 6113 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
6271 } 6114 }
6272 6115
6273 TEST_P(GLES2DecoderTest, TexSubImage2DDoesNotClearAfterTexImage2DNULLThenData) { 6116 TEST_F(GLES2DecoderTest, TexSubImage2DDoesNotClearAfterTexImage2DNULLThenData) {
6274 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); 6117 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId);
6275 DoTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, 6118 DoTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE,
6276 0, 0); 6119 0, 0);
6277 DoTexImage2D( 6120 DoTexImage2D(
6278 GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, 6121 GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE,
6279 kSharedMemoryId, kSharedMemoryOffset); 6122 kSharedMemoryId, kSharedMemoryOffset);
6280 EXPECT_CALL(*gl_, TexSubImage2D( 6123 EXPECT_CALL(*gl_, TexSubImage2D(
6281 GL_TEXTURE_2D, 0, 1, 1, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, 6124 GL_TEXTURE_2D, 0, 1, 1, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE,
6282 shared_memory_address_)) 6125 shared_memory_address_))
6283 .Times(1) 6126 .Times(1)
6284 .RetiresOnSaturation(); 6127 .RetiresOnSaturation();
6285 TexSubImage2D cmd; 6128 TexSubImage2D cmd;
6286 cmd.Init( 6129 cmd.Init(
6287 GL_TEXTURE_2D, 0, 1, 1, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, 6130 GL_TEXTURE_2D, 0, 1, 1, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE,
6288 kSharedMemoryId, kSharedMemoryOffset, GL_FALSE); 6131 kSharedMemoryId, kSharedMemoryOffset, GL_FALSE);
6289 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 6132 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
6290 // Test if we call it again it does not clear. 6133 // Test if we call it again it does not clear.
6291 EXPECT_CALL(*gl_, TexSubImage2D( 6134 EXPECT_CALL(*gl_, TexSubImage2D(
6292 GL_TEXTURE_2D, 0, 1, 1, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, 6135 GL_TEXTURE_2D, 0, 1, 1, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE,
6293 shared_memory_address_)) 6136 shared_memory_address_))
6294 .Times(1) 6137 .Times(1)
6295 .RetiresOnSaturation(); 6138 .RetiresOnSaturation();
6296 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 6139 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
6297 } 6140 }
6298 6141
6299 TEST_P( 6142 TEST_F(
6300 GLES2DecoderManualInitTest, 6143 GLES2DecoderManualInitTest,
6301 TexSubImage2DDoesNotClearAfterTexImage2DNULLThenDataWithTexImage2DIsFaster) { 6144 TexSubImage2DDoesNotClearAfterTexImage2DNULLThenDataWithTexImage2DIsFaster) {
6302 CommandLine command_line(0, NULL); 6145 CommandLine command_line(0, NULL);
6303 command_line.AppendSwitchASCII( 6146 command_line.AppendSwitchASCII(
6304 switches::kGpuDriverBugWorkarounds, 6147 switches::kGpuDriverBugWorkarounds,
6305 base::IntToString(gpu::TEXSUBIMAGE2D_FASTER_THAN_TEXIMAGE2D)); 6148 base::IntToString(gpu::TEXSUBIMAGE2D_FASTER_THAN_TEXIMAGE2D));
6306 InitState init; 6149 InitState init;
6307 init.gl_version = "3.0"; 6150 init.gl_version = "3.0";
6308 init.bind_generates_resource = true; 6151 init.bind_generates_resource = true;
6309 InitDecoderWithCommandLine(init, &command_line); 6152 InitDecoderWithCommandLine(init, &command_line);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
6345 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 6188 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
6346 // Test if we call it again it does not clear. 6189 // Test if we call it again it does not clear.
6347 EXPECT_CALL(*gl_, TexSubImage2D( 6190 EXPECT_CALL(*gl_, TexSubImage2D(
6348 GL_TEXTURE_2D, 0, 1, 1, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, 6191 GL_TEXTURE_2D, 0, 1, 1, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE,
6349 shared_memory_address_)) 6192 shared_memory_address_))
6350 .Times(1) 6193 .Times(1)
6351 .RetiresOnSaturation(); 6194 .RetiresOnSaturation();
6352 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 6195 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
6353 } 6196 }
6354 6197
6355 TEST_P(GLES2DecoderTest, TexSubImage2DClearsAfterTexImage2DWithDataThenNULL) { 6198 TEST_F(GLES2DecoderTest, TexSubImage2DClearsAfterTexImage2DWithDataThenNULL) {
6356 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); 6199 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId);
6357 // Put in data (so it should be marked as cleared) 6200 // Put in data (so it should be marked as cleared)
6358 DoTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, 6201 DoTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE,
6359 kSharedMemoryId, kSharedMemoryOffset); 6202 kSharedMemoryId, kSharedMemoryOffset);
6360 // Put in no data. 6203 // Put in no data.
6361 TexImage2D tex_cmd; 6204 TexImage2D tex_cmd;
6362 tex_cmd.Init( 6205 tex_cmd.Init(
6363 GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0, 0); 6206 GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0, 0);
6364 // It won't actually call TexImage2D, just mark it as uncleared. 6207 // It won't actually call TexImage2D, just mark it as uncleared.
6365 EXPECT_EQ(error::kNoError, ExecuteCmd(tex_cmd)); 6208 EXPECT_EQ(error::kNoError, ExecuteCmd(tex_cmd));
6366 // Next call to TexSubImage2d should clear. 6209 // Next call to TexSubImage2d should clear.
6367 SetupClearTextureExpectations( 6210 SetupClearTextureExpectations(
6368 kServiceTextureId, kServiceTextureId, GL_TEXTURE_2D, GL_TEXTURE_2D, 6211 kServiceTextureId, kServiceTextureId, GL_TEXTURE_2D, GL_TEXTURE_2D,
6369 0, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, 2, 2); 6212 0, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, 2, 2);
6370 EXPECT_CALL(*gl_, TexSubImage2D( 6213 EXPECT_CALL(*gl_, TexSubImage2D(
6371 GL_TEXTURE_2D, 0, 1, 1, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, 6214 GL_TEXTURE_2D, 0, 1, 1, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE,
6372 shared_memory_address_)) 6215 shared_memory_address_))
6373 .Times(1) 6216 .Times(1)
6374 .RetiresOnSaturation(); 6217 .RetiresOnSaturation();
6375 TexSubImage2D cmd; 6218 TexSubImage2D cmd;
6376 cmd.Init( 6219 cmd.Init(
6377 GL_TEXTURE_2D, 0, 1, 1, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, 6220 GL_TEXTURE_2D, 0, 1, 1, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE,
6378 kSharedMemoryId, kSharedMemoryOffset, GL_FALSE); 6221 kSharedMemoryId, kSharedMemoryOffset, GL_FALSE);
6379 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 6222 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
6380 } 6223 }
6381 6224
6382 TEST_P(GLES2DecoderWithShaderTest, DrawArraysClearsAfterTexImage2DNULL) { 6225 TEST_F(GLES2DecoderWithShaderTest, DrawArraysClearsAfterTexImage2DNULL) {
6383 SetupAllNeededVertexBuffers(); 6226 SetupAllNeededVertexBuffers();
6384 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); 6227 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId);
6385 // Create an uncleared texture with 2 levels. 6228 // Create an uncleared texture with 2 levels.
6386 DoTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, 6229 DoTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE,
6387 0, 0); 6230 0, 0);
6388 DoTexImage2D(GL_TEXTURE_2D, 1, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 6231 DoTexImage2D(GL_TEXTURE_2D, 1, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE,
6389 0, 0); 6232 0, 0);
6390 // Expect 2 levels will be cleared. 6233 // Expect 2 levels will be cleared.
6391 SetupClearTextureExpectations( 6234 SetupClearTextureExpectations(
6392 kServiceTextureId, kServiceTextureId, GL_TEXTURE_2D, GL_TEXTURE_2D, 6235 kServiceTextureId, kServiceTextureId, GL_TEXTURE_2D, GL_TEXTURE_2D,
(...skipping 11 matching lines...) Expand all
6404 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 6247 EXPECT_EQ(GL_NO_ERROR, GetGLError());
6405 6248
6406 // But not again 6249 // But not again
6407 EXPECT_CALL(*gl_, DrawArrays(GL_TRIANGLES, 0, kNumVertices)) 6250 EXPECT_CALL(*gl_, DrawArrays(GL_TRIANGLES, 0, kNumVertices))
6408 .Times(1) 6251 .Times(1)
6409 .RetiresOnSaturation(); 6252 .RetiresOnSaturation();
6410 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 6253 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
6411 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 6254 EXPECT_EQ(GL_NO_ERROR, GetGLError());
6412 } 6255 }
6413 6256
6414 TEST_P(GLES2DecoderWithShaderTest, DrawElementsClearsAfterTexImage2DNULL) { 6257 TEST_F(GLES2DecoderWithShaderTest, DrawElementsClearsAfterTexImage2DNULL) {
6415 SetupAllNeededVertexBuffers(); 6258 SetupAllNeededVertexBuffers();
6416 SetupIndexBuffer(); 6259 SetupIndexBuffer();
6417 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); 6260 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId);
6418 // Create an uncleared texture with 2 levels. 6261 // Create an uncleared texture with 2 levels.
6419 DoTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, 6262 DoTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE,
6420 0, 0); 6263 0, 0);
6421 DoTexImage2D(GL_TEXTURE_2D, 1, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 6264 DoTexImage2D(GL_TEXTURE_2D, 1, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE,
6422 0, 0); 6265 0, 0);
6423 // Expect 2 levels will be cleared. 6266 // Expect 2 levels will be cleared.
6424 SetupClearTextureExpectations( 6267 SetupClearTextureExpectations(
(...skipping 18 matching lines...) Expand all
6443 // But not again 6286 // But not again
6444 EXPECT_CALL(*gl_, DrawElements(GL_TRIANGLES, kValidIndexRangeCount, 6287 EXPECT_CALL(*gl_, DrawElements(GL_TRIANGLES, kValidIndexRangeCount,
6445 GL_UNSIGNED_SHORT, 6288 GL_UNSIGNED_SHORT,
6446 BufferOffset(kValidIndexRangeStart * 2))) 6289 BufferOffset(kValidIndexRangeStart * 2)))
6447 .Times(1) 6290 .Times(1)
6448 .RetiresOnSaturation(); 6291 .RetiresOnSaturation();
6449 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 6292 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
6450 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 6293 EXPECT_EQ(GL_NO_ERROR, GetGLError());
6451 } 6294 }
6452 6295
6453 TEST_P(GLES2DecoderWithShaderTest, DrawClearsAfterTexImage2DNULLInFBO) { 6296 TEST_F(GLES2DecoderWithShaderTest, DrawClearsAfterTexImage2DNULLInFBO) {
6454 const GLuint kFBOClientTextureId = 4100; 6297 const GLuint kFBOClientTextureId = 4100;
6455 const GLuint kFBOServiceTextureId = 4101; 6298 const GLuint kFBOServiceTextureId = 4101;
6456 6299
6457 SetupAllNeededVertexBuffers(); 6300 SetupAllNeededVertexBuffers();
6458 // Register a texture id. 6301 // Register a texture id.
6459 EXPECT_CALL(*gl_, GenTextures(_, _)) 6302 EXPECT_CALL(*gl_, GenTextures(_, _))
6460 .WillOnce(SetArgumentPointee<1>(kFBOServiceTextureId)) 6303 .WillOnce(SetArgumentPointee<1>(kFBOServiceTextureId))
6461 .RetiresOnSaturation(); 6304 .RetiresOnSaturation();
6462 GenHelper<GenTexturesImmediate>(kFBOClientTextureId); 6305 GenHelper<GenTexturesImmediate>(kFBOClientTextureId);
6463 6306
(...skipping 11 matching lines...) Expand all
6475 SetupTexture(); 6318 SetupTexture();
6476 6319
6477 SetupExpectationsForFramebufferClearing( 6320 SetupExpectationsForFramebufferClearing(
6478 GL_FRAMEBUFFER, // target 6321 GL_FRAMEBUFFER, // target
6479 GL_COLOR_BUFFER_BIT, // clear bits 6322 GL_COLOR_BUFFER_BIT, // clear bits
6480 0, 0, 0, 0, // color 6323 0, 0, 0, 0, // color
6481 0, // stencil 6324 0, // stencil
6482 1.0f, // depth 6325 1.0f, // depth
6483 false); // scissor test 6326 false); // scissor test
6484 6327
6485 SetupExpectationsForApplyingDirtyState(false, // Framebuffer is RGB 6328 SetupExpectationsForApplyingDirtyState(
6486 false, // Framebuffer has depth 6329 false, // Framebuffer is RGB
6487 false, // Framebuffer has stencil 6330 false, // Framebuffer has depth
6488 0x1111, // color bits 6331 false, // Framebuffer has stencil
6489 false, // depth mask 6332 0x1111, // color bits
6490 false, // depth enabled 6333 false, // depth mask
6491 0, // front stencil mask 6334 false, // depth enabled
6492 0, // back stencil mask 6335 0, // front stencil mask
6493 false); // stencil enabled 6336 0, // back stencil mask
6337 false, // stencil enabled
6338 false, // cull_face_enabled
6339 false, // scissor_test_enabled
6340 false); // blend_enabled
6494 6341
6495 EXPECT_CALL(*gl_, DrawArrays(GL_TRIANGLES, 0, kNumVertices)) 6342 EXPECT_CALL(*gl_, DrawArrays(GL_TRIANGLES, 0, kNumVertices))
6496 .Times(1) 6343 .Times(1)
6497 .RetiresOnSaturation(); 6344 .RetiresOnSaturation();
6498 DrawArrays cmd; 6345 DrawArrays cmd;
6499 cmd.Init(GL_TRIANGLES, 0, kNumVertices); 6346 cmd.Init(GL_TRIANGLES, 0, kNumVertices);
6500 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 6347 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
6501 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 6348 EXPECT_EQ(GL_NO_ERROR, GetGLError());
6502 6349
6503 // But not again. 6350 // But not again.
6504 EXPECT_CALL(*gl_, DrawArrays(GL_TRIANGLES, 0, kNumVertices)) 6351 EXPECT_CALL(*gl_, DrawArrays(GL_TRIANGLES, 0, kNumVertices))
6505 .Times(1) 6352 .Times(1)
6506 .RetiresOnSaturation(); 6353 .RetiresOnSaturation();
6507 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 6354 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
6508 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 6355 EXPECT_EQ(GL_NO_ERROR, GetGLError());
6509 } 6356 }
6510 6357
6511 TEST_P(GLES2DecoderWithShaderTest, DrawWitFBOThatCantClearDoesNotDraw) { 6358 TEST_F(GLES2DecoderWithShaderTest, DrawWitFBOThatCantClearDoesNotDraw) {
6512 const GLuint kFBOClientTextureId = 4100; 6359 const GLuint kFBOClientTextureId = 4100;
6513 const GLuint kFBOServiceTextureId = 4101; 6360 const GLuint kFBOServiceTextureId = 4101;
6514 6361
6515 // Register a texture id. 6362 // Register a texture id.
6516 EXPECT_CALL(*gl_, GenTextures(_, _)) 6363 EXPECT_CALL(*gl_, GenTextures(_, _))
6517 .WillOnce(SetArgumentPointee<1>(kFBOServiceTextureId)) 6364 .WillOnce(SetArgumentPointee<1>(kFBOServiceTextureId))
6518 .RetiresOnSaturation(); 6365 .RetiresOnSaturation();
6519 GenHelper<GenTexturesImmediate>(kFBOClientTextureId); 6366 GenHelper<GenTexturesImmediate>(kFBOClientTextureId);
6520 6367
6521 // Setup "render to" texture. 6368 // Setup "render to" texture.
(...skipping 14 matching lines...) Expand all
6536 .RetiresOnSaturation(); 6383 .RetiresOnSaturation();
6537 EXPECT_CALL(*gl_, DrawArrays(_, _, _)) 6384 EXPECT_CALL(*gl_, DrawArrays(_, _, _))
6538 .Times(0) 6385 .Times(0)
6539 .RetiresOnSaturation(); 6386 .RetiresOnSaturation();
6540 DrawArrays cmd; 6387 DrawArrays cmd;
6541 cmd.Init(GL_TRIANGLES, 0, kNumVertices); 6388 cmd.Init(GL_TRIANGLES, 0, kNumVertices);
6542 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 6389 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
6543 EXPECT_EQ(GL_INVALID_FRAMEBUFFER_OPERATION, GetGLError()); 6390 EXPECT_EQ(GL_INVALID_FRAMEBUFFER_OPERATION, GetGLError());
6544 } 6391 }
6545 6392
6546 TEST_P(GLES2DecoderTest, CopyTexImage2DMarksTextureAsCleared) { 6393 TEST_F(GLES2DecoderTest, CopyTexImage2DMarksTextureAsCleared) {
6547 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); 6394 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId);
6548 6395
6549 TextureManager* manager = group().texture_manager(); 6396 TextureManager* manager = group().texture_manager();
6550 TextureRef* texture_ref = manager->GetTexture(client_texture_id_); 6397 TextureRef* texture_ref = manager->GetTexture(client_texture_id_);
6551 ASSERT_TRUE(texture_ref != NULL); 6398 ASSERT_TRUE(texture_ref != NULL);
6552 Texture* texture = texture_ref->texture(); 6399 Texture* texture = texture_ref->texture();
6553 6400
6554 EXPECT_CALL(*gl_, GetError()) 6401 EXPECT_CALL(*gl_, GetError())
6555 .WillOnce(Return(GL_NO_ERROR)) 6402 .WillOnce(Return(GL_NO_ERROR))
6556 .RetiresOnSaturation(); 6403 .RetiresOnSaturation();
6557 EXPECT_CALL(*gl_, CopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 0, 0, 1, 1, 0)) 6404 EXPECT_CALL(*gl_, CopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 0, 0, 1, 1, 0))
6558 .Times(1) 6405 .Times(1)
6559 .RetiresOnSaturation(); 6406 .RetiresOnSaturation();
6560 EXPECT_CALL(*gl_, GetError()) 6407 EXPECT_CALL(*gl_, GetError())
6561 .WillOnce(Return(GL_NO_ERROR)) 6408 .WillOnce(Return(GL_NO_ERROR))
6562 .RetiresOnSaturation(); 6409 .RetiresOnSaturation();
6563 CopyTexImage2D cmd; 6410 CopyTexImage2D cmd;
6564 cmd.Init(GL_TEXTURE_2D, 0, GL_RGBA, 0, 0, 1, 1, 0); 6411 cmd.Init(GL_TEXTURE_2D, 0, GL_RGBA, 0, 0, 1, 1, 0);
6565 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 6412 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
6566 6413
6567 EXPECT_TRUE(texture->SafeToRenderFrom()); 6414 EXPECT_TRUE(texture->SafeToRenderFrom());
6568 } 6415 }
6569 6416
6570 TEST_P(GLES2DecoderTest, CopyTexSubImage2DClearsUnclearedTexture) { 6417 TEST_F(GLES2DecoderTest, CopyTexSubImage2DClearsUnclearedTexture) {
6571 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); 6418 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId);
6572 DoTexImage2D( 6419 DoTexImage2D(
6573 GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0, 0); 6420 GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0, 0);
6574 6421
6575 SetupClearTextureExpectations( 6422 SetupClearTextureExpectations(
6576 kServiceTextureId, kServiceTextureId, GL_TEXTURE_2D, GL_TEXTURE_2D, 6423 kServiceTextureId, kServiceTextureId, GL_TEXTURE_2D, GL_TEXTURE_2D,
6577 0, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, 2, 2); 6424 0, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, 2, 2);
6578 EXPECT_CALL(*gl_, CopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, 1, 1)) 6425 EXPECT_CALL(*gl_, CopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, 1, 1))
6579 .Times(1) 6426 .Times(1)
6580 .RetiresOnSaturation(); 6427 .RetiresOnSaturation();
6581 CopyTexSubImage2D cmd; 6428 CopyTexSubImage2D cmd;
6582 cmd.Init(GL_TEXTURE_2D, 0, 0, 0, 0, 0, 1, 1); 6429 cmd.Init(GL_TEXTURE_2D, 0, 0, 0, 0, 0, 1, 1);
6583 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 6430 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
6584 } 6431 }
6585 6432
6586 TEST_P(GLES2DecoderManualInitTest, CompressedImage2DMarksTextureAsCleared) { 6433 TEST_F(GLES2DecoderManualInitTest, CompressedImage2DMarksTextureAsCleared) {
6587 InitState init; 6434 InitState init;
6588 init.extensions = "GL_EXT_texture_compression_s3tc"; 6435 init.extensions = "GL_EXT_texture_compression_s3tc";
6589 init.gl_version = "3.0"; 6436 init.gl_version = "3.0";
6590 init.bind_generates_resource = true; 6437 init.bind_generates_resource = true;
6591 InitDecoder(init); 6438 InitDecoder(init);
6592 6439
6593 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); 6440 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId);
6594 EXPECT_CALL(*gl_, GetError()) 6441 EXPECT_CALL(*gl_, GetError())
6595 .WillOnce(Return(GL_NO_ERROR)) 6442 .WillOnce(Return(GL_NO_ERROR))
6596 .RetiresOnSaturation(); 6443 .RetiresOnSaturation();
6597 EXPECT_CALL(*gl_, CompressedTexImage2D( 6444 EXPECT_CALL(*gl_, CompressedTexImage2D(
6598 GL_TEXTURE_2D, 0, GL_COMPRESSED_RGB_S3TC_DXT1_EXT, 4, 4, 0, 8, _)) 6445 GL_TEXTURE_2D, 0, GL_COMPRESSED_RGB_S3TC_DXT1_EXT, 4, 4, 0, 8, _))
6599 .Times(1) 6446 .Times(1)
6600 .RetiresOnSaturation(); 6447 .RetiresOnSaturation();
6601 EXPECT_CALL(*gl_, GetError()) 6448 EXPECT_CALL(*gl_, GetError())
6602 .WillOnce(Return(GL_NO_ERROR)) 6449 .WillOnce(Return(GL_NO_ERROR))
6603 .RetiresOnSaturation(); 6450 .RetiresOnSaturation();
6604 CompressedTexImage2D cmd; 6451 CompressedTexImage2D cmd;
6605 cmd.Init(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGB_S3TC_DXT1_EXT, 4, 4, 0, 6452 cmd.Init(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGB_S3TC_DXT1_EXT, 4, 4, 0,
6606 8, kSharedMemoryId, kSharedMemoryOffset); 6453 8, kSharedMemoryId, kSharedMemoryOffset);
6607 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 6454 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
6608 TextureManager* manager = group().texture_manager(); 6455 TextureManager* manager = group().texture_manager();
6609 TextureRef* texture_ref = manager->GetTexture(client_texture_id_); 6456 TextureRef* texture_ref = manager->GetTexture(client_texture_id_);
6610 EXPECT_TRUE(texture_ref->texture()->SafeToRenderFrom()); 6457 EXPECT_TRUE(texture_ref->texture()->SafeToRenderFrom());
6611 } 6458 }
6612 6459
6613 TEST_P(GLES2DecoderWithShaderTest, UnClearedAttachmentsGetClearedOnClear) { 6460 TEST_F(GLES2DecoderWithShaderTest, UnClearedAttachmentsGetClearedOnClear) {
6614 const GLuint kFBOClientTextureId = 4100; 6461 const GLuint kFBOClientTextureId = 4100;
6615 const GLuint kFBOServiceTextureId = 4101; 6462 const GLuint kFBOServiceTextureId = 4101;
6616 6463
6617 // Register a texture id. 6464 // Register a texture id.
6618 EXPECT_CALL(*gl_, GenTextures(_, _)) 6465 EXPECT_CALL(*gl_, GenTextures(_, _))
6619 .WillOnce(SetArgumentPointee<1>(kFBOServiceTextureId)) 6466 .WillOnce(SetArgumentPointee<1>(kFBOServiceTextureId))
6620 .RetiresOnSaturation(); 6467 .RetiresOnSaturation();
6621 GenHelper<GenTexturesImmediate>(kFBOClientTextureId); 6468 GenHelper<GenTexturesImmediate>(kFBOClientTextureId);
6622 6469
6623 // Setup "render to" texture. 6470 // Setup "render to" texture.
6624 DoBindTexture(GL_TEXTURE_2D, kFBOClientTextureId, kFBOServiceTextureId); 6471 DoBindTexture(GL_TEXTURE_2D, kFBOClientTextureId, kFBOServiceTextureId);
6625 DoTexImage2D( 6472 DoTexImage2D(
6626 GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0, 0); 6473 GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0, 0);
6627 DoBindFramebuffer( 6474 DoBindFramebuffer(
6628 GL_FRAMEBUFFER, client_framebuffer_id_, kServiceFramebufferId); 6475 GL_FRAMEBUFFER, client_framebuffer_id_, kServiceFramebufferId);
6629 DoFramebufferTexture2D( 6476 DoFramebufferTexture2D(
6630 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 6477 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
6631 kFBOClientTextureId, kFBOServiceTextureId, 0, GL_NO_ERROR); 6478 kFBOClientTextureId, kFBOServiceTextureId, 0, GL_NO_ERROR);
6632 6479
6633 // Setup "render from" texture. 6480 // Setup "render from" texture.
6634 SetupTexture(); 6481 SetupTexture();
6635 6482
6636 SetupExpectationsForFramebufferClearing( 6483 SetupExpectationsForFramebufferClearing(
6637 GL_FRAMEBUFFER, // target 6484 GL_FRAMEBUFFER, // target
6638 GL_COLOR_BUFFER_BIT, // clear bits 6485 GL_COLOR_BUFFER_BIT, // clear bits
6639 0, 0, 0, 0, // color 6486 0, 0, 0, 0, // color
6640 0, // stencil 6487 0, // stencil
6641 1.0f, // depth 6488 1.0f, // depth
6642 false); // scissor test 6489 false); // scissor test
6643 SetupExpectationsForApplyingDirtyState(false, // Framebuffer is RGB 6490 SetupExpectationsForApplyingDirtyState(
6644 false, // Framebuffer has depth 6491 false, // Framebuffer is RGB
6645 false, // Framebuffer has stencil 6492 false, // Framebuffer has depth
6646 0x1111, // color bits 6493 false, // Framebuffer has stencil
6647 false, // depth mask 6494 0x1111, // color bits
6648 false, // depth enabled 6495 false, // depth mask
6649 0, // front stencil mask 6496 false, // depth enabled
6650 0, // back stencil mask 6497 0, // front stencil mask
6651 false); // stencil enabled 6498 0, // back stencil mask
6499 false, // stencil enabled
6500 false, // cull_face_enabled
6501 false, // scissor_test_enabled
6502 false); // blend_enabled
6652 6503
6653 EXPECT_CALL(*gl_, Clear(GL_COLOR_BUFFER_BIT)) 6504 EXPECT_CALL(*gl_, Clear(GL_COLOR_BUFFER_BIT))
6654 .Times(1) 6505 .Times(1)
6655 .RetiresOnSaturation(); 6506 .RetiresOnSaturation();
6656 6507
6657 Clear cmd; 6508 Clear cmd;
6658 cmd.Init(GL_COLOR_BUFFER_BIT); 6509 cmd.Init(GL_COLOR_BUFFER_BIT);
6659 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 6510 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
6660 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 6511 EXPECT_EQ(GL_NO_ERROR, GetGLError());
6661 } 6512 }
6662 6513
6663 TEST_P(GLES2DecoderWithShaderTest, UnClearedAttachmentsGetClearedOnReadPixels) { 6514 TEST_F(GLES2DecoderWithShaderTest, UnClearedAttachmentsGetClearedOnReadPixels) {
6664 const GLuint kFBOClientTextureId = 4100; 6515 const GLuint kFBOClientTextureId = 4100;
6665 const GLuint kFBOServiceTextureId = 4101; 6516 const GLuint kFBOServiceTextureId = 4101;
6666 6517
6667 // Register a texture id. 6518 // Register a texture id.
6668 EXPECT_CALL(*gl_, GenTextures(_, _)) 6519 EXPECT_CALL(*gl_, GenTextures(_, _))
6669 .WillOnce(SetArgumentPointee<1>(kFBOServiceTextureId)) 6520 .WillOnce(SetArgumentPointee<1>(kFBOServiceTextureId))
6670 .RetiresOnSaturation(); 6521 .RetiresOnSaturation();
6671 GenHelper<GenTexturesImmediate>(kFBOClientTextureId); 6522 GenHelper<GenTexturesImmediate>(kFBOClientTextureId);
6672 6523
6673 // Setup "render to" texture. 6524 // Setup "render to" texture.
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
6706 uint32 pixels_shm_offset = kSharedMemoryOffset + sizeof(*result); 6557 uint32 pixels_shm_offset = kSharedMemoryOffset + sizeof(*result);
6707 ReadPixels cmd; 6558 ReadPixels cmd;
6708 cmd.Init(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, 6559 cmd.Init(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE,
6709 pixels_shm_id, pixels_shm_offset, 6560 pixels_shm_id, pixels_shm_offset,
6710 result_shm_id, result_shm_offset, 6561 result_shm_id, result_shm_offset,
6711 false); 6562 false);
6712 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 6563 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
6713 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 6564 EXPECT_EQ(GL_NO_ERROR, GetGLError());
6714 } 6565 }
6715 6566
6716 TEST_P(GLES2DecoderManualInitTest, 6567 TEST_F(GLES2DecoderManualInitTest,
6717 UnClearedAttachmentsGetClearedOnReadPixelsAndDrawBufferGetsRestored) { 6568 UnClearedAttachmentsGetClearedOnReadPixelsAndDrawBufferGetsRestored) {
6718 InitState init; 6569 InitState init;
6719 init.extensions = "GL_EXT_framebuffer_multisample"; 6570 init.extensions = "GL_EXT_framebuffer_multisample";
6720 init.gl_version = "2.1"; 6571 init.gl_version = "2.1";
6721 init.bind_generates_resource = true; 6572 init.bind_generates_resource = true;
6722 InitDecoder(init); 6573 InitDecoder(init);
6723 const GLuint kFBOClientTextureId = 4100; 6574 const GLuint kFBOClientTextureId = 4100;
6724 const GLuint kFBOServiceTextureId = 4101; 6575 const GLuint kFBOServiceTextureId = 4101;
6725 6576
6726 // Register a texture id. 6577 // Register a texture id.
6727 EXPECT_CALL(*gl_, GenTextures(_, _)) 6578 EXPECT_CALL(*gl_, GenTextures(_, _))
6728 .WillOnce(SetArgumentPointee<1>(kFBOServiceTextureId)) 6579 .WillOnce(SetArgumentPointee<1>(kFBOServiceTextureId))
6729 .RetiresOnSaturation(); 6580 .RetiresOnSaturation();
6730 GenHelper<GenTexturesImmediate>(kFBOClientTextureId); 6581 GenHelper<GenTexturesImmediate>(kFBOClientTextureId);
6731 6582
6732 // Setup "render from" texture. 6583 // Setup "render from" texture.
6733 DoBindTexture(GL_TEXTURE_2D, kFBOClientTextureId, kFBOServiceTextureId); 6584 DoBindTexture(GL_TEXTURE_2D, kFBOClientTextureId, kFBOServiceTextureId);
6734 DoTexImage2D( 6585 DoTexImage2D(
6735 GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0, 0); 6586 GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0, 0);
6736 DoBindFramebuffer( 6587 DoBindFramebuffer(
6737 GL_READ_FRAMEBUFFER, client_framebuffer_id_, kServiceFramebufferId); 6588 GL_READ_FRAMEBUFFER, client_framebuffer_id_, kServiceFramebufferId);
6738 DoFramebufferTexture2D( 6589 DoFramebufferTexture2D(
6739 GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 6590 GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
6740 kFBOClientTextureId, kFBOServiceTextureId, 0, GL_NO_ERROR); 6591 kFBOClientTextureId, kFBOServiceTextureId, 0, GL_NO_ERROR);
6741 6592
6742 // Enable GL_SCISSOR_TEST to make sure we disable it in the clear,
6743 // then re-enable after.
6744 DoEnableDisable(GL_SCISSOR_TEST, true);
6745
6746 SetupExpectationsForFramebufferClearingMulti( 6593 SetupExpectationsForFramebufferClearingMulti(
6747 kServiceFramebufferId, // read framebuffer service id 6594 kServiceFramebufferId, // read framebuffer service id
6748 0, // backbuffer service id 6595 0, // backbuffer service id
6749 GL_READ_FRAMEBUFFER, // target 6596 GL_READ_FRAMEBUFFER, // target
6750 GL_COLOR_BUFFER_BIT, // clear bits 6597 GL_COLOR_BUFFER_BIT, // clear bits
6751 0, 6598 0, 0, 0, 0, // color
6752 0, 6599 0, // stencil
6753 0, 6600 1.0f, // depth
6754 0, // color 6601 false); // scissor test
6755 0, // stencil
6756 1.0f, // depth
6757 true); // scissor test
6758 6602
6759 EXPECT_CALL(*gl_, GetError()) 6603 EXPECT_CALL(*gl_, GetError())
6760 .WillOnce(Return(GL_NO_ERROR)) 6604 .WillOnce(Return(GL_NO_ERROR))
6761 .WillOnce(Return(GL_NO_ERROR)) 6605 .WillOnce(Return(GL_NO_ERROR))
6762 .RetiresOnSaturation(); 6606 .RetiresOnSaturation();
6763 EXPECT_CALL(*gl_, ReadPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, _)) 6607 EXPECT_CALL(*gl_, ReadPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, _))
6764 .Times(1) 6608 .Times(1)
6765 .RetiresOnSaturation(); 6609 .RetiresOnSaturation();
6766 typedef ReadPixels::Result Result; 6610 typedef ReadPixels::Result Result;
6767 uint32 result_shm_id = kSharedMemoryId; 6611 uint32 result_shm_id = kSharedMemoryId;
6768 uint32 result_shm_offset = kSharedMemoryOffset; 6612 uint32 result_shm_offset = kSharedMemoryOffset;
6769 uint32 pixels_shm_id = kSharedMemoryId; 6613 uint32 pixels_shm_id = kSharedMemoryId;
6770 uint32 pixels_shm_offset = kSharedMemoryOffset + sizeof(Result); 6614 uint32 pixels_shm_offset = kSharedMemoryOffset + sizeof(Result);
6771 ReadPixels cmd; 6615 ReadPixels cmd;
6772 cmd.Init(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, 6616 cmd.Init(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE,
6773 pixels_shm_id, pixels_shm_offset, 6617 pixels_shm_id, pixels_shm_offset,
6774 result_shm_id, result_shm_offset, 6618 result_shm_id, result_shm_offset,
6775 false); 6619 false);
6776 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 6620 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
6777 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 6621 EXPECT_EQ(GL_NO_ERROR, GetGLError());
6778 } 6622 }
6779 6623
6780 TEST_P(GLES2DecoderWithShaderTest, DrawClearsAfterRenderbufferStorageInFBO) { 6624 TEST_F(GLES2DecoderWithShaderTest, DrawClearsAfterRenderbufferStorageInFBO) {
6781 SetupTexture(); 6625 SetupTexture();
6782 DoBindRenderbuffer(GL_RENDERBUFFER, client_renderbuffer_id_, 6626 DoBindRenderbuffer(GL_RENDERBUFFER, client_renderbuffer_id_,
6783 kServiceRenderbufferId); 6627 kServiceRenderbufferId);
6784 DoBindFramebuffer(GL_FRAMEBUFFER, client_framebuffer_id_, 6628 DoBindFramebuffer(GL_FRAMEBUFFER, client_framebuffer_id_,
6785 kServiceFramebufferId); 6629 kServiceFramebufferId);
6786 DoRenderbufferStorage( 6630 DoRenderbufferStorage(
6787 GL_RENDERBUFFER, GL_RGBA4, GL_RGBA, 100, 50, GL_NO_ERROR); 6631 GL_RENDERBUFFER, GL_RGBA4, GL_RGBA, 100, 50, GL_NO_ERROR);
6788 DoFramebufferRenderbuffer( 6632 DoFramebufferRenderbuffer(
6789 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, 6633 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER,
6790 client_renderbuffer_id_, kServiceRenderbufferId, GL_NO_ERROR); 6634 client_renderbuffer_id_, kServiceRenderbufferId, GL_NO_ERROR);
6791 6635
6792 SetupExpectationsForFramebufferClearing( 6636 SetupExpectationsForFramebufferClearing(
6793 GL_FRAMEBUFFER, // target 6637 GL_FRAMEBUFFER, // target
6794 GL_COLOR_BUFFER_BIT, // clear bits 6638 GL_COLOR_BUFFER_BIT, // clear bits
6795 0, 0, 0, 0, // color 6639 0, 0, 0, 0, // color
6796 0, // stencil 6640 0, // stencil
6797 1.0f, // depth 6641 1.0f, // depth
6798 false); // scissor test 6642 false); // scissor test
6799 6643
6800 AddExpectationsForSimulatedAttrib0(kNumVertices, 0); 6644 AddExpectationsForSimulatedAttrib0(kNumVertices, 0);
6801 SetupExpectationsForApplyingDirtyState(false, // Framebuffer is RGB 6645 SetupExpectationsForApplyingDirtyState(
6802 false, // Framebuffer has depth 6646 false, // Framebuffer is RGB
6803 false, // Framebuffer has stencil 6647 false, // Framebuffer has depth
6804 0x1111, // color bits 6648 false, // Framebuffer has stencil
6805 false, // depth mask 6649 0x1111, // color bits
6806 false, // depth enabled 6650 false, // depth mask
6807 0, // front stencil mask 6651 false, // depth enabled
6808 0, // back stencil mask 6652 0, // front stencil mask
6809 false); // stencil enabled 6653 0, // back stencil mask
6654 false, // stencil enabled
6655 false, // cull_face_enabled
6656 false, // scissor_test_enabled
6657 false); // blend_enabled
6810 6658
6811 EXPECT_CALL(*gl_, DrawArrays(GL_TRIANGLES, 0, kNumVertices)) 6659 EXPECT_CALL(*gl_, DrawArrays(GL_TRIANGLES, 0, kNumVertices))
6812 .Times(1) 6660 .Times(1)
6813 .RetiresOnSaturation(); 6661 .RetiresOnSaturation();
6814 DrawArrays cmd; 6662 DrawArrays cmd;
6815 cmd.Init(GL_TRIANGLES, 0, kNumVertices); 6663 cmd.Init(GL_TRIANGLES, 0, kNumVertices);
6816 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 6664 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
6817 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 6665 EXPECT_EQ(GL_NO_ERROR, GetGLError());
6818 } 6666 }
6819 6667
6820 TEST_P(GLES2DecoderManualInitTest, DrawArraysClearsAfterTexImage2DNULLCubemap) { 6668 TEST_F(GLES2DecoderTest, DrawArraysClearsAfterTexImage2DNULLCubemap) {
6821 InitState init;
6822 init.gl_version = "opengl es 2.0";
6823 init.has_alpha = true;
6824 init.has_depth = true;
6825 init.request_alpha = true;
6826 init.request_depth = true;
6827 InitDecoder(init);
6828
6829 static const GLenum faces[] = { 6669 static const GLenum faces[] = {
6830 GL_TEXTURE_CUBE_MAP_POSITIVE_X, 6670 GL_TEXTURE_CUBE_MAP_POSITIVE_X,
6831 GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 6671 GL_TEXTURE_CUBE_MAP_NEGATIVE_X,
6832 GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 6672 GL_TEXTURE_CUBE_MAP_POSITIVE_Y,
6833 GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 6673 GL_TEXTURE_CUBE_MAP_NEGATIVE_Y,
6834 GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 6674 GL_TEXTURE_CUBE_MAP_POSITIVE_Z,
6835 GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 6675 GL_TEXTURE_CUBE_MAP_NEGATIVE_Z,
6836 }; 6676 };
6837 SetupCubemapProgram(); 6677 SetupCubemapProgram();
6838 DoBindTexture(GL_TEXTURE_CUBE_MAP, client_texture_id_, kServiceTextureId); 6678 DoBindTexture(GL_TEXTURE_CUBE_MAP, client_texture_id_, kServiceTextureId);
(...skipping 21 matching lines...) Expand all
6860 AddExpectationsForSimulatedAttrib0(kNumVertices, 0); 6700 AddExpectationsForSimulatedAttrib0(kNumVertices, 0);
6861 SetupExpectationsForApplyingDefaultDirtyState(); 6701 SetupExpectationsForApplyingDefaultDirtyState();
6862 EXPECT_CALL(*gl_, DrawArrays(GL_TRIANGLES, 0, kNumVertices)) 6702 EXPECT_CALL(*gl_, DrawArrays(GL_TRIANGLES, 0, kNumVertices))
6863 .Times(1) 6703 .Times(1)
6864 .RetiresOnSaturation(); 6704 .RetiresOnSaturation();
6865 DrawArrays cmd; 6705 DrawArrays cmd;
6866 cmd.Init(GL_TRIANGLES, 0, kNumVertices); 6706 cmd.Init(GL_TRIANGLES, 0, kNumVertices);
6867 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 6707 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
6868 } 6708 }
6869 6709
6870 TEST_P(GLES2DecoderTest, TextureUsageAngleExtNotEnabledByDefault) { 6710 TEST_F(GLES2DecoderTest, TextureUsageAngleExtNotEnabledByDefault) {
6871 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); 6711 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId);
6872 6712
6873 TexParameteri cmd; 6713 TexParameteri cmd;
6874 cmd.Init(GL_TEXTURE_2D, 6714 cmd.Init(GL_TEXTURE_2D,
6875 GL_TEXTURE_USAGE_ANGLE, 6715 GL_TEXTURE_USAGE_ANGLE,
6876 GL_FRAMEBUFFER_ATTACHMENT_ANGLE); 6716 GL_FRAMEBUFFER_ATTACHMENT_ANGLE);
6877 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 6717 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
6878 EXPECT_EQ(GL_INVALID_ENUM, GetGLError()); 6718 EXPECT_EQ(GL_INVALID_ENUM, GetGLError());
6879 } 6719 }
6880 6720
6881 TEST_P(GLES2DecoderWithShaderTest, 6721 TEST_F(GLES2DecoderWithShaderTest,
6882 DrawClearsAfterRenderbuffersWithMultipleAttachments) { 6722 DrawClearsAfterRenderbuffersWithMultipleAttachments) {
6883 const GLuint kFBOClientTextureId = 4100; 6723 const GLuint kFBOClientTextureId = 4100;
6884 const GLuint kFBOServiceTextureId = 4101; 6724 const GLuint kFBOServiceTextureId = 4101;
6885 6725
6886 // Register a texture id. 6726 // Register a texture id.
6887 EXPECT_CALL(*gl_, GenTextures(_, _)) 6727 EXPECT_CALL(*gl_, GenTextures(_, _))
6888 .WillOnce(SetArgumentPointee<1>(kFBOServiceTextureId)) 6728 .WillOnce(SetArgumentPointee<1>(kFBOServiceTextureId))
6889 .RetiresOnSaturation(); 6729 .RetiresOnSaturation();
6890 GenHelper<GenTexturesImmediate>(kFBOClientTextureId); 6730 GenHelper<GenTexturesImmediate>(kFBOClientTextureId);
6891 6731
(...skipping 21 matching lines...) Expand all
6913 SetupTexture(); 6753 SetupTexture();
6914 SetupExpectationsForFramebufferClearing( 6754 SetupExpectationsForFramebufferClearing(
6915 GL_FRAMEBUFFER, // target 6755 GL_FRAMEBUFFER, // target
6916 GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT, // clear bits 6756 GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT, // clear bits
6917 0, 0, 0, 0, // color 6757 0, 0, 0, 0, // color
6918 0, // stencil 6758 0, // stencil
6919 1.0f, // depth 6759 1.0f, // depth
6920 false); // scissor test 6760 false); // scissor test
6921 6761
6922 AddExpectationsForSimulatedAttrib0(kNumVertices, 0); 6762 AddExpectationsForSimulatedAttrib0(kNumVertices, 0);
6923 SetupExpectationsForApplyingDirtyState(false, // Framebuffer is RGB 6763 SetupExpectationsForApplyingDirtyState(
6924 true, // Framebuffer has depth 6764 false, // Framebuffer is RGB
6925 false, // Framebuffer has stencil 6765 true, // Framebuffer has depth
6926 0x1111, // color bits 6766 false, // Framebuffer has stencil
6927 true, // depth mask 6767 0x1111, // color bits
6928 false, // depth enabled 6768 true, // depth mask
6929 0, // front stencil mask 6769 false, // depth enabled
6930 0, // back stencil mask 6770 0, // front stencil mask
6931 false); // stencil enabled 6771 0, // back stencil mask
6772 false, // stencil enabled
6773 false, // cull_face_enabled
6774 false, // scissor_test_enabled
6775 false); // blend_enabled
6932 6776
6933 EXPECT_CALL(*gl_, DrawArrays(GL_TRIANGLES, 0, kNumVertices)) 6777 EXPECT_CALL(*gl_, DrawArrays(GL_TRIANGLES, 0, kNumVertices))
6934 .Times(1) 6778 .Times(1)
6935 .RetiresOnSaturation(); 6779 .RetiresOnSaturation();
6936 DrawArrays cmd; 6780 DrawArrays cmd;
6937 cmd.Init(GL_TRIANGLES, 0, kNumVertices); 6781 cmd.Init(GL_TRIANGLES, 0, kNumVertices);
6938 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 6782 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
6939 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 6783 EXPECT_EQ(GL_NO_ERROR, GetGLError());
6940 } 6784 }
6941 6785
6942 TEST_P(GLES2DecoderWithShaderTest, CopyTexImageWithInCompleteFBOFails) { 6786 TEST_F(GLES2DecoderWithShaderTest, CopyTexImageWithInCompleteFBOFails) {
6943 GLenum target = GL_TEXTURE_2D; 6787 GLenum target = GL_TEXTURE_2D;
6944 GLint level = 0; 6788 GLint level = 0;
6945 GLenum internal_format = GL_RGBA; 6789 GLenum internal_format = GL_RGBA;
6946 GLsizei width = 2; 6790 GLsizei width = 2;
6947 GLsizei height = 4; 6791 GLsizei height = 4;
6948 GLint border = 0; 6792 GLint border = 0;
6949 SetupTexture(); 6793 SetupTexture();
6950 DoBindRenderbuffer(GL_RENDERBUFFER, client_renderbuffer_id_, 6794 DoBindRenderbuffer(GL_RENDERBUFFER, client_renderbuffer_id_,
6951 kServiceRenderbufferId); 6795 kServiceRenderbufferId);
6952 DoBindFramebuffer(GL_FRAMEBUFFER, client_framebuffer_id_, 6796 DoBindFramebuffer(GL_FRAMEBUFFER, client_framebuffer_id_,
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
7005 } else { 6849 } else {
7006 EXPECT_TRUE(framebuffer_manager->IsComplete(framebuffer)); 6850 EXPECT_TRUE(framebuffer_manager->IsComplete(framebuffer));
7007 } 6851 }
7008 // Cleanup 6852 // Cleanup
7009 DoDeleteFramebuffer( 6853 DoDeleteFramebuffer(
7010 client_framebuffer_id_, kServiceFramebufferId, 6854 client_framebuffer_id_, kServiceFramebufferId,
7011 bound_fbo, GL_FRAMEBUFFER, 0, 6855 bound_fbo, GL_FRAMEBUFFER, 0,
7012 bound_fbo, GL_FRAMEBUFFER, 0); 6856 bound_fbo, GL_FRAMEBUFFER, 0);
7013 } 6857 }
7014 6858
7015 TEST_P(GLES2DecoderWithShaderTest, 6859 TEST_F(GLES2DecoderWithShaderTest,
7016 RenderbufferChangesMarkFBOAsNotCompleteBoundFBO) { 6860 RenderbufferChangesMarkFBOAsNotCompleteBoundFBO) {
7017 CheckRenderbufferChangesMarkFBOAsNotComplete(true); 6861 CheckRenderbufferChangesMarkFBOAsNotComplete(true);
7018 } 6862 }
7019 6863
7020 TEST_P(GLES2DecoderWithShaderTest, 6864 TEST_F(GLES2DecoderWithShaderTest,
7021 RenderbufferChangesMarkFBOAsNotCompleteUnboundFBO) { 6865 RenderbufferChangesMarkFBOAsNotCompleteUnboundFBO) {
7022 CheckRenderbufferChangesMarkFBOAsNotComplete(false); 6866 CheckRenderbufferChangesMarkFBOAsNotComplete(false);
7023 } 6867 }
7024 6868
7025 void GLES2DecoderWithShaderTest::CheckTextureChangesMarkFBOAsNotComplete( 6869 void GLES2DecoderWithShaderTest::CheckTextureChangesMarkFBOAsNotComplete(
7026 bool bound_fbo) { 6870 bool bound_fbo) {
7027 FramebufferManager* framebuffer_manager = group().framebuffer_manager(); 6871 FramebufferManager* framebuffer_manager = group().framebuffer_manager();
7028 const GLuint kFBOClientTextureId = 4100; 6872 const GLuint kFBOClientTextureId = 4100;
7029 const GLuint kFBOServiceTextureId = 4101; 6873 const GLuint kFBOServiceTextureId = 4101;
7030 6874
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
7099 } else { 6943 } else {
7100 EXPECT_TRUE(framebuffer_manager->IsComplete(framebuffer)); 6944 EXPECT_TRUE(framebuffer_manager->IsComplete(framebuffer));
7101 } 6945 }
7102 // Cleanup 6946 // Cleanup
7103 DoDeleteFramebuffer( 6947 DoDeleteFramebuffer(
7104 client_framebuffer_id_, kServiceFramebufferId, 6948 client_framebuffer_id_, kServiceFramebufferId,
7105 bound_fbo, GL_FRAMEBUFFER, 0, 6949 bound_fbo, GL_FRAMEBUFFER, 0,
7106 bound_fbo, GL_FRAMEBUFFER, 0); 6950 bound_fbo, GL_FRAMEBUFFER, 0);
7107 } 6951 }
7108 6952
7109 TEST_P(GLES2DecoderWithShaderTest, TextureChangesMarkFBOAsNotCompleteBoundFBO) { 6953 TEST_F(GLES2DecoderWithShaderTest, TextureChangesMarkFBOAsNotCompleteBoundFBO) {
7110 CheckTextureChangesMarkFBOAsNotComplete(true); 6954 CheckTextureChangesMarkFBOAsNotComplete(true);
7111 } 6955 }
7112 6956
7113 TEST_P(GLES2DecoderWithShaderTest, 6957 TEST_F(GLES2DecoderWithShaderTest,
7114 TextureChangesMarkFBOAsNotCompleteUnboundFBO) { 6958 TextureChangesMarkFBOAsNotCompleteUnboundFBO) {
7115 CheckTextureChangesMarkFBOAsNotComplete(false); 6959 CheckTextureChangesMarkFBOAsNotComplete(false);
7116 } 6960 }
7117 6961
7118 TEST_P(GLES2DecoderWithShaderTest, 6962 TEST_F(GLES2DecoderWithShaderTest,
7119 DrawingWithFBOTwiceChecksForFBOCompleteOnce) { 6963 DrawingWithFBOTwiceChecksForFBOCompleteOnce) {
7120 const GLuint kFBOClientTextureId = 4100; 6964 const GLuint kFBOClientTextureId = 4100;
7121 const GLuint kFBOServiceTextureId = 4101; 6965 const GLuint kFBOServiceTextureId = 4101;
7122 6966
7123 SetupAllNeededVertexBuffers(); 6967 SetupAllNeededVertexBuffers();
7124 6968
7125 // Register a texture id. 6969 // Register a texture id.
7126 EXPECT_CALL(*gl_, GenTextures(_, _)) 6970 EXPECT_CALL(*gl_, GenTextures(_, _))
7127 .WillOnce(SetArgumentPointee<1>(kFBOServiceTextureId)) 6971 .WillOnce(SetArgumentPointee<1>(kFBOServiceTextureId))
7128 .RetiresOnSaturation(); 6972 .RetiresOnSaturation();
(...skipping 11 matching lines...) Expand all
7140 kFBOClientTextureId, kFBOServiceTextureId, 0, GL_NO_ERROR); 6984 kFBOClientTextureId, kFBOServiceTextureId, 0, GL_NO_ERROR);
7141 6985
7142 // Setup "render from" texture. 6986 // Setup "render from" texture.
7143 SetupTexture(); 6987 SetupTexture();
7144 6988
7145 // Make sure we check for framebuffer complete. 6989 // Make sure we check for framebuffer complete.
7146 EXPECT_CALL(*gl_, CheckFramebufferStatusEXT(GL_FRAMEBUFFER)) 6990 EXPECT_CALL(*gl_, CheckFramebufferStatusEXT(GL_FRAMEBUFFER))
7147 .WillOnce(Return(GL_FRAMEBUFFER_COMPLETE)) 6991 .WillOnce(Return(GL_FRAMEBUFFER_COMPLETE))
7148 .RetiresOnSaturation(); 6992 .RetiresOnSaturation();
7149 6993
7150 SetupExpectationsForApplyingDirtyState(false, // Framebuffer is RGB 6994 SetupExpectationsForApplyingDirtyState(
7151 false, // Framebuffer has depth 6995 false, // Framebuffer is RGB
7152 false, // Framebuffer has stencil 6996 false, // Framebuffer has depth
7153 0x1111, // color bits 6997 false, // Framebuffer has stencil
7154 false, // depth mask 6998 0x1111, // color bits
7155 false, // depth enabled 6999 false, // depth mask
7156 0, // front stencil mask 7000 false, // depth enabled
7157 0, // back stencil mask 7001 0, // front stencil mask
7158 false); // stencil enabled 7002 0, // back stencil mask
7003 false, // stencil enabled
7004 false, // cull_face_enabled
7005 false, // scissor_test_enabled
7006 false); // blend_enabled
7159 7007
7160 EXPECT_CALL(*gl_, DrawArrays(GL_TRIANGLES, 0, kNumVertices)) 7008 EXPECT_CALL(*gl_, DrawArrays(GL_TRIANGLES, 0, kNumVertices))
7161 .Times(1) 7009 .Times(1)
7162 .RetiresOnSaturation(); 7010 .RetiresOnSaturation();
7163 DrawArrays cmd; 7011 DrawArrays cmd;
7164 cmd.Init(GL_TRIANGLES, 0, kNumVertices); 7012 cmd.Init(GL_TRIANGLES, 0, kNumVertices);
7165 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 7013 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
7166 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 7014 EXPECT_EQ(GL_NO_ERROR, GetGLError());
7167 7015
7168 // But not again. 7016 // But not again.
7169 EXPECT_CALL(*gl_, DrawArrays(GL_TRIANGLES, 0, kNumVertices)) 7017 EXPECT_CALL(*gl_, DrawArrays(GL_TRIANGLES, 0, kNumVertices))
7170 .Times(1) 7018 .Times(1)
7171 .RetiresOnSaturation(); 7019 .RetiresOnSaturation();
7172 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 7020 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
7173 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 7021 EXPECT_EQ(GL_NO_ERROR, GetGLError());
7174 } 7022 }
7175 7023
7176 TEST_P(GLES2DecoderTest, BeginQueryEXTDisabled) { 7024 TEST_F(GLES2DecoderTest, BeginQueryEXTDisabled) {
7177 // Test something fails if off. 7025 // Test something fails if off.
7178 } 7026 }
7179 7027
7180 TEST_P(GLES2DecoderManualInitTest, BeginEndQueryEXT) { 7028 TEST_F(GLES2DecoderManualInitTest, BeginEndQueryEXT) {
7181 InitState init; 7029 InitState init;
7182 init.extensions = "GL_EXT_occlusion_query_boolean"; 7030 init.extensions = "GL_EXT_occlusion_query_boolean";
7183 init.gl_version = "opengl es 2.0"; 7031 init.gl_version = "opengl es 2.0";
7184 init.has_alpha = true; 7032 init.has_alpha = true;
7185 init.request_alpha = true; 7033 init.request_alpha = true;
7186 init.bind_generates_resource = true; 7034 init.bind_generates_resource = true;
7187 InitDecoder(init); 7035 InitDecoder(init);
7188 7036
7189 // Test end fails if no begin. 7037 // Test end fails if no begin.
7190 EndQueryEXT end_cmd; 7038 EndQueryEXT end_cmd;
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
7357 if (query_type.is_gl) { 7205 if (query_type.is_gl) {
7358 EXPECT_CALL(*gl, DeleteQueriesARB(1, _)) 7206 EXPECT_CALL(*gl, DeleteQueriesARB(1, _))
7359 .Times(1) 7207 .Times(1)
7360 .RetiresOnSaturation(); 7208 .RetiresOnSaturation();
7361 } 7209 }
7362 if (query_type.type == GL_COMMANDS_COMPLETED_CHROMIUM) 7210 if (query_type.type == GL_COMMANDS_COMPLETED_CHROMIUM)
7363 EXPECT_CALL(*gl, DeleteSync(kGlSync)).Times(1).RetiresOnSaturation(); 7211 EXPECT_CALL(*gl, DeleteSync(kGlSync)).Times(1).RetiresOnSaturation();
7364 test->ResetDecoder(); 7212 test->ResetDecoder();
7365 } 7213 }
7366 7214
7367 TEST_P(GLES2DecoderManualInitTest, BeginEndQueryEXTBadMemoryIdFails) { 7215 TEST_F(GLES2DecoderManualInitTest, BeginEndQueryEXTBadMemoryIdFails) {
7368 for (size_t i = 0; i < arraysize(kQueryTypes); ++i) { 7216 for (size_t i = 0; i < arraysize(kQueryTypes); ++i) {
7369 CheckBeginEndQueryBadMemoryFails( 7217 CheckBeginEndQueryBadMemoryFails(
7370 this, kNewClientId, kNewServiceId, 7218 this, kNewClientId, kNewServiceId,
7371 kQueryTypes[i], 7219 kQueryTypes[i],
7372 kInvalidSharedMemoryId, kSharedMemoryOffset); 7220 kInvalidSharedMemoryId, kSharedMemoryOffset);
7373 } 7221 }
7374 } 7222 }
7375 7223
7376 TEST_P(GLES2DecoderManualInitTest, BeginEndQueryEXTBadMemoryOffsetFails) { 7224 TEST_F(GLES2DecoderManualInitTest, BeginEndQueryEXTBadMemoryOffsetFails) {
7377 for (size_t i = 0; i < arraysize(kQueryTypes); ++i) { 7225 for (size_t i = 0; i < arraysize(kQueryTypes); ++i) {
7378 // Out-of-bounds. 7226 // Out-of-bounds.
7379 CheckBeginEndQueryBadMemoryFails( 7227 CheckBeginEndQueryBadMemoryFails(
7380 this, kNewClientId, kNewServiceId, 7228 this, kNewClientId, kNewServiceId,
7381 kQueryTypes[i], 7229 kQueryTypes[i],
7382 kSharedMemoryId, kInvalidSharedMemoryOffset); 7230 kSharedMemoryId, kInvalidSharedMemoryOffset);
7383 // Overflow. 7231 // Overflow.
7384 CheckBeginEndQueryBadMemoryFails( 7232 CheckBeginEndQueryBadMemoryFails(
7385 this, kNewClientId, kNewServiceId, 7233 this, kNewClientId, kNewServiceId,
7386 kQueryTypes[i], 7234 kQueryTypes[i],
7387 kSharedMemoryId, 0xfffffffcu); 7235 kSharedMemoryId, 0xfffffffcu);
7388 } 7236 }
7389 } 7237 }
7390 7238
7391 TEST_P(GLES2DecoderTest, BeginEndQueryEXTCommandsIssuedCHROMIUM) { 7239 TEST_F(GLES2DecoderTest, BeginEndQueryEXTCommandsIssuedCHROMIUM) {
7392 BeginQueryEXT begin_cmd; 7240 BeginQueryEXT begin_cmd;
7393 7241
7394 GenHelper<GenQueriesEXTImmediate>(kNewClientId); 7242 GenHelper<GenQueriesEXTImmediate>(kNewClientId);
7395 7243
7396 // Test valid parameters work. 7244 // Test valid parameters work.
7397 begin_cmd.Init( 7245 begin_cmd.Init(
7398 GL_COMMANDS_ISSUED_CHROMIUM, kNewClientId, 7246 GL_COMMANDS_ISSUED_CHROMIUM, kNewClientId,
7399 kSharedMemoryId, kSharedMemoryOffset); 7247 kSharedMemoryId, kSharedMemoryOffset);
7400 EXPECT_EQ(error::kNoError, ExecuteCmd(begin_cmd)); 7248 EXPECT_EQ(error::kNoError, ExecuteCmd(begin_cmd));
7401 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 7249 EXPECT_EQ(GL_NO_ERROR, GetGLError());
7402 7250
7403 QueryManager* query_manager = decoder_->GetQueryManager(); 7251 QueryManager* query_manager = decoder_->GetQueryManager();
7404 ASSERT_TRUE(query_manager != NULL); 7252 ASSERT_TRUE(query_manager != NULL);
7405 QueryManager::Query* query = query_manager->GetQuery(kNewClientId); 7253 QueryManager::Query* query = query_manager->GetQuery(kNewClientId);
7406 ASSERT_TRUE(query != NULL); 7254 ASSERT_TRUE(query != NULL);
7407 EXPECT_FALSE(query->pending()); 7255 EXPECT_FALSE(query->pending());
7408 7256
7409 // Test end succeeds 7257 // Test end succeeds
7410 EndQueryEXT end_cmd; 7258 EndQueryEXT end_cmd;
7411 end_cmd.Init(GL_COMMANDS_ISSUED_CHROMIUM, 1); 7259 end_cmd.Init(GL_COMMANDS_ISSUED_CHROMIUM, 1);
7412 EXPECT_EQ(error::kNoError, ExecuteCmd(end_cmd)); 7260 EXPECT_EQ(error::kNoError, ExecuteCmd(end_cmd));
7413 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 7261 EXPECT_EQ(GL_NO_ERROR, GetGLError());
7414 EXPECT_FALSE(query->pending()); 7262 EXPECT_FALSE(query->pending());
7415 } 7263 }
7416 7264
7417 TEST_P(GLES2DecoderTest, BeginEndQueryEXTGetErrorQueryCHROMIUM) { 7265 TEST_F(GLES2DecoderTest, BeginEndQueryEXTGetErrorQueryCHROMIUM) {
7418 BeginQueryEXT begin_cmd; 7266 BeginQueryEXT begin_cmd;
7419 7267
7420 GenHelper<GenQueriesEXTImmediate>(kNewClientId); 7268 GenHelper<GenQueriesEXTImmediate>(kNewClientId);
7421 7269
7422 // Test valid parameters work. 7270 // Test valid parameters work.
7423 begin_cmd.Init( 7271 begin_cmd.Init(
7424 GL_GET_ERROR_QUERY_CHROMIUM, kNewClientId, 7272 GL_GET_ERROR_QUERY_CHROMIUM, kNewClientId,
7425 kSharedMemoryId, kSharedMemoryOffset); 7273 kSharedMemoryId, kSharedMemoryOffset);
7426 EXPECT_EQ(error::kNoError, ExecuteCmd(begin_cmd)); 7274 EXPECT_EQ(error::kNoError, ExecuteCmd(begin_cmd));
7427 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 7275 EXPECT_EQ(GL_NO_ERROR, GetGLError());
(...skipping 13 matching lines...) Expand all
7441 7289
7442 EndQueryEXT end_cmd; 7290 EndQueryEXT end_cmd;
7443 end_cmd.Init(GL_GET_ERROR_QUERY_CHROMIUM, 1); 7291 end_cmd.Init(GL_GET_ERROR_QUERY_CHROMIUM, 1);
7444 EXPECT_EQ(error::kNoError, ExecuteCmd(end_cmd)); 7292 EXPECT_EQ(error::kNoError, ExecuteCmd(end_cmd));
7445 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 7293 EXPECT_EQ(GL_NO_ERROR, GetGLError());
7446 EXPECT_FALSE(query->pending()); 7294 EXPECT_FALSE(query->pending());
7447 EXPECT_EQ(static_cast<GLenum>(GL_INVALID_VALUE), 7295 EXPECT_EQ(static_cast<GLenum>(GL_INVALID_VALUE),
7448 static_cast<GLenum>(sync->result)); 7296 static_cast<GLenum>(sync->result));
7449 } 7297 }
7450 7298
7451 TEST_P(GLES2DecoderManualInitTest, BeginEndQueryEXTCommandsCompletedCHROMIUM) { 7299 TEST_F(GLES2DecoderManualInitTest, BeginEndQueryEXTCommandsCompletedCHROMIUM) {
7452 InitState init; 7300 InitState init;
7453 init.extensions = "GL_EXT_occlusion_query_boolean GL_ARB_sync"; 7301 init.extensions = "GL_EXT_occlusion_query_boolean GL_ARB_sync";
7454 init.gl_version = "opengl es 2.0"; 7302 init.gl_version = "opengl es 2.0";
7455 init.has_alpha = true; 7303 init.has_alpha = true;
7456 init.request_alpha = true; 7304 init.request_alpha = true;
7457 init.bind_generates_resource = true; 7305 init.bind_generates_resource = true;
7458 InitDecoder(init); 7306 InitDecoder(init);
7459 7307
7460 GenHelper<GenQueriesEXTImmediate>(kNewClientId); 7308 GenHelper<GenQueriesEXTImmediate>(kNewClientId);
7461 7309
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
7500 7348
7501 EXPECT_TRUE(process_success); 7349 EXPECT_TRUE(process_success);
7502 EXPECT_FALSE(query->pending()); 7350 EXPECT_FALSE(query->pending());
7503 QuerySync* sync = static_cast<QuerySync*>(shared_memory_address_); 7351 QuerySync* sync = static_cast<QuerySync*>(shared_memory_address_);
7504 EXPECT_EQ(static_cast<GLenum>(0), static_cast<GLenum>(sync->result)); 7352 EXPECT_EQ(static_cast<GLenum>(0), static_cast<GLenum>(sync->result));
7505 7353
7506 EXPECT_CALL(*gl_, DeleteSync(kGlSync)).Times(1).RetiresOnSaturation(); 7354 EXPECT_CALL(*gl_, DeleteSync(kGlSync)).Times(1).RetiresOnSaturation();
7507 ResetDecoder(); 7355 ResetDecoder();
7508 } 7356 }
7509 7357
7510 TEST_P(GLES2DecoderTest, ProduceAndConsumeTextureCHROMIUM) { 7358 TEST_F(GLES2DecoderTest, ProduceAndConsumeTextureCHROMIUM) {
7511 Mailbox mailbox = Mailbox::Generate(); 7359 Mailbox mailbox = Mailbox::Generate();
7512 7360
7513 memcpy(shared_memory_address_, mailbox.name, sizeof(mailbox.name)); 7361 memcpy(shared_memory_address_, mailbox.name, sizeof(mailbox.name));
7514 7362
7515 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); 7363 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId);
7516 DoTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 3, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 7364 DoTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 3, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE,
7517 0, 0); 7365 0, 0);
7518 DoTexImage2D(GL_TEXTURE_2D, 1, GL_RGBA, 2, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 7366 DoTexImage2D(GL_TEXTURE_2D, 1, GL_RGBA, 2, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE,
7519 0, 0); 7367 0, 0);
7520 TextureRef* texture_ref = group().texture_manager()->GetTexture( 7368 TextureRef* texture_ref = group().texture_manager()->GetTexture(
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
7583 EXPECT_EQ(2, width); 7431 EXPECT_EQ(2, width);
7584 EXPECT_EQ(4, height); 7432 EXPECT_EQ(4, height);
7585 EXPECT_TRUE(texture->GetLevelType(GL_TEXTURE_2D, 1, &type, &internal_format)); 7433 EXPECT_TRUE(texture->GetLevelType(GL_TEXTURE_2D, 1, &type, &internal_format));
7586 EXPECT_EQ(static_cast<GLenum>(GL_RGBA), internal_format); 7434 EXPECT_EQ(static_cast<GLenum>(GL_RGBA), internal_format);
7587 EXPECT_EQ(static_cast<GLenum>(GL_UNSIGNED_BYTE), type); 7435 EXPECT_EQ(static_cast<GLenum>(GL_UNSIGNED_BYTE), type);
7588 7436
7589 // Service ID is restored. 7437 // Service ID is restored.
7590 EXPECT_EQ(kServiceTextureId, texture->service_id()); 7438 EXPECT_EQ(kServiceTextureId, texture->service_id());
7591 } 7439 }
7592 7440
7593 TEST_P(GLES2DecoderTest, CanChangeSurface) { 7441
7442 TEST_F(GLES2DecoderTest, CanChangeSurface) {
7594 scoped_refptr<GLSurfaceMock> other_surface(new GLSurfaceMock); 7443 scoped_refptr<GLSurfaceMock> other_surface(new GLSurfaceMock);
7595 EXPECT_CALL(*other_surface.get(), GetBackingFrameBufferObject()). 7444 EXPECT_CALL(*other_surface.get(), GetBackingFrameBufferObject()).
7596 WillOnce(Return(7)); 7445 WillOnce(Return(7));
7597 EXPECT_CALL(*gl_, BindFramebufferEXT(GL_FRAMEBUFFER_EXT, 7)); 7446 EXPECT_CALL(*gl_, BindFramebufferEXT(GL_FRAMEBUFFER_EXT, 7));
7598 7447
7599 decoder_->SetSurface(other_surface); 7448 decoder_->SetSurface(other_surface);
7600 } 7449 }
7601 7450
7602 TEST_P(GLES2DecoderTest, IsEnabledReturnsCachedValue) { 7451 TEST_F(GLES2DecoderTest, IsEnabledReturnsCachedValue) {
7603 // NOTE: There are no expectations because no GL functions should be 7452 // NOTE: There are no expectations because no GL functions should be
7604 // called for DEPTH_TEST or STENCIL_TEST 7453 // called for DEPTH_TEST or STENCIL_TEST
7605 static const GLenum kStates[] = { 7454 static const GLenum kStates[] = {
7606 GL_DEPTH_TEST, 7455 GL_DEPTH_TEST,
7607 GL_STENCIL_TEST, 7456 GL_STENCIL_TEST,
7608 }; 7457 };
7609 for (size_t ii = 0; ii < arraysize(kStates); ++ii) { 7458 for (size_t ii = 0; ii < arraysize(kStates); ++ii) {
7610 Enable enable_cmd; 7459 Enable enable_cmd;
7611 GLenum state = kStates[ii]; 7460 GLenum state = kStates[ii];
7612 enable_cmd.Init(state); 7461 enable_cmd.Init(state);
7613 EXPECT_EQ(error::kNoError, ExecuteCmd(enable_cmd)); 7462 EXPECT_EQ(error::kNoError, ExecuteCmd(enable_cmd));
7614 IsEnabled::Result* result = 7463 IsEnabled::Result* result =
7615 static_cast<IsEnabled::Result*>(shared_memory_address_); 7464 static_cast<IsEnabled::Result*>(shared_memory_address_);
7616 IsEnabled is_enabled_cmd; 7465 IsEnabled is_enabled_cmd;
7617 is_enabled_cmd.Init(state, shared_memory_id_, shared_memory_offset_); 7466 is_enabled_cmd.Init(state, shared_memory_id_, shared_memory_offset_);
7618 EXPECT_EQ(error::kNoError, ExecuteCmd(is_enabled_cmd)); 7467 EXPECT_EQ(error::kNoError, ExecuteCmd(is_enabled_cmd));
7619 EXPECT_NE(0u, *result); 7468 EXPECT_NE(0u, *result);
7620 Disable disable_cmd; 7469 Disable disable_cmd;
7621 disable_cmd.Init(state); 7470 disable_cmd.Init(state);
7622 EXPECT_EQ(error::kNoError, ExecuteCmd(disable_cmd)); 7471 EXPECT_EQ(error::kNoError, ExecuteCmd(disable_cmd));
7623 EXPECT_EQ(error::kNoError, ExecuteCmd(is_enabled_cmd)); 7472 EXPECT_EQ(error::kNoError, ExecuteCmd(is_enabled_cmd));
7624 EXPECT_EQ(0u, *result); 7473 EXPECT_EQ(0u, *result);
7625 } 7474 }
7626 } 7475 }
7627 7476
7628 TEST_P(GLES2DecoderManualInitTest, DepthTextureBadArgs) { 7477 TEST_F(GLES2DecoderManualInitTest, DepthTextureBadArgs) {
7629 InitState init; 7478 InitState init;
7630 init.extensions = "GL_ANGLE_depth_texture"; 7479 init.extensions = "GL_ANGLE_depth_texture";
7631 init.gl_version = "opengl es 2.0"; 7480 init.gl_version = "opengl es 2.0";
7632 init.has_depth = true; 7481 init.has_depth = true;
7633 init.has_stencil = true; 7482 init.has_stencil = true;
7634 init.request_depth = true; 7483 init.request_depth = true;
7635 init.request_stencil = true; 7484 init.request_stencil = true;
7636 init.bind_generates_resource = true; 7485 init.bind_generates_resource = true;
7637 InitDecoder(init); 7486 InitDecoder(init);
7638 7487
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
7670 EXPECT_EQ(error::kNoError, ExecuteCmd(copy_tex_cmd)); 7519 EXPECT_EQ(error::kNoError, ExecuteCmd(copy_tex_cmd));
7671 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); 7520 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
7672 7521
7673 // Check that trying to CopyTexSubImage2D fails 7522 // Check that trying to CopyTexSubImage2D fails
7674 CopyTexSubImage2D copy_sub_cmd; 7523 CopyTexSubImage2D copy_sub_cmd;
7675 copy_sub_cmd.Init(GL_TEXTURE_2D, 0, 0, 0, 0, 0, 1, 1); 7524 copy_sub_cmd.Init(GL_TEXTURE_2D, 0, 0, 0, 0, 0, 1, 1);
7676 EXPECT_EQ(error::kNoError, ExecuteCmd(copy_sub_cmd)); 7525 EXPECT_EQ(error::kNoError, ExecuteCmd(copy_sub_cmd));
7677 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); 7526 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
7678 } 7527 }
7679 7528
7680 TEST_P(GLES2DecoderManualInitTest, GenerateMipmapDepthTexture) { 7529 TEST_F(GLES2DecoderManualInitTest, GenerateMipmapDepthTexture) {
7681 InitState init; 7530 InitState init;
7682 init.extensions = "GL_ANGLE_depth_texture"; 7531 init.extensions = "GL_ANGLE_depth_texture";
7683 init.gl_version = "opengl es 2.0"; 7532 init.gl_version = "opengl es 2.0";
7684 init.has_depth = true; 7533 init.has_depth = true;
7685 init.has_stencil = true; 7534 init.has_stencil = true;
7686 init.request_depth = true; 7535 init.request_depth = true;
7687 init.request_stencil = true; 7536 init.request_stencil = true;
7688 init.bind_generates_resource = true; 7537 init.bind_generates_resource = true;
7689 InitDecoder(init); 7538 InitDecoder(init);
7690 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); 7539 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId);
7691 DoTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, 7540 DoTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT,
7692 2, 2, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, 7541 2, 2, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT,
7693 0, 0); 7542 0, 0);
7694 GenerateMipmap cmd; 7543 GenerateMipmap cmd;
7695 cmd.Init(GL_TEXTURE_2D); 7544 cmd.Init(GL_TEXTURE_2D);
7696 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 7545 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
7697 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); 7546 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
7698 } 7547 }
7699 7548
7700 TEST_P(GLES2DecoderManualInitTest, DrawClearsDepthTexture) { 7549 TEST_F(GLES2DecoderManualInitTest, DrawClearsDepthTexture) {
7701 InitState init; 7550 InitState init;
7702 init.extensions = "GL_ANGLE_depth_texture"; 7551 init.extensions = "GL_ANGLE_depth_texture";
7703 init.gl_version = "opengl es 2.0"; 7552 init.gl_version = "opengl es 2.0";
7704 init.has_alpha = true; 7553 init.has_alpha = true;
7705 init.has_depth = true; 7554 init.has_depth = true;
7706 init.request_alpha = true; 7555 init.request_alpha = true;
7707 init.request_depth = true; 7556 init.request_depth = true;
7708 init.bind_generates_resource = true; 7557 init.bind_generates_resource = true;
7709 InitDecoder(init); 7558 InitDecoder(init);
7710 7559
7711 SetupDefaultProgram(); 7560 SetupDefaultProgram();
7712 SetupAllNeededVertexBuffers(); 7561 SetupAllNeededVertexBuffers();
7713 const GLenum attachment = GL_DEPTH_ATTACHMENT; 7562 const GLenum attachment = GL_DEPTH_ATTACHMENT;
7714 const GLenum target = GL_TEXTURE_2D; 7563 const GLenum target = GL_TEXTURE_2D;
7715 const GLint level = 0; 7564 const GLint level = 0;
7716 DoBindTexture(target, client_texture_id_, kServiceTextureId); 7565 DoBindTexture(target, client_texture_id_, kServiceTextureId);
7717 7566
7718 // Create a depth texture. 7567 // Create a depth texture.
7719 DoTexImage2D(target, level, GL_DEPTH_COMPONENT, 1, 1, 0, 7568 DoTexImage2D(target, level, GL_DEPTH_COMPONENT, 1, 1, 0,
7720 GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, 0, 0); 7569 GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, 0, 0);
7721 7570
7722 // Enable GL_SCISSOR_TEST to make sure we disable it in the clear,
7723 // then re-enable it.
7724 DoEnableDisable(GL_SCISSOR_TEST, true);
7725
7726 EXPECT_CALL(*gl_, GenFramebuffersEXT(1, _)) 7571 EXPECT_CALL(*gl_, GenFramebuffersEXT(1, _))
7727 .Times(1) 7572 .Times(1)
7728 .RetiresOnSaturation(); 7573 .RetiresOnSaturation();
7729 EXPECT_CALL(*gl_, BindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, _)) 7574 EXPECT_CALL(*gl_, BindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, _))
7730 .Times(1) 7575 .Times(1)
7731 .RetiresOnSaturation(); 7576 .RetiresOnSaturation();
7732 7577
7733 EXPECT_CALL(*gl_, FramebufferTexture2DEXT( 7578 EXPECT_CALL(*gl_, FramebufferTexture2DEXT(
7734 GL_DRAW_FRAMEBUFFER_EXT, attachment, target, kServiceTextureId, level)) 7579 GL_DRAW_FRAMEBUFFER_EXT, attachment, target, kServiceTextureId, level))
7735 .Times(1) 7580 .Times(1)
7736 .RetiresOnSaturation(); 7581 .RetiresOnSaturation();
7737 EXPECT_CALL(*gl_, CheckFramebufferStatusEXT(GL_DRAW_FRAMEBUFFER_EXT)) 7582 EXPECT_CALL(*gl_, CheckFramebufferStatusEXT(GL_DRAW_FRAMEBUFFER_EXT))
7738 .WillOnce(Return(GL_FRAMEBUFFER_COMPLETE)) 7583 .WillOnce(Return(GL_FRAMEBUFFER_COMPLETE))
7739 .RetiresOnSaturation(); 7584 .RetiresOnSaturation();
7740 7585
7741 EXPECT_CALL(*gl_, ClearStencil(0)) 7586 EXPECT_CALL(*gl_, ClearStencil(0))
7742 .Times(1) 7587 .Times(1)
7743 .RetiresOnSaturation(); 7588 .RetiresOnSaturation();
7744 EXPECT_CALL(*gl_, StencilMask(-1)) 7589 EXPECT_CALL(*gl_, StencilMask(-1))
7745 .Times(1) 7590 .Times(1)
7746 .RetiresOnSaturation(); 7591 .RetiresOnSaturation();
7747 EXPECT_CALL(*gl_, ClearDepth(1.0f)) 7592 EXPECT_CALL(*gl_, ClearDepth(1.0f))
7748 .Times(1) 7593 .Times(1)
7749 .RetiresOnSaturation(); 7594 .RetiresOnSaturation();
7750 SetupExpectationsForDepthMask(true); 7595 EXPECT_CALL(*gl_, DepthMask(true))
7751 SetupExpectationsForEnableDisable(GL_SCISSOR_TEST, false); 7596 .Times(1)
7597 .RetiresOnSaturation();
7598 EXPECT_CALL(*gl_, Disable(GL_SCISSOR_TEST))
7599 .Times(1)
7600 .RetiresOnSaturation();
7752 7601
7753 EXPECT_CALL(*gl_, Clear(GL_DEPTH_BUFFER_BIT)) 7602 EXPECT_CALL(*gl_, Clear(GL_DEPTH_BUFFER_BIT))
7754 .Times(1) 7603 .Times(1)
7755 .RetiresOnSaturation(); 7604 .RetiresOnSaturation();
7756 7605
7757 SetupExpectationsForRestoreClearState(0.0f, 0.0f, 0.0f, 0.0f, 0, 1.0f, true); 7606 SetupExpectationsForRestoreClearState(
7607 0.0f, 0.0f, 0.0f, 0.0f, 0, 1.0f, false);
7758 7608
7759 EXPECT_CALL(*gl_, DeleteFramebuffersEXT(1, _)) 7609 EXPECT_CALL(*gl_, DeleteFramebuffersEXT(1, _))
7760 .Times(1) 7610 .Times(1)
7761 .RetiresOnSaturation(); 7611 .RetiresOnSaturation();
7762 EXPECT_CALL(*gl_, BindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, 0)) 7612 EXPECT_CALL(*gl_, BindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, 0))
7763 .Times(1) 7613 .Times(1)
7764 .RetiresOnSaturation(); 7614 .RetiresOnSaturation();
7765 7615
7766 SetupExpectationsForApplyingDefaultDirtyState(); 7616 SetupExpectationsForApplyingDefaultDirtyState();
7767 EXPECT_CALL(*gl_, DrawArrays(GL_TRIANGLES, 0, kNumVertices)) 7617 EXPECT_CALL(*gl_, DrawArrays(GL_TRIANGLES, 0, kNumVertices))
7768 .Times(1) 7618 .Times(1)
7769 .RetiresOnSaturation(); 7619 .RetiresOnSaturation();
7770 DrawArrays cmd; 7620 DrawArrays cmd;
7771 cmd.Init(GL_TRIANGLES, 0, kNumVertices); 7621 cmd.Init(GL_TRIANGLES, 0, kNumVertices);
7772 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 7622 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
7773 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 7623 EXPECT_EQ(GL_NO_ERROR, GetGLError());
7774 } 7624 }
7775 7625
7776 TEST_P(GLES2DecoderWithShaderTest, BindUniformLocationCHROMIUM) { 7626 TEST_F(GLES2DecoderWithShaderTest, BindUniformLocationCHROMIUM) {
7777 const GLint kLocation = 2; 7627 const GLint kLocation = 2;
7778 const char* kName = "testing"; 7628 const char* kName = "testing";
7779 const uint32 kNameSize = strlen(kName); 7629 const uint32 kNameSize = strlen(kName);
7780 const char* kBadName1 = "gl_testing"; 7630 const char* kBadName1 = "gl_testing";
7781 const uint32 kBadName1Size = strlen(kBadName1); 7631 const uint32 kBadName1Size = strlen(kBadName1);
7782 const char* kBadName2 = "testing[1]"; 7632 const char* kBadName2 = "testing[1]";
7783 const uint32 kBadName2Size = strlen(kBadName2); 7633 const uint32 kBadName2Size = strlen(kBadName2);
7784 memcpy(shared_memory_address_, kName, kNameSize); 7634 memcpy(shared_memory_address_, kName, kNameSize);
7785 BindUniformLocationCHROMIUM cmd; 7635 BindUniformLocationCHROMIUM cmd;
7786 cmd.Init(client_program_id_, kLocation, kSharedMemoryId, kSharedMemoryOffset, 7636 cmd.Init(client_program_id_, kLocation, kSharedMemoryId, kSharedMemoryOffset,
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
7995 SetupDefaultProgram(); 7845 SetupDefaultProgram();
7996 7846
7997 AddExpectationsForGenVertexArraysOES(); 7847 AddExpectationsForGenVertexArraysOES();
7998 GenHelper<GenVertexArraysOESImmediate>(client_vertexarray_id_); 7848 GenHelper<GenVertexArraysOESImmediate>(client_vertexarray_id_);
7999 7849
8000 vertex_array_deleted_manually_ = false; 7850 vertex_array_deleted_manually_ = false;
8001 } 7851 }
8002 }; 7852 };
8003 7853
8004 // Test vertex array objects with native support 7854 // Test vertex array objects with native support
8005 TEST_P(GLES2DecoderVertexArraysOESTest, GenVertexArraysOESValidArgs) { 7855 TEST_F(GLES2DecoderVertexArraysOESTest, GenVertexArraysOESValidArgs) {
8006 GenVertexArraysOESValidArgs(); 7856 GenVertexArraysOESValidArgs();
8007 } 7857 }
8008 TEST_P(GLES2DecoderEmulatedVertexArraysOESTest, GenVertexArraysOESValidArgs) { 7858 TEST_F(GLES2DecoderEmulatedVertexArraysOESTest, GenVertexArraysOESValidArgs) {
8009 GenVertexArraysOESValidArgs(); 7859 GenVertexArraysOESValidArgs();
8010 } 7860 }
8011 7861
8012 TEST_P(GLES2DecoderVertexArraysOESTest, GenVertexArraysOESInvalidArgs) { 7862 TEST_F(GLES2DecoderVertexArraysOESTest, GenVertexArraysOESInvalidArgs) {
8013 GenVertexArraysOESInvalidArgs(); 7863 GenVertexArraysOESInvalidArgs();
8014 } 7864 }
8015 TEST_P(GLES2DecoderEmulatedVertexArraysOESTest, ) { 7865 TEST_F(GLES2DecoderEmulatedVertexArraysOESTest, ) {
8016 GenVertexArraysOESInvalidArgs(); 7866 GenVertexArraysOESInvalidArgs();
8017 } 7867 }
8018 7868
8019 TEST_P(GLES2DecoderVertexArraysOESTest, GenVertexArraysOESImmediateValidArgs) { 7869 TEST_F(GLES2DecoderVertexArraysOESTest, GenVertexArraysOESImmediateValidArgs) {
8020 GenVertexArraysOESImmediateValidArgs(); 7870 GenVertexArraysOESImmediateValidArgs();
8021 } 7871 }
8022 TEST_P(GLES2DecoderEmulatedVertexArraysOESTest, 7872 TEST_F(GLES2DecoderEmulatedVertexArraysOESTest,
8023 GenVertexArraysOESImmediateValidArgs) { 7873 GenVertexArraysOESImmediateValidArgs) {
8024 GenVertexArraysOESImmediateValidArgs(); 7874 GenVertexArraysOESImmediateValidArgs();
8025 } 7875 }
8026 7876
8027 TEST_P(GLES2DecoderVertexArraysOESTest, 7877 TEST_F(GLES2DecoderVertexArraysOESTest,
8028 GenVertexArraysOESImmediateInvalidArgs) { 7878 GenVertexArraysOESImmediateInvalidArgs) {
8029 GenVertexArraysOESImmediateInvalidArgs(); 7879 GenVertexArraysOESImmediateInvalidArgs();
8030 } 7880 }
8031 TEST_P(GLES2DecoderEmulatedVertexArraysOESTest, 7881 TEST_F(GLES2DecoderEmulatedVertexArraysOESTest,
8032 GenVertexArraysOESImmediateInvalidArgs) { 7882 GenVertexArraysOESImmediateInvalidArgs) {
8033 GenVertexArraysOESImmediateInvalidArgs(); 7883 GenVertexArraysOESImmediateInvalidArgs();
8034 } 7884 }
8035 7885
8036 TEST_P(GLES2DecoderVertexArraysOESTest, DeleteVertexArraysOESValidArgs) { 7886 TEST_F(GLES2DecoderVertexArraysOESTest, DeleteVertexArraysOESValidArgs) {
8037 DeleteVertexArraysOESValidArgs(); 7887 DeleteVertexArraysOESValidArgs();
8038 } 7888 }
8039 TEST_P(GLES2DecoderEmulatedVertexArraysOESTest, 7889 TEST_F(GLES2DecoderEmulatedVertexArraysOESTest,
8040 DeleteVertexArraysOESValidArgs) { 7890 DeleteVertexArraysOESValidArgs) {
8041 DeleteVertexArraysOESValidArgs(); 7891 DeleteVertexArraysOESValidArgs();
8042 } 7892 }
8043 7893
8044 TEST_P(GLES2DecoderVertexArraysOESTest, DeleteVertexArraysOESInvalidArgs) { 7894 TEST_F(GLES2DecoderVertexArraysOESTest, DeleteVertexArraysOESInvalidArgs) {
8045 DeleteVertexArraysOESInvalidArgs(); 7895 DeleteVertexArraysOESInvalidArgs();
8046 } 7896 }
8047 TEST_P(GLES2DecoderEmulatedVertexArraysOESTest, 7897 TEST_F(GLES2DecoderEmulatedVertexArraysOESTest,
8048 DeleteVertexArraysOESInvalidArgs) { 7898 DeleteVertexArraysOESInvalidArgs) {
8049 DeleteVertexArraysOESInvalidArgs(); 7899 DeleteVertexArraysOESInvalidArgs();
8050 } 7900 }
8051 7901
8052 TEST_P(GLES2DecoderVertexArraysOESTest, 7902 TEST_F(GLES2DecoderVertexArraysOESTest,
8053 DeleteVertexArraysOESImmediateValidArgs) { 7903 DeleteVertexArraysOESImmediateValidArgs) {
8054 DeleteVertexArraysOESImmediateValidArgs(); 7904 DeleteVertexArraysOESImmediateValidArgs();
8055 } 7905 }
8056 TEST_P(GLES2DecoderEmulatedVertexArraysOESTest, 7906 TEST_F(GLES2DecoderEmulatedVertexArraysOESTest,
8057 DeleteVertexArraysOESImmediateValidArgs) { 7907 DeleteVertexArraysOESImmediateValidArgs) {
8058 DeleteVertexArraysOESImmediateValidArgs(); 7908 DeleteVertexArraysOESImmediateValidArgs();
8059 } 7909 }
8060 7910
8061 TEST_P(GLES2DecoderVertexArraysOESTest, 7911 TEST_F(GLES2DecoderVertexArraysOESTest,
8062 DeleteVertexArraysOESImmediateInvalidArgs) { 7912 DeleteVertexArraysOESImmediateInvalidArgs) {
8063 DeleteVertexArraysOESImmediateInvalidArgs(); 7913 DeleteVertexArraysOESImmediateInvalidArgs();
8064 } 7914 }
8065 TEST_P(GLES2DecoderEmulatedVertexArraysOESTest, 7915 TEST_F(GLES2DecoderEmulatedVertexArraysOESTest,
8066 DeleteVertexArraysOESImmediateInvalidArgs) { 7916 DeleteVertexArraysOESImmediateInvalidArgs) {
8067 DeleteVertexArraysOESImmediateInvalidArgs(); 7917 DeleteVertexArraysOESImmediateInvalidArgs();
8068 } 7918 }
8069 7919
8070 TEST_P(GLES2DecoderVertexArraysOESTest, 7920 TEST_F(GLES2DecoderVertexArraysOESTest,
8071 DeleteBoundVertexArraysOESImmediateValidArgs) { 7921 DeleteBoundVertexArraysOESImmediateValidArgs) {
8072 DeleteBoundVertexArraysOESImmediateValidArgs(); 7922 DeleteBoundVertexArraysOESImmediateValidArgs();
8073 } 7923 }
8074 TEST_P(GLES2DecoderEmulatedVertexArraysOESTest, 7924 TEST_F(GLES2DecoderEmulatedVertexArraysOESTest,
8075 DeleteBoundVertexArraysOESImmediateValidArgs) { 7925 DeleteBoundVertexArraysOESImmediateValidArgs) {
8076 DeleteBoundVertexArraysOESImmediateValidArgs(); 7926 DeleteBoundVertexArraysOESImmediateValidArgs();
8077 } 7927 }
8078 7928
8079 TEST_P(GLES2DecoderVertexArraysOESTest, IsVertexArrayOESValidArgs) { 7929 TEST_F(GLES2DecoderVertexArraysOESTest, IsVertexArrayOESValidArgs) {
8080 IsVertexArrayOESValidArgs(); 7930 IsVertexArrayOESValidArgs();
8081 } 7931 }
8082 TEST_P(GLES2DecoderEmulatedVertexArraysOESTest, IsVertexArrayOESValidArgs) { 7932 TEST_F(GLES2DecoderEmulatedVertexArraysOESTest, IsVertexArrayOESValidArgs) {
8083 IsVertexArrayOESValidArgs(); 7933 IsVertexArrayOESValidArgs();
8084 } 7934 }
8085 7935
8086 TEST_P(GLES2DecoderVertexArraysOESTest, 7936 TEST_F(GLES2DecoderVertexArraysOESTest,
8087 IsVertexArrayOESInvalidArgsBadSharedMemoryId) { 7937 IsVertexArrayOESInvalidArgsBadSharedMemoryId) {
8088 IsVertexArrayOESInvalidArgsBadSharedMemoryId(); 7938 IsVertexArrayOESInvalidArgsBadSharedMemoryId();
8089 } 7939 }
8090 TEST_P(GLES2DecoderEmulatedVertexArraysOESTest, 7940 TEST_F(GLES2DecoderEmulatedVertexArraysOESTest,
8091 IsVertexArrayOESInvalidArgsBadSharedMemoryId) { 7941 IsVertexArrayOESInvalidArgsBadSharedMemoryId) {
8092 IsVertexArrayOESInvalidArgsBadSharedMemoryId(); 7942 IsVertexArrayOESInvalidArgsBadSharedMemoryId();
8093 } 7943 }
8094 7944
8095 TEST_P(GLES2DecoderVertexArraysOESTest, BindVertexArrayOESValidArgs) { 7945 TEST_F(GLES2DecoderVertexArraysOESTest, BindVertexArrayOESValidArgs) {
8096 BindVertexArrayOESValidArgs(); 7946 BindVertexArrayOESValidArgs();
8097 } 7947 }
8098 TEST_P(GLES2DecoderEmulatedVertexArraysOESTest, BindVertexArrayOESValidArgs) { 7948 TEST_F(GLES2DecoderEmulatedVertexArraysOESTest, BindVertexArrayOESValidArgs) {
8099 BindVertexArrayOESValidArgs(); 7949 BindVertexArrayOESValidArgs();
8100 } 7950 }
8101 7951
8102 TEST_P(GLES2DecoderVertexArraysOESTest, BindVertexArrayOESValidArgsNewId) { 7952 TEST_F(GLES2DecoderVertexArraysOESTest, BindVertexArrayOESValidArgsNewId) {
8103 BindVertexArrayOESValidArgsNewId(); 7953 BindVertexArrayOESValidArgsNewId();
8104 } 7954 }
8105 TEST_P(GLES2DecoderEmulatedVertexArraysOESTest, 7955 TEST_F(GLES2DecoderEmulatedVertexArraysOESTest,
8106 BindVertexArrayOESValidArgsNewId) { 7956 BindVertexArrayOESValidArgsNewId) {
8107 BindVertexArrayOESValidArgsNewId(); 7957 BindVertexArrayOESValidArgsNewId();
8108 } 7958 }
8109 7959
8110 TEST_P(GLES2DecoderTest, BindTexImage2DCHROMIUM) { 7960 TEST_F(GLES2DecoderTest, BindTexImage2DCHROMIUM) {
8111 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); 7961 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId);
8112 DoTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 3, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 7962 DoTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 3, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE,
8113 0, 0); 7963 0, 0);
8114 TextureRef* texture_ref = group().texture_manager()->GetTexture( 7964 TextureRef* texture_ref = group().texture_manager()->GetTexture(
8115 client_texture_id_); 7965 client_texture_id_);
8116 ASSERT_TRUE(texture_ref != NULL); 7966 ASSERT_TRUE(texture_ref != NULL);
8117 Texture* texture = texture_ref->texture(); 7967 Texture* texture = texture_ref->texture();
8118 EXPECT_EQ(kServiceTextureId, texture->service_id()); 7968 EXPECT_EQ(kServiceTextureId, texture->service_id());
8119 7969
8120 group().image_manager()->AddImage(gfx::GLImage::CreateGLImage(0).get(), 1); 7970 group().image_manager()->AddImage(gfx::GLImage::CreateGLImage(0).get(), 1);
(...skipping 26 matching lines...) Expand all
8147 EXPECT_FALSE(texture->GetLevelImage(GL_TEXTURE_2D, 0) == NULL); 7997 EXPECT_FALSE(texture->GetLevelImage(GL_TEXTURE_2D, 0) == NULL);
8148 7998
8149 // Define new texture image. 7999 // Define new texture image.
8150 DoTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 3, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 8000 DoTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 3, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE,
8151 0, 0); 8001 0, 0);
8152 EXPECT_TRUE(texture->GetLevelSize(GL_TEXTURE_2D, 0, &width, &height)); 8002 EXPECT_TRUE(texture->GetLevelSize(GL_TEXTURE_2D, 0, &width, &height));
8153 // Image should no longer be set. 8003 // Image should no longer be set.
8154 EXPECT_TRUE(texture->GetLevelImage(GL_TEXTURE_2D, 0) == NULL); 8004 EXPECT_TRUE(texture->GetLevelImage(GL_TEXTURE_2D, 0) == NULL);
8155 } 8005 }
8156 8006
8157 TEST_P(GLES2DecoderTest, BindTexImage2DCHROMIUMCubeMapNotAllowed) { 8007 TEST_F(GLES2DecoderTest, BindTexImage2DCHROMIUMCubeMapNotAllowed) {
8158 group().image_manager()->AddImage(gfx::GLImage::CreateGLImage(0).get(), 1); 8008 group().image_manager()->AddImage(gfx::GLImage::CreateGLImage(0).get(), 1);
8159 DoBindTexture(GL_TEXTURE_CUBE_MAP, client_texture_id_, kServiceTextureId); 8009 DoBindTexture(GL_TEXTURE_CUBE_MAP, client_texture_id_, kServiceTextureId);
8160 8010
8161 BindTexImage2DCHROMIUM bind_tex_image_2d_cmd; 8011 BindTexImage2DCHROMIUM bind_tex_image_2d_cmd;
8162 bind_tex_image_2d_cmd.Init(GL_TEXTURE_CUBE_MAP, 1); 8012 bind_tex_image_2d_cmd.Init(GL_TEXTURE_CUBE_MAP, 1);
8163 EXPECT_EQ(error::kNoError, ExecuteCmd(bind_tex_image_2d_cmd)); 8013 EXPECT_EQ(error::kNoError, ExecuteCmd(bind_tex_image_2d_cmd));
8164 EXPECT_EQ(GL_INVALID_ENUM, GetGLError()); 8014 EXPECT_EQ(GL_INVALID_ENUM, GetGLError());
8165 } 8015 }
8166 8016
8167 TEST_P(GLES2DecoderTest, OrphanGLImageWithTexImage2D) { 8017 TEST_F(GLES2DecoderTest, OrphanGLImageWithTexImage2D) {
8168 group().image_manager()->AddImage(gfx::GLImage::CreateGLImage(0).get(), 1); 8018 group().image_manager()->AddImage(gfx::GLImage::CreateGLImage(0).get(), 1);
8169 DoBindTexture(GL_TEXTURE_CUBE_MAP, client_texture_id_, kServiceTextureId); 8019 DoBindTexture(GL_TEXTURE_CUBE_MAP, client_texture_id_, kServiceTextureId);
8170 8020
8171 BindTexImage2DCHROMIUM bind_tex_image_2d_cmd; 8021 BindTexImage2DCHROMIUM bind_tex_image_2d_cmd;
8172 bind_tex_image_2d_cmd.Init(GL_TEXTURE_CUBE_MAP, 1); 8022 bind_tex_image_2d_cmd.Init(GL_TEXTURE_CUBE_MAP, 1);
8173 EXPECT_EQ(error::kNoError, ExecuteCmd(bind_tex_image_2d_cmd)); 8023 EXPECT_EQ(error::kNoError, ExecuteCmd(bind_tex_image_2d_cmd));
8174 EXPECT_EQ(GL_INVALID_ENUM, GetGLError()); 8024 EXPECT_EQ(GL_INVALID_ENUM, GetGLError());
8175 8025
8176 DoTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 3, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 8026 DoTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 3, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE,
8177 0, 0); 8027 0, 0);
8178 TextureRef* texture_ref = group().texture_manager()->GetTexture( 8028 TextureRef* texture_ref = group().texture_manager()->GetTexture(
8179 client_texture_id_); 8029 client_texture_id_);
8180 ASSERT_TRUE(texture_ref != NULL); 8030 ASSERT_TRUE(texture_ref != NULL);
8181 Texture* texture = texture_ref->texture(); 8031 Texture* texture = texture_ref->texture();
8182 EXPECT_TRUE(texture->GetLevelImage(GL_TEXTURE_2D, 0) == NULL); 8032 EXPECT_TRUE(texture->GetLevelImage(GL_TEXTURE_2D, 0) == NULL);
8183 } 8033 }
8184 8034
8185 TEST_P(GLES2DecoderTest, ReleaseTexImage2DCHROMIUM) { 8035 TEST_F(GLES2DecoderTest, ReleaseTexImage2DCHROMIUM) {
8186 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); 8036 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId);
8187 DoTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 3, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 8037 DoTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 3, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE,
8188 0, 0); 8038 0, 0);
8189 TextureRef* texture_ref = group().texture_manager()->GetTexture( 8039 TextureRef* texture_ref = group().texture_manager()->GetTexture(
8190 client_texture_id_); 8040 client_texture_id_);
8191 ASSERT_TRUE(texture_ref != NULL); 8041 ASSERT_TRUE(texture_ref != NULL);
8192 Texture* texture = texture_ref->texture(); 8042 Texture* texture = texture_ref->texture();
8193 EXPECT_EQ(kServiceTextureId, texture->service_id()); 8043 EXPECT_EQ(kServiceTextureId, texture->service_id());
8194 8044
8195 group().image_manager()->AddImage(gfx::GLImage::CreateGLImage(0).get(), 1); 8045 group().image_manager()->AddImage(gfx::GLImage::CreateGLImage(0).get(), 1);
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
8246 MOCK_METHOD1(ReleaseTexImage, void(unsigned)); 8096 MOCK_METHOD1(ReleaseTexImage, void(unsigned));
8247 MOCK_METHOD0(WillUseTexImage, void()); 8097 MOCK_METHOD0(WillUseTexImage, void());
8248 MOCK_METHOD0(DidUseTexImage, void()); 8098 MOCK_METHOD0(DidUseTexImage, void());
8249 MOCK_METHOD0(WillModifyTexImage, void()); 8099 MOCK_METHOD0(WillModifyTexImage, void());
8250 MOCK_METHOD0(DidModifyTexImage, void()); 8100 MOCK_METHOD0(DidModifyTexImage, void());
8251 8101
8252 protected: 8102 protected:
8253 virtual ~MockGLImage() {} 8103 virtual ~MockGLImage() {}
8254 }; 8104 };
8255 8105
8256 TEST_P(GLES2DecoderWithShaderTest, UseTexImage) { 8106 TEST_F(GLES2DecoderWithShaderTest, UseTexImage) {
8257 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); 8107 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId);
8258 DoTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 8108 DoTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE,
8259 kSharedMemoryId, kSharedMemoryOffset); 8109 kSharedMemoryId, kSharedMemoryOffset);
8260 8110
8261 TextureRef* texture_ref = group().texture_manager()->GetTexture( 8111 TextureRef* texture_ref = group().texture_manager()->GetTexture(
8262 client_texture_id_); 8112 client_texture_id_);
8263 ASSERT_TRUE(texture_ref != NULL); 8113 ASSERT_TRUE(texture_ref != NULL);
8264 Texture* texture = texture_ref->texture(); 8114 Texture* texture = texture_ref->texture();
8265 EXPECT_EQ(kServiceTextureId, texture->service_id()); 8115 EXPECT_EQ(kServiceTextureId, texture->service_id());
8266 8116
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
8370 .WillOnce(Return(GL_NO_ERROR)) 8220 .WillOnce(Return(GL_NO_ERROR))
8371 .WillOnce(Return(GL_NO_ERROR)) 8221 .WillOnce(Return(GL_NO_ERROR))
8372 .RetiresOnSaturation(); 8222 .RetiresOnSaturation();
8373 FramebufferRenderbuffer fbrb_cmd; 8223 FramebufferRenderbuffer fbrb_cmd;
8374 fbrb_cmd.Init( 8224 fbrb_cmd.Init(
8375 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, 8225 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER,
8376 client_renderbuffer_id_); 8226 client_renderbuffer_id_);
8377 EXPECT_EQ(error::kNoError, ExecuteCmd(fbrb_cmd)); 8227 EXPECT_EQ(error::kNoError, ExecuteCmd(fbrb_cmd));
8378 } 8228 }
8379 8229
8380 TEST_P(GLES2DecoderManualInitTest, DrawWithGLImageExternal) { 8230 TEST_F(GLES2DecoderManualInitTest, DrawWithGLImageExternal) {
8381 InitState init; 8231 InitState init;
8382 init.extensions = "GL_OES_EGL_image_external"; 8232 init.extensions = "GL_OES_EGL_image_external";
8383 init.gl_version = "opengl es 2.0"; 8233 init.gl_version = "opengl es 2.0";
8384 init.has_alpha = true; 8234 init.has_alpha = true;
8385 init.has_depth = true; 8235 init.has_depth = true;
8386 init.request_alpha = true; 8236 init.request_alpha = true;
8387 init.request_depth = true; 8237 init.request_depth = true;
8388 init.bind_generates_resource = true; 8238 init.bind_generates_resource = true;
8389 InitDecoder(init); 8239 InitDecoder(init);
8390 8240
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
8444 EXPECT_CALL(*gl_, ActiveTexture(GL_TEXTURE0)) 8294 EXPECT_CALL(*gl_, ActiveTexture(GL_TEXTURE0))
8445 .Times(1) 8295 .Times(1)
8446 .RetiresOnSaturation(); 8296 .RetiresOnSaturation();
8447 DrawElements cmd; 8297 DrawElements cmd;
8448 cmd.Init(GL_TRIANGLES, kValidIndexRangeCount, GL_UNSIGNED_SHORT, 8298 cmd.Init(GL_TRIANGLES, kValidIndexRangeCount, GL_UNSIGNED_SHORT,
8449 kValidIndexRangeStart * 2); 8299 kValidIndexRangeStart * 2);
8450 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 8300 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
8451 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 8301 EXPECT_EQ(GL_NO_ERROR, GetGLError());
8452 } 8302 }
8453 8303
8454 TEST_P(GLES2DecoderManualInitTest, GpuMemoryManagerCHROMIUM) { 8304 TEST_F(GLES2DecoderManualInitTest, GpuMemoryManagerCHROMIUM) {
8455 InitState init; 8305 InitState init;
8456 init.extensions = "GL_ARB_texture_rectangle"; 8306 init.extensions = "GL_ARB_texture_rectangle";
8457 init.gl_version = "3.0"; 8307 init.gl_version = "3.0";
8458 init.bind_generates_resource = true; 8308 init.bind_generates_resource = true;
8459 InitDecoder(init); 8309 InitDecoder(init);
8460 8310
8461 Texture* texture = GetTexture(client_texture_id_)->texture(); 8311 Texture* texture = GetTexture(client_texture_id_)->texture();
8462 EXPECT_TRUE(texture != NULL); 8312 EXPECT_TRUE(texture != NULL);
8463 EXPECT_TRUE(texture->pool() == GL_TEXTURE_POOL_UNMANAGED_CHROMIUM); 8313 EXPECT_TRUE(texture->pool() == GL_TEXTURE_POOL_UNMANAGED_CHROMIUM);
8464 8314
(...skipping 15 matching lines...) Expand all
8480 8330
8481 EXPECT_TRUE(texture->pool() == GL_TEXTURE_POOL_MANAGED_CHROMIUM); 8331 EXPECT_TRUE(texture->pool() == GL_TEXTURE_POOL_MANAGED_CHROMIUM);
8482 8332
8483 cmd.Init(GL_TEXTURE_2D, 8333 cmd.Init(GL_TEXTURE_2D,
8484 GL_TEXTURE_POOL_CHROMIUM, 8334 GL_TEXTURE_POOL_CHROMIUM,
8485 GL_NONE); 8335 GL_NONE);
8486 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 8336 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
8487 EXPECT_EQ(GL_INVALID_ENUM, GetGLError()); 8337 EXPECT_EQ(GL_INVALID_ENUM, GetGLError());
8488 } 8338 }
8489 8339
8490 TEST_P(GLES2DecoderManualInitTest, AsyncPixelTransfers) { 8340 TEST_F(GLES2DecoderManualInitTest, AsyncPixelTransfers) {
8491 InitState init; 8341 InitState init;
8492 init.extensions = "GL_CHROMIUM_async_pixel_transfers"; 8342 init.extensions = "GL_CHROMIUM_async_pixel_transfers";
8493 init.gl_version = "3.0"; 8343 init.gl_version = "3.0";
8494 init.bind_generates_resource = true; 8344 init.bind_generates_resource = true;
8495 InitDecoder(init); 8345 InitDecoder(init);
8496 8346
8497 // Set up the texture. 8347 // Set up the texture.
8498 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); 8348 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId);
8499 TextureRef* texture_ref = GetTexture(client_texture_id_); 8349 TextureRef* texture_ref = GetTexture(client_texture_id_);
8500 Texture* texture = texture_ref->texture(); 8350 Texture* texture = texture_ref->texture();
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
8727 EXPECT_EQ(error::kNoError, ExecuteCmd(wait_all_cmd)); 8577 EXPECT_EQ(error::kNoError, ExecuteCmd(wait_all_cmd));
8728 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 8578 EXPECT_EQ(GL_NO_ERROR, GetGLError());
8729 } 8579 }
8730 8580
8731 // Remove PixelTransferManager before the decoder destroys. 8581 // Remove PixelTransferManager before the decoder destroys.
8732 EXPECT_CALL(*delegate, Destroy()).RetiresOnSaturation(); 8582 EXPECT_CALL(*delegate, Destroy()).RetiresOnSaturation();
8733 decoder_->ResetAsyncPixelTransferManagerForTest(); 8583 decoder_->ResetAsyncPixelTransferManagerForTest();
8734 manager = NULL; 8584 manager = NULL;
8735 } 8585 }
8736 8586
8737 TEST_P(GLES2DecoderManualInitTest, AsyncPixelTransferManager) { 8587 TEST_F(GLES2DecoderManualInitTest, AsyncPixelTransferManager) {
8738 InitState init; 8588 InitState init;
8739 init.extensions = "GL_CHROMIUM_async_pixel_transfers"; 8589 init.extensions = "GL_CHROMIUM_async_pixel_transfers";
8740 init.gl_version = "3.0"; 8590 init.gl_version = "3.0";
8741 init.bind_generates_resource = true; 8591 init.bind_generates_resource = true;
8742 InitDecoder(init); 8592 InitDecoder(init);
8743 8593
8744 // Set up the texture. 8594 // Set up the texture.
8745 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); 8595 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId);
8746 TextureRef* texture_ref = GetTexture(client_texture_id_); 8596 TextureRef* texture_ref = GetTexture(client_texture_id_);
8747 8597
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
8831 size(0) { 8681 size(0) {
8832 } 8682 }
8833 size_t initial_size; 8683 size_t initial_size;
8834 size_t size; 8684 size_t size;
8835 }; 8685 };
8836 std::map<Pool, PoolInfo> pool_infos_; 8686 std::map<Pool, PoolInfo> pool_infos_;
8837 }; 8687 };
8838 8688
8839 } // anonymous namespace. 8689 } // anonymous namespace.
8840 8690
8841 TEST_P(GLES2DecoderManualInitTest, MemoryTrackerInitialSize) { 8691 TEST_F(GLES2DecoderManualInitTest, MemoryTrackerInitialSize) {
8842 scoped_refptr<SizeOnlyMemoryTracker> memory_tracker = 8692 scoped_refptr<SizeOnlyMemoryTracker> memory_tracker =
8843 new SizeOnlyMemoryTracker(); 8693 new SizeOnlyMemoryTracker();
8844 set_memory_tracker(memory_tracker.get()); 8694 set_memory_tracker(memory_tracker.get());
8845 InitState init; 8695 InitState init;
8846 init.gl_version = "3.0"; 8696 init.gl_version = "3.0";
8847 init.bind_generates_resource = true; 8697 init.bind_generates_resource = true;
8848 InitDecoder(init); 8698 InitDecoder(init);
8849 // Expect that initial size - size is 0. 8699 // Expect that initial size - size is 0.
8850 EXPECT_EQ(0u, memory_tracker->GetPoolSize(MemoryTracker::kUnmanaged)); 8700 EXPECT_EQ(0u, memory_tracker->GetPoolSize(MemoryTracker::kUnmanaged));
8851 EXPECT_EQ(0u, memory_tracker->GetPoolSize(MemoryTracker::kManaged)); 8701 EXPECT_EQ(0u, memory_tracker->GetPoolSize(MemoryTracker::kManaged));
8852 } 8702 }
8853 8703
8854 TEST_P(GLES2DecoderManualInitTest, MemoryTrackerTexImage2D) { 8704 TEST_F(GLES2DecoderManualInitTest, MemoryTrackerTexImage2D) {
8855 scoped_refptr<SizeOnlyMemoryTracker> memory_tracker = 8705 scoped_refptr<SizeOnlyMemoryTracker> memory_tracker =
8856 new SizeOnlyMemoryTracker(); 8706 new SizeOnlyMemoryTracker();
8857 set_memory_tracker(memory_tracker.get()); 8707 set_memory_tracker(memory_tracker.get());
8858 InitState init; 8708 InitState init;
8859 init.gl_version = "3.0"; 8709 init.gl_version = "3.0";
8860 init.bind_generates_resource = true; 8710 init.bind_generates_resource = true;
8861 InitDecoder(init); 8711 InitDecoder(init);
8862 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); 8712 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId);
8863 EXPECT_CALL(*memory_tracker.get(), EnsureGPUMemoryAvailable(128)) 8713 EXPECT_CALL(*memory_tracker.get(), EnsureGPUMemoryAvailable(128))
8864 .WillOnce(Return(true)).RetiresOnSaturation(); 8714 .WillOnce(Return(true)).RetiresOnSaturation();
(...skipping 10 matching lines...) Expand all
8875 EXPECT_CALL(*memory_tracker.get(), EnsureGPUMemoryAvailable(64)) 8725 EXPECT_CALL(*memory_tracker.get(), EnsureGPUMemoryAvailable(64))
8876 .WillOnce(Return(false)).RetiresOnSaturation(); 8726 .WillOnce(Return(false)).RetiresOnSaturation();
8877 TexImage2D cmd; 8727 TexImage2D cmd;
8878 cmd.Init(GL_TEXTURE_2D, 0, GL_RGBA, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, 8728 cmd.Init(GL_TEXTURE_2D, 0, GL_RGBA, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE,
8879 kSharedMemoryId, kSharedMemoryOffset); 8729 kSharedMemoryId, kSharedMemoryOffset);
8880 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 8730 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
8881 EXPECT_EQ(GL_OUT_OF_MEMORY, GetGLError()); 8731 EXPECT_EQ(GL_OUT_OF_MEMORY, GetGLError());
8882 EXPECT_EQ(64u, memory_tracker->GetPoolSize(MemoryTracker::kUnmanaged)); 8732 EXPECT_EQ(64u, memory_tracker->GetPoolSize(MemoryTracker::kUnmanaged));
8883 } 8733 }
8884 8734
8885 TEST_P(GLES2DecoderManualInitTest, MemoryTrackerTexStorage2DEXT) { 8735 TEST_F(GLES2DecoderManualInitTest, MemoryTrackerTexStorage2DEXT) {
8886 scoped_refptr<SizeOnlyMemoryTracker> memory_tracker = 8736 scoped_refptr<SizeOnlyMemoryTracker> memory_tracker =
8887 new SizeOnlyMemoryTracker(); 8737 new SizeOnlyMemoryTracker();
8888 set_memory_tracker(memory_tracker.get()); 8738 set_memory_tracker(memory_tracker.get());
8889 InitState init; 8739 InitState init;
8890 init.gl_version = "3.0"; 8740 init.gl_version = "3.0";
8891 init.bind_generates_resource = true; 8741 init.bind_generates_resource = true;
8892 InitDecoder(init); 8742 InitDecoder(init);
8893 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); 8743 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId);
8894 // Check we get out of memory and no call to glTexStorage2DEXT 8744 // Check we get out of memory and no call to glTexStorage2DEXT
8895 // if Ensure fails. 8745 // if Ensure fails.
8896 EXPECT_CALL(*memory_tracker.get(), EnsureGPUMemoryAvailable(128)) 8746 EXPECT_CALL(*memory_tracker.get(), EnsureGPUMemoryAvailable(128))
8897 .WillOnce(Return(false)).RetiresOnSaturation(); 8747 .WillOnce(Return(false)).RetiresOnSaturation();
8898 TexStorage2DEXT cmd; 8748 TexStorage2DEXT cmd;
8899 cmd.Init(GL_TEXTURE_2D, 1, GL_RGBA8, 8, 4); 8749 cmd.Init(GL_TEXTURE_2D, 1, GL_RGBA8, 8, 4);
8900 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 8750 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
8901 EXPECT_EQ(0u, memory_tracker->GetPoolSize(MemoryTracker::kUnmanaged)); 8751 EXPECT_EQ(0u, memory_tracker->GetPoolSize(MemoryTracker::kUnmanaged));
8902 EXPECT_EQ(GL_OUT_OF_MEMORY, GetGLError()); 8752 EXPECT_EQ(GL_OUT_OF_MEMORY, GetGLError());
8903 } 8753 }
8904 8754
8905 TEST_P(GLES2DecoderManualInitTest, MemoryTrackerCopyTexImage2D) { 8755 TEST_F(GLES2DecoderManualInitTest, MemoryTrackerCopyTexImage2D) {
8906 GLenum target = GL_TEXTURE_2D; 8756 GLenum target = GL_TEXTURE_2D;
8907 GLint level = 0; 8757 GLint level = 0;
8908 GLenum internal_format = GL_RGBA; 8758 GLenum internal_format = GL_RGBA;
8909 GLsizei width = 4; 8759 GLsizei width = 4;
8910 GLsizei height = 8; 8760 GLsizei height = 8;
8911 GLint border = 0; 8761 GLint border = 0;
8912 scoped_refptr<SizeOnlyMemoryTracker> memory_tracker = 8762 scoped_refptr<SizeOnlyMemoryTracker> memory_tracker =
8913 new SizeOnlyMemoryTracker(); 8763 new SizeOnlyMemoryTracker();
8914 set_memory_tracker(memory_tracker.get()); 8764 set_memory_tracker(memory_tracker.get());
8915 InitState init; 8765 InitState init;
(...skipping 19 matching lines...) Expand all
8935 EXPECT_EQ(128u, memory_tracker->GetPoolSize(MemoryTracker::kUnmanaged)); 8785 EXPECT_EQ(128u, memory_tracker->GetPoolSize(MemoryTracker::kUnmanaged));
8936 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 8786 EXPECT_EQ(GL_NO_ERROR, GetGLError());
8937 // Check we get out of memory and no call to glCopyTexImage2D if Ensure fails. 8787 // Check we get out of memory and no call to glCopyTexImage2D if Ensure fails.
8938 EXPECT_CALL(*memory_tracker.get(), EnsureGPUMemoryAvailable(128)) 8788 EXPECT_CALL(*memory_tracker.get(), EnsureGPUMemoryAvailable(128))
8939 .WillOnce(Return(false)).RetiresOnSaturation(); 8789 .WillOnce(Return(false)).RetiresOnSaturation();
8940 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 8790 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
8941 EXPECT_EQ(GL_OUT_OF_MEMORY, GetGLError()); 8791 EXPECT_EQ(GL_OUT_OF_MEMORY, GetGLError());
8942 EXPECT_EQ(128u, memory_tracker->GetPoolSize(MemoryTracker::kUnmanaged)); 8792 EXPECT_EQ(128u, memory_tracker->GetPoolSize(MemoryTracker::kUnmanaged));
8943 } 8793 }
8944 8794
8945 TEST_P(GLES2DecoderManualInitTest, MemoryTrackerRenderbufferStorage) { 8795 TEST_F(GLES2DecoderManualInitTest, MemoryTrackerRenderbufferStorage) {
8946 scoped_refptr<SizeOnlyMemoryTracker> memory_tracker = 8796 scoped_refptr<SizeOnlyMemoryTracker> memory_tracker =
8947 new SizeOnlyMemoryTracker(); 8797 new SizeOnlyMemoryTracker();
8948 set_memory_tracker(memory_tracker.get()); 8798 set_memory_tracker(memory_tracker.get());
8949 InitState init; 8799 InitState init;
8950 init.gl_version = "3.0"; 8800 init.gl_version = "3.0";
8951 init.bind_generates_resource = true; 8801 init.bind_generates_resource = true;
8952 InitDecoder(init); 8802 InitDecoder(init);
8953 DoBindRenderbuffer(GL_RENDERBUFFER, client_renderbuffer_id_, 8803 DoBindRenderbuffer(GL_RENDERBUFFER, client_renderbuffer_id_,
8954 kServiceRenderbufferId); 8804 kServiceRenderbufferId);
8955 EXPECT_CALL(*gl_, GetError()) 8805 EXPECT_CALL(*gl_, GetError())
(...skipping 13 matching lines...) Expand all
8969 EXPECT_EQ(128u, memory_tracker->GetPoolSize(MemoryTracker::kUnmanaged)); 8819 EXPECT_EQ(128u, memory_tracker->GetPoolSize(MemoryTracker::kUnmanaged));
8970 // Check we get out of memory and no call to glRenderbufferStorage if Ensure 8820 // Check we get out of memory and no call to glRenderbufferStorage if Ensure
8971 // fails. 8821 // fails.
8972 EXPECT_CALL(*memory_tracker.get(), EnsureGPUMemoryAvailable(128)) 8822 EXPECT_CALL(*memory_tracker.get(), EnsureGPUMemoryAvailable(128))
8973 .WillOnce(Return(false)).RetiresOnSaturation(); 8823 .WillOnce(Return(false)).RetiresOnSaturation();
8974 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 8824 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
8975 EXPECT_EQ(GL_OUT_OF_MEMORY, GetGLError()); 8825 EXPECT_EQ(GL_OUT_OF_MEMORY, GetGLError());
8976 EXPECT_EQ(128u, memory_tracker->GetPoolSize(MemoryTracker::kUnmanaged)); 8826 EXPECT_EQ(128u, memory_tracker->GetPoolSize(MemoryTracker::kUnmanaged));
8977 } 8827 }
8978 8828
8979 TEST_P(GLES2DecoderManualInitTest, MemoryTrackerBufferData) { 8829 TEST_F(GLES2DecoderManualInitTest, MemoryTrackerBufferData) {
8980 scoped_refptr<SizeOnlyMemoryTracker> memory_tracker = 8830 scoped_refptr<SizeOnlyMemoryTracker> memory_tracker =
8981 new SizeOnlyMemoryTracker(); 8831 new SizeOnlyMemoryTracker();
8982 set_memory_tracker(memory_tracker.get()); 8832 set_memory_tracker(memory_tracker.get());
8983 InitState init; 8833 InitState init;
8984 init.gl_version = "3.0"; 8834 init.gl_version = "3.0";
8985 init.bind_generates_resource = true; 8835 init.bind_generates_resource = true;
8986 InitDecoder(init); 8836 InitDecoder(init);
8987 DoBindBuffer(GL_ARRAY_BUFFER, client_buffer_id_, 8837 DoBindBuffer(GL_ARRAY_BUFFER, client_buffer_id_,
8988 kServiceBufferId); 8838 kServiceBufferId);
8989 EXPECT_CALL(*gl_, GetError()) 8839 EXPECT_CALL(*gl_, GetError())
(...skipping 12 matching lines...) Expand all
9002 EXPECT_EQ(128u, memory_tracker->GetPoolSize(MemoryTracker::kManaged)); 8852 EXPECT_EQ(128u, memory_tracker->GetPoolSize(MemoryTracker::kManaged));
9003 // Check we get out of memory and no call to glBufferData if Ensure 8853 // Check we get out of memory and no call to glBufferData if Ensure
9004 // fails. 8854 // fails.
9005 EXPECT_CALL(*memory_tracker.get(), EnsureGPUMemoryAvailable(128)) 8855 EXPECT_CALL(*memory_tracker.get(), EnsureGPUMemoryAvailable(128))
9006 .WillOnce(Return(false)).RetiresOnSaturation(); 8856 .WillOnce(Return(false)).RetiresOnSaturation();
9007 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 8857 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
9008 EXPECT_EQ(GL_OUT_OF_MEMORY, GetGLError()); 8858 EXPECT_EQ(GL_OUT_OF_MEMORY, GetGLError());
9009 EXPECT_EQ(128u, memory_tracker->GetPoolSize(MemoryTracker::kManaged)); 8859 EXPECT_EQ(128u, memory_tracker->GetPoolSize(MemoryTracker::kManaged));
9010 } 8860 }
9011 8861
9012 TEST_P(GLES2DecoderTest, DrawBuffersEXTImmediateSuccceeds) { 8862 TEST_F(GLES2DecoderTest, DrawBuffersEXTImmediateSuccceeds) {
9013 const GLsizei count = 1; 8863 const GLsizei count = 1;
9014 const GLenum bufs[] = { GL_COLOR_ATTACHMENT0 }; 8864 const GLenum bufs[] = { GL_COLOR_ATTACHMENT0 };
9015 DrawBuffersEXTImmediate& cmd = 8865 DrawBuffersEXTImmediate& cmd =
9016 *GetImmediateAs<DrawBuffersEXTImmediate>(); 8866 *GetImmediateAs<DrawBuffersEXTImmediate>();
9017 cmd.Init(count, bufs); 8867 cmd.Init(count, bufs);
9018 8868
9019 DoBindFramebuffer(GL_FRAMEBUFFER, client_framebuffer_id_, 8869 DoBindFramebuffer(GL_FRAMEBUFFER, client_framebuffer_id_,
9020 kServiceFramebufferId); 8870 kServiceFramebufferId);
9021 EXPECT_CALL(*gl_, DrawBuffersARB(count, _)) 8871 EXPECT_CALL(*gl_, DrawBuffersARB(count, _))
9022 .Times(1) 8872 .Times(1)
9023 .RetiresOnSaturation(); 8873 .RetiresOnSaturation();
9024 EXPECT_EQ(error::kNoError, 8874 EXPECT_EQ(error::kNoError,
9025 ExecuteImmediateCmd(cmd, sizeof(bufs))); 8875 ExecuteImmediateCmd(cmd, sizeof(bufs)));
9026 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 8876 EXPECT_EQ(GL_NO_ERROR, GetGLError());
9027 } 8877 }
9028 8878
9029 TEST_P(GLES2DecoderTest, DrawBuffersEXTImmediateFails) { 8879 TEST_F(GLES2DecoderTest, DrawBuffersEXTImmediateFails) {
9030 const GLsizei count = 1; 8880 const GLsizei count = 1;
9031 const GLenum bufs[] = { GL_COLOR_ATTACHMENT1_EXT }; 8881 const GLenum bufs[] = { GL_COLOR_ATTACHMENT1_EXT };
9032 DrawBuffersEXTImmediate& cmd = 8882 DrawBuffersEXTImmediate& cmd =
9033 *GetImmediateAs<DrawBuffersEXTImmediate>(); 8883 *GetImmediateAs<DrawBuffersEXTImmediate>();
9034 cmd.Init(count, bufs); 8884 cmd.Init(count, bufs);
9035 8885
9036 DoBindFramebuffer(GL_FRAMEBUFFER, client_framebuffer_id_, 8886 DoBindFramebuffer(GL_FRAMEBUFFER, client_framebuffer_id_,
9037 kServiceFramebufferId); 8887 kServiceFramebufferId);
9038 EXPECT_EQ(error::kNoError, 8888 EXPECT_EQ(error::kNoError,
9039 ExecuteImmediateCmd(cmd, sizeof(bufs))); 8889 ExecuteImmediateCmd(cmd, sizeof(bufs)));
9040 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); 8890 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
9041 } 8891 }
9042 8892
9043 TEST_P(GLES2DecoderTest, DrawBuffersEXTImmediateBackbuffer) { 8893 TEST_F(GLES2DecoderTest, DrawBuffersEXTImmediateBackbuffer) {
9044 const GLsizei count = 1; 8894 const GLsizei count = 1;
9045 const GLenum bufs[] = { GL_BACK }; 8895 const GLenum bufs[] = { GL_BACK };
9046 DrawBuffersEXTImmediate& cmd = 8896 DrawBuffersEXTImmediate& cmd =
9047 *GetImmediateAs<DrawBuffersEXTImmediate>(); 8897 *GetImmediateAs<DrawBuffersEXTImmediate>();
9048 cmd.Init(count, bufs); 8898 cmd.Init(count, bufs);
9049 8899
9050 DoBindFramebuffer(GL_FRAMEBUFFER, client_framebuffer_id_, 8900 DoBindFramebuffer(GL_FRAMEBUFFER, client_framebuffer_id_,
9051 kServiceFramebufferId); 8901 kServiceFramebufferId);
9052 EXPECT_EQ(error::kNoError, 8902 EXPECT_EQ(error::kNoError,
9053 ExecuteImmediateCmd(cmd, sizeof(bufs))); 8903 ExecuteImmediateCmd(cmd, sizeof(bufs)));
9054 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); 8904 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
9055 8905
9056 DoBindFramebuffer(GL_FRAMEBUFFER, 0, 0); // unbind 8906 DoBindFramebuffer(GL_FRAMEBUFFER, 0, 0); // unbind
9057 8907
9058 EXPECT_CALL(*gl_, DrawBuffersARB(count, _)) 8908 EXPECT_CALL(*gl_, DrawBuffersARB(count, _))
9059 .Times(1) 8909 .Times(1)
9060 .RetiresOnSaturation(); 8910 .RetiresOnSaturation();
9061 8911
9062 EXPECT_EQ(error::kNoError, 8912 EXPECT_EQ(error::kNoError,
9063 ExecuteImmediateCmd(cmd, sizeof(bufs))); 8913 ExecuteImmediateCmd(cmd, sizeof(bufs)));
9064 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 8914 EXPECT_EQ(GL_NO_ERROR, GetGLError());
9065 } 8915 }
9066 8916
9067 TEST_P(GLES2DecoderManualInitTest, InvalidateFramebufferBinding) { 8917 TEST_F(GLES2DecoderManualInitTest, InvalidateFramebufferBinding) {
9068 InitState init; 8918 InitState init;
9069 init.gl_version = "opengl es 3.0"; 8919 init.gl_version = "opengl es 3.0";
9070 InitDecoder(init); 8920 InitDecoder(init);
9071 8921
9072 // EXPECT_EQ can't be used to compare function pointers 8922 // EXPECT_EQ can't be used to compare function pointers
9073 EXPECT_TRUE( 8923 EXPECT_TRUE(
9074 gfx::MockGLInterface::GetGLProcAddress("glInvalidateFramebuffer") == 8924 gfx::MockGLInterface::GetGLProcAddress("glInvalidateFramebuffer") ==
9075 gfx::g_driver_gl.fn.glDiscardFramebufferEXTFn); 8925 gfx::g_driver_gl.fn.glDiscardFramebufferEXTFn);
9076 EXPECT_TRUE( 8926 EXPECT_TRUE(
9077 gfx::MockGLInterface::GetGLProcAddress("glInvalidateFramebuffer") != 8927 gfx::MockGLInterface::GetGLProcAddress("glInvalidateFramebuffer") !=
9078 gfx::MockGLInterface::GetGLProcAddress("glDiscardFramebufferEXT")); 8928 gfx::MockGLInterface::GetGLProcAddress("glDiscardFramebufferEXT"));
9079 } 8929 }
9080 8930
9081 TEST_P(GLES2DecoderManualInitTest, DiscardFramebufferEXT) { 8931 TEST_F(GLES2DecoderManualInitTest, DiscardFramebufferEXT) {
9082 InitState init; 8932 InitState init;
9083 init.extensions = "GL_EXT_discard_framebuffer"; 8933 init.extensions = "GL_EXT_discard_framebuffer";
9084 init.gl_version = "opengl es 2.0"; 8934 init.gl_version = "opengl es 2.0";
9085 InitDecoder(init); 8935 InitDecoder(init);
9086 8936
9087 // EXPECT_EQ can't be used to compare function pointers 8937 // EXPECT_EQ can't be used to compare function pointers
9088 EXPECT_TRUE( 8938 EXPECT_TRUE(
9089 gfx::MockGLInterface::GetGLProcAddress("glDiscardFramebufferEXT") == 8939 gfx::MockGLInterface::GetGLProcAddress("glDiscardFramebufferEXT") ==
9090 gfx::g_driver_gl.fn.glDiscardFramebufferEXTFn); 8940 gfx::g_driver_gl.fn.glDiscardFramebufferEXTFn);
9091 8941
(...skipping 22 matching lines...) Expand all
9114 DiscardFramebufferEXTImmediate& cmd = 8964 DiscardFramebufferEXTImmediate& cmd =
9115 *GetImmediateAs<DiscardFramebufferEXTImmediate>(); 8965 *GetImmediateAs<DiscardFramebufferEXTImmediate>();
9116 cmd.Init(target, count, attachments); 8966 cmd.Init(target, count, attachments);
9117 8967
9118 EXPECT_EQ(error::kNoError, 8968 EXPECT_EQ(error::kNoError,
9119 ExecuteImmediateCmd(cmd, sizeof(attachments))); 8969 ExecuteImmediateCmd(cmd, sizeof(attachments)));
9120 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 8970 EXPECT_EQ(GL_NO_ERROR, GetGLError());
9121 EXPECT_FALSE(framebuffer->IsCleared()); 8971 EXPECT_FALSE(framebuffer->IsCleared());
9122 } 8972 }
9123 8973
9124 TEST_P(GLES2DecoderTest, DiscardFramebufferEXTUnsupported) { 8974 TEST_F(GLES2DecoderTest, DiscardFramebufferEXTUnsupported) {
9125 const GLenum target = GL_FRAMEBUFFER; 8975 const GLenum target = GL_FRAMEBUFFER;
9126 const GLsizei count = 1; 8976 const GLsizei count = 1;
9127 const GLenum attachments[] = { GL_COLOR_EXT }; 8977 const GLenum attachments[] = { GL_COLOR_EXT };
9128 DiscardFramebufferEXTImmediate& cmd = 8978 DiscardFramebufferEXTImmediate& cmd =
9129 *GetImmediateAs<DiscardFramebufferEXTImmediate>(); 8979 *GetImmediateAs<DiscardFramebufferEXTImmediate>();
9130 cmd.Init(target, count, attachments); 8980 cmd.Init(target, count, attachments);
9131 8981
9132 // Should not result into a call into GL. 8982 // Should not result into a call into GL.
9133 EXPECT_EQ(error::kNoError, 8983 EXPECT_EQ(error::kNoError,
9134 ExecuteImmediateCmd(cmd, sizeof(attachments))); 8984 ExecuteImmediateCmd(cmd, sizeof(attachments)));
9135 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); 8985 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
9136 } 8986 }
9137 8987
9138 TEST_P(GLES2DecoderRestoreStateTest, NullPreviousStateBGR) { 8988 TEST_F(GLES2DecoderRestoreStateTest, NullPreviousStateBGR) {
9139 InitState init; 8989 InitState init;
9140 init.gl_version = "3.0"; 8990 init.gl_version = "3.0";
9141 init.bind_generates_resource = true; 8991 init.bind_generates_resource = true;
9142 InitDecoder(init); 8992 InitDecoder(init);
9143 SetupTexture(); 8993 SetupTexture();
9144 8994
9145 InSequence sequence; 8995 InSequence sequence;
9146 // Expect to restore texture bindings for unit GL_TEXTURE0. 8996 // Expect to restore texture bindings for unit GL_TEXTURE0.
9147 AddExpectationsForActiveTexture(GL_TEXTURE0); 8997 AddExpectationsForActiveTexture(GL_TEXTURE0);
9148 AddExpectationsForBindTexture(GL_TEXTURE_2D, kServiceTextureId); 8998 AddExpectationsForBindTexture(GL_TEXTURE_2D, kServiceTextureId);
9149 AddExpectationsForBindTexture(GL_TEXTURE_CUBE_MAP, 8999 AddExpectationsForBindTexture(GL_TEXTURE_CUBE_MAP,
9150 TestHelper::kServiceDefaultTextureCubemapId); 9000 TestHelper::kServiceDefaultTextureCubemapId);
9151 9001
9152 // Expect to restore texture bindings for remaining units. 9002 // Expect to restore texture bindings for remaining units.
9153 for (uint32 i = 1; i < group().max_texture_units() ; ++i) { 9003 for (uint32 i = 1; i < group().max_texture_units() ; ++i) {
9154 AddExpectationsForActiveTexture(GL_TEXTURE0 + i); 9004 AddExpectationsForActiveTexture(GL_TEXTURE0 + i);
9155 AddExpectationsForBindTexture(GL_TEXTURE_2D, 9005 AddExpectationsForBindTexture(GL_TEXTURE_2D,
9156 TestHelper::kServiceDefaultTexture2dId); 9006 TestHelper::kServiceDefaultTexture2dId);
9157 AddExpectationsForBindTexture(GL_TEXTURE_CUBE_MAP, 9007 AddExpectationsForBindTexture(GL_TEXTURE_CUBE_MAP,
9158 TestHelper::kServiceDefaultTextureCubemapId); 9008 TestHelper::kServiceDefaultTextureCubemapId);
9159 } 9009 }
9160 9010
9161 // Expect to restore the active texture unit to GL_TEXTURE0. 9011 // Expect to restore the active texture unit to GL_TEXTURE0.
9162 AddExpectationsForActiveTexture(GL_TEXTURE0); 9012 AddExpectationsForActiveTexture(GL_TEXTURE0);
9163 9013
9164 GetDecoder()->RestoreAllTextureUnitBindings(NULL); 9014 GetDecoder()->RestoreAllTextureUnitBindings(NULL);
9165 } 9015 }
9166 9016
9167 TEST_P(GLES2DecoderRestoreStateTest, NullPreviousState) { 9017 TEST_F(GLES2DecoderRestoreStateTest, NullPreviousState) {
9168 InitState init; 9018 InitState init;
9169 init.gl_version = "3.0"; 9019 init.gl_version = "3.0";
9170 InitDecoder(init); 9020 InitDecoder(init);
9171 SetupTexture(); 9021 SetupTexture();
9172 9022
9173 InSequence sequence; 9023 InSequence sequence;
9174 // Expect to restore texture bindings for unit GL_TEXTURE0. 9024 // Expect to restore texture bindings for unit GL_TEXTURE0.
9175 AddExpectationsForActiveTexture(GL_TEXTURE0); 9025 AddExpectationsForActiveTexture(GL_TEXTURE0);
9176 AddExpectationsForBindTexture(GL_TEXTURE_2D, kServiceTextureId); 9026 AddExpectationsForBindTexture(GL_TEXTURE_2D, kServiceTextureId);
9177 AddExpectationsForBindTexture(GL_TEXTURE_CUBE_MAP, 0); 9027 AddExpectationsForBindTexture(GL_TEXTURE_CUBE_MAP, 0);
9178 9028
9179 // Expect to restore texture bindings for remaining units. 9029 // Expect to restore texture bindings for remaining units.
9180 for (uint32 i = 1; i < group().max_texture_units(); ++i) { 9030 for (uint32 i = 1; i < group().max_texture_units(); ++i) {
9181 AddExpectationsForActiveTexture(GL_TEXTURE0 + i); 9031 AddExpectationsForActiveTexture(GL_TEXTURE0 + i);
9182 AddExpectationsForBindTexture(GL_TEXTURE_2D, 0); 9032 AddExpectationsForBindTexture(GL_TEXTURE_2D, 0);
9183 AddExpectationsForBindTexture(GL_TEXTURE_CUBE_MAP, 0); 9033 AddExpectationsForBindTexture(GL_TEXTURE_CUBE_MAP, 0);
9184 } 9034 }
9185 9035
9186 // Expect to restore the active texture unit to GL_TEXTURE0. 9036 // Expect to restore the active texture unit to GL_TEXTURE0.
9187 AddExpectationsForActiveTexture(GL_TEXTURE0); 9037 AddExpectationsForActiveTexture(GL_TEXTURE0);
9188 9038
9189 GetDecoder()->RestoreAllTextureUnitBindings(NULL); 9039 GetDecoder()->RestoreAllTextureUnitBindings(NULL);
9190 } 9040 }
9191 9041
9192 TEST_P(GLES2DecoderRestoreStateTest, WithPreviousStateBGR) { 9042 TEST_F(GLES2DecoderRestoreStateTest, WithPreviousStateBGR) {
9193 InitState init; 9043 InitState init;
9194 init.gl_version = "3.0"; 9044 init.gl_version = "3.0";
9195 init.bind_generates_resource = true; 9045 init.bind_generates_resource = true;
9196 InitDecoder(init); 9046 InitDecoder(init);
9197 SetupTexture(); 9047 SetupTexture();
9198 9048
9199 // Construct a previous ContextState with all texture bindings 9049 // Construct a previous ContextState with all texture bindings
9200 // set to default textures. 9050 // set to default textures.
9201 ContextState prev_state(NULL, NULL, NULL); 9051 ContextState prev_state(NULL, NULL, NULL);
9202 InitializeContextState(&prev_state, std::numeric_limits<uint32>::max(), 0); 9052 InitializeContextState(&prev_state, std::numeric_limits<uint32>::max(), 0);
9203 9053
9204 InSequence sequence; 9054 InSequence sequence;
9205 // Expect to restore only GL_TEXTURE_2D binding for GL_TEXTURE0 unit, 9055 // Expect to restore only GL_TEXTURE_2D binding for GL_TEXTURE0 unit,
9206 // since the rest of the bindings haven't changed between the current 9056 // since the rest of the bindings haven't changed between the current
9207 // state and the |prev_state|. 9057 // state and the |prev_state|.
9208 AddExpectationsForActiveTexture(GL_TEXTURE0); 9058 AddExpectationsForActiveTexture(GL_TEXTURE0);
9209 AddExpectationsForBindTexture(GL_TEXTURE_2D, kServiceTextureId); 9059 AddExpectationsForBindTexture(GL_TEXTURE_2D, kServiceTextureId);
9210 9060
9211 // Expect to restore active texture unit to GL_TEXTURE0. 9061 // Expect to restore active texture unit to GL_TEXTURE0.
9212 AddExpectationsForActiveTexture(GL_TEXTURE0); 9062 AddExpectationsForActiveTexture(GL_TEXTURE0);
9213 9063
9214 GetDecoder()->RestoreAllTextureUnitBindings(&prev_state); 9064 GetDecoder()->RestoreAllTextureUnitBindings(&prev_state);
9215 } 9065 }
9216 9066
9217 TEST_P(GLES2DecoderRestoreStateTest, WithPreviousState) { 9067 TEST_F(GLES2DecoderRestoreStateTest, WithPreviousState) {
9218 InitState init; 9068 InitState init;
9219 init.gl_version = "3.0"; 9069 init.gl_version = "3.0";
9220 InitDecoder(init); 9070 InitDecoder(init);
9221 SetupTexture(); 9071 SetupTexture();
9222 9072
9223 // Construct a previous ContextState with all texture bindings 9073 // Construct a previous ContextState with all texture bindings
9224 // set to default textures. 9074 // set to default textures.
9225 ContextState prev_state(NULL, NULL, NULL); 9075 ContextState prev_state(NULL, NULL, NULL);
9226 InitializeContextState(&prev_state, std::numeric_limits<uint32>::max(), 0); 9076 InitializeContextState(&prev_state, std::numeric_limits<uint32>::max(), 0);
9227 9077
9228 InSequence sequence; 9078 InSequence sequence;
9229 // Expect to restore only GL_TEXTURE_2D binding for GL_TEXTURE0 unit, 9079 // Expect to restore only GL_TEXTURE_2D binding for GL_TEXTURE0 unit,
9230 // since the rest of the bindings haven't changed between the current 9080 // since the rest of the bindings haven't changed between the current
9231 // state and the |prev_state|. 9081 // state and the |prev_state|.
9232 AddExpectationsForActiveTexture(GL_TEXTURE0); 9082 AddExpectationsForActiveTexture(GL_TEXTURE0);
9233 AddExpectationsForBindTexture(GL_TEXTURE_2D, kServiceTextureId); 9083 AddExpectationsForBindTexture(GL_TEXTURE_2D, kServiceTextureId);
9234 9084
9235 // Expect to restore active texture unit to GL_TEXTURE0. 9085 // Expect to restore active texture unit to GL_TEXTURE0.
9236 AddExpectationsForActiveTexture(GL_TEXTURE0); 9086 AddExpectationsForActiveTexture(GL_TEXTURE0);
9237 9087
9238 GetDecoder()->RestoreAllTextureUnitBindings(&prev_state); 9088 GetDecoder()->RestoreAllTextureUnitBindings(&prev_state);
9239 } 9089 }
9240 9090
9241 TEST_P(GLES2DecoderRestoreStateTest, ActiveUnit1) { 9091 TEST_F(GLES2DecoderRestoreStateTest, ActiveUnit1) {
9242 InitState init; 9092 InitState init;
9243 init.gl_version = "3.0"; 9093 init.gl_version = "3.0";
9244 InitDecoder(init); 9094 InitDecoder(init);
9245 9095
9246 // Bind a non-default texture to GL_TEXTURE1 unit. 9096 // Bind a non-default texture to GL_TEXTURE1 unit.
9247 EXPECT_CALL(*gl_, ActiveTexture(GL_TEXTURE1)); 9097 EXPECT_CALL(*gl_, ActiveTexture(GL_TEXTURE1));
9248 ActiveTexture cmd; 9098 ActiveTexture cmd;
9249 cmd.Init(GL_TEXTURE1); 9099 cmd.Init(GL_TEXTURE1);
9250 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 9100 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
9251 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 9101 EXPECT_EQ(GL_NO_ERROR, GetGLError());
(...skipping 10 matching lines...) Expand all
9262 // state and the |prev_state|. 9112 // state and the |prev_state|.
9263 AddExpectationsForActiveTexture(GL_TEXTURE1); 9113 AddExpectationsForActiveTexture(GL_TEXTURE1);
9264 AddExpectationsForBindTexture(GL_TEXTURE_2D, kServiceTextureId); 9114 AddExpectationsForBindTexture(GL_TEXTURE_2D, kServiceTextureId);
9265 9115
9266 // Expect to restore active texture unit to GL_TEXTURE1. 9116 // Expect to restore active texture unit to GL_TEXTURE1.
9267 AddExpectationsForActiveTexture(GL_TEXTURE1); 9117 AddExpectationsForActiveTexture(GL_TEXTURE1);
9268 9118
9269 GetDecoder()->RestoreAllTextureUnitBindings(&prev_state); 9119 GetDecoder()->RestoreAllTextureUnitBindings(&prev_state);
9270 } 9120 }
9271 9121
9272 TEST_P(GLES2DecoderRestoreStateTest, NonDefaultUnit0BGR) { 9122 TEST_F(GLES2DecoderRestoreStateTest, NonDefaultUnit0BGR) {
9273 InitState init; 9123 InitState init;
9274 init.gl_version = "3.0"; 9124 init.gl_version = "3.0";
9275 init.bind_generates_resource = true; 9125 init.bind_generates_resource = true;
9276 InitDecoder(init); 9126 InitDecoder(init);
9277 9127
9278 // Bind a non-default texture to GL_TEXTURE1 unit. 9128 // Bind a non-default texture to GL_TEXTURE1 unit.
9279 EXPECT_CALL(*gl_, ActiveTexture(GL_TEXTURE1)); 9129 EXPECT_CALL(*gl_, ActiveTexture(GL_TEXTURE1));
9280 SpecializedSetup<ActiveTexture, 0>(true); 9130 SpecializedSetup<ActiveTexture, 0>(true);
9281 ActiveTexture cmd; 9131 ActiveTexture cmd;
9282 cmd.Init(GL_TEXTURE1); 9132 cmd.Init(GL_TEXTURE1);
(...skipping 18 matching lines...) Expand all
9301 // non-default. 9151 // non-default.
9302 AddExpectationsForActiveTexture(GL_TEXTURE1); 9152 AddExpectationsForActiveTexture(GL_TEXTURE1);
9303 AddExpectationsForBindTexture(GL_TEXTURE_2D, kServiceTextureId); 9153 AddExpectationsForBindTexture(GL_TEXTURE_2D, kServiceTextureId);
9304 9154
9305 // Expect to restore active texture unit to GL_TEXTURE1. 9155 // Expect to restore active texture unit to GL_TEXTURE1.
9306 AddExpectationsForActiveTexture(GL_TEXTURE1); 9156 AddExpectationsForActiveTexture(GL_TEXTURE1);
9307 9157
9308 GetDecoder()->RestoreAllTextureUnitBindings(&prev_state); 9158 GetDecoder()->RestoreAllTextureUnitBindings(&prev_state);
9309 } 9159 }
9310 9160
9311 TEST_P(GLES2DecoderRestoreStateTest, NonDefaultUnit1BGR) { 9161 TEST_F(GLES2DecoderRestoreStateTest, NonDefaultUnit1BGR) {
9312 InitState init; 9162 InitState init;
9313 init.gl_version = "3.0"; 9163 init.gl_version = "3.0";
9314 init.bind_generates_resource = true; 9164 init.bind_generates_resource = true;
9315 InitDecoder(init); 9165 InitDecoder(init);
9316 9166
9317 // Bind a non-default texture to GL_TEXTURE0 unit. 9167 // Bind a non-default texture to GL_TEXTURE0 unit.
9318 SetupTexture(); 9168 SetupTexture();
9319 9169
9320 // Construct a previous ContextState with GL_TEXTURE_2D target in 9170 // Construct a previous ContextState with GL_TEXTURE_2D target in
9321 // GL_TEXTURE1 unit bound to a non-default texture and the rest 9171 // GL_TEXTURE1 unit bound to a non-default texture and the rest
(...skipping 12 matching lines...) Expand all
9334 AddExpectationsForActiveTexture(GL_TEXTURE1); 9184 AddExpectationsForActiveTexture(GL_TEXTURE1);
9335 AddExpectationsForBindTexture(GL_TEXTURE_2D, 9185 AddExpectationsForBindTexture(GL_TEXTURE_2D,
9336 TestHelper::kServiceDefaultTexture2dId); 9186 TestHelper::kServiceDefaultTexture2dId);
9337 9187
9338 // Expect to restore active texture unit to GL_TEXTURE0. 9188 // Expect to restore active texture unit to GL_TEXTURE0.
9339 AddExpectationsForActiveTexture(GL_TEXTURE0); 9189 AddExpectationsForActiveTexture(GL_TEXTURE0);
9340 9190
9341 GetDecoder()->RestoreAllTextureUnitBindings(&prev_state); 9191 GetDecoder()->RestoreAllTextureUnitBindings(&prev_state);
9342 } 9192 }
9343 9193
9344 TEST_P(GLES2DecoderRestoreStateTest, DefaultUnit0) { 9194 TEST_F(GLES2DecoderRestoreStateTest, DefaultUnit0) {
9345 InitState init; 9195 InitState init;
9346 init.gl_version = "3.0"; 9196 init.gl_version = "3.0";
9347 InitDecoder(init); 9197 InitDecoder(init);
9348 9198
9349 // Bind a non-default texture to GL_TEXTURE1 unit. 9199 // Bind a non-default texture to GL_TEXTURE1 unit.
9350 EXPECT_CALL(*gl_, ActiveTexture(GL_TEXTURE1)); 9200 EXPECT_CALL(*gl_, ActiveTexture(GL_TEXTURE1));
9351 SpecializedSetup<ActiveTexture, 0>(true); 9201 SpecializedSetup<ActiveTexture, 0>(true);
9352 ActiveTexture cmd; 9202 ActiveTexture cmd;
9353 cmd.Init(GL_TEXTURE1); 9203 cmd.Init(GL_TEXTURE1);
9354 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 9204 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
(...skipping 16 matching lines...) Expand all
9371 // non-default. 9221 // non-default.
9372 AddExpectationsForActiveTexture(GL_TEXTURE1); 9222 AddExpectationsForActiveTexture(GL_TEXTURE1);
9373 AddExpectationsForBindTexture(GL_TEXTURE_2D, kServiceTextureId); 9223 AddExpectationsForBindTexture(GL_TEXTURE_2D, kServiceTextureId);
9374 9224
9375 // Expect to restore active texture unit to GL_TEXTURE1. 9225 // Expect to restore active texture unit to GL_TEXTURE1.
9376 AddExpectationsForActiveTexture(GL_TEXTURE1); 9226 AddExpectationsForActiveTexture(GL_TEXTURE1);
9377 9227
9378 GetDecoder()->RestoreAllTextureUnitBindings(&prev_state); 9228 GetDecoder()->RestoreAllTextureUnitBindings(&prev_state);
9379 } 9229 }
9380 9230
9381 TEST_P(GLES2DecoderRestoreStateTest, DefaultUnit1) { 9231 TEST_F(GLES2DecoderRestoreStateTest, DefaultUnit1) {
9382 InitState init; 9232 InitState init;
9383 init.gl_version = "3.0"; 9233 init.gl_version = "3.0";
9384 InitDecoder(init); 9234 InitDecoder(init);
9385 9235
9386 // Bind a non-default texture to GL_TEXTURE0 unit. 9236 // Bind a non-default texture to GL_TEXTURE0 unit.
9387 SetupTexture(); 9237 SetupTexture();
9388 9238
9389 // Construct a previous ContextState with GL_TEXTURE_2D target in 9239 // Construct a previous ContextState with GL_TEXTURE_2D target in
9390 // GL_TEXTURE1 unit bound to a non-default texture and the rest 9240 // GL_TEXTURE1 unit bound to a non-default texture and the rest
9391 // set to default textures. 9241 // set to default textures.
(...skipping 24 matching lines...) Expand all
9416 // TODO(vmiura): Tests for ContextState::RestoreBufferBindings(). 9266 // TODO(vmiura): Tests for ContextState::RestoreBufferBindings().
9417 9267
9418 // TODO(vmiura): Tests for ContextState::RestoreProgramBindings(). 9268 // TODO(vmiura): Tests for ContextState::RestoreProgramBindings().
9419 9269
9420 // TODO(vmiura): Tests for RestoreRenderbufferBindings(). 9270 // TODO(vmiura): Tests for RestoreRenderbufferBindings().
9421 9271
9422 // TODO(vmiura): Tests for RestoreProgramBindings(). 9272 // TODO(vmiura): Tests for RestoreProgramBindings().
9423 9273
9424 // TODO(vmiura): Tests for RestoreGlobalState(). 9274 // TODO(vmiura): Tests for RestoreGlobalState().
9425 9275
9426 TEST_P(GLES2DecoderManualInitTest, ClearUniformsBeforeFirstProgramUse) { 9276 TEST_F(GLES2DecoderManualInitTest, ClearUniformsBeforeFirstProgramUse) {
9427 CommandLine command_line(0, NULL); 9277 CommandLine command_line(0, NULL);
9428 command_line.AppendSwitchASCII( 9278 command_line.AppendSwitchASCII(
9429 switches::kGpuDriverBugWorkarounds, 9279 switches::kGpuDriverBugWorkarounds,
9430 base::IntToString(gpu::CLEAR_UNIFORMS_BEFORE_FIRST_PROGRAM_USE)); 9280 base::IntToString(gpu::CLEAR_UNIFORMS_BEFORE_FIRST_PROGRAM_USE));
9431 InitState init; 9281 InitState init;
9432 init.gl_version = "3.0"; 9282 init.gl_version = "3.0";
9433 init.has_alpha = true; 9283 init.has_alpha = true;
9434 init.request_alpha = true; 9284 init.request_alpha = true;
9435 init.bind_generates_resource = true; 9285 init.bind_generates_resource = true;
9436 InitDecoderWithCommandLine(init, &command_line); 9286 InitDecoderWithCommandLine(init, &command_line);
(...skipping 25 matching lines...) Expand all
9462 { 9312 {
9463 EXPECT_CALL(*gl_, UseProgram(kServiceProgramId)) 9313 EXPECT_CALL(*gl_, UseProgram(kServiceProgramId))
9464 .Times(1) 9314 .Times(1)
9465 .RetiresOnSaturation(); 9315 .RetiresOnSaturation();
9466 cmds::UseProgram cmd; 9316 cmds::UseProgram cmd;
9467 cmd.Init(client_program_id_); 9317 cmd.Init(client_program_id_);
9468 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 9318 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
9469 } 9319 }
9470 } 9320 }
9471 9321
9472 TEST_P(GLES2DecoderManualInitTest, TexImage2DFloatOnGLES2) { 9322 TEST_F(GLES2DecoderManualInitTest, TexImage2DFloatOnGLES2) {
9473 InitState init; 9323 InitState init;
9474 init.extensions = "GL_OES_texture_float"; 9324 init.extensions = "GL_OES_texture_float";
9475 init.gl_version = "opengl es 2.0"; 9325 init.gl_version = "opengl es 2.0";
9476 InitDecoder(init); 9326 InitDecoder(init);
9477 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); 9327 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId);
9478 DoTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 16, 17, 0, GL_RGBA, GL_FLOAT, 0, 0); 9328 DoTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 16, 17, 0, GL_RGBA, GL_FLOAT, 0, 0);
9479 DoTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 16, 17, 0, GL_RGB, GL_FLOAT, 0, 0); 9329 DoTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 16, 17, 0, GL_RGB, GL_FLOAT, 0, 0);
9480 DoTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, 16, 17, 0, GL_LUMINANCE, 9330 DoTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, 16, 17, 0, GL_LUMINANCE,
9481 GL_FLOAT, 0, 0); 9331 GL_FLOAT, 0, 0);
9482 DoTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, 16, 17, 0, GL_ALPHA, GL_FLOAT, 9332 DoTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, 16, 17, 0, GL_ALPHA, GL_FLOAT,
9483 0, 0); 9333 0, 0);
9484 DoTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE_ALPHA, 16, 17, 0, 9334 DoTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE_ALPHA, 16, 17, 0,
9485 GL_LUMINANCE_ALPHA, GL_FLOAT, 0, 0); 9335 GL_LUMINANCE_ALPHA, GL_FLOAT, 0, 0);
9486 } 9336 }
9487 9337
9488 TEST_P(GLES2DecoderManualInitTest, TexImage2DFloatOnGLES3) { 9338 TEST_F(GLES2DecoderManualInitTest, TexImage2DFloatOnGLES3) {
9489 InitState init; 9339 InitState init;
9490 init.extensions = "GL_OES_texture_float GL_EXT_color_buffer_float"; 9340 init.extensions = "GL_OES_texture_float GL_EXT_color_buffer_float";
9491 init.gl_version = "opengl es 3.0"; 9341 init.gl_version = "opengl es 3.0";
9492 InitDecoder(init); 9342 InitDecoder(init);
9493 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); 9343 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId);
9494 DoTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 16, 17, 0, GL_RGBA, GL_FLOAT, 0, 0); 9344 DoTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 16, 17, 0, GL_RGBA, GL_FLOAT, 0, 0);
9495 DoTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 16, 17, 0, GL_RGB, GL_FLOAT, 0, 0); 9345 DoTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 16, 17, 0, GL_RGB, GL_FLOAT, 0, 0);
9496 DoTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F, 16, 17, 0, GL_RGBA, GL_FLOAT, 0, 9346 DoTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F, 16, 17, 0, GL_RGBA, GL_FLOAT, 0,
9497 0); 9347 0);
9498 DoTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, 16, 17, 0, GL_LUMINANCE, 9348 DoTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, 16, 17, 0, GL_LUMINANCE,
9499 GL_FLOAT, 0, 0); 9349 GL_FLOAT, 0, 0);
9500 DoTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, 16, 17, 0, GL_ALPHA, GL_FLOAT, 9350 DoTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, 16, 17, 0, GL_ALPHA, GL_FLOAT,
9501 0, 0); 9351 0, 0);
9502 DoTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE_ALPHA, 16, 17, 0, 9352 DoTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE_ALPHA, 16, 17, 0,
9503 GL_LUMINANCE_ALPHA, GL_FLOAT, 0, 0); 9353 GL_LUMINANCE_ALPHA, GL_FLOAT, 0, 0);
9504 } 9354 }
9505 9355
9506 TEST_P(GLES2DecoderManualInitTest, TexSubImage2DFloatOnGLES3) { 9356 TEST_F(GLES2DecoderManualInitTest, TexSubImage2DFloatOnGLES3) {
9507 InitState init; 9357 InitState init;
9508 init.extensions = "GL_OES_texture_float GL_EXT_color_buffer_float"; 9358 init.extensions = "GL_OES_texture_float GL_EXT_color_buffer_float";
9509 init.gl_version = "opengl es 3.0"; 9359 init.gl_version = "opengl es 3.0";
9510 InitDecoder(init); 9360 InitDecoder(init);
9511 const int kWidth = 8; 9361 const int kWidth = 8;
9512 const int kHeight = 4; 9362 const int kHeight = 4;
9513 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); 9363 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId);
9514 DoTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F, kWidth, kHeight, 0, GL_RGBA, 9364 DoTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F, kWidth, kHeight, 0, GL_RGBA,
9515 GL_FLOAT, 0, 0); 9365 GL_FLOAT, 0, 0);
9516 EXPECT_CALL(*gl_, TexImage2D( 9366 EXPECT_CALL(*gl_, TexImage2D(
9517 GL_TEXTURE_2D, 0, GL_RGBA32F, kWidth, kHeight, 0, GL_RGBA, GL_FLOAT, 9367 GL_TEXTURE_2D, 0, GL_RGBA32F, kWidth, kHeight, 0, GL_RGBA, GL_FLOAT,
9518 shared_memory_address_)) 9368 shared_memory_address_))
9519 .Times(1) 9369 .Times(1)
9520 .RetiresOnSaturation(); 9370 .RetiresOnSaturation();
9521 TexSubImage2D cmd; 9371 TexSubImage2D cmd;
9522 cmd.Init( 9372 cmd.Init(
9523 GL_TEXTURE_2D, 0, 0, 0, kWidth, kHeight, GL_RGBA, GL_FLOAT, 9373 GL_TEXTURE_2D, 0, 0, 0, kWidth, kHeight, GL_RGBA, GL_FLOAT,
9524 kSharedMemoryId, kSharedMemoryOffset, GL_FALSE); 9374 kSharedMemoryId, kSharedMemoryOffset, GL_FALSE);
9525 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 9375 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
9526 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 9376 EXPECT_EQ(GL_NO_ERROR, GetGLError());
9527 } 9377 }
9528 9378
9529 TEST_P(GLES2DecoderManualInitTest, TexSubImage2DFloatDoesClearOnGLES3) { 9379 TEST_F(GLES2DecoderManualInitTest, TexSubImage2DFloatDoesClearOnGLES3) {
9530 InitState init; 9380 InitState init;
9531 init.extensions = "GL_OES_texture_float GL_EXT_color_buffer_float"; 9381 init.extensions = "GL_OES_texture_float GL_EXT_color_buffer_float";
9532 init.gl_version = "opengl es 3.0"; 9382 init.gl_version = "opengl es 3.0";
9533 InitDecoder(init); 9383 InitDecoder(init);
9534 const int kWidth = 8; 9384 const int kWidth = 8;
9535 const int kHeight = 4; 9385 const int kHeight = 4;
9536 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); 9386 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId);
9537 DoTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F, kWidth, kHeight, 0, GL_RGBA, 9387 DoTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F, kWidth, kHeight, 0, GL_RGBA,
9538 GL_FLOAT, 0, 0); 9388 GL_FLOAT, 0, 0);
9539 SetupClearTextureExpectations( 9389 SetupClearTextureExpectations(
9540 kServiceTextureId, kServiceTextureId, GL_TEXTURE_2D, GL_TEXTURE_2D, 9390 kServiceTextureId, kServiceTextureId, GL_TEXTURE_2D, GL_TEXTURE_2D,
9541 0, GL_RGBA32F, GL_RGBA, GL_FLOAT, kWidth, kHeight); 9391 0, GL_RGBA32F, GL_RGBA, GL_FLOAT, kWidth, kHeight);
9542 EXPECT_CALL(*gl_, TexSubImage2D( 9392 EXPECT_CALL(*gl_, TexSubImage2D(
9543 GL_TEXTURE_2D, 0, 1, 0, kWidth - 1, kHeight, GL_RGBA, GL_FLOAT, 9393 GL_TEXTURE_2D, 0, 1, 0, kWidth - 1, kHeight, GL_RGBA, GL_FLOAT,
9544 shared_memory_address_)) 9394 shared_memory_address_))
9545 .Times(1) 9395 .Times(1)
9546 .RetiresOnSaturation(); 9396 .RetiresOnSaturation();
9547 TexSubImage2D cmd; 9397 TexSubImage2D cmd;
9548 cmd.Init( 9398 cmd.Init(
9549 GL_TEXTURE_2D, 0, 1, 0, kWidth - 1, kHeight, GL_RGBA, GL_FLOAT, 9399 GL_TEXTURE_2D, 0, 1, 0, kWidth - 1, kHeight, GL_RGBA, GL_FLOAT,
9550 kSharedMemoryId, kSharedMemoryOffset, GL_FALSE); 9400 kSharedMemoryId, kSharedMemoryOffset, GL_FALSE);
9551 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 9401 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
9552 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 9402 EXPECT_EQ(GL_NO_ERROR, GetGLError());
9553 } 9403 }
9554 9404
9555 TEST_P(GLES2DecoderManualInitTest, TexImage2DFloatConvertsFormatDesktop) { 9405 TEST_F(GLES2DecoderManualInitTest, TexImage2DFloatConvertsFormatDesktop) {
9556 InitState init; 9406 InitState init;
9557 init.extensions = "GL_ARB_texture_float"; 9407 init.extensions = "GL_ARB_texture_float";
9558 init.gl_version = "2.1"; 9408 init.gl_version = "2.1";
9559 InitDecoder(init); 9409 InitDecoder(init);
9560 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); 9410 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId);
9561 DoTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F, 16, 17, 0, GL_RGBA, GL_FLOAT, 0, 9411 DoTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F, 16, 17, 0, GL_RGBA, GL_FLOAT, 0,
9562 0); 9412 0);
9563 DoTexImage2D(GL_TEXTURE_2D, 0, GL_RGB32F, 16, 17, 0, GL_RGB, GL_FLOAT, 0, 0); 9413 DoTexImage2D(GL_TEXTURE_2D, 0, GL_RGB32F, 16, 17, 0, GL_RGB, GL_FLOAT, 0, 0);
9564 DoTexImage2DConvertInternalFormat(GL_TEXTURE_2D, 0, GL_RGBA, 16, 17, 0, 9414 DoTexImage2DConvertInternalFormat(GL_TEXTURE_2D, 0, GL_RGBA, 16, 17, 0,
9565 GL_RGBA, GL_FLOAT, 0, 0, GL_RGBA32F_ARB); 9415 GL_RGBA, GL_FLOAT, 0, 0, GL_RGBA32F_ARB);
9566 DoTexImage2DConvertInternalFormat(GL_TEXTURE_2D, 0, GL_RGB, 16, 17, 0, 9416 DoTexImage2DConvertInternalFormat(GL_TEXTURE_2D, 0, GL_RGB, 16, 17, 0,
9567 GL_RGB, GL_FLOAT, 0, 0, GL_RGB32F_ARB); 9417 GL_RGB, GL_FLOAT, 0, 0, GL_RGB32F_ARB);
9568 DoTexImage2DConvertInternalFormat(GL_TEXTURE_2D, 0, GL_LUMINANCE, 16, 17, 0, 9418 DoTexImage2DConvertInternalFormat(GL_TEXTURE_2D, 0, GL_LUMINANCE, 16, 17, 0,
9569 GL_LUMINANCE, GL_FLOAT, 0, 0, 9419 GL_LUMINANCE, GL_FLOAT, 0, 0,
9570 GL_LUMINANCE32F_ARB); 9420 GL_LUMINANCE32F_ARB);
9571 DoTexImage2DConvertInternalFormat(GL_TEXTURE_2D, 0, GL_ALPHA, 16, 17, 0, 9421 DoTexImage2DConvertInternalFormat(GL_TEXTURE_2D, 0, GL_ALPHA, 16, 17, 0,
9572 GL_ALPHA, GL_FLOAT, 0, 0, GL_ALPHA32F_ARB); 9422 GL_ALPHA, GL_FLOAT, 0, 0, GL_ALPHA32F_ARB);
9573 DoTexImage2DConvertInternalFormat(GL_TEXTURE_2D, 0, GL_LUMINANCE_ALPHA, 16, 9423 DoTexImage2DConvertInternalFormat(GL_TEXTURE_2D, 0, GL_LUMINANCE_ALPHA, 16,
9574 17, 0, GL_LUMINANCE_ALPHA, GL_FLOAT, 0, 0, 9424 17, 0, GL_LUMINANCE_ALPHA, GL_FLOAT, 0, 0,
9575 GL_LUMINANCE_ALPHA32F_ARB); 9425 GL_LUMINANCE_ALPHA32F_ARB);
9576 } 9426 }
9577 9427
9578 TEST_P(GLES2DecoderManualInitTest, ReadFormatExtension) { 9428 TEST_F(GLES2DecoderManualInitTest, ReadFormatExtension) {
9579 InitState init; 9429 InitState init;
9580 init.extensions = "GL_OES_read_format"; 9430 init.extensions = "GL_OES_read_format";
9581 init.gl_version = "2.1"; 9431 init.gl_version = "2.1";
9582 init.bind_generates_resource = true; 9432 init.bind_generates_resource = true;
9583 InitDecoder(init); 9433 InitDecoder(init);
9584 9434
9585 EXPECT_CALL(*gl_, GetError()) 9435 EXPECT_CALL(*gl_, GetError())
9586 .WillOnce(Return(GL_NO_ERROR)) 9436 .WillOnce(Return(GL_NO_ERROR))
9587 .WillOnce(Return(GL_NO_ERROR)) 9437 .WillOnce(Return(GL_NO_ERROR))
9588 .WillOnce(Return(GL_NO_ERROR)) 9438 .WillOnce(Return(GL_NO_ERROR))
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
9630 .Times(1) 9480 .Times(1)
9631 .RetiresOnSaturation(); 9481 .RetiresOnSaturation();
9632 cmd.Init( 9482 cmd.Init(
9633 GL_IMPLEMENTATION_COLOR_READ_TYPE, 9483 GL_IMPLEMENTATION_COLOR_READ_TYPE,
9634 shared_memory_id_, shared_memory_offset_); 9484 shared_memory_id_, shared_memory_offset_);
9635 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 9485 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
9636 EXPECT_EQ(1, result->GetNumResults()); 9486 EXPECT_EQ(1, result->GetNumResults());
9637 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 9487 EXPECT_EQ(GL_NO_ERROR, GetGLError());
9638 } 9488 }
9639 9489
9640 TEST_P(GLES2DecoderManualInitTest, NoReadFormatExtension) { 9490 TEST_F(GLES2DecoderManualInitTest, NoReadFormatExtension) {
9641 InitState init; 9491 InitState init;
9642 init.gl_version = "2.1"; 9492 init.gl_version = "2.1";
9643 init.bind_generates_resource = true; 9493 init.bind_generates_resource = true;
9644 InitDecoder(init); 9494 InitDecoder(init);
9645 9495
9646 EXPECT_CALL(*gl_, GetError()) 9496 EXPECT_CALL(*gl_, GetError())
9647 .WillOnce(Return(GL_NO_ERROR)) 9497 .WillOnce(Return(GL_NO_ERROR))
9648 .WillOnce(Return(GL_NO_ERROR)) 9498 .WillOnce(Return(GL_NO_ERROR))
9649 .WillOnce(Return(GL_NO_ERROR)) 9499 .WillOnce(Return(GL_NO_ERROR))
9650 .WillOnce(Return(GL_NO_ERROR)) 9500 .WillOnce(Return(GL_NO_ERROR))
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
9688 .Times(0) 9538 .Times(0)
9689 .RetiresOnSaturation(); 9539 .RetiresOnSaturation();
9690 cmd.Init( 9540 cmd.Init(
9691 GL_IMPLEMENTATION_COLOR_READ_TYPE, 9541 GL_IMPLEMENTATION_COLOR_READ_TYPE,
9692 shared_memory_id_, shared_memory_offset_); 9542 shared_memory_id_, shared_memory_offset_);
9693 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 9543 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
9694 EXPECT_EQ(1, result->GetNumResults()); 9544 EXPECT_EQ(1, result->GetNumResults());
9695 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 9545 EXPECT_EQ(GL_NO_ERROR, GetGLError());
9696 } 9546 }
9697 9547
9698 TEST_P(GLES2DecoderManualInitTest, ContextStateCapabilityCaching) {
9699 struct TestInfo {
9700 GLenum gl_enum;
9701 bool default_state;
9702 bool expect_set;
9703 };
9704
9705 // TODO(vmiura): Should autogen this to match build_gles2_cmd_buffer.py.
9706 TestInfo test[] = {{GL_BLEND, false, true},
9707 {GL_CULL_FACE, false, true},
9708 {GL_DEPTH_TEST, false, false},
9709 {GL_DITHER, true, true},
9710 {GL_POLYGON_OFFSET_FILL, false, true},
9711 {GL_SAMPLE_ALPHA_TO_COVERAGE, false, true},
9712 {GL_SAMPLE_COVERAGE, false, true},
9713 {GL_SCISSOR_TEST, false, true},
9714 {GL_STENCIL_TEST, false, false},
9715 {0, false, false}};
9716
9717 InitState init;
9718 init.gl_version = "2.1";
9719 InitDecoder(init);
9720
9721 for (int i = 0; test[i].gl_enum; i++) {
9722 bool enable_state = test[i].default_state;
9723
9724 // Test setting default state initially is ignored.
9725 EnableDisableTest(test[i].gl_enum, enable_state, test[i].expect_set);
9726
9727 // Test new and cached state changes.
9728 for (int n = 0; n < 3; n++) {
9729 enable_state = !enable_state;
9730 EnableDisableTest(test[i].gl_enum, enable_state, test[i].expect_set);
9731 EnableDisableTest(test[i].gl_enum, enable_state, test[i].expect_set);
9732 }
9733 }
9734 }
9735
9736 // TODO(gman): Complete this test. 9548 // TODO(gman): Complete this test.
9737 // TEST_P(GLES2DecoderTest, CompressedTexImage2DGLError) { 9549 // TEST_F(GLES2DecoderTest, CompressedTexImage2DGLError) {
9738 // } 9550 // }
9739 9551
9740 // TODO(gman): BufferData 9552 // TODO(gman): BufferData
9741 9553
9742 // TODO(gman): BufferDataImmediate 9554 // TODO(gman): BufferDataImmediate
9743 9555
9744 // TODO(gman): BufferSubData 9556 // TODO(gman): BufferSubData
9745 9557
9746 // TODO(gman): BufferSubDataImmediate 9558 // TODO(gman): BufferSubDataImmediate
9747 9559
(...skipping 12 matching lines...) Expand all
9760 // TODO(gman): TexImage2D 9572 // TODO(gman): TexImage2D
9761 9573
9762 // TODO(gman): TexImage2DImmediate 9574 // TODO(gman): TexImage2DImmediate
9763 9575
9764 // TODO(gman): TexSubImage2DImmediate 9576 // TODO(gman): TexSubImage2DImmediate
9765 9577
9766 // TODO(gman): UseProgram 9578 // TODO(gman): UseProgram
9767 9579
9768 // TODO(gman): SwapBuffers 9580 // TODO(gman): SwapBuffers
9769 9581
9770 INSTANTIATE_TEST_CASE_P(Service, GLES2DecoderTest, ::testing::Bool());
9771
9772 INSTANTIATE_TEST_CASE_P(Service,
9773 GLES2DecoderGeometryInstancingTest,
9774 ::testing::Bool());
9775
9776 INSTANTIATE_TEST_CASE_P(Service, GLES2DecoderWithShaderTest, ::testing::Bool());
9777
9778 INSTANTIATE_TEST_CASE_P(Service, GLES2DecoderManualInitTest, ::testing::Bool());
9779
9780 INSTANTIATE_TEST_CASE_P(Service,
9781 GLES2DecoderCompressedFormatsTest,
9782 ::testing::Bool());
9783
9784 INSTANTIATE_TEST_CASE_P(Service,
9785 GLES2DecoderRGBBackbufferTest,
9786 ::testing::Bool());
9787
9788 INSTANTIATE_TEST_CASE_P(Service,
9789 GLES2DecoderVertexArraysOESTest,
9790 ::testing::Bool());
9791
9792 INSTANTIATE_TEST_CASE_P(Service,
9793 GLES2DecoderEmulatedVertexArraysOESTest,
9794 ::testing::Bool());
9795
9796 INSTANTIATE_TEST_CASE_P(Service,
9797 GLES2DecoderRestoreStateTest,
9798 ::testing::Bool());
9799
9800 INSTANTIATE_TEST_CASE_P(Service,
9801 GLES2DecoderMultisampledRenderToTextureTest,
9802 ::testing::Bool());
9803
9804 } // namespace gles2 9582 } // namespace gles2
9805 } // namespace gpu 9583 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/gles2_cmd_decoder_mock.h ('k') | gpu/command_buffer/service/gles2_cmd_decoder_unittest_1.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698