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/transp.cpp

    r555 r665  
    1919void transp_put(image *im, image *screen, uint8_t *table, int x, int y)
    2020{
    21   int cx1, cy1, cx2, cy2;
    22   screen->GetClip(cx1, cy1, cx2, cy2);
    23   int xs=0,ys=0,xl=im->Size().x,yl=im->Size().y;
    24   if (x<cx1)
    25   {
    26     int chop=cx1-x;
    27     xs+=chop;
    28     xl-=chop;
    29     x+=chop;
    30   }
    31   if (y<cy1)
    32   {
    33     int chop=cy1-y;
    34     ys+=chop;
    35     yl-=chop;
    36     y+=chop;
    37   }
    38   if (x + xl >= cx2)
    39     xl = cx2 - 1 - x;
    40   if (y + yl >= cy2)
    41     yl = cy2 - 1 - y;
     21    vec2i caa, cbb;
     22    screen->GetClip(caa, cbb);
    4223
    43   if (xl<0 || yl<0) return ;
    44   screen->AddDirty(x, y, x + xl, y + yl);
     24    vec2i aa(0), bb = im->Size();
     25    vec2i pos(x, y);
    4526
    46   int ye=ys+yl;
    47   int xe=xs+xl;
     27    aa += Max(caa - pos, vec2i(0));
     28    bb -= Max(caa - pos, vec2i(0));
     29    pos = Max(caa, pos);
    4830
    49   uint8_t *isl=im->scan_line(ys)+xs;
     31    bb = Min(bb, cbb - vec2i(1) - pos);
     32
     33    if (!(bb >= vec2i(0)))
     34        return;
     35    screen->AddDirty(pos.x, pos.y, pos.x + bb.x, pos.y + bb.y);
     36
     37  int ye=aa.y+bb.y;
     38  int xe=aa.x+bb.x;
     39
     40  uint8_t *isl=im->scan_line(aa.y)+aa.x;
    5041  uint8_t *ssl=screen->scan_line(y)+x;
    5142  int iw=im->Size().x,sw=screen->Size().x;
    5243
    53   for (int iy=ys; iy<ye; iy++,y++,isl+=iw,ssl+=sw)
     44  for (int iy=aa.y; iy<ye; iy++,y++,isl+=iw,ssl+=sw)
    5445  {
    5546    uint8_t *s=ssl,*i=isl;
    56     for (int ix=xs; ix<xe; ix++,s++,i++)
     47    for (int ix=aa.x; ix<xe; ix++,s++,i++)
    5748    {
    5849      if (*i)
Note: See TracChangeset for help on using the changeset viewer.