diff options
-rw-r--r-- | amiga/bitmap.c | 127 | ||||
-rwxr-xr-x | amiga/bitmap.h | 7 | ||||
-rw-r--r-- | amiga/font.c | 36 | ||||
-rwxr-xr-x | amiga/font.h | 2 | ||||
-rwxr-xr-x | amiga/gui.c | 71 | ||||
-rwxr-xr-x | amiga/gui.h | 1 | ||||
-rwxr-xr-x | amiga/gui_options.c | 2 | ||||
-rw-r--r-- | amiga/icon.c | 4 | ||||
-rw-r--r-- | amiga/options.h | 6 | ||||
-rwxr-xr-x | amiga/plotters.c | 340 | ||||
-rwxr-xr-x | amiga/plotters.h | 3 | ||||
-rw-r--r-- | amiga/theme.c | 49 | ||||
-rwxr-xr-x | amiga/tree.c | 7 |
13 files changed, 452 insertions, 203 deletions
diff --git a/amiga/bitmap.c b/amiga/bitmap.c index ce665aaf7..381958b34 100644 --- a/amiga/bitmap.c +++ b/amiga/bitmap.c @@ -1,5 +1,5 @@ /* - * Copyright 2008, 2009 Chris Young <chris@unsatisfactorysoftware.co.uk> + * Copyright 2008, 2009, 2012 Chris Young <chris@unsatisfactorysoftware.co.uk> * * This file is part of NetSurf, http://www.netsurf-browser.org/ * @@ -48,7 +48,7 @@ void *bitmap_create(int width, int height, unsigned int state) { struct bitmap *bitmap; - + bitmap = AllocVec(sizeof(struct bitmap),MEMF_PRIVATE | MEMF_CLEAR); if(bitmap) { @@ -62,6 +62,7 @@ void *bitmap_create(int width, int height, unsigned int state) if(state & BITMAP_OPAQUE) bitmap->opaque = true; else bitmap->opaque = false; } + return bitmap; } @@ -117,9 +118,21 @@ void bitmap_destroy(void *bitmap) if(bm) { - if(bm->nativebm) p96FreeBitMap(bm->nativebm); + if((bm->nativebm) && (bm->dto == NULL)) { + p96FreeBitMap(bm->nativebm); + } + + if(bm->dto) { + DisposeDTObject(bm->dto); + } + + if(bm->native_mask) FreeRaster(bm->native_mask, bm->width, bm->height); FreeVec(bm->pixdata); bm->pixdata = NULL; + bm->nativebm = NULL; + bm->native_mask = NULL; + bm->dto = NULL; + FreeVec(bm); bm = NULL; } @@ -160,8 +173,14 @@ bool bitmap_save(void *bitmap, const char *path, unsigned flags) void bitmap_modified(void *bitmap) { struct bitmap *bm = bitmap; - p96FreeBitMap(bm->nativebm); + if((bm->nativebm) && (bm->dto == NULL)) + p96FreeBitMap(bm->nativebm); + + if(bm->dto) DisposeDTObject(bm->dto); + if(bm->native_mask) FreeRaster(bm->native_mask, bm->width, bm->height); bm->nativebm = NULL; + bm->dto = NULL; + bm->native_mask = NULL; } @@ -208,7 +227,7 @@ bool bitmap_test_opaque(void *bitmap) for(a=0;a<p;a+=4) { - if ((*bmi & 0xff000000U) != 0xff000000U) return false; + if ((*bmi & 0x000000ffU) != 0x000000ffU) return false; bmi++; } return true; @@ -337,9 +356,7 @@ struct bitmap *ami_bitmap_from_datatype(char *filename) return bm; } - - -struct BitMap *ami_getcachenativebm(struct bitmap *bitmap,int width,int height,struct BitMap *friendbm) +static struct BitMap *ami_bitmap_get_truecolour(struct bitmap *bitmap,int width,int height,struct BitMap *friendbm) { struct RenderInfo ri; struct BitMap *tbm = NULL; @@ -454,3 +471,97 @@ struct BitMap *ami_getcachenativebm(struct bitmap *bitmap,int width,int height,s return tbm; } + +PLANEPTR ami_bitmap_get_mask(struct bitmap *bitmap, int width, int height) +{ + uint32 *bmi = (uint32 *) bitmap->pixdata; + UBYTE maskbit = 0; + int y, x, w; + + if((height != bitmap->height) || (width != bitmap->width)) return NULL; + if(bitmap_get_opaque(bitmap) == true) return NULL; + if(bitmap->native_mask) return bitmap->native_mask; + + bitmap->native_mask = AllocRaster(width, height); + + w = width / 8; + +/* + int wu = width; + while((wu % 16) != 0) { + wu += 8; + w++; + } +*/ + + for(int i=0; i<(height * (width / 8)); i++) { + bitmap->native_mask[i] = 0; + } + + for(y=0; y<height; y++) { + for(x=0; x<width; x++) { + if ((*bmi & 0x000000ffU) <= (ULONG)nsoption_int(mask_alpha)) maskbit = 0; + else maskbit = 1; + bmi++; + bitmap->native_mask[(y*w) + (x/8)] = + (bitmap->native_mask[(y*w) + (x/8)] << 1) | maskbit; + } + } + + return bitmap->native_mask; +} + +static struct BitMap *ami_bitmap_get_palettemapped(struct bitmap *bitmap, + int width, int height) +{ + struct BitMap *dtbm; + + /* 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 */ + + if(bitmap->dto && + ((bitmap->nativebmwidth != width) || + (bitmap->nativebmheight != height))) { + DisposeDTObject(bitmap->dto); + bitmap->dto = NULL; + } + + if(bitmap->dto == NULL) { + bitmap->dto = ami_datatype_object_from_bitmap(bitmap); + + SetDTAttrs(bitmap->dto, NULL, NULL, + PDTA_Screen, scrn, + PDTA_ScaleQuality, nsoption_bool(scale_quality), + PDTA_DitherQuality, nsoption_int(dither_quality), + PDTA_FreeSourceBitMap, TRUE, + TAG_DONE); + + if((bitmap->width != width) || (bitmap->height != height)) { + IDoMethod(bitmap->dto, PDTM_SCALE, width, height, 0); + } + + if((DoDTMethod(bitmap->dto, 0, 0, DTM_PROCLAYOUT, 0, 1)) == 0) + return NULL; + } + + GetDTAttrs(bitmap->dto, + PDTA_DestBitMap, &dtbm, + TAG_END); + + bitmap->nativebmwidth = width; + bitmap->nativebmheight = height; + + ami_bitmap_get_mask(bitmap, width, height); + return dtbm; +} + +struct BitMap *ami_bitmap_get_native(struct bitmap *bitmap, + int width, int height, struct BitMap *friendbm) +{ + if(ami_plot_screen_is_palettemapped() == true) { + return ami_bitmap_get_palettemapped(bitmap, width, height); + } else { + return ami_bitmap_get_truecolour(bitmap, width, height, friendbm); + } +} diff --git a/amiga/bitmap.h b/amiga/bitmap.h index 41d488e28..87c569f85 100755 --- a/amiga/bitmap.h +++ b/amiga/bitmap.h @@ -35,12 +35,17 @@ struct bitmap { struct BitMap *nativebm; int nativebmwidth; int nativebmheight; + PLANEPTR native_mask; + Object *dto; char *url; /* temporary storage space */ char *title; /* temporary storage space */ ULONG *icondata; /* for appicons */ }; -struct BitMap *ami_getcachenativebm(struct bitmap *bitmap,int width,int height,struct BitMap *friendbm); +struct BitMap *ami_bitmap_get_native(struct bitmap *bitmap, + int width, int height, struct BitMap *friendbm); +PLANEPTR ami_bitmap_get_mask(struct bitmap *bitmap, int width, int height); + Object *ami_datatype_object_from_bitmap(struct bitmap *bitmap); struct bitmap *ami_bitmap_from_datatype(char *filename); #endif diff --git a/amiga/font.c b/amiga/font.c index 8be407612..ffecf85fe 100644 --- a/amiga/font.c +++ b/amiga/font.c @@ -79,7 +79,7 @@ ULONG ami_devicedpi; ULONG ami_xdpi; int32 ami_font_plot_glyph(struct OutlineFont *ofont, struct RastPort *rp, - uint16 char1, uint16 char2, uint32 x, uint32 y, uint32 emwidth); + uint16 char1, uint16 char2, uint32 x, uint32 y, uint32 emwidth, bool aa); int32 ami_font_width_glyph(struct OutlineFont *ofont, uint16 char1, uint16 char2, uint32 emwidth); struct OutlineFont *ami_open_outline_font(const plot_font_style_t *fstyle, @@ -108,7 +108,7 @@ bool nsfont_width(const plot_font_style_t *fstyle, const char *string, size_t length, int *width) { - *width = ami_unicode_text(NULL,string,length,fstyle,0,0); + *width = ami_unicode_text(NULL, string, length, fstyle, 0, 0, false); if(*width <= 0) *width == length; // fudge @@ -517,20 +517,27 @@ struct OutlineFont *ami_open_outline_font(const plot_font_style_t *fstyle, } int32 ami_font_plot_glyph(struct OutlineFont *ofont, struct RastPort *rp, - uint16 char1, uint16 char2, uint32 x, uint32 y, uint32 emwidth) + uint16 char1, uint16 char2, uint32 x, uint32 y, uint32 emwidth, bool aa) { struct GlyphMap *glyph; UBYTE *glyphbm; int32 char_advance = 0; FIXED kern = 0; - + ULONG glyphmaptag = OT_GlyphMap8Bit; + ULONG template_type = BLITT_ALPHATEMPLATE; + + if(aa == false) { + glyphmaptag = OT_GlyphMap; + template_type = BLITT_TEMPLATE; + } + if(ESetInfo(&ofont->olf_EEngine, OT_GlyphCode, char1, OT_GlyphCode2, char2, TAG_END) == OTERR_Success) { if(EObtainInfo(&ofont->olf_EEngine, - OT_GlyphMap8Bit,&glyph, + glyphmaptag, &glyph, TAG_END) == 0) { glyphbm = glyph->glm_BitMap; @@ -545,7 +552,7 @@ int32 ami_font_plot_glyph(struct OutlineFont *ofont, struct RastPort *rp, BLITA_Width, glyph->glm_BlackWidth, BLITA_Height, glyph->glm_BlackHeight, BLITA_Source, glyphbm, - BLITA_SrcType, BLITT_ALPHATEMPLATE, + BLITA_SrcType, template_type, BLITA_Dest, rp, BLITA_DestType, BLITT_RASTPORT, BLITA_SrcBytesPerRow, glyph->glm_BMModulo, @@ -561,7 +568,7 @@ int32 ami_font_plot_glyph(struct OutlineFont *ofont, struct RastPort *rp, char_advance = (ULONG)(((glyph->glm_Width - kern) * emwidth) / 65536); EReleaseInfo(&ofont->olf_EEngine, - OT_GlyphMap8Bit,glyph, + glyphmaptag, glyph, TAG_END); } } @@ -691,7 +698,8 @@ uint16 ami_font_translate_smallcaps(uint16 utf16char) return utf16char; } -ULONG ami_unicode_text(struct RastPort *rp,const char *string,ULONG length,const plot_font_style_t *fstyle,ULONG dx, ULONG dy) +ULONG ami_unicode_text(struct RastPort *rp, const char *string, ULONG length, + const plot_font_style_t *fstyle, ULONG dx, ULONG dy, bool aa) { uint16 *utf16 = NULL, *outf16 = NULL; uint16 utf16charsc = 0, utf16nextsc = 0; @@ -712,8 +720,6 @@ ULONG ami_unicode_text(struct RastPort *rp,const char *string,ULONG length,const outf16 = utf16; if(!(ofont = ami_open_outline_font(fstyle, 0))) return 0; - if(rp) SetRPAttrs(rp,RPTAG_APenColor,p96EncodeColor(RGBFB_A8B8G8R8,fstyle->foreground),TAG_DONE); - while(*utf16 != 0) { if (*utf16 < 0xD800 || 0xDFFF < *utf16) @@ -729,7 +735,8 @@ ULONG ami_unicode_text(struct RastPort *rp,const char *string,ULONG length,const utf16nextsc = ami_font_translate_smallcaps(utf16next); if(rp) { - tempx = ami_font_plot_glyph(ofont, rp, utf16charsc, utf16nextsc, dx + x, dy, emwidth); + tempx = ami_font_plot_glyph(ofont, rp, utf16charsc, utf16nextsc, + dx + x, dy, emwidth, aa); } else { tempx = ami_font_width_glyph(ofont, utf16charsc, utf16nextsc, emwidth); } @@ -738,7 +745,8 @@ ULONG ami_unicode_text(struct RastPort *rp,const char *string,ULONG length,const if(tempx == 0) { if(rp) { - tempx = ami_font_plot_glyph(ofont, rp, *utf16, utf16next, dx + x, dy, emwidth); + tempx = ami_font_plot_glyph(ofont, rp, *utf16, utf16next, + dx + x, dy, emwidth, aa); } else { tempx = ami_font_width_glyph(ofont, *utf16, utf16next, emwidth); } @@ -755,7 +763,7 @@ ULONG ami_unicode_text(struct RastPort *rp,const char *string,ULONG length,const { if(rp) { tempx = ami_font_plot_glyph(ufont, rp, *utf16, utf16next, - dx + x, dy, emwidth); + dx + x, dy, emwidth, aa); } else { tempx = ami_font_width_glyph(ufont, *utf16, utf16next, emwidth); } @@ -765,7 +773,7 @@ ULONG ami_unicode_text(struct RastPort *rp,const char *string,ULONG length,const { if(rp) { tempx = ami_font_plot_glyph(ofont, rp, 0xfffd, utf16next, - dx + x, dy, emwidth); + dx + x, dy, emwidth, aa); } else { tempx = ami_font_width_glyph(ofont, 0xfffd, utf16next, emwidth); } diff --git a/amiga/font.h b/amiga/font.h index 36bdbf9ef..10137f777 100755 --- a/amiga/font.h +++ b/amiga/font.h @@ -26,7 +26,7 @@ struct ami_font_node; ULONG ami_unicode_text(struct RastPort *rp, const char *string, - ULONG length, const plot_font_style_t *fstyle, ULONG x, ULONG y); + ULONG length, const plot_font_style_t *fstyle, ULONG x, ULONG y, bool aa); void ami_font_setdevicedpi(int id); void ami_init_fonts(void); void ami_close_fonts(void); diff --git a/amiga/gui.c b/amiga/gui.c index 6fc8a2991..2c9eeb50e 100755 --- a/amiga/gui.c +++ b/amiga/gui.c @@ -571,7 +571,6 @@ void gui_init(int argc, char** argv) save_complete_init(); ami_theme_init(); ami_init_mouse_pointers(); - ami_theme_throbber_setup(); } static void ami_gui_newprefs_hook(struct Hook *hook, APTR window, APTR reserved) @@ -603,8 +602,8 @@ void ami_openscreen(void) if(screenmodereq = AllocAslRequest(ASL_ScreenModeRequest,NULL)) { if(AslRequestTags(screenmodereq, - ASLSM_MinDepth,16, - ASLSM_MaxDepth,32, + ASLSM_MinDepth, 0, + ASLSM_MaxDepth, 32, TAG_DONE)) { char *modeid = malloc(20); @@ -665,6 +664,7 @@ void ami_openscreenfirst(void) { ami_openscreen(); if(!browserglob.bm) ami_init_layers(&browserglob, 0, 0); + ami_theme_throbber_setup(); } static void gui_init2(int argc, char** argv) @@ -2209,6 +2209,7 @@ void ami_switch_tab(struct gui_window_2 *gwin,bool redraw) return; } + ami_plot_release_pens(&gwin->shared_pens); ami_update_buttons(gwin); ami_menu_update_disabled(gwin->bw->window, gwin->bw->current_content); @@ -2574,6 +2575,8 @@ struct gui_window *gui_create_browser_window(struct browser_window *bw, return NULL; } + NewMinList(&g->shared->shared_pens); + g->shared->scrollerhook.h_Entry = (void *)ami_scroller_hook; g->shared->scrollerhook.h_Data = g->shared; @@ -3182,12 +3185,14 @@ void gui_window_destroy(struct gui_window *g) return; } + ami_plot_release_pens(&g->shared->shared_pens); + DisposeObject(g->shared->objects[OID_MAIN]); ami_gui_appicon_remove(g->shared); if(g->shared->appwin) RemoveAppWindow(g->shared->appwin); /* These aren't freed by the above. - * TODO: nav_west etc need freeing too */ + * TODO: nav_west etc need freeing too? */ DisposeObject(g->shared->objects[GID_ADDTAB_BM]); DisposeObject(g->shared->objects[GID_CLOSETAB_BM]); DisposeObject(g->shared->objects[GID_TABS_FLAG]); @@ -3280,6 +3285,8 @@ void ami_do_redraw_tiled(struct gui_window_2 *gwin, int tile_x_scale = (int)(nsoption_int(redraw_tile_size_x) / gwin->bw->scale); int tile_y_scale = (int)(nsoption_int(redraw_tile_size_y) / gwin->bw->scale); + browserglob.shared_pens = &gwin->shared_pens; + if(top < 0) { height += top; top = 0; @@ -3308,7 +3315,7 @@ void ami_do_redraw_tiled(struct gui_window_2 *gwin, if(width <= 0) return; if(height <= 0) return; -//printf("%ld %ld %ld %ld\n",left, top, width, height); +// printf("%ld %ld %ld %ld\n",left, top, width, height); for(y = top; y < (top + height); y += tile_y_scale) { clip.y0 = 0; @@ -3470,14 +3477,14 @@ void ami_do_redraw(struct gui_window_2 *g) g->bw->window->c_h = g->bw->window->c_h_temp; - if(vcurrent>oldv) + if(vcurrent>oldv) /* Going down */ { ami_do_redraw_limits(g->bw->window, g->bw, hcurrent, (height / g->bw->scale) + oldv - 1, hcurrent + (width / g->bw->scale), vcurrent + (height / g->bw->scale) + 1); } - else if(vcurrent<oldv) + else if(vcurrent<oldv) /* Going up */ { ami_do_redraw_limits(g->bw->window, g->bw, hcurrent, vcurrent, @@ -3485,14 +3492,14 @@ void ami_do_redraw(struct gui_window_2 *g) oldv); } - if(hcurrent>oldh) + if(hcurrent>oldh) /* Going right */ { ami_do_redraw_limits(g->bw->window, g->bw, (width / g->bw->scale) + oldh , vcurrent, hcurrent + (width / g->bw->scale), vcurrent + (height / g->bw->scale)); } - else if(hcurrent<oldh) + else if(hcurrent<oldh) /* Going left */ { ami_do_redraw_limits(g->bw->window, g->bw, hcurrent, vcurrent, @@ -3516,6 +3523,7 @@ void ami_do_redraw(struct gui_window_2 *g) } else { + browserglob.shared_pens = &g->shared_pens; temprp = browserglob.rp; browserglob.rp = g->win->RPort; clip.x0 = bbox->Left; @@ -3805,6 +3813,7 @@ void gui_window_set_icon(struct gui_window *g, hlcache_handle *icon) struct BitMap *bm = NULL; struct IBox *bbox; ULONG cur_tab = 0; + struct bitmap *icon_bitmap; if(nsoption_bool(kiosk_mode) == true) return; if(!g) return; @@ -3813,9 +3822,9 @@ void gui_window_set_icon(struct gui_window *g, hlcache_handle *icon) g->shared->objects[GID_TABS], (ULONG *)&cur_tab); - if ((icon != NULL) && (content_get_bitmap(icon) != NULL)) + if ((icon != NULL) && ((icon_bitmap = content_get_bitmap(icon)) != NULL)) { - bm = ami_getcachenativebm(content_get_bitmap(icon), 16, 16, + bm = ami_bitmap_get_native(icon_bitmap, 16, 16, g->shared->win->RPort->BitMap); } @@ -3828,6 +3837,18 @@ void gui_window_set_icon(struct gui_window *g, hlcache_handle *icon) if(bm) { + ULONG tag, tag_data, minterm; + + if(ami_plot_screen_is_palettemapped() == false) { + tag = BLITA_UseSrcAlpha; + tag_data = !icon_bitmap->opaque; + minterm = 0xc0; + } else { + tag = BLITA_MaskPlane; + tag_data = (ULONG)ami_bitmap_get_mask(icon_bitmap, 16, 16); + minterm = (ABC|ABNC|ANBC); + } + BltBitMapTags(BLITA_SrcX, 0, BLITA_SrcY, 0, BLITA_DestX, bbox->Left, @@ -3838,7 +3859,8 @@ void gui_window_set_icon(struct gui_window *g, hlcache_handle *icon) BLITA_Dest, g->shared->win->RPort, BLITA_SrcType, BLITT_BITMAP, BLITA_DestType, BLITT_RASTPORT, - BLITA_UseSrcAlpha, TRUE, + BLITA_Minterm, minterm, + tag, tag_data, TAG_DONE); } } @@ -3868,15 +3890,15 @@ void gui_window_set_search_ico(hlcache_handle *ico) struct nsObject *nnode; struct gui_window_2 *gwin; char fname[100]; + struct bitmap *ico_bitmap; if(IsMinListEmpty(window_list)) return; if(nsoption_bool(kiosk_mode) == true) return; if (ico == NULL) ico = search_web_ico(); - if ((ico != NULL) && (content_get_bitmap(ico) != NULL)) - { - bm = ami_getcachenativebm(content_get_bitmap(ico), 16, 16, NULL); - } + ico_bitmap = content_get_bitmap(ico); + if ((ico != NULL) && (ico_bitmap != NULL)) + bm = ami_bitmap_get_native(ico_bitmap, 16, 16, NULL); node = (struct nsObject *)GetHead((struct List *)window_list); @@ -3898,6 +3920,18 @@ void gui_window_set_search_ico(hlcache_handle *ico) if(bm) { + ULONG tag, tag_data, minterm; + + if(ami_plot_screen_is_palettemapped() == false) { + tag = BLITA_UseSrcAlpha; + tag_data = !ico_bitmap->opaque; + minterm = 0xc0; + } else { + tag = BLITA_MaskPlane; + tag_data = (ULONG)ami_bitmap_get_mask(ico_bitmap, 16, 16); + minterm = (ABC|ABNC|ANBC); + } + BltBitMapTags(BLITA_SrcX, 0, BLITA_SrcY, 0, BLITA_DestX, bbox->Left, @@ -3908,7 +3942,8 @@ void gui_window_set_search_ico(hlcache_handle *ico) BLITA_Dest, gwin->win->RPort, BLITA_SrcType, BLITT_BITMAP, BLITA_DestType, BLITT_RASTPORT, - BLITA_UseSrcAlpha, TRUE, + BLITA_Minterm, minterm, + tag, tag_data, TAG_DONE); } } @@ -3997,7 +4032,7 @@ 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_menu_update_disabled(g, c); } diff --git a/amiga/gui.h b/amiga/gui.h index 01588c790..013be50c0 100755 --- a/amiga/gui.h +++ b/amiga/gui.h @@ -112,6 +112,7 @@ struct gui_window_2 { gui_drag_type drag_op; struct IBox *ptr_lock; struct AppWindow *appwin; + struct MinList shared_pens; }; struct gui_window diff --git a/amiga/gui_options.c b/amiga/gui_options.c index 2d65099b0..59e9c9038 100755 --- a/amiga/gui_options.c +++ b/amiga/gui_options.c @@ -669,7 +669,7 @@ void ami_gui_opts_open(void) GA_RelVerify, TRUE, GA_Disabled,screenmodedisabled, GETSCREENMODE_DisplayID,screenmodeid, - GETSCREENMODE_MinDepth, 16, + GETSCREENMODE_MinDepth, 0, GETSCREENMODE_MaxDepth, 32, GetScreenModeEnd, LAYOUT_AddChild, gow->objects[GID_OPTS_SCREENNAME] = StringObject, diff --git a/amiga/icon.c b/amiga/icon.c index e4d0cde2f..87a8a5c18 100644 --- a/amiga/icon.c +++ b/amiga/icon.c @@ -382,7 +382,7 @@ void amiga_icon_superimpose_favicon_internal(struct hlcache_handle *icon, struct { if ((icon != NULL) && (content_get_bitmap(icon) != NULL)) { - bm = ami_getcachenativebm(content_get_bitmap(icon), 16, 16, NULL); + bm = ami_bitmap_get_native(content_get_bitmap(icon), 16, 16, NULL); } if(bm) @@ -503,7 +503,7 @@ struct DiskObject *amiga_icon_from_bitmap(struct bitmap *bm) if(bm) { - bitmap = ami_getcachenativebm(bm, THUMBNAIL_WIDTH, + bitmap = ami_bitmap_get_native(bm, THUMBNAIL_WIDTH, THUMBNAIL_HEIGHT, NULL); bm->icondata = AllocVec(THUMBNAIL_WIDTH * 4 * THUMBNAIL_HEIGHT, MEMF_CLEAR); diff --git a/amiga/options.h b/amiga/options.h index 287b7ffc4..ed5bc93eb 100644 --- a/amiga/options.h +++ b/amiga/options.h @@ -49,6 +49,8 @@ int download_task_pri; \ bool faster_scroll; \ bool scale_quality; \ + int dither_quality; \ + int mask_alpha; \ bool ask_overwrite; \ int printer_unit; \ int print_scale; \ @@ -109,6 +111,8 @@ .download_task_pri = -1, \ .faster_scroll = true, \ .scale_quality = false, \ + .dither_quality = 1, \ + .mask_alpha = 0, \ .ask_overwrite = true, \ .printer_unit = 0, \ .print_scale = 100, \ @@ -168,6 +172,8 @@ { "download_task_pri", OPTION_INTEGER, &nsoptions.download_task_pri}, \ { "faster_scroll", OPTION_BOOL, &nsoptions.faster_scroll}, \ { "scale_quality", OPTION_BOOL, &nsoptions.scale_quality}, \ +{ "dither_quality", OPTION_INTEGER, &nsoptions.dither_quality}, \ +{ "mask_alpha", OPTION_INTEGER, &nsoptions.mask_alpha}, \ { "ask_overwrite", OPTION_BOOL, &nsoptions.ask_overwrite}, \ { "printer_unit", OPTION_INTEGER, &nsoptions.printer_unit}, \ { "print_scale", OPTION_INTEGER, &nsoptions.print_scale}, \ diff --git a/amiga/plotters.c b/amiga/plotters.c index c2a5c0b2e..f12ef1ae1 100755 --- a/amiga/plotters.c +++ b/amiga/plotters.c @@ -1,5 +1,5 @@ /* - * Copyright 2008,2009 Chris Young <chris@unsatisfactorysoftware.co.uk> + * Copyright 2008, 2009, 2012 Chris Young <chris@unsatisfactorysoftware.co.uk> * * This file is part of NetSurf, http://www.netsurf-browser.org/ * @@ -19,23 +19,29 @@ #include "amiga/plotters.h" #include "amiga/bitmap.h" #include "amiga/font.h" +#include "amiga/gui.h" +#include "amiga/utf8.h" + +#include "desktop/options.h" +#include "utils/utils.h" +#include "utils/log.h" + #include <proto/Picasso96API.h> +#include <proto/exec.h> +#include <proto/intuition.h> + #include <intuition/intuition.h> #include <graphics/rpattr.h> #include <graphics/gfxmacros.h> #include <graphics/gfxbase.h> -#include "amiga/utf8.h" -#include "desktop/options.h" + #ifdef __amigaos4__ #include <graphics/blitattr.h> #include <graphics/composite.h> #endif -#include "utils/log.h" + #include <math.h> #include <assert.h> -#include <proto/exec.h> -#include "amiga/gui.h" -#include "utils/utils.h" static void ami_bitmap_tile_hook(struct Hook *hook,struct RastPort *rp,struct BackFillMessage *bfmsg); @@ -45,8 +51,15 @@ struct bfbitmap { ULONG height; int offsetx; int offsety; + APTR mask; }; +struct ami_plot_pen { + struct MinNode node; + ULONG pen; +}; + +bool palette_mapped = false; #ifndef M_PI /* For some reason we don't always get this from math.h */ #define M_PI 3.14159265358979323846 @@ -118,20 +131,36 @@ void ami_init_layers(struct gui_globals *gg, ULONG width, ULONG height) /* init shared bitmaps * * Height is set to screen width to give enough space for thumbnails * * Also applies to the further gfx/layers functions and memory below */ - + + ULONG depth = 32; + struct DrawInfo *dri; struct BitMap *friend = NULL; /* Required to be NULL for Cairo and ARGB bitmaps */ + depth = GetBitMapAttr(scrn->RastPort.BitMap, BMA_DEPTH); + if((depth < 16) || (nsoption_int(cairo_renderer) == -1)) { + palette_mapped = true; + // friend = scrn->RastPort.BitMap; + } else { + palette_mapped = false; + } + if(nsoption_int(redraw_tile_size_x) <= 0) nsoption_set_int(redraw_tile_size_x, scrn->Width); if(nsoption_int(redraw_tile_size_y) <= 0) nsoption_set_int(redraw_tile_size_y, scrn->Height); if(!width) width = nsoption_int(redraw_tile_size_x); if(!height) height = nsoption_int(redraw_tile_size_y); gg->layerinfo = NewLayerInfo(); - gg->areabuf = AllocVec(100,MEMF_PRIVATE | MEMF_CLEAR); - gg->tmprasbuf = AllocVec(width*height,MEMF_PRIVATE | MEMF_CLEAR); - - gg->bm = p96AllocBitMap(width, height, 32, - BMF_INTERLEAVED, friend, RGBFB_A8R8G8B8); + gg->areabuf = AllocVec(100, MEMF_PRIVATE | MEMF_CLEAR); + gg->tmprasbuf = AllocVec(width * height, MEMF_PRIVATE | MEMF_CLEAR); + + if(palette_mapped == true) { + gg->bm = AllocBitMap(width, height, depth, + BMF_INTERLEAVED | BMF_DISPLAYABLE, friend); + } else { + gg->bm = p96AllocBitMap(width, height, 32, + BMF_INTERLEAVED | BMF_DISPLAYABLE, friend, RGBFB_A8R8G8B8); + } + if(!gg->bm) warn_user("NoMemory",""); gg->rp = AllocVec(sizeof(struct RastPort), MEMF_PRIVATE | MEMF_CLEAR); @@ -182,7 +211,11 @@ void ami_free_layers(struct gui_globals *gg) FreeVec(gg->tmprasbuf); FreeVec(gg->areabuf); DisposeLayerInfo(gg->layerinfo); - p96FreeBitMap(gg->bm); + if(palette_mapped == false) { + p96FreeBitMap(gg->bm); + } else { + FreeBitMap(gg->bm); + } } void ami_clearclipreg(struct gui_globals *gg) @@ -198,6 +231,70 @@ void ami_clearclipreg(struct gui_globals *gg) gg->rect.MaxY = scrn->Height-1; } +static ULONG ami_plot_obtain_pen(struct MinList *shared_pens, ULONG colour) +{ + struct ami_plot_pen *node; + ULONG pen = ObtainBestPenA(scrn->ViewPort.ColorMap, + (colour & 0x000000ff) << 24, + (colour & 0x0000ff00) << 16, + (colour & 0x00ff0000) << 8, + NULL); + + if(pen == -1) LOG(("WARNING: Cannot allocate pen for ABGR:%lx", colour)); + + if(shared_pens != NULL) { + if(node = (struct ami_plot_pen *)AllocVec(sizeof(struct ami_plot_pen), + MEMF_PRIVATE | MEMF_CLEAR)) { + AddTail((struct List *)shared_pens, (struct Node *)node); + } + } else { + /* Immediately release the pen if we can't keep track of it. */ + ReleasePen(scrn->ViewPort.ColorMap, pen); + } + return pen; +} + +void ami_plot_release_pens(struct MinList *shared_pens) +{ + struct ami_plot_pen *node; + struct ami_plot_pen *nnode; + + if(IsMinListEmpty(shared_pens)) return; + node = (struct ami_plot_pen *)GetHead((struct List *)shared_pens); + + do + { + nnode = (struct ami_plot_pen *)GetSucc((struct Node *)node); + ReleasePen(scrn->ViewPort.ColorMap, node->pen); + Remove((struct Node *)node); + FreeVec(node); + }while(node = nnode); +} + +static void ami_plot_setapen(ULONG colour) +{ + if(palette_mapped == false) { + SetRPAttrs(glob->rp, RPTAG_APenColor, + p96EncodeColor(RGBFB_A8B8G8R8, colour), + TAG_DONE); + } else { + ULONG pen = ami_plot_obtain_pen(glob->shared_pens, colour); + if(pen != -1) SetAPen(glob->rp, pen); + } +} + +static void ami_plot_setopen(ULONG colour) +{ + if(palette_mapped == false) { + SetRPAttrs(glob->rp, RPTAG_OPenColor, + p96EncodeColor(RGBFB_A8B8G8R8, colour), + TAG_DONE); + } else { + ULONG pen = ami_plot_obtain_pen(glob->shared_pens, colour); + if(pen != -1) SetOPen(glob->rp, pen); + } +} + bool ami_rectangle(int x0, int y0, int x1, int y1, const plot_style_t *style) { #ifdef AMI_PLOTTER_DEBUG @@ -206,11 +303,10 @@ bool ami_rectangle(int x0, int y0, int x1, int y1, const plot_style_t *style) if (style->fill_type != PLOT_OP_TYPE_NONE) { - if(nsoption_int(cairo_renderer) < 2) + if((nsoption_int(cairo_renderer) < 2) || + (palette_mapped == true)) { - SetRPAttrs(glob->rp, RPTAG_APenColor, - p96EncodeColor(RGBFB_A8B8G8R8, style->fill_colour), - TAG_DONE); + ami_plot_setapen(style->fill_colour); RectFill(glob->rp, x0, y0, x1-1, y1-1); } else @@ -228,7 +324,8 @@ bool ami_rectangle(int x0, int y0, int x1, int y1, const plot_style_t *style) } if (style->stroke_type != PLOT_OP_TYPE_NONE) { - if(nsoption_int(cairo_renderer) < 2) + if((nsoption_int(cairo_renderer) < 2) || + (palette_mapped == true)) { glob->rp->PenWidth = style->stroke_width; glob->rp->PenHeight = style->stroke_width; @@ -248,10 +345,7 @@ bool ami_rectangle(int x0, int y0, int x1, int y1, const plot_style_t *style) break; } - SetRPAttrs(glob->rp, - RPTAG_APenColor, - p96EncodeColor(RGBFB_A8B8G8R8, style->stroke_colour), - TAG_DONE); + ami_plot_setapen(style->stroke_colour); Move(glob->rp, x0,y0); Draw(glob->rp, x1, y0); Draw(glob->rp, x1, y1); @@ -267,25 +361,25 @@ bool ami_rectangle(int x0, int y0, int x1, int y1, const plot_style_t *style) #ifdef NS_AMIGA_CAIRO ami_cairo_set_colour(glob->cr, style->stroke_colour); - switch (style->stroke_type) { - case PLOT_OP_TYPE_SOLID: /**< Solid colour */ - default: - ami_cairo_set_solid(glob->cr); - break; + switch (style->stroke_type) { + case PLOT_OP_TYPE_SOLID: /**< Solid colour */ + default: + ami_cairo_set_solid(glob->cr); + break; - case PLOT_OP_TYPE_DOT: /**< Doted plot */ - ami_cairo_set_dotted(glob->cr); - break; + case PLOT_OP_TYPE_DOT: /**< Doted plot */ + ami_cairo_set_dotted(glob->cr); + break; - case PLOT_OP_TYPE_DASH: /**< dashed plot */ - ami_cairo_set_dashed(glob->cr); - break; - } + case PLOT_OP_TYPE_DASH: /**< dashed plot */ + ami_cairo_set_dashed(glob->cr); + break; + } - if (style->stroke_width == 0) - cairo_set_line_width(glob->cr, 1); - else - cairo_set_line_width(glob->cr, style->stroke_width); + if (style->stroke_width == 0) + cairo_set_line_width(glob->cr, 1); + else + cairo_set_line_width(glob->cr, style->stroke_width); cairo_rectangle(glob->cr, x0, y0, x1 - x0, y1 - y0); cairo_stroke(glob->cr); @@ -301,7 +395,7 @@ bool ami_line(int x0, int y0, int x1, int y1, const plot_style_t *style) LOG(("[ami_plotter] Entered ami_line()")); #endif - if(nsoption_int(cairo_renderer) < 2) + if((nsoption_int(cairo_renderer) < 2) || (palette_mapped == true)) { glob->rp->PenWidth = style->stroke_width; glob->rp->PenHeight = style->stroke_width; @@ -321,10 +415,7 @@ bool ami_line(int x0, int y0, int x1, int y1, const plot_style_t *style) break; } - SetRPAttrs(glob->rp, - RPTAG_APenColor, - p96EncodeColor(RGBFB_A8B8G8R8, style->stroke_colour), - TAG_DONE); + ami_plot_setapen(style->stroke_colour); Move(glob->rp,x0,y0); Draw(glob->rp,x1,y1); @@ -337,25 +428,25 @@ bool ami_line(int x0, int y0, int x1, int y1, const plot_style_t *style) #ifdef NS_AMIGA_CAIRO ami_cairo_set_colour(glob->cr, style->stroke_colour); - switch (style->stroke_type) { - case PLOT_OP_TYPE_SOLID: /**< Solid colour */ - default: - ami_cairo_set_solid(glob->cr); - break; - - case PLOT_OP_TYPE_DOT: /**< Doted plot */ - ami_cairo_set_dotted(glob->cr); - break; - - case PLOT_OP_TYPE_DASH: /**< dashed plot */ - ami_cairo_set_dashed(glob->cr); - break; - } + switch (style->stroke_type) { + case PLOT_OP_TYPE_SOLID: /**< Solid colour */ + default: + ami_cairo_set_solid(glob->cr); + break; + + case PLOT_OP_TYPE_DOT: /**< Doted plot */ + ami_cairo_set_dotted(glob->cr); + break; + + case PLOT_OP_TYPE_DASH: /**< dashed plot */ + ami_cairo_set_dashed(glob->cr); + break; + } - if (style->stroke_width == 0) - cairo_set_line_width(glob->cr, 1); - else - cairo_set_line_width(glob->cr, style->stroke_width); + if (style->stroke_width == 0) + cairo_set_line_width(glob->cr, 1); + else + cairo_set_line_width(glob->cr, style->stroke_width); /* core expects horizontal and vertical lines to be on pixels, not * between pixels */ @@ -377,17 +468,12 @@ bool ami_polygon(const int *p, unsigned int n, const plot_style_t *style) int k; - if(nsoption_int(cairo_renderer) < 1) + if((nsoption_int(cairo_renderer) < 1) || (palette_mapped == true)) { ULONG cx,cy; - SetRPAttrs(glob->rp, - RPTAG_APenColor, - p96EncodeColor(RGBFB_A8B8G8R8, style->fill_colour), - RPTAG_OPenColor, - p96EncodeColor(RGBFB_A8B8G8R8, style->fill_colour), -// RPTAG_OPenColor,0xffffffff, - TAG_DONE); + ami_plot_setapen(style->fill_colour); + ami_plot_setopen(style->fill_colour); AreaMove(glob->rp,p[0],p[1]); @@ -443,7 +529,7 @@ bool ami_clip(const struct rect *clip) } #ifdef NS_AMIGA_CAIRO - if(nsoption_int(cairo_renderer) == 2) + if((nsoption_int(cairo_renderer) == 2) && (palette_mapped == false)) { cairo_reset_clip(glob->cr); cairo_rectangle(glob->cr, clip->x0, clip->y0, @@ -462,7 +548,9 @@ bool ami_text(int x, int y, const char *text, size_t length, LOG(("[ami_plotter] Entered ami_text()")); #endif - ami_unicode_text(glob->rp,text,length,fstyle,x,y); + ami_plot_setapen(fstyle->foreground); + ami_unicode_text(glob->rp, text, length, fstyle, x, y, !palette_mapped); + return true; } @@ -472,23 +560,16 @@ bool ami_disc(int x, int y, int radius, const plot_style_t *style) LOG(("[ami_plotter] Entered ami_disc()")); #endif - if(nsoption_int(cairo_renderer) < 2) + if((nsoption_int(cairo_renderer) < 2) || (palette_mapped == true)) { if (style->fill_type != PLOT_OP_TYPE_NONE) { - SetRPAttrs(glob->rp, - RPTAG_APenColor, - p96EncodeColor(RGBFB_A8B8G8R8, style->fill_colour), - TAG_DONE); + ami_plot_setapen(style->fill_colour); AreaCircle(glob->rp,x,y,radius); AreaEnd(glob->rp); } if (style->stroke_type != PLOT_OP_TYPE_NONE) { - SetRPAttrs(glob->rp, - RPTAG_APenColor, - p96EncodeColor(RGBFB_A8B8G8R8, style->stroke_colour), - TAG_DONE); - + ami_plot_setapen(style->stroke_colour); DrawEllipse(glob->rp,x,y,radius,radius); } } @@ -525,8 +606,12 @@ bool ami_arc(int x, int y, int radius, int angle1, int angle2, const plot_style_ LOG(("[ami_plotter] Entered ami_arc()")); #endif - if(nsoption_int(cairo_renderer) >= 1) - { + if((nsoption_int(cairo_renderer) <= 0) || (palette_mapped == true)) { + /* TODO: gfx.lib plotter needs arc support */ + /* eg. http://www.crbond.com/primitives.htm CommonFuncsPPC.lha */ + ami_plot_setapen(style->fill_colour); + /* DrawArc(glob->rp,x,y,(float)angle1,(float)angle2,radius); */ + } else { #ifdef NS_AMIGA_CAIRO ami_cairo_set_colour(glob->cr, style->fill_colour); ami_cairo_set_solid(glob->cr); @@ -538,19 +623,7 @@ bool ami_arc(int x, int y, int radius, int angle1, int angle2, const plot_style_ cairo_stroke(glob->cr); #endif } - else - { - /* TODO: gfx.lib plotter needs arc support */ -/* http://www.crbond.com/primitives.htm -CommonFuncsPPC.lha */ - - SetRPAttrs(glob->rp, - RPTAG_APenColor, - p96EncodeColor(RGBFB_A8B8G8R8, style->fill_colour), - TAG_DONE); - -// DrawArc(glob->rp,x,y,(float)angle1,(float)angle2,radius); - } + return true; } @@ -570,15 +643,14 @@ static bool ami_bitmap(int x, int y, int width, int height, struct bitmap *bitma (y > glob->rect.MaxY)) return true; - tbm = ami_getcachenativebm(bitmap,width,height,glob->rp->BitMap); - + tbm = ami_bitmap_get_native(bitmap, width, height, glob->rp->BitMap); if(!tbm) return true; #ifdef AMI_PLOTTER_DEBUG LOG(("[ami_plotter] ami_bitmap() got native bitmap")); #endif - if(GfxBase->LibNode.lib_Version >= 53) // AutoDoc says v52, but this function isn't in OS4.0, so checking for v53 (OS4.1) + if((GfxBase->LibNode.lib_Version >= 53) && (palette_mapped == false)) { uint32 comptype = COMPOSITE_Src; if(!bitmap->opaque) @@ -598,6 +670,18 @@ static bool ami_bitmap(int x, int y, int width, int height, struct bitmap *bitma } else { + ULONG tag, tag_data, minterm = 0xc0; + + if(palette_mapped == false) { + tag = BLITA_UseSrcAlpha; + tag_data = !bitmap->opaque; + minterm = 0xc0; + } else { + tag = BLITA_MaskPlane; + if(tag_data = (ULONG)ami_bitmap_get_mask(bitmap, width, height)) + minterm = (ABC|ABNC|ANBC); + } + BltBitMapTags(BLITA_Width,width, BLITA_Height,height, BLITA_Source,tbm, @@ -606,12 +690,12 @@ static bool ami_bitmap(int x, int y, int width, int height, struct bitmap *bitma BLITA_DestY,y, BLITA_SrcType,BLITT_BITMAP, BLITA_DestType,BLITT_RASTPORT, -// BLITA_Mask,0xFF, - BLITA_UseSrcAlpha,!bitmap->opaque, + BLITA_Minterm, minterm, + tag, tag_data, TAG_DONE); } - if(tbm != bitmap->nativebm) + if((bitmap->dto == NULL) && (tbm != bitmap->nativebm)) { p96FreeBitMap(tbm); } @@ -643,8 +727,7 @@ bool ami_bitmap_tile(int x, int y, int width, int height, if((bitmap->opaque == false) && (bitmap->width == 1) && (bitmap->height == 1)) return true; - tbm = ami_getcachenativebm(bitmap,width,height,glob->rp->BitMap); - + tbm = ami_bitmap_get_native(bitmap,width,height,glob->rp->BitMap); if(!tbm) return true; ox = x; @@ -699,6 +782,7 @@ bool ami_bitmap_tile(int x, int y, int width, int height, bfbm.height = height; bfbm.offsetx = ox; bfbm.offsety = oy; + bfbm.mask = ami_bitmap_get_mask(bitmap, width, height);; bfh = AllocVec(sizeof(struct Hook),MEMF_CLEAR); bfh->h_Entry = (HOOKFUNC)ami_bitmap_tile_hook; bfh->h_SubEntry = 0; @@ -713,7 +797,7 @@ bool ami_bitmap_tile(int x, int y, int width, int height, if(bitmap->opaque) DeleteBackFillHook(bfh); else FreeVec(bfh); - if(tbm != bitmap->nativebm) + if((bitmap->dto == NULL) && (tbm != bitmap->nativebm)) { p96FreeBitMap(tbm); } @@ -730,9 +814,9 @@ static void ami_bitmap_tile_hook(struct Hook *hook,struct RastPort *rp,struct Ba for (xf = -bfbm->offsetx; xf < bfmsg->Bounds.MaxX; xf += bfbm->width) { for (yf = -bfbm->offsety; yf < bfmsg->Bounds.MaxY; yf += bfbm->height) { - if(GfxBase->LibNode.lib_Version >= 53) // AutoDoc says v52, but this function isn't in OS4.0, so checking for v53 (OS4.1) + if((GfxBase->LibNode.lib_Version >= 53) && (palette_mapped == false)) { - CompositeTags(COMPOSITE_Src_Over_Dest,bfbm->bm,rp->BitMap, + CompositeTags(COMPOSITE_Src_Over_Dest,bfbm->bm, rp->BitMap, COMPTAG_Flags,COMPFLAG_IgnoreDestAlpha, COMPTAG_DestX,bfmsg->Bounds.MinX, COMPTAG_DestY,bfmsg->Bounds.MinY, @@ -746,17 +830,30 @@ static void ami_bitmap_tile_hook(struct Hook *hook,struct RastPort *rp,struct Ba } else { - BltBitMapTags(BLITA_Width,bfbm->width, - BLITA_Height,bfbm->height, - BLITA_Source,bfbm->bm, - BLITA_Dest,rp, - BLITA_DestX,xf, - BLITA_DestY,yf, - BLITA_SrcType,BLITT_BITMAP, - BLITA_DestType,BLITT_RASTPORT, - BLITA_UseSrcAlpha,TRUE, + ULONG tag, tag_data, minterm = 0xc0; + + if(palette_mapped == false) { + tag = BLITA_UseSrcAlpha; + tag_data = TRUE; + minterm = 0xc0; + } else { + tag = BLITA_MaskPlane; + if(tag_data = (ULONG)bfbm->mask) + minterm = (ABC|ABNC|ANBC); + } + + BltBitMapTags(BLITA_Width, bfbm->width, + BLITA_Height, bfbm->height, + BLITA_Source, bfbm->bm, + BLITA_Dest, rp, + BLITA_DestX, xf, + BLITA_DestY, yf, + BLITA_SrcType, BLITT_BITMAP, + BLITA_DestType, BLITT_RASTPORT, + BLITA_Minterm, minterm, + tag, tag_data, TAG_DONE); - } + } } } } @@ -801,7 +898,7 @@ bool ami_path(const float *p, unsigned int n, colour fill, float width, /* We should probably check if the off-screen bitmap is 32-bit and render * using Cairo regardless if it is. For now, we respect user preferences. */ - if(nsoption_int(cairo_renderer) >= 1) + if((nsoption_int(cairo_renderer) >= 1) && (palette_mapped == false)) { unsigned int i; cairo_matrix_t old_ctm, n_ctm; @@ -880,3 +977,8 @@ bool ami_path(const float *p, unsigned int n, colour fill, float width, #endif return true; } + +bool ami_plot_screen_is_palettemapped(void) +{ + return palette_mapped; +} diff --git a/amiga/plotters.h b/amiga/plotters.h index c3f816dca..db767b60a 100755 --- a/amiga/plotters.h +++ b/amiga/plotters.h @@ -33,6 +33,7 @@ struct gui_globals APTR areabuf; APTR tmprasbuf; struct Rectangle rect; + struct MinList *shared_pens; #ifdef NS_AMIGA_CAIRO cairo_surface_t *surface; cairo_t *cr; @@ -63,6 +64,8 @@ bool ami_path(const float *p, unsigned int n, colour fill, float width, void ami_init_layers(struct gui_globals *gg, ULONG width, ULONG height); void ami_free_layers(struct gui_globals *gg); void ami_clearclipreg(struct gui_globals *gg); +void ami_plot_release_pens(struct MinList *shared_pens); +bool ami_plot_screen_is_palettemapped(void); struct gui_globals *glob; #endif diff --git a/amiga/theme.c b/amiga/theme.c index 1bcd6a7be..7415d7777 100644 --- a/amiga/theme.c +++ b/amiga/theme.c @@ -25,7 +25,6 @@ #include <proto/graphics.h> #include <proto/icon.h> #include <proto/intuition.h> -#include <proto/Picasso96API.h> #include <gadgets/clicktab.h> #include <gadgets/space.h> @@ -35,6 +34,7 @@ #include <intuition/pointerclass.h> #include <workbench/icon.h> +#include "amiga/bitmap.h" #include "amiga/drag.h" #include "desktop/options.h" #include "amiga/theme.h" @@ -43,6 +43,7 @@ #include "utils/utils.h" struct BitMap *throbber = NULL; +struct bitmap *throbber_nsbm = NULL; ULONG throbber_frames,throbber_update_interval; static Object *mouseptrobj[AMI_LASTPOINTER+1]; static struct BitMap *mouseptrbm[AMI_LASTPOINTER+1]; @@ -131,53 +132,25 @@ void ami_theme_throbber_setup(void) { char throbberfile[1024]; Object *dto; + struct bitmap *bm; ami_get_theme_filename(throbberfile,"theme_throbber",false); throbber_frames=atoi(messages_get("theme_throbber_frames")); throbber_update_interval = atoi(messages_get("theme_throbber_delay")); if(throbber_update_interval == 0) throbber_update_interval = 100; - if(dto = NewDTObject(throbberfile, - DTA_GroupID,GID_PICTURE, - PDTA_DestMode,PMODE_V43, - TAG_DONE)) - { - struct BitMapHeader *throbber_bmh; - struct RastPort throbber_rp; - - if(GetDTAttrs(dto,PDTA_BitMapHeader,&throbber_bmh,TAG_DONE)) - { - throbber_width = throbber_bmh->bmh_Width / throbber_frames; - throbber_height = throbber_bmh->bmh_Height; - - InitRastPort(&throbber_rp); - - if(throbber = p96AllocBitMap(throbber_bmh->bmh_Width, - throbber_height,32, - BMF_CLEAR | BMF_DISPLAYABLE | BMF_INTERLEAVED, - NULL,RGBFB_A8R8G8B8)) - { - struct RenderInfo ri; - UBYTE *throbber_tempmem = AllocVec(throbber_bmh->bmh_Width*throbber_height*4,MEMF_PRIVATE | MEMF_CLEAR); - throbber_rp.BitMap = throbber; - ri.Memory = throbber_tempmem; - ri.BytesPerRow = 4*throbber_bmh->bmh_Width; - ri.RGBFormat = RGBFB_A8R8G8B8; - - IDoMethod(dto,PDTM_READPIXELARRAY,ri.Memory,PBPAFMT_ARGB,ri.BytesPerRow,0,0,throbber_bmh->bmh_Width,throbber_height); - - p96WritePixelArray((struct RenderInfo *)&ri,0,0,&throbber_rp,0,0,throbber_bmh->bmh_Width,throbber_height); - - FreeVec(throbber_tempmem); - } - } - DisposeDTObject(dto); - } + bm = ami_bitmap_from_datatype(throbberfile); + throbber = ami_bitmap_get_native(bm, bm->width, bm->height, NULL); + + throbber_width = bm->width / throbber_frames; + throbber_height = bm->height; + throbber_nsbm = bm; } void ami_theme_throbber_free(void) { - p96FreeBitMap(throbber); + bitmap_destroy(throbber_nsbm); + throbber = NULL; } void ami_get_theme_filename(char *filename, char *themestring, bool protocol) diff --git a/amiga/tree.c b/amiga/tree.c index 0ec527ec7..da7e303bb 100755 --- a/amiga/tree.c +++ b/amiga/tree.c @@ -98,6 +98,7 @@ struct treeview_window { char *sslerr; char *sslaccept; char *sslreject; + struct MinList shared_pens; }; void ami_tree_draw(struct treeview_window *twin); @@ -130,8 +131,11 @@ struct treeview_window *ami_tree_create(uint8 flags, } twin->ssl_data = ssl_data; - twin->tree = tree_create(flags, &ami_tree_callbacks, twin); + + NewMinList(&twin->shared_pens); + twin->globals.shared_pens = &twin->shared_pens; + return twin; } @@ -666,6 +670,7 @@ void ami_tree_close(struct treeview_window *twin) DisposeObject(twin->objects[OID_MAIN]); DelObjectNoFree(twin->node); ami_free_layers(&twin->globals); + ami_plot_release_pens(&twin->shared_pens); for(i=0;i<AMI_TREE_MENU_ITEMS;i++) { |