From 4b2ac84233dc464567d1c0b1a500f7ce38a8b3cd Mon Sep 17 00:00:00 2001 From: Chris Young Date: Tue, 22 Mar 2016 19:26:36 +0000 Subject: Make struct bitmap private to bitmap.c --- amiga/bitmap.c | 51 ++++++++++++++++++++++++++++++++++++++++++++++++--- amiga/bitmap.h | 27 +++++++++++---------------- amiga/ctxmenu.c | 4 ++-- amiga/file.c | 4 ++-- amiga/gui.c | 2 +- amiga/icon.c | 13 +++++++++---- amiga/menu.c | 4 ++-- amiga/plotters.c | 15 +++++++++------ amiga/theme.c | 6 +++--- 9 files changed, 87 insertions(+), 39 deletions(-) (limited to 'amiga') diff --git a/amiga/bitmap.c b/amiga/bitmap.c index bc85afb36..ba72b11cf 100644 --- a/amiga/bitmap.c +++ b/amiga/bitmap.c @@ -35,6 +35,7 @@ #include "assert.h" #include "utils/nsoption.h" +#include "utils/nsurl.h" #include "utils/messages.h" #include "desktop/mouse.h" #include "desktop/gui_window.h" @@ -46,6 +47,22 @@ #include "amiga/misc.h" #include "amiga/rtg.h" +struct bitmap { + int width; + int height; + UBYTE *pixdata; + bool opaque; + int native; + struct BitMap *nativebm; + int nativebmwidth; + int nativebmheight; + PLANEPTR native_mask; + Object *dto; + struct nsurl *url; /* temporary storage space */ + const char *title; /* temporary storage space */ + ULONG *icondata; /* for appicons */ +}; + enum { AMI_NSBM_NONE = 0, AMI_NSBM_TRUECOLOUR, @@ -218,7 +235,7 @@ bool amiga_bitmap_get_opaque(void *bitmap) /** * get width of a bitmap. */ -static int bitmap_get_width(void *bitmap) +int bitmap_get_width(void *bitmap) { struct bitmap *bm = bitmap; @@ -235,7 +252,7 @@ static int bitmap_get_width(void *bitmap) /** * get height of a bitmap. */ -static int bitmap_get_height(void *bitmap) +int bitmap_get_height(void *bitmap) { struct bitmap *bm = bitmap; @@ -315,7 +332,7 @@ Object *ami_datatype_object_from_bitmap(struct bitmap *bitmap) } SetDTAttrs(dto,NULL,NULL, - DTA_ObjName,bitmap->url, + DTA_ObjName,nsurl_access(bitmap->url), DTA_ObjAnnotation,bitmap->title, DTA_ObjAuthor,messages_get("NetSurf"), DTA_NominalHoriz,bitmap_get_width(bitmap), @@ -625,6 +642,34 @@ static nserror bitmap_render(struct bitmap *bitmap, hlcache_handle *content) return NSERROR_OK; } +void ami_bitmap_set_url(struct bitmap *bm, struct nsurl *url) +{ + bm->url = url; +} + +void ami_bitmap_set_title(struct bitmap *bm, const char *title) +{ + bm->title = title; +} + +ULONG *ami_bitmap_get_icondata(struct bitmap *bm) +{ + return bm->icondata; +} + +bool ami_bitmap_has_dto(struct bitmap *bm) +{ + if(bm->dto) return true; + else return false; +} + +bool ami_bitmap_is_nativebm(struct bitmap *bm, struct BitMap *nbm) +{ + if(bm->nativebm == nbm) return true; + else return false; +} + + static struct gui_bitmap_table bitmap_table = { .create = amiga_bitmap_create, .destroy = amiga_bitmap_destroy, diff --git a/amiga/bitmap.h b/amiga/bitmap.h index 78d6c0d68..cb7f968a1 100755 --- a/amiga/bitmap.h +++ b/amiga/bitmap.h @@ -29,22 +29,8 @@ #define AMI_BITMAP_SCALE_ICON 0xFF struct gui_bitmap_table *amiga_bitmap_table; - -struct bitmap { - int width; - int height; - UBYTE *pixdata; - bool opaque; - int native; - 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; +struct nsurl; struct BitMap *ami_bitmap_get_native(struct bitmap *bitmap, int width, int height, struct BitMap *friendbm); @@ -54,6 +40,15 @@ PLANEPTR ami_bitmap_get_mask(struct bitmap *bitmap, int width, Object *ami_datatype_object_from_bitmap(struct bitmap *bitmap); struct bitmap *ami_bitmap_from_datatype(char *filename); +void ami_bitmap_set_url(struct bitmap *bm, struct nsurl *url); +void ami_bitmap_set_title(struct bitmap *bm, const char *title); +ULONG *ami_bitmap_get_icondata(struct bitmap *bm); +bool ami_bitmap_has_dto(struct bitmap *bm); +bool ami_bitmap_is_nativebm(struct bitmap *bm, struct BitMap *nbm); + +int bitmap_get_width(void *bitmap); +int bitmap_get_height(void *bitmap); + /** * Cleanup bitmap allocations */ diff --git a/amiga/ctxmenu.c b/amiga/ctxmenu.c index 8d49d4f15..b49ba8066 100644 --- a/amiga/ctxmenu.c +++ b/amiga/ctxmenu.c @@ -212,8 +212,8 @@ HOOKF(void, ami_ctxmenu_item_objcopy, APTR, window, struct IntuiMessage *) struct hlcache_handle *object = (struct hlcache_handle *)hook->h_Data; if((bm = content_get_bitmap(object))) { - bm->url = (char *)nsurl_access(hlcache_handle_get_url(object)); - bm->title = (char *)content_get_title(object); + ami_bitmap_set_url(bm, hlcache_handle_get_url(object)); + ami_bitmap_set_title(bm, content_get_title(object)); ami_easy_clipboard_bitmap(bm); } #ifdef WITH_NS_SVG diff --git a/amiga/file.c b/amiga/file.c index 8e81b9c28..d26b4be49 100644 --- a/amiga/file.c +++ b/amiga/file.c @@ -182,8 +182,8 @@ void ami_file_save(int type, char *fname, struct Window *win, case AMINS_SAVE_IFF: if((bm = content_get_bitmap(object))) { - bm->url = (char *)nsurl_access(hlcache_handle_get_url(object)); - bm->title = (char *)content_get_title(object); + ami_bitmap_set_url(bm, hlcache_handle_get_url(object)); + ami_bitmap_set_title(bm, content_get_title(object)); amiga_bitmap_save(bm, fname, 0); } #ifdef WITH_NS_SVG diff --git a/amiga/gui.c b/amiga/gui.c index 2b8e38a07..ec767352e 100644 --- a/amiga/gui.c +++ b/amiga/gui.c @@ -1772,7 +1772,7 @@ static void gui_window_set_icon(struct gui_window *g, hlcache_handle *icon) if(ami_plot_screen_is_palettemapped() == false) { tag = BLITA_UseSrcAlpha; - tag_data = !icon_bitmap->opaque; + tag_data = !amiga_bitmap_get_opaque(icon_bitmap); minterm = 0xc0; } else { tag = BLITA_MaskPlane; diff --git a/amiga/icon.c b/amiga/icon.c index f77f2eb6e..0ef3dbb12 100644 --- a/amiga/icon.c +++ b/amiga/icon.c @@ -493,12 +493,16 @@ struct DiskObject *amiga_icon_from_bitmap(struct bitmap *bm) { struct DiskObject *dobj; struct BitMap *bitmap; + ULONG *icondata; + #ifdef __amigaos4__ if(bm) { + icondata = ami_bitmap_get_icondata(bm); + bitmap = ami_bitmap_get_native(bm, THUMBNAIL_WIDTH, THUMBNAIL_HEIGHT, NULL); - bm->icondata = AllocVecTagList(THUMBNAIL_WIDTH * 4 * THUMBNAIL_HEIGHT, NULL); + icondata = AllocVecTagList(THUMBNAIL_WIDTH * 4 * THUMBNAIL_HEIGHT, NULL); BltBitMapTags(BLITA_Width, THUMBNAIL_WIDTH, BLITA_Height, THUMBNAIL_HEIGHT, @@ -506,7 +510,7 @@ struct DiskObject *amiga_icon_from_bitmap(struct bitmap *bm) BLITA_Source, bitmap, BLITA_DestType, BLITT_ARGB32, BLITA_DestBytesPerRow, THUMBNAIL_WIDTH * 4, - BLITA_Dest, bm->icondata, + BLITA_Dest, icondata, TAG_DONE); } #endif @@ -520,7 +524,7 @@ struct DiskObject *amiga_icon_from_bitmap(struct bitmap *bm) ICONCTRLA_SetImageDataFormat, IDFMT_DIRECTMAPPED, ICONCTRLA_SetWidth, THUMBNAIL_WIDTH, ICONCTRLA_SetHeight, THUMBNAIL_HEIGHT, - ICONCTRLA_SetImageData1, bm->icondata, + ICONCTRLA_SetImageData1, icondata, ICONCTRLA_SetImageData2, NULL, TAG_DONE); } @@ -537,5 +541,6 @@ void amiga_icon_free(struct DiskObject *dobj) struct bitmap *bm = dobj->do_Gadget.UserData; FreeDiskObject(dobj); - if(bm) FreeVec(bm->icondata); + if(bm) FreeVec(ami_bitmap_get_icondata(bm)); } + diff --git a/amiga/menu.c b/amiga/menu.c index 646039a30..f851e441c 100644 --- a/amiga/menu.c +++ b/amiga/menu.c @@ -260,8 +260,8 @@ HOOKF(void, ami_menu_item_edit_copy, APTR, window, struct IntuiMessage *) * the objects containing the values returned (and the * constness cast away) is safe. */ - bm->url = (char *)nsurl_access(browser_window_get_url(gwin->gw->bw)); - bm->title = (char *)browser_window_get_title(gwin->gw->bw); + ami_bitmap_set_url(bm, browser_window_get_url(gwin->gw->bw)); + ami_bitmap_set_title(bm, browser_window_get_title(gwin->gw->bw)); ami_easy_clipboard_bitmap(bm); } #ifdef WITH_NS_SVG diff --git a/amiga/plotters.c b/amiga/plotters.c index e9293086f..8d59f8193 100644 --- a/amiga/plotters.c +++ b/amiga/plotters.c @@ -581,7 +581,7 @@ static bool ami_bitmap(int x, int y, int width, int height, struct bitmap *bitma if(glob->palette_mapped == false) { tag = BLITA_UseSrcAlpha; - tag_data = !bitmap->opaque; + tag_data = !amiga_bitmap_get_opaque(bitmap); minterm = 0xc0; } else { tag = BLITA_MaskPlane; @@ -609,7 +609,8 @@ static bool ami_bitmap(int x, int y, int width, int height, struct bitmap *bitma #endif } - if((bitmap->dto == NULL) && (tbm != bitmap->nativebm)) { + if((ami_bitmap_has_dto(bitmap) == false) && (ami_bitmap_is_nativebm(bitmap, tbm) == false)) { + /**\todo is this logic logical? */ ami_rtg_freebitmap(tbm); } @@ -637,7 +638,8 @@ static bool ami_bitmap_tile(int x, int y, int width, int height, return ami_bitmap(x, y, width, height, bitmap); /* If it is a one pixel transparent image, we are wasting our time */ - if((bitmap->opaque == false) && (bitmap->width == 1) && (bitmap->height == 1)) + if((amiga_bitmap_get_opaque(bitmap) == false) && + (bitmap_get_width(bitmap) == 1) && (bitmap_get_height(bitmap) == 1)) return true; tbm = ami_bitmap_get_native(bitmap,width,height,glob->rp->BitMap); @@ -679,7 +681,7 @@ static bool ami_bitmap_tile(int x, int y, int width, int height, ym = y; } #ifdef __amigaos4__ - if(bitmap->opaque) + if(amiga_bitmap_get_opaque(bitmap)) { bfh = CreateBackFillHook(BFHA_BitMap,tbm, BFHA_Width,width, @@ -708,12 +710,13 @@ static bool ami_bitmap_tile(int x, int y, int width, int height, InstallLayerHook(glob->rp->Layer,LAYERS_NOBACKFILL); #ifdef __amigaos4__ - if(bitmap->opaque) DeleteBackFillHook(bfh); + if(amiga_bitmap_get_opaque(bitmap)) DeleteBackFillHook(bfh); else #endif FreeVec(bfh); - if((bitmap->dto == NULL) && (tbm != bitmap->nativebm)) { + if((ami_bitmap_has_dto(bitmap) == false) && (ami_bitmap_is_nativebm(bitmap, tbm) == false)) { + /**\todo is this logic logical? */ ami_rtg_freebitmap(tbm); } diff --git a/amiga/theme.c b/amiga/theme.c index 6a0d5dac0..97b6bab4f 100644 --- a/amiga/theme.c +++ b/amiga/theme.c @@ -167,10 +167,10 @@ void ami_theme_throbber_setup(void) if(throbber_update_interval == 0) throbber_update_interval = 250; bm = ami_bitmap_from_datatype(throbberfile); - throbber = ami_bitmap_get_native(bm, bm->width, bm->height, NULL); + throbber = ami_bitmap_get_native(bm, bitmap_get_width(bm), bitmap_get_height(bm), NULL); - throbber_width = bm->width / throbber_frames; - throbber_height = bm->height; + throbber_width = bitmap_get_width(bm) / throbber_frames; + throbber_height = bitmap_get_height(bm); throbber_nsbm = bm; } -- cgit v1.2.3