Pass gr_init_bitmap arg by &

This commit is contained in:
Kp 2014-11-30 22:09:20 +00:00
parent 594c597621
commit 53ce29e789
9 changed files with 32 additions and 31 deletions

View file

@ -56,32 +56,33 @@ grs_bitmap_ptr gr_create_bitmap(uint16_t w, uint16_t h )
grs_bitmap_ptr gr_create_bitmap_raw(uint16_t w, uint16_t h, unsigned char * raw_data )
{
grs_bitmap_ptr n(new grs_bitmap);
gr_init_bitmap(n.get(), 0, 0, 0, w, h, w, raw_data);
gr_init_bitmap(*n.get(), 0, 0, 0, w, h, w, raw_data);
return n;
}
void gr_init_bitmap( grs_bitmap *bm, uint8_t mode, uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint16_t bytesperline, unsigned char * data ) // TODO: virtualize
void gr_init_bitmap(grs_bitmap &bm, uint8_t mode, uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint16_t bytesperline, unsigned char * data ) // TODO: virtualize
{
bm->bm_x = x;
bm->bm_y = y;
bm->bm_w = w;
bm->bm_h = h;
bm->bm_flags = 0;
bm->bm_type = mode;
bm->bm_rowsize = bytesperline;
bm.bm_x = x;
bm.bm_y = y;
bm.bm_w = w;
bm.bm_h = h;
bm.bm_flags = 0;
bm.bm_type = mode;
bm.bm_rowsize = bytesperline;
bm->bm_data = NULL;
bm.bm_data = nullptr;
#ifdef OGL
bm->bm_parent=NULL;bm->gltexture=NULL;
bm.bm_parent = nullptr;
bm.gltexture = nullptr;
#endif
gr_set_bitmap_data (*bm, data);
gr_set_bitmap_data(bm, data);
}
void gr_init_bitmap_alloc( grs_bitmap *bm, uint8_t mode, uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint16_t bytesperline)
{
unsigned char *d;
MALLOC(d, unsigned char, MAX_BMP_SIZE(w, h));
gr_init_bitmap(bm, mode, x, y, w, h, bytesperline, d);
gr_init_bitmap(*bm, mode, x, y, w, h, bytesperline, d);
}
void gr_init_bitmap_data (grs_bitmap &bm) // TODO: virtulize

View file

@ -71,7 +71,7 @@ void gr_init_canvas(grs_canvas *canv, unsigned char * pixdata, uint8_t pixtype,
canv->cv_font_fg_color = 0;
canv->cv_font_bg_color = 0;
auto wreal = w;
gr_init_bitmap (&canv->cv_bitmap, pixtype, 0, 0, w, h, wreal, pixdata);
gr_init_bitmap(canv->cv_bitmap, pixtype, 0, 0, w, h, wreal, pixdata);
}
void gr_init_sub_canvas(grs_canvas *n, grs_canvas *src, uint16_t x, uint16_t y, uint16_t w, uint16_t h)

View file

@ -224,7 +224,7 @@ void gr_clear_canvas(color_t color);
// Bitmap functions:
// these are the two workhorses, the others just use these
void gr_init_bitmap( grs_bitmap *bm, uint8_t mode, uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint16_t bytesperline, unsigned char * data );
void gr_init_bitmap(grs_bitmap &bm, uint8_t mode, uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint16_t bytesperline, unsigned char * data);
void gr_init_sub_bitmap (grs_bitmap *bm, grs_bitmap *bmParent, uint16_t x, uint16_t y, uint16_t w, uint16_t h);
void gr_init_bitmap_alloc( grs_bitmap *bm, uint8_t mode, uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint16_t bytesperline);

View file

@ -294,7 +294,7 @@ static int load_pigpog(const d_fname &pogname)
GameBitmapOffset[x] = 0; // not in pig
*bmp = {};
gr_init_bitmap (bmp, 0, 0, 0, cip->width, cip->height, cip->width, p);
gr_init_bitmap(*bmp, 0, 0, 0, cip->width, cip->height, cip->width, p);
gr_set_bitmap_flags(bmp, cip->flags & 255);
bmp->avg_color = cip->flags >> 8;

View file

