From 3e3ba155fc0ef7a7f40f06762240d9ba22f62b19 Mon Sep 17 00:00:00 2001 From: Romain Guy Date: Mon, 25 Oct 2010 18:33:16 -0700 Subject: [PATCH] Don't change texture unit when not needed. Change-Id: Ifa84426d234f2122402cb13533cb5964f1ce95ec --- libs/hwui/OpenGLRenderer.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/libs/hwui/OpenGLRenderer.cpp b/libs/hwui/OpenGLRenderer.cpp index 9c37983fbb0b9..859251186b28d 100644 --- a/libs/hwui/OpenGLRenderer.cpp +++ b/libs/hwui/OpenGLRenderer.cpp @@ -1391,16 +1391,19 @@ void OpenGLRenderer::bindTexture(GLuint texture, GLuint textureUnit) { void OpenGLRenderer::setTextureWrapModes(Texture* texture, GLenum wrapS, GLenum wrapT, GLuint textureUnit) { - glActiveTexture(gTextureUnits[textureUnit]); bool bound = false; if (wrapS != texture->wrapS) { + glActiveTexture(gTextureUnits[textureUnit]); glBindTexture(GL_TEXTURE_2D, texture->id); bound = true; glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, wrapS); texture->wrapS = wrapS; } if (wrapT != texture->wrapT) { - if (!bound) glBindTexture(GL_TEXTURE_2D, texture->id); + if (!bound) { + glActiveTexture(gTextureUnits[textureUnit]); + glBindTexture(GL_TEXTURE_2D, texture->id); + } glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, wrapT); texture->wrapT = wrapT; }