@@ -34,9 +34,10 @@ namespace uirenderer {
3434// Defines
3535// /////////////////////////////////////////////////////////////////////////////
3636
37- #define DEFAULT_TEXT_CACHE_WIDTH 1024
38- #define DEFAULT_TEXT_CACHE_HEIGHT 256
39- #define MAX_TEXT_CACHE_WIDTH 2048
37+ #define DEFAULT_TEXT_SMALL_CACHE_WIDTH 1024
38+ #define DEFAULT_TEXT_SMALL_CACHE_HEIGHT 256
39+ #define DEFAULT_TEXT_LARGE_CACHE_WIDTH 2048
40+ #define DEFAULT_TEXT_LARGE_CACHE_HEIGHT 512
4041#define CACHE_BLOCK_ROUNDING_SIZE 4
4142
4243#define AUTO_KERN (prev, next ) (((next) - (prev) + 32 ) >> 6 << 16 )
@@ -626,30 +627,35 @@ FontRenderer::FontRenderer() {
626627
627628 mIndexBufferID = 0 ;
628629
629- mSmallCacheWidth = DEFAULT_TEXT_CACHE_WIDTH;
630- mSmallCacheHeight = DEFAULT_TEXT_CACHE_HEIGHT;
630+ mSmallCacheWidth = DEFAULT_TEXT_SMALL_CACHE_WIDTH;
631+ mSmallCacheHeight = DEFAULT_TEXT_SMALL_CACHE_HEIGHT;
632+ mLargeCacheWidth = DEFAULT_TEXT_LARGE_CACHE_WIDTH;
633+ mLargeCacheHeight = DEFAULT_TEXT_LARGE_CACHE_HEIGHT;
631634
632635 char property[PROPERTY_VALUE_MAX];
633- if (property_get (PROPERTY_TEXT_CACHE_WIDTH, property, NULL ) > 0 ) {
634- if (sLogFontRendererCreate ) {
635- INIT_LOGD (" Setting text cache width to %s pixels" , property);
636- }
636+ if (property_get (PROPERTY_TEXT_SMALL_CACHE_WIDTH, property, NULL ) > 0 ) {
637637 mSmallCacheWidth = atoi (property);
638- } else {
639- if (sLogFontRendererCreate ) {
640- INIT_LOGD (" Using default text cache width of %i pixels" , mSmallCacheWidth );
641- }
642638 }
643-
644- if (property_get (PROPERTY_TEXT_CACHE_HEIGHT, property, NULL ) > 0 ) {
645- if (sLogFontRendererCreate ) {
646- INIT_LOGD (" Setting text cache width to %s pixels" , property);
647- }
639+ if (property_get (PROPERTY_TEXT_SMALL_CACHE_HEIGHT, property, NULL ) > 0 ) {
648640 mSmallCacheHeight = atoi (property);
649- } else {
650- if (sLogFontRendererCreate ) {
651- INIT_LOGD (" Using default text cache height of %i pixels" , mSmallCacheHeight );
652- }
641+ }
642+ if (property_get (PROPERTY_TEXT_LARGE_CACHE_WIDTH, property, NULL ) > 0 ) {
643+ mLargeCacheWidth = atoi (property);
644+ }
645+ if (property_get (PROPERTY_TEXT_LARGE_CACHE_HEIGHT, property, NULL ) > 0 ) {
646+ mLargeCacheHeight = atoi (property);
647+ }
648+ GLint maxTextureSize = Caches::getInstance ().maxTextureSize ;
649+ mSmallCacheWidth = (mSmallCacheWidth > maxTextureSize) ? maxTextureSize : mSmallCacheWidth ;
650+ mSmallCacheHeight = (mSmallCacheHeight > maxTextureSize) ? maxTextureSize : mSmallCacheHeight ;
651+ mLargeCacheWidth = (mLargeCacheWidth > maxTextureSize) ? maxTextureSize : mLargeCacheWidth ;
652+ mLargeCacheHeight = (mLargeCacheHeight > maxTextureSize) ? maxTextureSize : mLargeCacheHeight ;
653+ if (sLogFontRendererCreate ) {
654+ INIT_LOGD (" Text cache sizes, in pixels: %i x %i, %i x %i, %i x %i, %i x %i" ,
655+ mSmallCacheWidth , mSmallCacheHeight ,
656+ mLargeCacheWidth , mLargeCacheHeight >> 1 ,
657+ mLargeCacheWidth , mLargeCacheHeight >> 1 ,
658+ mLargeCacheWidth , mLargeCacheHeight );
653659 }
654660
655661 sLogFontRendererCreate = false ;
@@ -861,21 +867,11 @@ void FontRenderer::initTextTexture() {
861867 }
862868 mCacheTextures .clear ();
863869
864- // Next, use other, separate caches for large glyphs.
865- uint16_t maxWidth = 0 ;
866- if (Caches::hasInstance ()) {
867- maxWidth = Caches::getInstance ().maxTextureSize ;
868- }
869-
870- if (maxWidth > MAX_TEXT_CACHE_WIDTH || maxWidth == 0 ) {
871- maxWidth = MAX_TEXT_CACHE_WIDTH;
872- }
873-
874870 mUploadTexture = false ;
875871 mCacheTextures .push (createCacheTexture (mSmallCacheWidth , mSmallCacheHeight , true ));
876- mCacheTextures .push (createCacheTexture (maxWidth, 256 , false ));
877- mCacheTextures .push (createCacheTexture (maxWidth, 256 , false ));
878- mCacheTextures .push (createCacheTexture (maxWidth, 512 , false ));
872+ mCacheTextures .push (createCacheTexture (mLargeCacheWidth , mLargeCacheHeight >> 1 , false ));
873+ mCacheTextures .push (createCacheTexture (mLargeCacheWidth , mLargeCacheHeight >> 1 , false ));
874+ mCacheTextures .push (createCacheTexture (mLargeCacheWidth , mLargeCacheHeight , false ));
879875 mCurrentCacheTexture = mCacheTextures [0 ];
880876}
881877
0 commit comments