From 4a17ab642972f0049512de392b3c0299e3b8b5a1 Mon Sep 17 00:00:00 2001 From: Jacky Romano Date: Mon, 25 Apr 2011 17:31:38 +0300 Subject: [PATCH] emulator opengl - ensure server connection for rendering thread Ensure a server connection creation on make current, for cases where the context and surface was created on a seperate thread. In addition this commit publishes all the surface as ES2 capable if queried. Change-Id: Ie415b8ab3e370fa7fe97a526276e333aaa5e9e8b --- .../opengl/tests/gles_android_wrapper/egl.cpp | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/tools/emulator/opengl/tests/gles_android_wrapper/egl.cpp b/tools/emulator/opengl/tests/gles_android_wrapper/egl.cpp index f05ec30ff..1ee2b6a7a 100644 --- a/tools/emulator/opengl/tests/gles_android_wrapper/egl.cpp +++ b/tools/emulator/opengl/tests/gles_android_wrapper/egl.cpp @@ -406,7 +406,11 @@ EGLBoolean eglDestroySurface(EGLDisplay dpy, EGLSurface surface) EGLBoolean eglQuerySurface(EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint *value) { - return getDispatch()->eglQuerySurface(dpy, surface, attribute, value); + EGLBoolean res = getDispatch()->eglQuerySurface(dpy, surface, attribute, value); + if (res && attribute == EGL_RENDERABLE_TYPE) { + *value |= EGL_OPENGL_ES2_BIT; + } + return res; } EGLBoolean eglBindAPI(EGLenum api) @@ -508,8 +512,9 @@ EGLBoolean eglDestroyContext(EGLDisplay dpy, EGLContext ctx) res = getDispatch()->eglDestroyContext(dpy, wctx->aglContext); if (res) { EGLThreadInfo *ti = getEGLThreadInfo(); - if (s_needEncode && ti->serverConn) { - ti->serverConn->utEnc()->destroyContext(ti->serverConn->utEnc(), getpid(), (uint32_t)ctx); + ServerConnection *server; + if (s_needEncode && (server = ServerConnection::s_getServerConnection())) { + server->utEnc()->destroyContext(ti->serverConn->utEnc(), getpid(), (uint32_t)ctx); } if (ti->currentContext == wctx) ti->currentContext = NULL; delete wctx; @@ -526,14 +531,17 @@ EGLBoolean eglMakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLC EGLThreadInfo *ti = getEGLThreadInfo(); EGLBoolean res = getDispatch()->eglMakeCurrent(dpy, draw, read, aglContext); if (res ) { + // NOTE - we do get a pointer to the server connection, (rather then using ti->serverConn) + // for cases that this is the first egl call of the current thread. + ServerConnection *server; - if (s_needEncode && ti->serverConn) { - ti->serverConn->utEnc()->makeCurrentContext(ti->serverConn->utEnc(), getpid(), + if (s_needEncode && (server = ServerConnection::s_getServerConnection())) { + server->utEnc()->makeCurrentContext(server->utEnc(), getpid(), (uint32_t) (draw == EGL_NO_SURFACE ? 0 : draw), (uint32_t) (read == EGL_NO_SURFACE ? 0 : read), (uint32_t) (ctx == EGL_NO_CONTEXT ? 0 : ctx)); - ti->serverConn->glEncoder()->setClientState( wctx ? wctx->clientState : NULL ); - ti->serverConn->gl2Encoder()->setClientState( wctx ? wctx->clientState : NULL ); + server->glEncoder()->setClientState( wctx ? wctx->clientState : NULL ); + server->gl2Encoder()->setClientState( wctx ? wctx->clientState : NULL ); } // set current context in our thread info