freetype-commit
[Top][All Lists]
Advanced

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

[Git][freetype/freetype][master] [base] Round values in `FT_MulAdd_Fix`.


From: Werner Lemberg (@wl)
Subject: [Git][freetype/freetype][master] [base] Round values in `FT_MulAdd_Fix`.
Date: Fri, 01 Jul 2022 12:02:05 +0000

Werner Lemberg pushed to branch master at FreeType / FreeType

Commits:

  • bec4ef41
    by Dominik Röttsches at 2022-07-01T14:01:08+02:00
    [base] Round values in `FT_MulAdd_Fix`.
    
    This avoids regressing Blink layout tests and makes `FT_MulAdd_Fix` delta
    retrieval implementation consistent with the previous implementation, which
    used `FT_fixedToInt` and included rounding.
    
    * src/base/ftcalc.c (FT_MulAdd_Fix): Implement it.
    Also fix remaining `temp` initialization compilation issue.
    
    Fixes #1169.
    

1 changed file:

Changes:

  • src/base/ftcalc.c
    ... ... @@ -1091,18 +1091,20 @@
    1091 1091
                     FT_UInt    count )
    
    1092 1092
       {
    
    1093 1093
         FT_UInt   i;
    
    1094
    -    FT_Int64  temp = 0;
    
    1094
    +    FT_Int64  temp;
    
    1095
    +#ifndef FT_INT64
    
    1096
    +    FT_Int64  halfUnit;
    
    1097
    +#endif
    
    1095 1098
     
    
    1096 1099
     
    
    1097 1100
     #ifdef FT_INT64
    
    1101
    +    temp = 0;
    
    1098 1102
     
    
    1099 1103
         for ( i = 0; i < count; ++i )
    
    1100 1104
           temp += (FT_Int64)s[i] * f[i];
    
    1101 1105
     
    
    1102
    -    return temp >> 16;
    
    1103
    -
    
    1106
    +    return ( temp + 0x8000 ) >> 16;
    
    1104 1107
     #else
    
    1105
    -
    
    1106 1108
         temp.hi = 0;
    
    1107 1109
         temp.lo = 0;
    
    1108 1110
     
    
    ... ... @@ -1137,6 +1139,11 @@
    1137 1139
           FT_Add64( &temp, &multResult, &temp );
    
    1138 1140
         }
    
    1139 1141
     
    
    1142
    +    /* Round value. */
    
    1143
    +    halfUnit.hi = 0;
    
    1144
    +    halfUnit.lo = 0x8000;
    
    1145
    +    FT_Add64( &temp, &halfUnit, &temp );
    
    1146
    +
    
    1140 1147
         return (FT_Int32)( ( (FT_Int32)( temp.hi & 0xFFFF ) << 16 ) |
    
    1141 1148
                                        ( temp.lo >> 16 )            );
    
    1142 1149
     
    


  • reply via email to

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