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

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

Issue 10106015: Allow textures to be moved from one GL context group to another. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 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
Index: gpu/command_buffer/tests/gl_unittests.cc
===================================================================
--- gpu/command_buffer/tests/gl_unittests.cc (revision 133771)
+++ gpu/command_buffer/tests/gl_unittests.cc (working copy)
@@ -2,16 +2,50 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#define GL_GLEXT_PROTOTYPES
+
#include <GLES2/gl2.h>
+#include <GLES2/gl2ext.h>
+#include "gpu/command_buffer/service/mailbox_manager.h"
#include "gpu/command_buffer/tests/gl_manager.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
+#include "ui/gfx/gl/gl_share_group.h"
namespace gpu {
+namespace {
+uint32 ReadTexel(GLuint id, GLint x, GLint y) {
+ GLint old_fbo = 0;
+ glGetIntegerv(GL_FRAMEBUFFER_BINDING, &old_fbo);
+
+ GLuint fbo;
+ glGenFramebuffers(1, &fbo);
+ glBindFramebuffer(GL_FRAMEBUFFER, fbo);
+ glFramebufferTexture2D(GL_FRAMEBUFFER,
+ GL_COLOR_ATTACHMENT0,
+ GL_TEXTURE_2D,
+ id,
+ 0);
+ EXPECT_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER));
+
+ uint32 texel;
+ glReadPixels(x, y, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &texel);
+
+ glBindFramebuffer(GL_FRAMEBUFFER, old_fbo);
+
+ glDeleteFramebuffers(1, &fbo);
+
+ return texel;
+}
+}
+
class GLTest : public testing::Test {
protected:
+ GLTest() : gl_(new gles2::MailboxManager, new gfx::GLShareGroup) {
+ }
+
virtual void SetUp() {
gl_.Initialize(gfx::Size(4, 4));
}
@@ -35,5 +69,51 @@
EXPECT_EQ(255u, pixels[3]);
}
+TEST_F(GLTest, ProduceAndConsumeTexture) {
Ken Russell (switch to Gerrit) 2012/04/26 01:10:53 Nice test!
+ GLManager gl2(gl_.mailbox_manager(), gl_.share_group());
+ gl2.Initialize(gfx::Size(1, 1));
+
+ char mailbox[32];
Ken Russell (switch to Gerrit) 2012/04/26 01:10:53 Really wish the "32" could be part of the type.
+ glGenMailboxCHROMIUM(mailbox);
+
+ gl_.MakeCurrent();
+
+ GLuint tex1;
+ glGenTextures(1, &tex1);
+
+ glBindTexture(GL_TEXTURE_2D, tex1);
+ uint32 source_pixel = 0xFF0000FF;
+ glTexImage2D(GL_TEXTURE_2D,
+ 0,
+ GL_RGBA,
+ 1, 1,
+ 0,
+ GL_RGBA,
+ GL_UNSIGNED_BYTE,
+ &source_pixel);
+
+ glProduceTextureCHROMIUM(GL_TEXTURE_2D, mailbox);
+ glFlush();
+
+ gl2.MakeCurrent();
+
+ GLuint tex2;
+ glGenTextures(1, &tex2);
+
+ glBindTexture(GL_TEXTURE_2D, tex2);
+ glConsumeTextureCHROMIUM(GL_TEXTURE_2D, mailbox);
+ EXPECT_EQ(source_pixel, ReadTexel(tex2, 0, 0));
+ glProduceTextureCHROMIUM(GL_TEXTURE_2D, mailbox);
+ glFlush();
+
+ gl_.MakeCurrent();
+
+ glBindTexture(GL_TEXTURE_2D, tex1);
+ glConsumeTextureCHROMIUM(GL_TEXTURE_2D, mailbox);
+ EXPECT_EQ(source_pixel, ReadTexel(tex1, 0, 0));
+
+ gl2.Destroy();
+}
+
} // namespace gpu

Powered by Google App Engine
This is Rietveld 408576698