Changeset 2806 for libpipi/trunk


Ignore:
Timestamp:
Aug 29, 2008, 11:34:42 PM (12 years ago)
Author:
Sam Hocevar
Message:
  • pipi_template.h: factor the last unrolled preprocessor loop.
Location:
libpipi/trunk/pipi
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • libpipi/trunk/pipi/filter/blur.c

    r2802 r2806  
    150150#else /* XXX: the following functions use the template system */
    151151
    152 static pipi_image_t *SUFFIX(boxblur)(pipi_image_t *src, int m, int n)
     152static pipi_image_t *T(boxblur)(pipi_image_t *src, int m, int n)
    153153{
    154154    pipi_image_t *dst;
  • libpipi/trunk/pipi/filter/convolution.c

    r2804 r2806  
    113113#else /* XXX: the following functions use the template system */
    114114
    115 static pipi_image_t *SUFFIX(conv)(pipi_image_t *src,
    116                                   int m, int n, double mat[])
     115static pipi_image_t *T(conv)(pipi_image_t *src, int m, int n, double mat[])
    117116{
    118117    pipi_image_t *dst;
     
    180179}
    181180
    182 static pipi_image_t *SUFFIX(sepconv)(pipi_image_t *src,
    183                             int m, double hvec[], int n, double vvec[])
     181static pipi_image_t *T(sepconv)(pipi_image_t *src,
     182                                int m, double hvec[], int n, double vvec[])
    184183{
    185184    pipi_image_t *dst;
  • libpipi/trunk/pipi/paint/line.c

    r2799 r2806  
    240240    }
    241241
    242 static void SUFFIX(aaline)(pipi_image_t *img, struct line* s)
     242static void T(aaline)(pipi_image_t *img, struct line* s)
    243243{
    244244    float x1 = s->x1, y1 = s->y1, x2 = s->x2, y2 = s->y2;
     
    361361/* Solid line drawing function, using Bresenham's mid-point line
    362362 * scan-conversion algorithm. */
    363 static void SUFFIX(line)(pipi_image_t *img, struct line* s)
     363static void T(line)(pipi_image_t *img, struct line* s)
    364364{
    365365    int x1, y1, x2, y2;
  • libpipi/trunk/pipi/pipi_template.h

    r2794 r2806  
    1919 *    - SET_FLAG_GRAY
    2020 *    - SET_FLAG_WRAP
     21 *    - SET_FLAG_8BIT
    2122 *  * TEMPLATE_FILE is set to the template file. The following macros
    2223 *    will be defined when including it. Their value depend on the flags
     
    2425 *    - FLAG_GRAY is set to 0 or 1
    2526 *    - FLAG_WRAP is set to 0 or 1
    26  *    - SUFFIX(x) expands x by adding relevant information, eg. x##_gray_wrap
     27 *    - FLAG_8BIT is set to 0 or 1
     28 *    - T(x) expands x by adding relevant information, eg. x##_gray_wrap
    2729 */
    2830
     
    3032#   if (TEMPLATE_FLAGS) & SET_FLAG_GRAY
    3133#      define FLAG_GRAY 1
     34#      define T_GRAY(x) CAT(x, _gray)
    3235#      include __FILE__
    3336#      undef FLAG_GRAY
     37#      undef T_GRAY
    3438#   endif
    3539#   define FLAG_GRAY 0
     40#   define T_GRAY(x) x
    3641#   include __FILE__
    3742#   undef FLAG_GRAY
     43#   undef T_GRAY
    3844
    3945#elif !defined FLAG_WRAP
    4046#   if (TEMPLATE_FLAGS) & SET_FLAG_WRAP
    4147#      define FLAG_WRAP 1
     48#      define T_WRAP(x) CAT(x, _wrap)
    4249#      include __FILE__
    4350#      undef FLAG_WRAP
     51#      undef T_WRAP
    4452#   endif
    4553#   define FLAG_WRAP 0
     54#   define T_WRAP(x) x
    4655#   include __FILE__
    4756#   undef FLAG_WRAP
     57#   undef T_WRAP
    4858
    4959#elif !defined FLAG_8BIT
    5060#   if (TEMPLATE_FLAGS) & SET_FLAG_8BIT
    5161#      define FLAG_8BIT 1
     62#      define T_8BIT(x) CAT(x, _8bit)
    5263#      include __FILE__
    5364#      undef FLAG_8BIT
     65#      undef T_8BIT
    5466#   endif
    5567#   define FLAG_8BIT 0
     68#   define T_8BIT(x) x
    5669#   include __FILE__
    5770#   undef FLAG_8BIT
     71#   undef T_8BIT
    5872
    5973#else
    60     /* FIXME: I couldn't find a way to do this in one preprocessor pass,
    61      * too many levels of indirection seem to be needed. */
    62 #   if FLAG_8BIT
    63 #      if FLAG_WRAP
    64 #         if FLAG_GRAY
    65 #            define SUFFIX(x) x##_gray_wrap_8bit
    66 #         else
    67 #            define SUFFIX(x) x##_wrap_8bit
    68 #         endif
    69 #      else
    70 #         if FLAG_GRAY
    71 #            define SUFFIX(x) x##_gray_8bit
    72 #         else
    73 #            define SUFFIX(x) x##_8bit
    74 #         endif
    75 #      endif
    76 #   else
    77 #      if FLAG_WRAP
    78 #         if FLAG_GRAY
    79 #            define SUFFIX(x) x##_gray_wrap
    80 #         else
    81 #            define SUFFIX(x) x##_wrap
    82 #         endif
    83 #      else
    84 #         if FLAG_GRAY
    85 #            define SUFFIX(x) x##_gray
    86 #         else
    87 #            define SUFFIX(x) x
    88 #         endif
    89 #      endif
    90 #   endif
     74#   define CAT(x, y) x ## y
     75#   define T(x) T_8BIT(T_WRAP(T_GRAY(x)))
    9176#   include TEMPLATE_FILE
    92 #   undef SUFFIX
     77#   undef CAT
     78#   undef S
    9379#endif
    9480
Note: See TracChangeset for help on using the changeset viewer.