From c990701d87beddfa1a690054c25d0c97989b3129 Mon Sep 17 00:00:00 2001 From: Kp Date: Tue, 2 Dec 2014 03:35:01 +0000 Subject: [PATCH] Pass show_fullscr arg by & --- common/2d/bitblt.cpp | 23 +++++++++++------------ common/include/gr.h | 2 +- similar/main/automap.cpp | 2 +- similar/main/credits.cpp | 4 ++-- similar/main/gameseq.cpp | 2 +- similar/main/kmatrix.cpp | 2 +- similar/main/newmenu.cpp | 6 +++--- similar/main/titles.cpp | 12 ++++-------- 8 files changed, 24 insertions(+), 29 deletions(-) diff --git a/common/2d/bitblt.cpp b/common/2d/bitblt.cpp index a070ccac5..e0e0e216f 100644 --- a/common/2d/bitblt.cpp +++ b/common/2d/bitblt.cpp @@ -483,26 +483,25 @@ inside: } } -void show_fullscr(grs_bitmap *bm) +void show_fullscr(grs_bitmap &bm) { - grs_bitmap * const scr = &grd_curcanv->cv_bitmap; - + auto &scr = grd_curcanv->cv_bitmap; #ifdef OGL - if(bm->bm_type == BM_LINEAR && scr->bm_type == BM_OGL && - bm->bm_w <= grd_curscreen->sc_w && bm->bm_h <= grd_curscreen->sc_h) // only scale with OGL if bitmap is not bigger than screen size + if(bm.bm_type == BM_LINEAR && scr.bm_type == BM_OGL && + bm.bm_w <= grd_curscreen->sc_w && bm.bm_h <= grd_curscreen->sc_h) // only scale with OGL if bitmap is not bigger than screen size { - ogl_ubitmapm_cs(0,0,-1,-1,*bm,-1,F1_0);//use opengl to scale, faster and saves ram. -MPM + ogl_ubitmapm_cs(0,0,-1,-1,bm,-1,F1_0);//use opengl to scale, faster and saves ram. -MPM return; } #endif - if(scr->bm_type != BM_LINEAR) { - grs_bitmap_ptr p = gr_create_bitmap(scr->bm_w, scr->bm_h); - grs_bitmap *tmp = p.get(); - gr_bitmap_scale_to(*bm, *tmp); - gr_bitmap(0, 0, *tmp); + if(scr.bm_type != BM_LINEAR) { + grs_bitmap_ptr p = gr_create_bitmap(scr.bm_w, scr.bm_h); + auto &tmp = *p.get(); + gr_bitmap_scale_to(bm, tmp); + gr_bitmap(0, 0, tmp); return; } - gr_bitmap_scale_to(*bm, *scr); + gr_bitmap_scale_to(bm, scr); } // Find transparent area in bitmap diff --git a/common/include/gr.h b/common/include/gr.h index 304f57f7f..7bf5c987a 100644 --- a/common/include/gr.h +++ b/common/include/gr.h @@ -313,7 +313,7 @@ int gr_uline(fix x0,fix y0,fix x1,fix y1); // Draw the bitmap into the current canvas at the specified location. void gr_bitmap(unsigned x,unsigned y,grs_bitmap &bm); void gr_ubitmap(grs_bitmap &bm); -void show_fullscr(grs_bitmap *bm); +void show_fullscr(grs_bitmap &bm); // Find transparent area in bitmap void gr_bitblt_find_transparent_area(grs_bitmap *bm, unsigned &minx, unsigned &miny, unsigned &maxx, unsigned &maxy); diff --git a/similar/main/automap.cpp b/similar/main/automap.cpp index 2b731a3d2..5ebe2c4a9 100644 --- a/similar/main/automap.cpp +++ b/similar/main/automap.cpp @@ -490,7 +490,7 @@ static void draw_automap(automap *am) am->leave_mode = 1; gr_set_current_canvas(NULL); - show_fullscr(&am->automap_background); + show_fullscr(am->automap_background); gr_set_curfont(HUGE_FONT); gr_set_fontcolor(BM_XRGB(20, 20, 20), -1); #if defined(DXX_BUILD_DESCENT_I) diff --git a/similar/main/credits.cpp b/similar/main/credits.cpp index 4263d0658..55d052fd2 100644 --- a/similar/main/credits.cpp +++ b/similar/main/credits.cpp @@ -170,7 +170,7 @@ static window_event_result credits_handler(window *wind,const d_event &event, cr } y = cr->first_line_offset - cr->row; - show_fullscr(&cr->backdrop); + show_fullscr(cr->backdrop); for (int j=0; jbackdrop,backdrop_palette, -1, -1 ); gr_set_current_canvas(NULL); - show_fullscr(&cr->backdrop); + show_fullscr(cr->backdrop); gr_palette_load( gr_palette ); key_flush(); diff --git a/similar/main/gameseq.cpp b/similar/main/gameseq.cpp index bd3bae4b8..ca96a970e 100644 --- a/similar/main/gameseq.cpp +++ b/similar/main/gameseq.cpp @@ -932,7 +932,7 @@ static int draw_endlevel_background(newmenu *,const d_event &event, grs_bitmap * { case EVENT_WINDOW_DRAW: gr_set_current_canvas(NULL); - show_fullscr(background); + show_fullscr(*background); break; default: diff --git a/similar/main/kmatrix.cpp b/similar/main/kmatrix.cpp index 6b6c8415b..a366f824e 100644 --- a/similar/main/kmatrix.cpp +++ b/similar/main/kmatrix.cpp @@ -189,7 +189,7 @@ static void kmatrix_redraw(kmatrix_screen *km) playernum_array_t sorted; gr_set_current_canvas(NULL); - show_fullscr(&km->background); + show_fullscr(km->background); if (Game_mode & GM_MULTI_COOP) { diff --git a/similar/main/newmenu.cpp b/similar/main/newmenu.cpp index 4e9368870..492c8beb8 100644 --- a/similar/main/newmenu.cpp +++ b/similar/main/newmenu.cpp @@ -129,7 +129,7 @@ static void nm_draw_background1(const char * filename) (void)pcx_error; } gr_palette_load( gr_palette ); - show_fullscr(&nm_background1); + show_fullscr(nm_background1); } #if defined(DXX_BUILD_DESCENT_II) strcpy(last_palette_loaded,""); //force palette load next time @@ -177,14 +177,14 @@ void nm_draw_background(int x1, int y1, int x2, int y2 ) gr_set_current_canvas(tmp); gr_palette_load( gr_palette ); - show_fullscr( &nm_background ); // show so we load all necessary data for the sub-bitmap + show_fullscr(nm_background); // show so we load all necessary data for the sub-bitmap if (!init_sub && ((nm_background_sub->bm_w != w*(((float) nm_background.bm_w)/SWIDTH)) || (nm_background_sub->bm_h != h*(((float) nm_background.bm_h)/SHEIGHT)))) { init_sub=1; } if (init_sub) nm_background_sub = gr_create_sub_bitmap(nm_background,0,0,w*(((float) nm_background.bm_w)/SWIDTH),h*(((float) nm_background.bm_h)/SHEIGHT)); - show_fullscr( nm_background_sub.get() ); + show_fullscr(*nm_background_sub.get()); gr_set_current_canvas(old); diff --git a/similar/main/titles.cpp b/similar/main/titles.cpp index eaed4f294..4d4460ae9 100644 --- a/similar/main/titles.cpp +++ b/similar/main/titles.cpp @@ -141,7 +141,7 @@ static window_event_result title_handler(window *wind,const d_event &event, titl case EVENT_WINDOW_DRAW: gr_set_current_canvas( NULL ); - show_fullscr(&ts->title_bm); + show_fullscr(ts->title_bm); break; case EVENT_WINDOW_CLOSE: @@ -1253,9 +1253,7 @@ static int load_briefing_screen(briefing *br, const char *fname) gr_palette[0].r = gr_palette[0].g = gr_palette[0].b = 0; gr_palette[255].r = gr_palette[255].g = gr_palette[255].b = 63; } - - show_fullscr(&br->background); - + show_fullscr(br->background); gr_palette_load(gr_palette); set_briefing_fontcolor(NULL); @@ -1280,9 +1278,7 @@ static int load_briefing_screen(briefing *br, const char *fname) if ((pcx_error = pcx_read_bitmap(fname, br->background, BM_LINEAR, gr_palette))!=PCX_ERROR_NONE) Error( "Error loading briefing screen <%s>, PCX load error: %s (%i)\n",fname, pcx_errormsg(pcx_error), pcx_error); - - show_fullscr(&br->background); - + show_fullscr(br->background); if (EMULATING_D1 && !d_stricmp(fname, "brief03.pcx")) // HACK, FIXME: D1 missions should use their own palette (PALETTE.256), but texture replacements not complete gr_use_palette_table("groupa.256"); @@ -1507,7 +1503,7 @@ static window_event_result briefing_handler(window *wind,const d_event &event, b check_text_pos(br); if (br->background.bm_data) - show_fullscr(&br->background); + show_fullscr(br->background); if (br->guy_bitmap_show) show_briefing_bitmap(&br->guy_bitmap);