@@ -37,7 +37,7 @@ namespace uirenderer {
3737#define DEFAULT_TEXT_CACHE_WIDTH 1024
3838#define DEFAULT_TEXT_CACHE_HEIGHT 256
3939#define MAX_TEXT_CACHE_WIDTH 2048
40- #define TEXTURE_BORDER_SIZE 2
40+ #define TEXTURE_BORDER_SIZE 1
4141
4242#define AUTO_KERN (prev, next ) (((next) - (prev) + 32 ) >> 6 << 16 )
4343
@@ -50,10 +50,10 @@ bool CacheTextureLine::fitBitmap(const SkGlyph& glyph, uint32_t *retOriginX, uin
5050 return false ;
5151 }
5252
53- if (mCurrentCol + glyph.fWidth + TEXTURE_BORDER_SIZE < mMaxWidth ) {
54- *retOriginX = mCurrentCol + 1 ;
55- *retOriginY = mCurrentRow + 1 ;
56- mCurrentCol += glyph.fWidth + TEXTURE_BORDER_SIZE;
53+ if (mCurrentCol + glyph.fWidth + TEXTURE_BORDER_SIZE * 2 < mMaxWidth ) {
54+ *retOriginX = mCurrentCol + TEXTURE_BORDER_SIZE ;
55+ *retOriginY = mCurrentRow + TEXTURE_BORDER_SIZE ;
56+ mCurrentCol += glyph.fWidth + TEXTURE_BORDER_SIZE * 2 ;
5757 mDirty = true ;
5858 return true ;
5959 }
@@ -412,10 +412,10 @@ void Font::updateGlyphCache(SkPaint* paint, const SkGlyph& skiaGlyph, CachedGlyp
412412 uint32_t cacheWidth = glyph->mCachedTextureLine ->mCacheTexture ->mWidth ;
413413 uint32_t cacheHeight = glyph->mCachedTextureLine ->mCacheTexture ->mHeight ;
414414
415- glyph->mBitmapMinU = ( float ) startX / (float ) cacheWidth;
416- glyph->mBitmapMinV = ( float ) startY / (float ) cacheHeight;
417- glyph->mBitmapMaxU = ( float ) endX / (float ) cacheWidth;
418- glyph->mBitmapMaxV = ( float ) endY / (float ) cacheHeight;
415+ glyph->mBitmapMinU = startX / (float ) cacheWidth;
416+ glyph->mBitmapMinV = startY / (float ) cacheHeight;
417+ glyph->mBitmapMaxU = endX / (float ) cacheWidth;
418+ glyph->mBitmapMaxV = endY / (float ) cacheHeight;
419419
420420 mState ->mUploadTexture = true ;
421421}
@@ -590,9 +590,6 @@ void FontRenderer::allocateTextureMemory(CacheTexture* cacheTexture) {
590590 int height = cacheTexture->mHeight ;
591591
592592 cacheTexture->mTexture = new uint8_t [width * height];
593- #if DEBUG_FONT_RENDERER
594- memset (cacheTexture->mTexture , 0 , width * height * sizeof (uint8_t ));
595- #endif
596593
597594 if (!cacheTexture->mTextureId ) {
598595 glGenTextures (1 , &cacheTexture->mTextureId );
@@ -617,7 +614,7 @@ void FontRenderer::cacheBitmap(const SkGlyph& glyph, CachedGlyphInfo* cachedGlyp
617614 uint32_t * retOriginX, uint32_t * retOriginY) {
618615 cachedGlyph->mIsValid = false ;
619616 // If the glyph is too tall, don't cache it
620- if (glyph.fHeight + TEXTURE_BORDER_SIZE > mCacheLines [mCacheLines .size () - 1 ]->mMaxHeight ) {
617+ if (glyph.fHeight + TEXTURE_BORDER_SIZE * 2 > mCacheLines [mCacheLines .size () - 1 ]->mMaxHeight ) {
621618 ALOGE (" Font size to large to fit in cache. width, height = %i, %i" ,
622619 (int ) glyph.fWidth , (int ) glyph.fHeight );
623620 return ;
@@ -677,6 +674,18 @@ void FontRenderer::cacheBitmap(const SkGlyph& glyph, CachedGlyphInfo* cachedGlyp
677674 unsigned int stride = glyph.rowBytes ();
678675
679676 uint32_t cacheX = 0 , bX = 0 , cacheY = 0 , bY = 0 ;
677+
678+ for (cacheX = startX - TEXTURE_BORDER_SIZE; cacheX < endX + TEXTURE_BORDER_SIZE; cacheX++) {
679+ cacheBuffer[(startY - TEXTURE_BORDER_SIZE) * cacheWidth + cacheX] = 0 ;
680+ cacheBuffer[(endY + TEXTURE_BORDER_SIZE - 1 ) * cacheWidth + cacheX] = 0 ;
681+ }
682+
683+ for (cacheY = startY - TEXTURE_BORDER_SIZE + 1 ;
684+ cacheY < endY + TEXTURE_BORDER_SIZE - 1 ; cacheY++) {
685+ cacheBuffer[cacheY * cacheWidth + startX - TEXTURE_BORDER_SIZE] = 0 ;
686+ cacheBuffer[cacheY * cacheWidth + endX + TEXTURE_BORDER_SIZE - 1 ] = 0 ;
687+ }
688+
680689 if (mGammaTable ) {
681690 for (cacheX = startX, bX = 0 ; cacheX < endX; cacheX++, bX++) {
682691 for (cacheY = startY, bY = 0 ; cacheY < endY; cacheY++, bY++) {
0 commit comments