From 91d4e8e195592dbc812441597118452f887ea07d Mon Sep 17 00:00:00 2001 From: Jesse Hall Date: Tue, 14 Feb 2012 14:06:02 -0800 Subject: [PATCH] GLESv2 translator: don't delete EGLImage textures Copy changes faaf1553cfa39c23ceb198ba7edbd46ff3a11f7a and f37a7ed6c5c609a3afc33f81bf50893362917ae6 from the GLESv1 translator to the GLESv2 translator. After this, both translators use the same logic for glEGLImageTargetTexture2DOES(). Change-Id: I0a95bf2301df7b7428abc593f38170edf4cbda30 --- .../host/libs/Translator/GLES_CM/GLEScmImp.cpp | 1 + .../host/libs/Translator/GLES_V2/GLESv2Imp.cpp | 15 +++++++++++---- 2 files changed, 12 insertions(+), 4 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 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;