Loading libs/hwui/FontRenderer.cpp +9 −7 Original line number Original line Diff line number Diff line Loading @@ -316,6 +316,8 @@ FontRenderer::FontRenderer() { mTextTexture = NULL; mTextTexture = NULL; mIndexBufferID = 0; mIndexBufferID = 0; mPositionAttrSlot = -1; mTexcoordAttrSlot = -1; mCacheWidth = DEFAULT_TEXT_CACHE_WIDTH; mCacheWidth = DEFAULT_TEXT_CACHE_WIDTH; mCacheHeight = DEFAULT_TEXT_CACHE_HEIGHT; mCacheHeight = DEFAULT_TEXT_CACHE_HEIGHT; Loading Loading @@ -565,13 +567,8 @@ void FontRenderer::issueDrawCommand() { float* vtx = mTextMeshPtr; float* vtx = mTextMeshPtr; float* tex = vtx + 3; float* tex = vtx + 3; // position is slot 0 glVertexAttribPointer(mPositionAttrSlot, 3, GL_FLOAT, false, 20, vtx); uint32_t slot = 0; glVertexAttribPointer(mTexcoordAttrSlot, 2, GL_FLOAT, false, 20, tex); glVertexAttribPointer(slot, 3, GL_FLOAT, false, 20, vtx); // texture0 is slot 1 slot = 1; glVertexAttribPointer(slot, 2, GL_FLOAT, false, 20, tex); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, mIndexBufferID); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, mIndexBufferID); glDrawElements(GL_TRIANGLES, mCurrentQuadIndex * 6, GL_UNSIGNED_SHORT, NULL); glDrawElements(GL_TRIANGLES, mCurrentQuadIndex * 6, GL_UNSIGNED_SHORT, NULL); Loading Loading @@ -718,6 +715,11 @@ bool FontRenderer::renderText(SkPaint* paint, const Rect* clip, const char *text return false; return false; } } if (mPositionAttrSlot < 0 || mTexcoordAttrSlot < 0) { LOGE("Font renderer unable to draw, attribute slots undefined"); return false; } mDrawn = false; mDrawn = false; mBounds = bounds; mBounds = bounds; mClip = clip; mClip = clip; Loading libs/hwui/FontRenderer.h +8 −0 Original line number Original line Diff line number Diff line Loading @@ -138,6 +138,11 @@ public: mGammaTable = gammaTable; mGammaTable = gammaTable; } } void setAttributeBindingSlots(int positionSlot, int texCoordSlot) { mPositionAttrSlot = positionSlot; mTexcoordAttrSlot = texCoordSlot; } void setFont(SkPaint* paint, uint32_t fontId, float fontSize); void setFont(SkPaint* paint, uint32_t fontId, float fontSize); bool renderText(SkPaint* paint, const Rect* clip, const char *text, uint32_t startIndex, bool renderText(SkPaint* paint, const Rect* clip, const char *text, uint32_t startIndex, uint32_t len, int numGlyphs, int x, int y, Rect* bounds); uint32_t len, int numGlyphs, int x, int y, Rect* bounds); Loading Loading @@ -263,6 +268,9 @@ protected: uint32_t mIndexBufferID; uint32_t mIndexBufferID; int32_t mPositionAttrSlot; int32_t mTexcoordAttrSlot; const Rect* mClip; const Rect* mClip; Rect* mBounds; Rect* mBounds; bool mDrawn; bool mDrawn; Loading libs/hwui/OpenGLRenderer.cpp +5 −1 Original line number Original line Diff line number Diff line Loading @@ -1585,8 +1585,12 @@ void OpenGLRenderer::drawText(const char* text, int bytesCount, int count, #else #else bool hasActiveLayer = false; bool hasActiveLayer = false; #endif #endif mCaches.unbindMeshBuffer(); mCaches.unbindMeshBuffer(); // Tell font renderer the locations of position and texture coord // attributes so it can bind its data properly int positionSlot = mCaches.currentProgram->position; fontRenderer.setAttributeBindingSlots(positionSlot, mTexCoordsSlot); if (fontRenderer.renderText(paint, clip, text, 0, bytesCount, count, x, y, if (fontRenderer.renderText(paint, clip, text, 0, bytesCount, count, x, y, hasActiveLayer ? &bounds : NULL)) { hasActiveLayer ? &bounds : NULL)) { #if RENDER_LAYERS_AS_REGIONS #if RENDER_LAYERS_AS_REGIONS Loading Loading
libs/hwui/FontRenderer.cpp +9 −7 Original line number Original line Diff line number Diff line Loading @@ -316,6 +316,8 @@ FontRenderer::FontRenderer() { mTextTexture = NULL; mTextTexture = NULL; mIndexBufferID = 0; mIndexBufferID = 0; mPositionAttrSlot = -1; mTexcoordAttrSlot = -1; mCacheWidth = DEFAULT_TEXT_CACHE_WIDTH; mCacheWidth = DEFAULT_TEXT_CACHE_WIDTH; mCacheHeight = DEFAULT_TEXT_CACHE_HEIGHT; mCacheHeight = DEFAULT_TEXT_CACHE_HEIGHT; Loading Loading @@ -565,13 +567,8 @@ void FontRenderer::issueDrawCommand() { float* vtx = mTextMeshPtr; float* vtx = mTextMeshPtr; float* tex = vtx + 3; float* tex = vtx + 3; // position is slot 0 glVertexAttribPointer(mPositionAttrSlot, 3, GL_FLOAT, false, 20, vtx); uint32_t slot = 0; glVertexAttribPointer(mTexcoordAttrSlot, 2, GL_FLOAT, false, 20, tex); glVertexAttribPointer(slot, 3, GL_FLOAT, false, 20, vtx); // texture0 is slot 1 slot = 1; glVertexAttribPointer(slot, 2, GL_FLOAT, false, 20, tex); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, mIndexBufferID); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, mIndexBufferID); glDrawElements(GL_TRIANGLES, mCurrentQuadIndex * 6, GL_UNSIGNED_SHORT, NULL); glDrawElements(GL_TRIANGLES, mCurrentQuadIndex * 6, GL_UNSIGNED_SHORT, NULL); Loading Loading @@ -718,6 +715,11 @@ bool FontRenderer::renderText(SkPaint* paint, const Rect* clip, const char *text return false; return false; } } if (mPositionAttrSlot < 0 || mTexcoordAttrSlot < 0) { LOGE("Font renderer unable to draw, attribute slots undefined"); return false; } mDrawn = false; mDrawn = false; mBounds = bounds; mBounds = bounds; mClip = clip; mClip = clip; Loading
libs/hwui/FontRenderer.h +8 −0 Original line number Original line Diff line number Diff line Loading @@ -138,6 +138,11 @@ public: mGammaTable = gammaTable; mGammaTable = gammaTable; } } void setAttributeBindingSlots(int positionSlot, int texCoordSlot) { mPositionAttrSlot = positionSlot; mTexcoordAttrSlot = texCoordSlot; } void setFont(SkPaint* paint, uint32_t fontId, float fontSize); void setFont(SkPaint* paint, uint32_t fontId, float fontSize); bool renderText(SkPaint* paint, const Rect* clip, const char *text, uint32_t startIndex, bool renderText(SkPaint* paint, const Rect* clip, const char *text, uint32_t startIndex, uint32_t len, int numGlyphs, int x, int y, Rect* bounds); uint32_t len, int numGlyphs, int x, int y, Rect* bounds); Loading Loading @@ -263,6 +268,9 @@ protected: uint32_t mIndexBufferID; uint32_t mIndexBufferID; int32_t mPositionAttrSlot; int32_t mTexcoordAttrSlot; const Rect* mClip; const Rect* mClip; Rect* mBounds; Rect* mBounds; bool mDrawn; bool mDrawn; Loading
libs/hwui/OpenGLRenderer.cpp +5 −1 Original line number Original line Diff line number Diff line Loading @@ -1585,8 +1585,12 @@ void OpenGLRenderer::drawText(const char* text, int bytesCount, int count, #else #else bool hasActiveLayer = false; bool hasActiveLayer = false; #endif #endif mCaches.unbindMeshBuffer(); mCaches.unbindMeshBuffer(); // Tell font renderer the locations of position and texture coord // attributes so it can bind its data properly int positionSlot = mCaches.currentProgram->position; fontRenderer.setAttributeBindingSlots(positionSlot, mTexCoordsSlot); if (fontRenderer.renderText(paint, clip, text, 0, bytesCount, count, x, y, if (fontRenderer.renderText(paint, clip, text, 0, bytesCount, count, x, y, hasActiveLayer ? &bounds : NULL)) { hasActiveLayer ? &bounds : NULL)) { #if RENDER_LAYERS_AS_REGIONS #if RENDER_LAYERS_AS_REGIONS Loading