Only set opaque on initial alloc, add flag for clearing buffer on realloc.

svn path=/trunk/netsurf/; revision=13378
This commit is contained in:
Ole Loots 2012-01-06 21:57:42 +00:00
parent 7314d12cba
commit d5d0289010
2 changed files with 5 additions and 1 deletions

View File

@ -105,6 +105,7 @@ void * bitmap_realloc( int w, int h, short bpp, int rowstride, unsigned int stat
assert( 1 == 0 );
/* add some buffer for bad code */
bitmap->pixdata = malloc( newsize + 128 );
bitmap->opaque = false;
} else {
int oldsize = bitmap->rowstride * bitmap->height;
bool doalloc = ( state == BITMAP_GROW) ? (newsize > oldsize) : (newsize != oldsize);
@ -116,10 +117,12 @@ void * bitmap_realloc( int w, int h, short bpp, int rowstride, unsigned int stat
return( NULL );
}
}
if( state & BITMAP_CLEAR ){
memset( bitmap->pixdata, 0x00, newsize + 128 );
}
bitmap->width = w;
bitmap->height = h;
bitmap->opaque = false;
bitmap->bpp = bpp;
bitmap->resized = NULL;
bitmap->rowstride = rowstride;

View File

@ -22,6 +22,7 @@
#define BITMAP_SHRINK 0
#define BITMAP_GROW 0x1024
#define BITMAP_MONOGLYPH 0x2048
#define BITMAP_CLEAR 0x4096
struct bitmap {
int width;