freetype-commit
[Top][All Lists]
Advanced

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

[Git][freetype/freetype][raster_2023] 2 commits: [Raster] Remove the jit


From: Alexei Podtelezhnikov (@apodtele)
Subject: [Git][freetype/freetype][raster_2023] 2 commits: [Raster] Remove the jitter exception.
Date: Thu, 02 Nov 2023 21:26:54 +0000

Alexei Podtelezhnikov pushed to branch raster_2023 at FreeType / FreeType

Commits:

  • 6e32e9b7
    by Alexei Podtelezhnikov (Алексей Подтележников) at 2023-11-02T17:25:31-04:00
     [Raster] Remove the jitter exception.
    
    The jitter exception used to be applied when two neighboring pixels
    were barely inside the outline. One the left one was turned on then,
    which contradicts the OpenType specifications.  Intended to remove
    glitches, it caused disappearing lines and was softened by adding an
    exception to the exception (#54589).
    
    * src/raster/ftraster.c (Vertical_Sweep_Span): Drop the jitter exception.
    
  • 9eb2ebc1
    by Alexei Podtelezhnikov (Алексей Подтележников) at 2023-11-02T17:26:16-04:00
    [raster] Modify the split condition.
    
    While curving close to a pixel center, vertical and horizontal pass
    might split the curve differently and cause a rare dropout.  This
    makes the split condition invariant of the sweep direction and more
    robust.
    
    * src/raster/ftraster.c (Bezier_Up): Modify the split condition.
    

1 changed file:

Changes:

  • src/raster/ftraster.c
    ... ... @@ -448,7 +448,6 @@
    448 448
         Int         precision_half;
    
    449 449
         Int         precision_scale;
    
    450 450
         Int         precision_step;
    
    451
    -    Int         precision_jitter;
    
    452 451
     
    
    453 452
         PLong       buff;               /* The profiles buffer                 */
    
    454 453
         PLong       sizeBuff;           /* Render pool size                    */
    
    ... ... @@ -549,27 +548,17 @@
    549 548
          *
    
    550 549
          *   256 / (1 << 12) = 0.0625 pixels.
    
    551 550
          *
    
    552
    -     * `precision_jitter' is an epsilon threshold used in
    
    553
    -     * `Vertical_Sweep_Span' to deal with small imperfections in the Bezier
    
    554
    -     * decomposition (after all, we are working with approximations only);
    
    555
    -     * it avoids switching on additional pixels which would cause artifacts
    
    556
    -     * otherwise.
    
    557
    -     *
    
    558
    -     * The value of `precision_jitter' has been determined heuristically.
    
    559
    -     *
    
    560 551
          */
    
    561 552
     
    
    562 553
         if ( High )
    
    563 554
         {
    
    564 555
           ras.precision_bits   = 12;
    
    565 556
           ras.precision_step   = 256;
    
    566
    -      ras.precision_jitter = 30;
    
    567 557
         }
    
    568 558
         else
    
    569 559
         {
    
    570 560
           ras.precision_bits   = 6;
    
    571 561
           ras.precision_step   = 32;
    
    572
    -      ras.precision_jitter = 2;
    
    573 562
         }
    
    574 563
     
    
    575 564
         ras.precision       = 1 << ras.precision_bits;
    
    ... ... @@ -1135,7 +1124,8 @@
    1135 1124
                           Long       miny,
    
    1136 1125
                           Long       maxy )
    
    1137 1126
       {
    
    1138
    -    Long   y1, y2, e, e2, e0;
    
    1127
    +    Long  y1, y2, e, e2, e0, dy;
    
    1128
    +    Long  dx, x2;
    
    1139 1129
     
    
    1140 1130
         TPoint*  start_arc;
    
    1141 1131
     
    
    ... ... @@ -1200,19 +1190,25 @@
    1200 1190
           ras.joint = FALSE;
    
    1201 1191
     
    
    1202 1192
           y2 = arc[0].y;
    
    1193
    +      x2 = arc[0].x;
    
    1203 1194
     
    
    1204 1195
           if ( y2 > e )
    
    1205 1196
           {
    
    1206
    -        y1 = arc[degree].y;
    
    1207
    -        if ( y2 - y1 >= ras.precision_step )
    
    1197
    +        dy = y2 - arc[degree].y;
    
    1198
    +        dx = x2 - arc[degree].x;
    
    1199
    +
    
    1200
    +
    
    1201
    +        /* split condition should be invariant of direction */
    
    1202
    +        if (  dy > ras.precision_step ||
    
    1203
    +              dx > ras.precision_step ||
    
    1204
    +             -dx > ras.precision_step )
    
    1208 1205
             {
    
    1209 1206
               splitter( arc );
    
    1210 1207
               arc += degree;
    
    1211 1208
             }
    
    1212 1209
             else
    
    1213 1210
             {
    
    1214
    -          *top++ = arc[degree].x + FMulDiv( arc[0].x - arc[degree].x,
    
    1215
    -                                            e - y1, y2 - y1 );
    
    1211
    +          *top++ = x2 - FMulDiv( y2 - e, dx, dy );
    
    1216 1212
               arc -= degree;
    
    1217 1213
               e   += ras.precision;
    
    1218 1214
             }
    
    ... ... @@ -1222,7 +1218,7 @@
    1222 1218
             if ( y2 == e )
    
    1223 1219
             {
    
    1224 1220
               ras.joint  = TRUE;
    
    1225
    -          *top++     = arc[0].x;
    
    1221
    +          *top++     = x2;
    
    1226 1222
     
    
    1227 1223
               e += ras.precision;
    
    1228 1224
             }
    
    ... ... @@ -2139,9 +2135,7 @@
    2139 2135
                                     PProfile    left,
    
    2140 2136
                                     PProfile    right )
    
    2141 2137
       {
    
    2142
    -    Long  e1, e2;
    
    2143
    -
    
    2144
    -    Int  dropOutControl = left->flags & 7;
    
    2138
    +    Int  e1, e2;
    
    2145 2139
     
    
    2146 2140
         FT_UNUSED( y );
    
    2147 2141
         FT_UNUSED( left );
    
    ... ... @@ -2153,20 +2147,8 @@
    2153 2147
                     ras.precision_bits, (double)x1 / (double)ras.precision,
    
    2154 2148
                     ras.precision_bits, (double)x2 / (double)ras.precision ));
    
    2155 2149
     
    
    2156
    -    /* Drop-out control */
    
    2157
    -
    
    2158
    -    e1 = CEILING( x1 );
    
    2159
    -    e2 = FLOOR( x2 );
    
    2160
    -
    
    2161
    -    /* take care of the special case where both the left */
    
    2162
    -    /* and right contour lie exactly on pixel centers    */
    
    2163
    -    if ( dropOutControl != 2                             &&
    
    2164
    -         x2 - x1 - ras.precision <= ras.precision_jitter &&
    
    2165
    -         e1 != x1 && e2 != x2                            )
    
    2166
    -      e2 = e1;
    
    2167
    -
    
    2168
    -    e1 = TRUNC( e1 );
    
    2169
    -    e2 = TRUNC( e2 );
    
    2150
    +    e1 = (Int)TRUNC( CEILING( x1 ) );
    
    2151
    +    e2 = (Int)TRUNC( FLOOR( x2 ) );
    
    2170 2152
     
    
    2171 2153
         if ( e2 >= 0 && e1 < ras.bWidth )
    
    2172 2154
         {
    
    ... ... @@ -2180,10 +2162,10 @@
    2180 2162
           if ( e2 >= ras.bWidth )
    
    2181 2163
             e2 = ras.bWidth - 1;
    
    2182 2164
     
    
    2183
    -      FT_TRACE7(( " -> x=[%ld;%ld]", e1, e2 ));
    
    2165
    +      FT_TRACE7(( " -> x=[%d;%d]", e1, e2 ));
    
    2184 2166
     
    
    2185
    -      c1 = (Int)( e1 >> 3 );
    
    2186
    -      c2 = (Int)( e2 >> 3 );
    
    2167
    +      c1 = e1 >> 3;
    
    2168
    +      c2 = e2 >> 3;
    
    2187 2169
     
    
    2188 2170
           f1 =  0xFF >> ( e1 & 7 );
    
    2189 2171
           f2 = ~0x7F >> ( e2 & 7 );
    


  • reply via email to

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