summaryrefslogtreecommitdiffstats
path: root/libs/gui
diff options
context:
space:
mode:
authorJamie Gennis <jgennis@google.com>2012-04-11 17:20:03 -0700
committerJamie Gennis <jgennis@google.com>2012-04-11 18:37:54 -0700
commitc2c380259b2a3fbe7cee1dbd3f2e1e23e9ffd5da (patch)
treecc52a364b4304a75a8d076c9c776b43a3e729877 /libs/gui
parent55a701459de964ae3504264a6b8c4dc37f54a9e8 (diff)
downloadframeworks_native-c2c380259b2a3fbe7cee1dbd3f2e1e23e9ffd5da.zip
frameworks_native-c2c380259b2a3fbe7cee1dbd3f2e1e23e9ffd5da.tar.gz
frameworks_native-c2c380259b2a3fbe7cee1dbd3f2e1e23e9ffd5da.tar.bz2
SurfaceTexture: add a test for user sizes & prerotation
This change adds 3 tests for: - User-overridden buffer size - Transform hint - User-overridden buffer size with transform hint Change-Id: Ib15ea354685e436822c506099613b2bffa7b68c9
Diffstat (limited to 'libs/gui')
-rw-r--r--libs/gui/tests/SurfaceTexture_test.cpp167
1 files changed, 167 insertions, 0 deletions
diff --git a/libs/gui/tests/SurfaceTexture_test.cpp b/libs/gui/tests/SurfaceTexture_test.cpp
index 3009093..3a5917f 100644
--- a/libs/gui/tests/SurfaceTexture_test.cpp
+++ b/libs/gui/tests/SurfaceTexture_test.cpp
@@ -1476,6 +1476,173 @@ TEST_F(SurfaceTextureGLToGLTest, EglSurfaceDefaultsToSynchronousMode) {
ASSERT_TRUE(mST->isSynchronousMode());
}
+TEST_F(SurfaceTextureGLToGLTest, TexturingFromUserSizedGLFilledBuffer) {
+ enum { texWidth = 64 };
+ enum { texHeight = 64 };
+
+ // Set the user buffer size.
+ native_window_set_buffers_user_dimensions(mANW.get(), texWidth, texHeight);
+
+ // Do the producer side of things
+ EXPECT_TRUE(eglMakeCurrent(mEglDisplay, mProducerEglSurface,
+ mProducerEglSurface, mProducerEglContext));
+ ASSERT_EQ(EGL_SUCCESS, eglGetError());
+
+ // This is needed to ensure we pick up a buffer of the correct size.
+ eglSwapBuffers(mEglDisplay, mProducerEglSurface);
+
+ glClearColor(0.6, 0.6, 0.6, 0.6);
+ glClear(GL_COLOR_BUFFER_BIT);
+
+ glEnable(GL_SCISSOR_TEST);
+ glScissor(4, 4, 1, 1);
+ glClearColor(1.0, 0.0, 0.0, 1.0);
+ glClear(GL_COLOR_BUFFER_BIT);
+
+ eglSwapBuffers(mEglDisplay, mProducerEglSurface);
+
+ // Do the consumer side of things
+ EXPECT_TRUE(eglMakeCurrent(mEglDisplay, mEglSurface, mEglSurface,
+ mEglContext));
+ ASSERT_EQ(EGL_SUCCESS, eglGetError());
+
+ glDisable(GL_SCISSOR_TEST);
+
+ mST->updateTexImage(); // Skip the first frame, which was empty
+ mST->updateTexImage();
+
+ glClearColor(0.2, 0.2, 0.2, 0.2);
+ glClear(GL_COLOR_BUFFER_BIT);
+
+ glViewport(0, 0, texWidth, texHeight);
+ drawTexture();
+
+ EXPECT_TRUE(checkPixel( 0, 0, 153, 153, 153, 153));
+ EXPECT_TRUE(checkPixel(63, 0, 153, 153, 153, 153));
+ EXPECT_TRUE(checkPixel(63, 63, 153, 153, 153, 153));
+ EXPECT_TRUE(checkPixel( 0, 63, 153, 153, 153, 153));
+
+ EXPECT_TRUE(checkPixel( 4, 4, 255, 0, 0, 255));
+ EXPECT_TRUE(checkPixel( 5, 5, 153, 153, 153, 153));
+ EXPECT_TRUE(checkPixel( 3, 3, 153, 153, 153, 153));
+ EXPECT_TRUE(checkPixel(45, 52, 153, 153, 153, 153));
+ EXPECT_TRUE(checkPixel(12, 36, 153, 153, 153, 153));
+}
+
+TEST_F(SurfaceTextureGLToGLTest, TexturingFromPreRotatedUserSizedGLFilledBuffer) {
+ enum { texWidth = 64 };
+ enum { texHeight = 16 };
+
+ // Set the transform hint.
+ mST->setTransformHint(NATIVE_WINDOW_TRANSFORM_ROT_90);
+
+ // Set the user buffer size.
+ native_window_set_buffers_user_dimensions(mANW.get(), texWidth, texHeight);
+
+ // Do the producer side of things
+ EXPECT_TRUE(eglMakeCurrent(mEglDisplay, mProducerEglSurface,
+ mProducerEglSurface, mProducerEglContext));
+ ASSERT_EQ(EGL_SUCCESS, eglGetError());
+
+ // This is needed to ensure we pick up a buffer of the correct size and the
+ // new rotation hint.
+ eglSwapBuffers(mEglDisplay, mProducerEglSurface);
+
+ glClearColor(0.6, 0.6, 0.6, 0.6);
+ glClear(GL_COLOR_BUFFER_BIT);
+
+ glEnable(GL_SCISSOR_TEST);
+ glScissor(24, 4, 1, 1);
+ glClearColor(1.0, 0.0, 0.0, 1.0);
+ glClear(GL_COLOR_BUFFER_BIT);
+
+ eglSwapBuffers(mEglDisplay, mProducerEglSurface);
+
+ // Do the consumer side of things
+ EXPECT_TRUE(eglMakeCurrent(mEglDisplay, mEglSurface, mEglSurface,
+ mEglContext));
+ ASSERT_EQ(EGL_SUCCESS, eglGetError());
+
+ glDisable(GL_SCISSOR_TEST);
+
+ mST->updateTexImage(); // Skip the first frame, which was empty
+ mST->updateTexImage();
+
+ glClearColor(0.2, 0.2, 0.2, 0.2);
+ glClear(GL_COLOR_BUFFER_BIT);
+
+ glViewport(0, 0, texWidth, texHeight);
+ drawTexture();
+
+ EXPECT_TRUE(checkPixel( 0, 0, 153, 153, 153, 153));
+ EXPECT_TRUE(checkPixel(63, 0, 153, 153, 153, 153));
+ EXPECT_TRUE(checkPixel(63, 15, 153, 153, 153, 153));
+ EXPECT_TRUE(checkPixel( 0, 15, 153, 153, 153, 153));
+
+ EXPECT_TRUE(checkPixel(24, 4, 255, 0, 0, 255));
+ EXPECT_TRUE(checkPixel(25, 5, 153, 153, 153, 153));
+ EXPECT_TRUE(checkPixel(23, 3, 153, 153, 153, 153));
+ EXPECT_TRUE(checkPixel(45, 13, 153, 153, 153, 153));
+ EXPECT_TRUE(checkPixel(12, 8, 153, 153, 153, 153));
+}
+
+TEST_F(SurfaceTextureGLToGLTest, TexturingFromPreRotatedGLFilledBuffer) {
+ enum { texWidth = 64 };
+ enum { texHeight = 16 };
+
+ // Set the transform hint.
+ mST->setTransformHint(NATIVE_WINDOW_TRANSFORM_ROT_90);
+
+ // Set the default buffer size.
+ mST->setDefaultBufferSize(texWidth, texHeight);
+
+ // Do the producer side of things
+ EXPECT_TRUE(eglMakeCurrent(mEglDisplay, mProducerEglSurface,
+ mProducerEglSurface, mProducerEglContext));
+ ASSERT_EQ(EGL_SUCCESS, eglGetError());
+
+ // This is needed to ensure we pick up a buffer of the correct size and the
+ // new rotation hint.
+ eglSwapBuffers(mEglDisplay, mProducerEglSurface);
+
+ glClearColor(0.6, 0.6, 0.6, 0.6);
+ glClear(GL_COLOR_BUFFER_BIT);
+
+ glEnable(GL_SCISSOR_TEST);
+ glScissor(24, 4, 1, 1);
+ glClearColor(1.0, 0.0, 0.0, 1.0);
+ glClear(GL_COLOR_BUFFER_BIT);
+
+ eglSwapBuffers(mEglDisplay, mProducerEglSurface);
+
+ // Do the consumer side of things
+ EXPECT_TRUE(eglMakeCurrent(mEglDisplay, mEglSurface, mEglSurface,
+ mEglContext));
+ ASSERT_EQ(EGL_SUCCESS, eglGetError());
+
+ glDisable(GL_SCISSOR_TEST);
+
+ mST->updateTexImage(); // Skip the first frame, which was empty
+ mST->updateTexImage();
+
+ glClearColor(0.2, 0.2, 0.2, 0.2);
+ glClear(GL_COLOR_BUFFER_BIT);
+
+ glViewport(0, 0, texWidth, texHeight);
+ drawTexture();
+
+ EXPECT_TRUE(checkPixel( 0, 0, 153, 153, 153, 153));
+ EXPECT_TRUE(checkPixel(63, 0, 153, 153, 153, 153));
+ EXPECT_TRUE(checkPixel(63, 15, 153, 153, 153, 153));
+ EXPECT_TRUE(checkPixel( 0, 15, 153, 153, 153, 153));
+
+ EXPECT_TRUE(checkPixel(24, 4, 255, 0, 0, 255));
+ EXPECT_TRUE(checkPixel(25, 5, 153, 153, 153, 153));
+ EXPECT_TRUE(checkPixel(23, 3, 153, 153, 153, 153));
+ EXPECT_TRUE(checkPixel(45, 13, 153, 153, 153, 153));
+ EXPECT_TRUE(checkPixel(12, 8, 153, 153, 153, 153));
+}
+
/*
* This test fixture is for testing GL -> GL texture streaming from one thread
* to another. It contains functionality to create a producer thread that will