mirror of
https://github.com/netsurf-browser/netsurf
synced 2024-12-19 02:32:44 +03:00
Make the palette-mapped state relate to the rendering layer rather than globally.
This means we can still render in 32-bit mode internally when the destination isn't the screen. NB: bitmap_render is currently freezing when the screen is in palette-mapped mode (old bug, pre-dates this change), so for now we skip this routine in that scenario.
This commit is contained in:
parent
452d8ce512
commit
c0d031bf73
@ -534,11 +534,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 +542,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 +583,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,
|
||||
|
15
amiga/gui.c
15
amiga/gui.c
@ -809,7 +809,7 @@ static void ami_openscreen(void)
|
||||
static void ami_openscreenfirst(void)
|
||||
{
|
||||
ami_openscreen();
|
||||
if(!browserglob.bm) ami_init_layers(&browserglob, 0, 0);
|
||||
if(!browserglob.bm) ami_init_layers(&browserglob, 0, 0, false);
|
||||
ami_theme_throbber_setup();
|
||||
}
|
||||
|
||||
@ -2859,7 +2859,7 @@ void ami_switch_tab(struct gui_window_2 *gwin, bool redraw)
|
||||
return;
|
||||
}
|
||||
|
||||
ami_plot_release_pens(&gwin->shared_pens);
|
||||
ami_plot_release_pens(gwin->shared_pens);
|
||||
ami_update_buttons(gwin);
|
||||
ami_menu_update_disabled(gwin->gw, browser_window_get_content(gwin->gw->bw));
|
||||
|
||||
@ -3495,7 +3495,7 @@ static void ami_do_redraw_tiled(struct gui_window_2 *gwin, bool busy,
|
||||
int tile_x_scale = (int)(tile_size_x / gwin->gw->scale);
|
||||
int tile_y_scale = (int)(tile_size_y / gwin->gw->scale);
|
||||
|
||||
browserglob.shared_pens = &gwin->shared_pens; /* do we need this?? */
|
||||
browserglob.shared_pens = gwin->shared_pens; /* do we need this?? */
|
||||
|
||||
if(top < 0) {
|
||||
height += top;
|
||||
@ -3869,7 +3869,7 @@ gui_window_create(struct browser_window *bw,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ami_NewMinList(&g->shared->shared_pens);
|
||||
g->shared->shared_pens = ami_AllocMinList();
|
||||
|
||||
g->shared->scrollerhook.h_Entry = (void *)ami_scroller_hook;
|
||||
g->shared->scrollerhook.h_Data = g->shared;
|
||||
@ -4492,7 +4492,8 @@ static void gui_window_destroy(struct gui_window *g)
|
||||
return;
|
||||
}
|
||||
|
||||
ami_plot_release_pens(&g->shared->shared_pens);
|
||||
ami_plot_release_pens(g->shared->shared_pens);
|
||||
FreeVec(g->shared->shared_pens);
|
||||
ami_schedule_redraw_remove(g->shared);
|
||||
ami_schedule(-1, ami_gui_refresh_favicon, g->shared);
|
||||
|
||||
@ -4831,7 +4832,7 @@ static void ami_do_redraw(struct gui_window_2 *gwin)
|
||||
}
|
||||
else
|
||||
{
|
||||
browserglob.shared_pens = &gwin->shared_pens;
|
||||
browserglob.shared_pens = gwin->shared_pens;
|
||||
temprp = browserglob.rp;
|
||||
browserglob.rp = gwin->win->RPort;
|
||||
clip.x0 = bbox->Left;
|
||||
@ -5202,7 +5203,7 @@ static void gui_window_new_content(struct gui_window *g)
|
||||
g->shared->oldh = 0;
|
||||
g->shared->oldv = 0;
|
||||
g->favicon = NULL;
|
||||
ami_plot_release_pens(&g->shared->shared_pens);
|
||||
ami_plot_release_pens(g->shared->shared_pens);
|
||||
ami_menu_update_disabled(g, c);
|
||||
ami_gui_update_hotlist_button(g->shared);
|
||||
ami_gui_scroller_update(g->shared);
|
||||
|
@ -138,7 +138,7 @@ struct gui_window_2 {
|
||||
gui_drag_type drag_op;
|
||||
struct IBox *ptr_lock;
|
||||
struct AppWindow *appwin;
|
||||
struct MinList shared_pens;
|
||||
struct MinList *shared_pens;
|
||||
gui_pointer_shape mouse_pointer;
|
||||
struct Menu *imenu; /* Intuition menu */
|
||||
struct VisualInfo *vi; /* For GadTools menu */
|
||||
|
@ -117,7 +117,7 @@ void ami_history_open(struct gui_window *gw)
|
||||
{
|
||||
gw->hw = ami_misc_allocvec_clear(sizeof(struct history_window), 0);
|
||||
|
||||
ami_init_layers(&gw->hw->gg, scrn->Width, scrn->Height);
|
||||
ami_init_layers(&gw->hw->gg, scrn->Width, scrn->Height, false);
|
||||
|
||||
gw->hw->gw = gw;
|
||||
browser_window_history_size(gw->bw, &width, &height);
|
||||
|
@ -70,7 +70,6 @@ struct bez_point {
|
||||
float y;
|
||||
};
|
||||
|
||||
static bool palette_mapped = false;
|
||||
static int init_layers_count = 0;
|
||||
static APTR pool_pens = NULL;
|
||||
|
||||
@ -90,7 +89,7 @@ static APTR pool_pens = NULL;
|
||||
/* Define the below to get additional debug */
|
||||
#undef AMI_PLOTTER_DEBUG
|
||||
|
||||
void ami_init_layers(struct gui_globals *gg, ULONG width, ULONG height)
|
||||
void ami_init_layers(struct gui_globals *gg, ULONG width, ULONG height, bool force32bit)
|
||||
{
|
||||
/* init shared bitmaps *
|
||||
* Height is set to screen width to give enough space for thumbnails *
|
||||
@ -99,22 +98,23 @@ void ami_init_layers(struct gui_globals *gg, ULONG width, ULONG height)
|
||||
int depth = 32;
|
||||
struct BitMap *friend = NULL;
|
||||
|
||||
depth = GetBitMapAttr(scrn->RastPort.BitMap, BMA_DEPTH);
|
||||
if(force32bit == false) depth = GetBitMapAttr(scrn->RastPort.BitMap, BMA_DEPTH);
|
||||
LOG("Screen depth = %d", depth);
|
||||
|
||||
if(depth < 16) {
|
||||
palette_mapped = true;
|
||||
gg->palette_mapped = true;
|
||||
} else {
|
||||
palette_mapped = false;
|
||||
gg->palette_mapped = false;
|
||||
}
|
||||
|
||||
#ifndef __amigaos4__
|
||||
#warning OS3 locked to palette-mapped modes
|
||||
palette_mapped = true;
|
||||
gg->palette_mapped = true;
|
||||
if(depth > 8) depth = 8;
|
||||
#endif
|
||||
|
||||
if(palette_mapped == true) nsoption_set_bool(font_antialiasing, false);
|
||||
/* Probably need to fix this next line */
|
||||
if(gg->palette_mapped == true) nsoption_set_bool(font_antialiasing, false);
|
||||
|
||||
if(!width) width = nsoption_int(redraw_tile_size_x);
|
||||
if(!height) height = nsoption_int(redraw_tile_size_y);
|
||||
@ -146,7 +146,7 @@ void ami_init_layers(struct gui_globals *gg, ULONG width, ULONG height)
|
||||
}
|
||||
#endif
|
||||
|
||||
if(palette_mapped == true) {
|
||||
if(gg->palette_mapped == true) {
|
||||
gg->bm = AllocBitMap(width, height, depth, 0, friend);
|
||||
} else {
|
||||
#ifdef __amigaos4__
|
||||
@ -184,7 +184,7 @@ void ami_init_layers(struct gui_globals *gg, ULONG width, ULONG height)
|
||||
|
||||
InitTmpRas(gg->rp->TmpRas, gg->tmprasbuf, width*height);
|
||||
|
||||
if((palette_mapped == true) && (pool_pens == NULL)) {
|
||||
if((gg->palette_mapped == true) && (pool_pens == NULL)) {
|
||||
pool_pens = ami_misc_itempool_create(sizeof(struct ami_plot_pen));
|
||||
}
|
||||
|
||||
@ -210,7 +210,7 @@ void ami_free_layers(struct gui_globals *gg)
|
||||
FreeVec(gg->tmprasbuf);
|
||||
FreeVec(gg->areabuf);
|
||||
DisposeLayerInfo(gg->layerinfo);
|
||||
if(palette_mapped == false) {
|
||||
if(gg->palette_mapped == false) {
|
||||
if(gg->bm) ami_rtg_freebitmap(gg->bm);
|
||||
} else {
|
||||
if(gg->bm) FreeBitMap(gg->bm);
|
||||
@ -273,7 +273,7 @@ void ami_plot_release_pens(struct MinList *shared_pens)
|
||||
static void ami_plot_setapen(struct RastPort *rp, ULONG colr)
|
||||
{
|
||||
#ifdef __amigaos4__
|
||||
if(palette_mapped == false) {
|
||||
if(glob->palette_mapped == false) {
|
||||
SetRPAttrs(rp, RPTAG_APenColor,
|
||||
ns_color_to_nscss(colr),
|
||||
TAG_DONE);
|
||||
@ -288,7 +288,7 @@ static void ami_plot_setapen(struct RastPort *rp, ULONG colr)
|
||||
static void ami_plot_setopen(struct RastPort *rp, ULONG colr)
|
||||
{
|
||||
#ifdef __amigaos4__
|
||||
if(palette_mapped == false) {
|
||||
if(glob->palette_mapped == false) {
|
||||
SetRPAttrs(rp, RPTAG_OPenColor,
|
||||
ns_color_to_nscss(colr),
|
||||
TAG_DONE);
|
||||
@ -537,7 +537,7 @@ static bool ami_bitmap(int x, int y, int width, int height, struct bitmap *bitma
|
||||
#endif
|
||||
|
||||
#ifdef __amigaos4__
|
||||
if(__builtin_expect((GfxBase->LibNode.lib_Version >= 53) && (palette_mapped == false) &&
|
||||
if(__builtin_expect((GfxBase->LibNode.lib_Version >= 53) && (glob->palette_mapped == false) &&
|
||||
(nsoption_bool(direct_render) == false), 1)) {
|
||||
uint32 comptype = COMPOSITE_Src_Over_Dest;
|
||||
uint32 compflags = COMPFLAG_IgnoreDestAlpha;
|
||||
@ -564,7 +564,7 @@ static bool ami_bitmap(int x, int y, int width, int height, struct bitmap *bitma
|
||||
{
|
||||
ULONG tag, tag_data, minterm = 0xc0;
|
||||
|
||||
if(palette_mapped == false) {
|
||||
if(glob->palette_mapped == false) {
|
||||
tag = BLITA_UseSrcAlpha;
|
||||
tag_data = !bitmap->opaque;
|
||||
minterm = 0xc0;
|
||||
@ -715,7 +715,7 @@ HOOKF(void, ami_bitmap_tile_hook, struct RastPort *, rp, struct BackFillMessage
|
||||
for (yf = -bfbm->offsety; yf < msg->Bounds.MaxY; yf += bfbm->height) {
|
||||
#ifdef __amigaos4__
|
||||
if(__builtin_expect((GfxBase->LibNode.lib_Version >= 53) &&
|
||||
(palette_mapped == false), 1)) {
|
||||
(glob->palette_mapped == false), 1)) {
|
||||
CompositeTags(COMPOSITE_Src_Over_Dest, bfbm->bm, rp->BitMap,
|
||||
COMPTAG_Flags, COMPFLAG_IgnoreDestAlpha,
|
||||
COMPTAG_DestX, msg->Bounds.MinX,
|
||||
@ -734,7 +734,7 @@ HOOKF(void, ami_bitmap_tile_hook, struct RastPort *, rp, struct BackFillMessage
|
||||
{
|
||||
ULONG tag, tag_data, minterm = 0xc0;
|
||||
|
||||
if(palette_mapped == false) {
|
||||
if(glob->palette_mapped == false) {
|
||||
tag = BLITA_UseSrcAlpha;
|
||||
tag_data = TRUE;
|
||||
minterm = 0xc0;
|
||||
@ -876,7 +876,7 @@ static bool ami_path(const float *p, unsigned int n, colour fill, float width,
|
||||
|
||||
bool ami_plot_screen_is_palettemapped(void)
|
||||
{
|
||||
return palette_mapped;
|
||||
return glob->palette_mapped;
|
||||
}
|
||||
|
||||
struct plotter_table plot;
|
||||
|
@ -33,13 +33,14 @@ struct gui_globals
|
||||
APTR tmprasbuf;
|
||||
struct Rectangle rect;
|
||||
struct MinList *shared_pens;
|
||||
bool palette_mapped;
|
||||
int width; /* size of bm and */
|
||||
int height; /* associated memory */
|
||||
};
|
||||
|
||||
extern const struct plotter_table amiplot;
|
||||
|
||||
void ami_init_layers(struct gui_globals *gg, ULONG width, ULONG height);
|
||||
void ami_init_layers(struct gui_globals *gg, ULONG width, ULONG height, bool force32bit);
|
||||
void ami_free_layers(struct gui_globals *gg);
|
||||
void ami_clearclipreg(struct gui_globals *gg);
|
||||
void ami_plot_clear_bbox(struct RastPort *rp, struct IBox *bbox);
|
||||
|
@ -481,7 +481,8 @@ bool ami_print_begin(struct print_settings *ps)
|
||||
|
||||
ami_init_layers(ami_print_info.gg,
|
||||
ami_print_info.PED->ped_MaxXDots,
|
||||
ami_print_info.PED->ped_MaxYDots);
|
||||
ami_print_info.PED->ped_MaxYDots,
|
||||
true);
|
||||
|
||||
ami_print_info.page = 0;
|
||||
|
||||
|
@ -734,7 +734,7 @@ void ami_tree_open(struct treeview_window *twin,int type)
|
||||
twin->scrollerhook.h_Entry = (void *)ami_tree_scroller_hook;
|
||||
twin->scrollerhook.h_Data = twin;
|
||||
|
||||
ami_init_layers(&twin->globals, 0, 0);
|
||||
ami_init_layers(&twin->globals, 0, 0, false);
|
||||
ami_tree_menu(twin);
|
||||
|
||||
if(type == AMI_TREE_SSLCERT)
|
||||
|
Loading…
Reference in New Issue
Block a user