[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[freetype2] smooth_malloc dc716cd08: [smooth] Somewhat naive estimate of
From: |
Werner Lemberg |
Subject: |
[freetype2] smooth_malloc dc716cd08: [smooth] Somewhat naive estimate of the rendering pool size. |
Date: |
Mon, 2 Oct 2023 16:46:48 -0400 (EDT) |
branch: smooth_malloc
commit dc716cd088fa0fc86e4132f6de8729fb684122ba
Author: Alexei Podtelezhnikov <apodtele@gmail.com>
Commit: Alexei Podtelezhnikov <apodtele@gmail.com>
[smooth] Somewhat naive estimate of the rendering pool size.
The estimate is based on the taxi perimeter with added space for the
corner cases.
* src/smooth/ftgrays.c (gray_taxi): New function for the perimeter.
(gray_convert_glyph): Updated, banding suppressed.
---
src/smooth/ftgrays.c | 50 ++++++++++++++++++++++++++++++++++++++++----------
1 file changed, 40 insertions(+), 10 deletions(-)
diff --git a/src/smooth/ftgrays.c b/src/smooth/ftgrays.c
index fabb986ab..2482eabc0 100644
--- a/src/smooth/ftgrays.c
+++ b/src/smooth/ftgrays.c
@@ -1920,6 +1920,39 @@ typedef ptrdiff_t FT_PtrDist;
)
+ static long
+ gray_taxi( RAS_ARG )
+ {
+ FT_Outline* outline = &ras.outline;
+ short c, p, first, last;
+ FT_Vector u, v;
+ FT_Pos taxi;
+
+
+ taxi = 0;
+ last = -1;
+ for ( c = 0; c < outline->n_contours; c++ )
+ {
+ first = last + 1;
+ last = outline->contours[c];
+
+ u = outline->points[last];
+ for ( p = first; p <= last; p++ )
+ {
+ v = outline->points[p];
+
+ taxi += v.x > u.x ? v.x - u.x : u.x - v.x;
+ taxi += v.y > u.y ? v.y - u.y : u.y - v.y;
+
+ u = v;
+ }
+ }
+
+ /* adding contours and points to deal with corner cases */
+ return ( taxi >> 6 ) + outline->n_contours + outline->n_points;
+ }
+
+
static int
gray_convert_glyph_inner( RAS_ARG_
int continued )
@@ -1964,7 +1997,8 @@ typedef ptrdiff_t FT_PtrDist;
TCell* buffer;
size_t height = (size_t)( yMax - yMin );
- size_t n = FT_MAX_GRAY_POOL / 8;
+ size_t n;
+ long size;
TCoord y;
TCoord bands[32]; /* enough to accommodate bisections */
TCoord* band;
@@ -1972,11 +2006,14 @@ typedef ptrdiff_t FT_PtrDist;
int continued = 0;
- if ( FT_QNEW_ARRAY ( buffer, FT_MAX_GRAY_POOL ) )
+ size = gray_taxi( RAS_VAR ) +
+ height * sizeof ( PCell ) / sizeof ( TCell ) + 1;
+
+ if ( FT_QNEW_ARRAY ( buffer, size ) )
return error;
/* Initialize the null cell at the end of the poll. */
- ras.cell_null = buffer + FT_MAX_GRAY_POOL - 1;
+ ras.cell_null = buffer + size - 1;
ras.cell_null->x = CELL_MAX_X_VALUE;
ras.cell_null->area = 0;
ras.cell_null->cover = 0;
@@ -1985,13 +2022,6 @@ typedef ptrdiff_t FT_PtrDist;
/* set up vertical bands */
ras.ycells = (PCell*)buffer;
- if ( height > n )
- {
- /* two divisions rounded up */
- n = ( height + n - 1 ) / n;
- height = ( height + n - 1 ) / n;
- }
-
for ( y = yMin; y < yMax; )
{
ras.min_ey = y;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [freetype2] smooth_malloc dc716cd08: [smooth] Somewhat naive estimate of the rendering pool size.,
Werner Lemberg <=