diff options
Diffstat (limited to 'gpu/command_buffer/tests')
-rw-r--r-- | gpu/command_buffer/tests/gl_manager.cc | 1 | ||||
-rw-r--r-- | gpu/command_buffer/tests/gl_manager.h | 4 | ||||
-rw-r--r-- | gpu/command_buffer/tests/gl_texture_mailbox_unittests.cc | 54 |
3 files changed, 58 insertions, 1 deletions
diff --git a/gpu/command_buffer/tests/gl_manager.cc b/gpu/command_buffer/tests/gl_manager.cc index 3e55384..cb05e35 100644 --- a/gpu/command_buffer/tests/gl_manager.cc +++ b/gpu/command_buffer/tests/gl_manager.cc @@ -249,6 +249,7 @@ void GLManager::Destroy() { if (decoder_.get()) { decoder_->MakeCurrent(); decoder_->Destroy(true); + decoder_.reset(); } } diff --git a/gpu/command_buffer/tests/gl_manager.h b/gpu/command_buffer/tests/gl_manager.h index 15fc9ef..7b96b84 100644 --- a/gpu/command_buffer/tests/gl_manager.h +++ b/gpu/command_buffer/tests/gl_manager.h @@ -67,6 +67,10 @@ class GLManager { void SetSurface(gfx::GLSurface* surface); + gles2::GLES2Decoder* decoder() const { + return decoder_.get(); + } + gles2::MailboxManager* mailbox_manager() const { return mailbox_manager_.get(); } diff --git a/gpu/command_buffer/tests/gl_texture_mailbox_unittests.cc b/gpu/command_buffer/tests/gl_texture_mailbox_unittests.cc index 566189f..dbd513c 100644 --- a/gpu/command_buffer/tests/gl_texture_mailbox_unittests.cc +++ b/gpu/command_buffer/tests/gl_texture_mailbox_unittests.cc @@ -6,6 +6,9 @@ #include <GLES2/gl2ext.h> #include <GLES2/gl2extchromium.h> +#include "gpu/command_buffer/client/gles2_lib.h" +#include "gpu/command_buffer/common/mailbox.h" +#include "gpu/command_buffer/service/gles2_cmd_decoder.h" #include "gpu/command_buffer/service/mailbox_manager.h" #include "gpu/command_buffer/tests/gl_manager.h" #include "testing/gmock/include/gmock/gmock.h" @@ -37,7 +40,7 @@ uint32 ReadTexel(GLuint id, GLint x, GLint y) { EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE), glCheckFramebufferStatus(GL_FRAMEBUFFER)); - uint32 texel; + uint32 texel = 0; glReadPixels(x, y, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &texel); glBindFramebuffer(GL_FRAMEBUFFER, old_fbo); @@ -266,5 +269,54 @@ TEST_F(GLTextureMailboxTest, SharedTextures) { EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError()); } +TEST_F(GLTextureMailboxTest, ProduceFrontBuffer) { + gl1_.MakeCurrent(); + Mailbox mailbox; + glGenMailboxCHROMIUM(mailbox.name); + + gl2_.MakeCurrent(); + gl2_.decoder()->ProduceFrontBuffer(mailbox); + + gl1_.MakeCurrent(); + GLuint tex1; + glGenTextures(1, &tex1); + glBindTexture(GL_TEXTURE_2D, tex1); + glConsumeTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name); + EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError()); + + gl2_.MakeCurrent(); + glResizeCHROMIUM(10, 10, 1); + glClearColor(1, 0, 0, 1); + glClear(GL_COLOR_BUFFER_BIT); + ::gles2::GetGLContext()->SwapBuffers(); + + gl1_.MakeCurrent(); + EXPECT_EQ(0xFF0000FFu, ReadTexel(tex1, 0, 0)); + EXPECT_EQ(0xFF0000FFu, ReadTexel(tex1, 9, 9)); + EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError()); + + gl2_.MakeCurrent(); + glClearColor(0, 1, 0, 1); + glClear(GL_COLOR_BUFFER_BIT); + glFlush(); + + gl1_.MakeCurrent(); + EXPECT_EQ(0xFF0000FFu, ReadTexel(tex1, 0, 0)); + + gl2_.MakeCurrent(); + ::gles2::GetGLContext()->SwapBuffers(); + + gl1_.MakeCurrent(); + EXPECT_EQ(0xFF00FF00u, ReadTexel(tex1, 0, 0)); + + gl2_.MakeCurrent(); + gl2_.Destroy(); + + gl1_.MakeCurrent(); + EXPECT_EQ(0xFF00FF00u, ReadTexel(tex1, 0, 0)); + EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError()); + glDeleteTextures(1, &tex1); +} + } // namespace gpu |