[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[freetype2] smooth_malloc 8059da9ac 2/2: [smooth] Limit pool size on dem
From: |
Werner Lemberg |
Subject: |
[freetype2] smooth_malloc 8059da9ac 2/2: [smooth] Limit pool size on demand. |
Date: |
Sat, 7 Oct 2023 23:14:58 -0400 (EDT) |
branch: smooth_malloc
commit 8059da9ac008f1617f7d13d248139bee3212d7ce
Author: Alexei Podtelezhnikov <apodtele@gmail.com>
Commit: Alexei Podtelezhnikov <apodtele@gmail.com>
[smooth] Limit pool size on demand.
* src/smooth/ftgrays.c (gray_convert_glyph): Honor FT_GRAY_POOL_SIZE.
---
src/smooth/ftgrays.c | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/src/smooth/ftgrays.c b/src/smooth/ftgrays.c
index 12e310855..a3bb82f92 100644
--- a/src/smooth/ftgrays.c
+++ b/src/smooth/ftgrays.c
@@ -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;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [freetype2] smooth_malloc 8059da9ac 2/2: [smooth] Limit pool size on demand.,
Werner Lemberg <=