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

Unified Diff: gpu/command_buffer/tests/gl_texture_mailbox_unittest.cc

Issue 1937173002: Revert of Pepper takes ownership of a mailbox before passing it to the texture layer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « gpu/command_buffer/service/gles2_cmd_decoder_mock.h ('k') | gpu/ipc/client/command_buffer_proxy_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gpu/command_buffer/tests/gl_texture_mailbox_unittest.cc
diff --git a/gpu/command_buffer/tests/gl_texture_mailbox_unittest.cc b/gpu/command_buffer/tests/gl_texture_mailbox_unittest.cc
index 81298299cb8e0e19a6c5271b334ab7ac8839ac66..beacdfb3163cb9080fc1618e4c615b67cc201732 100644
--- a/gpu/command_buffer/tests/gl_texture_mailbox_unittest.cc
+++ b/gpu/command_buffer/tests/gl_texture_mailbox_unittest.cc
@@ -68,29 +68,6 @@
gl2_.Destroy();
}
- // The second GL context takes and consumes a mailbox from the first GL
- // context. Assumes that |gl1_| is current.
- Mailbox TakeAndConsumeMailbox() {
- glResizeCHROMIUM(10, 10, 1, true);
- glClearColor(0, 1, 1, 1);
- glClear(GL_COLOR_BUFFER_BIT);
- ::gles2::GetGLContext()->SwapBuffers();
-
- Mailbox mailbox;
- glGenMailboxCHROMIUM(mailbox.name);
- gl1_.decoder()->TakeFrontBuffer(mailbox);
-
- gl2_.MakeCurrent();
- GLuint tex;
- glGenTextures(1, &tex);
- glBindTexture(GL_TEXTURE_2D, tex);
- glConsumeTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name);
- glDeleteTextures(1, &tex);
- glFlush();
- gl1_.MakeCurrent();
- return mailbox;
- }
-
GLManager gl1_;
GLManager gl2_;
};
@@ -350,101 +327,53 @@
EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError());
}
-TEST_F(GLTextureMailboxTest, TakeFrontBuffer) {
+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, true);
- glClearColor(0, 1, 1, 1);
- glClear(GL_COLOR_BUFFER_BIT);
- ::gles2::GetGLContext()->SwapBuffers();
- gl2_.decoder()->TakeFrontBuffer(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());
- EXPECT_EQ(0xFFFFFF00u, ReadTexel(tex1, 0, 0));
-
- gl2_.MakeCurrent();
glClearColor(1, 0, 0, 1);
glClear(GL_COLOR_BUFFER_BIT);
::gles2::GetGLContext()->SwapBuffers();
gl1_.MakeCurrent();
- EXPECT_EQ(0xFFFFFF00u, ReadTexel(tex1, 0, 0));
-
- glDeleteTextures(1, &tex1);
-
- Mailbox mailbox2;
- glGenMailboxCHROMIUM(mailbox2.name);
-
- gl2_.MakeCurrent();
- gl2_.decoder()->ReturnFrontBuffer(mailbox, false);
-
- // Flushing doesn't matter, only SwapBuffers().
+ 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();
- gl2_.decoder()->TakeFrontBuffer(mailbox2);
-
- gl1_.MakeCurrent();
- glGenTextures(1, &tex1);
- glBindTexture(GL_TEXTURE_2D, tex1);
- glConsumeTextureCHROMIUM(GL_TEXTURE_2D, mailbox2.name);
- EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError());
+ 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(0xFF0000FFu, ReadTexel(tex1, 0, 0));
+ EXPECT_EQ(0xFF00FF00u, ReadTexel(tex1, 0, 0));
EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError());
glDeleteTextures(1, &tex1);
-}
-
-// The client, represented by |gl2_|, will request 5 frontbuffers, and then
-// start returning them.
-TEST_F(GLTextureMailboxTest, FrontBufferCache) {
- gl1_.MakeCurrent();
-
- std::vector<Mailbox> mailboxes;
- for (int i = 0; i < 5; ++i) {
- Mailbox mailbox = TakeAndConsumeMailbox();
- mailboxes.push_back(mailbox);
- }
- EXPECT_EQ(5u, gl1_.decoder()->GetSavedBackTextureCountForTest());
- EXPECT_EQ(5u, gl1_.decoder()->GetCreatedBackTextureCountForTest());
-
- // If the textures aren't lost, they're reused.
- for (int i = 0; i < 100; ++i) {
- gl1_.decoder()->ReturnFrontBuffer(mailboxes[0], false);
- mailboxes.erase(mailboxes.begin());
-
- Mailbox mailbox = TakeAndConsumeMailbox();
- mailboxes.push_back(mailbox);
- }
-
- EXPECT_EQ(5u, gl1_.decoder()->GetSavedBackTextureCountForTest());
- EXPECT_EQ(5u, gl1_.decoder()->GetCreatedBackTextureCountForTest());
-
- // If the textures are lost, they're not reused.
- for (int i = 0; i < 100; ++i) {
- gl1_.decoder()->ReturnFrontBuffer(mailboxes[0], true);
- mailboxes.erase(mailboxes.begin());
-
- Mailbox mailbox = TakeAndConsumeMailbox();
- mailboxes.push_back(mailbox);
- }
-
- EXPECT_EQ(5u, gl1_.decoder()->GetSavedBackTextureCountForTest());
- EXPECT_EQ(105u, gl1_.decoder()->GetCreatedBackTextureCountForTest());
}
TEST_F(GLTextureMailboxTest, ProduceTextureDirectInvalidTarget) {
@@ -473,7 +402,7 @@
// http://crbug.com/281565
#if !defined(OS_ANDROID)
-TEST_F(GLTextureMailboxTest, TakeFrontBufferMultipleContexts) {
+TEST_F(GLTextureMailboxTest, ProduceFrontBufferMultipleContexts) {
gl1_.MakeCurrent();
Mailbox mailbox[2];
glGenMailboxCHROMIUM(mailbox[0].name);
@@ -487,15 +416,12 @@
for (size_t i = 0; i < 2; ++i) {
other_gl[i].Initialize(options);
other_gl[i].MakeCurrent();
- glResizeCHROMIUM(10, 10, 1, true);
- glClearColor(1 - i % 2, i % 2, 0, 1);
- glClear(GL_COLOR_BUFFER_BIT);
- ::gles2::GetGLContext()->SwapBuffers();
- other_gl[i].decoder()->TakeFrontBuffer(mailbox[i]);
+ 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) {
@@ -504,6 +430,14 @@
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, true);
+ 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));
« no previous file with comments | « gpu/command_buffer/service/gles2_cmd_decoder_mock.h ('k') | gpu/ipc/client/command_buffer_proxy_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698