diff options
-rw-r--r-- | gpu/command_buffer/service/gles2_cmd_decoder.cc | 3 | ||||
-rw-r--r-- | gpu/command_buffer/tests/gl_texture_mailbox_unittests.cc | 49 |
2 files changed, 51 insertions, 1 deletions
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.cc b/gpu/command_buffer/service/gles2_cmd_decoder.cc index e6f5027..5cfe248 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder.cc +++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc @@ -3234,7 +3234,8 @@ bool GLES2DecoderImpl::ProduceFrontBuffer(const Mailbox& mailbox) { return false; if (!offscreen_saved_color_texture_info_.get()) { GLuint service_id = offscreen_saved_color_texture_->id(); - offscreen_saved_color_texture_info_ = CreateTexture(0, service_id); + offscreen_saved_color_texture_info_ = TextureRef::Create( + texture_manager(), 0, service_id); texture_manager()->SetTarget(offscreen_saved_color_texture_info_.get(), GL_TEXTURE_2D); UpdateParentTextureInfo(); diff --git a/gpu/command_buffer/tests/gl_texture_mailbox_unittests.cc b/gpu/command_buffer/tests/gl_texture_mailbox_unittests.cc index dbd513c..d960efc 100644 --- a/gpu/command_buffer/tests/gl_texture_mailbox_unittests.cc +++ b/gpu/command_buffer/tests/gl_texture_mailbox_unittests.cc @@ -318,5 +318,54 @@ TEST_F(GLTextureMailboxTest, ProduceFrontBuffer) { glDeleteTextures(1, &tex1); } +TEST_F(GLTextureMailboxTest, ProduceFrontBufferMultipleContexts) { + gl1_.MakeCurrent(); + Mailbox mailbox[2]; + glGenMailboxCHROMIUM(mailbox[0].name); + glGenMailboxCHROMIUM(mailbox[1].name); + GLuint tex[2]; + glGenTextures(2, tex); + + GLManager::Options options; + options.share_mailbox_manager = &gl1_; + GLManager other_gl[2]; + for (size_t i = 0; i < 2; ++i) { + other_gl[i].Initialize(options); + other_gl[i].MakeCurrent(); + other_gl[i].decoder()->ProduceFrontBuffer(mailbox[i]); + // Make sure both "other gl" are in the same share group. + if (!options.share_group_manager) + options.share_group_manager = other_gl+i; + } + + + gl1_.MakeCurrent(); + for (size_t i = 0; i < 2; ++i) { + glBindTexture(GL_TEXTURE_2D, tex[i]); + glConsumeTextureCHROMIUM(GL_TEXTURE_2D, mailbox[i].name); + EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError()); + } + + for (size_t i = 0; i < 2; ++i) { + other_gl[i].MakeCurrent(); + glResizeCHROMIUM(10, 10, 1); + glClearColor(1-i%2, i%2, 0, 1); + glClear(GL_COLOR_BUFFER_BIT); + ::gles2::GetGLContext()->SwapBuffers(); + } + + gl1_.MakeCurrent(); + EXPECT_EQ(0xFF0000FFu, ReadTexel(tex[0], 0, 0)); + EXPECT_EQ(0xFF00FF00u, ReadTexel(tex[1], 9, 9)); + + for (size_t i = 0; i < 2; ++i) { + other_gl[i].MakeCurrent(); + other_gl[i].Destroy(); + } + + gl1_.MakeCurrent(); + glDeleteTextures(2, tex); +} + } // namespace gpu |