From 53ce29e789a7476460bf0c23785ea038e63b90e1 Mon Sep 17 00:00:00 2001 From: Kp Date: Sun, 30 Nov 2014 22:09:20 +0000 Subject: [PATCH] Pass gr_init_bitmap arg by & --- common/2d/bitmap.cpp | 27 ++++++++++++++------------- common/2d/canvas.cpp | 2 +- common/include/gr.h | 2 +- d1x-rebirth/main/custom.cpp | 2 +- similar/2d/font.cpp | 4 ++-- similar/main/gauges.cpp | 2 +- similar/main/iff.cpp | 4 ++-- similar/main/multi.cpp | 6 +++--- similar/main/piggy.cpp | 14 +++++++------- 9 files changed, 32 insertions(+), 31 deletions(-) diff --git a/common/2d/bitmap.cpp b/common/2d/bitmap.cpp index 23994c157..64df3f8a0 100644 --- a/common/2d/bitmap.cpp +++ b/common/2d/bitmap.cpp @@ -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 diff --git a/common/2d/canvas.cpp b/common/2d/canvas.cpp index b07ef4903..3e7c449d9 100644 --- a/common/2d/canvas.cpp +++ b/common/2d/canvas.cpp @@ -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) diff --git a/common/include/gr.h b/common/include/gr.h index 9fdf24ef5..1c4b35a1e 100644 --- a/common/include/gr.h +++ b/common/include/gr.h @@ -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); diff --git a/d1x-rebirth/main/custom.cpp b/d1x-rebirth/main/custom.cpp index 11c0da3de..55e69eda8 100644 --- a/d1x-rebirth/main/custom.cpp +++ b/d1x-rebirth/main/custom.cpp @@ -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; diff --git a/similar/2d/font.cpp b/similar/2d/font.cpp index 68857e5ae..423a0ce67 100644 --- a/similar/2d/font.cpp +++ b/similar/2d/font.cpp @@ -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)) diff --git a/similar/main/gauges.cpp b/similar/main/gauges.cpp index 444ee3ccb..178aec707 100644 --- a/similar/main/gauges.cpp +++ b/similar/main/gauges.cpp @@ -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 diff --git a/similar/main/iff.cpp b/similar/main/iff.cpp index 009e3c603..4f20fc40b 100644 --- a/similar/main/iff.cpp +++ b/similar/main/iff.cpp @@ -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; ybm_h; y++) { for (int x=0; xw; 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 diff --git a/similar/main/multi.cpp b/similar/main/multi.cpp index bff833943..19ebaa8bb 100644 --- a/similar/main/multi.cpp +++ b/similar/main/multi.cpp @@ -4909,7 +4909,7 @@ void init_hoard_data() Vclip[orb_vclip].light_value = F1_0; for (i=0;ibm_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);