freetype-commit
[Top][All Lists]
Advanced

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

[Git][freetype/freetype-demos][master] * graph/grblit.c: Clean up pointe


From: Alexei Podtelezhnikov
Subject: [Git][freetype/freetype-demos][master] * graph/grblit.c: Clean up pointer and variable types.
Date: Thu, 18 Feb 2021 17:48:25 +0000

Alexei Podtelezhnikov pushed to branch master at FreeType / FreeType Demo Programs

Commits:

2 changed files:

Changes:

  • ChangeLog
    1
    +2021-02-18  Alexei Podtelezhnikov  <apodtele@gmail.com>
    
    2
    +
    
    3
    +	* graph/grblit.c: Clean up pointer and variable types.
    
    4
    +
    
    1 5
     2021-02-03  Werner Lemberg  <wl@gnu.org>
    
    2 6
     
    
    3 7
     	[ftgrid] Make `-f ... -e ...` work.
    

  • graph/grblit.c
    ... ... @@ -206,11 +206,10 @@
    206 206
             x = count;
    
    207 207
             while ( x > 0 )
    
    208 208
             {
    
    209
    -          unsigned char val;
    
    209
    +          unsigned int  val = *_read++;
    
    210 210
     
    
    211
    -          val = *_read++;
    
    212 211
               *_write++ |= (unsigned char)( (val >> shift) | old );
    
    213
    -          old = (unsigned int)val << shift2;
    
    212
    +          old = val << shift2;
    
    214 213
               x--;
    
    215 214
             }
    
    216 215
     
    
    ... ... @@ -536,7 +535,7 @@
    536 535
         if ( num_grays < 2 )
    
    537 536
         {
    
    538 537
           grError = gr_err_bad_argument;
    
    539
    -      return 0;
    
    538
    +      return NULL;
    
    540 539
         }
    
    541 540
     
    
    542 541
         for ( ; sat < limit; sat++ )
    
    ... ... @@ -551,28 +550,28 @@
    551 550
         /* not found, simply create a new entry if there is room */
    
    552 551
         if (gr_num_saturations < GR_MAX_SATURATIONS)
    
    553 552
         {
    
    554
    -      int          i;
    
    555
    -      const byte*  table;
    
    553
    +      int    i;
    
    554
    +      byte*  table;
    
    556 555
     
    
    557
    -      table = (const byte*)grAlloc( (size_t)( 3 * num_grays - 1 ) *
    
    558
    -                                    sizeof ( byte ) );
    
    559
    -      if (!table) return 0;
    
    556
    +      table = grAlloc( (size_t)( 3 * num_grays - 1 ) * sizeof ( byte ) );
    
    557
    +      if (!table)
    
    558
    +        return NULL;
    
    560 559
     
    
    561 560
           sat->count = num_grays;
    
    562 561
           sat->table = table;
    
    563 562
     
    
    564 563
           for ( i = 0; i < num_grays; i++, table++ )
    
    565
    -        *(unsigned char*)table = (unsigned char)i;
    
    564
    +        *table = (byte)i;
    
    566 565
     
    
    567 566
           for ( i = 2*num_grays-1; i > 0; i--, table++ )
    
    568
    -        *(unsigned char*)table = (unsigned char)(num_grays-1);
    
    567
    +        *table = (byte)(num_grays-1);
    
    569 568
     
    
    570 569
           gr_num_saturations++;
    
    571 570
           gr_last_saturation = sat;
    
    572
    -      return sat->table;
    
    571
    +      return table;
    
    573 572
         }
    
    574 573
         grError = gr_err_saturation_overflow;
    
    575
    -    return 0;
    
    574
    +    return NULL;
    
    576 575
       }
    
    577 576
     
    
    578 577
     
    
    ... ... @@ -632,7 +631,7 @@
    632 631
         if ( target_grays < 2 || source_grays < 2 )
    
    633 632
         {
    
    634 633
           grError = gr_err_bad_argument;
    
    635
    -      return 0;
    
    634
    +      return NULL;
    
    636 635
         }
    
    637 636
     
    
    638 637
         /* otherwise, scan table */
    
    ... ... @@ -649,27 +648,26 @@
    649 648
         /* not found, add a new conversion to the table */
    
    650 649
         if (gr_num_conversions < GR_MAX_CONVERSIONS)
    
    651 650
         {
    
    652
    -      const byte*  table;
    
    653
    -      int          n;
    
    651
    +      byte*  table;
    
    652
    +      int    n;
    
    654 653
     
    
    655
    -      table = (const byte*)grAlloc( (size_t)source_grays * sizeof ( byte ) );
    
    654
    +      table = grAlloc( (size_t)source_grays * sizeof ( byte ) );
    
    656 655
           if (!table)
    
    657
    -        return 0;
    
    656
    +        return NULL;
    
    658 657
     
    
    659 658
           conv->target_grays = target_grays;
    
    660 659
           conv->source_grays = source_grays;
    
    661 660
           conv->table        = table;
    
    662 661
     
    
    663 662
           for ( n = 0; n < source_grays; n++ )
    
    664
    -        ((unsigned char*)table)[n] = (unsigned char)(n*(target_grays-1) /
    
    665
    -                                         (source_grays-1));
    
    663
    +        table[n] = (byte)(n*(target_grays-1) / (source_grays-1));
    
    666 664
     
    
    667 665
           gr_num_conversions++;
    
    668 666
           gr_last_conversion = conv;
    
    669 667
           return table;
    
    670 668
         }
    
    671 669
         grError = gr_err_conversion_overflow;
    
    672
    -    return 0;
    
    670
    +    return NULL;
    
    673 671
       }
    
    674 672
     
    
    675 673
     
    
    ... ... @@ -689,7 +687,10 @@
    689 687
         int             y;
    
    690 688
         unsigned char*  read;
    
    691 689
         unsigned char*  write;
    
    692
    -
    
    690
    +#ifdef GR_CONFIG_GRAY_SKIP_WHITE
    
    691
    +    int  max = blit->source.grays - 1;
    
    692
    +    int  max2 = blit-target.grays - 1;
    
    693
    +#endif
    
    693 694
     
    
    694 695
         read  = blit->read  + blit->xread;
    
    695 696
         write = blit->write + blit->xwrite;
    
    ... ... @@ -704,12 +705,12 @@
    704 705
           while (x > 0)
    
    705 706
           {
    
    706 707
     #ifdef GR_CONFIG_GRAY_SKIP_WHITE
    
    707
    -        unsigned char val = *_read;
    
    708
    +        int  val = *_read;
    
    708 709
     
    
    709 710
             if (val)
    
    710 711
             {
    
    711 712
               if (val == max)
    
    712
    -            *_write = max2;
    
    713
    +            *_write = (byte)max2;
    
    713 714
               else
    
    714 715
                 *_write = saturation[ (int)*_write + conversion[ *_read ] ];
    
    715 716
             }
    
    ... ... @@ -743,10 +744,7 @@
    743 744
         unsigned char*  read;
    
    744 745
         unsigned char*  write;
    
    745 746
     #ifdef GR_CONFIG_GRAY_SKIP_WHITE
    
    746
    -    unsigned char   max;
    
    747
    -
    
    748
    -
    
    749
    -    max = (unsigned char)( blit->source.grays - 1 );
    
    747
    +    int  max = blit->source.grays - 1;
    
    750 748
     #endif
    
    751 749
     
    
    752 750
         read  = blit->read  + blit->xread;
    
    ... ... @@ -762,7 +760,7 @@
    762 760
           while (x > 0)
    
    763 761
           {
    
    764 762
     #ifdef GR_CONFIG_GRAY_SKIP_WHITE
    
    765
    -        unsigned char val = *_read;
    
    763
    +        int  val = *_read;
    
    766 764
     
    
    767 765
             if (val)
    
    768 766
             {
    
    ... ... @@ -820,15 +818,15 @@
    820 818
     
    
    821 819
     
    
    822 820
     #define inject555( color )                          \
    
    823
    -   ( ( (unsigned short)color.chroma[0] << 10 ) |    \
    
    824
    -     ( (unsigned short)color.chroma[1] <<  5 ) |    \
    
    825
    -       color.chroma[2]                         )
    
    821
    +   (unsigned short)( ( color.chroma[0] << 10 ) |    \
    
    822
    +                     ( color.chroma[1] <<  5 ) |    \
    
    823
    +                       color.chroma[2]           )
    
    826 824
     
    
    827 825
     
    
    828 826
     #define inject565( color )                          \
    
    829
    -   ( ( (unsigned short)color.chroma[0] << 11 ) |    \
    
    830
    -     ( (unsigned short)color.chroma[1] <<  5 ) |    \
    
    831
    -       color.chroma[2]                         )
    
    827
    +   (unsigned short)( ( color.chroma[0] << 11 ) |    \
    
    828
    +                     ( color.chroma[1] <<  5 ) |    \
    
    829
    +                       color.chroma[2]           )
    
    832 830
     
    
    833 831
     
    
    834 832
     /**************************************************************************/
    
    ... ... @@ -855,25 +853,22 @@
    855 853
         y = blit->height;
    
    856 854
         do
    
    857 855
         {
    
    858
    -      unsigned char*  _read  = read;
    
    859
    -      unsigned char*  _write = write;
    
    860
    -      int             x      = blit->width;
    
    856
    +      unsigned char*   _read  = read;
    
    857
    +      unsigned short*  _write = (unsigned short*)write;
    
    858
    +      int              x      = blit->width;
    
    861 859
     
    
    862 860
           while (x > 0)
    
    863 861
           {
    
    864
    -        unsigned char    val;
    
    862
    +        unsigned char  val = *_read;
    
    865 863
     
    
    866
    -        val = *_read;
    
    867 864
             if (val)
    
    868 865
             {
    
    869
    -          unsigned short* pixel = (unsigned short*)_write;
    
    870
    -
    
    871 866
               if (val >= 254 )
    
    872
    -            *pixel = (unsigned short)( sr | sg | sb );
    
    867
    +            *_write = (unsigned short)( sr | sg | sb );
    
    873 868
               else if ( val >= 2 )
    
    874 869
               {
    
    875 870
                 /* compose gray value */
    
    876
    -            int   pix = (int)*pixel;
    
    871
    +            int   pix = (int)*_write;
    
    877 872
                 int   dr  = pix & 0x7C00;
    
    878 873
                 int   dg  = pix & 0x03E0;
    
    879 874
                 int   db  = pix & 0x001F;
    
    ... ... @@ -887,10 +882,10 @@
    887 882
                 db += ((sb-db)*val) >> 8;
    
    888 883
                 db &= 0x001F;
    
    889 884
     
    
    890
    -            *pixel = (unsigned short)( dr | dg | db );
    
    885
    +            *_write = (unsigned short)( dr | dg | db );
    
    891 886
               }
    
    892 887
             }
    
    893
    -        _write +=2;
    
    888
    +        _write ++;
    
    894 889
             _read  ++;
    
    895 890
             x--;
    
    896 891
           }
    
    ... ... @@ -924,34 +919,31 @@
    924 919
         y = blit->height;
    
    925 920
         do
    
    926 921
         {
    
    927
    -      unsigned char*  _read  = read;
    
    928
    -      unsigned char*  _write = write;
    
    929
    -      int             x      = blit->width;
    
    922
    +      unsigned char*   _read  = read;
    
    923
    +      unsigned short*  _write = (unsigned short*)write;
    
    924
    +      int              x      = blit->width;
    
    930 925
     
    
    931 926
           while (x > 0)
    
    932 927
           {
    
    933
    -        unsigned char   val;
    
    928
    +        int  val = *_read;
    
    934 929
     
    
    935
    -        val = *_read;
    
    936 930
             if (val)
    
    937 931
             {
    
    938
    -          unsigned short* pixel = (unsigned short*)_write;
    
    939
    -
    
    940 932
               if (val == max)
    
    941
    -            *pixel = (unsigned short)(inject555( color ));
    
    933
    +            *_write = inject555( color );
    
    942 934
               else
    
    943 935
               {
    
    944 936
                 /* compose gray value */
    
    945
    -            unsigned short  pix16 = *pixel;
    
    937
    +            unsigned short  pix16 = *_write;
    
    946 938
                 grColor         pix;
    
    947 939
     
    
    948 940
                 extract555( pix16, pix );
    
    949 941
     
    
    950 942
                 compose_pixel( pix, color, val, max );
    
    951
    -            *pixel = (unsigned short)(inject555( pix ));
    
    943
    +            *_write = inject555( pix );
    
    952 944
               }
    
    953 945
             }
    
    954
    -        _write += 2;
    
    946
    +        _write ++;
    
    955 947
             _read  ++;
    
    956 948
             x--;
    
    957 949
           }
    
    ... ... @@ -988,25 +980,22 @@
    988 980
         y = blit->height;
    
    989 981
         do
    
    990 982
         {
    
    991
    -      unsigned char*  _read  = read;
    
    992
    -      unsigned char*  _write = write;
    
    993
    -      int             x      = blit->width;
    
    983
    +      unsigned char*   _read  = read;
    
    984
    +      unsigned short*  _write = (unsigned short*)write;
    
    985
    +      int              x      = blit->width;
    
    994 986
     
    
    995 987
           while (x > 0)
    
    996 988
           {
    
    997
    -        unsigned char    val;
    
    989
    +        unsigned char  val = *_read;
    
    998 990
     
    
    999
    -        val = *_read;
    
    1000 991
             if (val)
    
    1001 992
             {
    
    1002
    -          unsigned short* pixel = (unsigned short*)_write;
    
    1003
    -
    
    1004 993
               if (val >= 254 )
    
    1005
    -            *pixel = (unsigned short)( sr | sg | sb );
    
    994
    +            *_write = (unsigned short)( sr | sg | sb );
    
    1006 995
               else if ( val >= 2 )
    
    1007 996
               {
    
    1008 997
                 /* compose gray value */
    
    1009
    -            int   pix = (int)*pixel;
    
    998
    +            int   pix = (int)*_write;
    
    1010 999
                 int   dr  = pix & 0xF800;
    
    1011 1000
                 int   dg  = pix & 0x07E0;
    
    1012 1001
                 int   db  = pix & 0x001F;
    
    ... ... @@ -1020,10 +1009,10 @@
    1020 1009
                 db += ((sb-db)*val) >> 8;
    
    1021 1010
                 db &= 0x001F;
    
    1022 1011
     
    
    1023
    -            *pixel = (unsigned short)( dr | dg | db );
    
    1012
    +            *_write = (unsigned short)( dr | dg | db );
    
    1024 1013
               }
    
    1025 1014
             }
    
    1026
    -        _write +=2;
    
    1015
    +        _write ++;
    
    1027 1016
             _read  ++;
    
    1028 1017
             x--;
    
    1029 1018
           }
    
    ... ... @@ -1056,34 +1045,31 @@
    1056 1045
         y = blit->height;
    
    1057 1046
         do
    
    1058 1047
         {
    
    1059
    -      unsigned char*  _read  = read;
    
    1060
    -      unsigned char*  _write = write;
    
    1061
    -      int             x      = blit->width;
    
    1048
    +      unsigned char*   _read  = read;
    
    1049
    +      unsigned short*  _write = (unsigned short*)write;
    
    1050
    +      int              x      = blit->width;
    
    1062 1051
     
    
    1063 1052
           while (x > 0)
    
    1064 1053
           {
    
    1065
    -        unsigned char    val;
    
    1054
    +        int  val = *_read;
    
    1066 1055
     
    
    1067
    -        val = *_read;
    
    1068 1056
             if (val)
    
    1069 1057
             {
    
    1070
    -          unsigned short* pixel = (unsigned short*)_write;
    
    1071
    -
    
    1072 1058
               if (val == max)
    
    1073
    -            *pixel = (unsigned short)inject565( color );
    
    1059
    +            *_write = inject565( color );
    
    1074 1060
               else
    
    1075 1061
               {
    
    1076 1062
                 /* compose gray value */
    
    1077
    -            unsigned short  pix16 = *pixel;
    
    1063
    +            unsigned short  pix16 = *_write;
    
    1078 1064
                 grColor         pix;
    
    1079 1065
     
    
    1080 1066
                 extract565( pix16, pix );
    
    1081 1067
     
    
    1082 1068
                 compose_pixel( pix, color, val, max );
    
    1083
    -            *pixel = (unsigned short)inject565( pix );
    
    1069
    +            *_write = inject565( pix );
    
    1084 1070
               }
    
    1085 1071
             }
    
    1086
    -        _write +=2;
    
    1072
    +        _write ++;
    
    1087 1073
             _read  ++;
    
    1088 1074
             x--;
    
    1089 1075
           }
    
    ... ... @@ -1126,9 +1112,8 @@
    1126 1112
     
    
    1127 1113
           while (x > 0)
    
    1128 1114
           {
    
    1129
    -        unsigned char    val;
    
    1115
    +        unsigned char  val = *_read;
    
    1130 1116
     
    
    1131
    -        val = *_read;
    
    1132 1117
             if (val)
    
    1133 1118
             {
    
    1134 1119
               if (val >= 254)
    
    ... ... @@ -1187,9 +1172,8 @@
    1187 1172
     
    
    1188 1173
           while (x > 0)
    
    1189 1174
           {
    
    1190
    -        unsigned char    val;
    
    1175
    +        int  val = *_read;
    
    1191 1176
     
    
    1192
    -        val = *_read;
    
    1193 1177
             if (val)
    
    1194 1178
             {
    
    1195 1179
               if (val == max)
    
    ... ... @@ -1254,9 +1238,8 @@
    1254 1238
     
    
    1255 1239
           while (x > 0)
    
    1256 1240
           {
    
    1257
    -        unsigned char  val;
    
    1241
    +        int  val = *_read;
    
    1258 1242
     
    
    1259
    -        val = *_read;
    
    1260 1243
             if (val)
    
    1261 1244
             {
    
    1262 1245
               if (val == max)
    
    ... ... @@ -1333,11 +1316,9 @@
    1333 1316
     
    
    1334 1317
           while (x > 0)
    
    1335 1318
           {
    
    1336
    -        int    val0, val1, val2;
    
    1337
    -
    
    1338
    -        val0 = _read[0];
    
    1339
    -        val1 = _read[1];
    
    1340
    -        val2 = _read[2];
    
    1319
    +        int  val0 = _read[0];
    
    1320
    +        int  val1 = _read[1];
    
    1321
    +        int  val2 = _read[2];
    
    1341 1322
     
    
    1342 1323
             if ( val0 | val1 | val2 )
    
    1343 1324
             {
    
    ... ... @@ -1402,11 +1383,9 @@
    1402 1383
     
    
    1403 1384
           while (x > 0)
    
    1404 1385
           {
    
    1405
    -        int    val0, val1, val2;
    
    1406
    -
    
    1407
    -        val0 = _read[0];
    
    1408
    -        val1 = _read[1];
    
    1409
    -        val2 = _read[2];
    
    1386
    +        int  val0 = _read[0];
    
    1387
    +        int  val1 = _read[1];
    
    1388
    +        int  val2 = _read[2];
    
    1410 1389
     
    
    1411 1390
             if ( val0 | val1 | val2 )
    
    1412 1391
             {
    
    ... ... @@ -1471,11 +1450,9 @@
    1471 1450
     
    
    1472 1451
           while (x > 0)
    
    1473 1452
           {
    
    1474
    -        int    val0, val1, val2;
    
    1475
    -
    
    1476
    -        val0 = _read[2];
    
    1477
    -        val1 = _read[1];
    
    1478
    -        val2 = _read[0];
    
    1453
    +        int  val0 = _read[2];
    
    1454
    +        int  val1 = _read[1];
    
    1455
    +        int  val2 = _read[0];
    
    1479 1456
     
    
    1480 1457
             if ( val0 | val1 | val2 )
    
    1481 1458
             {
    
    ... ... @@ -1540,11 +1517,9 @@
    1540 1517
     
    
    1541 1518
           while (x > 0)
    
    1542 1519
           {
    
    1543
    -        int    val0, val1, val2;
    
    1544
    -
    
    1545
    -        val0 = _read[2];
    
    1546
    -        val1 = _read[1];
    
    1547
    -        val2 = _read[0];
    
    1520
    +        int  val0 = _read[2];
    
    1521
    +        int  val1 = _read[1];
    
    1522
    +        int  val2 = _read[0];
    
    1548 1523
     
    
    1549 1524
             if ( val0 | val1 | val2 )
    
    1550 1525
             {
    
    ... ... @@ -1614,11 +1589,9 @@
    1614 1589
     
    
    1615 1590
           while (x > 0)
    
    1616 1591
           {
    
    1617
    -        unsigned char    val0, val1, val2;
    
    1618
    -
    
    1619
    -        val0 = _read[0*line];
    
    1620
    -        val1 = _read[1*line];
    
    1621
    -        val2 = _read[2*line];
    
    1592
    +        int  val0 = _read[0*line];
    
    1593
    +        int  val1 = _read[1*line];
    
    1594
    +        int  val2 = _read[2*line];
    
    1622 1595
     
    
    1623 1596
             if ( val0 | val1 | val2 )
    
    1624 1597
             {
    
    ... ... @@ -1682,11 +1655,9 @@
    1682 1655
     
    
    1683 1656
           while (x > 0)
    
    1684 1657
           {
    
    1685
    -        unsigned char    val0, val1, val2;
    
    1686
    -
    
    1687
    -        val0 = _read[2*line];
    
    1688
    -        val1 = _read[1*line];
    
    1689
    -        val2 = _read[0*line];
    
    1658
    +        int  val0 = _read[2*line];
    
    1659
    +        int  val1 = _read[1*line];
    
    1660
    +        int  val2 = _read[0*line];
    
    1690 1661
     
    
    1691 1662
             if ( val0 | val1 | val2 )
    
    1692 1663
             {
    


  • reply via email to

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