freetype-commit
[Top][All Lists]
Advanced

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

[Git][freetype/freetype][smooth_malloc] [smooth] Estimate of the renderi


From: Alexei Podtelezhnikov (@apodtele)
Subject: [Git][freetype/freetype][smooth_malloc] [smooth] Estimate of the rendering pool size.
Date: Tue, 03 Oct 2023 03:00:52 +0000

Alexei Podtelezhnikov pushed to branch smooth_malloc at FreeType / FreeType

Commits:

  • c8ab9dad
    by Alexei Podtelezhnikov at 2023-10-02T22:56:54-04:00
    [smooth] Estimate of the rendering pool size.
    
    The estimate is based on the taxi perimeter with extra space added
    for local extrema.
    
    * src/smooth/ftgrays.c (gray_taxi): New function for the perimeter.
    (gray_convert_glyph): Updated, banding suppressed.
    

1 changed file:

Changes:

  • src/smooth/ftgrays.c
    ... ... @@ -1920,6 +1920,39 @@ typedef ptrdiff_t FT_PtrDist;
    1920 1920
       )
    
    1921 1921
     
    
    1922 1922
     
    
    1923
    +  static long
    
    1924
    +  gray_taxi( RAS_ARG )
    
    1925
    +  {
    
    1926
    +    FT_Outline*  outline = &ras.outline;
    
    1927
    +    short        c, p, first, last;
    
    1928
    +    FT_Vector    u, v;
    
    1929
    +    FT_Pos       taxi;
    
    1930
    +
    
    1931
    +
    
    1932
    +    taxi = 0;
    
    1933
    +    last = -1;
    
    1934
    +    for ( c = 0; c < outline->n_contours; c++ )
    
    1935
    +    {
    
    1936
    +      first = last + 1;
    
    1937
    +      last = outline->contours[c];
    
    1938
    +
    
    1939
    +      u = outline->points[last];
    
    1940
    +      for ( p = first; p <= last; p++ )
    
    1941
    +      {
    
    1942
    +        v = outline->points[p];
    
    1943
    +
    
    1944
    +        taxi += v.x > u.x ? v.x - u.x : u.x - v.x;
    
    1945
    +        taxi += v.y > u.y ? v.y - u.y : u.y - v.y;
    
    1946
    +
    
    1947
    +        u = v;
    
    1948
    +      }
    
    1949
    +    }
    
    1950
    +
    
    1951
    +    /* adding the number of local extrema might be worth it but is hard */
    
    1952
    +    return  taxi >> 6;
    
    1953
    +  }
    
    1954
    +
    
    1955
    +
    
    1923 1956
       static int
    
    1924 1957
       gray_convert_glyph_inner( RAS_ARG_
    
    1925 1958
                                 int  continued )
    
    ... ... @@ -1935,7 +1968,7 @@ typedef ptrdiff_t FT_PtrDist;
    1935 1968
           if ( continued )
    
    1936 1969
             FT_Trace_Enable();
    
    1937 1970
     
    
    1938
    -      FT_TRACE7(( "band [%d..%d]: %td cell%s remaining/\n",
    
    1971
    +      FT_TRACE7(( "band [%d..%d]: %td cell%s remaining\n",
    
    1939 1972
                       ras.min_ey,
    
    1940 1973
                       ras.max_ey,
    
    1941 1974
                       ras.cell_null - ras.cell_free,
    
    ... ... @@ -1964,7 +1997,8 @@ typedef ptrdiff_t FT_PtrDist;
    1964 1997
     
    
    1965 1998
         TCell*   buffer;
    
    1966 1999
         size_t   height = (size_t)( yMax - yMin );
    
    1967
    -    size_t   n = FT_MAX_GRAY_POOL / 8;
    
    2000
    +    size_t   n;
    
    2001
    +    long     size;
    
    1968 2002
         TCoord   y;
    
    1969 2003
         TCoord   bands[32];  /* enough to accommodate bisections */
    
    1970 2004
         TCoord*  band;
    
    ... ... @@ -1972,11 +2006,18 @@ typedef ptrdiff_t FT_PtrDist;
    1972 2006
         int  continued = 0;
    
    1973 2007
     
    
    1974 2008
     
    
    1975
    -    if ( FT_QNEW_ARRAY ( buffer, FT_MAX_GRAY_POOL ) )
    
    2009
    +    size = gray_taxi( RAS_VAR ) +
    
    2010
    +           height * sizeof ( PCell ) / sizeof ( TCell ) +
    
    2011
    +           9;  /* empirical extra for local extrema */
    
    2012
    +
    
    2013
    +    if ( FT_QNEW_ARRAY ( buffer, size ) )
    
    1976 2014
           return error;
    
    1977 2015
     
    
    2016
    +    FT_TRACE7(( "Allocated %ld cells (%ld bytes)\n",
    
    2017
    +                size, size * sizeof ( TCell ) ));
    
    2018
    +
    
    1978 2019
         /* Initialize the null cell at the end of the poll. */
    
    1979
    -    ras.cell_null        = buffer + FT_MAX_GRAY_POOL - 1;
    
    2020
    +    ras.cell_null        = buffer + size - 1;
    
    1980 2021
         ras.cell_null->x     = CELL_MAX_X_VALUE;
    
    1981 2022
         ras.cell_null->area  = 0;
    
    1982 2023
         ras.cell_null->cover = 0;
    
    ... ... @@ -1985,13 +2026,6 @@ typedef ptrdiff_t FT_PtrDist;
    1985 2026
         /* set up vertical bands */
    
    1986 2027
         ras.ycells     = (PCell*)buffer;
    
    1987 2028
     
    
    1988
    -    if ( height > n )
    
    1989
    -    {
    
    1990
    -      /* two divisions rounded up */
    
    1991
    -      n       = ( height + n - 1 ) / n;
    
    1992
    -      height  = ( height + n - 1 ) / n;
    
    1993
    -    }
    
    1994
    -
    
    1995 2029
         for ( y = yMin; y < yMax; )
    
    1996 2030
         {
    
    1997 2031
           ras.min_ey = y;
    


  • reply via email to

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