mirror of
https://github.com/netsurf-browser/netsurf
synced 2024-12-24 21:16:50 +03:00
track type of native bitmap
This commit is contained in:
parent
452d8ce512
commit
8d71c0ae9e
@ -46,6 +46,13 @@
|
|||||||
#include "amiga/misc.h"
|
#include "amiga/misc.h"
|
||||||
#include "amiga/rtg.h"
|
#include "amiga/rtg.h"
|
||||||
|
|
||||||
|
enum {
|
||||||
|
AMI_NSBM_NONE = 0,
|
||||||
|
AMI_NSBM_TRUECOLOUR,
|
||||||
|
AMI_NSBM_PALETTEMAPPED
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/* exported function documented in amiga/bitmap.h */
|
/* exported function documented in amiga/bitmap.h */
|
||||||
void *amiga_bitmap_create(int width, int height, unsigned int state)
|
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->url = NULL;
|
||||||
bitmap->title = NULL;
|
bitmap->title = NULL;
|
||||||
bitmap->icondata = NULL;
|
bitmap->icondata = NULL;
|
||||||
|
bitmap->native = AMI_NSBM_NONE;
|
||||||
|
|
||||||
return bitmap;
|
return bitmap;
|
||||||
}
|
}
|
||||||
@ -163,6 +171,7 @@ void amiga_bitmap_modified(void *bitmap)
|
|||||||
bm->nativebm = NULL;
|
bm->nativebm = NULL;
|
||||||
bm->dto = NULL;
|
bm->dto = NULL;
|
||||||
bm->native_mask = 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) return NULL;
|
||||||
|
|
||||||
|
if((bitmap->native != AMI_NSBM_NONE) && (bitmap->native != AMI_NSBM_TRUECOLOUR)) {
|
||||||
|
amiga_bitmap_modified(bitmap);
|
||||||
|
}
|
||||||
|
|
||||||
if(bitmap->nativebm)
|
if(bitmap->nativebm)
|
||||||
{
|
{
|
||||||
if((bitmap->nativebmwidth == width) && (bitmap->nativebmheight==height))
|
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->nativebm = tbm;
|
||||||
bitmap->nativebmwidth = bitmap->width;
|
bitmap->nativebmwidth = bitmap->width;
|
||||||
bitmap->nativebmheight = bitmap->height;
|
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);
|
ami_rtg_freebitmap(tbm);
|
||||||
tbm = scaledbm;
|
tbm = scaledbm;
|
||||||
bitmap->nativebm = NULL;
|
bitmap->nativebm = NULL;
|
||||||
|
bitmap->native = AMI_NSBM_NONE;
|
||||||
|
|
||||||
if(nsoption_int(cache_bitmaps) >= 1)
|
if(nsoption_int(cache_bitmaps) >= 1)
|
||||||
{
|
{
|
||||||
bitmap->nativebm = tbm;
|
bitmap->nativebm = tbm;
|
||||||
bitmap->nativebmwidth = width;
|
bitmap->nativebmwidth = width;
|
||||||
bitmap->nativebmheight = height;
|
bitmap->nativebmheight = height;
|
||||||
|
bitmap->native = AMI_NSBM_TRUECOLOUR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -482,7 +498,11 @@ static inline struct BitMap *ami_bitmap_get_palettemapped(struct bitmap *bitmap,
|
|||||||
int width, int height)
|
int width, int height)
|
||||||
{
|
{
|
||||||
struct BitMap *dtbm;
|
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,
|
/* Dispose the DataTypes object if we've performed a layout already,
|
||||||
and we need to scale, as scaling can only be performed before
|
and we need to scale, as scaling can only be performed before
|
||||||
the first GM_LAYOUT */
|
the first GM_LAYOUT */
|
||||||
@ -519,6 +539,10 @@ static inline struct BitMap *ami_bitmap_get_palettemapped(struct bitmap *bitmap,
|
|||||||
bitmap->nativebmwidth = width;
|
bitmap->nativebmwidth = width;
|
||||||
bitmap->nativebmheight = height;
|
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;
|
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)
|
static nserror bitmap_render(struct bitmap *bitmap, hlcache_handle *content)
|
||||||
{
|
{
|
||||||
int plot_width;
|
// if(ami_plot_screen_is_palettemapped() == true) return NSERROR_OK;
|
||||||
int plot_height;
|
|
||||||
struct MinList shared_pens;
|
|
||||||
struct gui_globals bm_globals;
|
|
||||||
struct gui_globals *temp_gg = glob;
|
|
||||||
|
|
||||||
struct redraw_context ctx = {
|
struct redraw_context ctx = {
|
||||||
.interactive = false,
|
.interactive = false,
|
||||||
@ -546,13 +566,18 @@ static nserror bitmap_render(struct bitmap *bitmap, hlcache_handle *content)
|
|||||||
.plot = &amiplot
|
.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_width = MIN(content_get_width(content), bitmap->width);
|
||||||
plot_height = ((plot_width * bitmap->height) + (bitmap->width / 2)) /
|
plot_height = ((plot_width * bitmap->height) + (bitmap->width / 2)) /
|
||||||
bitmap->width;
|
bitmap->width;
|
||||||
|
|
||||||
ami_init_layers(&bm_globals, bitmap->width, bitmap->height);
|
ami_init_layers(&bm_globals, bitmap->width, bitmap->height, true);
|
||||||
ami_NewMinList(&shared_pens);
|
// bm_globals.shared_pens = shared_pens;
|
||||||
bm_globals.shared_pens = &shared_pens;
|
|
||||||
|
|
||||||
glob = &bm_globals;
|
glob = &bm_globals;
|
||||||
ami_clearclipreg(&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) */
|
to try to avoid re-conversion (at the expense of memory) */
|
||||||
|
|
||||||
ami_free_layers(&bm_globals);
|
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);
|
amiga_bitmap_set_opaque(bitmap, true);
|
||||||
|
|
||||||
/* Restore previous render area. This is set when plotting starts,
|
/* Restore previous render area. This is set when plotting starts,
|
||||||
|
Loading…
Reference in New Issue
Block a user