freetype-commit
[Top][All Lists]
Advanced

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

[Git][freetype/freetype][master] [base] Clean up contour indexing.


From: Alexei Podtelezhnikov (@apodtele)
Subject: [Git][freetype/freetype][master] [base] Clean up contour indexing.
Date: Mon, 20 Feb 2023 16:33:48 +0000

Alexei Podtelezhnikov pushed to branch master at FreeType / FreeType

Commits:

  • 34ed28d0
    by Alexei Podtelezhnikov at 2023-02-20T16:33:45+00:00
    [base] Clean up contour indexing.
    
    * src/base/ftoutln.c (FT_Outline_Reverse, FT_Outline_EmboldenXY,
    FT_Outline_Get_Orientation): Set the first and last indexes together.
    (FT_Outline_Decompose): Ditto and check them more stringently.
    * src/smooth/ftgrays.c (FT_Outline_Decompose)[STANDALONE_]: Ditto.

2 changed files:

Changes:

  • src/base/ftoutln.c
    ... ... @@ -58,7 +58,9 @@
    58 58
         FT_Error    error;
    
    59 59
     
    
    60 60
         FT_Int   n;         /* index of contour in outline     */
    
    61
    -    FT_UInt  first;     /* index of first point in contour */
    
    61
    +    FT_Int   first;     /* index of first point in contour */
    
    62
    +    FT_Int   last;      /* index of last point in contour  */
    
    63
    +
    
    62 64
         FT_Int   tag;       /* current point's state           */
    
    63 65
     
    
    64 66
         FT_Int   shift;
    
    ... ... @@ -73,18 +75,17 @@
    73 75
     
    
    74 76
         shift = func_interface->shift;
    
    75 77
         delta = func_interface->delta;
    
    76
    -    first = 0;
    
    77 78
     
    
    79
    +    last = -1;
    
    78 80
         for ( n = 0; n < outline->n_contours; n++ )
    
    79 81
         {
    
    80
    -      FT_Int  last;  /* index of last point in contour */
    
    81
    -
    
    82
    -
    
    83
    -      FT_TRACE5(( "FT_Outline_Decompose: Outline %d\n", n ));
    
    82
    +      FT_TRACE5(( "FT_Outline_Decompose: Contour %d\n", n ));
    
    84 83
     
    
    85
    -      last = outline->contours[n];
    
    86
    -      if ( last < 0 )
    
    84
    +      first = last + 1;
    
    85
    +      last  = outline->contours[n];
    
    86
    +      if ( last < first )
    
    87 87
             goto Invalid_Outline;
    
    88
    +
    
    88 89
           limit = outline->points + last;
    
    89 90
     
    
    90 91
           v_start   = outline->points[first];
    
    ... ... @@ -282,8 +283,6 @@
    282 283
         Close:
    
    283 284
           if ( error )
    
    284 285
             goto Exit;
    
    285
    -
    
    286
    -      first = (FT_UInt)last + 1;
    
    287 286
         }
    
    288 287
     
    
    289 288
         FT_TRACE5(( "FT_Outline_Decompose: Done\n" ));
    
    ... ... @@ -550,15 +549,13 @@
    550 549
         if ( !outline )
    
    551 550
           return;
    
    552 551
     
    
    553
    -    first = 0;
    
    554
    -
    
    552
    +    last = -1;
    
    555 553
         for ( n = 0; n < outline->n_contours; n++ )
    
    556 554
         {
    
    557
    -      last  = outline->contours[n];
    
    558
    -
    
    559 555
           /* keep the first contour point as is and swap points around it */
    
    560 556
           /* to guarantee that the cubic arches stay valid after reverse  */
    
    561
    -      first++;
    
    557
    +      first = last + 2;
    
    558
    +      last  = outline->contours[n];
    
    562 559
     
    
    563 560
           /* reverse point table */
    
    564 561
           {
    
    ... ... @@ -595,8 +592,6 @@
    595 592
               q--;
    
    596 593
             }
    
    597 594
           }
    
    598
    -
    
    599
    -      first = last + 1;
    
    600 595
         }
    
    601 596
     
    
    602 597
         outline->flags ^= FT_OUTLINE_REVERSE_FILL;
    
    ... ... @@ -945,7 +940,7 @@
    945 940
     
    
    946 941
         points = outline->points;
    
    947 942
     
    
    948
    -    first = 0;
    
    943
    +    last = -1;
    
    949 944
         for ( c = 0; c < outline->n_contours; c++ )
    
    950 945
         {
    
    951 946
           FT_Vector  in, out, anchor, shift;
    
    ... ... @@ -953,8 +948,9 @@
    953 948
           FT_Int     i, j, k;
    
    954 949
     
    
    955 950
     
    
    956
    -      l_in = 0;
    
    957
    -      last = outline->contours[c];
    
    951
    +      first = last + 1;
    
    952
    +      last  = outline->contours[c];
    
    953
    +      l_in  = 0;
    
    958 954
     
    
    959 955
           /* pacify compiler */
    
    960 956
           in.x = in.y = anchor.x = anchor.y = 0;
    
    ... ... @@ -1041,8 +1037,6 @@
    1041 1037
             in   = out;
    
    1042 1038
             l_in = l_out;
    
    1043 1039
           }
    
    1044
    -
    
    1045
    -      first = last + 1;
    
    1046 1040
         }
    
    1047 1041
     
    
    1048 1042
         return FT_Err_Ok;
    
    ... ... @@ -1058,7 +1052,7 @@
    1058 1052
         FT_Int      xshift, yshift;
    
    1059 1053
         FT_Vector*  points;
    
    1060 1054
         FT_Vector   v_prev, v_cur;
    
    1061
    -    FT_Int      c, n, first;
    
    1055
    +    FT_Int      c, n, first, last;
    
    1062 1056
         FT_Pos      area = 0;
    
    1063 1057
     
    
    1064 1058
     
    
    ... ... @@ -1090,11 +1084,11 @@
    1090 1084
     
    
    1091 1085
         points = outline->points;
    
    1092 1086
     
    
    1093
    -    first = 0;
    
    1087
    +    last = -1;
    
    1094 1088
         for ( c = 0; c < outline->n_contours; c++ )
    
    1095 1089
         {
    
    1096
    -      FT_Int  last = outline->contours[c];
    
    1097
    -
    
    1090
    +      first = last + 1;
    
    1091
    +      last  = outline->contours[c];
    
    1098 1092
     
    
    1099 1093
           v_prev.x = points[last].x >> xshift;
    
    1100 1094
           v_prev.y = points[last].y >> yshift;
    
    ... ... @@ -1110,8 +1104,6 @@
    1110 1104
     
    
    1111 1105
             v_prev = v_cur;
    
    1112 1106
           }
    
    1113
    -
    
    1114
    -      first = last + 1;
    
    1115 1107
         }
    
    1116 1108
     
    
    1117 1109
         if ( area > 0 )
    

  • src/smooth/ftgrays.c
    ... ... @@ -1666,6 +1666,8 @@ typedef ptrdiff_t FT_PtrDist;
    1666 1666
     
    
    1667 1667
         int   n;         /* index of contour in outline     */
    
    1668 1668
         int   first;     /* index of first point in contour */
    
    1669
    +    int   last;      /* index of last point in contour  */
    
    1670
    +
    
    1669 1671
         char  tag;       /* current point's state           */
    
    1670 1672
     
    
    1671 1673
         int   shift;
    
    ... ... @@ -1680,18 +1682,17 @@ typedef ptrdiff_t FT_PtrDist;
    1680 1682
     
    
    1681 1683
         shift = func_interface->shift;
    
    1682 1684
         delta = func_interface->delta;
    
    1683
    -    first = 0;
    
    1684 1685
     
    
    1686
    +    last = -1;
    
    1685 1687
         for ( n = 0; n < outline->n_contours; n++ )
    
    1686 1688
         {
    
    1687
    -      int  last;  /* index of last point in contour */
    
    1688
    -
    
    1689
    -
    
    1690
    -      FT_TRACE5(( "FT_Outline_Decompose: Outline %d\n", n ));
    
    1689
    +      FT_TRACE5(( "FT_Outline_Decompose: Contour %d\n", n ));
    
    1691 1690
     
    
    1691
    +      first = last + 1;
    
    1692 1692
           last  = outline->contours[n];
    
    1693
    -      if ( last < 0 )
    
    1693
    +      if ( last < first )
    
    1694 1694
             goto Invalid_Outline;
    
    1695
    +
    
    1695 1696
           limit = outline->points + last;
    
    1696 1697
     
    
    1697 1698
           v_start   = outline->points[first];
    
    ... ... @@ -1874,11 +1875,9 @@ typedef ptrdiff_t FT_PtrDist;
    1874 1875
                       v_start.x / 64.0, v_start.y / 64.0 ));
    
    1875 1876
           error = func_interface->line_to( &v_start, user );
    
    1876 1877
     
    
    1877
    -   Close:
    
    1878
    +    Close:
    
    1878 1879
           if ( error )
    
    1879 1880
             goto Exit;
    
    1880
    -
    
    1881
    -      first = last + 1;
    
    1882 1881
         }
    
    1883 1882
     
    
    1884 1883
         FT_TRACE5(( "FT_Outline_Decompose: Done\n", n ));
    


  • reply via email to

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