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: Wed, 04 Oct 2023 02:53:02 +0000

Alexei Podtelezhnikov pushed to branch smooth_malloc at FreeType / FreeType

Commits:

  • 79b26863
    by Alexei Podtelezhnikov (Алексей Подтележников) at 2023-10-03T22:49:17-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,44 @@ typedef ptrdiff_t FT_PtrDist;
    1920 1920
       )
    
    1921 1921
     
    
    1922 1922
     
    
    1923
    +  /*
    
    1924
    +   * The taxicab perimeter of the entire outline is used to estimate
    
    1925
    +   * the necessary memory pool or the job size in general.  Clipping
    
    1926
    +   * is ignored because it might hurt the performance.
    
    1927
    +   */
    
    1928
    +  static long
    
    1929
    +  gray_taxi( RAS_ARG )
    
    1930
    +  {
    
    1931
    +    FT_Outline*  outline = &ras.outline;
    
    1932
    +    short        c, p, first, last;
    
    1933
    +    FT_Vector    d, v;
    
    1934
    +    FT_Pos       taxi;
    
    1935
    +
    
    1936
    +
    
    1937
    +    taxi = 0;
    
    1938
    +    last = -1;
    
    1939
    +    for ( c = 0; c < outline->n_contours; c++ )
    
    1940
    +    {
    
    1941
    +      first = last + 1;
    
    1942
    +      last = outline->contours[c];
    
    1943
    +
    
    1944
    +      d = outline->points[last];
    
    1945
    +      for ( p = first; p <= last; p++ )
    
    1946
    +      {
    
    1947
    +        v    = outline->points[p];
    
    1948
    +        d.x -= v.x;
    
    1949
    +        d.y -= v.y;
    
    1950
    +
    
    1951
    +        taxi += FT_ABS( d.x ) + FT_ABS( d.y );
    
    1952
    +
    
    1953
    +        d = v;
    
    1954
    +      }
    
    1955
    +    }
    
    1956
    +
    
    1957
    +    return taxi >> 6;
    
    1958
    +  }
    
    1959
    +
    
    1960
    +
    
    1923 1961
       static int
    
    1924 1962
       gray_convert_glyph_inner( RAS_ARG_
    
    1925 1963
                                 int  continued )
    
    ... ... @@ -1935,7 +1973,7 @@ typedef ptrdiff_t FT_PtrDist;
    1935 1973
           if ( continued )
    
    1936 1974
             FT_Trace_Enable();
    
    1937 1975
     
    
    1938
    -      FT_TRACE7(( "band [%d..%d]: %td cell%s remaining/\n",
    
    1976
    +      FT_TRACE7(( "band [%d..%d]: %td cell%s remaining\n",
    
    1939 1977
                       ras.min_ey,
    
    1940 1978
                       ras.max_ey,
    
    1941 1979
                       ras.cell_null - ras.cell_free,
    
    ... ... @@ -1964,7 +2002,8 @@ typedef ptrdiff_t FT_PtrDist;
    1964 2002
     
    
    1965 2003
         TCell*   buffer;
    
    1966 2004
         size_t   height = (size_t)( yMax - yMin );
    
    1967
    -    size_t   n = FT_MAX_GRAY_POOL / 8;
    
    2005
    +    size_t   n;
    
    2006
    +    long     size;
    
    1968 2007
         TCoord   y;
    
    1969 2008
         TCoord   bands[32];  /* enough to accommodate bisections */
    
    1970 2009
         TCoord*  band;
    
    ... ... @@ -1972,11 +2011,18 @@ typedef ptrdiff_t FT_PtrDist;
    1972 2011
         int  continued = 0;
    
    1973 2012
     
    
    1974 2013
     
    
    1975
    -    if ( FT_QNEW_ARRAY ( buffer, FT_MAX_GRAY_POOL ) )
    
    2014
    +    size = gray_taxi( RAS_VAR ) +
    
    2015
    +           height * sizeof ( PCell ) / sizeof ( TCell ) +
    
    2016
    +           9;  /* empirical extra for local extrema */
    
    2017
    +
    
    2018
    +    if ( FT_QNEW_ARRAY( buffer, size ) )
    
    1976 2019
           return error;
    
    1977 2020
     
    
    2021
    +    FT_TRACE7(( "Allocated %ld cells (%ld bytes)\n",
    
    2022
    +                size, size * sizeof ( TCell ) ));
    
    2023
    +
    
    1978 2024
         /* Initialize the null cell at the end of the poll. */
    
    1979
    -    ras.cell_null        = buffer + FT_MAX_GRAY_POOL - 1;
    
    2025
    +    ras.cell_null        = buffer + size - 1;
    
    1980 2026
         ras.cell_null->x     = CELL_MAX_X_VALUE;
    
    1981 2027
         ras.cell_null->area  = 0;
    
    1982 2028
         ras.cell_null->cover = 0;
    
    ... ... @@ -1985,13 +2031,6 @@ typedef ptrdiff_t FT_PtrDist;
    1985 2031
         /* set up vertical bands */
    
    1986 2032
         ras.ycells     = (PCell*)buffer;
    
    1987 2033
     
    
    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 2034
         for ( y = yMin; y < yMax; )
    
    1996 2035
         {
    
    1997 2036
           ras.min_ey = y;
    


  • reply via email to

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