freetype-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[freetype2] smooth_malloc 4f01f5dbd 4/4: [smooth] Limit pool size on dem


From: Werner Lemberg
Subject: [freetype2] smooth_malloc 4f01f5dbd 4/4: [smooth] Limit pool size on demand.
Date: Mon, 9 Oct 2023 22:45:49 -0400 (EDT)

branch: smooth_malloc
commit 4f01f5dbd1191e3da93117d703a146e57eb164b0
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 201b730b3..79eadc76a 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;
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]