Changeset 2799


Ignore:
Timestamp:
08/29/08 00:27:35 (5 years ago)
Author:
sam
Message:
  • line.c: minor refactoring.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • libpipi/trunk/pipi/paint/line.c

    r2798 r2799  
    8383            s.color32 = c; 
    8484            s.buf_u32 = dstdata; 
    85             s.draw = aliased_line_8bit; 
     85            s.draw = line_8bit; 
    8686        } 
    8787        else 
     
    9393            s.colorf[0] = (c&0x000000FF)/255.0f;       /* XXX FIXME */ 
    9494            s.buf_f = dstdata; 
    95             s.draw = antialiased_line; 
     95            s.draw = aaline; 
    9696        } 
    9797    } 
     
    102102        s.colorf[0] = (c & 0xff) / 255.0f; /* XXX FIXME */ 
    103103        s.buf_f = dstdata; 
    104         s.draw = aa == 0 ? aliased_line_gray : antialiased_line_gray; 
     104        s.draw = aa ? aaline_gray : line_gray; 
    105105    } 
    106106    else 
     
    112112        s.colorf[0] = (c&0x000000FF)/255.0f;       /* XXX FIXME */ 
    113113        s.buf_f = dstdata; 
    114         s.draw = aa == 0 ? aliased_line : antialiased_line; 
     114        s.draw = aa ? aaline : line; 
    115115    } 
    116116 
     
    119119} 
    120120 
    121  
    122121int pipi_draw_polyline(pipi_image_t *img, int const x[], int const y[], 
    123122                       int n, uint32_t c, int aa) 
    124123{ 
    125124    int i; 
    126     struct line s; 
    127  
    128     if(img->last_modified == PIPI_PIXELS_RGBA_C) 
    129     { 
    130         if(!aa) 
    131         { 
    132             uint32_t  *dstdata; 
    133             dstdata = (uint32_t *)pipi_getpixels(img, PIPI_PIXELS_RGBA_C)->pixels; 
    134             s.color32 = c; 
    135             s.buf_u32 = dstdata; 
    136             s.draw = aliased_line_8bit; 
    137         } 
    138         else 
    139         { 
    140             float  *dstdata; 
    141             dstdata = (float *)pipi_getpixels(img, PIPI_PIXELS_RGBA_F)->pixels; 
    142             s.colorf[2] = ((c&0x00FF0000)>>16)/255.0f; /* XXX FIXME */ 
    143             s.colorf[1] = ((c&0x0000FF00)>>8)/255.0f;  /* XXX FIXME */ 
    144             s.colorf[0] = (c&0x000000FF)/255.0f;       /* XXX FIXME */ 
    145             s.buf_f = dstdata; 
    146             s.draw = antialiased_line; 
    147         } 
    148     } 
    149     else if(img->last_modified == PIPI_PIXELS_Y_F) 
    150     { 
    151         float  *dstdata; 
    152         dstdata = (float *)pipi_getpixels(img, PIPI_PIXELS_Y_F)->pixels; 
    153         s.colorf[0] = (c & 0xff) / 255.0f; /* XXX FIXME */ 
    154         s.buf_f = dstdata; 
    155         s.draw = aa == 0 ? aliased_line_gray : antialiased_line_gray; 
    156     } 
    157     else 
    158     { 
    159         float  *dstdata; 
    160         dstdata = (float *)pipi_getpixels(img, PIPI_PIXELS_RGBA_F)->pixels; 
    161         s.colorf[0] = (c&0x00FF0000)/255.0f; /* XXX FIXME */ 
    162         s.colorf[1] = (c&0x0000FF00)/255.0f; /* XXX FIXME */ 
    163         s.colorf[2] = (c&0x000000FF)/255.0f; /* XXX FIXME */ 
    164         s.buf_f = dstdata; 
    165         s.draw = aa == 0 ? aliased_line : antialiased_line; 
    166         img->last_modified = PIPI_PIXELS_RGBA_F; 
    167     } 
    168125 
    169126    for(i = 0; i < n; i++) 
    170     { 
    171         s.x1 = x[i]; 
    172         s.y1 = y[i]; 
    173         s.x2 = x[i+1]; 
    174         s.y2 = y[i+1]; 
    175         clip_line(img, &s); 
    176     } 
     127        pipi_draw_line(img, x[i], y[i], x[i + 1], y[i + 1], c, aa); 
     128 
    177129    return 0; 
    178130} 
     
    256208 
    257209#define PLOT(x, y, c) \ 
    258     if(FLAG_GRAY) \ 
     210    if(FLAG_8BIT) \ 
    259211    { \ 
    260         if(FLAG_8BIT) \ 
    261         { \ 
    262             /* TODO */ \ 
    263         } \ 
    264         else \ 
     212        /* TODO */ \ 
     213    } \ 
     214    else \ 
     215    { \ 
     216        if(FLAG_GRAY) \ 
    265217        { \ 
    266218            s->buf_f[((int)(x))+((int)(y))*img->w] =  \ 
     
    270222            if(s->buf_f[((int)(x))+((int)(y))*img->w] < 0.0f) \ 
    271223                s->buf_f[((int)(x))+((int)(y))*img->w] = 0.0f; \ 
    272             if(isnan(s->buf_f[((int)(x))+((int)(y))*img->w])) \ 
    273                 s->buf_f[((int)(x))+((int)(y))*img->w] = 0.0f; \ 
    274         } \ 
    275     } \ 
    276     else \ 
    277     { \ 
    278         if(FLAG_8BIT) \ 
    279         { \ 
    280             /* TODO */ \ 
    281224        } \ 
    282225        else \ 
    283         { \ 
     226        { \ 
    284227            int qwer = (((int)(x)*4))+((int)(y))*(img->w*4);\ 
    285228            int qweg = (1+((int)(x)*4))+((int)(y))*(img->w*4); \ 
     
    288231            s->buf_f[qweg] = (c*s->colorf[1]) + (1-c) * s->buf_f[qweg]; \ 
    289232            s->buf_f[qweb] = (c*s->colorf[2]) + (1-c) * s->buf_f[qweb]; \ 
    290             if(s->buf_f[qwer] > 1.0f) \ 
    291                 s->buf_f[qwer] = 1.0f; \ 
    292             if(s->buf_f[qwer] < 0.0f || isnan(s->buf_f[qwer])) \ 
    293                 s->buf_f[qwer] = 0.0f; \ 
    294             if(s->buf_f[qweg] > 1.0f) \ 
    295                 s->buf_f[qweg] = 1.0f; \ 
    296             if(s->buf_f[qweg] < 0.0f || isnan(s->buf_f[qweg])) \ 
    297                 s->buf_f[qweg] = 0.0f; \ 
    298             if(s->buf_f[qweb] > 1.0f) \ 
    299                 s->buf_f[qweb] = 1.0f; \ 
    300             if(s->buf_f[qweb] < 0.0f || isnan(s->buf_f[qweb])) \ 
    301                 s->buf_f[qweb] = 0.0f; \ 
     233            if(s->buf_f[qwer] > 1.0f) s->buf_f[qwer] = 1.0f; \ 
     234            if(s->buf_f[qwer] < 0.0f) s->buf_f[qwer] = 0.0f; \ 
     235            if(s->buf_f[qweg] > 1.0f) s->buf_f[qweg] = 1.0f; \ 
     236            if(s->buf_f[qweg] < 0.0f) s->buf_f[qweg] = 0.0f; \ 
     237            if(s->buf_f[qweb] > 1.0f) s->buf_f[qweb] = 1.0f; \ 
     238            if(s->buf_f[qweb] < 0.0f) s->buf_f[qweb] = 0.0f; \ 
    302239        } \ 
    303240    } 
    304241 
    305 static void SUFFIX(antialiased_line)(pipi_image_t *img, struct line* s) 
     242static void SUFFIX(aaline)(pipi_image_t *img, struct line* s) 
    306243{ 
    307244    float x1 = s->x1, y1 = s->y1, x2 = s->x2, y2 = s->y2; 
     
    424361/* Solid line drawing function, using Bresenham's mid-point line 
    425362 * scan-conversion algorithm. */ 
    426 static void SUFFIX(aliased_line)(pipi_image_t *img, struct line* s) 
     363static void SUFFIX(line)(pipi_image_t *img, struct line* s) 
    427364{ 
    428365    int x1, y1, x2, y2; 
Note: See TracChangeset for help on using the changeset viewer.