Ignore:
Timestamp:
Apr 22, 2011, 7:32:09 PM (11 years ago)
Author:
Sam Hocevar
Message:

imlib: reimplement trans_image::put_scan_line so that it uses the
common template for all blitting functions.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • abuse/trunk/src/imlib/timage.cpp

    r531 r532  
    106106}
    107107
    108 void trans_image::put_scan_line(image *screen, int x, int y, int line)   // always transparent
    109 {
    110   int x1, y1, x2, y2;
    111   screen->GetClip(x1, y1, x2, y2);
    112   if (y + line < y1 || y + line >= y2 || x >= x2 || x + m_size.x - 1 < x1)
    113     return; // clipped off completely?
    114 
    115   uint8_t *datap=m_data;
    116   int ix;
    117   while (line)            // skip scan line data until we get to the line of interest
    118   {
    119     for (ix=0; ix<m_size.x; )
    120     {
    121       ix+=*datap;        // skip blank space
    122       datap++;
    123       if (ix<m_size.x)
    124       {
    125     int run_length=*datap;     // skip run
    126     ix+=run_length;
    127     datap+=run_length+1;
    128       }
    129     }
    130     line--;
    131     y++;
    132   }
    133 
    134 
    135   // now slam this list of runs to the screen
    136   screen->Lock();
    137   uint8_t *screen_line=screen->scan_line(y)+x;
    138 
    139   for (ix=0; ix<m_size.x; )
    140   {
    141     int skip=*datap;              // how much space to skip?
    142     datap++;
    143     screen_line+=skip;
    144     ix+=skip;
    145 
    146     if (ix<m_size.x)
    147     {
    148       int run_length=*datap;
    149       datap++;
    150 
    151       if (x+ix+run_length-1<x1)      // is this run clipped out totally?
    152       {
    153     datap+=run_length;
    154     ix+=run_length;
    155     screen_line+=run_length;
    156       }
    157       else
    158       {
    159     if (x+ix<x1)                 // is the run clipped partially?
    160     {
    161       int clip=(x1-(x+ix));
    162       datap+=clip;
    163       run_length-=clip;
    164       screen_line+=clip;
    165       ix+=clip;
    166     }
    167 
    168     if (x + ix >= x2)                      // clipped totally on the right?
    169         {
    170           screen->Unlock();
    171           return ;                        // we are done, return!
    172         }
    173     else if (x + ix + run_length > x2)    // partially clipped?
    174     {
    175       memcpy(screen_line, datap, x + ix + run_length - x2); // slam what we can
    176       screen->Unlock();
    177       return ;    // and return 'cause we are done with the line
    178         } else
    179         {
    180       memcpy(screen_line,datap,run_length);
    181       screen_line+=run_length;
    182         datap+=run_length;
    183         ix+=run_length;
    184         }
    185       }
    186     }
    187   }
    188   screen->Unlock();
    189 }
    190 
    191 
    192108uint8_t *trans_image::ClipToLine(image *screen, int x1, int y1, int x2, int y2,
    193109                                 int x, int &y, int &ysteps)
     
    219135    screen->AddDirty(Max(x, x1), y, Min(x + m_size.x, x2), y + m_size.y);
    220136    return parser;
    221 }
    222 
    223 void trans_image::PutFilled(image *screen, int x, int y, uint8_t color)
    224 {
    225     PutImageGeneric<FILLED>(screen, x, y, color, NULL, 0, 0, NULL, NULL,
    226                             0, 1, NULL, NULL, NULL);
    227137}
    228138
     
    238148
    239149    screen->GetClip(x1, y1, x2, y2);
     150
     151    if (N == SCANLINE)
     152    {
     153        y1 = Max(y1, y + amount);
     154        y2 = Min(y2, y + amount + 1);
     155        if (y1 >= y2)
     156            return;
     157    }
     158
    240159    uint8_t *datap = ClipToLine(screen, x1, y1, x2, y2, x, y, ysteps),
    241160            *screen_line, *blend_line = NULL, *paddr = NULL;
     
    294213            int count = Min(todo, Max(x2 - ix, 0));
    295214
    296             if (N == NORMAL)
     215            if (N == NORMAL || N == SCANLINE)
    297216            {
    298217                memcpy(screen_line, datap, count);
     
    312231                    *sl++ = remap[*sl2++];
    313232            }
    314             else if (N == DOUBLE_REMAP)
     233            else if (N == REMAP2)
    315234            {
    316235                uint8_t *sl = screen_line, *sl2 = datap;
     
    361280                                 uint8_t *remap, uint8_t *remap2)
    362281{
    363     PutImageGeneric<DOUBLE_REMAP>(screen, x, y, 0, NULL, 0, 0, remap, remap2,
    364                                   0, 1, NULL, NULL, NULL);
     282    PutImageGeneric<REMAP2>(screen, x, y, 0, NULL, 0, 0, remap, remap2,
     283                            0, 1, NULL, NULL, NULL);
    365284}
    366285
     
    398317}
    399318
     319void trans_image::PutFilled(image *screen, int x, int y, uint8_t color)
     320{
     321    PutImageGeneric<FILLED>(screen, x, y, color, NULL, 0, 0, NULL, NULL,
     322                            0, 1, NULL, NULL, NULL);
     323}
     324
    400325void trans_image::PutPredator(image *screen, int x, int y)
    401326{
     
    404329}
    405330
     331void trans_image::PutScanLine(image *screen, int x, int y, int line)
     332{
     333    PutImageGeneric<SCANLINE>(screen, x, y, 0, NULL, 0, 0, NULL, NULL,
     334                              line, 1, NULL, NULL, NULL);
     335}
     336
    406337size_t trans_image::MemUsage()
    407338{
Note: See TracChangeset for help on using the changeset viewer.