Changeset 515


Ignore:
Timestamp:
Apr 20, 2011, 9:02:21 PM (7 years ago)
Author:
Sam Hocevar
Message:

imlib: image::Pixel and image::PutPixel? now use vec2i arguments.

Location:
abuse/trunk/src
Files:
16 edited

Legend:

Unmodified
Added
Removed
  • abuse/trunk/src/automap.cpp

    r512 r515  
    6262  if (draw_xstart==old_dx && draw_ystart==old_dy)
    6363  {
    64    automap_window->screen->lock();
     64   automap_window->screen->Lock();
    6565   automap_window->screen->add_dirty(centerx,centery,centerx,centery);
    6666    if ((tick++)&4)
    67       automap_window->screen->putpixel(centerx,centery,255);
     67      automap_window->screen->PutPixel(vec2i(centerx,centery),255);
    6868    else
    69       automap_window->screen->putpixel(centerx,centery,27);
    70    automap_window->screen->unlock();
     69      automap_window->screen->PutPixel(vec2i(centerx,centery),27);
     70   automap_window->screen->Unlock();
    7171    return ;
    7272  }
     
    136136      else
    137137        screen->bar(i,j,i+AUTOTILE_WIDTH-1,j+AUTOTILE_HEIGHT-1,0);
    138 
    139 
    140     }
    141 
    142   }
    143 
     138    }
     139  }
    144140
    145141  // draw the person as a dot, no need to add a dirty because we marked the
    146142  // whole screen already
    147   automap_window->screen->lock();
     143  automap_window->screen->Lock();
    148144  if ((tick++)&4)
    149     automap_window->screen->putpixel(centerx,centery,255);
     145    automap_window->screen->PutPixel(vec2i(centerx,centery),255);
    150146  else
    151     automap_window->screen->putpixel(centerx,centery,27);
    152   automap_window->screen->unlock();
     147    automap_window->screen->PutPixel(vec2i(centerx,centery),27);
     148  automap_window->screen->Unlock();
    153149
    154150  // set the clip back to full window size because soemthing else could mess with the area
    155151  automap_window->screen->set_clip(0,0,screen->Size().x-1,screen->Size().y-1);
    156152}
    157 
    158153
    159154void automap::toggle_window()
  • abuse/trunk/src/dev.cpp

    r513 r515  
    394394    new_height-=y+new_height-cy2;
    395395
    396   screen->lock();
    397   im->lock();
     396  screen->Lock();
     397  im->Lock();
    398398  for (iy=iy_start; new_height>0; new_height--,y++,iy+=ystep)
    399399  {
     
    403403      *sl2=sl1[ix>>16];
    404404  }
    405   im->unlock();
    406   screen->unlock();
     405  im->Unlock();
     406  screen->Unlock();
    407407}
    408408
     
    437437
    438438  uint8_t d;
    439   screen->lock();
     439  screen->Lock();
    440440  for (iy=iy_start; new_height>0; new_height--,y++,iy+=ystep)
    441441  {
     
    449449    }
    450450  }
    451   screen->unlock();
     451  screen->Unlock();
    452452}
    453453
  • abuse/trunk/src/endgame.cpp

    r513 r515  
    197197    *(si++)=jrand()%200;
    198198    *(si++)=c[jrand()%4];
    199     screen->putpixel(si[-3],si[-2],si[-1]);
     199    screen->PutPixel(vec2i(si[-3],si[-2]),si[-1]);
    200200  }
    201201  int32_t paddr[256];
     
    234234      int j;
    235235      for (si=sinfo,j=0; j<800; j++,si+=3)
    236         screen->putpixel(dx+si[0],dy+si[1],si[2]);
     236        screen->PutPixel(vec2i(dx+si[0],dy+si[1]),si[2]);
    237237
    238238      if (i>=30 && i<=37)
     
    286286      int j;
    287287      for (si=sinfo,j=0; j<800; j++,si+=3)
    288         screen->putpixel(dx+si[0],dy+si[1],si[2]);
     288        screen->PutPixel(vec2i(dx+si[0],dy+si[1]),si[2]);
    289289
    290290
     
    340340  int j;
    341341  for (si=sinfo,j=0; j<800; j++,si+=3)
    342     screen->putpixel(si[0],si[1],si[2]);
     342    screen->PutPixel(vec2i(si[0],si[1]),si[2]);
    343343
    344344  event ev;
     
    384384    int j;
    385385    for (si=sinfo,j=0; j<800; j++,si+=3)
    386       screen->putpixel(dx+si[0],dy+si[1],si[2]);
     386      screen->PutPixel(vec2i(dx+si[0],dy+si[1]),si[2]);
    387387
    388388    scan_map(screen,ex,ey,cache.img(planet),
  • abuse/trunk/src/game.cpp

    r513 r515  
    670670void remap_area(image *screen, int x1, int y1, int x2, int y2, uint8_t *remap)
    671671{
    672     screen->lock();
     672    screen->Lock();
    673673
    674674    uint8_t *sl = (uint8_t *)screen->scan_line(y1) + x1;
     
    684684        sl += step;
    685685    }
    686     screen->unlock();
     686    screen->Unlock();
    687687}
    688688
     
    736736  {
    737737    int c = v->draw_solid;
    738     screen->lock();
     738    screen->Lock();
    739739    for(int y = v->cy1; y <= v->cy2; y++)
    740740      memset(screen->scan_line(y)+v->cx1, c, v->cx2 - v->cx1 + 1);
    741     screen->unlock();
     741    screen->Unlock();
    742742    v->draw_solid = -1;
    743743    return;
     
    892892      else
    893893        screen->clear(wm->black());
    894       screen->lock();
     894      screen->Lock();
    895895      for(y = y1, draw_y = yo; y <= y2; y++, draw_y += yinc)
    896896      {
     
    917917    }
    918918      }
    919       screen->unlock();
     919      screen->Unlock();
    920920
    921921      if(dev & EDIT_MODE)
     
    14281428  recalc_local_view_space();   // now that we know what size the screen is...
    14291429
    1430   dark_color = get_color(cache.img(window_colors)->pixel(2, 0));
    1431   bright_color = get_color(cache.img(window_colors)->pixel(0, 0));
    1432   med_color = get_color(cache.img(window_colors)->pixel(1, 0));
    1433 
    1434   morph_dark_color = get_color(cache.img(window_colors)->pixel(2, 1));
    1435   morph_bright_color = get_color(cache.img(window_colors)->pixel(0, 1));
    1436   morph_med_color = get_color(cache.img(window_colors)->pixel(1, 1));
     1430  dark_color = get_color(cache.img(window_colors)->Pixel(vec2i(2, 0)));
     1431  bright_color = get_color(cache.img(window_colors)->Pixel(vec2i(0, 0)));
     1432  med_color = get_color(cache.img(window_colors)->Pixel(vec2i(1, 0)));
     1433
     1434  morph_dark_color = get_color(cache.img(window_colors)->Pixel(vec2i(2, 1)));
     1435  morph_bright_color = get_color(cache.img(window_colors)->Pixel(vec2i(0, 1)));
     1436  morph_med_color = get_color(cache.img(window_colors)->Pixel(vec2i(1, 1)));
    14371437  morph_sel_frame_color = pal->find_closest(255, 255, 0);
    14381438  light_connection_color = morph_sel_frame_color;
  • abuse/trunk/src/imlib/filter.cpp

    r512 r515  
    7575  CONDITION(colors>=0 && colors<=256,"bad colors value");
    7676  nc=colors;
    77   make_block(nc);
    7877  fdat=(unsigned char *)malloc(nc);
    7978  clear();
     
    8584  unsigned char *c;
    8685  CONDITION(im,"null image passed in filter::apply\n");
    87   im->lock();
     86  im->Lock();
    8887  for (y=im->Size().y-1; y>=0; y--)
    8988  {
     
    9594    }
    9695  }
    97   im->unlock();
     96  im->Unlock();
    9897}
    9998
     
    213212    screen->add_dirty(x, y, x + xl - 1, y + yl - 1);
    214213
    215     screen->lock();
    216     im->lock();
     214    screen->Lock();
     215    im->Lock();
    217216
    218217    uint8_t *pg1 = screen->scan_line(y), *source, *dest;
     
    232231    }
    233232
    234     im->unlock();
    235     screen->unlock();
    236 }
    237 
     233    im->Unlock();
     234    screen->Unlock();
     235}
     236
  • abuse/trunk/src/imlib/image.cpp

    r513 r515  
    8282image_descriptor::image_descriptor(vec2i size,
    8383                   int keep_dirties, int static_memory)
    84 
    85 { clipx1=0; clipy1=0;
    86   l=size.x; h=size.y;
    87   clipx2=l-1; clipy2=h-1;
    88   keep_dirt=keep_dirties;
    89   static_mem=static_memory;
     84{
     85    clipx1 = 0; clipy1 = 0;
     86    l = size.x; h = size.y;
     87    clipx2 = l - 1; clipy2 = h - 1;
     88    keep_dirt = keep_dirties;
     89    static_mem = static_memory;
    9090}
    9191
    9292void image::SetSize(vec2i new_size, uint8_t *page)
    9393{
    94     delete_page();
     94    DeletePage();
    9595    m_size = new_size;
    96     make_page(new_size, page);
     96    MakePage(new_size, page);
     97}
     98
     99void image::MakePage(vec2i size, uint8_t *page_buffer)
     100{
     101    m_data = page_buffer ? page_buffer : (uint8_t *)malloc(size.x * size.y);
     102}
     103
     104void image::DeletePage()
     105{
     106    if(!m_special || !m_special->static_mem)
     107        free(m_data);
    97108}
    98109
     
    102113    {
    103114        fprintf(stderr, "Error: image is locked upon deletion\n");
    104         unlock();
     115        Unlock();
    105116    }
    106117
    107118    image_list.unlink((linked_node *)this);
    108     delete_page();
    109     if(special)
    110         delete special;
    111 }
    112 
    113 
    114 void make_block(size_t size)
    115 {
    116   void *dat=malloc(size);
    117   CONDITION(dat, "Memory error : could not make block\n");
    118   if (dat) free((char *)dat);
    119 }
    120 
    121 uint8_t image::pixel(int16_t x, int16_t y)
    122 {
    123   CONDITION(x>=0 && x<m_size.x && y>=0 && y<m_size.y,
    124      "image::pixel Bad pixel xy");
    125   return (*(scan_line(y)+x));
    126 }
    127 
    128 void image::putpixel(int16_t x, int16_t y, char color)
    129 {
    130   CONDITION(x>=0 && x<m_size.x && y>=0 && y<m_size.y,
    131      "image::putpixel Bad pixel xy");
    132   if (special)
    133   { if (x>=special->x1_clip() && x<=special->x2_clip() &&
    134     y>=special->y1_clip() && y<=special->y2_clip())
    135       (*(scan_line(y)+x))=color;
    136   } else (*(scan_line(y)+x))=color;
     119    DeletePage();
     120    delete m_special;
     121}
     122
     123uint8_t image::Pixel(vec2i pos)
     124{
     125    CONDITION(pos.x >= 0 && pos.x < m_size.x && pos.y >= 0 && pos.y < m_size.y,
     126              "image::Pixel Bad pixel xy");
     127    return scan_line(pos.y)[pos.x];
     128}
     129
     130void image::PutPixel(vec2i pos, uint8_t color)
     131{
     132    CONDITION(pos.x >= 0 && pos.x < m_size.x && pos.y >= 0 && pos.y < m_size.y,
     133              "image::PutPixel Bad pixel xy");
     134
     135    if (m_special &&
     136         pos.x >= m_special->x1_clip() && pos.x <= m_special->x2_clip() &&
     137         pos.y >= m_special->y1_clip() && pos.y <= m_special->y2_clip())
     138        return;
     139
     140    scan_line(pos.y)[pos.x] = color;
    137141}
    138142
     
    144148    {
    145149        if (create_descriptor==2)
    146             special=new image_descriptor(size, 1, (page_buffer!=NULL));
     150            m_special=new image_descriptor(size, 1, (page_buffer!=NULL));
    147151        else
    148             special=new image_descriptor(size, 0, (page_buffer!=NULL));
     152            m_special=new image_descriptor(size, 0, (page_buffer!=NULL));
    149153    }
    150154    else
    151         special = NULL;
    152     make_page(size, page_buffer);
     155        m_special = NULL;
     156    MakePage(size, page_buffer);
    153157    image_list.add_end((linked_node *)this);
    154158    m_locked = false;
     
    160164    m_size.x = fp->read_uint16();
    161165    m_size.y = fp->read_uint16();
    162     special = NULL;
    163     make_page(m_size, NULL);
     166    m_special = NULL;
     167    MakePage(m_size, NULL);
    164168    for (int i = 0; i < m_size.y; i++)
    165169        fp->read(scan_line(i), m_size.x);
     
    172176    m_size.x = fp->read_uint16();
    173177    m_size.y = fp->read_uint16();
    174     special = NULL;
    175     make_page(m_size, NULL);
     178    m_special = NULL;
     179    MakePage(m_size, NULL);
    176180    for (int i = 0; i < m_size.y; i++)
    177181        fp->read(scan_line(i), m_size.x);
     
    180184}
    181185
    182 void image::lock()
     186void image::Lock()
    183187{
    184188    /* This is currently a no-op, because it's unneeded with SDL */
     
    189193}
    190194
    191 void image::unlock()
     195void image::Unlock()
    192196{
    193197    /* This is currently a no-op, because it's unneeded with SDL */
     
    237241    uint8_t *c;
    238242
    239     lock();
     243    Lock();
    240244    for(co = 0, i = m_size.y - 1; i >= 0; i--)
    241245    {
     
    244248            if(*c != background) co++;
    245249    }
    246     unlock();
     250    Unlock();
    247251    return co;
    248252}
     
    252256    int16_t i;
    253257
    254     lock();
     258    Lock();
    255259    if(color == -1)
    256260        color = current_background;
    257     if(special)
    258     {
    259         if(special->x1_clip() <= special->x2_clip())
    260             for(i = special->y2_clip(); i >= special->y1_clip(); i--)
    261                 memset(scan_line(i) + special->x1_clip(), color,
    262                        special->x2_clip() - special->x1_clip() + 1);
     261    if(m_special)
     262    {
     263        if(m_special->x1_clip() <= m_special->x2_clip())
     264            for(i = m_special->y2_clip(); i >= m_special->y1_clip(); i--)
     265                memset(scan_line(i) + m_special->x1_clip(), color,
     266                       m_special->x2_clip() - m_special->x1_clip() + 1);
    263267    }
    264268    else
     
    266270            memset(scan_line(i), color, m_size.x);
    267271    add_dirty(0, 0, m_size.x - 1, m_size.y - 1);
    268     unlock();
     272    Unlock();
    269273}
    270274
    271275image *image::copy()
    272276{
    273     lock();
     277    Lock();
    274278    image *im = new image(m_size);
    275     im->lock();
     279    im->Lock();
    276280    for(int i = m_size.y - 1; i >= 0; i--)
    277281        memcpy(im->scan_line(i), scan_line(i), m_size.x);
    278     im->unlock();
    279     unlock();
     282    im->Unlock();
     283    Unlock();
    280284    return im;
    281285}
     
    392396  er=0;
    393397
    394   lock();
     398  Lock();
    395399  if (n>m)
    396400  {
     
    421425    }
    422426  }
    423   unlock();
     427  Unlock();
    424428}
    425429
     
    431435
    432436    // the screen is clipped then we only want to put part of the image
    433     if(screen->special)
     437    if(screen->m_special)
    434438    {
    435439        put_part(screen, x, y, 0, 0, m_size.x-1, m_size.y-1, transparent);
     
    462466
    463467        screen->add_dirty(x, y, x + xl - 1, y + yl - 1);
    464         screen->lock();
    465         lock();
     468        screen->Lock();
     469        Lock();
    466470        for(j = starty; j < yl; j++, y++)
    467471        {
     
    481485                memcpy(&pg1[x], pg2, xl); // straight copy
    482486        }
    483         unlock();
    484         screen->unlock();
     487        Unlock();
     488        screen->Unlock();
    485489    }
    486490}
     
    492496  CHECK(x1<=x2 && y1<=y2);  // we should have gotten this
    493497
    494   if (screen->special)
    495   { x1=screen->special->bound_x1(x1);
    496     y1=screen->special->bound_y1(y1);
    497     x2=screen->special->bound_x2(x2);
    498     y2=screen->special->bound_y2(y2);
     498  if (screen->m_special)
     499  { x1=screen->m_special->bound_x1(x1);
     500    y1=screen->m_special->bound_y1(y1);
     501    x2=screen->m_special->bound_x2(x2);
     502    y2=screen->m_special->bound_y2(y2);
    499503  }
    500504  else
     
    517521    starty=0;
    518522  }
    519   screen->lock();
    520   lock();
     523  screen->Lock();
     524  Lock();
    521525  for (j=y1; j<=y2; j++)
    522526  {
     
    535539    }
    536540  }
    537   unlock();
    538   screen->unlock();
     541  Unlock();
     542  screen->Unlock();
    539543}
    540544
     
    584588  screen->add_dirty(x, y, x+xlen-1, y+ylen-1);
    585589
    586   screen->lock();
    587   lock();
     590  screen->Lock();
     591  Lock();
    588592  pg1=screen->scan_line(y);
    589593  pg2=scan_line(y1);
     
    606610    pg2=next_line(y1+j, pg2);
    607611  }
    608   unlock();
    609   screen->unlock();
     612  Unlock();
     613  screen->Unlock();
    610614}
    611615
     
    626630  { y-=y1; y1=0; }
    627631
    628   if (screen->special)
    629   {
    630     screen->special->get_clip(cx1, cy1, cx2, cy2);
     632  if (screen->m_special)
     633  {
     634    screen->m_special->get_clip(cx1, cy1, cx2, cy2);
    631635    if (x>cx2 || y>cy2 || x+(x2-x1)<0 || y+(y2-y1)<0) return ;
    632636    if (x<cx1)
     
    656660      yl=screen->Size().y-y;
    657661    screen->add_dirty(x, y, x+xl-1, y+yl-1);
    658     screen->lock();
    659     lock();
     662    screen->Lock();
     663    Lock();
    660664    for (j=0; j<yl; j++)
    661665    {
     
    671675          *dest=*source;
    672676    }
    673     unlock();
    674     screen->unlock();
     677    Unlock();
     678    screen->Unlock();
    675679  }
    676680}
     
    686690  CHECK(x1<=x2 && y1<=y2);
    687691
    688   if (screen->special)
    689   {
    690     screen->special->get_clip(cx1, cy1, cx2, cy2);
     692  if (screen->m_special)
     693  {
     694    screen->m_special->get_clip(cx1, cy1, cx2, cy2);
    691695    if (x>cx2 || y>cy2 || x+(x2-x1)<0 || y+(y2-y1)<0) return ;
    692696    if (x<cx1)
     
    719723      yl=screen->Size().y-y-1;
    720724    screen->add_dirty(x, y, x+xl-1, y+yl-1);
    721     screen->lock();
    722     mask->lock();
    723     lock();
     725    screen->Lock();
     726    mask->Lock();
     727    Lock();
    724728    for (j=0; j<yl; j++)
    725729    {
     
    737741      }
    738742    }
    739     unlock();
    740     mask->unlock();
    741     screen->unlock();
     743    Unlock();
     744    mask->Unlock();
     745    screen->Unlock();
    742746  }
    743747}
     
    750754  int32_t brv;
    751755  brv=0; bri=0;
    752   lock();
     756  Lock();
    753757  for (j=0; j<m_size.y; j++)
    754758  {
     
    762766    }
    763767  }
    764   unlock();
     768  Unlock();
    765769  return bri;
    766770}
     
    771775  int32_t brv, x;
    772776  brv=(int32_t)258*(int32_t)258*(int32_t)258; bri=0;
    773   lock();
     777  Lock();
    774778  for (j=0; j<m_size.y; j++)
    775779  {
     
    784788    }
    785789  }
    786   unlock();
     790  Unlock();
    787791  return bri;
    788792}
     
    800804    // If the image does not already have an Image descriptor, allocate one
    801805    // with no dirty rectangle keeping.
    802     if(!special)
    803         special = new image_descriptor(m_size.x, m_size.y, 0);
     806    if(!m_special)
     807        m_special = new image_descriptor(m_size.x, m_size.y, 0);
    804808
    805809    // set the image descriptor what the clip
    806810    // should be it will adjust to fit within the image.
    807     special->set_clip(x1, y1, x2, y2);
     811    m_special->set_clip(x1, y1, x2, y2);
    808812}
    809813
    810814void image::get_clip (int16_t &x1, int16_t &y1, int16_t &x2, int16_t &y2)
    811815{
    812   if (special)
    813     special->get_clip(x1, y1, x2, y2);
     816  if (m_special)
     817    m_special->get_clip(x1, y1, x2, y2);
    814818  else
    815819  { x1=0; y1=0; x2=m_size.x-1; y2=m_size.y-1; }
     
    818822void image::in_clip  (int16_t x1, int16_t y1, int16_t x2, int16_t y2)
    819823{
    820   if (special)
    821   {
    822     if (x1<special->x1_clip())
    823       x1=special->x1_clip();
    824     if (y1<special->y1_clip())
    825       y1=special->y1_clip();
    826     if (x2>special->x2_clip())
    827       x2=special->x2_clip();
    828     if (y2>special->y2_clip())
    829       y2=special->y2_clip();
     824  if (m_special)
     825  {
     826    if (x1<m_special->x1_clip())
     827      x1=m_special->x1_clip();
     828    if (y1<m_special->y1_clip())
     829      y1=m_special->y1_clip();
     830    if (x2>m_special->x2_clip())
     831      x2=m_special->x2_clip();
     832    if (y2>m_special->y2_clip())
     833      y2=m_special->y2_clip();
    830834  }
    831835  set_clip(x1, y1, x2, y2);
     
    10371041  int16_t y;
    10381042  if (x1>x2 || y1>y2) return ;
    1039   if (special)
    1040   { x1=special->bound_x1(x1);
    1041     y1=special->bound_y1(y1);
    1042     x2=special->bound_x2(x2);
    1043     y2=special->bound_y2(y2);
     1043  if (m_special)
     1044  { x1=m_special->bound_x1(x1);
     1045    y1=m_special->bound_y1(y1);
     1046    x2=m_special->bound_x2(x2);
     1047    y2=m_special->bound_y2(y2);
    10441048  }
    10451049  else
     
    10511055  if (x2<0 || y2<0 || x1>=m_size.x || y1>=m_size.y || x2<x1 || y2<y1)
    10521056    return ;
    1053   lock();
     1057  Lock();
    10541058  for (y=y1; y<=y2; y++)
    10551059    memset(scan_line(y)+x1, color, (x2-x1+1));
    1056   unlock();
     1060  Unlock();
    10571061  add_dirty(x1, y1, x2, y2);
    10581062}
     
    10621066  int16_t y, x;
    10631067  if (x1>x2 || y1>y2) return ;
    1064   if (special)
    1065   { x1=special->bound_x1(x1);
    1066     y1=special->bound_y1(y1);
    1067     x2=special->bound_x2(x2);
    1068     y2=special->bound_y2(y2);
     1068  if (m_special)
     1069  { x1=m_special->bound_x1(x1);
     1070    y1=m_special->bound_y1(y1);
     1071    x2=m_special->bound_x2(x2);
     1072    y2=m_special->bound_y2(y2);
    10691073  }
    10701074  else
     
    10771081    return ;
    10781082
    1079   lock();
     1083  Lock();
    10801084  uint8_t *sl=scan_line(y1)+x1;
    10811085  for (y=y1; y<=y2; y++)
     
    10861090    sl+=m_size.x;
    10871091  }
    1088   unlock();
     1092  Unlock();
    10891093
    10901094  add_dirty(x1, y1, x2, y2);
     
    10981102  ex=(uint8_t *)malloc(m_size.x);
    10991103
    1100   lock();
     1104  Lock();
    11011105  sl=scan_line(line);
    11021106  memcpy(ex, sl, m_size.x);
    1103   unlock();
     1107  Unlock();
    11041108
    11051109  if (bitsperpixel==1)      { mask=128;           bt=8; }
     
    11241128
    11251129  uint8_t *sl;
    1126   lock();
     1130  Lock();
    11271131  for (y=m_size.y-1; y>=0; y--)
    11281132  {
     
    11361140    }
    11371141  }
    1138   unlock();
     1142  Unlock();
    11391143}
    11401144
     
    11541158    vec2i old_size = m_size;
    11551159    uint8_t *im = (uint8_t *)malloc(old_size.x * old_size.y);
    1156     lock();
     1160    Lock();
    11571161    memcpy(im, scan_line(0), old_size.x * old_size.y);
    11581162
    1159     delete_page();
    1160     make_page(new_size, NULL);
     1163    DeletePage();
     1164    MakePage(new_size, NULL);
    11611165    m_size = new_size; // set the new height and width
    11621166
     
    11761180    }
    11771181    free(im);
    1178     if (special)
    1179         special->resize(new_size.x, new_size.y);
    1180     unlock();
     1182    if (m_special)
     1183        m_special->resize(new_size.x, new_size.y);
     1184    Unlock();
    11811185}
    11821186
     
    11851189  int16_t cx1, cy1, cx2, cy2;
    11861190  CHECK(x1>=0 && y1>=0 && x1<x2 && y1<y2 && x2<m_size.x && y2<m_size.y);
    1187   if (special)
    1188   {
    1189     special->get_clip(cx1, cy1, cx2, cy2);
     1191  if (m_special)
     1192  {
     1193    m_special->get_clip(cx1, cy1, cx2, cy2);
    11901194    x1=Max(x1, cx1); y1=Max(cy1, y1); x2=Min(x2, cx2); y2=Min(y2, cy2);
    11911195  }
     
    12231227    for (l=-smoothness; l<=smoothness; l++)
    12241228      if (i+k>smoothness && i+k<m_size.x-smoothness && j+l<m_size.y-smoothness && j+l>smoothness)
    1225         t+=pixel(i+k, j+l);
    1226       else t+=pixel(i, j);
    1227       im->putpixel(i, j, t/d);
     1229        t+=Pixel(vec2i(i+k, j+l));
     1230      else t+=Pixel(vec2i(i, j));
     1231      im->PutPixel(vec2i(i, j), t/d);
    12281232    }
    12291233  return im;
     
    12541258  fill_rec *recs=NULL, *r;
    12551259  uint8_t fcolor;
    1256   lock();
     1260  Lock();
    12571261  sl=scan_line(y);
    12581262  fcolor=sl[x];
     
    13281332    }
    13291333  } while (recs);
    1330   unlock();
     1334  Unlock();
    13311335}
    13321336
     
    13831387  else
    13841388  {
    1385     ret->lock();
    1386     lock();
     1389    ret->Lock();
     1390    Lock();
    13871391    for (y=y1, ry=0, dity=(y1%4)*4; y<=y2; y++, ry++)
    13881392    {
     
    14051409      dity+=4; if (dity>12) dity=0;
    14061410    }
    1407     unlock();
    1408     ret->unlock();
     1411    Unlock();
     1412    ret->Unlock();
    14091413  }
    14101414  return ret;
     
    14181422
    14191423  /* FIXME: Abuse Win32 uses RestoreSurface() here instead of locking */
    1420   lock();
     1424  Lock();
    14211425  for (y=0; y<m_size.y; y++)
    14221426  { sl=scan_line(y);
     
    14251429    memcpy(sl, rev, m_size.x);
    14261430  }
    1427   unlock();
     1431  Unlock();
    14281432  free(rev);
    14291433}
     
    14361440
    14371441  /* FIXME: Abuse Win32 uses RestoreSurface() here instead of locking */
    1438   lock();
     1442  Lock();
    14391443  for (y=0; y<m_size.y/2; y++)
    14401444  { sl=scan_line(y);
     
    14431447    memcpy(scan_line(m_size.y-y-1), rev, m_size.x);
    14441448  }
    1445   unlock();
     1449  Unlock();
    14461450  free(rev);
    14471451}
     
    14511455  uint8_t *sl;
    14521456  int y, x;
    1453   lock();
     1457  Lock();
    14541458  for (y=0; y<m_size.y; y++)
    14551459  {
     
    14591463        *sl=color;
    14601464  }
    1461   unlock();
    1462 }
     1465  Unlock();
     1466}
  • abuse/trunk/src/imlib/image.h

    r513 r515  
    1818#include "specs.h"
    1919#define MAX_DIRTY 200
    20 #define Inew(pointer,type); { make_block(sizeof(type)); pointer=new type; }
    2120
    2221extern char const *imerr_messages[];  // correspond to imERRORS
     
    3433void set_error(int16_t x);
    3534int16_t last_error();
    36 void make_block(size_t size);
    3735void image_init();
    3836void image_uninit();
     
    5654  { dx1=x1; dy1=y1; dx2=x2; dy2=y2;
    5755    if(x2<x1 || y2<y1)
    58       printf("add inccorect dirty\n");
     56      printf("add incorrect dirty\n");
    5957  }
    6058  virtual int16_t compare(void *n1, int16_t field)
     
    119117    uint8_t *m_data;
    120118    vec2i m_size;
    121 
    122     void make_page(vec2i size, uint8_t *page_buffer);
    123     void delete_page();
    124119    bool m_locked;
    125120
     121    void MakePage(vec2i size, uint8_t *page_buffer);
     122    void DeletePage();
     123
    126124public:
    127     image_descriptor *special;
     125    image_descriptor *m_special;
    128126
    129127    image(spec_entry *e, bFILE *fp);
     
    132130    ~image();
    133131
    134     void lock();
    135     void unlock();
    136 
    137     uint8_t pixel(int16_t x, int16_t y);
    138     void putpixel(int16_t x, int16_t y, char color);
    139     uint8_t *scan_line(int16_t y)
     132    void Lock();
     133    void Unlock();
     134
     135    uint8_t Pixel(vec2i pos);
     136    void PutPixel(vec2i pos, uint8_t color);
     137
     138    inline uint8_t *scan_line(int16_t y)
    140139    {
    141140        return m_data + y * m_size.x;
    142141    }
    143     uint8_t *next_line(int16_t lasty, uint8_t *last_scan)
     142    inline uint8_t *next_line(int16_t lasty, uint8_t *last_scan)
    144143    {
    145144        return last_scan + m_size.x;
     
    181180    void dirt_off()
    182181    {
    183         if(special && special->keep_dirt) special->keep_dirt = 0;
     182        if(m_special && m_special->keep_dirt) m_special->keep_dirt = 0;
    184183    }
    185184    void dirt_on()
    186185    {
    187         if(special) special->keep_dirt = 1;
     186        if(m_special) m_special->keep_dirt = 1;
    188187    }
    189188
    190189    void add_dirty(int x1, int y1, int x2, int y2)
    191190    {
    192         if(special) special->add_dirty(x1, y1, x2, y2);
     191        if(m_special) m_special->add_dirty(x1, y1, x2, y2);
    193192    }
    194193    void delete_dirty(int x1, int y1, int x2, int y2)
    195194    {
    196         if(special) special->delete_dirty(x1, y1, x2, y2);
     195        if(m_special) m_special->delete_dirty(x1, y1, x2, y2);
    197196    }
    198197    void clear_dirties()
    199198    {
    200         if(special) special->clear_dirties();
     199        if(m_special) m_special->clear_dirties();
    201200    }
    202201    void dither(palette *pal); // use a b&w palette!
  • abuse/trunk/src/imlib/include.cpp

    r512 r515  
    6161      for (x=0; x<size.x; x++,i++)
    6262      {
    63         fprintf(fp,"%d",(int)im->pixel(x,y));
     63        fprintf(fp,"%d",(int)im->Pixel(vec2i(x,y)));
    6464        if (i==max)
    6565          fprintf(fp,"};\n\n");
  • abuse/trunk/src/imlib/scroller.cpp

    r512 r515  
    6262  remap[2]=wm->dark_color();
    6363
    64   screen->lock();
     64  screen->Lock();
    6565  for (int yc=ich; yc; yc--,y++)
    6666  {
     
    7676  }
    7777  screen->add_dirty(x,y,x+icw-1,y+ich-1);
    78   screen->unlock();
     78  screen->Unlock();
    7979}
    8080
  • abuse/trunk/src/imlib/timage.cpp

    r513 r515  
    4040  image *im=new image(vec2i(w,h));
    4141
    42   im->lock();
     42  im->Lock();
    4343  uint8_t *d=im->scan_line(0),*dp=data,*dline;
    4444  int y,x;
     
    6464    d=im->next_line(y,d);
    6565  }
    66   im->unlock();
     66  im->Unlock();
    6767  return im;
    6868}
     
    7575  h=im->Size().y;
    7676
    77   im->lock();
     77  im->Lock();
    7878
    7979  // first we must find out how much data to allocate
     
    134134    }
    135135  }
    136   im->unlock();
     136  im->Unlock();
    137137}
    138138
     
    165165
    166166  // now slam this list of runs to the screen
    167   screen->lock();
     167  screen->Lock();
    168168  uint8_t *screen_line=screen->scan_line(y)+x;
    169169
     
    199199    if (x+ix>x2)                      // clipped totally on the right?
    200200        {
    201           screen->unlock();
     201          screen->Unlock();
    202202          return ;                        // we are done, return!
    203203        }
     
    205205    {
    206206      memcpy(screen_line,datap,(x+ix+run_length-1)-x2);   // slam what we can
    207           screen->unlock();
     207          screen->Unlock();
    208208      return ;    // and return 'cause we are done with the line
    209209        } else
     
    217217    }
    218218  }
    219   screen->unlock();
     219  screen->Unlock();
    220220}
    221221
     
    273273  if (!datap) return ;     // if clip_y says nothing to draw, return
    274274
    275   screen->lock();
     275  screen->Lock();
    276276
    277277  screen_line=screen->scan_line(y)+x;
     
    335335    screen_line+=sw;
    336336  }
    337   screen->unlock();
     337  screen->Unlock();
    338338}
    339339
     
    344344  uint8_t skip,*datap=data;
    345345
    346   screen->lock();
     346  screen->Lock();
    347347  screen_skip = screen->Size().x - w;
    348348  for (; ysteps; ysteps--)
     
    374374    s_off+=screen_skip;
    375375  }
    376   screen->unlock();
     376  screen->Unlock();
    377377}
    378378
     
    386386  if (!datap) return ;     // if clip_y says nothing to draw, return
    387387
    388   screen->lock();
     388  screen->Lock();
    389389  screen_line=screen->scan_line(y)+x;
    390390  int sw=screen->Size().x;
     
    439439    screen_line+=sw;
    440440  }
    441   screen->unlock();
     441  screen->Unlock();
    442442}
    443443
     
    451451  if (!datap) return ;     // if clip_y says nothing to draw, return
    452452
    453   screen->lock();
     453  screen->Lock();
    454454  screen_line=screen->scan_line(y)+x;
    455455  int sw=screen->Size().x;
     
    515515    screen_line+=sw;
    516516  }
    517   screen->unlock();
     517  screen->Unlock();
    518518}
    519519
     
    529529  if (!datap) return ;     // if clip_y says nothing to draw, return
    530530
    531   screen->lock();
     531  screen->Lock();
    532532  screen_line=screen->scan_line(y)+x;
    533533  int sw=screen->Size().x;
     
    593593    screen_line+=sw;
    594594  }
    595   screen->unlock();
     595  screen->Unlock();
    596596}
    597597
     
    614614
    615615  long fixmul=(frame_on<<16)/total_frames;
    616   screen->lock();
     616  screen->Lock();
    617617  for (; ysteps>0; ysteps--,y++)
    618618  {
     
    685685    }
    686686  }
    687   screen->unlock();
     687  screen->Unlock();
    688688}
    689689
     
    704704  if (!datap) return ;
    705705
    706   screen->lock();
     706  screen->Lock();
    707707  uint8_t *screen_run,*paddr=(uint8_t *)pal->addr(),
    708708                *caddr1,*caddr2,r_dest,g_dest,b_dest;
     
    779779    }
    780780  }
    781   screen->unlock();
     781  screen->Unlock();
    782782}
    783783
     
    792792  if (!datap) return ;
    793793
    794   screen->lock();
     794  screen->Lock();
    795795  for (; ysteps>0; ysteps--,y++)
    796796  {
     
    842842    }
    843843  }
    844   screen->unlock();
     844  screen->Unlock();
    845845}
    846846
     
    863863  blend_amount=16-blend_amount;
    864864
    865   screen->lock();
     865  screen->Lock();
    866866  for (; ysteps>0; ysteps--,y++)
    867867  {
     
    946946  }
    947947
    948   screen->unlock();
     948  screen->Unlock();
    949949}
    950950
     
    979979  }*/
    980980
    981   screen->lock();
     981  screen->Lock();
    982982  screen_line=screen->scan_line(y)+x;
    983983  int sw=screen->Size().x;
     
    10321032    screen_line+=sw;
    10331033  }
    1034   screen->unlock();
     1034  screen->Unlock();
    10351035}
    10361036
  • abuse/trunk/src/items.cpp

    r513 r515  
    255255
    256256  for (l=0; l<AUTOTILE_WIDTH*AUTOTILE_HEIGHT; l++)
    257     micro_image->putpixel(  l%AUTOTILE_WIDTH , l/AUTOTILE_WIDTH,
     257    micro_image->PutPixel(vec2i(l % AUTOTILE_WIDTH, l / AUTOTILE_WIDTH),
    258258       color_table->lookup_color((r[l]/(t[l]*4/5))>>3,
    259259                 (g[l]/(t[l]*4/5))>>3,
  • abuse/trunk/src/level.cpp

    r513 r515  
    16591659  fp->write_uint16(i->Size().y);
    16601660
    1661   i->lock();
     1661  i->Lock();
    16621662  for(int y = 0; y < i->Size().y; y++)
    16631663    fp->write(i->scan_line(y),i->Size().x);
    1664   i->unlock();
     1664  i->Unlock();
    16651665
    16661666  delete i;
  • abuse/trunk/src/light.cpp

    r512 r515  
    793793  light_patch *f=first;
    794794
    795   screen->lock();
     795  screen->Lock();
    796796
    797797  int scr_w=screen->Size().x;
     
    886886    screen_line-=prefix;
    887887  }
    888   screen->unlock();
     888  screen->Unlock();
    889889
    890890  while (first)
  • abuse/trunk/src/menu.cpp

    r513 r515  
    5555  percent=256-percent;
    5656
    57   screen->lock();
     57  screen->Lock();
    5858  for (y=y1; y<=y2; y++)
    5959  {
     
    6969  }
    7070  screen->add_dirty(x1,y1,x2,y2);
    71   screen->unlock();
     71  screen->Unlock();
    7272}
    7373
     
    8383  if (x2<x1 || y2<y1) return ;
    8484
    85   screen->lock();
     85  screen->Lock();
    8686  for (y=y1; y<=y2; y++)
    8787  {
     
    9797  }
    9898  screen->add_dirty(x1,y1,x2,y2);
    99   screen->unlock();
     99  screen->Unlock();
    100100}
    101101
  • abuse/trunk/src/particle.cpp

    r512 r515  
    181181  while (i && pon->y<cy1) { pon++; i--; }
    182182  if (!i) return ;
    183   screen->lock();
     183  screen->Lock();
    184184  if (dir>0)
    185185  {
     
    203203    }
    204204  }
    205   screen->unlock();
     205  screen->Unlock();
    206206}
    207207
     
    218218    s = ( 15 - s );
    219219
    220     screen->lock();
     220    screen->Lock();
    221221    while( t-- )
    222222    {
     
    230230        yo += dy;
    231231    }
    232     screen->unlock();
     232    screen->Unlock();
    233233}
    234234
     
    247247    s = ( 15 - s );
    248248
    249     screen->lock();
     249    screen->Lock();
    250250
    251251    int w = screen->Size().x;
     
    269269    }
    270270
    271     screen->unlock();
    272 }
    273 
     271    screen->Unlock();
     272}
     273
  • abuse/trunk/src/sdlport/video.cpp

    r513 r515  
    356356    int count;
    357357    dirty_rect *dr, *q;
    358     CHECK(im->special); // make sure the image has the ability to contain dirty areas
    359     if(im->special->keep_dirt == 0)
     358    CHECK(im->m_special); // make sure the image has the ability to contain dirty areas
     359    if(im->m_special->keep_dirt == 0)
    360360    {
    361361        put_image(im, xoff, yoff);
     
    363363    else
    364364    {
    365         count = im->special->dirties.number_nodes();
     365        count = im->m_special->dirties.number_nodes();
    366366        if(!count)
    367367            return;  // if nothing to update, return
    368         dr = (dirty_rect *)(im->special->dirties.first());
     368        dr = (dirty_rect *)(im->m_special->dirties.first());
    369369        while(count > 0)
    370370        {
     
    372372            q = dr;
    373373            dr = (dirty_rect *)(dr->next());
    374             im->special->dirties.unlink((linked_node *)q);
     374            im->m_special->dirties.unlink((linked_node *)q);
    375375            delete q;
    376376            count--;
     
    387387    update_dirty_window(im, xoff, yoff);
    388388    update_window_done();
    389 }
    390 
    391 //
    392 // make_page()
    393 //
    394 void image::make_page(vec2i size, uint8_t *page_buffer)
    395 {
    396     if (page_buffer)
    397         m_data = page_buffer;
    398     else
    399         m_data = (uint8_t *)malloc(size.x * size.y);
    400 }
    401 
    402 //
    403 // delete_page()
    404 //
    405 void image::delete_page()
    406 {
    407     if(!special || !special->static_mem)
    408         free(m_data);
    409389}
    410390
Note: See TracChangeset for help on using the changeset viewer.