[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[freetype2] smooth_malloc 5f5972da7: [smooth] Dynamic memory allocation.
From: |
Werner Lemberg |
Subject: |
[freetype2] smooth_malloc 5f5972da7: [smooth] Dynamic memory allocation. |
Date: |
Sat, 30 Sep 2023 15:47:36 -0400 (EDT) |
branch: smooth_malloc
commit 5f5972da7b0382e23efab66326c958edb35b2fd9
Author: Alexei Podtelezhnikov <apodtele@gmail.com>
Commit: Alexei Podtelezhnikov <apodtele@gmail.com>
[smooth] Dynamic memory allocation.
This is a proof of concept for performance comparison.
---
src/smooth/ftgrays.c | 25 ++++++++++++++++++-------
1 file changed, 18 insertions(+), 7 deletions(-)
diff --git a/src/smooth/ftgrays.c b/src/smooth/ftgrays.c
index fbf1541ef..579e8421e 100644
--- a/src/smooth/ftgrays.c
+++ b/src/smooth/ftgrays.c
@@ -490,6 +490,7 @@ typedef ptrdiff_t FT_PtrDist;
typedef struct gray_TWorker_
{
ft_jmp_buf jump_buffer;
+ FT_Memory memory;
TCoord min_ex, max_ex; /* min and max integer pixel coordinates */
TCoord min_ey, max_ey;
@@ -1958,7 +1959,10 @@ typedef ptrdiff_t FT_PtrDist;
const TCoord yMin = ras.min_ey;
const TCoord yMax = ras.max_ey;
- TCell buffer[FT_MAX_GRAY_POOL];
+ FT_Error error;
+ FT_Memory memory = ras.memory;
+
+ TCell* buffer;
size_t height = (size_t)( yMax - yMin );
size_t n = FT_MAX_GRAY_POOL / 8;
TCoord y;
@@ -1968,6 +1972,9 @@ typedef ptrdiff_t FT_PtrDist;
int continued = 0;
+ if ( FT_QNEW_ARRAY ( buffer, FT_MAX_GRAY_POOL ) )
+ return error;
+
/* Initialize the null cell at the end of the poll. */
ras.cell_null = buffer + FT_MAX_GRAY_POOL - 1;
ras.cell_null->x = CELL_MAX_X_VALUE;
@@ -1999,7 +2006,7 @@ typedef ptrdiff_t FT_PtrDist;
{
TCoord width = band[0] - band[1];
TCoord w;
- int error;
+ int err;
for ( w = 0; w < width; ++w )
@@ -2015,10 +2022,10 @@ typedef ptrdiff_t FT_PtrDist;
ras.max_ey = band[0];
ras.count_ey = width;
- error = gray_convert_glyph_inner( RAS_VAR_ continued );
+ err = gray_convert_glyph_inner( RAS_VAR_ continued );
continued = 1;
- if ( !error )
+ if ( !err )
{
if ( ras.render_span ) /* for FT_RASTER_FLAG_DIRECT only */
gray_sweep_direct( RAS_VAR );
@@ -2027,8 +2034,8 @@ typedef ptrdiff_t FT_PtrDist;
band--;
continue;
}
- else if ( error != Smooth_Err_Raster_Overflow )
- return error;
+ else if ( err != Smooth_Err_Raster_Overflow )
+ return err;
/* render pool overflow; we will reduce the render band by half */
width >>= 1;
@@ -2046,7 +2053,9 @@ typedef ptrdiff_t FT_PtrDist;
} while ( band >= bands );
}
- return Smooth_Err_Ok;
+
+ FT_FREE( buffer );
+ return error;
}
@@ -2132,6 +2141,8 @@ typedef ptrdiff_t FT_PtrDist;
if ( ras.max_ex <= ras.min_ex || ras.max_ey <= ras.min_ey )
return Smooth_Err_Ok;
+ ras.memory = (FT_Memory)((gray_PRaster)raster)->memory;
+
return gray_convert_glyph( RAS_VAR );
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [freetype2] smooth_malloc 5f5972da7: [smooth] Dynamic memory allocation.,
Werner Lemberg <=