From 40e9da0101e2c9afb6f823c7b21c02a011cc5300 Mon Sep 17 00:00:00 2001 From: Minkyoung Kim Date: Mon, 2 Jan 2017 15:29:48 +0900 Subject: [PATCH] Evas GL:Bind texture to correct one. Summary: If user bind textureA and want to use it continuously, do not call glBindTexture(textureA) again. But expect that textureA will be binding. So EvasGL sould not change binded texture silently. Restore texture to previous bound one after allocating new texture. And when destroy texture, reset texture to 0 if it is current bound texture. Test Plan: Tizen 3.0 Reviewers: wonsik, dkdk, cedric, jpeg Reviewed By: jpeg Differential Revision: https://phab.enlightenment.org/D4524 --- src/modules/evas/engines/gl_common/evas_gl_core.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/modules/evas/engines/gl_common/evas_gl_core.c b/src/modules/evas/engines/gl_common/evas_gl_core.c index 14d17f65c3..8292b5ce42 100644 --- a/src/modules/evas/engines/gl_common/evas_gl_core.c +++ b/src/modules/evas/engines/gl_common/evas_gl_core.c @@ -234,19 +234,26 @@ _texture_allocate_2d(GLuint tex, GLint ifmt, GLenum fmt, GLenum type, int w, int { //if (!(*tex)) // glGenTextures(1, tex); + GLint curr_tex = 0; + glGetIntegerv(GL_TEXTURE_BINDING_2D, &curr_tex); + glBindTexture(GL_TEXTURE_2D, tex); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexImage2D(GL_TEXTURE_2D, 0, ifmt, w, h, 0, fmt, type, NULL); - glBindTexture(GL_TEXTURE_2D, 0); + glBindTexture(GL_TEXTURE_2D, (GLuint)curr_tex); } // Destroy Texture static void _texture_destroy(GLuint *tex) { + GLint curr_tex = 0; + glGetIntegerv(GL_TEXTURE_BINDING_2D, &curr_tex); + + if ((GLuint)curr_tex == *tex) glBindTexture(GL_TEXTURE_2D, 0); if (*tex) { glDeleteTextures(1, tex);