mirror of
https://github.com/cjcliffe/CubicSDR.git
synced 2024-11-25 21:28:38 -05:00
Reset all font caches when font size changes
This commit is contained in:
parent
308baf163b
commit
85178095ca
@ -793,7 +793,10 @@ void GLFont::doCacheGC() {
|
|||||||
} //end while
|
} //end while
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLFont::flushGC() {
|
void GLFont::clearCache() {
|
||||||
|
|
||||||
|
std::lock_guard<std::mutex> lock(cache_busy);
|
||||||
|
|
||||||
std::map<std::wstring, GLFontStringCache * >::iterator cache_iter;
|
std::map<std::wstring, GLFontStringCache * >::iterator cache_iter;
|
||||||
|
|
||||||
cache_iter = stringCache.begin();
|
cache_iter = stringCache.begin();
|
||||||
@ -806,6 +809,14 @@ void GLFont::flushGC() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GLFont::clearAllCaches() {
|
||||||
|
|
||||||
|
for (int i = 0; i < GLFont::GLFONT_SIZE_MAX; i++) {
|
||||||
|
|
||||||
|
fonts[i].clearCache();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
GLFont &GLFont::getFont(GLFontSize esize) {
|
GLFont &GLFont::getFont(GLFontSize esize) {
|
||||||
|
|
||||||
@ -864,8 +875,6 @@ void GLFont::setScale(GLFontScale scale) {
|
|||||||
userFontZoomMapping[GLFont::GLFONT_SIZE36] = GLFont::GLFONT_SIZE48;
|
userFontZoomMapping[GLFont::GLFONT_SIZE36] = GLFont::GLFONT_SIZE48;
|
||||||
userFontZoomMapping[GLFont::GLFONT_SIZE48] = GLFont::GLFONT_SIZE72;
|
userFontZoomMapping[GLFont::GLFONT_SIZE48] = GLFont::GLFONT_SIZE72;
|
||||||
userFontZoomMapping[GLFont::GLFONT_SIZE64] = GLFont::GLFONT_SIZE96;
|
userFontZoomMapping[GLFont::GLFONT_SIZE64] = GLFont::GLFONT_SIZE96;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
//Large : 2x normal, more or less
|
//Large : 2x normal, more or less
|
||||||
else if (currentScaleFactor == GLFontScale::GLFONT_SCALE_LARGE) {
|
else if (currentScaleFactor == GLFontScale::GLFONT_SCALE_LARGE) {
|
||||||
@ -880,10 +889,8 @@ void GLFont::setScale(GLFontScale scale) {
|
|||||||
userFontZoomMapping[GLFont::GLFONT_SIZE48] = GLFont::GLFONT_SIZE96;
|
userFontZoomMapping[GLFont::GLFONT_SIZE48] = GLFont::GLFONT_SIZE96;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Not overridden mapping stays normal, like the biggest fonts.
|
//Flush all the GC stuff
|
||||||
|
clearAllCaches();
|
||||||
//Note that there is no need to flush the GC, no longer used fonts will be purged auto-magically by aging,
|
|
||||||
//and the new fonts will show up.
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GLFont::GLFontScale GLFont::getScale() {
|
GLFont::GLFontScale GLFont::getScale() {
|
||||||
|
@ -137,7 +137,10 @@ private:
|
|||||||
void drawCacheString(GLFontStringCache *fc, float xpos, float ypos, Align hAlign, Align vAlign);
|
void drawCacheString(GLFontStringCache *fc, float xpos, float ypos, Align hAlign, Align vAlign);
|
||||||
|
|
||||||
void doCacheGC();
|
void doCacheGC();
|
||||||
void flushGC();
|
void clearCache();
|
||||||
|
|
||||||
|
//force GC of all available fonts
|
||||||
|
static void clearAllCaches();
|
||||||
|
|
||||||
float getStringWidth(const std::wstring& str, float size, float viewAspect);
|
float getStringWidth(const std::wstring& str, float size, float viewAspect);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user