freetype-commit
[Top][All Lists]
Advanced

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

[Git][freetype/freetype][master] * src/raster/ftraster.c (Line_Up): Upda


From: Alexei Podtelezhnikov (@apodtele)
Subject: [Git][freetype/freetype][master] * src/raster/ftraster.c (Line_Up): Updated and fixed up.
Date: Sat, 11 Nov 2023 04:34:12 +0000

Alexei Podtelezhnikov pushed to branch master at FreeType / FreeType

Commits:

  • 028b0d5c
    by Alexei Podtelezhnikov (Алексей Подтележников) at 2023-11-10T23:25:26-05:00
    * src/raster/ftraster.c (Line_Up): Updated and fixed up.
    
    This largely synchronizes the entries into `Line_Up` and `Bezier_Up`.
    Minor bugs in the remainder calculations and accumulations are fixed.
    

1 changed file:

Changes:

  • src/raster/ftraster.c
    ... ... @@ -927,107 +927,87 @@
    927 927
                         Long  miny,
    
    928 928
                         Long  maxy )
    
    929 929
       {
    
    930
    -    Long   Dx, Dy;
    
    931
    -    Int    e1, e2, f1, f2, size;
    
    932
    -    Long   Ix, Rx, Ax;
    
    930
    +    Long  e, e2, Dx, Dy;
    
    931
    +    Long  Ix, Rx, Ax;
    
    932
    +    Int   size;
    
    933 933
     
    
    934
    -    PLong  top;
    
    934
    +    PLong top;
    
    935 935
     
    
    936 936
     
    
    937
    -    Dx = x2 - x1;
    
    938
    -    Dy = y2 - y1;
    
    937
    +    top = ras.top;
    
    939 938
     
    
    940
    -    if ( Dy <= 0 || y2 < miny || y1 > maxy )
    
    941
    -      return SUCCESS;
    
    939
    +    if ( y2 == y1 || y2 < miny || y1 > maxy )
    
    940
    +      goto Fin;
    
    942 941
     
    
    943
    -    if ( y1 < miny )
    
    944
    -    {
    
    945
    -      /* Take care: miny-y1 can be a very large value; we use     */
    
    946
    -      /*            a slow MulDiv function to avoid clipping bugs */
    
    947
    -      x1 += SMulDiv( Dx, miny - y1, Dy );
    
    948
    -      e1  = (Int)TRUNC( miny );
    
    949
    -      f1  = 0;
    
    950
    -    }
    
    951
    -    else
    
    952
    -    {
    
    953
    -      e1 = (Int)TRUNC( y1 );
    
    954
    -      f1 = (Int)FRAC( y1 );
    
    955
    -    }
    
    942
    +    e2 = y2 > maxy ? maxy : FLOOR( y2 );
    
    943
    +    e  = y1 < miny ? miny : CEILING( y1 );
    
    956 944
     
    
    957
    -    if ( y2 > maxy )
    
    958
    -    {
    
    959
    -      /* x2 += FMulDiv( Dx, maxy - y2, Dy );  UNNECESSARY */
    
    960
    -      e2  = (Int)TRUNC( maxy );
    
    961
    -      f2  = 0;
    
    962
    -    }
    
    963
    -    else
    
    945
    +    if ( ras.fresh )
    
    964 946
         {
    
    965
    -      e2 = (Int)TRUNC( y2 );
    
    966
    -      f2 = (Int)FRAC( y2 );
    
    947
    +      ras.cProfile->start = (Int)TRUNC( e );
    
    948
    +      ras.fresh = FALSE;
    
    967 949
         }
    
    968 950
     
    
    969
    -    if ( f1 > 0 )
    
    970
    -    {
    
    971
    -      if ( e1 == e2 )
    
    972
    -        return SUCCESS;
    
    973
    -      else
    
    974
    -      {
    
    975
    -        x1 += SMulDiv( Dx, ras.precision - f1, Dy );
    
    976
    -        e1 += 1;
    
    977
    -      }
    
    978
    -    }
    
    979
    -    else
    
    980
    -      if ( ras.joint )
    
    981
    -      {
    
    982
    -        ras.top--;
    
    983
    -        ras.joint = FALSE;
    
    984
    -      }
    
    951
    +    if ( y1 == e && ras.joint )
    
    952
    +      top--;
    
    985 953
     
    
    986
    -    ras.joint = (char)( f2 == 0 );
    
    954
    +    ras.joint = (Bool)( y2 == e2 );
    
    987 955
     
    
    988
    -    if ( ras.fresh )
    
    989
    -    {
    
    990
    -      ras.cProfile->start = e1;
    
    991
    -      ras.fresh           = FALSE;
    
    992
    -    }
    
    956
    +    if ( e2 < e )
    
    957
    +      goto Fin;
    
    993 958
     
    
    994
    -    size = e2 - e1 + 1;
    
    995
    -    if ( ras.top + size >= ras.maxBuff )
    
    959
    +    size = (Int)TRUNC( e2 - e ) + 1;
    
    960
    +
    
    961
    +    if ( top + size >= ras.maxBuff )
    
    996 962
         {
    
    997 963
           ras.error = FT_THROW( Raster_Overflow );
    
    998 964
           return FAILURE;
    
    999 965
         }
    
    1000 966
     
    
    1001
    -    if ( Dx > 0 )
    
    1002
    -    {
    
    1003
    -      Ix = SMulDiv_No_Round( ras.precision, Dx, Dy );
    
    1004
    -      Rx = ( ras.precision * Dx ) % Dy;
    
    1005
    -      Dx = 1;
    
    1006
    -    }
    
    1007
    -    else
    
    967
    +    Dx = x2 - x1;
    
    968
    +    Dy = y2 - y1;
    
    969
    +
    
    970
    +    if ( Dx == 0 )  /* very easy */
    
    1008 971
         {
    
    1009
    -      Ix = -SMulDiv_No_Round( ras.precision, -Dx, Dy );
    
    1010
    -      Rx = ( ras.precision * -Dx ) % Dy;
    
    1011
    -      Dx = -1;
    
    972
    +      do
    
    973
    +        *top++ = x1;
    
    974
    +      while ( --size );
    
    975
    +      goto Fin;
    
    1012 976
         }
    
    1013 977
     
    
    1014
    -    Ax  = -Dy;
    
    1015
    -    top = ras.top;
    
    978
    +    Ix     = SMulDiv_No_Round( e - y1, Dx, Dy );
    
    979
    +    x1    += Ix;
    
    980
    +    *top++ = x1;
    
    1016 981
     
    
    1017
    -    while ( size > 0 )
    
    982
    +    if ( --size )
    
    1018 983
         {
    
    1019
    -      *top++ = x1;
    
    984
    +      Ax = Dx * ( e - y1 )    - Dy * Ix;  /* remainder */
    
    985
    +      Ix = FMulDiv( ras.precision, Dx, Dy );
    
    986
    +      Rx = Dx * ras.precision - Dy * Ix;  /* remainder */
    
    987
    +      Dx = 1;
    
    1020 988
     
    
    1021
    -      x1 += Ix;
    
    1022
    -      Ax += Rx;
    
    1023
    -      if ( Ax >= 0 )
    
    989
    +      if ( x2 < x1 )
    
    1024 990
           {
    
    1025
    -        Ax -= Dy;
    
    1026
    -        x1 += Dx;
    
    991
    +        Ax = -Ax;
    
    992
    +        Rx = -Rx;
    
    993
    +        Dx = -Dx;
    
    1027 994
           }
    
    1028
    -      size--;
    
    995
    +
    
    996
    +      do
    
    997
    +      {
    
    998
    +        x1 += Ix;
    
    999
    +        Ax += Rx;
    
    1000
    +        if ( Ax >= Dy )
    
    1001
    +        {
    
    1002
    +          Ax -= Dy;
    
    1003
    +          x1 += Dx;
    
    1004
    +        }
    
    1005
    +        *top++ = x1;
    
    1006
    +      }
    
    1007
    +      while ( --size );
    
    1029 1008
         }
    
    1030 1009
     
    
    1010
    +  Fin:
    
    1031 1011
         ras.top = top;
    
    1032 1012
         return SUCCESS;
    
    1033 1013
       }
    


  • reply via email to

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