Chromium Code Reviews| OLD | NEW |
|---|---|
| 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> |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 109 uint8 copied_pixels[1 * 4]; | 109 uint8 copied_pixels[1 * 4]; |
| 110 glReadPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, copied_pixels); | 110 glReadPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, copied_pixels); |
| 111 EXPECT_EQ(1u, copied_pixels[0]); | 111 EXPECT_EQ(1u, copied_pixels[0]); |
| 112 EXPECT_EQ(1u, copied_pixels[1]); | 112 EXPECT_EQ(1u, copied_pixels[1]); |
| 113 EXPECT_EQ(1u, copied_pixels[2]); | 113 EXPECT_EQ(1u, copied_pixels[2]); |
| 114 EXPECT_EQ(128u, copied_pixels[3]); | 114 EXPECT_EQ(128u, copied_pixels[3]); |
| 115 | 115 |
| 116 EXPECT_TRUE(GL_NO_ERROR == glGetError()); | 116 EXPECT_TRUE(GL_NO_ERROR == glGetError()); |
| 117 } | 117 } |
| 118 | 118 |
| 119 // Test that the extension respects the GL_UNPACK_UNPREMULTIPLY_ALPHA_CHROMIUM | |
| 120 // storage setting. | |
| 121 TEST_F(GLCopyTextureCHROMIUMTest, UnpremultiplyAlpha) { | |
|
apatrick_chromium
2012/06/14 21:06:29
How about the unpremultiply flip y variant as well
Jeff Timanus
2012/06/14 22:54:14
Done.
| |
| 122 uint8 pixels[1 * 4] = { 16, 16, 16, 128 }; | |
| 123 | |
| 124 glBindTexture(GL_TEXTURE_2D, textures_[0]); | |
| 125 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, | |
| 126 pixels); | |
| 127 | |
| 128 glPixelStorei(GL_UNPACK_UNPREMULTIPLY_ALPHA_CHROMIUM, GL_TRUE); | |
| 129 glCopyTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 0, GL_RGBA); | |
| 130 EXPECT_TRUE(GL_NO_ERROR == glGetError()); | |
| 131 | |
| 132 uint8 copied_pixels[1 * 4]; | |
| 133 glReadPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, copied_pixels); | |
| 134 EXPECT_EQ(32u, copied_pixels[0]); | |
| 135 EXPECT_EQ(32u, copied_pixels[1]); | |
| 136 EXPECT_EQ(32u, copied_pixels[2]); | |
| 137 EXPECT_EQ(128u, copied_pixels[3]); | |
| 138 | |
| 139 EXPECT_TRUE(GL_NO_ERROR == glGetError()); | |
| 140 } | |
| 141 | |
| 119 TEST_F(GLCopyTextureCHROMIUMTest, FlipYAndPremultiplyAlpha) { | 142 TEST_F(GLCopyTextureCHROMIUMTest, FlipYAndPremultiplyAlpha) { |
| 120 uint8 pixels[2][2][4]; | 143 uint8 pixels[2][2][4]; |
| 121 for (int x = 0; x < 2; ++x) { | 144 for (int x = 0; x < 2; ++x) { |
| 122 for (int y = 0; y < 2; ++y) { | 145 for (int y = 0; y < 2; ++y) { |
| 123 uint8 color = 16 * x + 16 * y; | 146 uint8 color = 16 * x + 16 * y; |
| 124 pixels[y][x][0] = color; | 147 pixels[y][x][0] = color; |
| 125 pixels[y][x][1] = color; | 148 pixels[y][x][1] = color; |
| 126 pixels[y][x][2] = color; | 149 pixels[y][x][2] = color; |
| 127 pixels[y][x][3] = 128u; | 150 pixels[y][x][3] = 128u; |
| 128 } | 151 } |
| (...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 402 EXPECT_TRUE(GLTestHelper::CheckPixels(0, 0, 1, 1, 0, expected)); | 425 EXPECT_TRUE(GLTestHelper::CheckPixels(0, 0, 1, 1, 0, expected)); |
| 403 | 426 |
| 404 EXPECT_TRUE(GL_NO_ERROR == glGetError()); | 427 EXPECT_TRUE(GL_NO_ERROR == glGetError()); |
| 405 | 428 |
| 406 gl2.MakeCurrent(); | 429 gl2.MakeCurrent(); |
| 407 gl2.Destroy(); | 430 gl2.Destroy(); |
| 408 gl_.MakeCurrent(); | 431 gl_.MakeCurrent(); |
| 409 } | 432 } |
| 410 | 433 |
| 411 } // namespace gpu | 434 } // namespace gpu |
| OLD | NEW |