diff options
author | Romain Guy <romainguy@google.com> | 2012-06-11 16:03:47 -0700 |
---|---|---|
committer | Romain Guy <romainguy@google.com> | 2012-06-11 16:11:56 -0700 |
commit | 16c88085255c71a1a8fc034129aa2dcc61e1ddd0 (patch) | |
tree | d582a3cff3847c2befee35dccd94d2b1e02b018c /libs/hwui | |
parent | 527ee91b60426b5a344e9905c7f9a14d6d26219e (diff) | |
download | frameworks_base-16c88085255c71a1a8fc034129aa2dcc61e1ddd0.zip frameworks_base-16c88085255c71a1a8fc034129aa2dcc61e1ddd0.tar.gz frameworks_base-16c88085255c71a1a8fc034129aa2dcc61e1ddd0.tar.bz2 |
Textured text calls could be invisible
Bug #6597730
Text would sometimes not appear when rendered with textured content
(BitmapShader, LinearGradientShader, etc.) This was due to a misuse
of OpenGL texture unit in FontRenderer. Textured text normally uses
two texture units:
- texture unit 0 for the font cache
- texture unit 1 for the textured content (gradient, etc.)
Recent changes to the font renderer allow it to bind new textures
while processing the text's geometry (this happens when caches get
full or when switching font size for instance.) The bindings were
done without ensuring the texture unit was the correct one
(unit 0), thus replacing the content of another texture unit
(unit 1).
This lead to text being drawn using the font cache itself as the
content texture, making the text invisible.
Change-Id: I392b4c884f09223305f6cbc6253e2ef9a98944c9
Diffstat (limited to 'libs/hwui')
-rw-r--r-- | libs/hwui/FontRenderer.cpp | 2 | ||||
-rw-r--r-- | libs/hwui/OpenGLRenderer.cpp | 3 |
2 files changed, 5 insertions, 0 deletions
diff --git a/libs/hwui/FontRenderer.cpp b/libs/hwui/FontRenderer.cpp index a0bf8e3..0d6e62a 100644 --- a/libs/hwui/FontRenderer.cpp +++ b/libs/hwui/FontRenderer.cpp @@ -598,6 +598,7 @@ void FontRenderer::allocateTextureMemory(CacheTexture* cacheTexture) { glGenTextures(1, &cacheTexture->mTextureId); } + Caches::getInstance().activeTexture(0); glBindTexture(GL_TEXTURE_2D, cacheTexture->mTextureId); glPixelStorei(GL_UNPACK_ALIGNMENT, 1); // Initialize texture dimensions @@ -826,6 +827,7 @@ void FontRenderer::checkTextureUpdate() { } } + caches.activeTexture(0); glBindTexture(GL_TEXTURE_2D, mCurrentCacheTexture->mTextureId); if (mLinearFiltering != mCurrentCacheTexture->mLinearFiltering) { const GLenum filtering = mLinearFiltering ? GL_LINEAR : GL_NEAREST; diff --git a/libs/hwui/OpenGLRenderer.cpp b/libs/hwui/OpenGLRenderer.cpp index 0d857bf..c92bead 100644 --- a/libs/hwui/OpenGLRenderer.cpp +++ b/libs/hwui/OpenGLRenderer.cpp @@ -2422,6 +2422,7 @@ status_t OpenGLRenderer::drawText(const char* text, int bytesCount, int count, linearFilter = fabs(y - (int) y) > 0.0f || fabs(x - (int) x) > 0.0f; } + // The font renderer will always use texture unit 0 mCaches.activeTexture(0); setupDraw(); setupDrawDirtyRegionsDisabled(); @@ -2432,6 +2433,8 @@ status_t OpenGLRenderer::drawText(const char* text, int bytesCount, int count, setupDrawBlending(true, mode); setupDrawProgram(); setupDrawModelView(x, y, x, y, pureTranslate, true); + // See comment above; the font renderer must use texture unit 0 + // assert(mTextureUnit == 0) setupDrawTexture(fontRenderer.getTexture(linearFilter)); setupDrawPureColorUniforms(); setupDrawColorFilterUniforms(); |