mirror of
https://github.com/love2d/love.git
synced 2026-08-14 01:20:56 +02:00
Reduce peak memory usage when a font's glyph atlas needs to be recreated.
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user