Remove suspension of bmp/gif images. It's completely redundant with the convert on demand core image cache.

This commit is contained in:
Michael Drake 2012-10-14 20:03:18 +01:00
parent dbed8312c8
commit d88a839937
12 changed files with 79 additions and 200 deletions

View File

@ -183,19 +183,6 @@ void bitmap_modified(void *bitmap) {
bm->native_mask = NULL;
}
/**
* The bitmap image can be suspended.
*
* \param bitmap a bitmap, as returned by bitmap_create()
* \param private_word a private word to be returned later
* \param suspend the function to be called upon suspension
* \param resume the function to be called when resuming
*/
void bitmap_set_suspendable(void *bitmap, void *private_word,
void (*invalidate)(void *bitmap, void *private_word)) {
}
/**
* Sets whether a bitmap should be plotted opaque
*

View File

@ -29,36 +29,36 @@
#include "atari/plot/plot.h"
#include "utils/log.h"
/*
bpp: bits per pixel,
*/
int init_mfdb(int bpp, int w, int h, uint32_t flags, MFDB * out )
{
int dststride;
dststride = MFDB_STRIDE( w );
int size = MFDB_SIZE( bpp, dststride, h );
if( bpp > 0 ) {
if( (flags & MFDB_FLAG_NOALLOC) == 0 ) {
out->fd_addr = malloc( size );
if( out->fd_addr == NULL ){
return( 0 );
}
if( (flags & MFDB_FLAG_ZEROMEM) ){
memset( out->fd_addr, 0, size );
}
}
out->fd_stand = (flags & MFDB_FLAG_STAND) ? 1 : 0;
out->fd_nplanes = (short)bpp;
out->fd_r1 = out->fd_r2 = out->fd_r3 = 0;
} else {
memset( out, 0, sizeof(MFDB) );
}
out->fd_w = dststride;
out->fd_h = h;
out->fd_wdwidth = dststride >> 4;
return( size );
*/
int init_mfdb(int bpp, int w, int h, uint32_t flags, MFDB * out )
{
int dststride;
dststride = MFDB_STRIDE( w );
int size = MFDB_SIZE( bpp, dststride, h );
if( bpp > 0 ) {
if( (flags & MFDB_FLAG_NOALLOC) == 0 ) {
out->fd_addr = malloc( size );
if( out->fd_addr == NULL ){
return( 0 );
}
if( (flags & MFDB_FLAG_ZEROMEM) ){
memset( out->fd_addr, 0, size );
}
}
out->fd_stand = (flags & MFDB_FLAG_STAND) ? 1 : 0;
out->fd_nplanes = (short)bpp;
out->fd_r1 = out->fd_r2 = out->fd_r3 = 0;
} else {
memset( out, 0, sizeof(MFDB) );
}
out->fd_w = dststride;
out->fd_h = h;
out->fd_wdwidth = dststride >> 4;
return( size );
}
@ -311,19 +311,6 @@ void bitmap_modified(void *bitmap)
}
/**
* The bitmap image can be suspended.
*
* \param bitmap a bitmap, as returned by bitmap_create()
* \param private_word a private word to be returned later
* \param suspend the function to be called upon suspension
* \param resume the function to be called when resuming
*/
void bitmap_set_suspendable(void *bitmap, void *private_word,
void (*invalidate)(void *bitmap, void *private_word)) {
}
/**
* Sets whether a bitmap should be plotted opaque
*
@ -430,58 +417,58 @@ size_t bitmap_get_bpp(void *bitmap)
}
bool bitmap_resize(struct bitmap *img, HermesHandle hermes_h,
HermesFormat *fmt, int nw, int nh)
{
short bpp = bitmap_get_bpp( img );
int stride = bitmap_get_rowstride( img );
int err;
if( img->resized != NULL ) {
if( img->resized->width != nw || img->resized->height != nh ) {
bitmap_destroy( img->resized );
img->resized = NULL;
} else {
/* the bitmap is already resized */
return(true);
}
}
/* allocate the mem for resized bitmap */
img->resized = bitmap_create_ex( nw, nh, bpp, nw*bpp, 0, NULL );
if( img->resized == NULL ) {
printf("W: %d, H: %d, bpp: %d\n", nw, nh, bpp);
assert(img->resized);
return(false);
}
/* allocate an converter, only for resizing */
err = Hermes_ConverterRequest( hermes_h,
fmt,
fmt
);
if( err == 0 ) {
return(false);
}
err = Hermes_ConverterCopy( hermes_h,
img->pixdata,
0, /* x src coord of top left in pixel coords */
0, /* y src coord of top left in pixel coords */
bitmap_get_width( img ), bitmap_get_height( img ),
stride, /* stride as bytes */
img->resized->pixdata,
0, /* x dst coord of top left in pixel coords */
0, /* y dst coord of top left in pixel coords */
nw, nh,
bitmap_get_rowstride(img->resized) /* stride as bytes */
);
if( err == 0 ) {
bitmap_destroy( img->resized );
img->resized = NULL;
return(false);
}
return(true);
HermesFormat *fmt, int nw, int nh)
{
short bpp = bitmap_get_bpp( img );
int stride = bitmap_get_rowstride( img );
int err;
if( img->resized != NULL ) {
if( img->resized->width != nw || img->resized->height != nh ) {
bitmap_destroy( img->resized );
img->resized = NULL;
} else {
/* the bitmap is already resized */
return(true);
}
}
/* allocate the mem for resized bitmap */
img->resized = bitmap_create_ex( nw, nh, bpp, nw*bpp, 0, NULL );
if( img->resized == NULL ) {
printf("W: %d, H: %d, bpp: %d\n", nw, nh, bpp);
assert(img->resized);
return(false);
}
/* allocate an converter, only for resizing */
err = Hermes_ConverterRequest( hermes_h,
fmt,
fmt
);
if( err == 0 ) {
return(false);
}
err = Hermes_ConverterCopy( hermes_h,
img->pixdata,
0, /* x src coord of top left in pixel coords */
0, /* y src coord of top left in pixel coords */
bitmap_get_width( img ), bitmap_get_height( img ),
stride, /* stride as bytes */
img->resized->pixdata,
0, /* x dst coord of top left in pixel coords */
0, /* y dst coord of top left in pixel coords */
nw, nh,
bitmap_get_rowstride(img->resized) /* stride as bytes */
);
if( err == 0 ) {
bitmap_destroy( img->resized );
img->resized = NULL;
return(false);
}
return(true);
}
/*

View File

@ -298,20 +298,6 @@ void bitmap_modified(void *vbitmap) {
nsbeos_bitmap_free_pretiles(bitmap);
}
/**
* The bitmap image can be suspended.
*
* \param vbitmap a bitmap, as returned by bitmap_create()
* \param private_word a private word to be returned later
* \param suspend the function to be called upon suspension
* \param resume the function to be called when resuming
*/
void bitmap_set_suspendable(void *vbitmap, void *private_word,
void (*invalidate)(void *vbitmap, void *private_word)) {
struct bitmap *bitmap = (struct bitmap *)vbitmap;
}
int bitmap_get_width(void *vbitmap){
struct bitmap *bitmap = (struct bitmap *)vbitmap;
return bitmap->primary->Bounds().Width() + 1;

View File

@ -156,13 +156,6 @@ void bitmap_modified(void *bitmap)
}
}
void bitmap_set_suspendable(void *bitmap, void *private_word,
void (*invalidate)(void *bitmap, void *private_word))
{
// nothing to do
}
CGImageRef cocoa_get_cgimage( void *bitmap )
{
NSMapTable *cache = cocoa_get_bitmap_cache();

View File

@ -144,19 +144,6 @@ bool bitmap_save(void *bitmap, const char *path, unsigned flags)
void bitmap_modified(void *bitmap) {
}
/**
* The bitmap image can be suspended.
*
* \param bitmap a bitmap, as returned by bitmap_create()
* \param private_word a private word to be returned later
* \param suspend the function to be called upon suspension
* \param resume the function to be called when resuming
*/
void bitmap_set_suspendable(void *bitmap, void *private_word,
void (*invalidate)(void *bitmap, void *private_word)) {
}
/**
* Sets wether a bitmap should be plotted opaque
*

View File

@ -319,18 +319,6 @@ void bitmap_modified(void *vbitmap) {
gbitmap->converted = true;
}
/**
* The bitmap image can be suspended.
*
* \param bitmap a bitmap, as returned by bitmap_create()
* \param private_word a private word to be returned later
* \param invalidate the function to be called upon suspension
*/
void bitmap_set_suspendable(void *vbitmap, void *private_word,
void (*invalidate)(void *vbitmap, void *private_word)) {
}
int bitmap_get_width(void *vbitmap){
struct bitmap *gbitmap = (struct bitmap *)vbitmap;
assert(gbitmap);

View File

@ -81,8 +81,6 @@ size_t bitmap_get_bpp(void *bitmap);
void bitmap_destroy(void *bitmap);
bool bitmap_save(void *bitmap, const char *path, unsigned flags);
void bitmap_modified(void *bitmap);
void bitmap_set_suspendable(void *bitmap, void *private_word,
void (*invalidate)(void *bitmap, void *private_word));
int bitmap_get_width(void *bitmap);
int bitmap_get_height(void *bitmap);

View File

@ -120,7 +120,6 @@ static void *nsbmp_bitmap_create(int width, int height, unsigned int bmp_state)
bmp_bitmap_callback_vt bmp_bitmap_callbacks = {
.bitmap_create = nsbmp_bitmap_create,
.bitmap_destroy = bitmap_destroy,
.bitmap_set_suspendable = bitmap_set_suspendable,
.bitmap_get_buffer = bitmap_get_buffer,
.bitmap_get_bpp = bitmap_get_bpp
};

View File

@ -235,13 +235,6 @@ static void nsgif_animate(void *p)
content_broadcast(&gif->base, CONTENT_MSG_REDRAW, data);
}
static void nsgif_invalidate(void *bitmap, void *private_word)
{
struct gif_animation *gif = (struct gif_animation *)private_word;
gif->decoded_frame = -1;
}
static bool nsgif_convert(struct content *c)
{
nsgif_content *gif = (nsgif_content *) c;
@ -294,9 +287,6 @@ static bool nsgif_convert(struct content *c)
gif->current_frame = 0;
if (gif->gif->frame_count_partial > 1)
schedule(gif->gif->frames[0].frame_delay, nsgif_animate, c);
else
bitmap_set_suspendable(gif->gif->frame_image, gif->gif,
nsgif_invalidate);
/* Exit as a success */
content_set_ready(c);

View File

@ -108,12 +108,6 @@ void bitmap_modified(void *bitmap)
bmap->state |= BITMAP_MODIFIED;
}
void bitmap_set_suspendable(void *bitmap, void *private_word,
void (*invalidate)(void *bitmap, void *private_word))
{
}
int bitmap_get_width(void *bitmap)
{
struct bitmap *bmap = bitmap;

View File

@ -781,23 +781,6 @@ void bitmap_modified(void *vbitmap) {
}
/**
* The bitmap image can be suspended.
*
* \param bitmap a bitmap, as returned by bitmap_create()
* \param private_word a private word to be returned later
* \param invalidate the function to be called upon suspension
*/
void bitmap_set_suspendable(void *vbitmap, void *private_word,
void (*invalidate)(void *bitmap, void *private_word)) {
struct bitmap *bitmap = (struct bitmap *) vbitmap;
bitmap->private_word = private_word;
bitmap->invalidate = invalidate;
bitmap_suspendable++;
}
/**
* Performs routine maintenance.
*/

View File

@ -177,19 +177,6 @@ bool bitmap_save(void *bitmap, const char *path, unsigned flags)
void bitmap_modified(void *bitmap) {
}
/**
* The bitmap image can be suspended.
*
* \param bitmap a bitmap, as returned by bitmap_create()
* \param private_word a private word to be returned later
* \param suspend the function to be called upon suspension
* \param resume the function to be called when resuming
*/
void bitmap_set_suspendable(void *bitmap, void *private_word,
void (*invalidate)(void *bitmap, void *private_word)) {
}
/**
* Sets whether a bitmap should be plotted opaque
*