@ -501,7 +501,7 @@ static int gr_internal_color_string(int x, int y, const char *s )
else
fp = grd_curcanv->cv_font->ft_data + letter * BITS_TO_BYTES(width)*grd_curcanv->cv_font->ft_h;
gr_init_bitmap (&char_bm, BM_LINEAR, 0, 0, width, grd_curcanv->cv_font->ft_h, width, fp);
gr_init_bitmap(char_bm, BM_LINEAR, 0, 0, width, grd_curcanv->cv_font->ft_h, width, fp);
gr_bitmapm(xx,yy,&char_bm);
xx += spacing;
@ -614,7 +614,7 @@ static void ogl_init_font(grs_font * font)
ogl_font_choose_size(font,gap,&tw,&th);
MALLOC(data, ubyte, tw*th);
memset(data, TRANSPARENCY_COLOR, tw * th); // map the whole data with transparency so we won't have borders if using gap
gr_init_bitmap(&font->ft_parent_bitmap,BM_LINEAR,0,0,tw,th,tw,data);
gr_init_bitmap(font->ft_parent_bitmap,BM_LINEAR,0,0,tw,th,tw,data);
gr_set_transparent(&font->ft_parent_bitmap, 1);
if (!(font->ft_flags & FT_COLOR))

View file

@ -1801,7 +1801,7 @@ static void cockpit_decode_alpha(grs_bitmap *bm)
#ifdef OGL
ogl_freebmtexture(*bm);
#endif
gr_init_bitmap (&deccpt, 0, 0, 0, bm->bm_w, bm->bm_h, bm->bm_w, cockpitbuf);
gr_init_bitmap(deccpt, 0, 0, 0, bm->bm_w, bm->bm_h, bm->bm_w, cockpitbuf);
gr_set_transparent(&deccpt,1);
#ifdef OGL
ogl_ubitmapm_cs (0, 0, -1, -1, deccpt, 255, F1_0); // render one time to init the texture

View file

