Ignore:
Timestamp:
May 15, 2011, 5:32:56 PM (12 years ago)
Author:
Sam Hocevar
Message:

imlib: refactor GetClip?, SetClip? etc. to use vec2i.

File:
1 edited

Legend:

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

    r579 r665  
    8181void Filter::PutImage(image *screen, image *im, vec2i pos)
    8282{
    83     int cx1, cy1, cx2, cy2, x1 = 0, y1 = 0,
    84         x2 = im->Size().x, y2 = im->Size().y;
    85     screen->GetClip(cx1, cy1, cx2, cy2);
     83    vec2i aa = vec2i(0), bb = im->Size(), caa, cbb;
     84    screen->GetClip(caa, cbb);
    8685
    8786    // See if the image gets clipped off the screen
    88     if(pos.x >= cx2 || pos.y >= cy2 ||
    89        pos.x + (x2 - x1) <= cx1 || pos.y + (y2 - y1) <= cy1)
     87    if (!(pos < cbb && pos + (bb - aa) > caa))
    9088        return;
    9189
    92     x1 += Max(cx1 - pos.x, 0);
    93     y1 += Max(cy1 - pos.y, 0);
    94     pos.x = Max(pos.x, cx1);
    95     pos.y = Max(pos.y, cy1);
    96     x2 = Min(x2, cx2 - pos.x + x1);
    97     y2 = Min(y2, cy2 - pos.y + y1);
     90    aa += Max(caa - pos, 0);
     91    pos = Max(pos, caa);
     92    bb = Min(bb, cbb - pos + aa);
    9893
    99     if(x1 >= x2 || y1 >= y2)
     94    if (!(aa < bb))
    10095        return;
    10196
    102     int xl = x2 - x1;
    103     int yl = y2 - y1;
     97    vec2i span = bb - aa;
    10498
    105     screen->AddDirty(pos.x, pos.y, pos.x + xl, pos.y + yl);
     99    screen->AddDirty(pos.x, pos.y, pos.x + span.x, pos.y + span.y);
    106100
    107101    screen->Lock();
    108102    im->Lock();
    109103
    110     for(int j = 0; j < yl; j++)
     104    for (int j = 0; j < span.y; j++)
    111105    {
    112         uint8_t *source = im->scan_line(y1 + j) + x1;
    113         uint8_t *dest = screen->scan_line(pos.y + j) + pos.x;
     106        uint8_t *src = im->scan_line(aa.y + j) + aa.x;
     107        uint8_t *dst = screen->scan_line(pos.y + j) + pos.x;
    114108
    115         for(int i = 0; i < xl; i++, source++, dest++)
    116             if (*source)
    117                 *dest = m_table[*source];
     109        for (int i = 0; i < span.x; i++, src++, dst++)
     110            if (*src)
     111                *dst = m_table[*src];
    118112    }
    119113
Note: See TracChangeset for help on using the changeset viewer.