Skip to content
Commit b4093c12 authored by Fred Fettinger's avatar Fred Fettinger Committed by Chris Craik
Browse files

hwui: Caches: use mBoundTextures only for GL_TEXTURE_2D - DO NOT MERGE



Cherry-picked into klp-modular-dev.

bug:17441218

GLConsumer uses glBindTexture() directly instead of going through
Caches::bindTexture(). This can cause libhwui to draw with the wrong
texture bound in the following case which involves 2 TextureViews:

Frame 1:
GLConsumer::updateTexImage() calls glBindTexture(GL_TEXTURE_EXTERNAL_OES, 1)
HWUI renders TextureView A:
    calls Caches::bindTexture(GL_TEXTURE_EXTERNAL_OES, 1) and draws

Frame 2:
GLConsumer::updateTexImage() calls glBindTexture(GL_TEXTURE_EXTERNAL_OES, 1)
GLConsumer::updateTexImage() calls glBindTexture(GL_TEXTURE_EXTERNAL_OES, 2)
HWUI renders TextureView A:
    calls Caches::bindTexture(GL_TEXTURE_EXTERNAL_OES, 1) and draws
HWUI renders TextureView B:
    calls Caches::bindTexture(GL_TEXTURE_EXTERNAL_OES, 2) and draws

In this case, HWUI will incorrectly draw TextureView A using texture 2 on
frame 2, because mBoundTextures[0]=1, even though the texture currently
bound to GL_TEXTURE_EXTERNAL_OES is 2.

Since GLConsumer is always used with a target of GL_TEXTURE_EXTERNAL_OES,
work around this problem by having mBoundTextures[] store only the
textures bound to the target GL_TEXTURE_2D. This is the common case
where the extra performance is needed. Since it's legal to have
different textures bound to GL_TEXTURE_2D and GL_TEXTURE_EXTERNAL_OES
on one texture unit, Caches::bindTexture() does not need to clear
mBoundTextures[mTextureUnit] when target != GL_TEXTURE_2D.

Change-Id: I8bc54ab8adcfacad7f3ed17a31236dc7a86c967a
Signed-off-by: default avatarFred Fettinger <fred.fettinger@motorola.com>
(cherry picked from commit e4de36bbc2baf13206deb53ced39f0befadb1861)
parent 63cd4977
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment