Pass grs_main_bitmap to gr_init_bitmap_alloc
This commit is contained in:
parent
19fd79d8ae
commit
3081e69536
|
@ -83,7 +83,7 @@ void gr_init_bitmap(grs_bitmap &bm, const bm_mode mode, const uint16_t x, const
|
|||
gr_set_bitmap_data(bm, data);
|
||||
}
|
||||
|
||||
void gr_init_bitmap_alloc(grs_bitmap &bm, const bm_mode mode, const uint16_t x, const uint16_t y, const uint16_t w, const uint16_t h, const uint16_t bytesperline)
|
||||
void gr_init_bitmap_alloc(grs_main_bitmap &bm, const bm_mode mode, const uint16_t x, const uint16_t y, const uint16_t w, const uint16_t h, const uint16_t bytesperline)
|
||||
{
|
||||
unsigned char *d;
|
||||
MALLOC(d, unsigned char, MAX_BMP_SIZE(w, h));
|
||||
|
|
|
@ -146,7 +146,7 @@ void gr_clear_canvas(color_t color);
|
|||
void gr_init_bitmap(grs_bitmap &bm, bm_mode mode, uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint16_t bytesperline, const uint8_t* 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, bm_mode mode, uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint16_t bytesperline);
|
||||
void gr_init_bitmap_alloc(grs_main_bitmap &bm, bm_mode mode, uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint16_t bytesperline);
|
||||
void gr_free_bitmap_data(grs_bitmap &bm);
|
||||
|
||||
// Allocate a bitmap and its pixel data buffer.
|
||||
|
|
|
@ -34,6 +34,7 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
|
|||
#include "fmtcheck.h"
|
||||
#include "pack.h"
|
||||
#include "compiler-array.h"
|
||||
#include "compiler-exchange.h"
|
||||
|
||||
struct grs_point
|
||||
{
|
||||
|
@ -199,6 +200,17 @@ public:
|
|||
grs_main_bitmap() = default;
|
||||
grs_main_bitmap(const grs_main_bitmap &) = delete;
|
||||
grs_main_bitmap &operator=(const grs_main_bitmap &) = delete;
|
||||
grs_main_bitmap(grs_main_bitmap &&r) :
|
||||
grs_bitmap(std::move(static_cast<grs_bitmap &>(r)))
|
||||
{
|
||||
r.bm_data = nullptr;
|
||||
}
|
||||
grs_main_bitmap &operator=(grs_main_bitmap &&r)
|
||||
{
|
||||
grs_bitmap::operator=(std::move(static_cast<grs_bitmap &>(r)));
|
||||
bm_data = exchange(r.bm_data, nullptr);
|
||||
return *this;
|
||||
}
|
||||
~grs_main_bitmap()
|
||||
{
|
||||
reset();
|
||||
|
|
|
@ -55,7 +55,7 @@ namespace dcx {
|
|||
// then bmp->bm_data is allocated and the w,h are filled.
|
||||
// If palette==NULL the palette isn't read in. Returns error code.
|
||||
|
||||
int pcx_read_bitmap(const char * filename, grs_bitmap &bmp, palette_array_t &palette);
|
||||
int pcx_read_bitmap(const char * filename, grs_main_bitmap &bmp, palette_array_t &palette);
|
||||
|
||||
// Writes the bitmap bmp to filename, using palette. Returns error code.
|
||||
|
||||
|
|
|
@ -194,9 +194,9 @@ struct PCX_PHYSFS_file
|
|||
RAIIPHYSFS_File PCXfile;
|
||||
};
|
||||
|
||||
static int pcx_read_bitmap_file(struct PCX_PHYSFS_file *const pcxphysfs, grs_bitmap &bmp, bm_mode bitmap_type, palette_array_t &palette);
|
||||
static int pcx_read_bitmap_file(struct PCX_PHYSFS_file *const pcxphysfs, grs_main_bitmap &bmp, bm_mode bitmap_type, palette_array_t &palette);
|
||||
|
||||
int pcx_read_bitmap(const char *const filename, grs_bitmap &bmp, palette_array_t &palette)
|
||||
int pcx_read_bitmap(const char *const filename, grs_main_bitmap &bmp, palette_array_t &palette)
|
||||
{
|
||||
int result;
|
||||
PCX_PHYSFS_file pcxphysfs{PHYSFSX_openReadBuffered(filename)};
|
||||
|
@ -211,7 +211,7 @@ static int PCX_PHYSFS_read(struct PCX_PHYSFS_file *pcxphysfs, ubyte *data, unsig
|
|||
return PHYSFS_read(pcxphysfs->PCXfile, data, size, sizeof(*data));
|
||||
}
|
||||
|
||||
static int pcx_read_bitmap_file(struct PCX_PHYSFS_file *const pcxphysfs, grs_bitmap &bmp, const bm_mode bitmap_type, palette_array_t &palette)
|
||||
static int pcx_read_bitmap_file(struct PCX_PHYSFS_file *const pcxphysfs, grs_main_bitmap &bmp, const bm_mode bitmap_type, palette_array_t &palette)
|
||||
{
|
||||
PCXHeader header;
|
||||
int i, row, col, count, xsize, ysize;
|
||||
|
|
|
@ -141,7 +141,7 @@ struct automap : ignore_window_pointer_t
|
|||
// Screen canvas variables
|
||||
grs_canvas automap_view;
|
||||
|
||||
grs_bitmap automap_background;
|
||||
grs_main_bitmap automap_background;
|
||||
|
||||
// Rendering variables
|
||||
fix zoom;
|
||||
|
@ -965,9 +965,6 @@ static window_event_result automap_handler(window *wind,const d_event &event, au
|
|||
ConsoleObject->mtype.phys_info.flags |= am->old_wiggle; // Restore wiggle
|
||||
event_toggle_focus(0);
|
||||
key_toggle_repeat(1);
|
||||
#if DXX_USE_OGL
|
||||
gr_free_bitmap_data(am->automap_background);
|
||||
#endif
|
||||
std::default_delete<automap>()(am);
|
||||
window_set_visible(Game_wind, 1);
|
||||
Automap_active = 0;
|
||||
|
|
|
@ -88,7 +88,7 @@ struct credits : ignore_window_pointer_t
|
|||
int extra_inc;
|
||||
int done;
|
||||
int row;
|
||||
grs_bitmap backdrop;
|
||||
grs_main_bitmap backdrop;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -213,7 +213,6 @@ static window_event_result credits_handler(window *, const d_event &event, credi
|
|||
break;
|
||||
|
||||
case EVENT_WINDOW_CLOSE:
|
||||
gr_free_bitmap_data(cr->backdrop);
|
||||
songs_set_volume(GameCfg.MusicVolume);
|
||||
songs_play_song( SONG_TITLE, 1 );
|
||||
std::default_delete<credits>()(cr);
|
||||
|
|
|
@ -1045,7 +1045,7 @@ static int draw_endlevel_background(newmenu *,const d_event &event, grs_bitmap *
|
|||
static void do_screen_message(const char *msg) __attribute_nonnull();
|
||||
static void do_screen_message(const char *msg)
|
||||
{
|
||||
grs_bitmap background;
|
||||
grs_main_bitmap background;
|
||||
|
||||
if (Game_mode & GM_MULTI)
|
||||
return;
|
||||
|
@ -1058,7 +1058,6 @@ static void do_screen_message(const char *msg)
|
|||
nm_item_menu(TXT_OK),
|
||||
}};
|
||||
newmenu_do( NULL, msg, nm_message_items, draw_endlevel_background, static_cast<grs_bitmap *>(&background));
|
||||
gr_free_bitmap_data(background);
|
||||
}
|
||||
|
||||
#if defined(DXX_BUILD_DESCENT_II)
|
||||
|
|
|
@ -175,7 +175,7 @@ namespace {
|
|||
|
||||
struct kmatrix_screen : ignore_window_pointer_t
|
||||
{
|
||||
grs_bitmap background;
|
||||
grs_main_bitmap background;
|
||||
int network;
|
||||
fix64 end_time;
|
||||
int playing;
|
||||
|
@ -415,6 +415,5 @@ kmatrix_result kmatrix_view(int network)
|
|||
|
||||
while (window_exists(wind))
|
||||
event_process();
|
||||
gr_free_bitmap_data(km.background);
|
||||
return (km.aborted ? kmatrix_result::abort : kmatrix_result::proceed);
|
||||
}
|
||||
|
|
|
@ -102,7 +102,7 @@ namespace {
|
|||
|
||||
struct title_screen : ignore_window_pointer_t
|
||||
{
|
||||
grs_bitmap title_bm;
|
||||
grs_main_bitmap title_bm;
|
||||
fix64 timer;
|
||||
int allow_keys;
|
||||
};
|
||||
|
@ -145,7 +145,6 @@ static window_event_result title_handler(window *, const d_event &event, title_s
|
|||
break;
|
||||
|
||||
case EVENT_WINDOW_CLOSE:
|
||||
gr_free_bitmap_data(ts->title_bm);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -183,7 +182,6 @@ static void show_title_screen(const char * filename, int allow_keys, int from_ho
|
|||
const auto wind = window_create(grd_curscreen->sc_canvas, 0, 0, SWIDTH, SHEIGHT, title_handler, ts.get());
|
||||
if (!wind)
|
||||
{
|
||||
gr_free_bitmap_data(ts->title_bm);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -469,7 +467,7 @@ struct briefing : ignore_window_pointer_t
|
|||
short level_num;
|
||||
short cur_screen;
|
||||
std::unique_ptr<briefing_screen, briefing_screen_deleter> screen;
|
||||
grs_bitmap background;
|
||||
grs_main_bitmap background;
|
||||
char background_name[PATH_MAX];
|
||||
#if defined(DXX_BUILD_DESCENT_II)
|
||||
int got_z;
|
||||
|
@ -1339,8 +1337,6 @@ static void free_briefing_screen(briefing *br)
|
|||
#endif
|
||||
if (EMULATING_D1)
|
||||
br->screen.reset();
|
||||
if (br->background.bm_data != NULL)
|
||||
gr_free_bitmap_data(br->background);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue