[smooth] Limit pool size on demand.

* src/smooth/ftgrays.c (gray_convert_glyph): Honor FT_GRAY_POOL_SIZE.
This commit is contained in:
Alexei Podtelezhnikov 2023-10-09 22:42:25 -04:00
parent 819d73f658
commit 4f01f5dbd1

View File

@ -469,10 +469,8 @@ typedef ptrdiff_t FT_PtrDist;
} TPixmap;
/* maximum number of gray cells in the buffer */
#if FT_RENDER_POOL_SIZE > 2048
#if defined( FT_GRAY_POOL_SIZE ) && FT_GRAY_POOL_SIZE > 2048
#define FT_MAX_GRAY_POOL ( FT_RENDER_POOL_SIZE / sizeof ( TCell ) )
#else
#define FT_MAX_GRAY_POOL ( 2048 / sizeof ( TCell ) )
#endif
/* FT_Span buffer size for direct rendering only */
@ -2026,6 +2024,16 @@ typedef ptrdiff_t FT_PtrDist;
size += height * sizeof ( PCell ) / sizeof ( TCell ) +
9; /* empirical extra for local extrema */
#ifdef FT_MAX_GRAY_POOL
if ( size > FT_MAX_GRAY_POOL )
{
/* both divisions rounded up */
n = ( size + FT_MAX_GRAY_POOL - 1 ) / FT_MAX_GRAY_POOL;
height = ( height + n - 1 ) / n;
size = FT_MAX_GRAY_POOL;
}
#endif
if ( FT_QNEW_ARRAY( buffer, size ) )
return error;