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

Side by Side Diff: gpu/command_buffer/tests/gl_copy_texture_CHROMIUM_unittest.cc

Issue 1542513002: Switch to standard integer types in gpu/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix Created 5 years 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 #ifndef GL_GLEXT_PROTOTYPES 5 #ifndef GL_GLEXT_PROTOTYPES
6 #define GL_GLEXT_PROTOTYPES 6 #define GL_GLEXT_PROTOTYPES
7 #endif 7 #endif
8 8
9 #include <GLES2/gl2.h> 9 #include <GLES2/gl2.h>
10 #include <GLES2/gl2ext.h> 10 #include <GLES2/gl2ext.h>
11 #include <GLES2/gl2extchromium.h> 11 #include <GLES2/gl2extchromium.h>
12 #include <stddef.h>
13 #include <stdint.h>
12 14
13 #include "gpu/command_buffer/tests/gl_manager.h" 15 #include "gpu/command_buffer/tests/gl_manager.h"
14 #include "gpu/command_buffer/tests/gl_test_utils.h" 16 #include "gpu/command_buffer/tests/gl_test_utils.h"
15 #include "testing/gmock/include/gmock/gmock.h" 17 #include "testing/gmock/include/gmock/gmock.h"
16 #include "testing/gtest/include/gtest/gtest.h" 18 #include "testing/gtest/include/gtest/gtest.h"
17 19
18 namespace gpu { 20 namespace gpu {
19 21
20 namespace { 22 namespace {
21 enum CopyType { TexImage, TexSubImage }; 23 enum CopyType { TexImage, TexSubImage };
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 GLuint framebuffer_id_; 62 GLuint framebuffer_id_;
61 }; 63 };
62 64
63 INSTANTIATE_TEST_CASE_P(CopyType, 65 INSTANTIATE_TEST_CASE_P(CopyType,
64 GLCopyTextureCHROMIUMTest, 66 GLCopyTextureCHROMIUMTest,
65 ::testing::ValuesIn(kCopyTypes)); 67 ::testing::ValuesIn(kCopyTypes));
66 68
67 // Test to ensure that the basic functionality of the extension works. 69 // Test to ensure that the basic functionality of the extension works.
68 TEST_P(GLCopyTextureCHROMIUMTest, Basic) { 70 TEST_P(GLCopyTextureCHROMIUMTest, Basic) {
69 CopyType copy_type = GetParam(); 71 CopyType copy_type = GetParam();
70 uint8 pixels[1 * 4] = { 255u, 0u, 0u, 255u }; 72 uint8_t pixels[1 * 4] = {255u, 0u, 0u, 255u};
71 73
72 glBindTexture(GL_TEXTURE_2D, textures_[0]); 74 glBindTexture(GL_TEXTURE_2D, textures_[0]);
73 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 75 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE,
74 pixels); 76 pixels);
75 77
76 if (copy_type == TexImage) { 78 if (copy_type == TexImage) {
77 glCopyTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], GL_RGBA, 79 glCopyTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], GL_RGBA,
78 GL_UNSIGNED_BYTE, false, false, false); 80 GL_UNSIGNED_BYTE, false, false, false);
79 } else { 81 } else {
80 glBindTexture(GL_TEXTURE_2D, textures_[1]); 82 glBindTexture(GL_TEXTURE_2D, textures_[1]);
(...skipping 19 matching lines...) Expand all
100 EXPECT_TRUE(GL_NO_ERROR == glGetError()); 102 EXPECT_TRUE(GL_NO_ERROR == glGetError());
101 } 103 }
102 104
103 TEST_P(GLCopyTextureCHROMIUMTest, ImmutableTexture) { 105 TEST_P(GLCopyTextureCHROMIUMTest, ImmutableTexture) {
104 if (!GLTestHelper::HasExtension("GL_EXT_texture_storage")) { 106 if (!GLTestHelper::HasExtension("GL_EXT_texture_storage")) {
105 LOG(INFO) << "GL_EXT_texture_storage not supported. Skipping test..."; 107 LOG(INFO) << "GL_EXT_texture_storage not supported. Skipping test...";
106 return; 108 return;
107 } 109 }
108 CopyType copy_type = GetParam(); 110 CopyType copy_type = GetParam();
109 111
110 uint8 pixels[1 * 4] = {255u, 0u, 0u, 255u}; 112 uint8_t pixels[1 * 4] = {255u, 0u, 0u, 255u};
111 113
112 glBindTexture(GL_TEXTURE_2D, textures_[0]); 114 glBindTexture(GL_TEXTURE_2D, textures_[0]);
113 glTexStorage2DEXT(GL_TEXTURE_2D, 1, GL_RGBA8_OES, 1, 1); 115 glTexStorage2DEXT(GL_TEXTURE_2D, 1, GL_RGBA8_OES, 1, 1);
114 glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, 116 glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE,
115 pixels); 117 pixels);
116 118
117 glBindTexture(GL_TEXTURE_2D, textures_[1]); 119 glBindTexture(GL_TEXTURE_2D, textures_[1]);
118 glTexStorage2DEXT(GL_TEXTURE_2D, 1, GL_RGBA8_OES, 1, 1); 120 glTexStorage2DEXT(GL_TEXTURE_2D, 1, GL_RGBA8_OES, 1, 1);
119 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 121 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
120 textures_[1], 0); 122 textures_[1], 0);
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 0, 0, 1, 1, false, false, false); 205 0, 0, 1, 1, false, false, false);
204 } 206 }
205 EXPECT_TRUE(GL_INVALID_OPERATION == glGetError()) 207 EXPECT_TRUE(GL_INVALID_OPERATION == glGetError())
206 << "dest_index:" << dest_index; 208 << "dest_index:" << dest_index;
207 } 209 }
208 } 210 }
209 211
210 // Test to ensure that the destination texture is redefined if the properties 212 // Test to ensure that the destination texture is redefined if the properties
211 // are different. 213 // are different.
212 TEST_F(GLCopyTextureCHROMIUMTest, RedefineDestinationTexture) { 214 TEST_F(GLCopyTextureCHROMIUMTest, RedefineDestinationTexture) {
213 uint8 pixels[4 * 4] = {255u, 0u, 0u, 255u, 255u, 0u, 0u, 255u, 215 uint8_t pixels[4 * 4] = {255u, 0u, 0u, 255u, 255u, 0u, 0u, 255u,
214 255u, 0u, 0u, 255u, 255u, 0u, 0u, 255u}; 216 255u, 0u, 0u, 255u, 255u, 0u, 0u, 255u};
215 217
216 glBindTexture(GL_TEXTURE_2D, textures_[0]); 218 glBindTexture(GL_TEXTURE_2D, textures_[0]);
217 glTexImage2D( 219 glTexImage2D(
218 GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels); 220 GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
219 221
220 glBindTexture(GL_TEXTURE_2D, textures_[1]); 222 glBindTexture(GL_TEXTURE_2D, textures_[1]);
221 glTexImage2D(GL_TEXTURE_2D, 223 glTexImage2D(GL_TEXTURE_2D,
222 0, 224 0,
223 GL_BGRA_EXT, 225 GL_BGRA_EXT,
224 1, 226 1,
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 else 275 else
274 glDisable(param); 276 glDisable(param);
275 } 277 }
276 278
277 } // unnamed namespace 279 } // unnamed namespace
278 280
279 // Validate that some basic GL state is not touched upon execution of 281 // Validate that some basic GL state is not touched upon execution of
280 // the extension. 282 // the extension.
281 TEST_P(GLCopyTextureCHROMIUMTest, BasicStatePreservation) { 283 TEST_P(GLCopyTextureCHROMIUMTest, BasicStatePreservation) {
282 CopyType copy_type = GetParam(); 284 CopyType copy_type = GetParam();
283 uint8 pixels[1 * 4] = { 255u, 0u, 0u, 255u }; 285 uint8_t pixels[1 * 4] = {255u, 0u, 0u, 255u};
284 286
285 glBindFramebuffer(GL_FRAMEBUFFER, 0); 287 glBindFramebuffer(GL_FRAMEBUFFER, 0);
286 288
287 glBindTexture(GL_TEXTURE_2D, textures_[0]); 289 glBindTexture(GL_TEXTURE_2D, textures_[0]);
288 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 290 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE,
289 pixels); 291 pixels);
290 292
291 if (copy_type == TexSubImage) { 293 if (copy_type == TexSubImage) {
292 glBindTexture(GL_TEXTURE_2D, textures_[1]); 294 glBindTexture(GL_TEXTURE_2D, textures_[1]);
293 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 295 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE,
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 } 341 }
340 342
341 EXPECT_TRUE(GL_NO_ERROR == glGetError()); 343 EXPECT_TRUE(GL_NO_ERROR == glGetError());
342 }; 344 };
343 345
344 // Verify that invocation of the extension does not modify the bound 346 // Verify that invocation of the extension does not modify the bound
345 // texture state. 347 // texture state.
346 TEST_P(GLCopyTextureCHROMIUMTest, TextureStatePreserved) { 348 TEST_P(GLCopyTextureCHROMIUMTest, TextureStatePreserved) {
347 CopyType copy_type = GetParam(); 349 CopyType copy_type = GetParam();
348 // Setup the texture used for the extension invocation. 350 // Setup the texture used for the extension invocation.
349 uint8 pixels[1 * 4] = { 255u, 0u, 0u, 255u }; 351 uint8_t pixels[1 * 4] = {255u, 0u, 0u, 255u};
350 glBindTexture(GL_TEXTURE_2D, textures_[0]); 352 glBindTexture(GL_TEXTURE_2D, textures_[0]);
351 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 353 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE,
352 pixels); 354 pixels);
353 355
354 if (copy_type == TexSubImage) { 356 if (copy_type == TexSubImage) {
355 glBindTexture(GL_TEXTURE_2D, textures_[1]); 357 glBindTexture(GL_TEXTURE_2D, textures_[1]);
356 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 358 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE,
357 nullptr); 359 nullptr);
358 } 360 }
359 361
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 glDeleteTextures(2, texture_ids); 395 glDeleteTextures(2, texture_ids);
394 396
395 EXPECT_TRUE(GL_NO_ERROR == glGetError()); 397 EXPECT_TRUE(GL_NO_ERROR == glGetError());
396 } 398 }
397 399
398 // Verify that invocation of the extension does not perturb the currently 400 // Verify that invocation of the extension does not perturb the currently
399 // bound FBO state. 401 // bound FBO state.
400 TEST_P(GLCopyTextureCHROMIUMTest, FBOStatePreserved) { 402 TEST_P(GLCopyTextureCHROMIUMTest, FBOStatePreserved) {
401 CopyType copy_type = GetParam(); 403 CopyType copy_type = GetParam();
402 // Setup the texture used for the extension invocation. 404 // Setup the texture used for the extension invocation.
403 uint8 pixels[1 * 4] = { 255u, 0u, 0u, 255u }; 405 uint8_t pixels[1 * 4] = {255u, 0u, 0u, 255u};
404 glBindTexture(GL_TEXTURE_2D, textures_[0]); 406 glBindTexture(GL_TEXTURE_2D, textures_[0]);
405 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 407 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE,
406 pixels); 408 pixels);
407 409
408 if (copy_type == TexSubImage) { 410 if (copy_type == TexSubImage) {
409 glBindTexture(GL_TEXTURE_2D, textures_[1]); 411 glBindTexture(GL_TEXTURE_2D, textures_[1]);
410 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 412 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE,
411 nullptr); 413 nullptr);
412 } 414 }
413 415
(...skipping 12 matching lines...) Expand all
426 glGenFramebuffers(1, &framebuffer_id); 428 glGenFramebuffers(1, &framebuffer_id);
427 glBindFramebuffer(GL_FRAMEBUFFER, framebuffer_id); 429 glBindFramebuffer(GL_FRAMEBUFFER, framebuffer_id);
428 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 430 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
429 texture_id, 0); 431 texture_id, 0);
430 glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, 432 glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT,
431 GL_RENDERBUFFER, renderbuffer_id); 433 GL_RENDERBUFFER, renderbuffer_id);
432 EXPECT_TRUE( 434 EXPECT_TRUE(
433 GL_FRAMEBUFFER_COMPLETE == glCheckFramebufferStatus(GL_FRAMEBUFFER)); 435 GL_FRAMEBUFFER_COMPLETE == glCheckFramebufferStatus(GL_FRAMEBUFFER));
434 436
435 // Test that we can write to the bound framebuffer 437 // Test that we can write to the bound framebuffer
436 uint8 expected_color[4] = { 255u, 255u, 0, 255u }; 438 uint8_t expected_color[4] = {255u, 255u, 0, 255u};
437 glClearColor(1.0, 1.0, 0, 1.0); 439 glClearColor(1.0, 1.0, 0, 1.0);
438 glClear(GL_COLOR_BUFFER_BIT); 440 glClear(GL_COLOR_BUFFER_BIT);
439 GLTestHelper::CheckPixels(0, 0, 1, 1, 0, expected_color); 441 GLTestHelper::CheckPixels(0, 0, 1, 1, 0, expected_color);
440 442
441 if (copy_type == TexImage) { 443 if (copy_type == TexImage) {
442 glCopyTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], GL_RGBA, 444 glCopyTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], GL_RGBA,
443 GL_UNSIGNED_BYTE, false, false, false); 445 GL_UNSIGNED_BYTE, false, false, false);
444 } else { 446 } else {
445 glCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 0, 0, 0, 447 glCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 0, 0, 0,
446 0, 1, 1, false, false, false); 448 0, 1, 1, false, false, false);
447 } 449 }
448 EXPECT_TRUE(GL_NO_ERROR == glGetError()); 450 EXPECT_TRUE(GL_NO_ERROR == glGetError());
449 451
450 EXPECT_TRUE(glIsFramebuffer(framebuffer_id)); 452 EXPECT_TRUE(glIsFramebuffer(framebuffer_id));
451 453
452 // Ensure that reading from the framebuffer produces correct pixels. 454 // Ensure that reading from the framebuffer produces correct pixels.
453 GLTestHelper::CheckPixels(0, 0, 1, 1, 0, expected_color); 455 GLTestHelper::CheckPixels(0, 0, 1, 1, 0, expected_color);
454 456
455 uint8 expected_color2[4] = { 255u, 0, 255u, 255u }; 457 uint8_t expected_color2[4] = {255u, 0, 255u, 255u};
456 glClearColor(1.0, 0, 1.0, 1.0); 458 glClearColor(1.0, 0, 1.0, 1.0);
457 glClear(GL_COLOR_BUFFER_BIT); 459 glClear(GL_COLOR_BUFFER_BIT);
458 GLTestHelper::CheckPixels(0, 0, 1, 1, 0, expected_color2); 460 GLTestHelper::CheckPixels(0, 0, 1, 1, 0, expected_color2);
459 461
460 GLint bound_fbo = 0; 462 GLint bound_fbo = 0;
461 glGetIntegerv(GL_FRAMEBUFFER_BINDING, &bound_fbo); 463 glGetIntegerv(GL_FRAMEBUFFER_BINDING, &bound_fbo);
462 EXPECT_EQ(framebuffer_id, static_cast<GLuint>(bound_fbo)); 464 EXPECT_EQ(framebuffer_id, static_cast<GLuint>(bound_fbo));
463 465
464 GLint fbo_params = 0; 466 GLint fbo_params = 0;
465 glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, 467 glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
528 glDeleteProgram(program); 530 glDeleteProgram(program);
529 EXPECT_TRUE(GL_NO_ERROR == glGetError()); 531 EXPECT_TRUE(GL_NO_ERROR == glGetError());
530 glFlush(); 532 glFlush();
531 533
532 // Program should still be usable on this context. 534 // Program should still be usable on this context.
533 gl_.MakeCurrent(); 535 gl_.MakeCurrent();
534 536
535 GLTestHelper::SetupUnitQuad(position_loc); 537 GLTestHelper::SetupUnitQuad(position_loc);
536 538
537 // test using program before 539 // test using program before
538 uint8 expected[] = { 0, 255, 0, 255, }; 540 uint8_t expected[] = {
539 uint8 zero[] = { 0, 0, 0, 0, }; 541 0, 255, 0, 255,
542 };
543 uint8_t zero[] = {
544 0, 0, 0, 0,
545 };
540 glClear(GL_COLOR_BUFFER_BIT); 546 glClear(GL_COLOR_BUFFER_BIT);
541 EXPECT_TRUE(GLTestHelper::CheckPixels(0, 0, 1, 1, 0, zero)); 547 EXPECT_TRUE(GLTestHelper::CheckPixels(0, 0, 1, 1, 0, zero));
542 glDrawArrays(GL_TRIANGLES, 0, 6); 548 glDrawArrays(GL_TRIANGLES, 0, 6);
543 EXPECT_TRUE(GLTestHelper::CheckPixels(0, 0, 1, 1, 0, expected)); 549 EXPECT_TRUE(GLTestHelper::CheckPixels(0, 0, 1, 1, 0, expected));
544 550
545 // Call copyTextureCHROMIUM 551 // Call copyTextureCHROMIUM
546 uint8 pixels[1 * 4] = { 255u, 0u, 0u, 255u }; 552 uint8_t pixels[1 * 4] = {255u, 0u, 0u, 255u};
547 glBindTexture(GL_TEXTURE_2D, textures_[0]); 553 glBindTexture(GL_TEXTURE_2D, textures_[0]);
548 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 554 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE,
549 pixels); 555 pixels);
550 if (copy_type == TexImage) { 556 if (copy_type == TexImage) {
551 glCopyTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], GL_RGBA, 557 glCopyTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], GL_RGBA,
552 GL_UNSIGNED_BYTE, false, false, false); 558 GL_UNSIGNED_BYTE, false, false, false);
553 } else { 559 } else {
554 glBindTexture(GL_TEXTURE_2D, textures_[1]); 560 glBindTexture(GL_TEXTURE_2D, textures_[1]);
555 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 561 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE,
556 nullptr); 562 nullptr);
(...skipping 27 matching lines...) Expand all
584 GL_UNSIGNED_BYTE, false, false, false); 590 GL_UNSIGNED_BYTE, false, false, false);
585 } else { 591 } else {
586 glBindTexture(GL_TEXTURE_2D, textures_[1]); 592 glBindTexture(GL_TEXTURE_2D, textures_[1]);
587 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, kWidth, kHeight, 0, GL_RGBA, 593 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, kWidth, kHeight, 0, GL_RGBA,
588 GL_UNSIGNED_BYTE, nullptr); 594 GL_UNSIGNED_BYTE, nullptr);
589 glCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 0, 0, 0, 595 glCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 0, 0, 0,
590 0, kWidth, kHeight, false, false, false); 596 0, kWidth, kHeight, false, false, false);
591 } 597 }
592 EXPECT_TRUE(GL_NO_ERROR == glGetError()); 598 EXPECT_TRUE(GL_NO_ERROR == glGetError());
593 599
594 uint8 pixels[kHeight][kWidth][4] = {{{1}}}; 600 uint8_t pixels[kHeight][kWidth][4] = {{{1}}};
595 glReadPixels(0, 0, kWidth, kHeight, GL_RGBA, GL_UNSIGNED_BYTE, pixels); 601 glReadPixels(0, 0, kWidth, kHeight, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
596 for (int x = 0; x < kWidth; ++x) { 602 for (int x = 0; x < kWidth; ++x) {
597 for (int y = 0; y < kHeight; ++y) { 603 for (int y = 0; y < kHeight; ++y) {
598 EXPECT_EQ(0, pixels[y][x][0]); 604 EXPECT_EQ(0, pixels[y][x][0]);
599 EXPECT_EQ(0, pixels[y][x][1]); 605 EXPECT_EQ(0, pixels[y][x][1]);
600 EXPECT_EQ(0, pixels[y][x][2]); 606 EXPECT_EQ(0, pixels[y][x][2]);
601 EXPECT_EQ(0, pixels[y][x][3]); 607 EXPECT_EQ(0, pixels[y][x][3]);
602 } 608 }
603 } 609 }
604 610
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
685 glCopySubTextureCHROMIUM(GL_TEXTURE_2D, 99995, 99996, 1, 1, 0, 0, 1, 1, false, 691 glCopySubTextureCHROMIUM(GL_TEXTURE_2D, 99995, 99996, 1, 1, 0, 0, 1, 1, false,
686 false, false); 692 false, false);
687 EXPECT_TRUE(GL_INVALID_VALUE == glGetError()); 693 EXPECT_TRUE(GL_INVALID_VALUE == glGetError());
688 694
689 glCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 1, 1, 0, 695 glCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 1, 1, 0,
690 0, 1, 1, false, false, false); 696 0, 1, 1, false, false, false);
691 EXPECT_TRUE(GL_NO_ERROR == glGetError()); 697 EXPECT_TRUE(GL_NO_ERROR == glGetError());
692 } 698 }
693 699
694 TEST_F(GLCopyTextureCHROMIUMTest, CopySubTextureOffset) { 700 TEST_F(GLCopyTextureCHROMIUMTest, CopySubTextureOffset) {
695 uint8 rgba_pixels[4 * 4] = {255u, 701 uint8_t rgba_pixels[4 * 4] = {255u, 0u, 0u, 255u, 0u, 255u, 0u, 255u,
696 0u, 702 0u, 0u, 255u, 255u, 0u, 0u, 0u, 255u};
697 0u,
698 255u,
699 0u,
700 255u,
701 0u,
702 255u,
703 0u,
704 0u,
705 255u,
706 255u,
707 0u,
708 0u,
709 0u,
710 255u};
711 glBindTexture(GL_TEXTURE_2D, textures_[0]); 703 glBindTexture(GL_TEXTURE_2D, textures_[0]);
712 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, 704 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE,
713 rgba_pixels); 705 rgba_pixels);
714 706
715 uint8 transparent_pixels[4 * 4] = { 707 uint8_t transparent_pixels[4 * 4] = {0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
716 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u}; 708 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u};
717 glBindTexture(GL_TEXTURE_2D, textures_[1]); 709 glBindTexture(GL_TEXTURE_2D, textures_[1]);
718 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, 710 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE,
719 transparent_pixels); 711 transparent_pixels);
720 712
721 glCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 1, 1, 0, 713 glCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 1, 1, 0,
722 0, 1, 1, false, false, false); 714 0, 1, 1, false, false, false);
723 EXPECT_TRUE(glGetError() == GL_NO_ERROR); 715 EXPECT_TRUE(glGetError() == GL_NO_ERROR);
724 glCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 1, 0, 1, 716 glCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 1, 0, 1,
725 0, 1, 1, false, false, false); 717 0, 1, 1, false, false, false);
726 EXPECT_TRUE(glGetError() == GL_NO_ERROR); 718 EXPECT_TRUE(glGetError() == GL_NO_ERROR);
727 glCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 0, 1, 0, 719 glCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 0, 1, 0,
728 1, 1, 1, false, false, false); 720 1, 1, 1, false, false, false);
729 EXPECT_TRUE(glGetError() == GL_NO_ERROR); 721 EXPECT_TRUE(glGetError() == GL_NO_ERROR);
730 722
731 // Check the FB is still bound. 723 // Check the FB is still bound.
732 GLint value = 0; 724 GLint value = 0;
733 glGetIntegerv(GL_FRAMEBUFFER_BINDING, &value); 725 glGetIntegerv(GL_FRAMEBUFFER_BINDING, &value);
734 GLuint fb_id = value; 726 GLuint fb_id = value;
735 EXPECT_EQ(framebuffer_id_, fb_id); 727 EXPECT_EQ(framebuffer_id_, fb_id);
736 728
737 // Check that FB is complete. 729 // Check that FB is complete.
738 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE), 730 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE),
739 glCheckFramebufferStatus(GL_FRAMEBUFFER)); 731 glCheckFramebufferStatus(GL_FRAMEBUFFER));
740 732
741 uint8 transparent[1 * 4] = {0u, 0u, 0u, 0u}; 733 uint8_t transparent[1 * 4] = {0u, 0u, 0u, 0u};
742 uint8 red[1 * 4] = {255u, 0u, 0u, 255u}; 734 uint8_t red[1 * 4] = {255u, 0u, 0u, 255u};
743 uint8 green[1 * 4] = {0u, 255u, 0u, 255u}; 735 uint8_t green[1 * 4] = {0u, 255u, 0u, 255u};
744 uint8 blue[1 * 4] = {0u, 0u, 255u, 255u}; 736 uint8_t blue[1 * 4] = {0u, 0u, 255u, 255u};
745 GLTestHelper::CheckPixels(0, 0, 1, 1, 0, transparent); 737 GLTestHelper::CheckPixels(0, 0, 1, 1, 0, transparent);
746 GLTestHelper::CheckPixels(1, 1, 1, 1, 0, red); 738 GLTestHelper::CheckPixels(1, 1, 1, 1, 0, red);
747 GLTestHelper::CheckPixels(1, 0, 1, 1, 0, green); 739 GLTestHelper::CheckPixels(1, 0, 1, 1, 0, green);
748 GLTestHelper::CheckPixels(0, 1, 1, 1, 0, blue); 740 GLTestHelper::CheckPixels(0, 1, 1, 1, 0, blue);
749 EXPECT_TRUE(GL_NO_ERROR == glGetError()); 741 EXPECT_TRUE(GL_NO_ERROR == glGetError());
750 } 742 }
751 743
752 } // namespace gpu 744 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698