@ -491,7 +491,7 @@ static int convert_rgb15(grs_bitmap *bm,iff_bitmap_header *bmheader)
palette_array_t::iterator palptr = begin(bmheader->palette);
#if defined(DXX_BUILD_DESCENT_I)
gr_init_bitmap (bm, bm->bm_type, 0, 0, bm->bm_w, bm->bm_h, bm->bm_rowsize, 0);
gr_init_bitmap(*bm, bm->bm_type, 0, 0, bm->bm_w, bm->bm_h, bm->bm_rowsize, 0);
for (int y=0; y<bm->bm_h; y++) {
for (int x=0; x<bmheader->w; x++)
@ -523,7 +523,7 @@ static int convert_rgb15(grs_bitmap *bm,iff_bitmap_header *bmheader)
//copy an iff header structure to a grs_bitmap structure
static void copy_iff_to_grs(grs_bitmap *bm,iff_bitmap_header *bmheader)
{
gr_init_bitmap (bm, bmheader->type, 0, 0, bmheader->w, bmheader->h, bmheader->w, bmheader->raw_data);
gr_init_bitmap(*bm, bmheader->type, 0, 0, bmheader->w, bmheader->h, bmheader->w, bmheader->raw_data);
}
//if bm->bm_data is set, use it (making sure w & h are correct), else

View file

@ -4909,7 +4909,7 @@ void init_hoard_data()
Vclip[orb_vclip].light_value = F1_0;
for (i=0;i<n_orb_frames;i++) {
Vclip[orb_vclip].frames[i].index = bitmap_num;
gr_init_bitmap(&GameBitmaps[bitmap_num],BM_LINEAR,0,0,orb_w,orb_h,orb_w,bitmap_data1);
gr_init_bitmap(GameBitmaps[bitmap_num],BM_LINEAR,0,0,orb_w,orb_h,orb_w,bitmap_data1);
gr_set_transparent (&GameBitmaps[bitmap_num], 1);
bitmap_data1 += orb_w*orb_h;
bitmap_num++;
@ -4936,7 +4936,7 @@ void init_hoard_data()
Assert(NumTextures < MAX_TEXTURES);
for (i=0;i<n_goal_frames;i++) {
Effects[Hoard_goal_eclip].vc.frames[i].index = bitmap_num;
gr_init_bitmap(&GameBitmaps[bitmap_num],BM_LINEAR,0,0,64,64,64,bitmap_data1);
gr_init_bitmap(GameBitmaps[bitmap_num],BM_LINEAR,0,0,64,64,64,bitmap_data1);
bitmap_data1 += 64*64;
bitmap_num++;
Assert(bitmap_num < MAX_BITMAP_FILES);
@ -4965,7 +4965,7 @@ void init_hoard_data()
icon_w = PHYSFSX_readShort(ifile);
icon_h = PHYSFSX_readShort(ifile);
MALLOC( bitmap_data2, ubyte, icon_w*icon_h );
gr_init_bitmap(&Orb_icons[i],BM_LINEAR,0,0,icon_w,icon_h,icon_w,bitmap_data2);
gr_init_bitmap(Orb_icons[i],BM_LINEAR,0,0,icon_w,icon_h,icon_w,bitmap_data2);
gr_set_transparent (&Orb_icons[i], 1);
PHYSFS_read(ifile,&palette[0],sizeof(palette[0]),palette.size());
PHYSFS_read(ifile,Orb_icons[i].bm_data,1,icon_w*icon_h);

View file

@ -459,7 +459,7 @@ int properties_init()
bogus_data[i*64+i] = c;
bogus_data[i*64+(63-i)] = c;
}
gr_init_bitmap (&bogus_bitmap, 0, 0, 0, 64, 64, 64, bogus_data);
gr_init_bitmap(bogus_bitmap, 0, 0, 0, 64, 64, 64, bogus_data);
piggy_register_bitmap( &bogus_bitmap, "bogus", 1 );
#ifdef ALLEGRO
bogus_sound.len = 64*64;
@ -556,7 +556,7 @@ int properties_init()
strcpy( temp_name, temp_name_read );
grs_bitmap temp_bitmap{};
gr_init_bitmap( &temp_bitmap, 0, 0, 0,
gr_init_bitmap(temp_bitmap, 0, 0, 0,
(bmh.dflags & DBM_FLAG_LARGE) ? bmh.width + 256 : bmh.width, bmh.height,
(bmh.dflags & DBM_FLAG_LARGE) ? bmh.width + 256 : bmh.width, Piggy_bitmap_cache_data);
temp_bitmap.bm_flags |= BM_FLAG_PAGED_OUT;
@ -687,7 +687,7 @@ void piggy_init_pigfile(const char *filename)
else
strcpy( temp_name, temp_name_read );
width = bmh.width + ((short) (bmh.wh_extra & 0x0f) << 8);
gr_init_bitmap(bm, 0, 0, 0, width, bmh.height + ((short) (bmh.wh_extra & 0xf0) << 4), width, NULL);
gr_init_bitmap(*bm, 0, 0, 0, width, bmh.height + ((short) (bmh.wh_extra & 0xf0) << 4), width, NULL);
bm->bm_flags = BM_FLAG_PAGED_OUT;
bm->avg_color = bmh.avg_color;
@ -799,7 +799,7 @@ void piggy_new_pigfile(char *pigname)
width = bmh.width + ((short) (bmh.wh_extra & 0x0f) << 8);
gr_set_bitmap_data(*bm, NULL); // free ogl texture
gr_init_bitmap(bm, 0, 0, 0, width, bmh.height + ((short) (bmh.wh_extra & 0xf0) << 4), width, NULL);
gr_init_bitmap(*bm, 0, 0, 0, width, bmh.height + ((short) (bmh.wh_extra & 0xf0) << 4), width, NULL);
bm->bm_flags = BM_FLAG_PAGED_OUT;
bm->avg_color = bmh.avg_color;
@ -1152,7 +1152,7 @@ int properties_init(void)
bogus_data[i*64+i] = c;
bogus_data[i*64+(63-i)] = c;
}
gr_init_bitmap(&GameBitmaps[Num_bitmap_files], 0, 0, 0, 64, 64, 64, bogus_data);
gr_init_bitmap(GameBitmaps[Num_bitmap_files], 0, 0, 0, 64, 64, 64, bogus_data);
piggy_register_bitmap(&GameBitmaps[Num_bitmap_files], "bogus", 1);
bogus_sound.length = 64*64;
bogus_sound.data = bogus_data;
@ -1785,7 +1785,7 @@ void load_bitmap_replacements(const char *level_name)
width = bmh.width + ((short) (bmh.wh_extra & 0x0f) << 8);
gr_set_bitmap_data(*bm, NULL); // free ogl texture
gr_init_bitmap(bm, 0, 0, 0, width, bmh.height + ((short) (bmh.wh_extra & 0xf0) << 4), width, NULL);
gr_init_bitmap(*bm, 0, 0, 0, width, bmh.height + ((short) (bmh.wh_extra & 0xf0) << 4), width, NULL);
bm->avg_color = bmh.avg_color;
bm->bm_data = (ubyte *) (size_t)bmh.offset;
@ -1842,7 +1842,7 @@ static void bitmap_read_d1( grs_bitmap *bitmap, /* read into this bitmap */
width = bmh->width + ((short) (bmh->wh_extra & 0x0f) << 8);
gr_set_bitmap_data(*bitmap, NULL); // free ogl texture
gr_init_bitmap(bitmap, 0, 0, 0, width, bmh->height + ((short) (bmh->wh_extra & 0xf0) << 4), width, NULL);
gr_init_bitmap(*bitmap, 0, 0, 0, width, bmh->height + ((short) (bmh->wh_extra & 0xf0) << 4), width, NULL);
bitmap->avg_color = bmh->avg_color;
gr_set_bitmap_flags(bitmap, bmh->flags & BM_FLAGS_TO_COPY);