EGL: default to swap interval 1

This change explicitly sets swap interval 1 on the window when an
EGLSurface is created to render to it.

Change-Id: I91eb29dbee3ae4a55076b921f084d503fbe94e03
This commit is contained in:
Jamie Gennis 2011-11-19 18:04:43 -08:00
parent 6f4cdfe0db
commit 59769469e4
4 changed files with 39 additions and 0 deletions

View File

@ -202,6 +202,10 @@ public:
// getCurrentScalingMode returns the scaling mode of the current buffer
uint32_t getCurrentScalingMode() const;
// isSynchronousMode returns whether the SurfaceTexture is currently in
// synchronous mode.
bool isSynchronousMode() const;
// abandon frees all the buffers and puts the SurfaceTexture into the
// 'abandoned' state. Once put in this state the SurfaceTexture can never
// leave it. When in the 'abandoned' state, all methods of the

View File

@ -1005,6 +1005,11 @@ uint32_t SurfaceTexture::getCurrentScalingMode() const {
return mCurrentScalingMode;
}
bool SurfaceTexture::isSynchronousMode() const {
Mutex::Autolock lock(mMutex);
return mSynchronousMode;
}
int SurfaceTexture::query(int what, int* outValue)
{
Mutex::Autolock lock(mMutex);

View File

@ -1245,6 +1245,31 @@ TEST_F(SurfaceTextureGLToGLTest, EglDestroySurfaceAfterAbandonUnrefsBuffers) {
EXPECT_EQ(1, buffers[2]->getStrongCount());
}
TEST_F(SurfaceTextureGLToGLTest, EglSurfaceDefaultsToSynchronousMode) {
// This test requires 3 buffers to run on a single thread.
mST->setBufferCountServer(3);
ASSERT_TRUE(mST->isSynchronousMode());
for (int i = 0; i < 10; i++) {
// Produce a frame
EXPECT_TRUE(eglMakeCurrent(mEglDisplay, mProducerEglSurface,
mProducerEglSurface, mProducerEglContext));
ASSERT_EQ(EGL_SUCCESS, eglGetError());
glClear(GL_COLOR_BUFFER_BIT);
EXPECT_TRUE(eglSwapBuffers(mEglDisplay, mProducerEglSurface));
ASSERT_EQ(EGL_SUCCESS, eglGetError());
// Consume a frame
EXPECT_TRUE(eglMakeCurrent(mEglDisplay, mEglSurface, mEglSurface,
mEglContext));
ASSERT_EQ(EGL_SUCCESS, eglGetError());
ASSERT_EQ(NO_ERROR, mST->updateTexImage());
}
ASSERT_TRUE(mST->isSynchronousMode());
}
/*
* 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

View File

@ -370,6 +370,11 @@ EGLSurface eglCreateWindowSurface( EGLDisplay dpy, EGLConfig config,
}
}
// the EGL spec requires that a new EGLSurface default to swap interval
// 1, so explicitly set that on the window here.
ANativeWindow* anw = reinterpret_cast<ANativeWindow*>(window);
anw->setSwapInterval(anw, 1);
EGLSurface surface = cnx->egl.eglCreateWindowSurface(
iDpy, iConfig, window, attrib_list);
if (surface != EGL_NO_SURFACE) {