Pass rle_expand_texture arg as const &

This commit is contained in:
Kp 2014-11-30 22:09:17 +00:00
parent 6ac655ec53
commit dd4a0db47f
6 changed files with 15 additions and 16 deletions

View file

@ -339,7 +339,7 @@ int gr_bitmap_rle_compress( grs_bitmap * bmp )
struct rle_cache_element
{
grs_bitmap * rle_bitmap;
const grs_bitmap *rle_bitmap;
ubyte * rle_data;
grs_bitmap_ptr expanded_bitmap;
int last_used;
@ -397,14 +397,14 @@ static void rle_expand_texture_sub(const grs_bitmap &bmp, grs_bitmap &rle_temp_b
}
grs_bitmap * rle_expand_texture( grs_bitmap * bmp )
grs_bitmap * rle_expand_texture(const grs_bitmap &bmp)
{
int lowest_count, lc;
int least_recently_used;
if (!rle_cache_initialized) rle_cache_init();
Assert( !(bmp->bm_flags & BM_FLAG_PAGED_OUT) );
Assert( !(bmp.bm_flags & BM_FLAG_PAGED_OUT) );
lc = rle_counter;
rle_counter++;
@ -427,7 +427,7 @@ grs_bitmap * rle_expand_texture( grs_bitmap * bmp )
rle_next = 0;
for (int i=0; i<MAX_CACHE_BITMAPS; i++ ) {
if (rle_cache[i].rle_bitmap == bmp) {
if (rle_cache[i].rle_bitmap == &bmp) {
rle_hits++;
rle_cache[i].last_used = rle_counter;
return rle_cache[i].expanded_bitmap.get();
@ -439,9 +439,9 @@ grs_bitmap * rle_expand_texture( grs_bitmap * bmp )
}
rle_misses++;
rle_cache[least_recently_used].expanded_bitmap = gr_create_bitmap(bmp->bm_w, bmp->bm_h);
rle_expand_texture_sub(*bmp, *rle_cache[least_recently_used].expanded_bitmap.get());
rle_cache[least_recently_used].rle_bitmap = bmp;
rle_cache[least_recently_used].expanded_bitmap = gr_create_bitmap(bmp.bm_w, bmp.bm_h);
rle_expand_texture_sub(bmp, *rle_cache[least_recently_used].expanded_bitmap.get());
rle_cache[least_recently_used].rle_bitmap = &bmp;
rle_cache[least_recently_used].last_used = rle_counter;
return rle_cache[least_recently_used].expanded_bitmap.get();
}

View file

@ -67,7 +67,7 @@ ubyte * gr_rle_find_xth_pixel( ubyte *src, int x,int * count, ubyte color );
int gr_bitmap_rle_compress( grs_bitmap * bmp );
void gr_rle_expand_scanline_masked( ubyte *dest, ubyte *src, int x1, int x2 );
void gr_rle_expand_scanline( ubyte *dest, ubyte *src, int x1, int x2 );
grs_bitmap * rle_expand_texture( grs_bitmap * bmp );
grs_bitmap * rle_expand_texture(const grs_bitmap &bmp);
void rle_cache_close();
void rle_cache_flush();
void rle_swap_0_255(grs_bitmap *bmp);

View file

@ -809,7 +809,7 @@ void draw_tmap(grs_bitmap *bp,int nverts,const g3s_point *const *vertbuf)
}
if ( bp->bm_flags & BM_FLAG_RLE )
bp = rle_expand_texture( bp ); // Expand if rle'd
bp = rle_expand_texture(*bp); // Expand if rle'd
Transparency_on = bp->bm_flags & BM_FLAG_TRANSPARENT;
if (bp->bm_flags & BM_FLAG_NO_LIGHTING)

View file

@ -586,9 +586,8 @@ int check_effect_blowup(const vsegptridx_t seg,int side,const vms_vector &pnt, _
case 0x8000: y=bm->bm_h-y-1; x=bm->bm_w-x-1; break;
case 0xc000: t=x; x=y; y=bm->bm_h-t-1; break;
}
if (bm->bm_flags & BM_FLAG_RLE)
bm = rle_expand_texture(bm);
bm = rle_expand_texture(*bm);
}
#if defined(DXX_BUILD_DESCENT_I)

View file

@ -1185,7 +1185,7 @@ int check_trans_wall(const vms_vector &pnt,const vcsegptridx_t seg,int sidenum,i
}
if (bm->bm_flags & BM_FLAG_RLE)
bm = rle_expand_texture(bm);
bm = rle_expand_texture(*bm);
bmx = ((unsigned) f2i(u*bm->bm_w)) % bm->bm_w;
bmy = ((unsigned) f2i(v*bm->bm_h)) % bm->bm_h;

View file

@ -178,10 +178,10 @@ void merge_textures_new( int type, grs_bitmap * bottom_bmp, grs_bitmap * top_bmp
int wh;
if ( top_bmp->bm_flags & BM_FLAG_RLE )
top_bmp = rle_expand_texture(top_bmp);
top_bmp = rle_expand_texture(*top_bmp);
if ( bottom_bmp->bm_flags & BM_FLAG_RLE )
bottom_bmp = rle_expand_texture(bottom_bmp);
bottom_bmp = rle_expand_texture(*bottom_bmp);
top_data = top_bmp->bm_data;
bottom_data = bottom_bmp->bm_data;
@ -237,10 +237,10 @@ void merge_textures_super_xparent( int type, grs_bitmap * bottom_bmp, grs_bitmap
int wh;
if ( top_bmp->bm_flags & BM_FLAG_RLE )
top_bmp = rle_expand_texture(top_bmp);
top_bmp = rle_expand_texture(*top_bmp);
if ( bottom_bmp->bm_flags & BM_FLAG_RLE )
bottom_bmp = rle_expand_texture(bottom_bmp);
bottom_bmp = rle_expand_texture(*bottom_bmp);
top_data = top_bmp->bm_data;
bottom_data = bottom_bmp->bm_data;