From f37a7ed6c5c609a3afc33f81bf50893362917ae6 Mon Sep 17 00:00:00 2001 From: Jesse Hall Date: Fri, 18 Nov 2011 14:05:26 -0800 Subject: [PATCH] GLES translator: don't delete EGLImage textures When remapping a GLES texture to a different GL texture in glEGLImageTargetTexture2DOES(), the GLES texture's previous GL texture was deleted unconditionally. This is bad when it came from an EGLImage and is therefore owned by (and will continue to be used by) some other object. The code now skips deleting the old GL texture if it came from an EGLImage. This mirrors the logic in glDeleteTextures(). Change-Id: I5b650334a7019d824517c2915b1f23961fbbd809 --- .../opengl/host/libs/Translator/GLES_CM/GLEScmImp.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tools/emulator/opengl/host/libs/Translator/GLES_CM/GLEScmImp.cpp b/tools/emulator/opengl/host/libs/Translator/GLES_CM/GLEScmImp.cpp index 903ddac48..f1833d89b 100644 --- a/tools/emulator/opengl/host/libs/Translator/GLES_CM/GLEScmImp.cpp +++ b/tools/emulator/opengl/host/libs/Translator/GLES_CM/GLEScmImp.cpp @@ -1664,9 +1664,12 @@ GL_API void GL_APIENTRY glEGLImageTargetTexture2DOES(GLenum target, GLeglImageOE if (ctx->shareGroup().Ptr()) { ObjectLocalName tex = TextureLocalName(target,ctx->getBindedTexture(target)); unsigned int oldGlobal = ctx->shareGroup()->getGlobalName(TEXTURE, tex); - // Delete old texture object + // Delete old texture object but only if it is not a target of a EGLImage if (oldGlobal) { - ctx->dispatcher().glDeleteTextures(1, &oldGlobal); + TextureData* oldTexData = getTextureData(tex); + if (!oldTexData || oldTexData->sourceEGLImage == 0) { + ctx->dispatcher().glDeleteTextures(1, &oldGlobal); + } } // replace mapping and bind the new global object ctx->shareGroup()->replaceGlobalName(TEXTURE, tex,img->globalTexName);