diff options
| author | Mnikolenko Productengine <mnikolenko@productengine.com> | 2021-10-11 18:05:27 +0300 | 
|---|---|---|
| committer | Mnikolenko Productengine <mnikolenko@productengine.com> | 2021-10-11 18:05:27 +0300 | 
| commit | 2238f89db70a754614b01bb85adc5f16a63e7eb4 (patch) | |
| tree | aaca40b6dda44f4f31f2bbd0145291a7902214ac /indra | |
| parent | dc972623a9d4d03c726a36baaf840934c1ba6ed0 (diff) | |
SL-16141 Load fonts and generate glyphs on startup
Diffstat (limited to 'indra')
| -rw-r--r-- | indra/llrender/llfontgl.cpp | 31 | ||||
| -rw-r--r-- | indra/llrender/llfontgl.h | 4 | ||||
| -rw-r--r-- | indra/llrender/llfontregistry.cpp | 5 | ||||
| -rw-r--r-- | indra/newview/llviewerwindow.cpp | 19 | 
4 files changed, 40 insertions, 19 deletions
| diff --git a/indra/llrender/llfontgl.cpp b/indra/llrender/llfontgl.cpp index 86a4c35e6d..266399d212 100644 --- a/indra/llrender/llfontgl.cpp +++ b/indra/llrender/llfontgl.cpp @@ -547,9 +547,19 @@ F32 LLFontGL::getWidthF32(const llwchar* wchars, S32 begin_offset, S32 max_chars  	return cur_x / sScaleX;  } +void LLFontGL::generateASCIIglyphs() +{ +    LL_PROFILE_ZONE_SCOPED +    for (U32 i = 32; (i < 127); i++) +    { +        mFontFreetype->getGlyphInfo(i); +    } +} +  // Returns the max number of complete characters from text (up to max_chars) that can be drawn in max_pixels  S32 LLFontGL::maxDrawableChars(const llwchar* wchars, F32 max_pixels, S32 max_chars, EWordWrapStyle end_on_word_boundary) const  { +	LL_PROFILE_ZONE_SCOPED  	if (!wchars || !wchars[0] || max_chars == 0)  	{  		return 0; @@ -829,6 +839,8 @@ void LLFontGL::initClass(F32 screen_dpi, F32 x_scale, F32 y_scale, const std::st  	{  		sFontRegistry->reset();  	} + +	LLFontGL::loadDefaultFonts();  }  // Force standard fonts to get generated up front. @@ -838,6 +850,7 @@ void LLFontGL::initClass(F32 screen_dpi, F32 x_scale, F32 y_scale, const std::st  // static  bool LLFontGL::loadDefaultFonts()  { +	LL_PROFILE_ZONE_SCOPED  	bool succ = true;  	succ &= (NULL != getFontSansSerifSmall());  	succ &= (NULL != getFontSansSerif()); @@ -845,10 +858,18 @@ bool LLFontGL::loadDefaultFonts()  	succ &= (NULL != getFontSansSerifHuge());  	succ &= (NULL != getFontSansSerifBold());  	succ &= (NULL != getFontMonospace()); -	succ &= (NULL != getFontExtChar());  	return succ;  } +void LLFontGL::loadCommonFonts() +{ +    LL_PROFILE_ZONE_SCOPED +    getFont(LLFontDescriptor("SansSerif", "Small", BOLD)); +    getFont(LLFontDescriptor("SansSerif", "Large", BOLD)); +    getFont(LLFontDescriptor("SansSerif", "Huge", BOLD)); +    getFont(LLFontDescriptor("Monospace", "Medium", 0)); +} +  // static  void LLFontGL::destroyDefaultFonts()  { @@ -1015,7 +1036,7 @@ LLFontGL* LLFontGL::getFontSansSerifBig()  //static   LLFontGL* LLFontGL::getFontSansSerifHuge()  { -	static LLFontGL* fontp = getFont(LLFontDescriptor("SansSerif","Large",0)); +	static LLFontGL* fontp = getFont(LLFontDescriptor("SansSerif","Huge",0));  	return fontp;  } @@ -1026,12 +1047,6 @@ LLFontGL* LLFontGL::getFontSansSerifBold()  	return fontp;  } -//static -LLFontGL* LLFontGL::getFontExtChar() -{ -	return getFontSansSerif(); -} -  //static   LLFontGL* LLFontGL::getFont(const LLFontDescriptor& desc)  { diff --git a/indra/llrender/llfontgl.h b/indra/llrender/llfontgl.h index 10891faed9..3b58a37d33 100644 --- a/indra/llrender/llfontgl.h +++ b/indra/llrender/llfontgl.h @@ -160,12 +160,15 @@ public:  	const LLFontDescriptor& getFontDesc() const; +	void generateASCIIglyphs(); +  	static void initClass(F32 screen_dpi, F32 x_scale, F32 y_scale, const std::string& app_dir, bool create_gl_textures = true);  	// Load sans-serif, sans-serif-small, etc.  	// Slow, requires multiple seconds to load fonts.  	static bool loadDefaultFonts(); +    static void loadCommonFonts();  	static void	destroyDefaultFonts();  	static void destroyAllGL(); @@ -190,7 +193,6 @@ public:  	static LLFontGL* getFontSansSerifBig();  	static LLFontGL* getFontSansSerifHuge();  	static LLFontGL* getFontSansSerifBold(); -	static LLFontGL* getFontExtChar();  	static LLFontGL* getFont(const LLFontDescriptor& desc);  	// Use with legacy names like "SANSSERIF_SMALL" or "OCRA"  	static LLFontGL* getFontByName(const std::string& name); diff --git a/indra/llrender/llfontregistry.cpp b/indra/llrender/llfontregistry.cpp index 33a33af160..bc1a2f8887 100644 --- a/indra/llrender/llfontregistry.cpp +++ b/indra/llrender/llfontregistry.cpp @@ -597,6 +597,11 @@ LLFontGL *LLFontRegistry::getFont(const LLFontDescriptor& desc)  					<<" style=[" << ((S32) desc.getStyle()) << "]"  					<< " size=[" << desc.getSize() << "]" << LL_ENDL;  		} +		else +		{ +			//generate glyphs for ASCII chars to avoid stalls later +			fontp->generateASCIIglyphs(); +		}  		return fontp;  	}  } diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index 2157585364..c52a4e98d3 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -1963,6 +1963,13 @@ LLViewerWindow::LLViewerWindow(const Params& p)  	}  	LLFontManager::initClass(); +	// Init font system, load default fonts and generate basic glyphs +	// currently it takes aprox. 0.5 sec and we would load these fonts anyway +	// before login screen. +	LLFontGL::initClass( gSavedSettings.getF32("FontScreenDPI"), +		mDisplayScale.mV[VX], +		mDisplayScale.mV[VY], +		gDirUtilp->getAppRODataDir());  	//  	// We want to set this stuff up BEFORE we initialize the pipeline, so we can turn off @@ -2009,14 +2016,6 @@ LLViewerWindow::LLViewerWindow(const Params& p)  	LLViewerTextureManager::init() ;  	gBumpImageList.init(); -	// Init font system, but don't actually load the fonts yet -	// because our window isn't onscreen and they take several -	// seconds to parse. -	LLFontGL::initClass( gSavedSettings.getF32("FontScreenDPI"), -								mDisplayScale.mV[VX], -								mDisplayScale.mV[VY], -								gDirUtilp->getAppRODataDir()); -	  	// Create container for all sub-views  	LLView::Params rvp;  	rvp.name("root"); @@ -2102,6 +2101,8 @@ void LLViewerWindow::initBase()  	LL_DEBUGS("AppInit") << "initializing edit menu" << LL_ENDL;  	initialize_edit_menu(); +    LLFontGL::loadCommonFonts(); +  	// Create the floater view at the start so that other views can add children to it.   	// (But wait to add it as a child of the root view so that it will be in front of the   	// other views.) @@ -5499,8 +5500,6 @@ void LLViewerWindow::initFonts(F32 zoom_factor)  								mDisplayScale.mV[VX] * zoom_factor,  								mDisplayScale.mV[VY] * zoom_factor,  								gDirUtilp->getAppRODataDir()); -	// Force font reloads, which can be very slow -	LLFontGL::loadDefaultFonts();  }  void LLViewerWindow::requestResolutionUpdate() | 
