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

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

Issue 1143373004: gpu: Extend CopyTextureCHROMIUM with support for copying part of source texture. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: keep TODO for now Created 5 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 #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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 pixels); 74 pixels);
75 75
76 if (copy_type == TexImage) { 76 if (copy_type == TexImage) {
77 glCopyTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], GL_RGBA, 77 glCopyTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], GL_RGBA,
78 GL_UNSIGNED_BYTE); 78 GL_UNSIGNED_BYTE);
79 } else { 79 } else {
80 glBindTexture(GL_TEXTURE_2D, textures_[1]); 80 glBindTexture(GL_TEXTURE_2D, textures_[1]);
81 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 81 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE,
82 nullptr); 82 nullptr);
83 83
84 glCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 0, 0); 84 glCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 0, 0, 0,
85 0, 1, 1);
85 } 86 }
86 EXPECT_TRUE(glGetError() == GL_NO_ERROR); 87 EXPECT_TRUE(glGetError() == GL_NO_ERROR);
87 88
88 // Check the FB is still bound. 89 // Check the FB is still bound.
89 GLint value = 0; 90 GLint value = 0;
90 glGetIntegerv(GL_FRAMEBUFFER_BINDING, &value); 91 glGetIntegerv(GL_FRAMEBUFFER_BINDING, &value);
91 GLuint fb_id = value; 92 GLuint fb_id = value;
92 EXPECT_EQ(framebuffer_id_, fb_id); 93 EXPECT_EQ(framebuffer_id_, fb_id);
93 94
94 // Check that FB is complete. 95 // Check that FB is complete.
(...skipping 22 matching lines...) Expand all
117 glTexStorage2DEXT(GL_TEXTURE_2D, 1, GL_RGBA8_OES, 1, 1); 118 glTexStorage2DEXT(GL_TEXTURE_2D, 1, GL_RGBA8_OES, 1, 1);
118 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 119 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
119 textures_[1], 0); 120 textures_[1], 0);
120 EXPECT_TRUE(glGetError() == GL_NO_ERROR); 121 EXPECT_TRUE(glGetError() == GL_NO_ERROR);
121 122
122 if (copy_type == TexImage) { 123 if (copy_type == TexImage) {
123 glCopyTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], GL_RGBA, 124 glCopyTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], GL_RGBA,
124 GL_UNSIGNED_BYTE); 125 GL_UNSIGNED_BYTE);
125 EXPECT_TRUE(glGetError() == GL_INVALID_OPERATION); 126 EXPECT_TRUE(glGetError() == GL_INVALID_OPERATION);
126 } else { 127 } else {
127 glCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 0, 0); 128 glCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 0, 0, 0,
129 0, 1, 1);
128 EXPECT_TRUE(glGetError() == GL_NO_ERROR); 130 EXPECT_TRUE(glGetError() == GL_NO_ERROR);
129 131
130 // Check the FB is still bound. 132 // Check the FB is still bound.
131 GLint value = 0; 133 GLint value = 0;
132 glGetIntegerv(GL_FRAMEBUFFER_BINDING, &value); 134 glGetIntegerv(GL_FRAMEBUFFER_BINDING, &value);
133 GLuint fb_id = value; 135 GLuint fb_id = value;
134 EXPECT_EQ(framebuffer_id_, fb_id); 136 EXPECT_EQ(framebuffer_id_, fb_id);
135 137
136 // Check that FB is complete. 138 // Check that FB is complete.
137 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE), 139 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE),
(...skipping 21 matching lines...) Expand all
159 if (copy_type == TexImage) { 161 if (copy_type == TexImage) {
160 glCopyTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 162 glCopyTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1],
161 dest_formats[dest_index], GL_UNSIGNED_BYTE); 163 dest_formats[dest_index], GL_UNSIGNED_BYTE);
162 } else { 164 } else {
163 glBindTexture(GL_TEXTURE_2D, textures_[1]); 165 glBindTexture(GL_TEXTURE_2D, textures_[1]);
164 glTexImage2D(GL_TEXTURE_2D, 0, dest_formats[dest_index], 1, 1, 0, 166 glTexImage2D(GL_TEXTURE_2D, 0, dest_formats[dest_index], 1, 1, 0,
165 dest_formats[dest_index], GL_UNSIGNED_BYTE, nullptr); 167 dest_formats[dest_index], GL_UNSIGNED_BYTE, nullptr);
166 EXPECT_TRUE(GL_NO_ERROR == glGetError()); 168 EXPECT_TRUE(GL_NO_ERROR == glGetError());
167 169
168 glCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 0, 170 glCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 0,
169 0); 171 0, 0, 0, 1, 1);
170 } 172 }
171 173
172 EXPECT_TRUE(GL_NO_ERROR == glGetError()) << "src_index:" << src_index 174 EXPECT_TRUE(GL_NO_ERROR == glGetError()) << "src_index:" << src_index
173 << " dest_index:" << dest_index; 175 << " dest_index:" << dest_index;
174 } 176 }
175 } 177 }
176 } 178 }
177 179
178 TEST_P(GLCopyTextureCHROMIUMTest, InternalFormatNotSupported) { 180 TEST_P(GLCopyTextureCHROMIUMTest, InternalFormatNotSupported) {
179 CopyType copy_type = GetParam(); 181 CopyType copy_type = GetParam();
180 glBindTexture(GL_TEXTURE_2D, textures_[0]); 182 glBindTexture(GL_TEXTURE_2D, textures_[0]);
181 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 183 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE,
182 nullptr); 184 nullptr);
183 EXPECT_TRUE(GL_NO_ERROR == glGetError()); 185 EXPECT_TRUE(GL_NO_ERROR == glGetError());
184 186
185 // Check unsupported format reports error. 187 // Check unsupported format reports error.
186 GLint unsupported_dest_formats[] = {GL_ALPHA, GL_LUMINANCE, 188 GLint unsupported_dest_formats[] = {GL_ALPHA, GL_LUMINANCE,
187 GL_LUMINANCE_ALPHA}; 189 GL_LUMINANCE_ALPHA};
188 for (size_t dest_index = 0; dest_index < arraysize(unsupported_dest_formats); 190 for (size_t dest_index = 0; dest_index < arraysize(unsupported_dest_formats);
189 dest_index++) { 191 dest_index++) {
190 if (copy_type == TexImage) { 192 if (copy_type == TexImage) {
191 glCopyTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 193 glCopyTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1],
192 unsupported_dest_formats[dest_index], 194 unsupported_dest_formats[dest_index],
193 GL_UNSIGNED_BYTE); 195 GL_UNSIGNED_BYTE);
194 } else { 196 } else {
195 glBindTexture(GL_TEXTURE_2D, textures_[1]); 197 glBindTexture(GL_TEXTURE_2D, textures_[1]);
196 glTexImage2D(GL_TEXTURE_2D, 0, unsupported_dest_formats[dest_index], 1, 1, 198 glTexImage2D(GL_TEXTURE_2D, 0, unsupported_dest_formats[dest_index], 1, 1,
197 0, unsupported_dest_formats[dest_index], GL_UNSIGNED_BYTE, 199 0, unsupported_dest_formats[dest_index], GL_UNSIGNED_BYTE,
198 nullptr); 200 nullptr);
199 glCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 0, 0); 201 glCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 0, 0,
202 0, 0, 1, 1);
200 } 203 }
201 EXPECT_TRUE(GL_INVALID_OPERATION == glGetError()) 204 EXPECT_TRUE(GL_INVALID_OPERATION == glGetError())
202 << "dest_index:" << dest_index; 205 << "dest_index:" << dest_index;
203 } 206 }
204 } 207 }
205 208
206 // Test to ensure that the destination texture is redefined if the properties 209 // Test to ensure that the destination texture is redefined if the properties
207 // are different. 210 // are different.
208 TEST_F(GLCopyTextureCHROMIUMTest, RedefineDestinationTexture) { 211 TEST_F(GLCopyTextureCHROMIUMTest, RedefineDestinationTexture) {
209 uint8 pixels[4 * 4] = {255u, 0u, 0u, 255u, 255u, 0u, 0u, 255u, 212 uint8 pixels[4 * 4] = {255u, 0u, 0u, 255u, 255u, 0u, 0u, 255u,
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 283
281 glPixelStorei(GL_UNPACK_FLIP_Y_CHROMIUM, GL_TRUE); 284 glPixelStorei(GL_UNPACK_FLIP_Y_CHROMIUM, GL_TRUE);
282 285
283 if (copy_type == TexImage) { 286 if (copy_type == TexImage) {
284 glCopyTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], GL_RGBA, 287 glCopyTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], GL_RGBA,
285 GL_UNSIGNED_BYTE); 288 GL_UNSIGNED_BYTE);
286 } else { 289 } else {
287 glBindTexture(GL_TEXTURE_2D, textures_[1]); 290 glBindTexture(GL_TEXTURE_2D, textures_[1]);
288 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, 291 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE,
289 nullptr); 292 nullptr);
290 glCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 0, 0); 293 glCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 0, 0, 0,
294 0, 2, 2);
291 } 295 }
292 EXPECT_TRUE(GL_NO_ERROR == glGetError()); 296 EXPECT_TRUE(GL_NO_ERROR == glGetError());
293 297
294 uint8 copied_pixels[2][2][4] = {{{0}}}; 298 uint8 copied_pixels[2][2][4] = {{{0}}};
295 glReadPixels(0, 0, 2, 2, GL_RGBA, GL_UNSIGNED_BYTE, copied_pixels); 299 glReadPixels(0, 0, 2, 2, GL_RGBA, GL_UNSIGNED_BYTE, copied_pixels);
296 for (int x = 0; x < 2; ++x) { 300 for (int x = 0; x < 2; ++x) {
297 for (int y = 0; y < 2; ++y) { 301 for (int y = 0; y < 2; ++y) {
298 EXPECT_EQ(pixels[1-y][x][0], copied_pixels[y][x][0]); 302 EXPECT_EQ(pixels[1-y][x][0], copied_pixels[y][x][0]);
299 EXPECT_EQ(pixels[1-y][x][1], copied_pixels[y][x][1]); 303 EXPECT_EQ(pixels[1-y][x][1], copied_pixels[y][x][1]);
300 EXPECT_EQ(pixels[1-y][x][2], copied_pixels[y][x][2]); 304 EXPECT_EQ(pixels[1-y][x][2], copied_pixels[y][x][2]);
(...skipping 15 matching lines...) Expand all
316 pixels); 320 pixels);
317 321
318 glPixelStorei(GL_UNPACK_PREMULTIPLY_ALPHA_CHROMIUM, GL_TRUE); 322 glPixelStorei(GL_UNPACK_PREMULTIPLY_ALPHA_CHROMIUM, GL_TRUE);
319 if (copy_type == TexImage) { 323 if (copy_type == TexImage) {
320 glCopyTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], GL_RGBA, 324 glCopyTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], GL_RGBA,
321 GL_UNSIGNED_BYTE); 325 GL_UNSIGNED_BYTE);
322 } else { 326 } else {
323 glBindTexture(GL_TEXTURE_2D, textures_[1]); 327 glBindTexture(GL_TEXTURE_2D, textures_[1]);
324 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 328 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE,
325 nullptr); 329 nullptr);
326 glCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 0, 0); 330 glCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 0, 0, 0,
331 0, 1, 1);
327 } 332 }
328 EXPECT_TRUE(GL_NO_ERROR == glGetError()); 333 EXPECT_TRUE(GL_NO_ERROR == glGetError());
329 334
330 uint8 copied_pixels[1 * 4] = {0}; 335 uint8 copied_pixels[1 * 4] = {0};
331 glReadPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, copied_pixels); 336 glReadPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, copied_pixels);
332 EXPECT_EQ(1u, copied_pixels[0]); 337 EXPECT_EQ(1u, copied_pixels[0]);
333 EXPECT_EQ(1u, copied_pixels[1]); 338 EXPECT_EQ(1u, copied_pixels[1]);
334 EXPECT_EQ(1u, copied_pixels[2]); 339 EXPECT_EQ(1u, copied_pixels[2]);
335 EXPECT_EQ(128u, copied_pixels[3]); 340 EXPECT_EQ(128u, copied_pixels[3]);
336 341
(...skipping 11 matching lines...) Expand all
348 pixels); 353 pixels);
349 354
350 glPixelStorei(GL_UNPACK_UNPREMULTIPLY_ALPHA_CHROMIUM, GL_TRUE); 355 glPixelStorei(GL_UNPACK_UNPREMULTIPLY_ALPHA_CHROMIUM, GL_TRUE);
351 if (copy_type == TexImage) { 356 if (copy_type == TexImage) {
352 glCopyTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], GL_RGBA, 357 glCopyTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], GL_RGBA,
353 GL_UNSIGNED_BYTE); 358 GL_UNSIGNED_BYTE);
354 } else { 359 } else {
355 glBindTexture(GL_TEXTURE_2D, textures_[1]); 360 glBindTexture(GL_TEXTURE_2D, textures_[1]);
356 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 361 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE,
357 nullptr); 362 nullptr);
358 glCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 0, 0); 363 glCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 0, 0, 0,
364 0, 1, 1);
359 } 365 }
360 EXPECT_TRUE(GL_NO_ERROR == glGetError()); 366 EXPECT_TRUE(GL_NO_ERROR == glGetError());
361 367
362 uint8 copied_pixels[1 * 4] = {0}; 368 uint8 copied_pixels[1 * 4] = {0};
363 glReadPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, copied_pixels); 369 glReadPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, copied_pixels);
364 EXPECT_EQ(32u, copied_pixels[0]); 370 EXPECT_EQ(32u, copied_pixels[0]);
365 EXPECT_EQ(32u, copied_pixels[1]); 371 EXPECT_EQ(32u, copied_pixels[1]);
366 EXPECT_EQ(32u, copied_pixels[2]); 372 EXPECT_EQ(32u, copied_pixels[2]);
367 EXPECT_EQ(128u, copied_pixels[3]); 373 EXPECT_EQ(128u, copied_pixels[3]);
368 374
(...skipping 19 matching lines...) Expand all
388 394
389 glPixelStorei(GL_UNPACK_FLIP_Y_CHROMIUM, GL_TRUE); 395 glPixelStorei(GL_UNPACK_FLIP_Y_CHROMIUM, GL_TRUE);
390 glPixelStorei(GL_UNPACK_PREMULTIPLY_ALPHA_CHROMIUM, GL_TRUE); 396 glPixelStorei(GL_UNPACK_PREMULTIPLY_ALPHA_CHROMIUM, GL_TRUE);
391 if (copy_type == TexImage) { 397 if (copy_type == TexImage) {
392 glCopyTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], GL_RGBA, 398 glCopyTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], GL_RGBA,
393 GL_UNSIGNED_BYTE); 399 GL_UNSIGNED_BYTE);
394 } else { 400 } else {
395 glBindTexture(GL_TEXTURE_2D, textures_[1]); 401 glBindTexture(GL_TEXTURE_2D, textures_[1]);
396 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, 402 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE,
397 nullptr); 403 nullptr);
398 glCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 0, 0); 404 glCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 0, 0, 0,
405 0, 2, 2);
399 } 406 }
400 EXPECT_TRUE(GL_NO_ERROR == glGetError()); 407 EXPECT_TRUE(GL_NO_ERROR == glGetError());
401 408
402 uint8 copied_pixels[2][2][4] = {{{0}}}; 409 uint8 copied_pixels[2][2][4] = {{{0}}};
403 glReadPixels(0, 0, 2, 2, GL_RGBA, GL_UNSIGNED_BYTE, copied_pixels); 410 glReadPixels(0, 0, 2, 2, GL_RGBA, GL_UNSIGNED_BYTE, copied_pixels);
404 for (int x = 0; x < 2; ++x) { 411 for (int x = 0; x < 2; ++x) {
405 for (int y = 0; y < 2; ++y) { 412 for (int y = 0; y < 2; ++y) {
406 EXPECT_EQ(pixels[1-y][x][0] / 2, copied_pixels[y][x][0]); 413 EXPECT_EQ(pixels[1-y][x][0] / 2, copied_pixels[y][x][0]);
407 EXPECT_EQ(pixels[1-y][x][1] / 2, copied_pixels[y][x][1]); 414 EXPECT_EQ(pixels[1-y][x][1] / 2, copied_pixels[y][x][1]);
408 EXPECT_EQ(pixels[1-y][x][2] / 2, copied_pixels[y][x][2]); 415 EXPECT_EQ(pixels[1-y][x][2] / 2, copied_pixels[y][x][2]);
(...skipping 23 matching lines...) Expand all
432 439
433 glPixelStorei(GL_UNPACK_FLIP_Y_CHROMIUM, GL_TRUE); 440 glPixelStorei(GL_UNPACK_FLIP_Y_CHROMIUM, GL_TRUE);
434 glPixelStorei(GL_UNPACK_UNPREMULTIPLY_ALPHA_CHROMIUM, GL_TRUE); 441 glPixelStorei(GL_UNPACK_UNPREMULTIPLY_ALPHA_CHROMIUM, GL_TRUE);
435 if (copy_type == TexImage) { 442 if (copy_type == TexImage) {
436 glCopyTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], GL_RGBA, 443 glCopyTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], GL_RGBA,
437 GL_UNSIGNED_BYTE); 444 GL_UNSIGNED_BYTE);
438 } else { 445 } else {
439 glBindTexture(GL_TEXTURE_2D, textures_[1]); 446 glBindTexture(GL_TEXTURE_2D, textures_[1]);
440 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, 447 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE,
441 nullptr); 448 nullptr);
442 glCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 0, 0); 449 glCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 0, 0, 0,
450 0, 2, 2);
443 } 451 }
444 EXPECT_TRUE(GL_NO_ERROR == glGetError()); 452 EXPECT_TRUE(GL_NO_ERROR == glGetError());
445 453
446 uint8 copied_pixels[2][2][4] = {{{0}}}; 454 uint8 copied_pixels[2][2][4] = {{{0}}};
447 glReadPixels(0, 0, 2, 2, GL_RGBA, GL_UNSIGNED_BYTE, copied_pixels); 455 glReadPixels(0, 0, 2, 2, GL_RGBA, GL_UNSIGNED_BYTE, copied_pixels);
448 for (int x = 0; x < 2; ++x) { 456 for (int x = 0; x < 2; ++x) {
449 for (int y = 0; y < 2; ++y) { 457 for (int y = 0; y < 2; ++y) {
450 EXPECT_EQ(pixels[1-y][x][0] * 2, copied_pixels[y][x][0]); 458 EXPECT_EQ(pixels[1-y][x][0] * 2, copied_pixels[y][x][0]);
451 EXPECT_EQ(pixels[1-y][x][1] * 2, copied_pixels[y][x][1]); 459 EXPECT_EQ(pixels[1-y][x][1] * 2, copied_pixels[y][x][1]);
452 EXPECT_EQ(pixels[1-y][x][2] * 2, copied_pixels[y][x][2]); 460 EXPECT_EQ(pixels[1-y][x][2] * 2, copied_pixels[y][x][2]);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
496 glEnableDisable(GL_BLEND, setting); 504 glEnableDisable(GL_BLEND, setting);
497 glColorMask(setting, setting, setting, setting); 505 glColorMask(setting, setting, setting, setting);
498 glDepthMask(setting); 506 glDepthMask(setting);
499 507
500 glActiveTexture(GL_TEXTURE1 + x); 508 glActiveTexture(GL_TEXTURE1 + x);
501 509
502 if (copy_type == TexImage) { 510 if (copy_type == TexImage) {
503 glCopyTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], GL_RGBA, 511 glCopyTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], GL_RGBA,
504 GL_UNSIGNED_BYTE); 512 GL_UNSIGNED_BYTE);
505 } else { 513 } else {
506 glCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 0, 0); 514 glCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 0, 0,
515 0, 0, 1, 1);
507 } 516 }
508 EXPECT_TRUE(GL_NO_ERROR == glGetError()); 517 EXPECT_TRUE(GL_NO_ERROR == glGetError());
509 518
510 EXPECT_EQ(setting, glIsEnabled(GL_DEPTH_TEST)); 519 EXPECT_EQ(setting, glIsEnabled(GL_DEPTH_TEST));
511 EXPECT_EQ(setting, glIsEnabled(GL_SCISSOR_TEST)); 520 EXPECT_EQ(setting, glIsEnabled(GL_SCISSOR_TEST));
512 EXPECT_EQ(setting, glIsEnabled(GL_STENCIL_TEST)); 521 EXPECT_EQ(setting, glIsEnabled(GL_STENCIL_TEST));
513 EXPECT_EQ(setting, glIsEnabled(GL_CULL_FACE)); 522 EXPECT_EQ(setting, glIsEnabled(GL_CULL_FACE));
514 EXPECT_EQ(setting, glIsEnabled(GL_BLEND)); 523 EXPECT_EQ(setting, glIsEnabled(GL_BLEND));
515 524
516 GLboolean bool_array[4] = { GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE }; 525 GLboolean bool_array[4] = { GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE };
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
554 glActiveTexture(GL_TEXTURE0); 563 glActiveTexture(GL_TEXTURE0);
555 glBindTexture(GL_TEXTURE_2D, texture_ids[0]); 564 glBindTexture(GL_TEXTURE_2D, texture_ids[0]);
556 565
557 glActiveTexture(GL_TEXTURE1); 566 glActiveTexture(GL_TEXTURE1);
558 glBindTexture(GL_TEXTURE_2D, texture_ids[1]); 567 glBindTexture(GL_TEXTURE_2D, texture_ids[1]);
559 568
560 if (copy_type == TexImage) { 569 if (copy_type == TexImage) {
561 glCopyTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], GL_RGBA, 570 glCopyTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], GL_RGBA,
562 GL_UNSIGNED_BYTE); 571 GL_UNSIGNED_BYTE);
563 } else { 572 } else {
564 glCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 0, 0); 573 glCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 0, 0, 0,
574 0, 1, 1);
565 } 575 }
566 EXPECT_TRUE(GL_NO_ERROR == glGetError()); 576 EXPECT_TRUE(GL_NO_ERROR == glGetError());
567 577
568 GLint active_texture = 0; 578 GLint active_texture = 0;
569 glGetIntegerv(GL_ACTIVE_TEXTURE, &active_texture); 579 glGetIntegerv(GL_ACTIVE_TEXTURE, &active_texture);
570 EXPECT_EQ(GL_TEXTURE1, active_texture); 580 EXPECT_EQ(GL_TEXTURE1, active_texture);
571 581
572 GLint bound_texture = 0; 582 GLint bound_texture = 0;
573 glGetIntegerv(GL_TEXTURE_BINDING_2D, &bound_texture); 583 glGetIntegerv(GL_TEXTURE_BINDING_2D, &bound_texture);
574 EXPECT_EQ(texture_ids[1], static_cast<GLuint>(bound_texture)); 584 EXPECT_EQ(texture_ids[1], static_cast<GLuint>(bound_texture));
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
625 // Test that we can write to the bound framebuffer 635 // Test that we can write to the bound framebuffer
626 uint8 expected_color[4] = { 255u, 255u, 0, 255u }; 636 uint8 expected_color[4] = { 255u, 255u, 0, 255u };
627 glClearColor(1.0, 1.0, 0, 1.0); 637 glClearColor(1.0, 1.0, 0, 1.0);
628 glClear(GL_COLOR_BUFFER_BIT); 638 glClear(GL_COLOR_BUFFER_BIT);
629 GLTestHelper::CheckPixels(0, 0, 1, 1, 0, expected_color); 639 GLTestHelper::CheckPixels(0, 0, 1, 1, 0, expected_color);
630 640
631 if (copy_type == TexImage) { 641 if (copy_type == TexImage) {
632 glCopyTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], GL_RGBA, 642 glCopyTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], GL_RGBA,
633 GL_UNSIGNED_BYTE); 643 GL_UNSIGNED_BYTE);
634 } else { 644 } else {
635 glCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 0, 0); 645 glCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 0, 0, 0,
646 0, 1, 1);
636 } 647 }
637 EXPECT_TRUE(GL_NO_ERROR == glGetError()); 648 EXPECT_TRUE(GL_NO_ERROR == glGetError());
638 649
639 EXPECT_TRUE(glIsFramebuffer(framebuffer_id)); 650 EXPECT_TRUE(glIsFramebuffer(framebuffer_id));
640 651
641 // Ensure that reading from the framebuffer produces correct pixels. 652 // Ensure that reading from the framebuffer produces correct pixels.
642 GLTestHelper::CheckPixels(0, 0, 1, 1, 0, expected_color); 653 GLTestHelper::CheckPixels(0, 0, 1, 1, 0, expected_color);
643 654
644 uint8 expected_color2[4] = { 255u, 0, 255u, 255u }; 655 uint8 expected_color2[4] = { 255u, 0, 255u, 255u };
645 glClearColor(1.0, 0, 1.0, 1.0); 656 glClearColor(1.0, 0, 1.0, 1.0);
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
736 glBindTexture(GL_TEXTURE_2D, textures_[0]); 747 glBindTexture(GL_TEXTURE_2D, textures_[0]);
737 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 748 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE,
738 pixels); 749 pixels);
739 if (copy_type == TexImage) { 750 if (copy_type == TexImage) {
740 glCopyTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], GL_RGBA, 751 glCopyTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], GL_RGBA,
741 GL_UNSIGNED_BYTE); 752 GL_UNSIGNED_BYTE);
742 } else { 753 } else {
743 glBindTexture(GL_TEXTURE_2D, textures_[1]); 754 glBindTexture(GL_TEXTURE_2D, textures_[1]);
744 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 755 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE,
745 nullptr); 756 nullptr);
746 glCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 0, 0); 757 glCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 0, 0, 0,
758 0, 1, 1);
747 } 759 }
748 760
749 // test using program after 761 // test using program after
750 glClear(GL_COLOR_BUFFER_BIT); 762 glClear(GL_COLOR_BUFFER_BIT);
751 EXPECT_TRUE(GLTestHelper::CheckPixels(0, 0, 1, 1, 0, zero)); 763 EXPECT_TRUE(GLTestHelper::CheckPixels(0, 0, 1, 1, 0, zero));
752 glDrawArrays(GL_TRIANGLES, 0, 6); 764 glDrawArrays(GL_TRIANGLES, 0, 6);
753 EXPECT_TRUE(GLTestHelper::CheckPixels(0, 0, 1, 1, 0, expected)); 765 EXPECT_TRUE(GLTestHelper::CheckPixels(0, 0, 1, 1, 0, expected));
754 766
755 EXPECT_TRUE(GL_NO_ERROR == glGetError()); 767 EXPECT_TRUE(GL_NO_ERROR == glGetError());
756 768
(...skipping 10 matching lines...) Expand all
767 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, kWidth, kHeight, 0, GL_RGBA, 779 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, kWidth, kHeight, 0, GL_RGBA,
768 GL_UNSIGNED_BYTE, nullptr); 780 GL_UNSIGNED_BYTE, nullptr);
769 781
770 if (copy_type == TexImage) { 782 if (copy_type == TexImage) {
771 glCopyTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], GL_RGBA, 783 glCopyTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], GL_RGBA,
772 GL_UNSIGNED_BYTE); 784 GL_UNSIGNED_BYTE);
773 } else { 785 } else {
774 glBindTexture(GL_TEXTURE_2D, textures_[1]); 786 glBindTexture(GL_TEXTURE_2D, textures_[1]);
775 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, kWidth, kHeight, 0, GL_RGBA, 787 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, kWidth, kHeight, 0, GL_RGBA,
776 GL_UNSIGNED_BYTE, nullptr); 788 GL_UNSIGNED_BYTE, nullptr);
777 glCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 0, 0); 789 glCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 0, 0, 0,
790 0, kWidth, kHeight);
778 } 791 }
779 EXPECT_TRUE(GL_NO_ERROR == glGetError()); 792 EXPECT_TRUE(GL_NO_ERROR == glGetError());
780 793
781 uint8 pixels[kHeight][kWidth][4] = {{{1}}}; 794 uint8 pixels[kHeight][kWidth][4] = {{{1}}};
782 glReadPixels(0, 0, kWidth, kHeight, GL_RGBA, GL_UNSIGNED_BYTE, pixels); 795 glReadPixels(0, 0, kWidth, kHeight, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
783 for (int x = 0; x < kWidth; ++x) { 796 for (int x = 0; x < kWidth; ++x) {
784 for (int y = 0; y < kHeight; ++y) { 797 for (int y = 0; y < kHeight; ++y) {
785 EXPECT_EQ(0, pixels[y][x][0]); 798 EXPECT_EQ(0, pixels[y][x][0]);
786 EXPECT_EQ(0, pixels[y][x][1]); 799 EXPECT_EQ(0, pixels[y][x][1]);
787 EXPECT_EQ(0, pixels[y][x][2]); 800 EXPECT_EQ(0, pixels[y][x][2]);
788 EXPECT_EQ(0, pixels[y][x][3]); 801 EXPECT_EQ(0, pixels[y][x][3]);
789 } 802 }
790 } 803 }
791 804
792 EXPECT_TRUE(GL_NO_ERROR == glGetError()); 805 EXPECT_TRUE(GL_NO_ERROR == glGetError());
793 } 806 }
794 807
795 TEST_F(GLCopyTextureCHROMIUMTest, CopySubTextureDimension) { 808 TEST_F(GLCopyTextureCHROMIUMTest, CopySubTextureDimension) {
796 glBindTexture(GL_TEXTURE_2D, textures_[0]); 809 glBindTexture(GL_TEXTURE_2D, textures_[0]);
797 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, 810 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE,
798 nullptr); 811 nullptr);
799 812
800 glBindTexture(GL_TEXTURE_2D, textures_[1]); 813 glBindTexture(GL_TEXTURE_2D, textures_[1]);
801 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 3, 3, 0, GL_RGBA, GL_UNSIGNED_BYTE, 814 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 3, 3, 0, GL_RGBA, GL_UNSIGNED_BYTE,
802 nullptr); 815 nullptr);
803 816
804 glCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 1, 1); 817 glCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 1, 1, 0,
818 0, 1, 1);
805 EXPECT_TRUE(GL_NO_ERROR == glGetError()); 819 EXPECT_TRUE(GL_NO_ERROR == glGetError());
806 820
807 // xoffset < 0 821 // xoffset < 0
808 glCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], -1, 1); 822 glCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], -1, 1, 0,
823 0, 1, 1);
809 EXPECT_TRUE(glGetError() == GL_INVALID_VALUE); 824 EXPECT_TRUE(glGetError() == GL_INVALID_VALUE);
810 825
811 // xoffset + source_width > dest_width 826 // x < 0
812 glCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 2, 2); 827 glCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 1, 1, -1,
828 0, 1, 1);
829 EXPECT_TRUE(glGetError() == GL_INVALID_VALUE);
830
831 // xoffset + width > dest_width
832 glCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 2, 2, 0,
833 0, 2, 2);
834 EXPECT_TRUE(glGetError() == GL_INVALID_VALUE);
835
836 // x + width > source_width
837 glCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 0, 0, 1,
838 1, 2, 2);
813 EXPECT_TRUE(glGetError() == GL_INVALID_VALUE); 839 EXPECT_TRUE(glGetError() == GL_INVALID_VALUE);
814 } 840 }
815 841
816 TEST_F(GLCopyTextureCHROMIUMTest, CopySubTextureOffset) { 842 TEST_F(GLCopyTextureCHROMIUMTest, CopySubTextureOffset) {
817 uint8 red[1 * 4] = {255u, 0u, 0u, 255u}; 843 uint8 rgba_pixels[4 * 4] = {255u,
844 0u,
845 0u,
846 255u,
847 0u,
848 255u,
849 0u,
850 255u,
851 0u,
852 0u,
853 255u,
854 255u,
855 0u,
856 0u,
857 0u,
858 255u};
818 glBindTexture(GL_TEXTURE_2D, textures_[0]); 859 glBindTexture(GL_TEXTURE_2D, textures_[0]);
819 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 860 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE,
820 red); 861 rgba_pixels);
821 862
822 uint8 transparent_pixel[4 * 4] = { 863 uint8 transparent_pixels[4 * 4] = {
823 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u}; 864 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u};
824 glBindTexture(GL_TEXTURE_2D, textures_[1]); 865 glBindTexture(GL_TEXTURE_2D, textures_[1]);
825 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, 866 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE,
826 transparent_pixel); 867 transparent_pixels);
827 868
828 glCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 1, 1); 869 glCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 1, 1, 0,
870 0, 1, 1);
871 EXPECT_TRUE(glGetError() == GL_NO_ERROR);
872 glCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 1, 0, 1,
873 0, 1, 1);
874 EXPECT_TRUE(glGetError() == GL_NO_ERROR);
875 glCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 0, 1, 0,
876 1, 1, 1);
829 EXPECT_TRUE(glGetError() == GL_NO_ERROR); 877 EXPECT_TRUE(glGetError() == GL_NO_ERROR);
830 878
831 // Check the FB is still bound. 879 // Check the FB is still bound.
832 GLint value = 0; 880 GLint value = 0;
833 glGetIntegerv(GL_FRAMEBUFFER_BINDING, &value); 881 glGetIntegerv(GL_FRAMEBUFFER_BINDING, &value);
834 GLuint fb_id = value; 882 GLuint fb_id = value;
835 EXPECT_EQ(framebuffer_id_, fb_id); 883 EXPECT_EQ(framebuffer_id_, fb_id);
836 884
837 // Check that FB is complete. 885 // Check that FB is complete.
838 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE), 886 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE),
839 glCheckFramebufferStatus(GL_FRAMEBUFFER)); 887 glCheckFramebufferStatus(GL_FRAMEBUFFER));
840 888
841 uint8 transparent[1 * 4] = {0u, 0u, 0u, 0u}; 889 uint8 transparent[1 * 4] = {0u, 0u, 0u, 0u};
890 uint8 red[1 * 4] = {255u, 0u, 0u, 255u};
891 uint8 green[1 * 4] = {0u, 255u, 0u, 255u};
892 uint8 blue[1 * 4] = {0u, 0u, 255u, 255u};
842 GLTestHelper::CheckPixels(0, 0, 1, 1, 0, transparent); 893 GLTestHelper::CheckPixels(0, 0, 1, 1, 0, transparent);
843 GLTestHelper::CheckPixels(1, 1, 1, 1, 0, red); 894 GLTestHelper::CheckPixels(1, 1, 1, 1, 0, red);
895 GLTestHelper::CheckPixels(1, 0, 1, 1, 0, green);
896 GLTestHelper::CheckPixels(0, 1, 1, 1, 0, blue);
844 EXPECT_TRUE(GL_NO_ERROR == glGetError()); 897 EXPECT_TRUE(GL_NO_ERROR == glGetError());
845 } 898 }
846 899
847 } // namespace gpu 900 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/gles2_cmd_decoder_autogen.h ('k') | mojo/gpu/mojo_gles2_impl_autogen.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698