mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-14 20:18:19 +00:00
Avoid unnecessary copy of glyph data for entities text
Copy the glyph data directly from the font bitmap buffer to the target image instead of using `m_aaGlyphData` as a temporary buffer.
This commit is contained in:
parent
eecaf4cdfc
commit
f5179df6d0
|
@ -788,14 +788,6 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
const FT_Bitmap *pBitmap = &Face->glyph->bitmap;
|
const FT_Bitmap *pBitmap = &Face->glyph->bitmap;
|
||||||
|
|
||||||
// prepare glyph data
|
|
||||||
const size_t GlyphDataSize = (size_t)pBitmap->width * pBitmap->rows * sizeof(uint8_t);
|
|
||||||
if(pBitmap->pixel_mode == FT_PIXEL_MODE_GRAY)
|
|
||||||
mem_copy(m_aaGlyphData[FONT_TEXTURE_FILL], pBitmap->buffer, GlyphDataSize);
|
|
||||||
else
|
|
||||||
mem_zero(m_aaGlyphData[FONT_TEXTURE_FILL], GlyphDataSize);
|
|
||||||
|
|
||||||
for(unsigned OffY = 0; OffY < pBitmap->rows; ++OffY)
|
for(unsigned OffY = 0; OffY < pBitmap->rows; ++OffY)
|
||||||
{
|
{
|
||||||
for(unsigned OffX = 0; OffX < pBitmap->width; ++OffX)
|
for(unsigned OffX = 0; OffX < pBitmap->width; ++OffX)
|
||||||
|
@ -803,18 +795,11 @@ public:
|
||||||
const int ImgOffX = clamp(x + OffX + WidthLastChars, x, (x + TexSubWidth) - 1);
|
const int ImgOffX = clamp(x + OffX + WidthLastChars, x, (x + TexSubWidth) - 1);
|
||||||
const int ImgOffY = clamp(y + OffY, y, (y + TexSubHeight) - 1);
|
const int ImgOffY = clamp(y + OffY, y, (y + TexSubHeight) - 1);
|
||||||
const size_t ImageOffset = ImgOffY * (TextImage.m_Width * PixelSize) + ImgOffX * PixelSize;
|
const size_t ImageOffset = ImgOffY * (TextImage.m_Width * PixelSize) + ImgOffX * PixelSize;
|
||||||
const size_t GlyphOffset = OffY * pBitmap->width + OffX;
|
for(size_t i = 0; i < PixelSize - 1; ++i)
|
||||||
for(size_t i = 0; i < PixelSize; ++i)
|
|
||||||
{
|
{
|
||||||
if(i != PixelSize - 1)
|
TextImage.m_pData[ImageOffset + i] = 255;
|
||||||
{
|
|
||||||
*(TextImage.m_pData + ImageOffset + i) = 255;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
*(TextImage.m_pData + ImageOffset + i) = *(m_aaGlyphData[FONT_TEXTURE_FILL] + GlyphOffset);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
TextImage.m_pData[ImageOffset + PixelSize - 1] = pBitmap->buffer[OffY * pBitmap->width + OffX];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue