track type of native bitmap

This commit is contained in:
Chris Young 2016-01-25 00:29:08 +00:00
parent 452d8ce512
commit 8d71c0ae9e

View File

@ -46,6 +46,13 @@
#include "amiga/misc.h"
#include "amiga/rtg.h"
enum {
AMI_NSBM_NONE = 0,
AMI_NSBM_TRUECOLOUR,
AMI_NSBM_PALETTEMAPPED
};
/* exported function documented in amiga/bitmap.h */
void *amiga_bitmap_create(int width, int height, unsigned int state)
{
@ -69,6 +76,7 @@ void *amiga_bitmap_create(int width, int height, unsigned int state)
bitmap->url = NULL;
bitmap->title = NULL;
bitmap->icondata = NULL;
bitmap->native = AMI_NSBM_NONE;
return bitmap;
}
@ -163,6 +171,7 @@ void amiga_bitmap_modified(void *bitmap)
bm->nativebm = NULL;
bm->dto = NULL;
bm->native_mask = NULL;
bm->native = AMI_NSBM_NONE;
}
@ -353,6 +362,10 @@ static inline struct BitMap *ami_bitmap_get_truecolour(struct bitmap *bitmap,int
if(!bitmap) return NULL;
if((bitmap->native != AMI_NSBM_NONE) && (bitmap->native != AMI_NSBM_TRUECOLOUR)) {
amiga_bitmap_modified(bitmap);
}
if(bitmap->nativebm)
{
if((bitmap->nativebmwidth == width) && (bitmap->nativebmheight==height))
@ -384,6 +397,7 @@ static inline struct BitMap *ami_bitmap_get_truecolour(struct bitmap *bitmap,int
bitmap->nativebm = tbm;
bitmap->nativebmwidth = bitmap->width;
bitmap->nativebmheight = bitmap->height;
bitmap->native = AMI_NSBM_TRUECOLOUR;
}
}
@ -436,12 +450,14 @@ static inline struct BitMap *ami_bitmap_get_truecolour(struct bitmap *bitmap,int
ami_rtg_freebitmap(tbm);
tbm = scaledbm;
bitmap->nativebm = NULL;
bitmap->native = AMI_NSBM_NONE;
if(nsoption_int(cache_bitmaps) >= 1)
{
bitmap->nativebm = tbm;
bitmap->nativebmwidth = width;
bitmap->nativebmheight = height;
bitmap->native = AMI_NSBM_TRUECOLOUR;
}
}
@ -483,6 +499,10 @@ static inline struct BitMap *ami_bitmap_get_palettemapped(struct bitmap *bitmap,
{
struct BitMap *dtbm;
if((bitmap->native != AMI_NSBM_NONE) && (bitmap->native != AMI_NSBM_PALETTEMAPPED)) {
amiga_bitmap_modified(bitmap);
}
/* Dispose the DataTypes object if we've performed a layout already,
and we need to scale, as scaling can only be performed before
the first GM_LAYOUT */
@ -519,6 +539,10 @@ static inline struct BitMap *ami_bitmap_get_palettemapped(struct bitmap *bitmap,
bitmap->nativebmwidth = width;
bitmap->nativebmheight = height;
/**\todo Native bitmaps are stored as DataTypes Objects here?
This is sub-optimal and they should be cached as BitMaps according to user
preferences */
bitmap->native = AMI_NSBM_PALETTEMAPPED;
return dtbm;
}
@ -534,11 +558,7 @@ struct BitMap *ami_bitmap_get_native(struct bitmap *bitmap,
static nserror bitmap_render(struct bitmap *bitmap, hlcache_handle *content)
{
int plot_width;
int plot_height;
struct MinList shared_pens;
struct gui_globals bm_globals;
struct gui_globals *temp_gg = glob;
// if(ami_plot_screen_is_palettemapped() == true) return NSERROR_OK;
struct redraw_context ctx = {
.interactive = false,
@ -546,13 +566,18 @@ static nserror bitmap_render(struct bitmap *bitmap, hlcache_handle *content)
.plot = &amiplot
};
int plot_width;
int plot_height;
struct gui_globals bm_globals;
struct gui_globals *temp_gg = glob;
// struct MinList *shared_pens = ami_AllocMinList();
plot_width = MIN(content_get_width(content), bitmap->width);
plot_height = ((plot_width * bitmap->height) + (bitmap->width / 2)) /
bitmap->width;
ami_init_layers(&bm_globals, bitmap->width, bitmap->height);
ami_NewMinList(&shared_pens);
bm_globals.shared_pens = &shared_pens;
ami_init_layers(&bm_globals, bitmap->width, bitmap->height, true);
// bm_globals.shared_pens = shared_pens;
glob = &bm_globals;
ami_clearclipreg(&bm_globals);
@ -582,7 +607,8 @@ static nserror bitmap_render(struct bitmap *bitmap, hlcache_handle *content)
to try to avoid re-conversion (at the expense of memory) */
ami_free_layers(&bm_globals);
ami_plot_release_pens(&shared_pens);
// ami_plot_release_pens(shared_pens);
// FreeVec(shared_pens);
amiga_bitmap_set_opaque(bitmap, true);
/* Restore previous render area. This is set when plotting starts,