summaryrefslogtreecommitdiffstats
path: root/opengl/system/egl
diff options
context:
space:
mode:
authorbohu <bohu@google.com>2014-11-25 16:50:37 -0800
committerbohu <bohu@google.com>2014-11-26 14:31:35 -0800
commit4f9ec3916ac526dca9ddf2781d26340fe1f18015 (patch)
tree0c31a968e124cdba798eda6a34530c02603b492a /opengl/system/egl
parentc2f8474518a220b3c1b86b6d4f9fa28ed9bb734a (diff)
downloadandroid_device_generic_goldfish-4f9ec3916ac526dca9ddf2781d26340fe1f18015.tar.gz
android_device_generic_goldfish-4f9ec3916ac526dca9ddf2781d26340fe1f18015.tar.bz2
android_device_generic_goldfish-4f9ec3916ac526dca9ddf2781d26340fe1f18015.zip
Fix eglDestroyContext and glTexImage2D
1. When destroy context that is in use, EGL spec says: "If the EGL rendering context context is not current to any thread, eglDestroyContext destroys it immediately. Otherwise, context is destroyed when it becomes not current to any thread." 2. When calling glTexImage2D, should bind the correct texture first. Change-Id: I6c779b71d1e6002b8a484477921ba323acbd986e
Diffstat (limited to 'opengl/system/egl')
-rw-r--r--opengl/system/egl/egl.cpp22
-rw-r--r--opengl/system/egl/eglContext.h2
2 files changed, 18 insertions, 6 deletions
diff --git a/opengl/system/egl/egl.cpp b/opengl/system/egl/egl.cpp
index 1ad91ff..8499229 100644
--- a/opengl/system/egl/egl.cpp
+++ b/opengl/system/egl/egl.cpp
@@ -140,7 +140,8 @@ EGLContext_t::EGLContext_t(EGLDisplay dpy, EGLConfig config, EGLContext_t* share
versionString(NULL),
vendorString(NULL),
rendererString(NULL),
- extensionString(NULL)
+ extensionString(NULL),
+ deletePending(0)
{
flags = 0;
version = 1;
@@ -915,9 +916,11 @@ EGLBoolean eglDestroyContext(EGLDisplay dpy, EGLContext ctx)
EGLContext_t * context = static_cast<EGLContext_t*>(ctx);
- if (getEGLThreadInfo()->currentContext == context)
- {
- eglMakeCurrent(dpy, EGL_NO_CONTEXT, EGL_NO_SURFACE, EGL_NO_SURFACE);
+ if (!context) return EGL_TRUE;
+
+ if (getEGLThreadInfo()->currentContext == context) {
+ getEGLThreadInfo()->currentContext->deletePending = 1;
+ return EGL_TRUE;
}
if (context->rcContext) {
@@ -952,12 +955,21 @@ EGLBoolean eglMakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLC
// Nothing to do if no binding change has made
//
EGLThreadInfo *tInfo = getEGLThreadInfo();
+
if (tInfo->currentContext == context &&
(context == NULL ||
(context && context->draw == draw && context->read == read))) {
return EGL_TRUE;
}
+ if (tInfo->currentContext && tInfo->currentContext->deletePending) {
+ if (tInfo->currentContext != context) {
+ EGLContext_t * contextToDelete = tInfo->currentContext;
+ tInfo->currentContext = 0;
+ eglDestroyContext(dpy, contextToDelete);
+ }
+ }
+
if (context && (context->flags & EGLContext_t::IS_CURRENT) && (context != tInfo->currentContext)) {
//context is current to another thread
setErrorReturn(EGL_BAD_ACCESS, EGL_FALSE);
@@ -984,7 +996,7 @@ EGLBoolean eglMakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLC
hostCon->glEncoder()->setSharedGroup(context->getSharedGroup());
}
}
- else {
+ else if (tInfo->currentContext) {
//release ClientState & SharedGroup
if (tInfo->currentContext->version == 2) {
hostCon->gl2Encoder()->setClientState(NULL);
diff --git a/opengl/system/egl/eglContext.h b/opengl/system/egl/eglContext.h
index 2ca6d0c..16a2780 100644
--- a/opengl/system/egl/eglContext.h
+++ b/opengl/system/egl/eglContext.h
@@ -40,7 +40,7 @@ struct EGLContext_t {
const char* vendorString;
const char* rendererString;
const char* extensionString;
-
+ EGLint deletePending;
GLClientState * getClientState(){ return clientState; }
GLSharedGroupPtr getSharedGroup(){ return sharedGroup; }
private: