Fixed an issue where large text sizes at high resolutions would crash the application.

This commit is contained in:
Leon Styhre 2021-01-16 18:05:48 +01:00
parent 917ed738a0
commit 09e5095a08
4 changed files with 14 additions and 12 deletions

View file

@ -95,6 +95,7 @@ Many bugs have been fixed, and numerous features that were only partially implem
* If the user tried to enter a blank game name in the metadata editor, the application would crash upon saving
* Switching to the Grid view style with a placeholder shown in the gamelist crashed the application
* FileSystemUtil::getDirContent crashed when searching through directories recursively
* Large text sizes at higher resolutions (such as 4K) would crash the application as fixed-size texture buffers were used which weren't big enough to hold the larger font textures
* Fixed a massive memory leak related to SVG images
* Fixed an issue where SVG images would sometimes be cut off slightly on the right side (e.g. logos on the system view carousel)
* The scraper didn't handle error conditions correctly

View file

@ -128,10 +128,12 @@ void Font::unloadTextures()
it->deinitTexture();
}
Font::FontTexture::FontTexture()
Font::FontTexture::FontTexture(const int mSize)
{
textureId = 0;
textureSize = Vector2i(2048, 512);
// I'm not entirely sure if the 16 and 4 constants are correct, but they seem to provide
// a texture buffer large enough to hold the fonts. (Otherwise the application would crash.)
textureSize = Vector2i(mSize * 16, mSize * 4);
writePos = Vector2i::Zero();
rowHeight = 0;
}
@ -197,9 +199,8 @@ void Font::getTextureForNewGlyph(const Vector2i& glyphSize,
return; // Yes.
}
// Current textures are full,
// make a new one.
mTextures.push_back(FontTexture());
// Current textures are full, make a new one.
mTextures.push_back(FontTexture(mSize));
tex_out = &mTextures.back();
tex_out->initTexture();
@ -607,7 +608,7 @@ TextCache* Font::buildTextCache(
convertedColor };
// Round vertices.
for (int i = 1; i < 5; ++i)
for (int i = 1; i < 5; i++)
vertices[i].pos.round();
// Make duplicates of first and last vertex so this can be rendered as a triangle strip.

View file

@ -106,7 +106,7 @@ private:
Vector2i writePos;
int rowHeight;
FontTexture();
FontTexture(const int mSize);
~FontTexture();
bool findEmpty(const Vector2i& size, Vector2i& cursor_out);