freetype-commit
[Top][All Lists]
Advanced

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

[Git][freetype/freetype][master] [smooth] Fix left shifts of negative nu


From: Werner Lemberg (@wl)
Subject: [Git][freetype/freetype][master] [smooth] Fix left shifts of negative numbers.
Date: Fri, 06 Aug 2021 06:36:43 +0000

Werner Lemberg pushed to branch master at FreeType / FreeType

Commits:

1 changed file:

Changes:

  • src/smooth/ftgrays.c
    ... ... @@ -1035,6 +1035,9 @@ typedef ptrdiff_t FT_PtrDist;
    1035 1035
     #  include <emmintrin.h>
    
    1036 1036
     #endif
    
    1037 1037
     
    
    1038
    +#define LEFT_SHIFT( a, b )  (FT_Int64)( (FT_UInt64)(a) << (b) )
    
    1039
    +
    
    1040
    +
    
    1038 1041
       static void
    
    1039 1042
       gray_render_conic( RAS_ARG_ const FT_Vector*  control,
    
    1040 1043
                                   const FT_Vector*  to )
    
    ... ... @@ -1126,13 +1129,15 @@ typedef ptrdiff_t FT_PtrDist;
    1126 1129
          *     EMIT(P)
    
    1127 1130
          *
    
    1128 1131
          * To ensure accurate results, perform computations on 64-bit
    
    1129
    -     * values, after scaling them by 2^32:
    
    1132
    +     * values, after scaling them by 2^32.
    
    1133
    +     *
    
    1134
    +     *           h = 1 / 2^N
    
    1130 1135
          *
    
    1131
    -     *     R << 32   = 2 * A << (32 - N - N)
    
    1132
    -     *               = A << (33 - 2 *N)
    
    1136
    +     *     R << 32 = 2 * A << (32 - N - N)
    
    1137
    +     *             = A << (33 - 2*N)
    
    1133 1138
          *
    
    1134
    -     *     Q << 32   = (2 * B << (32 - N)) + (A << (32 - N - N))
    
    1135
    -     *               = (B << (33 - N)) + (A << (32 - N - N))
    
    1139
    +     *     Q << 32 = (2 * B << (32 - N)) + (A << (32 - N - N))
    
    1140
    +     *             = (B << (33 - N)) + (A << (32 - 2*N))
    
    1136 1141
          */
    
    1137 1142
     
    
    1138 1143
     #ifdef __SSE2__
    
    ... ... @@ -1199,14 +1204,14 @@ typedef ptrdiff_t FT_PtrDist;
    1199 1204
         bx = p1.x - p0.x;
    
    1200 1205
         by = p1.y - p0.y;
    
    1201 1206
     
    
    1202
    -    rx = ax << ( 33 - 2 * shift );
    
    1203
    -    ry = ay << ( 33 - 2 * shift );
    
    1207
    +    rx = LEFT_SHIFT( ax, 33 - 2 * shift );
    
    1208
    +    ry = LEFT_SHIFT( ay, 33 - 2 * shift );
    
    1204 1209
     
    
    1205
    -    qx = ( bx << ( 33 - shift ) ) + ( ax << ( 32 - 2 * shift ) );
    
    1206
    -    qy = ( by << ( 33 - shift ) ) + ( ay << ( 32 - 2 * shift ) );
    
    1210
    +    qx = LEFT_SHIFT( bx, 33 - shift ) + LEFT_SHIFT( ax, 32 - 2 * shift );
    
    1211
    +    qy = LEFT_SHIFT( by, 33 - shift ) + LEFT_SHIFT( ay, 32 - 2 * shift );
    
    1207 1212
     
    
    1208
    -    px = (FT_Int64)p0.x << 32;
    
    1209
    -    py = (FT_Int64)p0.y << 32;
    
    1213
    +    px = LEFT_SHIFT( p0.x, 32 );
    
    1214
    +    py = LEFT_SHIFT( p0.y, 32 );
    
    1210 1215
     
    
    1211 1216
         for ( count = 1U << shift; count > 0; count-- )
    
    1212 1217
         {
    


  • reply via email to

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