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 f1833d89b..8ba7234f6 100644 --- a/tools/emulator/opengl/host/libs/Translator/GLES_CM/GLEScmImp.cpp +++ b/tools/emulator/opengl/host/libs/Translator/GLES_CM/GLEScmImp.cpp @@ -1682,6 +1682,7 @@ GL_API void GL_APIENTRY glEGLImageTargetTexture2DOES(GLenum target, GLeglImageOE texData->internalFormat = img->internalFormat; texData->sourceEGLImage = (unsigned int)image; texData->eglImageDetach = s_eglIface->eglDetachEGLImage; + texData->oldGlobal = oldGlobal; } } } diff --git a/tools/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Imp.cpp b/tools/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Imp.cpp index 3c48a434e..f5477823b 100644 --- a/tools/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Imp.cpp +++ b/tools/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Imp.cpp @@ -1,7 +1,7 @@ /* -* Copyright(C) 2011 The Android Open Source Project +* Copyright (C) 2011 The Android Open Source Project * -* Licensed under the Apache License, Version 2.0(the "License"){ GET_CTX();} +* Licensed under the Apache License, Version 2.0 (the "License") * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * @@ -2017,15 +2017,22 @@ GL_APICALL void GL_APIENTRY glEGLImageTargetTexture2DOES(GLenum target, GLeglIma 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); ctx->dispatcher().glBindTexture(GL_TEXTURE_2D, img->globalTexName); TextureData *texData = getTextureTargetData(target); SET_ERROR_IF(texData==NULL,GL_INVALID_OPERATION); + texData->width = img->width; + texData->height = img->height; + texData->border = img->border; + texData->internalFormat = img->internalFormat; texData->sourceEGLImage = (unsigned int)image; texData->eglImageDetach = s_eglIface->eglDetachEGLImage; texData->oldGlobal = oldGlobal;