From 8d71c0ae9e48695b14f24a62d3655f11858bba95 Mon Sep 17 00:00:00 2001 From: Chris Young Date: Mon, 25 Jan 2016 00:29:08 +0000 Subject: [PATCH 1/6] track type of native bitmap --- amiga/bitmap.c | 46 ++++++++++++++++++++++++++++++++++++---------- 1 file changed, 36 insertions(+), 10 deletions(-) diff --git a/amiga/bitmap.c b/amiga/bitmap.c index ae9479d26..c57fb8f20 100644 --- a/amiga/bitmap.c +++ b/amiga/bitmap.c @@ -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; } } @@ -482,7 +498,11 @@ static inline struct BitMap *ami_bitmap_get_palettemapped(struct bitmap *bitmap, int width, int height) { 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, From beb6cebf1e25cd95f7b2e5acbcb35defcf1496b5 Mon Sep 17 00:00:00 2001 From: Chris Young Date: Mon, 25 Jan 2016 18:26:22 +0000 Subject: [PATCH 2/6] conflict --- amiga/bitmap.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/amiga/bitmap.c b/amiga/bitmap.c index 73cb4e35f..c57fb8f20 100644 --- a/amiga/bitmap.c +++ b/amiga/bitmap.c @@ -558,11 +558,7 @@ struct BitMap *ami_bitmap_get_native(struct bitmap *bitmap, static nserror bitmap_render(struct bitmap *bitmap, hlcache_handle *content) { -<<<<<<< HEAD // if(ami_plot_screen_is_palettemapped() == true) return NSERROR_OK; -======= - if(ami_plot_screen_is_palettemapped() == true) return NSERROR_OK; ->>>>>>> 6847fad65368bab3418eb716af4f9d485dfe30b1 struct redraw_context ctx = { .interactive = false, From 5c8dccd5f6353524173542762154473f4006383f Mon Sep 17 00:00:00 2001 From: Chris Young Date: Mon, 25 Jan 2016 18:41:50 +0000 Subject: [PATCH 3/6] When forcing 32-bit render mode, don't create the BitMaps as friends of the screen BitMap. This fixes a system freeze on OS4 --- amiga/bitmap.h | 1 + amiga/plotters.c | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/amiga/bitmap.h b/amiga/bitmap.h index 20e631585..aba359783 100755 --- a/amiga/bitmap.h +++ b/amiga/bitmap.h @@ -35,6 +35,7 @@ struct bitmap { int height; UBYTE *pixdata; bool opaque; + int native; struct BitMap *nativebm; int nativebmwidth; int nativebmheight; diff --git a/amiga/plotters.c b/amiga/plotters.c index bb69dce24..c6c546b03 100644 --- a/amiga/plotters.c +++ b/amiga/plotters.c @@ -142,7 +142,7 @@ void ami_init_layers(struct gui_globals *gg, ULONG width, ULONG height, bool for } else { /* 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(depth >= 16) friend = scrn->RastPort.BitMap; + if((depth >= 16) && (force32bit == false)) friend = scrn->RastPort.BitMap; } #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 * other depths, hence this check. */ - if(depth >= 24) friend = scrn->RastPort.BitMap; + if((depth >= 24) && (force32bit == false)) friend = scrn->RastPort.BitMap; #endif gg->bm = ami_rtg_allocbitmap(width, height, 32, 0, friend, RGBFB_A8R8G8B8); } From 1ea29c6aec03e0d6e9325910998e16910170fafa Mon Sep 17 00:00:00 2001 From: Chris Young Date: Mon, 25 Jan 2016 18:43:43 +0000 Subject: [PATCH 4/6] Plot local history background white instead of wholly transparent --- amiga/history_local.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/amiga/history_local.c b/amiga/history_local.c index f11c78473..e2d1b358e 100755 --- a/amiga/history_local.c +++ b/amiga/history_local.c @@ -82,7 +82,7 @@ static void ami_history_redraw(struct history_window *hw) glob = &hw->gg; - SetRPAttrs(glob->rp, RPTAG_APenColor, 0xffffffff, TAG_DONE); + SetRPAttrs(glob->rp, RPTAG_APenColor, 0x00ffffff, TAG_DONE); RectFill(glob->rp, 0, 0, bbox->Width - 1, bbox->Height - 1); browser_window_history_redraw_rectangle(hw->gw->bw, xs, ys, From 6eb0bd45799853d039d3e3ca8f61f7d4f428ce67 Mon Sep 17 00:00:00 2001 From: Chris Young Date: Mon, 25 Jan 2016 18:48:49 +0000 Subject: [PATCH 5/6] Remove unneeded pen list --- amiga/bitmap.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/amiga/bitmap.c b/amiga/bitmap.c index c57fb8f20..b98d95f5a 100644 --- a/amiga/bitmap.c +++ b/amiga/bitmap.c @@ -558,8 +558,6 @@ struct BitMap *ami_bitmap_get_native(struct bitmap *bitmap, static nserror bitmap_render(struct bitmap *bitmap, hlcache_handle *content) { -// if(ami_plot_screen_is_palettemapped() == true) return NSERROR_OK; - struct redraw_context ctx = { .interactive = false, .background_images = true, @@ -570,14 +568,13 @@ static nserror bitmap_render(struct bitmap *bitmap, hlcache_handle *content) 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, true); -// bm_globals.shared_pens = shared_pens; + bm_globals.shared_pens = NULL; glob = &bm_globals; ami_clearclipreg(&bm_globals); @@ -600,15 +597,13 @@ static nserror bitmap_render(struct bitmap *bitmap, hlcache_handle *content) ami_bitmap_argb_to_rgba(bitmap); #else -#warning FIXME for OS3 +#warning FIXME for OS3 (in current state none of bitmap_render can work!) #endif /**\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) */ ami_free_layers(&bm_globals); -// 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, From 893df2ccf12b14b74f7fefebf6e635836fde3513 Mon Sep 17 00:00:00 2001 From: Chris Young Date: Mon, 25 Jan 2016 18:53:21 +0000 Subject: [PATCH 6/6] Revert "Plot local history background white instead of wholly transparent" On second thoughts this was correct initially. This reverts commit 1ea29c6aec03e0d6e9325910998e16910170fafa. --- amiga/history_local.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/amiga/history_local.c b/amiga/history_local.c index e2d1b358e..f11c78473 100755 --- a/amiga/history_local.c +++ b/amiga/history_local.c @@ -82,7 +82,7 @@ static void ami_history_redraw(struct history_window *hw) glob = &hw->gg; - SetRPAttrs(glob->rp, RPTAG_APenColor, 0x00ffffff, TAG_DONE); + SetRPAttrs(glob->rp, RPTAG_APenColor, 0xffffffff, TAG_DONE); RectFill(glob->rp, 0, 0, bbox->Width - 1, bbox->Height - 1); browser_window_history_redraw_rectangle(hw->gw->bw, xs, ys,