| 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) { |
| 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 15 matching lines...) Expand all Loading... |
| 144 EXPECT_EQ(pixels[1-y][x][0] / 2, copied_pixels[y][x][0]); | 167 EXPECT_EQ(pixels[1-y][x][0] / 2, copied_pixels[y][x][0]); |
| 145 EXPECT_EQ(pixels[1-y][x][1] / 2, copied_pixels[y][x][1]); | 168 EXPECT_EQ(pixels[1-y][x][1] / 2, copied_pixels[y][x][1]); |
| 146 EXPECT_EQ(pixels[1-y][x][2] / 2, copied_pixels[y][x][2]); | 169 EXPECT_EQ(pixels[1-y][x][2] / 2, copied_pixels[y][x][2]); |
| 147 EXPECT_EQ(pixels[1-y][x][3], copied_pixels[y][x][3]); | 170 EXPECT_EQ(pixels[1-y][x][3], copied_pixels[y][x][3]); |
| 148 } | 171 } |
| 149 } | 172 } |
| 150 | 173 |
| 151 EXPECT_TRUE(GL_NO_ERROR == glGetError()); | 174 EXPECT_TRUE(GL_NO_ERROR == glGetError()); |
| 152 } | 175 } |
| 153 | 176 |
| 177 TEST_F(GLCopyTextureCHROMIUMTest, FlipYAndUnpremultiplyAlpha) { |
| 178 uint8 pixels[2][2][4]; |
| 179 for (int x = 0; x < 2; ++x) { |
| 180 for (int y = 0; y < 2; ++y) { |
| 181 uint8 color = 16 * x + 16 * y; |
| 182 pixels[y][x][0] = color; |
| 183 pixels[y][x][1] = color; |
| 184 pixels[y][x][2] = color; |
| 185 pixels[y][x][3] = 128u; |
| 186 } |
| 187 } |
| 188 |
| 189 glBindTexture(GL_TEXTURE_2D, textures_[0]); |
| 190 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, |
| 191 pixels); |
| 192 |
| 193 glPixelStorei(GL_UNPACK_FLIP_Y_CHROMIUM, GL_TRUE); |
| 194 glPixelStorei(GL_UNPACK_UNPREMULTIPLY_ALPHA_CHROMIUM, GL_TRUE); |
| 195 glCopyTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 0, GL_RGBA); |
| 196 EXPECT_TRUE(GL_NO_ERROR == glGetError()); |
| 197 |
| 198 uint8 copied_pixels[2][2][4]; |
| 199 glReadPixels(0, 0, 2, 2, GL_RGBA, GL_UNSIGNED_BYTE, copied_pixels); |
| 200 for (int x = 0; x < 2; ++x) { |
| 201 for (int y = 0; y < 2; ++y) { |
| 202 EXPECT_EQ(pixels[1-y][x][0] * 2, copied_pixels[y][x][0]); |
| 203 EXPECT_EQ(pixels[1-y][x][1] * 2, copied_pixels[y][x][1]); |
| 204 EXPECT_EQ(pixels[1-y][x][2] * 2, copied_pixels[y][x][2]); |
| 205 EXPECT_EQ(pixels[1-y][x][3], copied_pixels[y][x][3]); |
| 206 } |
| 207 } |
| 208 |
| 209 EXPECT_TRUE(GL_NO_ERROR == glGetError()); |
| 210 } |
| 211 |
| 154 namespace { | 212 namespace { |
| 155 | 213 |
| 156 void glEnableDisable(GLint param, GLboolean value) { | 214 void glEnableDisable(GLint param, GLboolean value) { |
| 157 if (value) | 215 if (value) |
| 158 glEnable(param); | 216 glEnable(param); |
| 159 else | 217 else |
| 160 glDisable(param); | 218 glDisable(param); |
| 161 } | 219 } |
| 162 | 220 |
| 163 } // unnamed namespace | 221 } // unnamed namespace |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 402 EXPECT_TRUE(GLTestHelper::CheckPixels(0, 0, 1, 1, 0, expected)); | 460 EXPECT_TRUE(GLTestHelper::CheckPixels(0, 0, 1, 1, 0, expected)); |
| 403 | 461 |
| 404 EXPECT_TRUE(GL_NO_ERROR == glGetError()); | 462 EXPECT_TRUE(GL_NO_ERROR == glGetError()); |
| 405 | 463 |
| 406 gl2.MakeCurrent(); | 464 gl2.MakeCurrent(); |
| 407 gl2.Destroy(); | 465 gl2.Destroy(); |
| 408 gl_.MakeCurrent(); | 466 gl_.MakeCurrent(); |
| 409 } | 467 } |
| 410 | 468 |
| 411 } // namespace gpu | 469 } // namespace gpu |
| OLD | NEW |