Reduce peak memory usage when a font's glyph atlas needs to be recreated.

This commit is contained in:
Alex Szpakowski
2019-01-16 18:21:58 -04:00
parent d83117c981
commit 1bb50fccac
+7 -5
View File
@@ -152,12 +152,14 @@ void Font::createTexture()
image = gfx->newImage(TEXTURE_2D, pixelFormat, size.width, size.height, 1, settings);
image->setFilter(filter);
// Initialize the texture with transparent black.
size_t bpp = getPixelFormatSize(pixelFormat);
std::vector<uint8> emptydata(size.width * size.height * bpp, 0);
{
// Initialize the texture with transparent black.
size_t bpp = getPixelFormatSize(pixelFormat);
std::vector<uint8> emptydata(size.width * size.height * bpp, 0);
Rect rect = {0, 0, size.width, size.height};
image->replacePixels(emptydata.data(), emptydata.size(), 0, 0, rect, false);
Rect rect = {0, 0, size.width, size.height};
image->replacePixels(emptydata.data(), emptydata.size(), 0, 0, rect, false);
}
images.emplace_back(image, Acquire::NORETAIN);