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 #include <GLES2/gl2.h> | 5 #include <GLES2/gl2.h> |
6 #include <GLES2/gl2ext.h> | 6 #include <GLES2/gl2ext.h> |
7 #include <GLES2/gl2extchromium.h> | 7 #include <GLES2/gl2extchromium.h> |
8 | 8 |
| 9 #include "gpu/command_buffer/client/gles2_lib.h" |
| 10 #include "gpu/command_buffer/common/mailbox.h" |
| 11 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" |
9 #include "gpu/command_buffer/service/mailbox_manager.h" | 12 #include "gpu/command_buffer/service/mailbox_manager.h" |
10 #include "gpu/command_buffer/tests/gl_manager.h" | 13 #include "gpu/command_buffer/tests/gl_manager.h" |
11 #include "testing/gmock/include/gmock/gmock.h" | 14 #include "testing/gmock/include/gmock/gmock.h" |
12 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
13 #include "ui/gl/gl_share_group.h" | 16 #include "ui/gl/gl_share_group.h" |
14 | 17 |
15 namespace gpu { | 18 namespace gpu { |
16 | 19 |
17 namespace { | 20 namespace { |
18 uint32 ReadTexel(GLuint id, GLint x, GLint y) { | 21 uint32 ReadTexel(GLuint id, GLint x, GLint y) { |
(...skipping 11 matching lines...) Expand all Loading... |
30 // Some drivers (NVidia/SGX) require texture settings to be a certain way or | 33 // Some drivers (NVidia/SGX) require texture settings to be a certain way or |
31 // they won't report FRAMEBUFFER_COMPLETE. | 34 // they won't report FRAMEBUFFER_COMPLETE. |
32 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); | 35 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); |
33 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); | 36 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); |
34 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); | 37 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
35 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); | 38 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); |
36 | 39 |
37 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE), | 40 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE), |
38 glCheckFramebufferStatus(GL_FRAMEBUFFER)); | 41 glCheckFramebufferStatus(GL_FRAMEBUFFER)); |
39 | 42 |
40 uint32 texel; | 43 uint32 texel = 0; |
41 glReadPixels(x, y, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &texel); | 44 glReadPixels(x, y, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &texel); |
42 | 45 |
43 glBindFramebuffer(GL_FRAMEBUFFER, old_fbo); | 46 glBindFramebuffer(GL_FRAMEBUFFER, old_fbo); |
44 | 47 |
45 glDeleteFramebuffers(1, &fbo); | 48 glDeleteFramebuffers(1, &fbo); |
46 | 49 |
47 return texel; | 50 return texel; |
48 } | 51 } |
49 } | 52 } |
50 | 53 |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 | 262 |
260 // Mailbox should be gone now. | 263 // Mailbox should be gone now. |
261 glGenTextures(1, &tex2); | 264 glGenTextures(1, &tex2); |
262 glBindTexture(GL_TEXTURE_2D, tex2); | 265 glBindTexture(GL_TEXTURE_2D, tex2); |
263 glConsumeTextureCHROMIUM(GL_TEXTURE_2D, mailbox); | 266 glConsumeTextureCHROMIUM(GL_TEXTURE_2D, mailbox); |
264 EXPECT_EQ(static_cast<GLenum>(GL_INVALID_OPERATION), glGetError()); | 267 EXPECT_EQ(static_cast<GLenum>(GL_INVALID_OPERATION), glGetError()); |
265 glDeleteTextures(1, &tex2); | 268 glDeleteTextures(1, &tex2); |
266 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError()); | 269 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError()); |
267 } | 270 } |
268 | 271 |
| 272 TEST_F(GLTextureMailboxTest, ProduceFrontBuffer) { |
| 273 gl1_.MakeCurrent(); |
| 274 Mailbox mailbox; |
| 275 glGenMailboxCHROMIUM(mailbox.name); |
| 276 |
| 277 gl2_.MakeCurrent(); |
| 278 gl2_.decoder()->ProduceFrontBuffer(mailbox); |
| 279 |
| 280 gl1_.MakeCurrent(); |
| 281 GLuint tex1; |
| 282 glGenTextures(1, &tex1); |
| 283 glBindTexture(GL_TEXTURE_2D, tex1); |
| 284 glConsumeTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name); |
| 285 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError()); |
| 286 |
| 287 gl2_.MakeCurrent(); |
| 288 glResizeCHROMIUM(10, 10, 1); |
| 289 glClearColor(1, 0, 0, 1); |
| 290 glClear(GL_COLOR_BUFFER_BIT); |
| 291 ::gles2::GetGLContext()->SwapBuffers(); |
| 292 |
| 293 gl1_.MakeCurrent(); |
| 294 EXPECT_EQ(0xFF0000FFu, ReadTexel(tex1, 0, 0)); |
| 295 EXPECT_EQ(0xFF0000FFu, ReadTexel(tex1, 9, 9)); |
| 296 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError()); |
| 297 |
| 298 gl2_.MakeCurrent(); |
| 299 glClearColor(0, 1, 0, 1); |
| 300 glClear(GL_COLOR_BUFFER_BIT); |
| 301 glFlush(); |
| 302 |
| 303 gl1_.MakeCurrent(); |
| 304 EXPECT_EQ(0xFF0000FFu, ReadTexel(tex1, 0, 0)); |
| 305 |
| 306 gl2_.MakeCurrent(); |
| 307 ::gles2::GetGLContext()->SwapBuffers(); |
| 308 |
| 309 gl1_.MakeCurrent(); |
| 310 EXPECT_EQ(0xFF00FF00u, ReadTexel(tex1, 0, 0)); |
| 311 |
| 312 gl2_.MakeCurrent(); |
| 313 gl2_.Destroy(); |
| 314 |
| 315 gl1_.MakeCurrent(); |
| 316 EXPECT_EQ(0xFF00FF00u, ReadTexel(tex1, 0, 0)); |
| 317 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError()); |
| 318 glDeleteTextures(1, &tex1); |
| 319 } |
| 320 |
269 } // namespace gpu | 321 } // namespace gpu |
270 | 322 |
OLD | NEW |