freetype-commit
[Top][All Lists]
Advanced

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

[Git][freetype/freetype][master] [raster] Harmonize target bitmap naviga


From: Alexei Podtelezhnikov (@apodtele)
Subject: [Git][freetype/freetype][master] [raster] Harmonize target bitmap navigation.
Date: Tue, 07 Nov 2023 00:05:15 +0000

Alexei Podtelezhnikov pushed to branch master at FreeType / FreeType

Commits:

  • 6338f2a6
    by Alexei Podtelezhnikov (Алексей Подтележников) at 2023-11-06T18:56:38-05:00
    [raster] Harmonize target bitmap navigation.
    
    * src/raster/ftraster.c (black_TWorker): Store signed maximum indexes
    in both directions instead of unsigned dimensions of the original bitmap.
    (*_Sweep_*, Render_Glyph, ft_black_render): Updated all users.
    

1 changed file:

Changes:

  • src/raster/ftraster.c
    ... ... @@ -459,10 +459,6 @@
    459 459
     
    
    460 460
         Byte        dropOutControl;     /* current drop_out control method     */
    
    461 461
     
    
    462
    -    UShort      bWidth;             /* target bitmap width                 */
    
    463
    -    PByte       bOrigin;            /* target bitmap bottom-left origin    */
    
    464
    -    PByte       bLine;              /* target bitmap current line          */
    
    465
    -
    
    466 462
         Long        lastX, lastY;
    
    467 463
         Long        minY, maxY;
    
    468 464
     
    
    ... ... @@ -480,9 +476,14 @@
    480 476
     
    
    481 477
         TStates     state;              /* rendering state                     */
    
    482 478
     
    
    483
    -    FT_Bitmap   target;             /* description of target bit/pixmap    */
    
    484 479
         FT_Outline  outline;
    
    485 480
     
    
    481
    +    Int         bTop;               /* target bitmap max line  index       */
    
    482
    +    Int         bRight;             /* target bitmap rightmost index       */
    
    483
    +    Int         bPitch;             /* target bitmap pitch                 */
    
    484
    +    PByte       bOrigin;            /* target bitmap bottom-left origin    */
    
    485
    +    PByte       bLine;              /* target bitmap current line          */
    
    486
    +
    
    486 487
         /* dispatch variables */
    
    487 488
     
    
    488 489
         Function_Sweep_Init*  Proc_Sweep_Init;
    
    ... ... @@ -2084,7 +2085,7 @@
    2084 2085
         FT_UNUSED( max );
    
    2085 2086
     
    
    2086 2087
     
    
    2087
    -    ras.bLine = ras.bOrigin - min * ras.target.pitch;
    
    2088
    +    ras.bLine = ras.bOrigin - min * ras.bPitch;
    
    2088 2089
       }
    
    2089 2090
     
    
    2090 2091
     
    
    ... ... @@ -2110,7 +2111,7 @@
    2110 2111
         e1 = (Int)TRUNC( CEILING( x1 ) );
    
    2111 2112
         e2 = (Int)TRUNC( FLOOR( x2 ) );
    
    2112 2113
     
    
    2113
    -    if ( e2 >= 0 && e1 < ras.bWidth )
    
    2114
    +    if ( e2 >= 0 && e1 <= ras.bRight )
    
    2114 2115
         {
    
    2115 2116
           Byte*  target;
    
    2116 2117
     
    
    ... ... @@ -2119,8 +2120,8 @@
    2119 2120
     
    
    2120 2121
           if ( e1 < 0 )
    
    2121 2122
             e1 = 0;
    
    2122
    -      if ( e2 >= ras.bWidth )
    
    2123
    -        e2 = ras.bWidth - 1;
    
    2123
    +      if ( e2 > ras.bRight )
    
    2124
    +        e2 = ras.bRight;
    
    2124 2125
     
    
    2125 2126
           FT_TRACE7(( " -> x=[%d;%d]", e1, e2 ));
    
    2126 2127
     
    
    ... ... @@ -2273,7 +2274,7 @@
    2273 2274
             /* bounding box instead                                           */
    
    2274 2275
             if ( pxl < 0 )
    
    2275 2276
               pxl = e1;
    
    2276
    -        else if ( TRUNC( pxl ) >= ras.bWidth )
    
    2277
    +        else if ( TRUNC( pxl ) > ras.bRight )
    
    2277 2278
               pxl = e2;
    
    2278 2279
     
    
    2279 2280
             /* check that the other pixel isn't set */
    
    ... ... @@ -2284,7 +2285,7 @@
    2284 2285
             c1 = (Int)( e1 >> 3 );
    
    2285 2286
             f1 = (Int)( e1 &  7 );
    
    2286 2287
     
    
    2287
    -        if ( e1 >= 0 && e1 < ras.bWidth     &&
    
    2288
    +        if ( e1 >= 0 && e1 <= ras.bRight    &&
    
    2288 2289
                  ras.bLine[c1] & ( 0x80 >> f1 ) )
    
    2289 2290
               goto Exit;
    
    2290 2291
           }
    
    ... ... @@ -2294,7 +2295,7 @@
    2294 2295
     
    
    2295 2296
         e1 = TRUNC( pxl );
    
    2296 2297
     
    
    2297
    -    if ( e1 >= 0 && e1 < ras.bWidth )
    
    2298
    +    if ( e1 >= 0 && e1 <= ras.bRight )
    
    2298 2299
         {
    
    2299 2300
           FT_TRACE7(( " -> x=%ld", e1 ));
    
    2300 2301
     
    
    ... ... @@ -2312,7 +2313,7 @@
    2312 2313
       static void
    
    2313 2314
       Vertical_Sweep_Step( RAS_ARG )
    
    2314 2315
       {
    
    2315
    -    ras.bLine -= ras.target.pitch;
    
    2316
    +    ras.bLine -= ras.bPitch;
    
    2316 2317
       }
    
    2317 2318
     
    
    2318 2319
     
    
    ... ... @@ -2366,13 +2367,13 @@
    2366 2367
         {
    
    2367 2368
           e1 = TRUNC( e1 );
    
    2368 2369
     
    
    2369
    -      if ( e1 >= 0 && (ULong)e1 < ras.target.rows )
    
    2370
    +      if ( e1 >= 0 && e1 <= ras.bTop )
    
    2370 2371
           {
    
    2371 2372
             Int    f1;
    
    2372 2373
             PByte  bits;
    
    2373 2374
     
    
    2374 2375
     
    
    2375
    -        bits = ras.bOrigin + ( y >> 3 ) - e1 * ras.target.pitch;
    
    2376
    +        bits = ras.bOrigin + ( y >> 3 ) - e1 * ras.bPitch;
    
    2376 2377
             f1   = 0x80 >> ( y & 7 );
    
    2377 2378
     
    
    2378 2379
             FT_TRACE7(( bits[0] & f1 ? " redundant"
    
    ... ... @@ -2388,13 +2389,13 @@
    2388 2389
         {
    
    2389 2390
           e2 = TRUNC( e2 );
    
    2390 2391
     
    
    2391
    -      if ( e2 >= 0 && (ULong)e2 < ras.target.rows )
    
    2392
    +      if ( e2 >= 0 && e2 <= ras.bTop )
    
    2392 2393
           {
    
    2393 2394
             Int    f1;
    
    2394 2395
             PByte  bits;
    
    2395 2396
     
    
    2396 2397
     
    
    2397
    -        bits = ras.bOrigin + ( y >> 3 ) - e2 * ras.target.pitch;
    
    2398
    +        bits = ras.bOrigin + ( y >> 3 ) - e2 * ras.bPitch;
    
    2398 2399
             f1   = 0x80 >> ( y & 7 );
    
    2399 2400
     
    
    2400 2401
             FT_TRACE7(( bits[0] & f1 ? " redundant"
    
    ... ... @@ -2491,7 +2492,7 @@
    2491 2492
             /* bounding box instead                                           */
    
    2492 2493
             if ( pxl < 0 )
    
    2493 2494
               pxl = e1;
    
    2494
    -        else if ( (ULong)( TRUNC( pxl ) ) >= ras.target.rows )
    
    2495
    +        else if ( TRUNC( pxl ) > ras.bTop )
    
    2495 2496
               pxl = e2;
    
    2496 2497
     
    
    2497 2498
             /* check that the other pixel isn't set */
    
    ... ... @@ -2499,12 +2500,11 @@
    2499 2500
     
    
    2500 2501
             e1 = TRUNC( e1 );
    
    2501 2502
     
    
    2502
    -        bits = ras.bOrigin + ( y >> 3 ) - e1 * ras.target.pitch;
    
    2503
    +        bits = ras.bOrigin + ( y >> 3 ) - e1 * ras.bPitch;
    
    2503 2504
             f1   = 0x80 >> ( y & 7 );
    
    2504 2505
     
    
    2505
    -        if ( e1 >= 0                     &&
    
    2506
    -             (ULong)e1 < ras.target.rows &&
    
    2507
    -             *bits & f1                  )
    
    2506
    +        if ( e1 >= 0 && e1 <= ras.bTop &&
    
    2507
    +             *bits & f1                )
    
    2508 2508
               goto Exit;
    
    2509 2509
           }
    
    2510 2510
           else
    
    ... ... @@ -2513,11 +2513,11 @@
    2513 2513
     
    
    2514 2514
         e1 = TRUNC( pxl );
    
    2515 2515
     
    
    2516
    -    if ( e1 >= 0 && (ULong)e1 < ras.target.rows )
    
    2516
    +    if ( e1 >= 0 && e1 <= ras.bTop )
    
    2517 2517
         {
    
    2518 2518
           FT_TRACE7(( " -> y=%ld", e1 ));
    
    2519 2519
     
    
    2520
    -      bits  = ras.bOrigin + ( y >> 3 ) - e1 * ras.target.pitch;
    
    2520
    +      bits  = ras.bOrigin + ( y >> 3 ) - e1 * ras.bPitch;
    
    2521 2521
           f1    = 0x80 >> ( y & 7 );
    
    2522 2522
     
    
    2523 2523
           bits[0] |= f1;
    
    ... ... @@ -2910,7 +2910,7 @@
    2910 2910
         ras.Proc_Sweep_Drop = Vertical_Sweep_Drop;
    
    2911 2911
         ras.Proc_Sweep_Step = Vertical_Sweep_Step;
    
    2912 2912
     
    
    2913
    -    error = Render_Single_Pass( RAS_VARS 0, 0, (Int)ras.target.rows - 1 );
    
    2913
    +    error = Render_Single_Pass( RAS_VARS 0, 0, ras.bTop );
    
    2914 2914
         if ( error )
    
    2915 2915
           return error;
    
    2916 2916
     
    
    ... ... @@ -2922,7 +2922,7 @@
    2922 2922
           ras.Proc_Sweep_Drop = Horizontal_Sweep_Drop;
    
    2923 2923
           ras.Proc_Sweep_Step = Horizontal_Sweep_Step;
    
    2924 2924
     
    
    2925
    -      error = Render_Single_Pass( RAS_VARS 1, 0, (Int)ras.target.width - 1 );
    
    2925
    +      error = Render_Single_Pass( RAS_VARS 1, 0, ras.bRight );
    
    2926 2926
           if ( error )
    
    2927 2927
             return error;
    
    2928 2928
         }
    
    ... ... @@ -3067,13 +3067,14 @@
    3067 3067
           return FT_THROW( Invalid_Argument );
    
    3068 3068
     
    
    3069 3069
         ras.outline = *outline;
    
    3070
    -    ras.target  = *target_map;
    
    3071 3070
     
    
    3072
    -    ras.bWidth  = (UShort)ras.target.width;
    
    3073
    -    ras.bOrigin = (Byte*)ras.target.buffer;
    
    3071
    +    ras.bTop    =   (Int)target_map->rows - 1;
    
    3072
    +    ras.bRight  =   (Int)target_map->width - 1;
    
    3073
    +    ras.bPitch  =   (Int)target_map->pitch;
    
    3074
    +    ras.bOrigin = (PByte)target_map->buffer;
    
    3074 3075
     
    
    3075
    -    if ( ras.target.pitch > 0 )
    
    3076
    -      ras.bOrigin += (Long)( ras.target.rows - 1 ) * ras.target.pitch;
    
    3076
    +    if ( ras.bPitch > 0 )
    
    3077
    +      ras.bOrigin += ras.bTop * ras.bPitch;
    
    3077 3078
     
    
    3078 3079
         return Render_Glyph( RAS_VAR );
    
    3079 3080
       }
    


  • reply via email to

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