Loading libs/hwui/FontRenderer.cpp +10 −2 Original line number Original line Diff line number Diff line Loading @@ -615,6 +615,8 @@ void FontRenderer::checkTextureUpdate() { return; return; } } Caches& caches = Caches::getInstance(); GLuint lastTextureId = 0; // Iterate over all the cache lines and see which ones need to be updated // Iterate over all the cache lines and see which ones need to be updated for (uint32_t i = 0; i < mCacheLines.size(); i++) { for (uint32_t i = 0; i < mCacheLines.size(); i++) { CacheTextureLine* cl = mCacheLines[i]; CacheTextureLine* cl = mCacheLines[i]; Loading @@ -626,7 +628,11 @@ void FontRenderer::checkTextureUpdate() { uint32_t height = cl->mMaxHeight; uint32_t height = cl->mMaxHeight; void* textureData = cacheTexture->mTexture + (yOffset * width); void* textureData = cacheTexture->mTexture + (yOffset * width); if (cacheTexture->mTextureId != lastTextureId) { caches.activeTexture(0); glBindTexture(GL_TEXTURE_2D, cacheTexture->mTextureId); glBindTexture(GL_TEXTURE_2D, cacheTexture->mTextureId); lastTextureId = cacheTexture->mTextureId; } glTexSubImage2D(GL_TEXTURE_2D, 0, xOffset, yOffset, width, height, glTexSubImage2D(GL_TEXTURE_2D, 0, xOffset, yOffset, width, height, GL_ALPHA, GL_UNSIGNED_BYTE, textureData); GL_ALPHA, GL_UNSIGNED_BYTE, textureData); Loading @@ -644,6 +650,7 @@ void FontRenderer::issueDrawCommand() { checkTextureUpdate(); checkTextureUpdate(); Caches& caches = Caches::getInstance(); Caches& caches = Caches::getInstance(); caches.bindIndicesBuffer(mIndexBufferID); if (!mDrawn) { if (!mDrawn) { float* buffer = mTextMeshPtr; float* buffer = mTextMeshPtr; int offset = 2; int offset = 2; Loading @@ -654,7 +661,6 @@ void FontRenderer::issueDrawCommand() { buffer + offset); buffer + offset); } } caches.bindIndicesBuffer(mIndexBufferID); glDrawElements(GL_TRIANGLES, mCurrentQuadIndex * 6, GL_UNSIGNED_SHORT, NULL); glDrawElements(GL_TRIANGLES, mCurrentQuadIndex * 6, GL_UNSIGNED_SHORT, NULL); mDrawn = true; mDrawn = true; Loading Loading @@ -779,6 +785,7 @@ FontRenderer::DropShadow FontRenderer::renderDropShadow(SkPaint* paint, const ch return image; return image; } } mDrawn = false; mClip = NULL; mClip = NULL; mBounds = NULL; mBounds = NULL; Loading Loading @@ -806,6 +813,7 @@ FontRenderer::DropShadow FontRenderer::renderDropShadow(SkPaint* paint, const ch image.image = dataBuffer; image.image = dataBuffer; image.penX = penX; image.penX = penX; image.penY = penY; image.penY = penY; return image; return image; } } Loading libs/hwui/OpenGLRenderer.cpp +4 −5 Original line number Original line Diff line number Diff line Loading @@ -1207,13 +1207,13 @@ void OpenGLRenderer::setupDrawSimpleMesh() { void OpenGLRenderer::setupDrawTexture(GLuint texture) { void OpenGLRenderer::setupDrawTexture(GLuint texture) { bindTexture(texture); bindTexture(texture); glUniform1i(mCaches.currentProgram->getUniform("sampler"), mTextureUnit++); mTextureUnit++; mCaches.enableTexCoordsVertexArray(); mCaches.enableTexCoordsVertexArray(); } } void OpenGLRenderer::setupDrawExternalTexture(GLuint texture) { void OpenGLRenderer::setupDrawExternalTexture(GLuint texture) { bindExternalTexture(texture); bindExternalTexture(texture); glUniform1i(mCaches.currentProgram->getUniform("sampler"), mTextureUnit++); mTextureUnit++; mCaches.enableTexCoordsVertexArray(); mCaches.enableTexCoordsVertexArray(); } } Loading Loading @@ -2128,6 +2128,8 @@ void OpenGLRenderer::drawText(const char* text, int bytesCount, int count, getAlphaAndMode(paint, &alpha, &mode); getAlphaAndMode(paint, &alpha, &mode); if (mHasShadow) { if (mHasShadow) { mCaches.activeTexture(0); mCaches.dropShadowCache.setFontRenderer(fontRenderer); mCaches.dropShadowCache.setFontRenderer(fontRenderer); const ShadowTexture* shadow = mCaches.dropShadowCache.get( const ShadowTexture* shadow = mCaches.dropShadowCache.get( paint, text, bytesCount, count, mShadowRadius); paint, text, bytesCount, count, mShadowRadius); Loading @@ -2142,7 +2144,6 @@ void OpenGLRenderer::drawText(const char* text, int bytesCount, int count, shadowColor = 0xffffffff; shadowColor = 0xffffffff; } } mCaches.activeTexture(0); setupDraw(); setupDraw(); setupDrawWithTexture(true); setupDrawWithTexture(true); setupDrawAlpha8Color(shadowColor, shadowAlpha < 255 ? shadowAlpha : alpha); setupDrawAlpha8Color(shadowColor, shadowAlpha < 255 ? shadowAlpha : alpha); Loading @@ -2158,8 +2159,6 @@ void OpenGLRenderer::drawText(const char* text, int bytesCount, int count, setupDrawMesh(NULL, (GLvoid*) gMeshTextureOffset); setupDrawMesh(NULL, (GLvoid*) gMeshTextureOffset); glDrawArrays(GL_TRIANGLE_STRIP, 0, gMeshCount); glDrawArrays(GL_TRIANGLE_STRIP, 0, gMeshCount); finishDrawTexture(); } } if (paint->getAlpha() == 0 && paint->getXfermode() == NULL) { if (paint->getAlpha() == 0 && paint->getXfermode() == NULL) { Loading libs/hwui/Program.cpp +5 −0 Original line number Original line Diff line number Diff line Loading @@ -29,6 +29,7 @@ namespace uirenderer { Program::Program(const ProgramDescription& description, const char* vertex, const char* fragment) { Program::Program(const ProgramDescription& description, const char* vertex, const char* fragment) { mInitialized = false; mInitialized = false; mHasColorUniform = false; mHasColorUniform = false; mHasSampler = false; mUse = false; mUse = false; // No need to cache compiled shaders, rely instead on Android's // No need to cache compiled shaders, rely instead on Android's Loading Loading @@ -176,6 +177,10 @@ void Program::setColor(const float r, const float g, const float b, const float void Program::use() { void Program::use() { glUseProgram(mProgramId); glUseProgram(mProgramId); if (texCoords >= 0 && !mHasSampler) { glUniform1i(getUniform("sampler"), 0); mHasSampler = true; } mUse = true; mUse = true; } } Loading libs/hwui/Program.h +2 −0 Original line number Original line Diff line number Diff line Loading @@ -398,6 +398,8 @@ private: bool mHasColorUniform; bool mHasColorUniform; int mColorUniform; int mColorUniform; bool mHasSampler; }; // class Program }; // class Program }; // namespace uirenderer }; // namespace uirenderer Loading Loading
libs/hwui/FontRenderer.cpp +10 −2 Original line number Original line Diff line number Diff line Loading @@ -615,6 +615,8 @@ void FontRenderer::checkTextureUpdate() { return; return; } } Caches& caches = Caches::getInstance(); GLuint lastTextureId = 0; // Iterate over all the cache lines and see which ones need to be updated // Iterate over all the cache lines and see which ones need to be updated for (uint32_t i = 0; i < mCacheLines.size(); i++) { for (uint32_t i = 0; i < mCacheLines.size(); i++) { CacheTextureLine* cl = mCacheLines[i]; CacheTextureLine* cl = mCacheLines[i]; Loading @@ -626,7 +628,11 @@ void FontRenderer::checkTextureUpdate() { uint32_t height = cl->mMaxHeight; uint32_t height = cl->mMaxHeight; void* textureData = cacheTexture->mTexture + (yOffset * width); void* textureData = cacheTexture->mTexture + (yOffset * width); if (cacheTexture->mTextureId != lastTextureId) { caches.activeTexture(0); glBindTexture(GL_TEXTURE_2D, cacheTexture->mTextureId); glBindTexture(GL_TEXTURE_2D, cacheTexture->mTextureId); lastTextureId = cacheTexture->mTextureId; } glTexSubImage2D(GL_TEXTURE_2D, 0, xOffset, yOffset, width, height, glTexSubImage2D(GL_TEXTURE_2D, 0, xOffset, yOffset, width, height, GL_ALPHA, GL_UNSIGNED_BYTE, textureData); GL_ALPHA, GL_UNSIGNED_BYTE, textureData); Loading @@ -644,6 +650,7 @@ void FontRenderer::issueDrawCommand() { checkTextureUpdate(); checkTextureUpdate(); Caches& caches = Caches::getInstance(); Caches& caches = Caches::getInstance(); caches.bindIndicesBuffer(mIndexBufferID); if (!mDrawn) { if (!mDrawn) { float* buffer = mTextMeshPtr; float* buffer = mTextMeshPtr; int offset = 2; int offset = 2; Loading @@ -654,7 +661,6 @@ void FontRenderer::issueDrawCommand() { buffer + offset); buffer + offset); } } caches.bindIndicesBuffer(mIndexBufferID); glDrawElements(GL_TRIANGLES, mCurrentQuadIndex * 6, GL_UNSIGNED_SHORT, NULL); glDrawElements(GL_TRIANGLES, mCurrentQuadIndex * 6, GL_UNSIGNED_SHORT, NULL); mDrawn = true; mDrawn = true; Loading Loading @@ -779,6 +785,7 @@ FontRenderer::DropShadow FontRenderer::renderDropShadow(SkPaint* paint, const ch return image; return image; } } mDrawn = false; mClip = NULL; mClip = NULL; mBounds = NULL; mBounds = NULL; Loading Loading @@ -806,6 +813,7 @@ FontRenderer::DropShadow FontRenderer::renderDropShadow(SkPaint* paint, const ch image.image = dataBuffer; image.image = dataBuffer; image.penX = penX; image.penX = penX; image.penY = penY; image.penY = penY; return image; return image; } } Loading
libs/hwui/OpenGLRenderer.cpp +4 −5 Original line number Original line Diff line number Diff line Loading @@ -1207,13 +1207,13 @@ void OpenGLRenderer::setupDrawSimpleMesh() { void OpenGLRenderer::setupDrawTexture(GLuint texture) { void OpenGLRenderer::setupDrawTexture(GLuint texture) { bindTexture(texture); bindTexture(texture); glUniform1i(mCaches.currentProgram->getUniform("sampler"), mTextureUnit++); mTextureUnit++; mCaches.enableTexCoordsVertexArray(); mCaches.enableTexCoordsVertexArray(); } } void OpenGLRenderer::setupDrawExternalTexture(GLuint texture) { void OpenGLRenderer::setupDrawExternalTexture(GLuint texture) { bindExternalTexture(texture); bindExternalTexture(texture); glUniform1i(mCaches.currentProgram->getUniform("sampler"), mTextureUnit++); mTextureUnit++; mCaches.enableTexCoordsVertexArray(); mCaches.enableTexCoordsVertexArray(); } } Loading Loading @@ -2128,6 +2128,8 @@ void OpenGLRenderer::drawText(const char* text, int bytesCount, int count, getAlphaAndMode(paint, &alpha, &mode); getAlphaAndMode(paint, &alpha, &mode); if (mHasShadow) { if (mHasShadow) { mCaches.activeTexture(0); mCaches.dropShadowCache.setFontRenderer(fontRenderer); mCaches.dropShadowCache.setFontRenderer(fontRenderer); const ShadowTexture* shadow = mCaches.dropShadowCache.get( const ShadowTexture* shadow = mCaches.dropShadowCache.get( paint, text, bytesCount, count, mShadowRadius); paint, text, bytesCount, count, mShadowRadius); Loading @@ -2142,7 +2144,6 @@ void OpenGLRenderer::drawText(const char* text, int bytesCount, int count, shadowColor = 0xffffffff; shadowColor = 0xffffffff; } } mCaches.activeTexture(0); setupDraw(); setupDraw(); setupDrawWithTexture(true); setupDrawWithTexture(true); setupDrawAlpha8Color(shadowColor, shadowAlpha < 255 ? shadowAlpha : alpha); setupDrawAlpha8Color(shadowColor, shadowAlpha < 255 ? shadowAlpha : alpha); Loading @@ -2158,8 +2159,6 @@ void OpenGLRenderer::drawText(const char* text, int bytesCount, int count, setupDrawMesh(NULL, (GLvoid*) gMeshTextureOffset); setupDrawMesh(NULL, (GLvoid*) gMeshTextureOffset); glDrawArrays(GL_TRIANGLE_STRIP, 0, gMeshCount); glDrawArrays(GL_TRIANGLE_STRIP, 0, gMeshCount); finishDrawTexture(); } } if (paint->getAlpha() == 0 && paint->getXfermode() == NULL) { if (paint->getAlpha() == 0 && paint->getXfermode() == NULL) { Loading
libs/hwui/Program.cpp +5 −0 Original line number Original line Diff line number Diff line Loading @@ -29,6 +29,7 @@ namespace uirenderer { Program::Program(const ProgramDescription& description, const char* vertex, const char* fragment) { Program::Program(const ProgramDescription& description, const char* vertex, const char* fragment) { mInitialized = false; mInitialized = false; mHasColorUniform = false; mHasColorUniform = false; mHasSampler = false; mUse = false; mUse = false; // No need to cache compiled shaders, rely instead on Android's // No need to cache compiled shaders, rely instead on Android's Loading Loading @@ -176,6 +177,10 @@ void Program::setColor(const float r, const float g, const float b, const float void Program::use() { void Program::use() { glUseProgram(mProgramId); glUseProgram(mProgramId); if (texCoords >= 0 && !mHasSampler) { glUniform1i(getUniform("sampler"), 0); mHasSampler = true; } mUse = true; mUse = true; } } Loading
libs/hwui/Program.h +2 −0 Original line number Original line Diff line number Diff line Loading @@ -398,6 +398,8 @@ private: bool mHasColorUniform; bool mHasColorUniform; int mColorUniform; int mColorUniform; bool mHasSampler; }; // class Program }; // class Program }; // namespace uirenderer }; // namespace uirenderer Loading