Merge branch 'chris/fix-palmap-crash'

Fixes a problem with OS4 freezing up when running NetSurf on a palette mapped screen.
This commit is contained in:
Chris Young 2016-01-25 18:55:30 +00:00
commit 9879cbbfae
3 changed files with 30 additions and 10 deletions

View File

@ -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,8 +558,6 @@ 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)
{ {
if(ami_plot_screen_is_palettemapped() == true) return NSERROR_OK;
struct redraw_context ctx = { struct redraw_context ctx = {
.interactive = false, .interactive = false,
.background_images = true, .background_images = true,
@ -546,14 +568,13 @@ static nserror bitmap_render(struct bitmap *bitmap, hlcache_handle *content)
int plot_height; int plot_height;
struct gui_globals bm_globals; struct gui_globals bm_globals;
struct gui_globals *temp_gg = glob; 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, true); ami_init_layers(&bm_globals, bitmap->width, bitmap->height, true);
// bm_globals.shared_pens = shared_pens; bm_globals.shared_pens = NULL;
glob = &bm_globals; glob = &bm_globals;
ami_clearclipreg(&bm_globals); ami_clearclipreg(&bm_globals);
@ -576,15 +597,13 @@ static nserror bitmap_render(struct bitmap *bitmap, hlcache_handle *content)
ami_bitmap_argb_to_rgba(bitmap); ami_bitmap_argb_to_rgba(bitmap);
#else #else
#warning FIXME for OS3 #warning FIXME for OS3 (in current state none of bitmap_render can work!)
#endif #endif
/**\todo In theory we should be able to move the bitmap to our native area /**\todo In theory we should be able to move the bitmap to our native area
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);
// 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,

View File

@ -35,6 +35,7 @@ struct bitmap {
int height; int height;
UBYTE *pixdata; UBYTE *pixdata;
bool opaque; bool opaque;
int native;
struct BitMap *nativebm; struct BitMap *nativebm;
int nativebmwidth; int nativebmwidth;
int nativebmheight; int nativebmheight;

View File

@ -142,7 +142,7 @@ void ami_init_layers(struct gui_globals *gg, ULONG width, ULONG height, bool for
} else { } else {
/* Force friend BitMaps on for obvious RTG screens under OS3. /* Force friend BitMaps on for obvious RTG screens under OS3.
* If we get a bit smarter about this we can lose the user option. */ * If we get a bit smarter about this we can lose the user option. */
if(depth >= 16) friend = scrn->RastPort.BitMap; if((depth >= 16) && (force32bit == false)) friend = scrn->RastPort.BitMap;
} }
#endif #endif
@ -154,7 +154,7 @@ void ami_init_layers(struct gui_globals *gg, ULONG width, ULONG height, bool for
* We get freezes and other problems on OS4 if we befriend at any * We get freezes and other problems on OS4 if we befriend at any
* other depths, hence this check. * other depths, hence this check.
*/ */
if(depth >= 24) friend = scrn->RastPort.BitMap; if((depth >= 24) && (force32bit == false)) friend = scrn->RastPort.BitMap;
#endif #endif
gg->bm = ami_rtg_allocbitmap(width, height, 32, 0, friend, RGBFB_A8R8G8B8); gg->bm = ami_rtg_allocbitmap(width, height, 32, 0, friend, RGBFB_A8R8G8B8);
} }